Glossary / Formatters
Formatters
A code formatter rewrites source into a consistent layout according to formatting rules. Tools such as Prettier reduce style debates and review noise by enforcing choices like line wrapping, spacing, and quotes; a formatter does not establish correctness, architecture, or semantic safety.
Formatting and linting
Formatters generally aim for deterministic, idempotent output: running them again should produce no further changes. Linters report or fix code patterns and policy; formatters focus on presentation. Some lint rules overlap with formatting and can conflict, so projects often disable stylistic lint rules when a dedicated formatter owns those concerns.
Formatting can produce large diffs when introduced to an existing codebase. Pin the formatter version and configuration, run it in CI or pre-commit workflows, and keep generated code policy explicit. Editor integration must use the repository's installed version and configuration to avoid save-time churn.
Engineering guidance
Adopt a formatter early, commit its config, and format files consistently rather than debating individual lines in review. Separate formatting-only changes from behavior changes for easier review. Do not treat formatter output as validation; retain linting, type checks, and tests as appropriate.
Interview questions
- Formatter vs linter? Formatter controls layout; linter checks code patterns and policy.
- Why pin the formatter version? Formatting output may change across versions, causing churn.
- What makes a formatter deterministic? Same input/config/version produces stable output, ideally idempotently.
- Why separate mass formatting? It keeps behavior changes reviewable and reduces blame noise.
- Does formatted code imply quality? No; layout consistency says nothing about correctness.