linting

What Is a Linter? How Linting and Static Analysis Work

By Zest | Updated | 14 min read

Related guide: Claude Code hooks: run a formatter or a check on every edit

A desktop monitor showing code in an editor, with a magnifying glass icon and the words What is Linter

A linter is a tool that reads source code without running it and flags likely bugs, risky patterns and style problems, such as a variable that’s never used or an = where you meant ==. Linting means running one, usually in your editor, before each commit and in CI.

Zest records each engineer's coding-agent sessions and links them to the pull requests they led to, with the model, tools and cost behind each change. Start freeGet started

Every language has its own: ESLint for JavaScript and TypeScript, Ruff and Pylint for Python, golangci-lint for Go, Clippy for Rust. Linting is the lightest kind of static analysis; tools such as CodeQL and SonarQube go further and follow data through the whole program. Both are below, with ESLint and Ruff setups we ran on November 12, 2026.

Where does the name “lint” come from?

The word comes from lint, a C checker Stephen C. Johnson wrote at Bell Labs. His paper, “Lint, a C Program Checker”, is dated July 26, 1978, and opens: “Lint is a command which examines C source programs, detecting a number of bugs and obscurities.” It appears in the Seventh Edition Unix manual, dated January 1979 (Unix Seventh Edition Manual).

Johnson explained the name in a 2017 post to the Unix Heritage Society mailing list. With two young children in the era of cloth diapers, his family did a lot of laundry: “One day, as I was cleaning out the lint trap in our dryer, I realized that the program I was writing was performing a similar function, and the name was born” (Steve Johnson, TUHS). C had no function prototypes then, so changing a function and missing a caller was “a common source of bugs”. His checker compared every call with its definition and complained when they didn’t match. He didn’t claim to be first: Barbara Ryder’s PFORT, also at Bell Labs, already flagged FORTRAN that wouldn’t work on the six major FORTRAN compilers then in use.

How does a linter work?

Most linters work in three steps:

  1. Parse. The linter turns the source text into an abstract syntax tree (AST), a tree of the program’s structure with a node for each function, if and comparison. ESLint parses with Espree and records each node’s line and column, which is how it points at the exact spot (ESLint architecture).
  2. Run the rules. Each rule is a small check that asks for certain kinds of node. ESLint walks the tree and calls each rule for the nodes it asked for, such as every if statement (ESLint custom rules).
  3. Report, and sometimes fix. For each problem, the linter reports a message, a location and the rule’s severity. Some rules also carry a fix it can apply for you.

Here is ESLint 10.14.0 on src/permissions.js, a short function with four mistakes in it:

export function canEdit(user, doc) {
  let owner = doc.ownerId;
  const today = new Date();
  if (user.role = "admin") return true;
  return owner == user.id;
}
$ npx eslint .

/your/project/src/permissions.js
  2:7   warning  'owner' is never reassigned. Use 'const' instead                 prefer-const
  3:9   error    'today' is assigned a value but never used                       no-unused-vars
  4:7   error    Expected a conditional expression and instead saw an assignment  no-cond-assign
  4:7   error    Unexpected constant condition                                    no-constant-condition
  5:16  error    Expected '===' and instead saw '=='                              eqeqeq

✖ 5 problems (4 errors, 1 warning)
  0 errors and 1 warning potentially fixable with the `--fix` option.

Line 4 is the one that matters. user.role = "admin" assigns instead of comparing, so every user can edit every document, and the code runs without an error. npx eslint . --fix changed only let to const, because only prefer-const carries a fix here. Ruff, the Python linter, labels its fixes “safe” and “unsafe” and “only applies safe fixes by default”, because an unsafe fix can change what the code does (Ruff docs).

Why linters raise false alarms

Johnson’s paper says why no linter can be exact. Many facts it needs “may be impossible to discover”: whether a function is ever called can depend on the input, so “most of the lint algorithms are a compromise.” He also set the bar every linter still answers to: warnings “are acceptable only in proportion to the fraction of real bugs they uncover.”

When a rule is wrong for one line, switch it off there and say why: // eslint-disable-next-line no-alert in ESLint, # noqa: F841 in Ruff. ESLint’s docs say to do it only “with a clear and valid reason” (ESLint docs). When a rule is wrong for the whole codebase, turn it off in the config.

Linter vs formatter vs compiler vs type checker

Four kinds of tool read your code before it runs, and each checks something different:

