Prettier "--check" Fails on Ignored Files - Fix .prettierignore in CI
Prettier --check fails when it formats files you never intended to format - build output, generated code, vendored assets. Usually .prettierignore is in the wrong place relative to where Prettier runs, the glob passed on the CLI overrides ignore handling, or the paths simply are not listed.
What this error means
prettier --check . reports formatting issues in dist/, build/, generated files, or node_modules-adjacent output, failing CI even though your source is formatted. The flagged files are ones you do not author.
Checking formatting...
[warn] dist/bundle.js
[warn] src/generated/schema.ts
[warn] Code style issues found in 2 files. Run Prettier to fix.
Error: Process completed with exit code 1.Common causes
.prettierignore not in the run directory
Prettier reads .prettierignore from the current working directory by default. If CI runs Prettier from a different directory (or in a monorepo subpackage), the root ignore file is not applied.
Generated/output paths not ignored
Build output (dist/, build/, .next/), generated code, and snapshots are not listed in .prettierignore, so prettier --check . formats and flags them.
How to fix it
List generated and output paths in .prettierignore
Ignore everything Prettier should not own, in the directory Prettier runs from.
# .prettierignore
dist/
build/
.next/
coverage/
**/*.generated.ts
package-lock.jsonPoint Prettier at the right ignore file
Pass --ignore-path explicitly, or narrow the check glob to source only.
# explicit ignore path (e.g. reuse .gitignore)
npx prettier --check . --ignore-path .gitignore
# or scope the check to source
npx prettier --check "src/**/*.{ts,tsx,css}"How to prevent it
- Keep
.prettierignorein the directory Prettier runs from. - Ignore build output and generated files explicitly.
- Scope
--checkglobs to source, or pass--ignore-path.