Skip to content

MPDX-9933 - Enforce t in <Trans> - #1986

Merged
zweatshirt merged 2 commits into
mainfrom
enforce-t-in-trans
Aug 14, 2026
Merged

MPDX-9933 - Enforce t in <Trans>#1986
zweatshirt merged 2 commits into
mainfrom
enforce-t-in-trans

Conversation

@zweatshirt

@zweatshirt zweatshirt commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Description

Testing

  • N/A

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels (Add the label "Preview" to automatically create a preview environment)
  • I have run the Claude Code /quality:agent-review command locally and fixed any relevant suggestions
  • I have requested a review from another person on the project
  • I have tested my changes in preview or in staging
  • I have cleaned up my commit history

@zweatshirt zweatshirt self-assigned this Aug 13, 2026
@zweatshirt zweatshirt added the Preview Environment Add this label to create an Amplify Preview label Aug 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Preview branch generated at https://enforce-t-in-trans.d3dytjb8adxkk5.amplifyapp.com

@github-actions

Copy link
Copy Markdown
Contributor

Bundle sizes [mpdx-react]

Compared against e02be0d

Route Size (gzipped) Diff
/accountLists/[accountListId]/setup/finish 83.5 KB -3.11 KB

@zweatshirt zweatshirt changed the title Enforce t in trans MPDX-9933 - Enforce t in trans Aug 13, 2026
@zweatshirt zweatshirt changed the title MPDX-9933 - Enforce t in trans MPDX-9933 - Enforce t in <Trans> Aug 13, 2026
@zweatshirt
zweatshirt marked this pull request as ready for review August 13, 2026 21:11

@zweatshirt zweatshirt 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.

Multi-Agent Review — APPROVED WITH SUGGESTIONS

6 agents (Architecture, Testing & Quality, Standards, UX, Financial Reporting, Dependency Impact) · 0 blockers · 5 suggestions, highest severity 5.5 · Risk: MEDIUM

The PR does exactly what it claims, and the claim is machine-verifiable rather than asserted:

Check Result
yarn lint:ci (read-only) 0 errors, 2244 files
yarn lint:ts (tsc) exit 0
eslintTransRules.test.ts 11/11 pass
Component suites, all changed trees 466 tests pass, no timeouts
<Trans> missing t, repo-wide 0 of 108 (63 files)
Rule-fires probe <Trans>x</Trans> flagged; <Trans t={t}>x</Trans> clean

"Fix one, fix all" passed — this is the strongest signal in the review. The PR adds an error-level rule and then satisfies it everywhere, so CI will not break on merge. Four already-compliant files outside the diff (AccountListRow, AccountListInvites, ContactRow, GoalCard) were correctly left alone.

Behavior-neutral, and slightly positive. No changed file uses a namespaced useTranslation('ns'), and keySeparator/nsSeparator are both false, so t={t} cannot shift key resolution. Bonus: EligibleDisplay, EffectiveDateBanner and SuggestedContactStatus previously had no useTranslation() at all and so never subscribed to languageChanged — they could stay stuck on English after a mid-session language switch. They now re-render.

