Lorixen.
EN

End formatting noise in code reviews: EditorConfig and Prettier

Short answer: If code reviews keep filling up with indentation, quote-style and line-length changes, settle formatting with tools instead of comments. An .editorconfig file tells editors the basics, such as indentation, line endings and final newlines, and a formatter like Prettier rewrites code into one consistent style automatically. Run the formatter on save and in CI, reformat the whole codebase once in a single commit, and from then on reviews can focus on what the code does.

Why formatting noise is costly

When each developer's editor formats code differently, every pull request carries changes nobody meant to make: tabs turned to spaces, quotes swapped, lines rewrapped. Reviewers either waste time on them or start skimming, and that's how real problems slip through. Debates about style also eat time in small teams, especially when contractors or new hires join with their own habits.

Prettier's own documentation states the motivation directly, quoting its "Why Prettier?" page: by far the biggest reason for adopting it is to stop all the ongoing debates over styles. It's deliberately opinionated and offers only a limited set of options.

EditorConfig: the shared baseline

EditorConfig is a small file, .editorconfig, at the root of your repository that many editors and IDEs read directly or through a plugin. A typical file:

  • root = true at the top, telling editors to stop looking in parent folders.
  • A [*] section with end_of_line = lf, insert_final_newline = true and charset = utf-8.
  • Indentation rules by file type, such as indent_style = space and indent_size = 2 for web files, or indent_style = tab for a Makefile.

These examples follow the sample on the EditorConfig site. The value is that every editor, from a heavyweight IDE to a quick terminal editor, starts from the same basic settings, even for file types your formatter doesn't handle.

Prettier: one style, applied automatically

Prettier reformats supported files, such as JavaScript, TypeScript, CSS, HTML, JSON, Markdown and YAML, by parsing the code and printing it again in a consistent style. Because it rewrites rather than suggests, there's nothing to argue about once it's adopted.

Setting it up:

  1. Add Prettier as a development dependency with an exact version, so everyone gets the same output.
  2. Add a small config file if you need to change one of its few options, such as print width or quote style. Many teams keep the defaults.
  3. Add a .prettierignore file for files that shouldn't be reformatted, such as generated code, vendored libraries or build output. Prettier's documentation also supports prettier-ignore comments to skip a specific block.
  4. Enable format-on-save in everyone's editor through the Prettier extension or integration.
  5. Add a check to CI that runs Prettier in check mode and fails if any file isn't formatted.

Prettier reads .editorconfig for some settings, such as indentation, unless its own config overrides them, so the two work together.

Other languages

Prettier focuses on web languages. Most other languages have their own standard formatter, often with even fewer options: Go has gofmt, Rust has rustfmt, Python teams commonly use Black or Ruff's formatter, and PHP projects have tools based on agreed coding standards. The principle is the same: one tool, run automatically, checked in CI.

Reformatting an existing codebase

Turning on a formatter in an established project creates one huge change. Handle it deliberately:

  1. Agree on a time when few branches are open.
  2. Merge or rebase open work first, where possible.
  3. Run the formatter across the whole repository in a single commit with a clear message, and change nothing else in it.
  4. Merge it quickly so other branches can update.
  5. Record the commit in a .git-blame-ignore-revs file so git blame skips it and keeps pointing at the real authors of each line.

Developers with long-running branches should run the formatter on their branch before merging main in. That makes their conflicts far smaller.

Getting the team on board

Introduce the change as a time-saver rather than a rule. Show one recent pull request where formatting changes hid the real edit, and propose the setup for a two-week trial. Let people raise genuine problems, such as a generated file being reformatted or an editor that doesn't pick up the settings, and fix those quickly. Once the formatter runs on save, most developers stop noticing it within days, and nobody misses the style debates.

Keeping it consistent

  • Pin versions. A formatter upgrade can change output slightly. Upgrade deliberately, in its own commit.
  • Format staged files before commit with a pre-commit hook, so unformatted code rarely reaches CI.
  • Separate linting from formatting. Linters catch likely bugs and risky patterns; formatters handle layout. Turn off linter rules that only concern style, so the tools don't fight.
  • Document it in the README: how to run the formatter, and which editor extensions to install.

A worked example

Consider a hypothetical San Diego surf school whose booking site was built by a rotation of freelancers. Pull requests were cluttered with formatting changes, and the owner's in-house developer spent much of each review sorting real changes from noise. She added an .editorconfig, adopted Prettier with default settings and a pinned version, reformatted the codebase in one Friday commit added to the blame-ignore file, and set CI to fail on unformatted files. New freelancers now get one line in the README instead of a style guide.

FAQ

Will Prettier change how my code works?

It's designed to change only formatting, not behaviour. Review the first big reformat anyway, and run your tests.

Do I need both EditorConfig and Prettier?

They overlap, but EditorConfig covers every file type and every editor, while Prettier enforces detailed style for the languages it supports. Many teams use both.

What if a developer dislikes the style?

That's the point of an opinionated tool: the team accepts one style and stops discussing it.

Should formatting run in CI or only locally?

Both. Local formatting is convenient; the CI check guarantees it.

If code reviews in your team are drowning in formatting changes, tell us about your stack and we'll help set up consistent tooling.

Sources

WhatsAppBook a call