Skip to content

chore(lint): ratchet literal fontSize, borderRadius and hex in scf-core features (#819) - #942

Merged
thinkclay merged 1 commit into
mainfrom
chore/819-literal-ratchet
Oct 2, 2026
Merged

thinkclay merged 1 commit into
mainfrom
chore/819-literal-ratchet

Conversation

@thinkclay

@thinkclay thinkclay commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #819. First item of release 4 (#939).

What lands

  • scripts/lint/check-literal-ratchet.mjs — ceilings per feature directory, per pattern. Per directory rather than one total on purpose: a single number lets you add literals to office while fixing communities and still pass.
  • scripts/lint/literal-baseline.json — 40 directories, measured fresh on main at 1ca00321d.
  • Wired into four places — pnpm lint:literals, pnpm lint, pnpm prepush, pnpm radium:check, and a CI step in the lint job.
  • .radium/scaffald-ui.md — the rule and the map from each literal value to its token.

--update lowers ceilings and refuses to raise them. Falling counts don't fail the build, they print the tightening to apply — failing on an improvement would put every unrelated PR in the business of editing the baseline.

The issue's numbers were wrong, and the baseline doesn't use them

#819 measured borderRadius: <n> and reported 360 sites. It didn't measure borderRadius={<n>}, the JSX prop form — that's another 355, more than the style-object form's 337. The real figure is 693. Hex was counted as '#abc' only, missing 124 double-quoted sites.

Counting one syntax and not the other would have left the obvious bypass open on day one, so all three forms are counted and the baseline is measured fresh rather than carried over.

fontSize was measured correctly, and has improved on its own since: 637, down from the 720 the issue reported.

Pattern Issue said Actually, measured here
borderRadius 360 693
fontSize 720 637
hex 215 273

Two of the issue's instructions turned out not to apply

  • It proposed pinning luscher-test because "the colour-preference assessment is literal colour by definition". That directory has no hex literals left — it uses rgb() through tokens now. No exception added.
  • marketing/theme.ts is pinned, with the reason in the baseline: a deliberate palette the file itself explains is not the product's, carrying WCAG contrast notes against each value.

The first CI run caught slack in my own baseline

Worth recording, because it is the ratchet doing its job on the person who wrote it. The first CI run passed but reported borderRadius 693, fontSize 637 where the committed baseline said 697/643. CI builds the merge commit, and #934 had landed on main after I branched, removing literals from notifications and drawer.

A pass is a pass, so nothing failed — but shipping that baseline would have meant 10 sites of built-in slack on day one, which is the opposite of the point. Rebased onto 1ca00321d and re-seeded:

  4 ceiling(s) lowered:
    drawer.borderRadius  17 -> 15
    drawer.fontSize  23 -> 20
    notifications.borderRadius  8 -> 6
    notifications.fontSize  20 -> 17

The general lesson for anyone adding to this baseline: seed it against the merge target, not your branch point, or the first tightening someone else does is really just reclaiming your slack.

Verification

Each acceptance criterion exercised rather than reasoned about:

Adding one fontSize: 13 to analytics/components/KpiCard.tsx — exits 1, names the ceiling and puts the culprit first:

✖ Literal styling increased in packages/scf-core/features (borderRadius 697, fontSize 644, hexColor 273).

    analytics — fontSize: 43, ceiling 42
        1  packages/scf-core/features/analytics/components/KpiCard.tsx  <- changed in this branch
        16  packages/scf-core/features/analytics/EngagementScreen.tsx
        ...

Removing one — passes, and offers the tightening; --update writes a one-line diff:

✓ Literal styling within baseline (borderRadius 697, fontSize 642, hexColor 273)
  1 ceiling(s) can be lowered — run `pnpm lint:literals --update`:
    analytics.fontSize  42 -> 41

--update with a rise — refused, exit 1: "it lowers ceilings, it does not raise them."

pnpm prepush green with the new step. Both probe edits reverted; git status confirmed clean.

One thing worth knowing separately

CI does not run pnpm lint — the lint job runs pnpm check, which is locales:validate + nx lint + typecheck. So lint:routes, lint:sorted-keys, lint:overrides and lint:migrations are prepush-only and not enforced in CI at all, which means they don't gate anyone who sets SKIP_PREPUSH=1. That's why this change adds its own explicit CI step rather than relying on the chain. Filed as #941.

Also: scripts/radium-check.sh already exits 1 on main for three pre-existing hits (two are doc-comment false positives, one is the @hookform/resolvers grep). Its own header says it's informational, so the real gates here are prepush and CI.

🤖 Generated with Claude Code

…re features (#819)

Closes #819.

The tokens landed in #621 and nothing held the line, so the counts went the
wrong way through three releases of reskinning. This pins them per directory
per pattern and fails anything worse.

- scripts/lint/check-literal-ratchet.mjs — the check. Per directory, not one
  total, so you cannot add literals to office while fixing communities and
  still pass. Reports the directory's ceiling, the files under it, and marks
  the ones changed in this branch.
- scripts/lint/literal-baseline.json — 40 directories, measured fresh on main.
- Wired into pnpm lint, pnpm prepush, pnpm radium:check and the CI lint job.
- .radium/scaffald-ui.md — the rule, and the map from each literal value to
  its token.

`--update` lowers ceilings and refuses to raise them. Falling counts do not
fail the build, they print the tightening to apply: failing on an improvement
would put every unrelated PR in the business of editing the baseline.

**The issue's numbers were wrong and the baseline does not use them.** #819
measured `borderRadius: <n>` (337 sites) and missed `borderRadius={<n>}`, the
JSX prop form, which is another 355 — more than the style-object form. The real
figure is 693, not 360. Hex was counted as `'#abc'` only, missing 124
double-quoted sites. Counting one syntax and not the other would have left the
obvious bypass open on day one. fontSize was measured correctly and has since
improved on its own: 637, down from 720.

Measured ceilings: borderRadius 693, fontSize 637, hexColor 273, on main at 1ca0032.

Two things in the issue turned out not to be needed. It proposed pinning
`luscher-test` for literal colour; that directory has no hex literals left, so
no exception is added. `marketing/theme.ts` is pinned, with the reason recorded
in the baseline — it is a deliberate palette the file itself explains is not
the product's, carrying WCAG notes against each value.

Co-Authored-By: Claude Opus 5 <[email protected]>
@thinkclay
thinkclay force-pushed the chore/819-literal-ratchet branch from 10d17fc to 4f5254c Compare October 2, 2026 08:48
@thinkclay
thinkclay merged commit 925d197 into main Oct 2, 2026
10 checks passed
@thinkclay
thinkclay deleted the chore/819-literal-ratchet branch October 2, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(lint): ratchet literal fontSize / borderRadius / hex in scf-core features — counts may only go down

1 participant