On this page
A linter is a static code analysis tool that checks source code without running it and flags likely bugs, style violations and suspicious patterns, such as an unused variable or an overly complex function. Each finding names a rule and a line. Linting means running one, usually in the editor and again in CI.
This guide covers what a linter checks, where the name comes from, how a linter differs from a formatter and from wider static analysis, the main linters for each language, how to fix lint errors and run a linter on GitHub, and what a linter cannot see.
What is a linter?
A linter reads your code as text and syntax, matches it against a set of rules, and reports every place a rule is broken. It never executes the program. That makes it fast enough to run on every save and safe to run on any code, including code that would not start.
The name comes from lint, a Unix program Stephen C. Johnson wrote at Bell Labs and described in a 1978 paper, "Lint, a C Program Checker". It flagged C constructs that compiled but were likely wrong or non-portable. Johnson borrowed the word from the lint trap in a clothes dryer: it catches the small fluff and leaves the fabric intact. Every tool that does the same job for another language inherited the name.
A modern linter has three parts:
| Part | What it does | Example |
|---|---|---|
| Parser | Turns source into a syntax tree | ESLint uses espree; Ruff has its own Python parser |
| Rules | Each one looks for one pattern in the tree | no-unused-vars, E711 (comparison to None with ==) |
| Reporter and fixer | Prints findings with file, line and rule id; rewrites the ones that have a safe fix | eslint --fix, ruff check --fix |
Scroll the table sideways to see every column.
Rules are configured per project. A team turns rules on or off, sets thresholds (how complex a function may be, how long a line), and can silence one line with an inline comment such as // eslint-disable-next-line or # noqa: E711.
What does linting check?
Linting checks four kinds of problem: likely bugs, style, complexity and suspicious constructs. The exact rules differ by tool, but most linters cover the same ground.
| Category | What it catches | Example rule |
|---|---|---|
| Likely bugs | Unused variables and imports, unreachable code, shadowed names, comparisons that are always true, missing await | ESLint no-unused-vars, no-unreachable; Ruff F401 (unused import) |
| Style and conventions | Naming, import order, quote style, preferred syntax | ESLint camelcase; Ruff N802 (function name should be lowercase) |
| Complexity | Functions with too many branches, too deep nesting, too many parameters | ESLint complexity (default 20), max-depth, max-params |
| Suspicious constructs | eval, bare except:, mutable default arguments, == instead of === | ESLint no-eval, eqeqeq; Ruff E722, B006 |
Scroll the table sideways to see every column.
Here is a short Python file and what Ruff reports on it:
import os
import json
def load(path, cache={}):
try:
data = json.load(open(path))
except:
return None
if data == None:
return cache
return data
$ ruff check --select E,F,B --output-format concise example.py
example.py:1:8: F401 [*] `os` imported but unused
example.py:4:22: B006 Do not use mutable data structures for argument defaults
example.py:7:5: E722 Do not use bare `except`
example.py:9:16: E711 Comparison to `None` should be `cond is None`
(Output from Ruff 0.15. B006 comes from Ruff's bugbear rules, which are off by default; enable them with select = ["E", "F", "B"] in pyproject.toml.) Every finding is real, none of them stop the file from running, and two of them (the mutable default and the bare except) are classic sources of bugs that only show up later. That is the point of running a linter early: syntax and compile errors were only 5.15% (averaged per repository) of the named-cause coding errors fixed in 290 popular repos, far behind logic, build and integration bugs.
Linter vs formatter: what is the difference?
A formatter rewrites how code looks; a linter reports what may be wrong with it. Prettier, Black, gofmt and ruff format take code and print it back in one canonical layout: indentation, line breaks, quotes, trailing commas. They do not judge whether the code is correct. A linter does the judging and leaves layout alone, or should.
| Linter | Formatter | |
|---|---|---|
| Output | A list of findings | Rewritten code |
| Judges correctness | Yes | No |
| Configurable | Rule by rule | Few options, by design |
| Examples | ESLint, Ruff (ruff check), Pylint, golangci-lint, Clippy, RuboCop | Prettier, Black, ruff format, gofmt, rustfmt |
Scroll the table sideways to see every column.
Most teams run both, with the formatter owning whitespace so the two never argue. ESLint deprecated its own formatting rules in 2023 and recommends a dedicated formatter for layout; eslint-config-prettier switches off any remaining rule that would conflict with Prettier. Biome and Ruff ship a linter and a formatter in one binary, which removes the conflict entirely.
Linter vs static analysis vs code health
A linter is the simplest kind of static analysis. It checks one file at a time against pattern rules. Wider static analysis follows data and control flow across files, and a code health tool adds the repository's git history on top. Each answers a different question.
| Linter | Static analysis (SAST, type checkers) | Code health | |
|---|---|---|---|
| Scope | A line or a file | Across files and functions | The whole repository |
| Typical question | Does this line break a rule? | Can untrusted input reach this query? Is this type correct? | Which files are most likely to carry the next bug? |
| Uses git history | No | No | Yes: churn, ownership, prior bug fixes |
| Speed | Milliseconds per file | Seconds to minutes | Indexed once, updated per commit |
| Examples | ESLint, Ruff, RuboCop | mypy, TypeScript tsc, Semgrep, CodeQL, SonarQube | repowise |
Scroll the table sideways to see every column.
Our guide to static code analysis covers the middle column, and what SonarQube is covers the best-known platform in it.
Linters by language
Every major language has one or two default linters, and most teams pick the one the ecosystem settled on.
| Language | Main linters | Run it |
|---|---|---|
| JavaScript and TypeScript | ESLint (with typescript-eslint), Biome, Oxlint | npx eslint . or npx @biomejs/biome lint . |
| Python | Ruff, Pylint, Flake8 | ruff check . or pylint src/ |
| Go | golangci-lint (runs staticcheck, govet and others), go vet | golangci-lint run |
| Rust | Clippy | cargo clippy |
| Ruby | RuboCop | rubocop |
| Java and Kotlin | Checkstyle, PMD, ktlint, detekt | via the Maven or Gradle plugin |
| C and C++ | clang-tidy, cppcheck | clang-tidy src/*.cpp -- |
| Swift | SwiftLint | swiftlint |
| Shell | ShellCheck | shellcheck script.sh |
| CSS | Stylelint | npx stylelint "**/*.css" |
Scroll the table sideways to see every column.
Which Python linter should you use? For a new project, Ruff: it is written in Rust, runs in a fraction of the time older tools take, and reimplements Flake8 and many of its popular plugins, plus isort and pyupgrade rules, in one tool. Pylint is slower but goes deeper on some checks, such as design rules on class and argument counts, and some teams run it in CI next to Ruff. Pair either with a type checker such as mypy or Pyright, which catches a different class of bug. Whichever tool you pick, the thresholds belong in your written coding standards.
How to fix a lint error
Read the rule id, fix the code or the config, and let the tool fix what it safely can. Every finding names its rule, and every rule has a documentation page explaining why it exists.
- Run the autofixer first.
npx eslint . --fix,ruff check --fix,rubocop -aandcargo clippy --fixhandle the mechanical findings: unused imports, quote style, simple rewrites. - Read the rule's page for the rest. Search the rule id (
no-floating-promises,B006). The page shows the bad pattern and the fixed one. - Fix the code, not the warning. A bare
exceptshould name the exception it expects. An unused variable is often a bug: a value you meant to use. - Change the config when the rule is wrong for your project. Turn it off or adjust its threshold in
eslint.config.jsorpyproject.tomlfor the whole team, instead of scattering suppressions. - Suppress one line only with a reason.
# noqa: E722 # re-raised after loggingtells the next reader why the rule does not apply.
How to run a linter in CI and on GitHub
Run the linter on every pull request so a finding blocks the merge before it reaches main. On GitHub that means a workflow in .github/workflows/:
name: lint
on: [pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install ruff
- run: ruff check --output-format=github .
--output-format=github makes each finding appear as an annotation on the changed line in the pull request. ESLint and golangci-lint have equivalent workflows.
What is a linter in GitHub? Usually one of two things: a linter running as a GitHub Actions check like the one above, or Super-Linter, an open-source GitHub Action that bundles linters for dozens of languages and runs the right ones against the files in a repository. Super-Linter suits a repository with many languages and no setup; a dedicated linter per language is faster and easier to tune.
Add a pre-commit hook as well, so most findings never reach CI. The pre-commit framework runs Ruff, ESLint and others on staged files before each commit.
What a linter cannot see
A linter judges each file alone and treats every finding the same, so it cannot tell you which of a thousand warnings matter. A complex function in a file nobody has touched in three years and the same function in the file that changes every week get the same warning. Three things decide which one is worth fixing, and none of them are in the source text:
- Churn. How often the file changes. Problems in busy files cost something on every edit.
- Ownership. Whether one person wrote most of it. In the median repo of the 195 popular open-source repositories we analysed (November 2026), 60% of production files have a bus factor of 1.
- Bug history. Whether fixes keep landing in it. In the same cohort, the least-healthy 20% of files hold 60% of the files that needed a bug fix in the last 180 days.
Some problems also span files, which a per-file rule cannot see. An export nothing imports is invisible to no-unused-vars, which only looks inside one file. Across 190 of those repositories, the median repo has 16.2 dead-code findings per 100 production files: unreachable files and unused exports that no single-file linter reports.
Complexity rules show the same limit. We measured 200,744 production files in 160 popular repositories: 23.3% contain a function above McCabe's classic limit of 10, and 9.9% contain one above 20, the default threshold of ESLint's complexity rule. A team that turns that rule on in an existing codebase gets a long list with no order. Code complexity metrics explains what those numbers measure.
How repowise works with your linter
repowise does not replace a linter; it ranks what a linter finds by where it costs you. It reads the parse tree, the dependency graph and the git history of the repository, runs 59 deterministic detectors, and scores every file from 1 to 10. Code-shape findings such as long or high-complexity functions, deep nesting, god classes and complex conditions are weighted by change history, so a messy file that changes every week ranks above a messy file nobody touches. No LLM key and no network are needed.
repowise init # indexes the repo and scores every file
repowise health # Fix first: the ranked list, with the first edit and the tests to run
repowise health check origin/main...HEAD # in CI: fails only on a new high-severity finding the change wrote
repowise health check behaves like a linter in CI, but on the change: it analyzes the changed files at the base and the head and fails only when the PR introduces a new code-shape finding, so an old codebase can adopt it without a wall of existing warnings.
You can see the result on a real repository: the FastAPI code health report shows file scores, hotspots and the ranked fix list. The code health feature page covers the detectors and the scoring.
FAQ
- What is linting and why is it important?
- Linting is running a tool that checks source code against rules without executing it, to flag likely bugs, style violations and risky patterns. It matters because it catches a whole class of mistakes (unused variables, bare exceptions, accidental comparisons) in seconds, before review, and keeps a codebase consistent without anyone arguing about it in pull requests.
- What is the difference between a linter and Prettier?
- Prettier is a formatter: it rewrites code into one consistent layout and does not judge correctness. A linter such as ESLint reports code that may be wrong or breaks a convention. Most JavaScript teams run both, with
eslint-config-prettierturning off ESLint rules that would conflict with Prettier's formatting. - What is a linter in GitHub?
- It is usually a linter that runs as a GitHub Actions check on every pull request and reports findings as annotations on the changed lines. GitHub's Super-Linter is a ready-made action that runs linters for many languages at once; most teams with one or two languages run ESLint, Ruff or golangci-lint directly instead.
- How do I fix a lint error?
- Run the tool's autofix first (
eslint --fix,ruff check --fix). For what remains, look up the rule id in the error, read why the rule exists, and fix the code. If the rule does not fit your project, change it in the shared config, and suppress single lines only with a comment that says why. - Is a linter static analysis?
- Yes. A linter is the simplest form of static analysis: it inspects code without running it, file by file, against pattern rules. Wider static analysis tools such as type checkers and SAST scanners follow types and data flow across files, and catch problems a linter cannot.
- Which Python linter should I use?
- Ruff is the default choice for new projects: it is very fast and covers the rules of Flake8, many of its plugins, isort and pyupgrade in one tool, with a matching formatter. Add Pylint if you want its deeper design checks, and a type checker such as mypy or Pyright for type errors.



