Skip to content
Latchkey

Prettier "Code style issues found" - Fix the CI Check (--check)

prettier --check (the CI-safe mode) found files whose formatting does not match Prettier's output and exits non-zero. It does not change anything - 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.

prettier output
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.

Terminal
npx prettier --write .
git add -A && git commit -m "Apply Prettier formatting"

Pin Prettier and automate formatting

  1. Pin one Prettier version in devDependencies so local and CI agree.
  2. Add a pre-commit hook (lint-staged + husky) to format on commit.
  3. Keep CI on prettier --check so unformatted code can never merge.

How to prevent it

  • Pin a single Prettier version and share .prettierrc across the repo.
  • Run prettier --write via a pre-commit hook.
  • Gate CI on prettier --check (not --write).

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →