Files
TREK/client/scripts/eslint-ratchet.mjs
T
Maurice 1b60de27f4 ci(client): lint:warnings fails an inline rule config comment
A block comment such as /* eslint @typescript-eslint/no-explicit-any: off */
turns a rule off for its file without leaving a message behind, neither
among the warnings nor among the suppressed ones, so a new file could
switch any warning rule off and the ratchet stayed green. eslint-disable
comments were already counted under "suppressed"; this was the way
around them.

lintClient now reads the block comments of every file ESLint linted from
the TypeScript parser, so the same text in a string, a template or a
regex does not count, and the tally reports each config comment as an
error. Nothing in the client uses one today, so the check is zero
tolerance. The tests baseline drops by one no-unused-vars warning that
is gone.
2026-10-08 13:04:41 +02:00

27 lines
1.4 KiB
JavaScript

#!/usr/bin/env node
/*
* lint:warnings: ESLint warnings may only go down.
*
* Most rules in eslint.config.mjs are warnings, set that way to keep CI green
* on code that was never linted, and a warning never fails a build. So they
* piled up: unused variables hiding dead props, missing effect dependencies
* of the kind that has already shown stale money. This runs ESLint over the
* client and counts the warnings per rule, separately for app code and
* tests, and the messages an eslint-disable comment silenced as a third
* group. Each count may not pass its entry in scripts/eslint-baseline.json.
* Any error fails as well, so the check can stand in for `npm run lint:check`,
* and so does a block comment that configures a rule inline (such as one that
* turns no-explicit-any off): it leaves no message to count, so it would
* otherwise be the free way past the ratchet.
*
* npm run lint:warnings check against the baseline (CI)
* npm run lint:warnings -- --update lower the baseline to today's counts;
* it never raises an entry
*/
import { fileURLToPath } from 'node:url';
import { check } from './lib/eslint-warnings.mjs';
import { runCli } from './lib/ratchet.mjs';
const root = fileURLToPath(new URL('..', import.meta.url));
await runCli('lint:warnings', (args) => check({ root, update: args.includes('--update') }));