If your pull requests are full of formatting churn and your editor reformats a file the moment ESLint has finished with it, you do not have a tooling problem. You have two tools trying to own the same job.
Prettier and ESLint are both good at what they do, and they overlap on exactly one thing that causes all the trouble: code style. ESLint ships stylistic rules — quote marks, semicolons, indentation, trailing commas — that Prettier also has an opinion about. Left alone, they disagree, and every save or commit becomes a small fight that shows up as noise in diffs and wasted minutes in review. The fix is not a cleverer rule set. It is a clean division of labour, enforced in one place, that every new clone of the repository inherits for free.
Draw the line: formatting versus correctness
The whole approach rests on one decision. Prettier owns formatting — how the code looks. ESLint owns correctness — whether the code is likely to be wrong. Once you accept that, the conflict has a mechanical solution: turn off every ESLint rule that is about appearance, and let ESLint keep only the rules that catch bugs.
Free · 4 minutes
Is your engineering team shipping safely, or quietly accumulating risk?
Fourteen questions on how work gets from idea to production — cadence, testing, rollback, and the key-person risk in your delivery. Banded finding on screen, full sheet by email.
You do not do that by hand. The package eslint-config-prettier exists precisely for this: it disables all ESLint rules that are unnecessary or that could conflict with Prettier. You add it last in your configuration, so its rule-disabling overrides anything switched on earlier. After that, ESLint stops caring about semicolons and Prettier is the only voice on layout. There is nothing left to argue about.
This assumes ESLint 9 and its flat config. If you are still on the legacy .eslintrc format, sort that out first — the migration is its own piece of work, and I have written about doing it without breaking your lint rules. Everything below assumes a flat eslint.config.mjs.
The configuration
Install the tools. Names and roles are stable across current versions — Prettier 3, ESLint 9, and eslint-config-prettier 10.
npm install --save-dev \
eslint @eslint/js globals \
prettier eslint-config-prettier \
lint-staged husky
The flat config. Note the single most important line: eslint-config-prettier/flat is spread last. Order is not cosmetic here — anything after it could re-enable a rule it just switched off.
// eslint.config.mjs
import js from "@eslint/js";
import globals from "globals";
import prettier from "eslint-config-prettier/flat";
export default [
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 2024,
sourceType: "module",
globals: { ...globals.node, ...globals.browser },
},
rules: {
// correctness rules only — never style
"no-unused-vars": "warn",
"no-undef": "error",
},
},
// MUST be last: switches off every ESLint rule that would fight Prettier
prettier,
];
The /flat import path is the current recommendation for ESLint 9 configs; it adds a name property so the config inspector shows you what it did. Then give Prettier its own file, so the settings live in the repository rather than in each developer’s head.
// .prettierrc.json
{
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100
}
You can verify the split is clean without reading every rule. The package ships a checker that inspects the config actually applied to a file and reports any style rule still enabled that Prettier would contradict:
npx eslint-config-prettier src/index.js
A clean exit means the two tools no longer overlap. A non-zero exit names the offending rules so you can remove them.
Wire it into commit, not into good intentions
A config that only runs when someone remembers to run it is a config that drifts. The point of the exercise is that formatting and linting happen automatically on the files a developer is about to commit — no more, no fewer. That is what lint-staged is for: it runs your tools against staged files only, so a commit touching one file does not reformat the whole tree.
// package.json
{
"scripts": {
"lint": "eslint .",
"format": "prettier --write .",
"format:check": "prettier --check .",
"prepare": "husky"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.{json,css,md,yml,yaml}": [
"prettier --write"
]
}
}
Run ESLint first, then Prettier. ESLint fixes what it can (unused imports, and so on); Prettier then lays the result out. Because eslint-config-prettier has already silenced the style rules, ESLint’s --fix never touches formatting, so Prettier is not undoing ESLint’s work. The two commands run in sequence with nothing to squabble over.
The prepare script installs the Husky hooks on npm install. Add the pre-commit hook once:
npx husky init
echo "npx lint-staged" > .husky/pre-commit
Now anyone who clones the repository and runs npm install gets the hook automatically. There is nothing to document in a wiki, nothing to remember, and nothing a new joiner can quietly skip. The setup is the same reproducibility discipline that makes pinned developer tooling worth the effort on any team.
The editor and the gate that backs it up
Two more pieces close the loop. First, format-on-save, so developers see the formatted result as they work rather than at commit. In VS Code, commit a .vscode/settings.json to the repository so the team shares it:
// .vscode/settings.json
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}
Second, a CI check, because pre-commit hooks can be bypassed with --no-verify and not everyone uses the same editor. CI is the line that actually holds. Fail the build if anything is unformatted or fails to lint:
# .github/workflows/lint.yml (job steps)
- run: npm ci
- run: npx prettier --check .
- run: npx eslint .
Use prettier --check, not --write, in CI: the pipeline reports drift, it does not silently rewrite history. This is the same instinct as putting the contract before the code in spec-first API work — you make the standard machine-checkable and non-negotiable, rather than a matter of taste in review.
That is the whole system: Prettier formats, ESLint finds bugs, eslint-config-prettier keeps them out of each other’s lane, lint-staged runs both on commit, and CI refuses anything that slips through. The reward is not tidier code for its own sake. It is that formatting stops appearing in your diffs entirely, so review is about the change and nothing else — which is the only reason any of this was worth doing.
Build and rescue work
Hands-on delivery of this kind is handled by Sixteen Pillars Studio.
Free interactive tool
Website compliance checklist
What your site has to do, based on what it actually does
Answer as much or as little as you like — the list builds as you go. Nothing is stored against your name and no email is required.
Everything that applies
Ordered by what to do first: legal requirements you can close quickly, then larger pieces of work, then what is expected rather than required. Not exhaustive, and not a legal audit.
Dated PDF, yours to keep or circulate.
Most technology problems are not technology problems. They are control problems.
The systems exist. The investment has been made. The question is whether leadership can understand, direct, evidence, and sustain what those systems produce. Find out where control exists — and where it only appears to.