Public: anyone can read this; the crew can change it.

scripts/design-lint.ts runs the empty-words and width-read ratchets, so a builder sees them before the push #17531

opened this

Merged 13h 8m ago, live in production

bun scripts/design-lint.ts now runs the two ratchets the check refused most often last week: a page's own bare "No …" empty states and width reads in script.

Notes

opened this

bun scripts/design-lint.ts now runs the two ratchets the check refused most often last week: a page's own bare "No …" empty states and width reads in script. It names each file that breaks one, with the tests' count and the fix:

src/web/pages/map.ts: 1 > 0 bare 'No …' empty states; add the words to the EMPTY_WORDS table (src/core/empty_words.ts) and draw them with emptyList(kind)
src/web/pages/map.ts: 3 reads of a width in script; use a media or container query
  • One module for the counting: the "No …" pattern, OWN_WORDS, the width pattern, WIDTH_READS and WIDTH_SKIP move out of the two tests into src/design/ratchets.ts. test/empty-words-all.test.ts, test/behaviors-rule.test.ts and scripts/design-lint.ts all import it, so there is one copy of each pattern and table.
  • What the tests check is unchanged: each still reads the same files and expects an empty list. The tables are copied over as they were.
  • Fewer than named: the lint also reports a page whose count dropped below its OWN_WORDS entry, so the list of own words test is not a surprise either.

Things to look at:

  • Not under src/web/ as the issue asked: the module is in src/design/, beside width.ts and motion.ts. The empty-words scan reads every file under src/web, so the module would be scanned by its own rule.
  • The width pattern is written differently: it now reads inner[W]idth|client[W]idth|offset[W]idth|…, which matches exactly what it did. Written plainly, the module's own source would count as three width reads, because the width scan reads all of src/.
  • Every file, not just changed ones: the lint reads the same files as the tests (all of src/web for empty words, src/ minus vendor/render/og for width). It reports changed files as the issue asks, and any other file off its count.
  • @tree-scan lines: both tests now list files through tsSources, so each carries a @tree-scan line and the fast tier still finds it.

New test test/design-lint-ratchets.test.ts gives ratchetFindings a page with one bare "No …" too many and a file with one width read too many, and checks both lines and their fixes. It also covers a file exactly at its count (no finding), one below it (told to lower the count), and a file not in either table. Without this change it fails, because ratchetFindings does not exist.

Nothing was reused: scripts/similar.ts found no existing finder for these counts. The gate flagged my first two empty-words functions as near-duplicates, so they are now one, ownWordsOff, returning { over, moved }.

Checks: the gate (32 rules satisfied), bun x tsc --noEmit and bun scripts/design-lint.ts all pass. scripts/fast.ts called the diff too broad to pick tests for, so I ran the ones it reaches and they passed: design-lint*, empty-words-all, empty-notes, behaviors-rule, unused-exports, tree-scans and module-state. The full suite runs on the forge's check.

To try it: add window.innerWidth to any file under src/web, or add one extra <p class="muted">No …</p>, then run bun scripts/design-lint.ts.

🤖 Generated with Claude Code

Closes #17521

commented

bun scripts/design-lint.ts now runs the two ratchets the check refused most often last week: a page's own bare "No …" empty states and width reads in script. It names each file that breaks one, with the tests' count and the fix:

src/web/pages/map.ts: 1 > 0 bare 'No …' empty states; add the words to the EMPTY_WORDS table (src/core/empty_words.ts) and draw them with emptyList(kind)
src/web/pages/map.ts: 3 reads of a width in script; use a media or container query
  • One module for the counting: the "No …" pattern, OWN_WORDS, the width pattern, WIDTH_READS and WIDTH_SKIP move out of the two tests into src/design/ratchets.ts. test/empty-words-all.test.ts, test/behaviors-rule.test.ts and scripts/design-lint.ts all import it, so there is one copy of each pattern and table.
  • What the tests check is unchanged: each still reads the same files and expects an empty list. The tables are copied over as they were.
  • Fewer than named: the lint also reports a page whose count dropped below its OWN_WORDS entry, so the list of own words test is not a surprise either.

Things to look at:

  • Not under src/web/ as the issue asked: the module is in src/design/, beside width.ts and motion.ts. The empty-words scan reads every file under src/web, so the module would be scanned by its own rule.
  • The width pattern is written differently: it now reads inner[W]idth|client[W]idth|offset[W]idth|…, which matches exactly what it did. Written plainly, the module's own source would count as three width reads, because the width scan reads all of src/.
  • Every file, not just changed ones: the lint reads the same files as the tests (all of src/web for empty words, src/ minus vendor/render/og for width). It reports changed files as the issue asks, and any other file off its count.
  • @tree-scan lines: both tests now list files through tsSources, so each carries a @tree-scan line and the fast tier still finds it.

New test test/design-lint-ratchets.test.ts gives ratchetFindings a page with one bare "No …" too many and a file with one width read too many, and checks both lines and their fixes. It also covers a file exactly at its count (no finding), one below it (told to lower the count), and a file not in either table. Without this change it fails, because ratchetFindings does not exist.

Nothing was reused: scripts/similar.ts found no existing finder for these counts. The gate flagged my first two empty-words functions as near-duplicates, so they are now one, ownWordsOff, returning { over, moved }.

Checks: the gate (32 rules satisfied), bun x tsc --noEmit and bun scripts/design-lint.ts all pass. scripts/fast.ts called the diff too broad to pick tests for, so I ran the ones it reaches and they passed: design-lint*, empty-words-all, empty-notes, behaviors-rule, unused-exports, tree-scans and module-state. The full suite runs on the forge's check.

To try it: add window.innerWidth to any file under src/web, or add one extra <p class="muted">No …</p>, then run bun scripts/design-lint.ts.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs