What Linters Actually Do
You'll learn: How linters analyze your code without running it to catch errors, style issues, and potential bugs.
The Core Concept
A linter is a static analysis tool. The key word here is "static"—it reads and examines your code as plain text, checking it against rules and patterns, but never executes it. Think of a linter like a grammar checker for your writing: it scans sentences for mistakes and style violations without needing to "speak" them aloud.
When you run ESLint (or any linter), it:
- Parses your code into an Abstract Syntax Tree (AST)—a structured representation of your code's logic
- Checks each node of that tree against configured rules
- Reports violations when patterns match known problems or style preferences
What Linters Catch
Linters look for three main categories:
- Syntax errors: Malformed code that would break at runtime (
const x =;) - Logic errors: Valid syntax but likely bugs (unused variables, unreachable code)
- Style issues: Code that works but violates team conventions (spacing, quotes, naming)
The Power of Static Analysis
Because linters don't execute code, they're fast and safe. They can analyze thousands of lines in seconds without worrying about infinite loops, API calls, or side effects. They catch issues before runtime—often before you even save the file if your editor is configured properly.
However, linters have limits: they can't catch runtime-only bugs (like type mismatches in loosely-typed operations) or logic errors that require execution context to understand.
Key Takeaway: Linters perform static code analysis—scanning and checking your code against rules without running it—to catch errors, bugs, and style violations early in development.