Core Concepts
ESLint is a configurable JavaScript linter that helps you find and fix problems in your code. This page covers the core concepts you need to understand to use ESLint effectively.What is ESLint?
ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. Problems can be anything from potential runtime bugs, to not following best practices, to styling issues.AST-Based
Uses an Abstract Syntax Tree to evaluate patterns in code
Pluggable
Every single rule is a plugin - add more at runtime
Configurable
Customize which rules to enforce and how
Rules
Rules are the core building block of ESLint. A rule validates if your code meets a certain expectation, and what to do if it doesn’t.ESLint contains hundreds of built-in rules that you can use. You can also create custom rules or use rules from plugins.
Understanding Rules
Each rule has:Rule ID
Rule ID
A unique identifier like
semi, no-unused-vars, or prefer-const.Severity Level
Severity Level
Three severity levels control enforcement:
"off"or0- Turn the rule off"warn"or1- Turn on as a warning (doesn’t affect exit code)"error"or2- Turn on as an error (exit code will be 1)
Options
Options
Many rules accept additional configuration options:The first item in the array is always the severity level.
Rule Categories
ESLint rules fall into different categories:- Problem
- Suggestion
- Layout
Possible ErrorsThese rules identify code that could cause runtime errors:
no-unused-vars- Variables that are declared but never usedno-undef- Undefined variablesuse-isnan- Require isNaN() when checking for NaN
Many formatting rules are being deprecated in favor of dedicated formatters like Prettier or ESLint Stylistic.
Rule Fixes
Rules may provide automatic fixes for violations:Fixes 🔧
Safe, Automatic Corrections
- Don’t change application logic
- Applied with
--fixCLI option - Available in editor extensions
Suggestions 💡
Manual Review Required
- May change application logic
- Require manual review
- Only available in editors
Configuration Files
An ESLint configuration file is where you configure ESLint for your project:eslint.config.js
Configuration files can include:
- Built-in rules and their enforcement levels
- Plugins with custom rules
- Shareable configurations
- File patterns to apply rules to
- Language options (ECMAScript version, globals, etc.)
- Parser configuration
Shareable Configurations
Shareable configurations are ESLint configurations distributed via npm:eslint-config-airbnb-base
Popular Airbnb JavaScript style guide
eslint-config-standard
JavaScript Standard Style
eslint-config-google
Google JavaScript style guide
@eslint/js
ESLint’s recommended configuration
Plugins
Plugins are npm modules that can contain:- Rules - Custom ESLint rules
- Configurations - Predefined rule configurations
- Processors - Extract JavaScript from other file types
- Environments - Predefined global variables
Using Plugins
Popular Plugins
@typescript-eslint
@typescript-eslint
TypeScript support for ESLint:
eslint-plugin-react
eslint-plugin-react
React-specific linting rules:
@angular-eslint
@angular-eslint
Angular framework best practices:
Parsers
Parsers convert code into an Abstract Syntax Tree (AST) that ESLint can evaluate:- Espree (Default)
- @typescript-eslint/parser
- @babel/eslint-parser
Built-in JavaScript ParserESLint’s default parser, compatible with standard JavaScript runtimes:Supports all standard ECMAScript features.
Processors
Processors extract JavaScript code from other file types or manipulate code before parsing:@eslint/markdown
Lint JavaScript code inside Markdown code blocks
eslint-plugin-vue
Extract and lint JavaScript from Vue single-file components
Formatters
Formatters control the appearance of linting results in the CLI:- stylish (default)
- json
- html
- Custom
Integrations
ESLint integrates with many development tools:VS Code
ESLint Extension provides real-time feedback
WebStorm
Built-in ESLint support
Vim
ALE and Syntastic plugins
Webpack
eslint-webpack-plugin
Rollup
@rollup/plugin-eslint
Git Hooks
Lint on pre-commit
CLI & Node.js API
- CLI
- Node.js API
Command Line InterfaceExecute linting from the terminal:The CLI has many options for:
- Specifying files to lint
- Configuring output format
- Enabling auto-fix
- Setting up caching
- And much more
Unless you are extending ESLint in some way, you should use the CLI.
How ESLint Works
Parse Code
ESLint uses a parser (default: Espree) to convert your code into an Abstract Syntax Tree (AST).
Quick Reference
Rule Severity Levels
Rule Severity Levels
| Level | String | Number | Behavior |
|---|---|---|---|
| Off | "off" | 0 | Rule is disabled |
| Warning | "warn" | 1 | Reported but doesn’t affect exit code |
| Error | "error" | 2 | Reported and causes exit code 1 |
Configuration File Names
Configuration File Names
eslint.config.js- JavaScript (ESM or CommonJS)eslint.config.mjs- JavaScript (ESM only)eslint.config.cjs- JavaScript (CommonJS only)eslint.config.ts- TypeScript (requires jiti)eslint.config.mts- TypeScript ESMeslint.config.cts- TypeScript CommonJS
Common CLI Commands
Common CLI Commands
Exit Codes
Exit Codes
- 0 - Linting successful, no errors
- 1 - Linting successful, but errors found
- 2 - Linting failed (configuration problem or internal error)
Related Resources
Configuration
Learn how to configure ESLint
Rules
Configure rule severity and options
Command Line
CLI options and usage
Formatters
Output format options