Installation Guide
This guide covers everything you need to know about installing and configuring ESLint for your JavaScript or TypeScript project.System Requirements
Node.js Version
Required:
^20.19.0, ^22.13.0, or >=24ESLint requires Node.js built with SSL support (included in all official distributions).Package Manager
Supported: npm, yarn, pnpm, or bunAny modern JavaScript package manager will work with ESLint.
Check your Node.js version:
node --versionIf you need to upgrade, visit nodejs.org to download the latest LTS version.Quick Installation
The fastest way to get started is with the interactive configuration tool:- Guide you through project-specific setup questions
- Install ESLint and required dependencies
- Create an
eslint.config.jsconfiguration file - Set up appropriate plugins (React, TypeScript, etc.)
Manual Installation
- npm
- yarn
- pnpm
- bun
Framework-Specific Setup
React
React
Configuration File Formats
ESLint supports multiple configuration file formats. Choose based on your project setup:- ESM (eslint.config.js)
- CommonJS (eslint.config.cjs)
- ESM (eslint.config.mjs)
Recommended for modern projects
eslint.config.js
- Uses ES module syntax
- Supports top-level
await - Default for new projects
Understanding the Config Structure
ESLint uses a flat config structure. Here’s a breakdown of the key components from the source:eslint.config.js
Key Configuration Options
files
Glob patterns for which files to lint:
ignores
Patterns to exclude from linting:
languageOptions
Parser and language settings:
rules
Individual rule configuration:
Recommended Rules Reference
ESLint’s recommended configuration includes 74 carefully selected rules. Here are some key ones fromeslint-recommended.js:1-76:
- Problem Detection
- Best Practices
- ES6+ Features
Rules that catch actual bugs:
Environment-Specific Setup
1
Browser Projects
Configure globals for browser environments:This adds globals like
eslint.config.js
window, document, localStorage, etc.2
Node.js Projects
Configure for Node.js runtime:This adds globals like
eslint.config.js
process, __dirname, Buffer, etc.3
Test Environments
Configure for testing frameworks:
eslint.config.js
Package.json Scripts
Add these scripts to yourpackage.json for convenient linting:
package.json
Verifying Installation
After installation, verify everything is working:1
Check ESLint Version
2
Verify Configuration
3
Test on a File
Troubleshooting
Module Resolution Errors
Module Resolution Errors
Error:
Cannot find module 'eslint-plugin-*'Solution: Ensure plugins are installed in the same location as ESLint. With pnpm, make sure your .npmrc has node-linker=hoisted.Config File Not Found
Config File Not Found
Error:
ESLint couldn't find a configuration fileSolution: ESLint looks for eslint.config.js, eslint.config.mjs, or eslint.config.cjs in the project root. Check:- File is in the correct location
- File name is spelled correctly
- File exports a valid configuration
Parsing Errors with TypeScript
Parsing Errors with TypeScript
Error: Update your config:
Parsing error: Unexpected tokenSolution: Install the TypeScript parser:Slow Linting Performance
Slow Linting Performance
Issue: ESLint is running slowly on large codebasesSolutions:
- Enable caching:
- Use parallel processing (ESLint automatically uses available CPU cores):
- Ignore unnecessary files:
Node.js Version Mismatch
Node.js Version Mismatch
Error:
ESLint requires Node.js version ^20.19.0 || ^22.13.0 || >=24Solution: Upgrade Node.js to a supported version:Next Steps
Configure Rules
Learn how to customize individual rules for your project
Integrations
Set up ESLint with your editor, build tools, and CI/CD
Create Plugins
Build custom plugins to extend ESLint’s functionality
Migration Guide
Upgrading from an older ESLint version? Check the migration guide
Additional Resources
- Source Code: The ESLint installation is defined in
package.json:1-221with the binary atbin/eslint.js:1-196 - CLI Options: Full reference in
lib/options.js:1-150+ - Config API: Exported from
lib/config-api.js - GitHub: github.com/eslint/eslint
- Discord: eslint.org/chat