{"id":10389,"library":"eslint","title":"ESLint","description":"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.","status":"active","version":"10.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/eslint/eslint","tags":["javascript","ast","lint","ecmascript","espree","typescript"],"install":[{"cmd":"npm install eslint","lang":"bash","label":"npm"},{"cmd":"yarn add eslint","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"const { ESLint } = require('eslint');","symbol":"ESLint","correct":"import { ESLint } from 'eslint';"}],"quickstart":{"code":"import { ESLint } from 'eslint';\n\nasync function lintCode(code: string): Promise<void> {\n  const eslint = new ESLint({\n    useEslintrc: false, // Don't use .eslintrc.* files\n    overrideConfigFile: true, // Use this config file\n    overrideConfig: {\n      languageOptions: {\n        ecmaVersion: 2022,\n        sourceType: \"module\",\n        globals: {\n          console: \"readonly\"\n        }\n      },\n      rules: {\n        \"no-unused-vars\": \"warn\",\n        \"prefer-const\": \"error\"\n      }\n    }\n  });\n\n  const results = await eslint.lintText(code);\n\n  console.log(`Linting results for: \"${code}\"`);\n  results.forEach(result => {\n    result.messages.forEach(message => {\n      console.log(\n        `  Line ${message.line}, Col ${message.column}: ${message.message} (${message.ruleId})`\n      );\n    });\n  });\n}\n\nlintCode(`\n  var x = 1; // no-unused-vars (warn), prefer-const (error)\n  console.log('hello');\n  const y = 2;\n`).catch(console.error);","lang":"typescript","description":"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."},"warnings":[{"fix":"Upgrade Node.js to a supported version.","message":"ESLint v10 requires Node.js v20.19.0, v22.13.0, or >=24. Older Node.js versions are not supported.","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Refactor your `eslint.config.js` to use `import` and `export` statements, for example, `export default defineConfig(...)`.","message":"Configuration files (`eslint.config.js`) must be written in ESM format (`import/export` syntax). CommonJS (`require/module.exports`) is no longer supported for config files.","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Ensure your project is configured for ESM, and use `import { ESLint } from 'eslint';`.","message":"Programmatic 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.","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Add `auto-install-peers=true` and `node-linker=hoisted` to your `.npmrc` file and reinstall dependencies.","message":"Using `pnpm` requires specific `.npmrc` settings (`auto-install-peers=true`, `node-linker=hoisted`) to avoid dependency resolution errors related to peer dependencies.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure your project's `typescript` dependency is at version 5.3 or newer.","message":"If you use ESLint's TypeScript type definitions, TypeScript 5.3 or later is required.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-18T00:00:00.000Z","next_check":"2026-07-17T00:00:00.000Z","problems":[{"fix":"Upgrade your Node.js installation to v20.19.0, v22.13.0, or >=24.","cause":"Running ESLint v10 on an unsupported Node.js version (e.g., Node.js 18).","error":"ESLint: Node.js v18.x is no longer supported. Please upgrade to a supported version."},{"fix":"Ensure you are using `import { ESLint } from 'eslint';` in an ESM module context.","cause":"Attempting to use `require('eslint').ESLint` in an ESM context, or incorrectly mixing CJS and ESM, or not importing it correctly.","error":"TypeError: ESLint is not a constructor"},{"fix":"Convert your project or specific file to use ESM `import` statements, and ensure your `eslint.config.js` is also ESM.","cause":"Attempting to `require()` an ESLint module that is ESM-only, or trying to load an `eslint.config.js` file with `require` syntax.","error":"ERR_REQUIRE_ESM: Must use import to load ES Module: .../node_modules/eslint/lib/eslint/eslint.js"},{"fix":"Add `auto-install-peers=true` and `node-linker=hoisted` to your `.npmrc` file and reinstall dependencies.","cause":"Occurs with `pnpm` if peer dependencies are not correctly hoisted or automatically installed.","error":"Error: Cannot find module '@eslint/js/configs/eslint-recommended'"},{"fix":"Update TypeScript to version 5.3 or later, or ensure `eslint` is properly installed in your `node_modules`.","cause":"TypeScript version is too old for ESLint's type definitions, or `eslint` is not correctly installed.","error":"TS2307: Cannot find module 'eslint' or its corresponding type declarations."}],"ecosystem":"npm"}