Validate ICU branch keys where the macro is transformed - #80
Conversation
🦋 Changeset detectedLatest commit: 537dfd2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 54 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
WalkthroughThe change validates ICU branch keys during JavaScript and JSX transformation. It formats numeric plural and ordinal keys as ICU exact-value cases, rejects unsupported ChangesICU branch key handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.changeset/hungry-pugs-repeat.md:
- Line 7: Update the changeset entry to include ordinal branch keys alongside
select and plural branches, accurately documenting that the build now fails for
ICU-invalid ordinal keys before format time.
In `@packages/config/src/features/messages/identifier.ts`:
- Around line 21-23: Update getBranchCase in
packages/config/src/features/messages/identifier.ts:21-23 to apply exact-value
formatting only when the identifier string contains decimal digits, preserving
non-digit, whitespace-only, and signed numeric-like strings without coercing
them to =0 or another numeric case. Add regression tests covering empty,
whitespace-only, and signed numeric-like branch keys in
packages/config/src/features/messages/identifier.test.ts:187-232.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 37847bc3-353b-4aca-a58a-47bbae73b9cd
📒 Files selected for processing (10)
.changeset/hungry-pugs-repeat.mdpackages/config/src/features/messages/convert.tspackages/config/src/features/messages/identifier.test.tspackages/config/src/features/messages/identifier.tspackages/transform-js/src/index.test.tspackages/transform-js/src/parser.test.tspackages/transform-js/src/parser.tspackages/transform-jsx/src/index.test.tspackages/transform-jsx/src/parser.tswebsite/content/core-concepts/messages.mdx
@saykit/config
@saykit/format-json
@saykit/format-po
saykit
@saykit/carbon
@saykit/react
babel-plugin-saykit
unplugin-saykit
@saykit/transform-js
@saykit/transform-jsx
commit: |
|
The preview build of |
Closes #54.
A
selectorpluralbranch key that is not a valid ICU key passed every stage of the toolchain and only failed when the runtime handed the pattern to@messageformat/parser. The constraint lives in that lexer, where a case is=\d+or[^\p{Pat_Syn}\p{Pat_WS}]+— and-is Pattern_Syntax, so an ordinary hyphenated string union ('sold-out') extracted to a normal-looking catalogue entry and then died withinvalid syntax at line 2 col 3.Validation now runs where the macro is transformed, while the key is still attached to a file and a line:
validateBranchIdentifierandgetBranchCaselive in@saykit/config, andconvertMessageToIcuwrites its cases throughgetBranchCase, so what is validated and what is emitted cannot drift.<Say.Select in-stock="…">had the same hole.añostays legal.Numeric keys are the one adjacent case included: a number compiles to an exact-value case (
=0), which onlypluralandordinalaccept, sosay.select(x, { 0: … })was failing at format time for the same reason. It now errors with the reason named.The error is a plain
Error, matching the existingInvalid placeholder nameandsay-tagvalidation — the filename comes from the bundler reporting which module threw. Naming the file and line in the message text would be a separate change across all three validators.Docs get a paragraph under Select, and there are tests for the validator, both parsers, and both extractors.
Summary by CodeRabbit
Bug Fixes
Documentation
selectand numeric keys.Tests