← Lessons

quiz vs the machine

Gold1330

Frontend

Linting And Formatting

Automate code quality and style so reviews focus on logic.

4 min read · core · beat Gold to climb

Two distinct jobs

  • A linter finds likely bugs and bad patterns such as unused variables or missing dependency arrays.
  • A formatter rewrites whitespace, quotes, and line breaks to one consistent style.

They overlap but solve different problems. Let the formatter own style and the linter own correctness.

Why automate

  • Removes bikeshedding about style in code review.
  • Catches whole classes of bugs before they reach runtime.
  • Keeps a large codebase consistent across many contributors.

Run it in the right places

  • Editor instant feedback while typing.
  • Pre commit auto fix and block obvious problems locally.
  • CI the final gate so nothing unformatted or failing lint merges.

Configure the formatter and linter to not fight each other so saving a file is conflict free.

Key idea

Let a formatter own style and a linter own correctness, then enforce both from editor to CI.

Check yourself

Answer to earn rating on the learn ladder.

1. What is the division of labor between a formatter and a linter?

2. Why run linting in CI even if the editor already lints?