mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
724c88c201
A mechanical prettier --write over server/src, server/tests, server/scripts and shared/src with the workspaces' .prettierrc; nothing but layout and import order changes, and every file keeps the same set of imports. shared is formatted throughout and its format baseline is empty. The server baseline keeps the 35 files that Prettier would grow past their lint:size limit (they need a split first, which is not a formatting change), and the generated entity files stay as their generator writes them.
46 lines
1.9 KiB
JavaScript
46 lines
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
/*
|
|
* lint:format: new server code is formatted with Prettier.
|
|
*
|
|
* `npm run format:check` was never part of CI, and most files differ from what
|
|
* .prettierrc asks for. Formatting all of them belongs in one mechanical
|
|
* commit of its own; until it lands, 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. After the
|
|
* mass reformat, --update empties the list and the check is a plain
|
|
* prettier --check over 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
|
|
*
|
|
* src/db/entities/ is generated and checked by check:entities instead.
|
|
*
|
|
* To format a file: npx prettier --write <file>. The comparison lives in
|
|
* scripts/lib/format.mjs at the repository root; Prettier and its config come
|
|
* from this workspace.
|
|
*/
|
|
import { check } from '../../scripts/lib/format.mjs';
|
|
import { runCli } from '../../scripts/lib/ratchet.mjs';
|
|
|
|
import { fileURLToPath } from 'node:url';
|
|
import * as prettier from 'prettier';
|
|
|
|
const root = fileURLToPath(new URL('..', import.meta.url));
|
|
// The entity files are written by scripts/generate-entities.ts and held byte for
|
|
// byte to its output by check:entities, so their layout is the generator's, not
|
|
// Prettier's. .prettierignore keeps `npm run format` off them for the same reason.
|
|
const GENERATED = 'src/db/entities/';
|
|
await runCli('lint:format', (args) =>
|
|
check({
|
|
prettier,
|
|
root,
|
|
dirs: ['src', 'tests'],
|
|
accepts: (key) => key.endsWith('.ts') && !key.startsWith(GENERATED),
|
|
update: args.includes('--update'),
|
|
list: args.includes('--list'),
|
|
}),
|
|
);
|