# Linters and Formatters

> How a linter warns about likely bugs, and how a formatter tidies the layout. Why ESLint and Prettier are two tools, and how to run both.

**Course:** [Code Editors and Package Managers](https://learn.benibix.com/learn/development-tools)  
**Time:** 12 min

**After this lesson you can:**

- Tell a linter from a formatter
- Read a linter warning
- Run Prettier on a whole project

## What a linter checks, and what a formatter fixes

A linter reads your code without running it and warns you about likely mistakes. A formatter rewrites the layout of your code in one fixed style. ESLint, the most used linter for JavaScript, came out in 2013. Prettier, the most used formatter, came out in 2017. Most teams run both, each time they save.

A linter catches things like a name you set and never use, a name spelled two ways, or code that can never run. Each check is a rule, and you turn rules on or off in a settings file. Many warnings come with a fix the linter can make for you.

ESLint is free, and it works on JavaScript and TypeScript. Its settings live in a file called eslint.config.js. Each warning names the line, the column and the rule that fired, so you can look the rule up and see why it exists.

A formatter never changes what the code does, only how it looks. It sets the spaces, the line breaks, the quotes and the indents. Prettier works on JavaScript, TypeScript, CSS, HTML, JSON, Markdown, YAML and more. It has very few settings on purpose, so a team stops arguing about tabs.

The two overlap a little, and that can cause trouble. Old linter setups also had rules about spaces, which fought with the formatter. The usual fix is simple. Let the formatter own the layout, and let the linter own the bugs.

Run the formatter over the whole project once, in its own commit. After that, each change shows only real edits. If you format just the files you touch, each change mixes real edits with layout edits. Then the people who read it cannot tell which is which.

The common mistake is turning linter warnings off because there are too many. Each one is a hint about a real slip. Fix a few at a time, and switch a rule off only after you have read why it fired.

## A linter and a formatter side by side

| Tool | What it does | Changes how the code runs? | Example |
| --- | --- | --- | --- |
| Linter | Warns about likely bugs and risky code | No, it only reports | ESLint |
| Formatter | Rewrites spaces, breaks and quotes | No, only the look | Prettier |

## Which one to reach for

1. **Linter.** When you want to find a bug before you run the code. One example is a name you set and never used.
2. **Formatter.** When a team keeps arguing about spaces and quotes, or a change is full of layout noise.

```console
$ npx eslint app.js

/home/emma/shop/app.js
  3:7  error  'total' is assigned a value but never used  no-unused-vars

✖ 1 problem (1 error, 0 warnings)

$ npx prettier . --write
app.js 35ms
eslint.config.js 4ms
```
ESLint names the line, the column and the rule. Prettier then rewrites each file in the folder and lists it.

![On the left, three lines of JavaScript with odd spaces, mixed quotes and an if block squeezed onto one line. An arrow marked prettier --write points to the right, where the same code has even spacing, double quotes, semicolons and the if block opened onto three lines.](https://learn.benibix.com/diagrams/dev5-prettier.svg)

### Example: A team stops arguing about tabs

Emma's team of 4 spends part of every code review on spaces and quotes. They add Prettier, run it on all 300 files in one commit, and set it to run on save.

They also add ESLint. In its first run it finds 12 names that are set and never used. Two of them were real bugs.

**Words in this lesson:** [Linter](https://learn.benibix.com/term/development/linter), [Code Formatter](https://learn.benibix.com/term/development/formatter), [ESLint](https://learn.benibix.com/term/development/eslint), [Prettier](https://learn.benibix.com/term/development/prettier)

> **The one thing to remember.** A linter warns about bugs. A formatter fixes the look. Let the formatter own the layout, and the linter own the bugs.

**Question:** How is a linter not the same as a formatter?

**Answer:** A linter warns about bugs, and a formatter fixes the layout. A linter reads the code and reports risky spots. A formatter rewrites spaces, breaks and quotes. Neither one changes what the code does.

---

Source: https://learn.benibix.com/learn/development-tools/linters-and-formatters
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