Tool What it checks What it does Examples
Formatter Layout: spacing, line breaks, quotes Rewrites the file Prettier, Black, ruff format
Linter Patterns that are likely bugs or break your conventions Reports problems and fixes some ESLint, Ruff, Pylint, Clippy
Type checker That every value is used as its type allows Reports type errors mypy, tsc --noEmit
Compiler That the code is valid in the language Turns it into something that runs, and warns about risky code gcc, clang, rustc, javac

Linter vs compiler

A compiler has to be fast and accept every valid program; a linter can take its time and be pickier. Johnson drew that line in 1978: “The compilers turn C programs into executable files rapidly and efficiently,” while “Lint takes a more global, leisurely view of the program.”

Compilers warn too. GCC’s warnings “report constructions that are not inherently erroneous but that are risky or suggest there may have been an error,” and -Werror turns them into errors (GCC docs). Rust shows the split: rustc compiles, and cargo clippy adds Clippy’s lints on top. JavaScript and Python have no compile step you run before shipping, so there the linter and type checker are the first tools to read the code.

Linter vs formatter

A formatter decides how code looks; a linter decides whether it’s probably wrong. Prettier’s docs split linter rules into “formatting rules” (such as max-len) and “code-quality rules” (such as no-unused-vars) and advise: “use Prettier for formatting and linters for catching bugs!” (Prettier). ESLint agreed in November 2023, when v8.53.0 deprecated its own formatting rules (ESLint blog). Ruff does both jobs, with ruff check and ruff format, and its docs name the few lint rules that fight its formatter, such as W191 and COM812 (Ruff formatter).

Linter vs type checker

A type checker asks one question across the whole program: is every value used the way its type allows? “Mypy is a static checker, so it finds bugs in your programs without even running them” (mypy). TypeScript’s noEmit option leaves the output to another tool and uses TypeScript “as a source code type-checker” (TypeScript). Run both; they catch different mistakes.

The usual linter for each language, and what its own docs say it does (read November 12, 2026):

Language Linter What it does
JavaScript, TypeScript ESLint “Identifying and reporting on patterns found in ECMAScript/JavaScript code”; TypeScript through typescript-eslint
JavaScript, TypeScript Biome, Oxlint Biome formats and lints in one command; Oxlint says it is “50 to 100 times faster than ESLint”
Python Ruff Linter and formatter written in Rust, over 900 rules; can replace Flake8, isort and Black
Python Pylint Slower, but “a lot more thorough than other linters”
Go golangci-lint Runs over a hundred Go linters in parallel
Rust Clippy “Over 800 lints”, run with cargo clippy
Ruby RuboCop Linter and formatter for the community Ruby Style Guide
Java Checkstyle, PMD Checkstyle: naming, imports, formatting, Javadoc; PMD: unused variables, empty catch blocks, copied code
Swift SwiftLint “A tool to enforce Swift style and conventions”
C, C++ clang-tidy, Cppcheck clang-tidy finds and fixes typical errors; Cppcheck targets undefined behavior, aiming for “very few false positives”
Shell ShellCheck Finds bugs in shell scripts, including quoting problems
CSS Stylelint Over 150 built-in rules

How to set up a linter

ESLint for JavaScript and TypeScript

ESLint 10 reads only flat config files such as eslint.config.js: “Starting with ESLint v10.0.0, the old configuration format is no longer supported,” so .eslintrc tutorials are out of date (ESLint migration guide). It needs Node.js 20.19+, 22.13+ or 24+ (not 21 or 23). The setup wizard asks a few questions and writes the config for you:

npm init @eslint/config@latest

Or set it up by hand:

npm install --save-dev eslint@latest @eslint/js@latest globals

This config, the one behind the output above, turns on ESLint’s recommended rules for Node.js code and adds two more:

// eslint.config.js
import { defineConfig } from "eslint/config";
import js from "@eslint/js";
import globals from "globals";

export default defineConfig([
  {
    files: ["**/*.js"],
    plugins: { js },
    extends: ["js/recommended"],
    languageOptions: { globals: globals.node },
    rules: {
      eqeqeq: "error",
      "prefer-const": "warn",
    },
  },
]);

Each rule is "off", "warn" or "error", and by default only errors make ESLint exit with code 1. For TypeScript, add typescript-eslint and extend tseslint.configs.recommended (typescript-eslint).

Ruff for Python

