Skip to content

fix(i18n): lint visible English literals, and wire the header caption - #181

Merged
sydevs-bot merged 10 commits into
mainfrom
claude/fix-165-i18n-jsx-literals
Oct 11, 2026
Merged

sydevs-bot merged 10 commits into
mainfrom
claude/fix-165-i18n-jsx-literals

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • A new AST-accurate lint rule fails on visible English in JSX; the two text-matching guards could not see it.
  • The header mega-menu's caption now renders through useT(), so it stops being English in every locale.

Change outline

The rule is the change. It states, in the one place every component author already runs, what
AGENTS.md only said in prose.

Contract — what a component may write where a visitor reads

eslint.config.js, over components/**, layouts/** and pages/**:

 a JSX text node, or a brace holding a string
-  any English prose                       # nothing looked at JSXText at all
+  rejected once it holds two letters      # `·`, `—`, an entity, a lone initial still pass
+  {'…'} {`…`} {c && '…'} {c ? '…' : '…'}  # every re-spelling of the same string
+  the same inside a fragment              # `<>{'…'}</>` is not a JSXElement
+  <style>{`…`}</style> accepted           # a script or style child is code, not copy
+  {t('group.key')} accepted
 a prop that carries copy: COPY_PROPS, ten names — `description` and `text` among them
-  aria-label="Close"                      # caught by a text-matching guard
-  aria-label={muted ? 'Unmute' : 'Mute'}  # caught by the same guard
-  title="Meditate Now"                    # caught by nothing
-  description="Sit quietly"               # caught by nothing; 16 props carry copy under this name
+  rejected, quoted or braced or in either arm of a ternary or an `&&`
+  title={t('group.key')} accepted         # the key is a Literal under the call, not the attribute
 alt
-  alt="A seated meditator"                # caught by nothing
+  rejected, with its own message          # `alt=""` is as often the right fix as t()
 escape hatch
+  eslint-disable region, reason mandatory # five regions; each names its blocker
+  ignores, for a tree that is never copy  # stories, tests, Ladle, pages/sentry/**

An identifier still passes — aria-label={CLOSE} is not a Literal — so the rule bounds the
spellings rather than proving intent. See the detail block for the follow-up that would close that.

Components — the two that stopped speaking English

 HeaderDropdown                            components/organisms/HeaderDropdown/HeaderDropdown.tsx
 └── FeaturedArticleColumn                 # owns the markup, so it owns the hook
+      useT()
       hover overlay
-        "Inspiration comes from within"
+        t('navigation.featured_caption')  # already held that exact English

 AnimatedLogoSvg                           components/atoms/graphics/svgs/AnimatedLogoSvg.tsx
-  <title>WeMeditate Animated Logo</title> # an English accessible name on decorative chrome
+  aria-hidden="true"                      # before the spread, so a caller can opt back in
   …

Spinner's logo variant already wraps it in role="status" with a translated aria-label and an
sr-only copy of that label (components/atoms/Spinner/Spinner.tsx:109-118), so a screen reader
read the English title over the translated status message. Translating the <title> would have been
the symptom fix.

Files — the guard family after this

 tests/guards/
 ├── _source-scan.ts            # repo root, file list, comment blanking
 ├── a11y-literals.test.ts      # text matching, and unsuppressible: it strips comments,
 │                              # so no eslint-disable silences the #56 subset
 ├── translation-keys.test.ts   # every t() key resolves in the committed snapshot
+└── jsx-literals.test.ts       # asks ESLint whether the new selectors match anything

Preview

  • preview pending

Phases

Test results

  • Lean gate: ✓ lint (0 errors), tsc --noEmit, 82 files / 815 tests
  • Targeted specs: tests/guards/jsx-literals.test.ts 5 passed, HeaderDropdown.locale.test.tsx 1 passed
  • Build: ✓ pnpm build — the diff touches pages/sentry/+Page.tsx, and only a build catches a + file
  • Security review: skipped — no changed path matches securityReview.triggerPattern
  • Comment lint: ✓ no banned comment added
  • Measured cost of the new rule: no-restricted-syntax is 0.05ms per file against prettier/prettier's
    5.66ms, and the new guard adds ~1.4s of CPU in one Vitest worker, 86% of it ESLint cold start
  • Widened selectors re-measured against the real tree: still 0 errors over all three scoped globs

Manual verification

  1. Open the header mega-menu on a non-English locale and confirm the featured caption is translated,
    not "Inspiration comes from within".
  2. In Ladle (pnpm ladle, port 61000), the HeaderDropdown story still shows the caption — it falls
    back to the committed English snapshot there. Not run in this session; no dev server.
  3. With a screen reader, confirm the loading spinner announces only its translated status label and no
    longer says "WeMeditate Animated Logo". SplashLoader
    (components/atoms/SplashLoader/SplashLoader.tsx:154) has no status role, so there the logo is now
    purely branding and its optional text prop carries the message — worth a look if that is wrong.

Notes for reviewer

  • Phase 3 is not in this PR, and GitHub lists this PR as closing fix(i18n): visible page text stays English — no guard covers JSX text #165. So
    merging it closes the ticket with its third phase undone. Re-open it then, or let the two upstream
    tickets carry phase 3 — your call, but it is not automatic. The six DiscoverMeditation strings
    have no upstream keys (feat(translations): add the keys WeMeditate Web still hardcodes SahajCloud#917, which also covers the component's two English default
    props — those are default parameter values, which no JSX selector can see), and
    pnpm sync:translations refuses to run at all while production's global returns 200 {}
    (fix(translations): wm-web-translations returns no English strings SahajCloud#918, re-measured 2026-10-10). Both are now Blocked by: lines on the ticket.
  • The rule reports zero errors on this branch. Two sites are fixed; the rest sit behind five
    commented eslint-disable no-restricted-syntax regions across four files, each naming why: the
    error-details panel and the RichText unimplemented-node notice render in DEV only, the RichText
    debug button's label is a block type behind a debug prop that defaults to false, the player
    upsell needs keys (filed as fix(i18n): the meditation player's upsell copy stays English #178), and DiscoverMeditation is phase 3.
    pages/sentry/** is no longer one of them — it is a whole tree that is never visitor copy, so it
    sits in the block's ignores beside the stories and Ladle.
    The judgement worth checking is the DEV-only pair: both ErrorFallback call sites pass
    showDetails={import.meta.env.DEV} (layouts/LayoutRoot.tsx:49, pages/_error/+Page.tsx:33), and
    the RichText converter returns null unless import.meta.env.DEV.
  • tests/guards/a11y-literals.test.ts is kept rather than deleted, and its caveat rewritten to
    the one reason that survives scrutiny: it strips comments, so an eslint-disable cannot silence it,
    and the screen-reader subset feat(i18n): consume CMS wm-web-translations + BCP-47 locale codes #56 was about stays enforced whatever a later
    region suppresses. Deleting it is a defensible call and it is yours, not mine.
  • The title says less than the ticket's, because this PR carries two of its three phases.
Detail

react/jsx-no-literals was weighed and lost. The plugin is already installed and
react.configs.flat.recommended is already in this config, and the rule ships noStrings,
allowedStrings and noAttributeStrings. But allowedStrings is exact-match, so every separator and
entity in the tree would become an enumerated allowlist, and its prop checking is all-props rather
than the ones that carry copy. The /[A-Za-z]{2}/ prose test and the named prop set are what make
the rule green on today's tree.

Why > and never a descendant. JSXAttribute[name.name=/…/] Literal[…] would catch every
nesting in one line, but it also matches the key inside title={t('navigation.featured_caption')} —
that key is a Literal under the attribute. So each accepted shape gets its own direct-child path.

Why the brace paths are composed rather than listed. The children position and the prop position
each need the bare brace, a ternary arm and an && arm, which is six paths written twice. copyBraced
is the one definition both call, so the positions cannot drift apart again — which is exactly how
{cond && 'copy'} shipped unflagged while title={cond ? 'a' : 'b'} was caught.

Why the test drives ESLint rather than re-implementing the selectors. A selector that matches
nothing fails open: pnpm lint goes green and every literal ships. The repo's existing guard says the
same of its own regexes, so the new file asks ESLint itself, with lintText resolving config by
filePath — which is also what pins the scope and the story/test exclusions. Each case is named for
the spellings it asserts, so a green suite is not read as proof that the set is closed.

The follow-ups this leaves, none of them in scope here:

  • A named rule instead of selectors. A ~40-line rule defined inline in flat config
    (plugins: { copy: { rules: … } }) could resolve a single-init module-scope identifier through
    context.sourceCode.getScope(), which is the only way aria-label={SOME_CONST} is ever caught. It
    would also give suppressions a specific id, where no-restricted-syntax is shared.
  • A branded Copy type. TFunction returns plain string (lib/i18n.ts:149), so nothing in the
    type system separates copy from any other string. Branding it and typing copy-carrying props Copy
    would let tsc reject the three categories no selector or source scan reaches: default parameter
    values, lookup tables in .ts files, and composed strings.
  • One components/dev/ directory for DEV-only chrome, exempted by glob the way components/ladle/**
    and now pages/sentry/** are, instead of the two remaining per-site exclusions that each restate the
    import.meta.env.DEV gate differently.
  • A fifth copy of the usePageContext mock idiom. The new locale test joins four others inlining
    vi.mock('vike-react/usePageContext', …). A factory in tests/_helpers/ is worth it now, but it
    touches five unrelated test files.
  • The scope globs are stated in three places — this config block, SOURCE_GLOBS in
    a11y-literals.test.ts, and the stories/tests filter in _source-scan.ts — with nothing tying
    them together. eslint.config.js importing from tests/ is the wrong direction, so the fix is a
    shared module neither owns.

Part of #165

🤖 Generated with Claude Code

https://claude.ai/code/session_01AhcbUT9cprRA3oWuNcTWdH

The caption on every chromed page's mega-menu was a JSX literal, so it
stayed English in every locale. `navigation.featured_caption` already
held the same string, so this is a wiring fix and needs no new key.

The hook belongs in `FeaturedArticleColumn`, not the exported component:
that inner component owns the markup.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AhcbUT9cprRA3oWuNcTWdH
Its `<title>` gave a decorative brand animation an English accessible
name, inside a `role="status"` region that already names itself from a
translated label — so a screen reader read "WeMeditate Animated Logo"
over the loading message in every locale.

`FloralDividerSvg`, `HeaderIllustrationSvg` and `LeafSvg` all set
aria-hidden before the spread, which lets a caller opt back in.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AhcbUT9cprRA3oWuNcTWdH
Neither guard under `tests/guards/` could see visible copy: both match
source text, so `<p>Inspiration comes from within</p>` and
`title="Meditate Now"` passed, and `a11y-literals` said so in its own
docblock. Four `no-restricted-syntax` selectors read the AST instead,
over JSX text and over alt, aria-label, label, placeholder, subtitle and
title — including a braced literal and either arm of a ternary.

Two consecutive ASCII letters is the prose test, so a separator or a
lone initial passes. A key inside `t('a.b')` is not a Literal child of
the attribute, so a resolved call never trips it.

`tests/guards/jsx-literals.test.ts` asks ESLint itself whether the
selectors match. A selector that matches nothing fails open, which would
make lint green and ship every literal.

Four sites keep the old literals behind a commented region, each naming
why: the error details panel and the unimplemented-node notice render in
DEV only, the Sentry page exists to throw test errors, and the player
upsell and `DiscoverMeditation` need keys that do not exist upstream yet
(#178, and this ticket's third phase).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AhcbUT9cprRA3oWuNcTWdH
Review found three gaps and one false claim.

A braced literal and a backticked one were both missed, so the string
this branch fixes in `HeaderDropdown` passed again the moment someone
wrote `{'Inspiration comes from within'}`. Both spellings are now
covered, for JSX children and for every copy prop — excluding a
`<style>` or `<script>` child, whose backticks hold CSS.

`alt` gets its own message: an untranslated alt is as often decorative,
and `alt=""` is the right fix there, which this branch's own
`AnimatedLogoSvg` change shows. A message offering only `t()` nudges
toward translating chrome.

The config comment claimed `aria-label={SOME_CONST}` as its motivation,
which the rule cannot see and the guard beside it says so. It now states
what the selectors do read, and that an identifier passes.

`a11y-literals` is kept for the reason that is actually true: it strips
comments, so no `eslint-disable` silences it. The reason it gave —
invisible in `pnpm test:run` — was backwards, since lint runs first in
both CI and the local gate.

Also: `repoRoot` from `_source-scan` instead of a second definition, one
`lintText` per case asserting the reported lines, and a fixture spread
from `EN_TRANSLATIONS` rather than cast.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AhcbUT9cprRA3oWuNcTWdH
The bullet said two guards under `tests/guards/` enforce it, which was
never true of visible text and is no longer the whole story.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AhcbUT9cprRA3oWuNcTWdH
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
wemeditate-web 456ae9e Commit Preview URL

Branch Preview URL
Oct 10 2026, 08:13 PM

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 10, 2026
@sydevs-bot

sydevs-bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 20:01Z address-review · attempt 1 · session · done
  • 20:01Z address-review · attempt 1 · session
  • 19:50Z review-pr · attempt 1 · session · done
  • 19:50Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The shape is right. A lint rule in the one place every author already runs beats the same rule as prose in AGENTS.md, and phase 1 matches the ticket. The six disable regions are the rule's price, not scope creep.

The rule's reach does not hold. It enumerates AST paths, so it covers the spellings someone thought of. Five prop names this repo uses for copy are missing, and braced copy in children position escapes through && or a ternary — the same ternary the rule catches on a prop. Widening costs two lines and keeps lint at 0, so take it now rather than wait for the named-rule follow-up.

Two guards now cover one concern, and #165 asked whether a11y-literals.test.ts survives. Its kept reason is real but unexercised: no region here hides anything it would catch.

Findings

  • should-fix — COPY_PROPS misses description, text, buttonText, caption, heading (eslint.config.js:9).
  • should-fix — {cond && 'copy'} and {cond ? 'a' : 'b'} as children pass unflagged (eslint.config.js:190).
  • consider — a whole-file disable belongs in the block's ignores (pages/sentry/+Page.tsx:1).
  • consider — "catches every spelling" names three (tests/guards/jsx-literals.test.ts:43).

What was checked

  • Read #165 and the whole diff: eslint.config.js, both guards, HeaderDropdown, AnimatedLogoSvg and its consumers (Spinner.tsx:109-118 names itself; SplashLoader has no production mount).
  • Ran this branch's config in a scratch worktree. Baseline reproduces at 0 errors; probes confirm four escaping shapes; the widened selectors still report 0 across all three scoped globs.
  • No contract surface moves: no server/, no payload-types.ts.
  • Grepped for live leaks: both holes are latent — the escaping shapes carry only class names, and the unenumerated props take literals only in JSDoc.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread eslint.config.js Resolved
Comment thread eslint.config.js Resolved
Comment thread pages/sentry/+Page.tsx Resolved
Comment thread tests/guards/jsx-literals.test.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 10, 2026
`description`, `text`, `buttonText`, `caption` and `heading` are what this
tree calls copy far more often than `subtitle`: 16 prop declarations under
`components/**` use one of them. `<TechniqueCard description="Sit quietly" />`
passed the rule the ticket added it for.

Lint stays at 0 errors over all three scoped globs.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01X14a5zgbn88jrtpwtxoHXU
`{cond && 'copy'}` and `{cond ? 'a' : 'b'}` in children position passed the
rule, as did `title={cond && 'copy'}` and a braced string in a fragment — the
same ternary the prop selectors already report. Children enumerated two paths
where a prop enumerated three.

`copyBraced` is now the one definition of "a brace, directly or through a
branch", shared by both positions, so the two cannot drift apart again.

Lint stays at 0 errors over all three scoped globs.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01X14a5zgbn88jrtpwtxoHXU
"every spelling" was three spellings, and the ones that escaped were the ones
a reader assumes it covers. A green suite is not proof of completeness, so the
name states what the case checks rather than claiming the set is closed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01X14a5zgbn88jrtpwtxoHXU
A whole-file `eslint-disable` is config written in the wrong place: the block
already names `*.stories.tsx` and `components/ladle/**` in `ignores`, and a
developer's error-trigger page belongs beside them. The file-level form also
silenced every future `no-restricted-syntax` rule there, since the id is
shared across all three selectors.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01X14a5zgbn88jrtpwtxoHXU
The bullet enumerated five prop names and the rule now names ten, so the list
belongs in one place. It also said nothing about a braced string or a branch
arm, which the rule now rejects, and nothing about `ignores` as the home for a
tree that is not visitor copy at all.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01X14a5zgbn88jrtpwtxoHXU
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

All four review findings adopted, pushed as 456ae9e.

Nine shapes measured escaping before, reporting after. Lint holds at 0 errors.

Gate: lint, tsc --noEmit, 82 files / 815 tests, pnpm build ✓. The body's contract block, region count (five across four files) and test counts are refreshed.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 10, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 10, 2026 20:17
@sydevs-bot
sydevs-bot requested a review from Ardnived October 10, 2026 20:17
@sydevs-bot
sydevs-bot enabled auto-merge October 10, 2026 20:17
@sydevs-bot
sydevs-bot added this pull request to the merge queue Oct 11, 2026
@sydevs-bot sydevs-bot moved this from Revising to Approved in SYDevelopers Technical Roadmap Oct 11, 2026
Merged via the queue into main with commit a4de44c Oct 11, 2026
73 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants