Prettier "Code style issues found" - Fix prettier --check in CI
prettier --check (the CI-safe mode) found files whose formatting does not match Prettier's output and exits non-zero. It changes nothing - it reports the drift and fails the job so unformatted code cannot merge.
What this error means
A formatting step fails with [warn] Code style issues found in N files. Run Prettier with --write to fix., listing the offending files. The job exits non-zero; the fix is to format the files, not to retry.
Checking formatting...
[warn] src/App.tsx
[warn] src/utils/format.ts
[warn] Code style issues found in 2 files. Run Prettier with --write to fix.Common causes
Files not formatted before commit
Code was committed without running Prettier, so its formatting differs from prettier --check's expected output. The check is doing its job by failing.
Config/version drift between local and CI
A different Prettier version or .prettierrc between machines produces different formatting, so files formatted locally still fail the CI check.
How to fix it
Format the files
Run Prettier in write mode locally and commit the result; CI then passes.
npx prettier --write .
git add -A && git commit -m "Apply Prettier formatting"Pin Prettier and automate formatting
- Pin one Prettier version in
devDependenciesso local and CI agree. - Add a pre-commit hook (lint-staged + husky) to format on commit.
- Keep CI on
prettier --checkso unformatted code can never merge.
How to prevent it
- Pin a single Prettier version and share
.prettierrcacross the repo. - Run
prettier --writevia a pre-commit hook. - Gate CI on
prettier --check(not--write).