An AST-based pattern checker for JavaScript.
ESLint is a static code analysis tool that examines JavaScript code for problems without executing it. Built on an Abstract Syntax Tree (AST) parser, it identifies potential bugs, stylistic inconsistencies, and code pattern violations based on configurable rules. Created by Nicholas C. Zakas in 2013, ESLint has become the de facto standard for JavaScript linting with over 79 million weekly downloads.
Unlike older tools like JSLint or JSHint, ESLint was designed from the ground up to be completely pluggable. Every rule is independent and configurable, allowing teams to define their own coding standards or adopt popular presets like Airbnb, Google, or StandardJS. Rules can be set to 'warn' or 'error' severity levels, and ESLint makes no opinionated decisions about your code style by default.
The tool integrates seamlessly into modern development workflows through editor plugins for VS Code, WebStorm, Sublime Text, and others, providing real-time feedback as you write code. It also runs in CI/CD pipelines to enforce quality gates before code reaches production. With support for modern JavaScript features, JSX, TypeScript (via plugins), and custom parsers, ESLint adapts to diverse project requirements.
ESLint's automatic fixing capability handles many violations programmatically using syntax-aware transformations rather than naive find-and-replace. This makes it safe to run --fix on large codebases without introducing new bugs. The vibrant ecosystem includes hundreds of community-maintained plugins for frameworks like React, Vue, and Angular, as well as specialized rule sets for accessibility, security, and performance optimization.
// eslint.config.mjs
import js from '@eslint/js';
import globals from 'globals';
export default [
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 2024,
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'no-console': 'warn',
'prefer-const': 'error',
'eqeqeq': ['error', 'always'],
'curly': ['error', 'all'],
},
},
{
files: ['**/*.test.js'],
languageOptions: {
globals: {
...globals.jest,
},
},
rules: {
'no-console': 'off',
},
},
];
// Run: npx eslint src/**/*.js
// Run with autofix: npx eslint src/**/*.js --fixEnforcing team coding standards: Configure ESLint with a shared configuration to ensure all developers follow consistent patterns for variable naming, import ordering, indentation, and code structure. This reduces friction during code reviews and maintains readability across large codebases.
Catching common bugs before runtime: ESLint detects problematic patterns like unused variables, unreachable code, missing return statements in functions, and incorrect use of async/await. These checks catch mistakes that JavaScript's dynamic nature would otherwise allow through to production.
Integrating with CI/CD pipelines: Run ESLint as a quality gate in GitHub Actions, GitLab CI, or Jenkins to automatically reject pull requests that violate coding standards. This prevents technical debt from accumulating and enforces quality without manual oversight.
Migrating legacy code to modern standards: Apply ESLint with autofixing to gradually modernize old codebases by converting var to const/let, updating callback patterns to promises, and applying consistent formatting. The tool's safe transformations allow incremental improvements without full rewrites.
Framework-specific linting: Use specialized plugins like eslint-plugin-react to enforce React best practices (proper hook dependencies, key props in lists), eslint-plugin-vue for Vue component standards, or @typescript-eslint for TypeScript-specific type safety checks beyond what the compiler catches.
npm install eslintpnpm add eslintbun add eslint