Linters and static analysis
Beginner
8 min read
Tools that read your code without running it and catch mistakes, risky patterns and style drift.
Why it matters
A linter finds an unused variable, a missing await or a likely bug in seconds, before a reviewer or a user does. A formatter ends arguments about style, so reviews focus on what the code does.
Where it fits
What you will learn
- Tell a linter, a formatter and a type checker apart.
- Run a linter locally and in CI.
- Fix or deliberately silence a warning.
Before you start
- Automated tests✓ Learned
- Formatter — rewrites layout (spaces, line breaks) so all code looks the same. Never changes behaviour.
- Linter — reports suspicious code: unused names, unreachable code, risky patterns.
- Type checker — proves types line up (TypeScript, mypy, PHPStan) without running the code.
Example
npx eslint . # JavaScript / TypeScript
ruff check . # Python: lint
ruff format . # Python: format
Tip: Add the linter to an existing project gradually: start with the rules that find bugs, fix those, then tighten. A thousand style warnings on day one get ignored.
Run the same commands in CI as locally, with the versions pinned, so "passes on my machine" means "passes in the pipeline".
Official documentation and references
Documentation
- ESLint documentation ↗ Official · ESLint
- Ruff documentation ↗ Official · Astral
Guides
- ESLint — Getting started ↗ Official · ESLint
Learn next
- CI/CD pipelines ›✓ Learned
Related topics
- Automated tests✓ Learned
- CI/CD pipelines✓ Learned
Done with this topic?
Reviewed 2026-10-23. Links go to the official documentation unless marked otherwise.