fix(checks): stop SpellingDialect rewriting Tailwind and CSS tokens (CD-319) - #207
Open
TAJD wants to merge 1 commit into
Open
fix(checks): stop SpellingDialect rewriting Tailwind and CSS tokens (CD-319)#207TAJD wants to merge 1 commit into
TAJD wants to merge 1 commit into
Conversation
…CD-319) The check counted any string literal containing a space as prose, so a class list qualified and it recommended `items-center` -> `items-centre`. Tailwind emits no rule for `items-centre`, so following the advice broke the UI silently. Three exclusions, cheapest first: - a `className`/`class` JSX attribute is never scanned; - an object property keyed by a CSS property name is never scanned, including the camelCase `backgroundColor` form; - a dialect word hyphen-adjacent to a utility-class root is skipped wherever it appears, so a class list built with `clsx` is covered too. The third is gated on the word itself being CSS vocabulary. Without that gate `self` — a Tailwind root and an English hyphen prefix — silences `self-defence` as readily as `self-center`. Validated against two real repos with `dialect = "british"` pinned: bestefforttools 322 -> 89 findings, every survivor a genuine American spelling in prose; poker-puzzle's ~60 class-name rewrites -> 0, five prose comments left. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019afugU2bTYCtXn6Vy9dn1v
Criterion benchmark comparison (PR head vs base branch) |
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.
Fixes CD-319.
Consistency.SpellingDialectcounted any string literal containing a space as prose, so a Tailwind class list qualified. Pinningdialect = "british"on bestefforttools turned 12 findings into 322, of which ~60 were instructions to rewriteitems-centerasitems-centre. Tailwind emits no rule foritems-centre, so following the check's own advice breaks the UI silently and passes review. The check is currently disabled in all five repos in the estate because of it.What changed
Three exclusions in
crates/cofferdam-checks/src/consistency.rs, cheapest first:className/classJSX attribute is never scanned;style={{ backgroundColor: … }}and{ 'background-color': … };clsx/cnis covered too.The third is gated on the word itself being CSS vocabulary (
center,color,gray,normalize,capitalize,behavior, both spellings). Without the gate,self— both a Tailwind root and an English hyphen prefix — silencesself-defenceas readily asself-center.The single-pass shape of
collect_dialect_hitsis preserved. Scanning per spelling costs 170 passes over every comment and showed up as a 20% whole-run regression, so it stays one pass.Validation
Real repos,
dialect = "british"pinned,--no-cache --no-baseline:Every one of the 89 survivors on bestefforttools is a genuine American spelling in prose (
optimization,analyze,favorite,labeled). poker-puzzle is down to five prose comments.Tests
Eight cases in
spelling_dialect_tests:classNameattribute, CSS-property-keyed object value, bare class-shaped string outside JSX, media-query feature name, a genuine hyphenated compound (well-organised), theself-defence/self-centerpair, and a prose literal reporting alongside an excluded position in the same file. Fixtures extended inexamples/spelling_dialect.tsplus a newexamples/spelling_dialect_jsx.tsx.Known limits
Both lists are curated, not exhaustive — an uncommon CSS property or a plugin-added Tailwind root falls through to the ordinary prose rules. That matches
DIALECT_PAIRS' own restraint and fails in the safe direction only for the positional exclusions; a missed root means a false positive returns, not a silent miss.🤖 Generated with Claude Code
https://claude.ai/code/session_019afugU2bTYCtXn6Vy9dn1v