Guide · Open source
How to use ESLint: install, configure and run it
Updated · written with AI from the project's own documentation and checked against our catalogue data
ESLint is an open-source tool that scans JavaScript (ECMAScript) code, reports patterns that may be problems or bad practice, and can be configured rule by rule. This guide is for JavaScript developers and teams who want automatic checks and shared coding rules. By the end you will know how to install ESLint, run it on a file, and turn individual rules on or off.
Quick start
- 1Check your Node.js version. Confirm Node.js is ^20.19.0, ^22.13.0, or >=24 and built with SSL and ICU.
- 2Run the setup command. Run npm init @eslint/config@latest in your project to install and configure ESLint.
- 3Review eslint.config.js. Open the generated eslint.config.js and check which files and rules are set.
- 4Set rule levels. Set each rule to "off", "warn" or "error" depending on how strict you want the check to be.
- 5Run ESLint on a file. Run npx eslint yourfile.js and read the reported problems.
- 6Add React or other plugins if needed. If you use React, add eslint-plugin-react for React-specific rules.
What you need before installing ESLint
ESLint needs Node.js with a supported version: ^20.19.0, ^22.13.0, or >=24. Node.js must be built with SSL and ICU support. Official Node.js distributions include both.
If you use ESLint's TypeScript type definitions, TypeScript 5.3 or later is required.
- Node.js ^20.19.0, ^22.13.0, or >=24
- SSL and ICU support (always included in official Node.js distributions)
- TypeScript 5.3 or later, only if you use ESLint's TypeScript type definitions
Install and configure ESLint with npm
Run the setup command below to install and configure ESLint in your project. Once that is done, you can run ESLint on any file or directory.
If you use pnpm instead of npm, the README recommends a .npmrc file with the settings shown in the code block below. This makes pnpm install dependencies in a way that is more compatible with npm.
npm init @eslint/config@latest
npx eslint yourfile.js
# pnpm: add to .npmrc
auto-install-peers=true
node-linker=hoistedConfigure rules in eslint.config.js
Rules are configured in eslint.config.js files. Each rule name, such as prefer-const, is set to an error level. Each rule is a separate plugin, so you turn on only the checks you want.
The README lists three error levels: "off" (or 0) turns the rule off, "warn" (or 1) reports it as a warning that does not change the exit code, and "error" (or 2) reports it as an error so the exit code is 1. The configuration docs on the ESLint website cover more options.
- "off" or 0: turn the rule off
- "warn" or 1: warning only, does not affect exit code
- "error" or 2: error, exit code will be 1
import { defineConfig } from "eslint/config";
export default defineConfig([
{
files: ["**/*.js", "**/*.cjs", "**/*.mjs"],
rules: {
"prefer-const": "warn",
"no-constant-binary-expression": "error",
},
},
]);Run ESLint and read the results
Run ESLint on a single file with npx, or point it at a directory to check many files. ESLint parses each file into a syntax tree and checks it against the rules you enabled. Warnings and errors are reported with the rule that triggered them.
ESLint does not format code. The README says Prettier is the formatter and ESLint is the linter, and the two are commonly used together.
- Check one file: npx eslint yourfile.js
- Errors set to "error" make the command exit with code 1; warnings do not.
npx eslint yourfile.jsHandle JSX, React and experimental syntax
ESLint natively parses JSX, but this must be enabled in configuration. Supporting JSX syntax is not the same as supporting React: React gives JSX specific meaning that ESLint does not recognize by default. If you use React and want React rules, the README recommends adding eslint-plugin-react.
ESLint's parser officially supports only the latest final ECMAScript standard. For stage 3 proposals, the core rules are adjusted to avoid crashes, but for other cases the README suggests other parsers and plugins. If you use Babel, it names @babel/eslint-parser and @babel/eslint-plugin.
- JSX parsing: enable it in configuration
- React rules: add eslint-plugin-react
- Experimental syntax: use a suitable parser and plugin, such as Babel's
Keep ESLint versions and Node.js in step
The ESLint team supports the current version and gives six months of limited support to the previous version. Limited support covers critical bug fixes, security issues, and compatibility issues. Supported Node.js versions are updated with each major ESLint release, and the Quick Start Guide lists them for each release.
ESLint does not lock dependency versions when published, so your own project lock file is what keeps installs consistent between environments.
What people use it for
- Catching likely mistakes in JavaScript code, such as constant expressions that always evaluate the same way.
- Enforcing a shared set of rules across a team through one eslint.config.js file.
- Enforcing consistent variable declarations, for example flagging let where const could be used.
- Adding React-specific checks on top of JSX parsing with eslint-plugin-react.
- Running ESLint on a single file while editing, or on a whole project in CI.
Frequently asked questions
Is ESLint free to use?
ESLint is released under the MIT licence, according to the project's repository details. The source does not discuss pricing for other services. Commercial support for previous versions is offered through a partner, HeroDevs.
What Node.js version do I need for ESLint?
The README lists ^20.19.0, ^22.13.0, or >=24, built with SSL and ICU support. Official Node.js distributions include SSL and ICU. If you use ESLint's TypeScript type definitions, TypeScript 5.3 or later is required.
How do I install ESLint?
Run npm init @eslint/config@latest to install and configure it. Then run npx eslint yourfile.js to check a file. If you use pnpm, the README recommends a .npmrc with auto-install-peers=true and node-linker=hoisted.
Does ESLint replace Prettier?
No. ESLint is a linter that looks for problematic patterns, and Prettier is a code formatter. Many projects use both, and Prettier's documentation explains how to configure them to work together.
Does ESLint support React and JSX?
ESLint parses JSX natively, but you must enable it in configuration. For React semantics, the README recommends adding eslint-plugin-react, because JSX syntax support does not mean React support.
What are alternatives to ESLint?
The source names JSHint, Biome, typescript-eslint and Prettier as comparable projects. The README says ESLint is similar to JSLint and JSHint, but it is fully pluggable, with every rule being a plugin.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
ESLint suits JavaScript developers and teams who want automatic, configurable checks and shared rules enforced through one config file. If you only need code formatting, pick Prettier, and if you need to lint experimental syntax or run an unsupported Node.js version, check compatibility before adopting it.
Install options & downloads