Ruff works without a config file. Version 0.16 (July 23, 2026) raised its default set to 413 rules, up from 59 (Ruff 0.16.0), and 0.17 trimmed it to the 407 on its default rules page, so if an upgrade brought a wave of new warnings, that’s why. Run it with uv, or install it:

uvx ruff check
pip install ruff

To add rules on top of the defaults, use extend-select; select would replace them:

# pyproject.toml
[tool.ruff]
line-length = 100

[tool.ruff.lint]
# Keep Ruff's defaults and also flag == None and == True
extend-select = ["E711", "E712"]

Ruff 0.17.5 on users.py:

import os
import json


def load_users(path, cache={}):
    if path in cache:
        return cache[path]
    with open(path) as f:
        users = json.load(f)
    if users == None:
        return []
    cache[path] = users
    return users
$ ruff check --output-format concise
users.py:1:1: I001 [*] Import block is un-sorted or un-formatted
users.py:1:8: F401 [*] `os` imported but unused
users.py:5:28: B006 Do not use mutable data structures for argument defaults
users.py:10:17: E711 Comparison to `None` should be `cond is None`
Found 4 errors.
[*] 2 fixable with `--fix` (2 unsafe fixes available with `--fix --unsafe-fixes`).

B006 is the real bug: the {} default is created once and shared by every call. ruff check --fix removed the unused import and sorted the rest, and left the two unsafe fixes to you. ruff format then handles the layout.

Where to run a linter

Run the same linter, with the same config, in four places. Each one catches what the one before missed.

In your editor

The editor is the cheapest place to catch a problem, because the warning shows as you type. ESLint lists integrations for VS Code, the JetBrains IDEs, Vim, Neovim, Emacs and Sublime Text (ESLint integrations). Ruff’s built-in language server “provides Ruff diagnostics, Code Actions to fix them, and formatting” (Ruff editors).

Before each commit

A Git pre-commit hook lints staged files before they’re committed. The pre-commit framework manages such hooks across languages; catching simple issues first “allows a code reviewer to focus on the architecture of a change” (pre-commit). Ruff’s official hook puts the linter before the formatter, as its README asks:

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.17.5
    hooks:
      - id: ruff-check
        args: [--fix]
      - id: ruff-format

In CI

CI is the check nobody can skip. Make the lint job required, so a reviewer only reads code that already passes, rule 3 of our code review best practices:

npx eslint . --max-warnings 0
ruff check --output-format=github .

--max-warnings 0 fails the job on warnings too. Ruff’s github format turns each problem into an inline annotation on the pull request (Ruff integrations). Any of the CI/CD platforms can run both.

After every edit a coding agent makes

A coding agent can lint its own work as it goes. In Claude Code, a PostToolUse hook with the matcher Edit|Write runs after every Edit or Write call, and when it exits with code 2, Claude Code “shows stderr to Claude”, so the lint output goes straight back to the agent (Claude Code hooks reference). Add it to .claude/settings.json:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/lint.sh",
            "args": []
          }
        ]
      }
    ]
  }
}
#!/bin/bash
# .claude/hooks/lint.sh (chmod +x): lint the file Claude just edited.
# Exit 2 sends the problems back to Claude.
FILE=$(jq -r '.tool_input.file_path // empty')
case "$FILE" in
  *.js | *.jsx | *.ts | *.tsx) ;;
  *) exit 0 ;;
esac
if ! OUTPUT=$(npx eslint --no-warn-ignored "$FILE" 2>&1); then
  echo "$OUTPUT" >&2
  exit 2
fi

On sample events, the script exits 2 with the five problems above for permissions.js, and 0 for a clean file or a Markdown file. Claude Code hooks covers the events and exit codes in full. Codex has the same PostToolUse event: its edits go through apply_patch, which an Edit or Write matcher also catches (the patch arrives in tool_input.command, not file_path, so the script above needs changing for Codex), exit code 2 sends your stderr back to the model, and a new hook runs only after you trust it in /hooks (Codex hooks).

Test a hook before you rely on it, because one that can’t run is a non-blocking error and the agent carries on. In one of our repositories, a formatter hook failed 124 times in two days on a laptop without pnpm (exit code 127, command not found), and Claude Code kept going each time.

Linting vs static analysis and SAST

Static analysis is any check that reads code without running it, so every linter is a static analysis tool. In practice the term usually means heavier tools that follow data through a program, and SAST (static application security testing) means the ones that look for security holes. OWASP describes static code analysis, “also known as Source Code Analysis”, as tools that “attempt to highlight possible vulnerabilities within ‘static’ (non-running) source code” (OWASP).

