Files
TREK/client/scripts/size-lint.mjs
T
Maurice 9d596d9916 ci(client): lint:size measures the Playwright specs and fixtures too
The size check walked src/ and tests/ only, while lint:format and
lint:skips already cover e2e/. The help center fixtures under
e2e/help/fixtures.ts hold 2291 wrapped lines, past the 2000 a test may
reach, and could grow without bound. e2e/ is now measured with the test
limit; fixtures.ts enters the baseline at its current size, every other
file there is within the limit.
2026-10-08 13:04:41 +02:00

28 lines
1.4 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).
*
* 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') }));