Skip to main content

Quick Start Guide

Get ESLint analyzing your JavaScript code in under 5 minutes. This guide will walk you through the essentials.

Prerequisites

Before you begin, ensure you have Node.js installed:
Required: Node.js ^20.19.0, ^22.13.0, or >=24 built with SSL support.Check your version: node --version

Installation & Setup

1

Initialize ESLint Configuration

Run the interactive configuration wizard to set up ESLint for your project:
This command will:
  • Detect your project type (JavaScript, TypeScript, React, etc.)
  • Ask about your code style preferences
  • Install required dependencies
  • Create an eslint.config.js file
The wizard is smart enough to detect if you’re using React, Vue, or TypeScript and will configure ESLint accordingly.
2

Run Your First Lint

Lint a single file:
Or lint an entire directory:
3

Fix Problems Automatically

Many ESLint errors can be fixed automatically. Run with the --fix flag:
This will automatically fix:
  • Spacing and indentation issues
  • Missing semicolons
  • Quote style inconsistencies
  • And many other stylistic problems
The --fix flag modifies your files in place. Make sure your code is committed or backed up before running it.
4

Add Lint Script to package.json

Add ESLint to your npm scripts for easy access:
package.json
Now you can run:

Understanding the Config File

The configuration wizard creates an eslint.config.js file. Here’s what a basic config looks like:
eslint.config.js

Configuration Breakdown

Specifies which files ESLint should analyze. Supports glob patterns:
This matches all .js, .cjs, and .mjs files in any directory.
Configures individual rules with severity levels:
  • "off" or 0 - Disable the rule
  • "warn" or 1 - Show warning (exit code 0)
  • "error" or 2 - Show error (exit code 1)
Import configurations from presets:

Common Rules to Start With

Here are some essential rules from the ESLint source code:

no-unused-vars

Type: Problem
Recommended: ✓
Disallow unused variables to keep your code clean.

no-undef

Type: Problem
Recommended: ✓
Disallow undefined variables to catch typos early.

prefer-const

Type: Suggestion
Fixable: ✓
Suggest using const for variables that are never reassigned.

no-debugger

Type: Problem
Recommended: ✓
Disallow debugger statements in production code.

CLI Options Quick Reference

Here are the most commonly used CLI options from ESLint’s source:
For a complete list of CLI options, run npx eslint --help or check the options.js source file.

What’s Next?

Deep Dive into Installation

Learn about advanced installation options, pnpm setup, and TypeScript configuration

Configuration Guide

Master ESLint’s powerful configuration system

Rules Reference

Browse all 200+ built-in rules with examples

Create Custom Rules

Build your own rules to enforce project-specific patterns

Troubleshooting

Make sure your config file is named eslint.config.js, eslint.config.mjs, or eslint.config.cjs and is in your project root.You can also specify a config file explicitly:
This usually means ESLint can’t parse your JavaScript syntax. If you’re using modern syntax or TypeScript:
Then update your config:
Check that:
  1. The files pattern matches your source files
  2. The rule is spelled correctly (e.g., no-unused-vars, not no-unused-variables)
  3. Your config file is being loaded (run with --debug flag)

Need Help?