AndrewYou press Ctrl+S (Cmd+S on macOS) and watch a file rewrite itself twice. Double quotes become single,...
You press Ctrl+S (Cmd+S on macOS) and watch a file rewrite itself twice. Double quotes become single, a trailing comma appears, then vanishes; indentation jumps two spaces and back. On some saves the file settles into a state neither tool would produce alone, and on others consecutive saves keep flipping between two layouts. Nothing is corrupt — two tools with different formatting opinions are both editing the file during the same save.
This tutorial shows how to confirm the conflict from the command line, put eslint-config-prettier in the right place, and configure format on save in VS Code so Prettier owns formatting while ESLint only fixes correctness issues. You will finish with a repeatable check that proves the setup is stable outside the editor too.
A single save can trigger two independent rewriting passes in VS Code. The editor.formatOnSave setting asks the configured default formatter to format the document, and formatting behaviors like this are off by default until you enable them (VS Code's basic editing documentation covers the formatting settings). Separately, the ESLint extension can apply fixes through editor.codeActionsOnSave using the source.fixAll.eslint action (the VS Code ESLint extension documents this save hook). When both passes touch the same lines, you see the document change twice.
The overlap exists because ESLint was not always a pure correctness linter. Its core shipped stylistic rules that enforced quote style, semicolons, indentation and trailing commas. ESLint formally deprecated those formatting rules in v8.53.0 and now recommends using a dedicated formatter instead (ESLint's deprecation announcement lists the affected rules and the reasoning). Those rules still exist and are still enabled by many shareable configs, so if you never disabled them, ESLint is formatting with a different rulebook than Prettier.
The telltale symptoms map directly to that overlap:
| What changes on save | Rules with different opinions |
|---|---|
Quotes flip between 'single' and "double"
|
Prettier singleQuote vs ESLint quotes
|
| A trailing comma appears, then disappears | Prettier trailingComma vs ESLint comma-dangle
|
| Indentation jumps from two spaces to four | Prettier tabWidth vs ESLint indent
|
| Semicolons are added, then removed | Prettier semi vs ESLint semi
|
Whichever pass runs last decides what you see, and that order is not obvious from reading settings.json. That is why the result sometimes looks stable but wrong, and sometimes oscillates.
Before changing any settings, reproduce the problem with the tools themselves. Editor extensions hide the details, and you need to know whether the disagreement lives in your shared config or in VS Code's save behavior.
Pick a file that changes on save and run Prettier first, then ESLint's fixer:
npx prettier --write src/App.tsx
npx eslint --fix src/App.tsx
git diff -- src/App.tsx
npx uses the Prettier and ESLint installed in your project, which is the same pair the extensions use when they can find them locally.
If the diff shows ESLint editing the lines Prettier just wrote — restoring double quotes, deleting a trailing comma, re-indenting a block — the two configurations disagree. Confirm that the file no longer matches Prettier's output:
npx prettier --check src/App.tsx
A warning here means ESLint's fix pass had the last word. Run the pair again and the same diff will reappear, which is the CLI version of the flicker you see in the editor.
The package purpose-built for this problem is eslint-config-prettier. It turns off all ESLint rules that are unnecessary or might conflict with Prettier, and it only turns rules off, so it has to be combined with your other ESLint configs (the eslint-config-prettier README documents installation, ordering and its CLI helper).
npm install --save-dev eslint-config-prettier
.eslintrc configuration
With the older config format, add "prettier" to the extends array and make it the final entry:
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
]
}
Order is not cosmetic. ESLint resolves extended configs in sequence and later entries override earlier ones, so a config listed after eslint-config-prettier can silently re-enable indent or quotes. Putting "prettier" last gives it the final word over every shared config.
Flat config is the default in ESLint v9 and later. Import the flat entry point and place it after the configs you want to override:
// eslint.config.js
import someConfig from "some-other-config-you-use";
import eslintConfigPrettier from "eslint-config-prettier/flat";
export default [
someConfig,
eslintConfigPrettier,
];
Note the /flat suffix. The default eslint-config-prettier export is for .eslintrc files, and the flat export adds a name property so the config inspector can identify it.
eslint-config-prettier cannot disable rules in your own "rules" object, because your config is applied after the configs you extend. A leftover entry such as "indent": "error" re-creates the conflict even with prettier last. The package ships a helper that reports conflicting rules:
npx eslint-config-prettier src/App.tsx
It exits with code 0 when nothing is wrong and 2 when it finds conflicting rules. If your project uses overrides or per-folder configs, run it against a representative file from each group.
Once ESLint's formatting rules are off, the remaining job is to make sure VS Code never asks both tools to format the same document. The division of labor is simple: Prettier handles whitespace, quotes, line length and trailing commas; ESLint handles correctness — unused variables, undefined references, missing hook dependencies. Prettier's own guidance is to use Prettier for formatting concerns and linters for code-quality concerns (Prettier's linter integration page explains the split and the trade-offs).
| Setting | Before (ownership is ambiguous) | After (Prettier owns formatting) |
|---|---|---|
editor.defaultFormatter |
"dbaeumer.vscode-eslint" |
"esbenp.prettier-vscode" |
eslint.format.enable |
true |
false |
editor.codeActionsOnSave |
"source.fixAll.eslint": true |
"source.fixAll.eslint": "explicit" |
editor.formatOnSave |
true |
true |
If Prettier is already your default formatter, the settings change comes down to "explicit" plus switching off ESLint's formatter mode; the decisive fix is still the config from the previous section.
The boolean value for a save action is the old syntax. The supported values are explicit, always and never; true and false still work but are being deprecated. explicit runs the action when you save manually, while always also runs it on Auto Save (VS Code's refactoring documentation lists the supported save-action values). If you rely on Auto Save, "explicit" will leave ESLint fixes unapplied.
The resulting .vscode/settings.json looks like this:
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.format.enable": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}
Keeping source.fixAll.eslint enabled is safe once the conflicting rules are gone: ESLint can only fix rules it still reports, and formatting rules are no longer among them. Prettier remains the single formatter, so the file is written once per save.
If eslint-plugin-prettier is installed, ESLint also reports Prettier's output as lint errors. That setup can work, but it adds a layer that is slower and noisier than running Prettier directly, which is why Prettier's own docs suggest prettier --check and a direct editor integration instead.
A global editor.defaultFormatter applies to every language, including ones Prettier does not support. Language blocks are safer, and each language needs its own block because the Prettier extension's README warns that combined syntax such as "[javascript][typescript]" does not work for editor.defaultFormatter (the Prettier VS Code extension README documents the supported formatter values and language scoping):
{
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
Scope matters when a setting seems to be ignored. Workspace settings normally override user settings, but a language-specific user block overrides a non-language-specific workspace value, and object-valued settings are merged rather than replaced (VS Code's user and workspace settings documentation explains the precedence rules). For the menu route and the exact JSON for user, workspace and per-language scopes, our walkthrough on making Prettier the default formatter in VS Code shows where each value belongs in .vscode/settings.json.
Configuration changes are only trustworthy if the CLIs agree. Run Prettier, then ESLint's fixer, then ask Prettier whether the file is still in the shape it produced:
npx prettier --write src/App.tsx
npx eslint --fix src/App.tsx
npx prettier --check src/App.tsx
If the check passes, ESLint's fixes left formatting that Prettier agrees with. If it fails, ESLint rewrote what Prettier wrote and a conflicting rule survived — run the helper from the previous section and remove the rule it reports. Before the fix, this same sequence fails.
Then check the whole project the way CI would:
npx prettier --check .
npx eslint .
prettier --check should pass, and ESLint should report only real code-quality problems, not formatting. Run the three-command sequence a second time; once the file is stable, prettier --write and eslint --fix should leave it unchanged (commit the file first if you want git diff to show that clearly).
Finally, test the editor path: add and remove a space so the buffer is dirty, save, and check git diff; then run Format Document. A stable setup produces no formatting changes from either action.
| Trap | Fix |
|---|---|
prettier is in extends but not last |
Move it to the end and rerun npx eslint-config-prettier src/App.tsx
|
Your own "rules" block re-enables indent, quotes or comma-dangle
|
Delete those rules; the helper reports each one |
ESLint is still selected as the default formatter, or eslint.format.enable is on |
Set esbenp.prettier-vscode and disable ESLint's formatter mode |
Auto Save is on but the save action is "explicit"
|
Use "always" so fixes run on Auto Save too |
A file that changes twice on save is not a broken extension; it is two tools being asked to format the same lines. Reproduce it by running ESLint's fixer over Prettier's output and inspecting the diff, then fix the root cause by installing eslint-config-prettier and placing it last in extends — or after your other configs in eslint.config.js. In VS Code, make Prettier the explicit default formatter, turn off ESLint's formatter mode, and leave source.fixAll.eslint enabled only for the correctness rules that remain. Finish by rerunning both CLIs until prettier --check passes right after ESLint's fixer; once the command line is stable, the editor will be too.