Skip to main content
The ESLint class is the primary interface for integrating ESLint into Node.js applications. It supports flat config and provides high-level methods for linting files, formatting results, and managing configurations.

Constructor

object
Configuration options for the ESLint instance.

Static Properties

ESLint.version

string
The ESLint version string (e.g., “9.0.0”).

ESLint.configType

string
The type of configuration used by this class. Always returns "flat".

ESLint.defaultConfig

FlatConfigArray
The default configuration that ESLint uses internally.

Instance Methods

lintFiles()

Lints files matching the given patterns.
string | string[]
required
File patterns to lint. Can be file paths, directory paths, or glob patterns.
LintResult[]
Array of linting results for each file.

lintText()

Lints the provided source code text.
string
required
The source code to lint.
object
LintResult[]
Array containing a single linting result.

loadFormatter()

Loads a formatter to format lint results.
string
default:"stylish"
Name of the formatter. Can be:
  • A built-in formatter name (e.g., "stylish", "json")
  • A third-party formatter (e.g., "eslint-formatter-pretty")
  • A file path to a custom formatter
object

calculateConfigForFile()

Calculates the configuration for a given file.
string
required
The path to the file.
object | undefined
The calculated configuration object, or undefined if no configuration applies.

findConfigFile()

Finds the config file being used.
string
The path to find the config file for. Defaults to cwd.
string | undefined
The path to the config file, or undefined if not found.

isPathIgnored()

Checks if a path is ignored by ESLint.
string
required
The path to check.
boolean
true if the path is ignored, false otherwise.

getRulesMetaForResults()

Returns metadata for rules used in the results.
LintResult[]
required
The lint results to get metadata for.
Record<string, RulesMeta>
Object mapping rule IDs to their metadata.

hasFlag()

Checks if a feature flag is enabled.
string
required
The feature flag name to check.
boolean
true if the flag is enabled, false otherwise.

Static Methods

ESLint.outputFixes()

Writes fixes to files.
LintResult[]
required
The lint results containing fixes to apply.

ESLint.getErrorResults()

Filters results to only include errors.
LintResult[]
required
The lint results to filter.
LintResult[]
Results containing only error messages.

ESLint.fromOptionsModule()

Creates an ESLint instance from an options module URL.
URL
required
URL to a module that exports ESLint options.
ESLint
A new ESLint instance.

Examples