facebook / facebook/astryx

Formatting is enforced only by the local pre-commit hook; should CI check Prettier for the same scope?

Open
#6,186 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
13.2k
Forks
1.1k
Avg merge
1d 14h
Merged PRs (30d)
669

Description

## Current behavior

Prettier runs only through the lint-staged pre-commit hook (`*.{ts,tsx,md}` → `prettier --write`). No workflow runs `prettier --check`; `lint` is `check:repo` + ESLint, and ESLint carries no Prettier plugin. Commits that bypass the hook — squash merges, bot commits, `--no-verify` — land unformatted, and the hook then reformats such a file as part of whatever unrelated PR next stages it. This happened in #6150: merging `main` staged `docs/families/input-fields.md` (unformatted since #6183) and the hook rewrote 92 lines the PR never intended to touch.

Measured on current `main` (4,988 tracked source/doc files, `prettier --check`):

| kind | not clean | note |
|---|---|---|
| `.mjs` | 880 | outside the hook's pattern entirely |
| `.ts` / `.tsx` / `.js` | 171 | inside the hook's pattern |
| `.json` | 26 | |
| `.md` | 18 | `docs/`: only `docs/families/input-fields.md`; the rest are `.changeset/` |

Prior art searched: issues/PRs/discussions for "prettier", "formatting", "lint-staged", "format:check"; workflow history for a removed Prettier step. Closest is #3528 (hook breakage), which already noted that CI never runs the hook. No proposal or decision found.

## Question

Is a CI check wanted, and at what scope? Options, smallest first:

1. Keep hook-only enforcement; document that reviewers ask for Prettier on touched files (status quo, zero migration).
2. `prettier --check` in CI for exactly the hook's scope (`*.{ts,tsx,md}`), after a one-time format of the 189 affected files; `.changeset/` and `.mjs` stay out.
3. Full-repo check with a `.prettierignore` for generated output, after formatting 1,108 files.

The tool is a separate choice from the scope: the check can run Prettier as-is, or a Prettier-compatible formatter that is cheaper to run repo-wide (Biome, or Oxc's `oxfmt` alongside the `oxlint` already common in that toolchain). I'm not proposing a switch here; only noting that option 2 or 3 need not mean a slow CI step.

If option 2 (or 3) is chosen and the direction is settled, I'd be glad to send the migration.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the lint-staged pre-commit hook and the existing CI workflow that runs check:repo and ESLint. Compare the three proposed Prettier scopes and their reported affected-file counts, then confirm the chosen scope and formatter before implementation. Done means the settled formatting policy is enforced by CI without unrelated files being rewritten.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ci-cd, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.