Financial Reporting agent was triggered by HrTools/** + the keywords amount/total/value, and reports a false positive: no arithmetic, aggregation, currency, rounding, or date-window expression is added, removed, or modified anywhere in the diff.


Debate resolution — the one genuine disagreement

Three agents converged on the same defect (see the .eslintrc.js comment) but proposed conflicting fixes. Resolved against the real ESLint rather than by consensus:

Proposal Verdict
:has(> JSXAttribute[name.name='t']) Invalid — esquery in ESLint 8.57 rejects a leading > inside :has(); throws SyntaxError at position 46
[parent.name.name='Trans'] Valid, 0 false positives across all 64 <Trans> files — but narrower than its author claimed

Both forms were probed directly:

<Trans components={{ x: <Foo   t={t}/> }}>  -> fixed by [parent...]  OK
<Trans components={{ x: <Trans t={t}/> }}>  -> still missed          --

The second escapes because the inner Trans's own t also satisfies [parent.name.name='Trans']. That form is pathological and absent from the repo; the first is the realistic one.


Pre-existing, informational — not part of this PR's scope

These sit in touched files but predate this PR and do not count toward the verdict. Listing them here rather than as inline comments, since they belong in separate tickets — not in an i18n conformance sweep.

  • SuggestedContactStatus.tsx:37-55 — rules-of-hooks violation (8.0/10). Four hooks sit below an early return null gated on contactIds, a live Formik value. Going 1 → 2 selected contacts on a mounted modal throws "Rendered fewer hooks than expected." Nothing catches it: eslint-plugin-react-hooks is neither installed nor configured repo-wide. This PR's change here is correct — its new useTranslation() is placed above the guard, leaving the hook-count delta unchanged. Worth its own ticket.
  • transKeepBasicHtmlNodesFor extraction/runtime mismatch. It is not configured anywhere in the repo, so the runtime keeps <strong>/<br>/<i>/<p> while i18next-parser indexes them as <2>. Affected keys can never match, so those strings are untranslatable in production (users still see readable English via the defaultValue fallback, so nothing is visibly broken). Seen at EligibleDisplay.tsx:19, and via the single-brace {above}/{after} form at RequestSummaryCard.tsx:88 and AboutForm.tsx:93. If the deferred #1977 work doesn't cover this, it needs a ticket.
  • EligibleDisplay.tsx:19-29 — two adjacent <Trans> blocks render with no space: ...button below.If you would like....

Explicitly cleared — not findings

Checked and dismissed so no reviewer re-raises them: two top-level describes in the test file (34/816 test files already do this); spread props being flagged (zero <Trans {... in repo); aliased/namespaced Trans escaping the selector (zero instances, and the pre-existing sibling i18nKey rule has the identical limitation).

Dependency impact

No breaking changes — every export/interface/React.FC line across all 23 files is byte-identical to merge-base e02be0d02. No CRITICAL-impact files; widest is Calculation.tsx (9 direct / 22 transitive). NullState.tsx is not the widely-imported one — that's the untouched NullStateBox.tsx; CreateButton is module-local and never exported.


Two things not verified first-hand, stated rather than papered over: whether yarn extract output changes for finish.page.tsx (locales are Crowdin-owned, so no extract was run), and two react-i18next v11 internals (namespace resolution order, nodesToString keep-vs-index) — inferred from library semantics plus corroborating extracted-key shapes, and both concerning pre-existing behavior.

Tooling note, unrelated to the diff: yarn lint is eslint ... --quiet --fix and mutates the working tree. Use yarn lint:ci when reviewing.

Comment thread .eslintrc.js Outdated
Comment thread __tests__/eslintrules/eslintTransRules.test.ts
Comment thread __tests__/eslintrules/eslintTransRules.test.ts Outdated
Comment thread pages/accountLists/[accountListId]/setup/finish.page.tsx
{isContactType && (
<Typography variant="body2">
<Trans
t={t}

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.

[Suggestion] **No test coverage for these three `` edits — direct or indirect.**

ContactPair.tsx and StickyConfirmButtons.tsx are the only 2 of 23 changed components without a colocated test. Their parents (MergeContacts.tsx, MergePeople.tsx) do have tests, but those assert none of the affected strings — grep for Showing / Source: in both test files returns nothing.

Low severity because the properties that matter here are already verified globally: tsc is clean (so t resolves — here it comes from the explicit t: TFunction prop on ContactItem at line 137, not a hook, which is correct pre-existing threading), and the sweep is provably behavior-neutral. Flagging only so you know this is where a rendering regression would go unnoticed.

<Box>
<Typography>
<Trans
t={t}

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.

[Suggestion] **No colocated test for this file** — see the note on `ContactPair.tsx:232`. Same situation: `MergeContacts.test.tsx` and `MergePeople.test.tsx` don't assert the `Showing ... of ...` string, so this `` edit has no coverage in either direction.

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.

/dismiss out of scope

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI Review Auto-Approval

Risk Level: MEDIUM (4/10)
Verdict: APPROVED_WITH_SUGGESTIONS (suggestions posted, no blockers)

This PR was auto-approved because:

  • The multi-agent AI review determined it is medium risk
  • No blocking issues were found
  • All suggestions have been posted as review comments for the developer to consider

If you believe this PR needs human review, dismiss this approval and request a review manually.

@zweatshirt
zweatshirt merged commit 5f0edc3 into main Aug 14, 2026
23 of 24 checks passed
@zweatshirt
zweatshirt deleted the enforce-t-in-trans branch August 14, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Preview Environment Add this label to create an Amplify Preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant