Files
TREK/client/scripts/layer-lint.mjs
T
Maurice bd267c67f8 ci(client): fail the count ratchets on an entry above the tree
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.
2026-10-08 14:11:54 +02:00

29 lines
1.4 KiB
JavaScript

#!/usr/bin/env node
/*
* lint:layers: imports follow the layering, downwards only.
*
* Components reached up into pages/ for models and helpers, and sideways into
* mobile/ for phone hooks and sheets, so nothing could be moved or split
* without touching three trees. scripts/lib/layers.mjs holds the rules: a
* component imports neither pages/ nor mobile/, a shared hook no view, and
* nothing under the views (stores, repos, sync, api, db, helpers) a view at
* all. The imports that already broke a rule are counted per file in
* scripts/layers-baseline.json, and a file may hold no more of them than its
* entry (a file without an entry holds none). Type-only imports count: a type
* the lower layer needs belongs below it. An entry above what its file holds
* now, or for a file that is gone, fails as well until --update lowers it.
*
* npm run lint:layers check against the baseline (CI)
* npm run lint:layers -- --list print every import against the layering
* npm run lint:layers -- --update lower the baseline to what the files hold now;
* it never raises an entry
*/
import { fileURLToPath } from 'node:url';
import { check } from './lib/layers.mjs';
import { runCli } from './lib/ratchet.mjs';
const root = fileURLToPath(new URL('..', import.meta.url));
await runCli('lint:layers', (args) =>
check({ root, update: args.includes('--update'), list: args.includes('--list') })
);