Prettier ConfigPrettier Config

checkIgnorePragma β€” lets a file opt itself out of formatting entirely

The Prettier Check Ignore Pragma option

checkIgnorePragma makes Prettier honour a @noprettier marker in a file's first block comment and skip that file completely. It is the opt-out counterpart to requirePragma, and it is most useful for generated files whose paths are awkward to express in .prettierignore.

Check whether the file's first docblock comment contains '@noprettier' or '@noformat' to determine if it should be formatted.
Prettier's own description, from the official options documentation
Default
false
Type
boolean
CLI flag
--check-ignore-pragma

What the option does

With checkIgnorePragma: true, Prettier inspects the first block comment of each file and skips any that contains @noprettier:

/**
 * @noprettier
 * Generated by scripts/build-schema.mjs β€” do not edit.
 */
This file will not be formatted.

The default is false, meaning the marker is ignored and the file is formatted like any other.

Why it is better than .prettierignore for generated files

A generator that emits files across several directories, or whose output paths depend on the input, is genuinely hard to express as a set of ignore globs. Keeping that pattern list in step with the generator is a maintenance task that nobody remembers until formatting breaks something.

Emitting the marker from the generator itself moves the decision to where the knowledge is. Any file the generator writes announces its own status, and the ignore list never needs updating β€” the file and its exemption travel together, including when the output layout changes.

It is also self-documenting. Someone opening the file sees immediately why it is not formatted, which an entry in .prettierignore does not tell them.

How it differs from prettier-ignore

  • @noprettier with this option skips the entire file.
  • // prettier-ignore skips the next node only, and needs no option β€” it is always honoured.
  • .prettierignore skips by path, and is the right tool for whole directories such as dist/ or node_modules/.

Reach for the narrowest of the three that solves your problem. A single stubborn matrix literal wants // prettier-ignore, not a whole-file exemption.

Version note and common mistakes

checkIgnorePragma was added in Prettier 3.5. On earlier releases the marker has no effect at all, whatever your configuration says.

  • Adding @noprettier without enabling the option, so the file is formatted anyway.
  • Using a line comment. It must be a block comment, and the first one in the file.
  • Reaching for it when // prettier-ignore on a single node would do.
  • Expecting it on Prettier 3.4 or older.

Choosing among the four ways to skip formatting

Prettier offers four mechanisms and they are easy to confuse. They differ in scope and in where the decision is recorded:

  • // prettier-ignore β€” skips the next node. Always active, no configuration. Use it for a single hand-aligned matrix or ASCII table.
  • @noprettier with checkIgnorePragma β€” skips the whole file, recorded in the file. Use it for generated output whose paths are hard to enumerate.
  • .prettierignore β€” skips by path glob. Use it for whole directories such as dist/ or vendored code.
  • requirePragma β€” inverts the default so only marked files are formatted. Use it for gradual adoption, not for exclusions.

Prefer the narrowest mechanism that solves the problem. Reaching for a whole-file exemption when one node is the difficulty means the rest of the file quietly stops being formatted, and nobody notices until it has drifted.

Emitting the marker from a generator

The reason to prefer this over .prettierignore for generated code is that the generator already knows what it wrote. Emitting the header alongside the usual do-not-edit warning keeps the exemption and the file in one place:

const header = [
  '/**',
  ' * @noprettier',
  ' * Generated by scripts/build-schema.mjs β€” do not edit.',
  ' */',
  '',
].join('\n');

writeFileSync(out, header + body);
A generator writing its own exemption.

Note the trade-off: a file exempted this way is also not checked by prettier --check in CI, so a hand-edit that breaks its formatting will not be caught. That is usually the intent for generated files, but it is worth being deliberate about.

Use it in .prettierrc

Drop checkIgnorePragma into your Prettier config file:

{
  "checkIgnorePragma": false
}
Try it in the generator

Common questions

Why is my @noprettier comment being ignored?
Either checkIgnorePragma is not enabled β€” it defaults to false β€” or you are on a Prettier older than 3.5, where the option does not exist.
When should I use this instead of .prettierignore?
When the files are generated and their paths are hard to enumerate. Emit the marker from the generator and the exemption travels with the file.

Other Special options

Generated from Prettier 3.9.6.