|
| 1 | +# 0011. Use Prettier and a single check gate |
| 2 | + |
| 3 | +Date: 2026-05-26 |
| 4 | + |
| 5 | +Status: Accepted |
| 6 | + |
| 7 | +## Context |
| 8 | + |
| 9 | +vanityURLs includes JavaScript, JSON, Markdown, HTML, CSS, TOML, and YAML files. Before this decision, the repository |
| 10 | +had custom linting and tests, but no automatic formatter. Formatting drift could show up late, and CI could not enforce |
| 11 | +the same style that maintainers use locally. |
| 12 | + |
| 13 | +The project also needs one obvious command for local verification and CI/CD. Instance owners should not need to remember |
| 14 | +separate format, build, lint, and test commands before pushing. |
| 15 | + |
| 16 | +## Decision |
| 17 | + |
| 18 | +Use Prettier as the automatic formatter for supported text files. |
| 19 | + |
| 20 | +Expose two explicit formatting commands: |
| 21 | + |
| 22 | +- `npm run format` rewrites supported files with Prettier |
| 23 | +- `npm run format:check` verifies that supported files already match Prettier output |
| 24 | + |
| 25 | +Keep `scripts/lint.mjs` as the project-specific lint layer for checks Prettier does not cover, including trailing |
| 26 | +newlines, JSON parse errors, JavaScript syntax checks, and vanityURLs-specific `wrangler.toml` expectations. |
| 27 | + |
| 28 | +Make `npm run check` the single local and CI gate. It runs, in order: |
| 29 | + |
| 30 | +1. `npm run format:check` |
| 31 | +2. `node scripts/build.mjs` |
| 32 | +3. `npm run lint` |
| 33 | +4. `npm test` |
| 34 | + |
| 35 | +The GitHub Actions check workflow runs `npm ci` followed by `npm run check`. |
| 36 | + |
| 37 | +## Consequences |
| 38 | + |
| 39 | +- Formatting is deterministic locally and in CI |
| 40 | +- Maintainers can run `npm run format` before committing noisy style changes |
| 41 | +- `npm run check` remains the one command to run before pushing |
| 42 | +- Prettier does not replace project-specific linting or runtime tests |
| 43 | +- The installer can run the same check gate quietly and show a concise setup result |
0 commit comments