API Reference

ESLint

Pluggable static analysis tool whose Node API lints files, applies automatic fixes, and reports structured results.

Official Documentation ↗
CompatibilityThis documentation covers version v10.14.0. Check the official docs for the latest API surface.

Installation

npmnpm install --save-dev eslint
pnpmpnpm add -D eslint

Methods

Overview

ESLint is a pluggable linter whose Node API can lint files, apply fixes, and serialize results. ESLint 9 standardizes on flat config. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.

Core APIs

  • eslint.lintFiles — Lints the matched files and resolves with per-file results including messages and fix info.
  • ESLint.outputFixes — Writes the automatically fixed output back to the files it came from.
  • eslint.loadFormatter — Loads a formatter plugin so results can be rendered for humans or CI.

Example

const { ESLint } = require('eslint');

const eslint = new ESLint({ fix: true });
const results = await eslint.lintFiles(['src/**/*.ts']);
console.log(results[0].messages);

Notes

ESLint 9 requires flat config, so legacy .eslintrc files need migration. Fixes are not written unless you explicitly call ESLint.outputFixes.

Verification

Lint a file containing a fixable issue and confirm the message disappears after running outputFixes and re-linting.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://eslint.org/docs/latest/integrate/nodejs-api · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:49:27.616Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

FAQ

What changed in ESLint 9?
ESLint 9 defaults to flat config (eslint.config.js) and makes it the only supported format, replacing .eslintrc.
How do I apply fixes programmatically?
Construct ESLint with { fix: true }, then pass the results to ESLint.outputFixes to write changes to disk.
How do I lint files without a config file?
Pass { overrideConfig: true, overrideConfigFile: [...] } or use the flat config object via overrideConfig for inline rules.