Repository navigation
[feat] i18n: extend no-hardcoded-i18n-string to catch ternary + template patterns - #4014
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
nynexman4464
marked this pull request as ready for review
July 15, 2026 22:29
nynexman4464
requested review from
cixzhang,
ejhammond and
imdreamrunner
as code owners
July 15, 2026 22:29
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-more-strings
branch
from
July 15, 2026 22:51
ee7dbfe to
bdadf04
Compare
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-lint-rule-ternary
branch
from
July 15, 2026 22:51
3761240 to
501efd4
Compare
imdreamrunner
approved these changes
Jul 16, 2026
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-more-strings
branch
from
July 17, 2026 16:26
bdadf04 to
995e996
Compare
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-lint-rule-ternary
branch
from
July 17, 2026 16:26
501efd4 to
cb95539
Compare
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-more-strings
branch
from
July 17, 2026 17:54
995e996 to
bdba214
Compare
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-lint-rule-ternary
branch
from
July 17, 2026 17:55
cb95539 to
b7f5546
Compare
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-more-strings
branch
from
July 17, 2026 21:28
bdba214 to
5fd23ed
Compare
…late patterns
Walks into a JSX-expression container (or a destructure default) and
recursively reports string literals nested inside conditional, logical,
and template-literal expressions. Handles the two patterns that a
plain-literal check missed:
aria-label={isOpen ? 'Close X' : 'Open X'} // ConditionalExpression
aria-label={cond && 'Something'} // LogicalExpression
aria-label={fallback ?? 'Default'} // LogicalExpression
aria-label={`Clear ${label}`} // TemplateLiteral
Deliberately does NOT walk into CallExpression (already handled — t()
calls are the correct form), MemberExpression, Identifier, arrow
function bodies, or JSX expressions — those are either fine or too
likely to false-positive.
Same behavior for the destructure-default case:
function Foo({label = cond ? 'A' : 'B'}) { ... }
function Foo({label = `Default ${x}`}) { ... }
Both are now flagged as `hardcodedDefault`.
Real-world integration testing (pseudo-locale swap on a consumer app)
was the forcing function. The pattern is common enough that a 24-file
migration was needed to green up the extension — landed separately in
#4013 which this PR stacks on.
Refs #3641, builds on #4013
nynexman4464
force-pushed
the
nynexman4464/feat/i18n-lint-rule-ternary
branch
from
July 17, 2026 21:40
b7f5546 to
e4d8a62
Compare
nynexman4464
changed the base branch from
nynexman4464/feat/i18n-more-strings
to
main
July 17, 2026 21:40
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
31 of 40 tasks
This branch was successfully deployed
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.
Stacked on #4013. Extends
@astryx/no-hardcoded-i18n-stringto catch string literals inside ternary, logical, and template-literal expressions:Same treatment for destructure defaults. Real-world integration testing (pseudo-locale swap on a consumer app) surfaced ~50 pre-existing violations the plain-literal walker missed; all migrated in #4013, which this PR stacks on.
The walker deliberately stops at
CallExpression(t() is fine),MemberExpression, and function bodies — those are too likely to false-positive.Testing
Refs #3641, builds on #4013.