Repository navigation
fix(no-single-variables-to-translate): count text inside ICU macro props - #157
Merged
Merged
Conversation
<Plural>, <Select> and <SelectOrdinal> carry their translatable text in choice props (one=, other=, male=, _0=, ...), not in JSX children, so a <Trans> containing only an ICU macro was wrongly reported. Inspect the message-carrying props of the three ICU macros and skip the non-message props (value, offset, id, comment, ...), mirroring the list used by no-unnamed-tag-placeholders. Fixes lingui#104
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #157 +/- ##
==========================================
- Coverage 98.63% 98.45% -0.19%
==========================================
Files 18 18
Lines 881 906 +25
Branches 303 319 +16
==========================================
+ Hits 869 892 +23
- Misses 12 14 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
@cpruijsen thanks, the fix looks right. Codecov fails on two new lines: the ICU check inside |
…, cover valueless prop
Contributor
Author
|
Done. I removed the redundant check and added that invalid case. |
andrii-bodnar
approved these changes
Oct 12, 2026
andrii-bodnar
left a comment
Contributor
There was a problem hiding this comment.
@cpruijsen thank you!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
no-single-variables-to-translatenow reads text in ICU choice props for<Plural>,<Select>, and<SelectOrdinal>inside<Trans>.In
src/rules/no-single-variables-to-translate.ts, choice props count if they contain non-blank strings, template literals with static text, or nested JSX with text. Variable-only choices and unrelated props still produce the existing diagnostic.The issue's example now passes:
The nine new valid cases, including the issue example, fail without the source change and pass with it.
Fixes #104.