Files
TREK/client/scripts/format-lint.mjs
T
Maurice 37d386178b ci(client): lint:format keeps new client code Prettier-formatted
client/package.json has had a format:check script, but no workflow runs
it, and 2144 of the 2171 .ts, .tsx and .css files under src/ and tests/
differ from what .prettierrc asks for. Without a formatter gate the line
count in lint:size could also be gamed, and every new file picked its
own layout.

Formatting everything in one commit would bury the history, so lint:format
lists today's unformatted files in scripts/format-baseline.json and only
lets the list shrink: a file outside it, any new file in particular, must
be formatted, and a listed file that has been formatted must leave the
list (--update takes it off and never adds one). A stale entry fails the
check, since it would let the next file at that path in unformatted.

The check runs Prettier through its API with the config that applies to
each file and reads the text with LF line ends, so a Windows checkout
agrees with CI about endOfLine. A file Prettier cannot parse counts as
unformatted, and a missing config stops the run.
2026-10-08 13:04:39 +02:00

27 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
/*
* lint:format: new code is formatted with Prettier.
*
* Client code was never Prettier-checked, and almost every file differs from
* what .prettierrc asks for. Formatting all of it at once would bury the
* history under one commit, so the files that were unformatted when this
* check came in are listed in scripts/format-baseline.json and the list only
* shrinks: every file outside it, a new one in particular, must be formatted,
* and a listed file leaves the list once it has been formatted. The check
* covers .ts, .tsx and .css under src/ and tests/.
*
* npm run lint:format check against the baseline (CI)
* npm run lint:format -- --list print every unformatted file
* npm run lint:format -- --update take formatted and deleted files off the list;
* it never adds one
*
* To format a file: npx prettier --write <file>. The comparison lives in
* scripts/lib/format.mjs.
*/
import { fileURLToPath } from 'node:url'
import { check } from './lib/format.mjs'
import { runCli } from './lib/ratchet.mjs'
const root = fileURLToPath(new URL('..', import.meta.url))
await runCli('lint:format', (args) => check({ root, update: args.includes('--update'), list: args.includes('--list') }))