Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Prettier Processor

Purpose

Checks that files are formatted the way Prettier would format them.

How It Works

Runs prettier --check <files>. Prettier exits non-zero when a file is not formatted, which fails the product; its output names the files:

[warn] web/a.js
[warn] Code style issues found in the above file. Run Prettier with --write to fix.

Prettier’s own config file is read as usual, and any of .prettierrc, .prettierrc.json, .prettierrc.js, .prettierrc.yml, .prettierrc.yaml, .prettierrc.toml, .prettierrc.cjs, .prettierrc.mjs, prettier.config.js, prettier.config.cjs and prettier.config.mjs that exists is an input (dep_auto), so editing it re-checks every file.

This processor checks only. To reformat, run prettier --write yourself.

Source Files

  • Input: files under src_dirs with extensions .js .jsx .ts .tsx .mjs .cjs .css .scss .less .html .json .md .yaml .yml
  • Output: none (checker)

The default src_dirs is empty, so a stanza with no src_dirs or src_files checks nothing: name the directories ([""] for the whole project) or files to check.

Configuration

[processor.checker.prettier]
src_dirs = ["web"]
KeyTypeDefaultDescription
commandstring"prettier"The prettier executable to run
argsstring[][]Extra arguments passed to prettier
src_dirsstring[][]Directories to scan
src_extensionsstring[](list above)File extensions to check
dep_inputsstring[][]Extra files whose changes trigger rebuilds
dep_autostring[](config files above)Config files that are inputs when they exist

Batch support

The tool accepts multiple files on the command line. When batching is enabled (default), rsconstruct passes all files in a single invocation; a failure then marks every file in that invocation as failed (see batch in Configuration). Set batch = false to have each file reported on its own.

Clean behavior

This processor is a Checker — rsconstruct clean outputs is a no-op for it (checkers produce no outputs). See Clean behavior and rsconstruct clean.