mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-20 22:16:26 +00:00
07f35d8b81
eslint.config.mjs keeps most rules at warn so that CI stayed green on a codebase that was never linted, and CI runs eslint without --max-warnings. Warnings therefore only ever accumulated: 1218 today, among them 194 unused variables and 144 missing effect dependencies in app code, the kind behind the stale closures #2610 chased. lint:warnings runs ESLint over the client with its own config and counts the warnings per rule, separately for app code and for tests, so the headroom from fixing a test cannot be spent in app code. Messages that an eslint-disable comment silenced are counted as a third group, so an inline disable is no way past the ratchet either. No count may pass its entry in scripts/eslint-baseline.json, and --update only lowers. Any error, a parse failure included, fails the check too, so it can replace the plain lint:check step in CI instead of running ESLint twice.
24 lines
1.2 KiB
JavaScript
24 lines
1.2 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`.
|
|
*
|
|
* 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') }))
|