ESLint 10
This skill covers ESLint 10.14.0 as documented on https://eslint.org/docs/latest/. It holds what differs from habit: flat config pitfalls, surprising defaults, removed APIs and the patterns the docs recommend. Each claim in the reference files ends with the page it comes from.
How to navigate
- Read the quick rules below. They catch the most frequent mistakes.
- Open the one reference file that matches the task, from the table at the end.
- When the code uses
.eslintrc,env,context.getScope()orFlatESLint, readreferences/migration.mdfirst.
Quick start
npm init @eslint/config@latest
// eslint.config.js
import js from "@eslint/js";
import globals from "globals";
import { defineConfig, globalIgnores } from "eslint/config";
export default defineConfig([
globalIgnores(["dist/"]),
{
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
plugins: { js },
extends: ["js/recommended"],
languageOptions: { globals: { ...globals.browser } },
rules: { "no-unused-vars": "warn" },
},
]);
https://eslint.org/docs/latest/use/getting-started , https://eslint.org/docs/latest/use/configure/configuration-files
- Node.js
^20.19.0,^22.13.0or>=24. TypeScript types need TypeScript 5.3+. https://eslint.org/docs/latest/use/getting-started - Install
eslintand@eslint/jslocally as dev dependencies. A global install is not recommended and plugins must still be local.globalsis a separate package. https://eslint.org/docs/latest/use/getting-started , https://eslint.org/docs/latest/use/configure/migration-guide eslint.config.tsneeds the dev dependencyjiti>= 2.2.0 on Node. https://eslint.org/docs/latest/use/configure/configuration-files
Quick rules
Config files
- ESLint lints nothing useful until you extend a config or enable rules. https://eslint.org/docs/latest/use/getting-started
- Config lookup starts in each linted file's directory and walks up.
--configforces 1 file. https://eslint.org/docs/latest/use/configure/configuration-files , https://eslint.org/docs/latest/use/migrate-to-10.0.0 - An object without
filesapplies to every file another object matches. Once you lint.ts,.mdor.json, scope JS rules withfiles, and always putfilesnext toextends. https://eslint.org/docs/latest/use/configure/configuration-files ignoresalone in an object (global ignores) can match directories. Next to other keys it matches files only:"dir/**", not"dir/". PreferglobalIgnores(). https://eslint.org/docs/latest/use/configure/configuration-files- Dotfiles are linted unless ignored. Only
**/node_modules/and.git/are ignored by default. https://eslint.org/docs/latest/use/configure/ignore , https://eslint.org/docs/latest/use/configure/configuration-files - Import
.gitignorewithincludeIgnoreFile(path, { gitignoreResolution: true })fromeslint/config. https://eslint.org/docs/latest/use/configure/ignore - No environments: declare globals with the
globalspackage inlanguageOptions.globals. https://eslint.org/docs/latest/use/configure/language-options - Plugins, parsers and processors are imported objects. Processors are never applied automatically. https://eslint.org/docs/latest/use/configure/migration-guide
- Inspect what matches a file with
npx eslint --inspect-configor--print-config file.js. https://eslint.org/docs/latest/use/configure/debug
Rules and comments
- A severity-only override keeps the earlier options, in config and in
/* eslint */comments. https://eslint.org/docs/latest/use/configure/rules , https://eslint.org/docs/latest/use/migrate-to-9.0.0 - An inline comment cannot load a plugin. A bare
/* eslint-enable */re-enables every rule. https://eslint.org/docs/latest/use/configure/rules - Put the reason after
--:// eslint-disable-next-line no-console -- reason. https://eslint.org/docs/latest/use/configure/rules /* eslint-env */is an error in ESLint 10. Use/* global name */or config globals. https://eslint.org/docs/latest/use/migrate-to-10.0.0no-unused-varsreports unusedcatch (e)by default: writecatch {. https://eslint.org/docs/latest/rules/no-unused-vars- Do not enable
no-return-await. Use a formatter or ESLint Stylistic rather than core layout rules. https://eslint.org/docs/latest/rules/no-return-await , https://eslint.org/docs/latest/use/core-concepts/glossary
CLI and CI
- Exit code 1 means errors (or too many warnings), 2 means a config or internal error. https://eslint.org/docs/latest/use/command-line-interface
--quietdoes not run"warn"rules, unless--max-warningsis also set: then they run but are not reported. https://eslint.org/docs/latest/use/command-line-interface- Quote globs.
--fixthrows on stdin: use--fix-dry-run --format json. https://eslint.org/docs/latest/use/command-line-interface --cacheignores cross-file dependencies: type-aware and import rules can be stale. https://eslint.org/docs/latest/use/command-line-interface- Adopt a strict rule on old code with
eslint --fix --suppress-alland commiteslint-suppressions.json. https://eslint.org/docs/latest/use/suppressions
Custom rules and integrations
- A rule is
{ meta, create }.meta.fixableandmeta.hasSuggestionsare required to fix or suggest,meta.schemato accept options. https://eslint.org/docs/latest/extend/custom-rules - Use
context.sourceCode,context.filenameandsourceCode.getScope(node). Thecontext.getX()methods are gone. https://eslint.org/docs/latest/use/migrate-to-10.0.0 , https://eslint.org/docs/latest/use/migrate-to-9.0.0 new ESLint({ fix: true })writes nothing untilESLint.outputFixes(results). https://eslint.org/docs/latest/integrate/nodejs-api- Give a plugin
meta.name,meta.versionandmeta.namespacefor easier debugging and more effective caching. The namespace letsdefineConfig()find the plugin under another name. https://eslint.org/docs/latest/extend/plugins
Old patterns
| Old | Current |
|---|---|
.eslintrc.*, eslintConfig in package.json | eslint.config.js with defineConfig() |
"extends": "eslint:recommended" | extends: ["js/recommended"] with plugins: { js } |
env, /* eslint-env */ | languageOptions.globals, /* global */ |
.eslintignore, --ignore-path | globalIgnores(), includeIgnoreFile() |
overrides | More config objects with files |
--rulesdir, linter.defineRule() | Inline plugin plugins: { local: { rules } } |
--no-eslintrc | --no-config-lookup |
context.getScope(), context.getSourceCode() | sourceCode.getScope(node), context.sourceCode |
| Function-style rules | { meta, create } |
FlatESLint, LegacyESLint, FlatRuleTester | ESLint, RuleTester |
require-jsdoc, valid-jsdoc | eslint-plugin-jsdoc |
Details and the full lists: references/migration.md.
Reference files
| File | Read it for |
|---|---|
| references/configuration.md | Config file names and lookup, TypeScript configs, config object keys, files matching, extends, language options, globals, parsers, processors, languages, debugging |
| references/ignoring-files.md | Global and non-global ignores, default ignores, dotfiles, unignore recipes, .gitignore import |
| references/rules-and-inline-config.md | Severities, option merging, inline config comments, disable directives, linterOptions, fixes versus suggestions, circular fixes |
| references/cli.md | Globs, --fix, exit codes, --quiet, formatters, cache, bulk suppressions, feature flags, concurrency, MCP server |
| references/migration.md | ESLint 9 and 10 breaking changes, codemods, eslintrc to flat config, changed rule options, broken plugins |
| references/custom-rules.md | Rule meta, local rules, context.report, fixes, suggestions, meta.schema, meta.defaultOptions, deprecation, removed context methods |
| references/ast-scope-code-paths.md | Selectors, SourceCode methods, scopes, scope manager objects, code path events, profiling |
| references/testing-rules.md | RuleTester defaults, valid and invalid cases, fix and suggestion assertions, strict checks, framework hooks |
| references/plugins-and-shareable-configs.md | Plugin object and meta, plugin configs, publishing, shareable configs, custom parsers, processors, languages, formatters |
| references/nodejs-api.md | ESLint options and methods, lintText, outputFixes, loadFormatter, LintResult, Linter, SourceCode |
| references/core-rules-problems.md | Rules TypeScript covers, unused and undeclared variables, shadowing, conditions, async errors, regex traps |
| references/core-rules-restrictions.md | no-restricted-imports, -globals, -properties, -exports, no-restricted-syntax recipes, other bans, size and complexity limits |
| references/core-rules-style.md | Suggestion rule defaults, layout rule defaults, removed rules, deprecated options |
Crawled pages: SOURCES.md.