mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
bd267c67f8
lint:size, lint:layers, lint:rtl (both baselines), lint:skips and lint:warnings only failed a count that passed its entry. A count that fell below its entry was logged and nothing more, so a file that shrank could grow back to its old entry unseen, and the entry of a deleted file stayed behind for the next file at that path. lint:format and lint:offline already fail on such a stale entry, and the docs said these counts may only shrink. Each of them now fails on an entry that lowerCounts would lower or drop, naming its count or saying the file is gone, and tells to run --update, which still only lowers. staleCounts and reportStale in lib/ratchet.mjs hold the shared part. Every baseline matches the tree today, so none needed lowering. The client CLAUDE.md says so, and that CI lints through lint:warnings rather than lint:check.
31 lines
1.6 KiB
JavaScript
31 lines
1.6 KiB
JavaScript
#!/usr/bin/env node
|
|
/*
|
|
* lint:size: keeps files from growing into the next god file.
|
|
*
|
|
* A file past a thousand lines holds several concerns that no longer fit in
|
|
* one reading, and every change to one of them risks the others. Each source
|
|
* file and stylesheet under src/ may hold 1000 lines, each test (under tests/,
|
|
* a Playwright spec or fixture under e2e/, or a co-located *.test.*) 2000. Lines are counted as an editor wraps them
|
|
* at 120 columns, so joining lines does not make a file smaller. The files
|
|
* that were already larger are listed in scripts/size-baseline.json with the
|
|
* size they had, and the check fails when one of them grows past its entry. A
|
|
* file that needs to grow is split by concern instead (the trip planner hook,
|
|
* page and road trip sidebar are the precedent). An entry above the file's
|
|
* size now, or for a file that is gone, fails as well until --update lowers
|
|
* it: otherwise the file could grow back unseen, and a new file at a deleted
|
|
* path would inherit its allowance.
|
|
*
|
|
* npm run lint:size check against the baseline (CI)
|
|
* npm run lint:size -- --update lower the baseline to what the files hold now;
|
|
* it never raises an entry, and drops a file
|
|
* that is back under its limit
|
|
*
|
|
* The measuring lives in scripts/lib/size.mjs.
|
|
*/
|
|
import { fileURLToPath } from 'node:url';
|
|
import { runCli } from './lib/ratchet.mjs';
|
|
import { check } from './lib/size.mjs';
|
|
|
|
const root = fileURLToPath(new URL('..', import.meta.url));
|
|
await runCli('lint:size', (args) => check({ root, update: args.includes('--update') }));
|