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 usenpx 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
--config, -c
--config, -c
Use a specific configuration file instead of the default Type: String (path to file)
eslint.config.js.--no-config-lookup
--no-config-lookup
Disables automatic lookup for
eslint.config.js files.--inspect-config
--inspect-config
Opens the config inspector to visualize your configuration.This runs
@eslint/config-inspector to help you understand what your configuration is doing.--ext
--ext
Specify additional file extensions to lint beyond the default Type: String or Array
Default:
.js, .mjs, and .cjs..js, .mjs, .cjs--global
--global
Define global variables so they are not flagged as undefined by the Append
no-undef rule.:true to a variable name to allow writes to that global.--parser
--parser
Specify the parser to be used by ESLint.Default:
espree--parser-options
--parser-options
Specify parser options as key-value pairs.Format:
key:value pairsRules and Plugins
--plugin
--plugin
Specify plugins to load. You can optionally omit the
eslint-plugin- prefix.--rule
--rule
Fix Problems
--fix
--fix
Automatically fix problems. Fixes are made to the actual files.
--fix-dry-run
--fix-dry-run
Fix problems without saving changes to the file system.Useful for editor integrations that need to autofix text without saving.
--fix-type
--fix-type
Specify the types of fixes to apply.Options:
problem- fix potential errors in the codesuggestion- apply fixes that improve codelayout- apply fixes that don’t change the ASTdirective- apply fixes to inline directives
Ignore Files
--no-ignore
--no-ignore
Disables excluding files from
--ignore-pattern and the ignores configuration property.--ignore-pattern
--ignore-pattern
Specify patterns of files to ignore (uses minimatch syntax).
Quote your patterns to avoid shell interpretation of glob patterns.
Input/Output
--stdin
--stdin
Lint code provided on STDIN instead of from files.
--stdin-filename
--stdin-filename
Specify a filename to process STDIN as.Useful when processing files from STDIN and you have rules that depend on the filename.
--output-file, -o
--output-file, -o
Write the output to a specified file.
--format, -f
--format, -f
Specify the output format for the console.Built-in formatters:
stylish(default)jsonjson-with-metadatahtml
--color / --no-color
--color / --no-color
Force enabling or disabling of colorized output.
Handle Warnings
--quiet
--quiet
Report errors only - disables reporting on warnings.Only rules set to
error will be run; rules set to warn are disabled.--max-warnings
--max-warnings
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
--cache
--cache
Only check changed files. Dramatically improves performance by storing info about processed files.Default cache location:
.eslintcache--cache-location
--cache-location
Specify the path to the cache file or directory.
Add a trailing
/ on *nix systems or \ on Windows if specifying a directory.--cache-strategy
--cache-strategy
Strategy for detecting changed files in the cache.Options:
metadata(default) - uses file modification timecontent- uses file content hash
Miscellaneous
--init
--init
Run config initialization wizard.Runs
npm init @eslint/config to help create an eslint.config.js file.--debug
--debug
Output debugging information to the console.Useful when you’re seeing a problem and having a hard time pinpointing it.
--help, -h
--help, -h
Output the help menu.
--version, -v
--version, -v
Output the current ESLint version.
--print-config
--print-config
Output the configuration to be used for a file.No linting is performed when this flag is present.
--stats
--stats
Add detailed performance statistics to the lint results.Includes parse, fix, and lint times per rule.
--env-info
--env-info
Output execution environment information.Displays Node.js, npm, and ESLint version information.
--concurrency
--concurrency
Control the number of worker threads used to lint files.Options:
off(default) - lint in main threadauto- 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
- Basic
- With Fixing
- Performance
- CI/CD
Related Resources
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