Linting
Linting is the automated process of analyzing source code to flag stylistic issues, suspicious patterns, and potential bugs without actually executing the program.
Definition
Linting is the automated process of analyzing source code to flag stylistic issues, suspicious patterns, and potential bugs without actually executing the program.
Overview
A linter is a static analysis tool that scans code and reports problems ranging from simple style violations — inconsistent indentation, unused variables, missing semicolons — to genuine risks such as comparing values with the wrong equality operator, unreachable code, or accessing a variable before it's defined. Because linting analyzes code without running it, it can catch these issues the moment code is written or committed, well before unit testing or manual code review would surface them. Widely used linters include ESLint for JavaScript and TypeScript, Pylint and Ruff for Python, and RuboCop for Ruby; most integrate directly into editors to highlight problems in real time, and into pre-commit hooks or CI pipelines to block code that violates a team's agreed rules from being merged. Linter configurations are typically shared across a team or project, encoding decisions like preferred quote style or naming conventions so that style discussions happen once, in configuration, rather than repeatedly in every code review. Linting is complementary to a code formatter: a formatter automatically rewrites code to match a consistent style, while a linter flags issues — some of which, like unused imports, it can also auto-fix, but many of which require a human decision about the underlying logic. Together, the two tools remove most low-value discussion from code review, letting reviewers focus on architecture and correctness instead of formatting nitpicks.
Key Concepts
- Performs static analysis without executing the program
- Flags style violations, unused code, and suspicious patterns
- Can catch likely bugs before tests or code review ever run
- Popular tools include ESLint, Pylint, Ruff, and RuboCop
- Integrates into editors, pre-commit hooks, and CI pipelines
- Shared team configuration encodes style decisions once, centrally
- Complements code formatters, which rewrite rather than just flag issues