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

  1. Plan & Design
  2. Develop
  3. Version control
  4. ● Verify
  5. Build & Package
  6. CI/CD
  7. Deploy
  8. Operate

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

  • 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

Guides

Learn next

Done with this topic?

Reviewed 2026-10-23. Links go to the official documentation unless marked otherwise.