Skip to main content

Command Line Interface

The ESLint Command Line Interface (CLI) lets you execute linting from the terminal. The CLI has a variety of options that you can pass to configure ESLint.

Basic Usage

ESLint requires Node.js for installation. Most users use npx to run ESLint on the command line:
When passing a glob as a parameter, it is expanded by your shell. Quote your parameter if you need it to run in Windows: npx eslint "lib/**"

CLI Options Reference

Basic Configuration

Use a specific configuration file instead of the default eslint.config.js.
Type: String (path to file)
Disables automatic lookup for eslint.config.js files.
Opens the config inspector to visualize your configuration.
This runs @eslint/config-inspector to help you understand what your configuration is doing.
Specify additional file extensions to lint beyond the default .js, .mjs, and .cjs.
Type: String or Array Default: .js, .mjs, .cjs
Define global variables so they are not flagged as undefined by the no-undef rule.
Append :true to a variable name to allow writes to that global.
Specify the parser to be used by ESLint.
Default: espree
Specify parser options as key-value pairs.
Format: key:value pairs

Rules and Plugins

Specify plugins to load. You can optionally omit the eslint-plugin- prefix.
You must install the plugin using npm before using this option.
Specify rules to be used. These are merged with configuration file rules.
Format: Uses levn format
Combine with --no-config-lookup to only apply command line rules.

Fix Problems

Automatically fix problems. Fixes are made to the actual files.
  • This option throws an error when code is piped to ESLint
  • Not all problems are fixable
  • Has no effect on code that uses a processor (unless the processor opts in)
Fix problems without saving changes to the file system.
Useful for editor integrations that need to autofix text without saving.
Specify the types of fixes to apply.
Options:
  • problem - fix potential errors in the code
  • suggestion - apply fixes that improve code
  • layout - apply fixes that don’t change the AST
  • directive - apply fixes to inline directives

Ignore Files

Disables excluding files from --ignore-pattern and the ignores configuration property.
Specify patterns of files to ignore (uses minimatch syntax).
Quote your patterns to avoid shell interpretation of glob patterns.

Input/Output

Lint code provided on STDIN instead of from files.
Specify a filename to process STDIN as.
Useful when processing files from STDIN and you have rules that depend on the filename.
Write the output to a specified file.
Specify the output format for the console.
Built-in formatters:
  • stylish (default)
  • json
  • json-with-metadata
  • html
Force enabling or disabling of colorized output.

Handle Warnings

Report errors only - disables reporting on warnings.
Only rules set to error will be run; rules set to warn are disabled.
Specify a warning threshold to force ESLint to exit with an error status.
Type: Integer Default: -1 (unlimited)
When used with --quiet, rules marked as warn still run but are not reported.

Caching

Only check changed files. Dramatically improves performance by storing info about processed files.
Default cache location: .eslintcache
Autofixed files are not placed in the cache. Subsequent linting that doesn’t trigger an autofix will place it in the cache.
Specify the path to the cache file or directory.
Add a trailing / on *nix systems or \ on Windows if specifying a directory.
Strategy for detecting changed files in the cache.
Options:
  • metadata (default) - uses file modification time
  • content - uses file content hash
Use content strategy for git operations where modification time changes but content doesn’t.

Miscellaneous

Run config initialization wizard.
Runs npm init @eslint/config to help create an eslint.config.js file.
Output debugging information to the console.
Useful when you’re seeing a problem and having a hard time pinpointing it.
Output the help menu.
Output the current ESLint version.
Add detailed performance statistics to the lint results.
Includes parse, fix, and lint times per rule.
Output execution environment information.
Displays Node.js, npm, and ESLint version information.
Control the number of worker threads used to lint files.
Options:
  • off (default) - lint in main thread
  • auto - determine best setting automatically
  • <number> - specific number of threads

Exit Codes

When linting files, ESLint exits with one of the following exit codes:

Exit Code 0

Linting successful with no errors. Warnings are at most equal to --max-warnings value.

Exit Code 1

Linting successful but at least one error found, or warnings exceed --max-warnings.

Exit Code 2

Linting unsuccessful due to configuration problem or internal error.

Examples

Configuration

Learn how to configure ESLint using eslint.config.js

Formatters

Explore different output format options

Ignoring Code

Learn how to ignore files and patterns

Core Concepts

Understand ESLint fundamentals