Linter Static analyzer or SAST tool
Looks at Patterns, mostly one file at a time How data and control flow through the program
Finds Likely bugs, dead code, convention breaks Injection, unsafe data flows, bugs that cross files
Usually runs In the editor and on every commit In CI, on each pull request or on a schedule
Examples ESLint, Ruff, Clippy, RuboCop CodeQL, SonarQube

How does static code analysis work?

Static code analysis builds a model of the code, then asks questions of the model. OWASP lists the main techniques: data flow analysis, control flow graphs, lexical analysis and taint analysis, which follows variables “‘tainted’ with user controllable input” to where they’re used. That’s how an analyzer finds a request parameter that reaches a SQL query in another file.

GitHub’s CodeQL treats “code like data”: you build a CodeQL database of your codebase, run queries against it, and the results show up as code scanning alerts. Its supported languages include C/C++, Java/Kotlin, JavaScript/TypeScript, Python and Rust (GitHub docs). Code scanning also takes other tools’ results in SARIF format, and on private repositories it needs a GitHub Code Security license (GitHub docs).

SonarQube “evaluates your code against a set of rules to generate issues”: bugs, vulnerabilities, security hotspots and code smells (SonarQube rules). Its default quality gate, “Sonar way”, fails new code that adds issues, leaves new security hotspots unreviewed, has under 80% test coverage or more than 3% duplication (quality gates). It also reports technical debt, “a measure of effort to fix all maintainability issues” (SonarQube metrics).

OWASP’s warnings apply to all of these tools: “High numbers of false positives,” and they “frequently can’t find configuration issues, since they are not represented in the code.” Static analysis catches a class of bugs early. It doesn’t replace unit tests or a review.

Linters and AI-written code

Coding agents make linting more useful, not less. An agent writes a large change in minutes, and the person reviewing it shouldn’t spend that attention on an unused import.

The checks matter for security too. In a study at IEEE Security and Privacy 2022, researchers had an early GitHub Copilot complete 89 scenarios built so that a common weakness was possible; of the 1,689 programs it wrote, “approximately 40%” were vulnerable, judged with CodeQL and by hand (Pearce et al.). Veracode, which sells static analysis, tested 18 models in its Fall 2026 round and found code with a vulnerability in about 38% of its security tasks, down from roughly 44% in July (Veracode, October 29, 2026). Neither study tested an agent that runs a linter as it works.

So give agents the same checks you give people, where they can’t be skipped. Claude Code’s docs say hooks give “deterministic control: certain actions always happen rather than relying on the LLM to choose to run them” (Claude Code hooks guide). A practical stack: the linter in the agent’s hook, the type checker and tests before the pull request, CodeQL or SonarQube in CI, and a person who reads the diff. In review, watch for new eslint-disable and noqa comments: each one is a rule switched off, not a problem fixed.

Zest is ours, and it doesn’t lint, analyze or review code. It records each engineer’s coding-agent sessions and links each one to the GitHub pull request it led to, with the model, tools and cost behind it. Keep your linter, SonarQube or CodeQL for the code itself.

Frequently asked questions

What is linting in programming?

Linting is running a linter: a tool that checks source code against a set of rules without running it, and reports likely bugs and style problems with a file, line and rule name. The name comes from lint, the C checker Stephen C. Johnson wrote at Bell Labs and described in a 1978 paper.

Is a linter a static analysis tool?

Yes, the lightest kind: fast rules about patterns, mostly one file at a time. CodeQL and SonarQube are static analyzers that also follow data across files, which lets them trace a problem like SQL injection from user input to the query.

Can a linter fix code automatically?

Some of it. ESLint’s --fix applies the fixes its rules provide, such as let to const. Ruff’s applies the fixes it labels safe, such as removing an unused import, and holds back the rest until you add --unsafe-fixes. Real bugs, like an assignment inside an if, are still yours to fix.

Is a linter the same as a debugger?

No. A linter reads the code without running it and points at suspicious lines. A debugger runs the program and pauses it at breakpoints so you can inspect values. Use the linter to catch mistakes early, and the debugger when the code does something you can’t explain (debugging with VS Code).

Zest is AI coding analytics for engineering teams: it shows which coding agents, models and skills each engineer uses, what they cost, and which sessions end in merged pull requests. See how Zest works.