Registry / testing / eslint

eslint

JSON →
library10.2.1jsnpmunverified

ESLint is a powerful, pluggable tool for identifying and reporting on patterns found in ECMAScript/JavaScript code, enforcing coding standards and catching potential issues. It uses an AST-based parser and is entirely pluggable. The current stable version is v10.2.1. It follows a frequent release cadence for minor features and bug fixes, with major versions introducing breaking changes.

npm install eslint
INSTALL
IMPORT
SIG · ESLINT
E
eslint
testingjavascriptv10.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ESLint
import { ESLint } from 'eslint';
const { ESLint } = require('eslint');
ESLint v9+ is designed for ESM environments. While a CJS entry point exists, it is largely deprecated, and configuration files (`eslint.config.js`) must be ESM.

This example demonstrates how to programmatically use the ESLint class to lint a string of JavaScript code with a custom configuration, reporting any found issues.

import { ESLint } from 'eslint'; async function lintCode(code: string): Promise<void> { const eslint = new ESLint({ useEslintrc: false, // Don't use .eslintrc.* files overrideConfigFile: true, // Use this config file overrideConfig: { languageOptions: { ecmaVersion: 2022, sourceType: "module", globals: { console: "readonly" } }, rules: { "no-unused-vars": "warn", "prefer-const": "error" } } }); const results = await eslint.lintText(code); console.log(`Linting results for: "${code}"`); results.forEach(result => { result.messages.forEach(message => { console.log( ` Line ${message.line}, Col ${message.column}: ${message.message} (${message.ruleId})` ); }); }); } lintCode(` var x = 1; // no-unused-vars (warn), prefer-const (error) console.log('hello'); const y = 2; `).catch(console.error);
eslint --version
Debug
Known issues
breakingESLint v10 requires Node.js v20.19.0, v22.13.0, or >=24. Older Node.js versions are not supported.
fix
Upgrade Node.js to a supported version.
affects: >=10.0.0
breakingConfiguration files (`eslint.config.js`) must be written in ESM format (`import/export` syntax). CommonJS (`require/module.exports`) is no longer supported for config files.
fix
Refactor your `eslint.config.js` to use `import` and `export` statements, for example, `export default defineConfig(...)`.
affects: >=9.0.0
breakingProgrammatic usage of ESLint, including the `ESLint` class, is primarily designed for ESM environments. While a CJS entry point may exist, it is largely deprecated and can lead to module resolution issues.
fix
Ensure your project is configured for ESM, and use `import { ESLint } from 'eslint';`.
affects: >=9.0.0
gotchaUsing `pnpm` requires specific `.npmrc` settings (`auto-install-peers=true`, `node-linker=hoisted`) to avoid dependency resolution errors related to peer dependencies.
fix
Add `auto-install-peers=true` and `node-linker=hoisted` to your `.npmrc` file and reinstall dependencies.
affects: *
gotchaIf you use ESLint's TypeScript type definitions, TypeScript 5.3 or later is required.
fix
Ensure your project's `typescript` dependency is at version 5.3 or newer.
affects: *
Errors
Common errors & fixes
ESLint: Node.js v18.x is no longer supported. Please upgrade to a supported version.
Running ESLint v10 on an unsupported Node.js version (e.g., Node.js 18).
fix
Upgrade your Node.js installation to v20.19.0, v22.13.0, or >=24.
TypeError: ESLint is not a constructor
Attempting to use `require('eslint').ESLint` in an ESM context, or incorrectly mixing CJS and ESM, or not importing it correctly.
fix
Ensure you are using `import { ESLint } from 'eslint';` in an ESM module context.
ERR_REQUIRE_ESM: Must use import to load ES Module: .../node_modules/eslint/lib/eslint/eslint.js
Attempting to `require()` an ESLint module that is ESM-only, or trying to load an `eslint.config.js` file with `require` syntax.
fix
Convert your project or specific file to use ESM `import` statements, and ensure your `eslint.config.js` is also ESM.
Error: Cannot find module '@eslint/js/configs/eslint-recommended'
Occurs with `pnpm` if peer dependencies are not correctly hoisted or automatically installed.
fix
Add `auto-install-peers=true` and `node-linker=hoisted` to your `.npmrc` file and reinstall dependencies.
TS2307: Cannot find module 'eslint' or its corresponding type declarations.
TypeScript version is too old for ESLint's type definitions, or `eslint` is not correctly installed.
fix
Update TypeScript to version 5.3 or later, or ensure `eslint` is properly installed in your `node_modules`.
Upgrade
Version history
10.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
eslint — npm install eslint · libregistry