Skip to content

chore(lint): make the ESLint ratchet pass on master again, and tighten it to 99 (#627) - #891

Open
alex-dembele wants to merge 5 commits into
masterfrom
chore/627-lint-ratchet-green
Open

alex-dembele wants to merge 5 commits into
masterfrom
chore/627-lint-ratchet-green

Conversation

@alex-dembele

Copy link
Copy Markdown
Member

Closes #627

npm run lint:ceiling, the blocking ESLint gate in CI, fails on a clean master (14f26e8e). Four rules are over their ceiling, so every frontend PR is red for reasons it did not cause:

@typescript-eslint/no-unused-vars: 42 (ceiling 39, +3)
no-irregular-whitespace: 3 (ceiling 1, +2)
openrisk/no-raw-colors: 2 (ceiling 0, +2)
react-hooks/refs: 2 (ceiling 1, +1)

What changes (one commit per fix)

  • no-irregular-whitespace: in e2e/empty-states.spec.ts, i18n/__tests__/format.test.ts and translate.test.ts, the intentional U+00A0, U+202F, U+200E and U+200F inside the regex classes are now written as \u escapes. Same regexes, same matches, and nothing is replaced by a plain space, as chore(frontend): lint:ceiling fails on a clean master — stale no-irregular-whitespace count #627 criterion 2 requires. The rule is enforced at zero from now on.
  • no-unused-vars: fifteen unused imports removed from SettingsScreen.tsx. Import removal only.
  • no-raw-colors: PersonalizeCard drew the accent swatches with #0a84ff and #7c6cff, which matched neither theme's accent. It now uses the existing --swatch-azure and --swatch-iris tokens, which mirror each variant's real accent per theme. This is a visible change: each swatch now shows the colour the accent will actually be.
  • react-hooks/refs: useHotkeys updates its handler ref in a layout effect instead of during render. TagInput's ref write stays inside the frozen debt.
  • Ratchet: re-frozen with npm run lint:ceiling -- --update, from 132 down to 99. Every number only went down. That includes debt paid on master since the last freeze.

Verification

npm run lint:ceiling     → ESLint errors: 99 (ceiling 99) ✓ No regression.
npx tsc -b --noEmit      → exit 0
npx vite build           → built
npx vitest run           → 107 files, 993 tests passed

Live, on this branch against a local backend, in Settings → General: the page loads without errors after the import removal. The swatches compute to the variant accents:

  • Azure: rgb(11,96,185) in light, rgb(79,155,255) in dark;
  • Iris: rgb(91,70,201) in light, rgb(157,144,255) in dark.

Not done

  • e2e/empty-states.spec.ts was edited (escape only), but I did not run the Playwright e2e suite.
  • eslint . still reports 99 errors. Those are the frozen debt, which this PR does not touch beyond the four rules above.

Three regex classes held literal U+00A0, U+202F, U+200E and U+200F, the
spaces and direction marks French number formatting emits. They are
intentional, but no-irregular-whitespace flagged them and the ratchet
failed on a clean master.

Written as \u escapes, the regexes match exactly what they matched
before; the characters are not replaced with plain spaces, and a reader
can now see which ones are meant.

Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
Leftovers from panels that moved out of this file. Import removal only;
nothing else in the file changes.

Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
PersonalizeCard drew its two accent swatches with literal colours,
#0a84ff and #7c6cff, which matched neither theme's accent and broke
openrisk/no-raw-colors. tokens.css already defines --swatch-azure and
--swatch-iris for exactly this, mirroring each variant's accent per
theme. The swatches now show the colour the accent will actually be.

Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
…ender (#627)

Writing ref.current during render is what react-hooks/refs forbids: a
render React throws away still mutates the ref. The layout effect runs
after every commit and before any later keydown, so the listener keeps
seeing the latest handlers.

Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
The fixes in this branch, plus debt paid down on master since the last
freeze, put six rules under their ceiling. Re-frozen with
npm run lint:ceiling -- --update; every number only went down, and
no-irregular-whitespace is now enforced at zero.

Signed-off-by: alex-dembele <alexandredembele16@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend React, /src priority:P2-medium Normal milestone work tier:0-trust Trust: security, isolation, evidence integrity type:chore Maintenance, no user impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(frontend): lint:ceiling fails on a clean master — stale no-irregular-whitespace count

1 participant