Repository navigation
feat(no-expression-in-message): recommend named placeholders in the error message - #156
Open
andrii-bodnar wants to merge 2 commits into
Open
andrii-bodnar wants to merge 2 commits into
andrii-bodnar wants to merge 2 commits into
Conversation
…rror message
The report now names the offending expression and shows the exact
`ph({ label: expression })` wrapper to use, with the label derived from
the code (`user.name` -> `name`, `getUserName()` -> `getUserName`,
otherwise `value`). The rule docs are rewritten to lead with `ph` as the
fix and to explain why explicit labels are preferred over names inherited
from variables.
Refs lingui/js-lingui#2457
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
6 of 8 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #156 +/- ##
==========================================
+ Coverage 98.63% 98.66% +0.02%
==========================================
Files 18 18
Lines 881 900 +19
Branches 303 308 +5
==========================================
+ Hits 869 888 +19
Misses 12 12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ify the docs
With `allowIdentifiers: false` the rule also reports plain identifiers
such as `${name}` and suggests `ph({ name })`, so that renaming a
variable can never change a message. The default stays `true`.
The docs now explain the rename problem with a concrete example.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
Author
|
@timofei-iatsenko is there anything else we can do to move this PR forward? |
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.
The report now names the offending expression and shows the exact
ph({ label: expression })wrapper to use, with the label derived from the code (user.name->name,getUserName()->getUserName, otherwisevalue).New
allowIdentifiersoption (defaulttrue). Withfalse, plain identifiers such ast`Hello ${name}`and<Trans>Hello {name}</Trans>are reported too, with a message that suggestsph({ name }), so that renaming a variable can never change a message. Explicit labels, the{ name }object shorthand, and nestedplural/select/selectOrdinalmacros remain valid. The shorthand is supported by both the Babel macro and the SWC plugin.The rule docs are rewritten to lead with
phas the fix, explain with a concrete example why explicit labels are preferred over names inherited from variables, and document the new option.Refs lingui/js-lingui#2457