Skip to content

Lint

Lint is the static analysis of source code for stylistic, structural and likely-bug patterns, performed before the code runs; the name comes from a 1978 C checker by Stephen C. Johnson at Bell Labs.

Definition

What it is

A linter reads source code without executing it and reports patterns that are stylistically wrong, structurally suspicious or likely bugs. It does not prove correctness. It catches the class of problems that a compiler accepts but a reviewer would flag: unused variables, unreachable branches, shadowed identifiers, inconsistent imports, missing semicolons in languages that require them, duplicate keys in objects.

The verb and the noun are the same: to lint code, you run a linter. The output is a list of findings, each with a line, a column and a rule identifier.

Why it matters

Code review time is the most expensive resource in a healthy engineering team. A linter handles the mechanical layer for free: it never gets tired, it never has opinions about architecture, it never negotiates. What it does, it does in milliseconds, on every save, on every commit, on every pull request. Reviewers then spend their time on the parts that a linter cannot judge: naming, abstraction, contract, coupling.

Static vs runtime analysis

Aspect

Lint (static)

Tests (runtime)

Requires execution

No

Yes

Speed

Milliseconds

Seconds to hours

Catches syntax errors

Yes

Only if the code reaches them

Catches logic errors

Sometimes, by pattern

Yes, if a test covers them

Catches performance issues

Rarely

Sometimes, under load

False positives

Common

Rare

Where lint sits in the pipeline

graph LR
  A[Save in editor] -->|linter on save| B[Finding shown inline]
  B --> C[Commit]
  C -->|pre-commit hook| D[Linter runs]
  D --> E[Pull request]
  E -->|CI lint stage| F[Linter runs again]
  F --> G[Merge]
  style A fill:#E8F5E9
  style G fill:#E8F5E9

How to adopt lint without drowning

Adopting a linter on an existing codebase

  1. Start with the recommended preset

    Every serious linter ships a preset. Turn it on. Do not customize yet.

  2. Fix what it flags, do not silence

    Silencing a rule with a comment is fine for a specific line, never for a file.

  3. Add one rule at a time

    One rule, one pull request, one discussion. Adoption is a conversation, not a decree.

  4. Fail the build on error, not on warning

    Warnings that do not fail the build get ignored within a week.

Origin

The first linter was written by Stephen C. Johnson at Bell Labs and published in July 1978 as Lint, a C Program Checker (Computer Science Technical Report 65). It scanned C source for constructs that the portable C compiler accepted but that were likely to be bugs: unused variables, inconsistent argument counts, unreachable code, suspicious type conversions. Johnson named it after the small fibers that cling to fabric. The metaphor stuck, and "lint" became the generic term for any static code checker.

The name "lint" was chosen because the program picked up the small bits of fluff that clung to a programmer's code the way lint clings to a suit.

— Stephen C. Johnson, quoted in *The Practice of Programming* (Kernighan & Pike, 1999)
1978 · año de publicación del lint original
1 · lenguaje objetivoC
200+ · reglas en linters modernos como ESLint
3 ms · tiempo típico de lint en un archivo medio

Evidence

FAQ

Linter vs compiler?

The compiler translates code; a linter critiques code. Many linters run inside compilers now (Go's vet, Rust's clippy, TypeScript's --strict).

Does lint slow development?

On save, it is invisible. On a pre-commit hook, it takes a second. In CI, it takes a few seconds. The cost is far below a broken build.

Which linter to pick?

The one with the most maintained rules for your language and the most adoption in your community. ESLint for JavaScript, PHP_CodeSniffer and PHPStan for PHP, clippy for Rust, golangci-lint for Go.

Can a project run without a linter?

Yes, and many do. They compensate with stronger review and slower releases. Lint is a shortcut, not a requirement.

Connections

Etymology

Origin: metaphor

  • lint (noun): small fibers that cling to fabric, from Old English lynnet, flax

Semantic network

Lintstatic-anasoftware-qstatic-anacompilercode-revieeslintphpstan

● broader ● narrower ● related

Broader

  • static-analysis
  • software-quality

Related

  • static-analysis
  • compiler
  • code-review
  • eslint
  • phpstan

Sources