Prettier Integration
Prettier enforces consistent formatting so code review focuses on behavior, not semicolons and line breaks.
Search across all documentation pages
Prettier enforces consistent formatting so code review focuses on behavior, not semicolons and line breaks.
Quick-reference recipe card - copy-paste ready.
npm install -D prettier eslint-config-prettier// .prettierrc
{
"semi": true,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 100
}{
"scripts": {
"format": "prettier --write .",
"format:check": "prettier --check ."
}
}When to reach for this:
// eslint.config.js
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
{ ignores: ["dist/**"] }
);// package.json
{
"scripts": {
"lint": "eslint .",
"format": "prettier --write .",
"format:check": "prettier --check ."
},
"devDependencies": {
"prettier": "^3.4.0",
"eslint-config-prettier": "^9.1.0",
"husky": "^9.1.0",
"lint-staged": "^15.2.0"
}
}// lint-staged.config.js
export default {
"*.{ts,json,md}": ["prettier --write"],
"*.ts": ["eslint --fix"],
};npx husky init
echo "npx lint-staged" > .husky/pre-commitWhat this demonstrates:
eslint-config-prettier disables ESLint stylistic rules that fight Prettier.lint-staged formats only staged files on commit.format:check runs in CI without modifying files.--check to fail PRs with unformatted diffs.{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}tsc --noEmit in CI.format script.eslint-config-prettier, remove stylistic ESLint plugins..git-blame-ignore-revs.--no-verify - Bad code can still land. Fix: enforce format:check and lint in CI regardless of hooks.devDependencies; use npm ci.dist/, openapi.json to .prettierignore.| Alternative | Use When | Don't Use When |
|---|---|---|
| ESLint stylistic only | No Prettier in org policy | Team already standardized on Prettier |
| Biome | Want lint+format one tool | Ecosystem plugins expect ESLint |
| EditorConfig alone | Basic indentation only | TypeScript needs full formatter |
No. Prettier formats; ESLint catches unused vars, promise misuse, and import boundaries.
format:check in CI (read-only). Developers run format or rely on pre-commit hooks locally.
Add paths to .prettierignore (same syntax as .gitignore).
Yes. Root .prettierrc applies across monorepo workspaces unless overridden.
Prettier supports YAML; Dockerfiles need a plugin or separate linter. Prioritize TS/JSON/MD first.
No, but it keeps commits fast. CI format:check is the real gate.
One PR: npm run format, add CI check, optionally .git-blame-ignore-revs for the format SHA.
Rarely with flat config. Prefer eslint-config-prettier disable list instead of running Prettier inside ESLint.
Yes if docs live in repo - consistent wrapping helps diffs in site/ and README files.
Root script: "format:check": "prettier --check ." with ignores for dist/ in each package.
Stack versions: This page was written for Node.js 24.18.0 (Active LTS), npm 10+, TypeScript 5.6+, Express 5, Fastify 5, and NestJS 11.
Reviewed by Chris St. John·Last updated Jul 18, 2026