Versions
Index

Command Line Interface Reference

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.

Run the CLI

ESLint requires Node.js for installation. Follow the instructions in the Getting Started Guide to install ESLint.

Most users use npx to run ESLint on the command line like this:

npm

npx eslint [options] [file|dir|glob]* 

yarn

yarn dlx eslint [options] [file|dir|glob]* 

pnpm

pnpm dlx eslint [options] [file|dir|glob]* 

bun

bunx eslint [options] [file|dir|glob]* 

Such as:

npm

# Run on two files
npx eslint file1.js file2.js 

yarn

# Run on two files
yarn dlx eslint file1.js file2.js 

pnpm

# Run on two files
pnpm dlx eslint file1.js file2.js 

bun

# Run on two files
bunx eslint file1.js file2.js 

or

npm

# Run on multiple files
npx eslint lib/** 

yarn

# Run on multiple files
yarn dlx eslint lib/** 

pnpm

# Run on multiple files
pnpm dlx eslint lib/** 

bun

# Run on multiple files
bunx eslint lib/** 

Please note that when passing a glob as a parameter, it is expanded by your shell. The results of the expansion can vary depending on your shell, and its configuration. If you want to use node glob syntax, you have to quote your parameter (using double quotes if you need it to run in Windows), as follows:

npm

npx eslint "lib/**" 

yarn

yarn dlx eslint "lib/**" 

pnpm

pnpm dlx eslint "lib/**" 

bun

bunx eslint "lib/**" 

You can also omit the file arguments and ESLint will use .. For instance, these two lines perform the same operation:

npm

npx eslint . 

yarn

yarn dlx eslint . 

pnpm

pnpm dlx eslint . 

bun

bunx eslint . 

npm

npx eslint 

yarn

yarn dlx eslint 

pnpm

pnpm dlx eslint 

bun

bunx eslint 

Note: You can also use alternative package managers such as Yarn or pnpm to run ESLint. For pnpm use pnpm dlx eslint and for Yarn use yarn dlx eslint.

Pass Multiple Values to an Option

Options that accept multiple values can be specified by repeating the option or with a comma-delimited list (other than --ignore-pattern, which does not allow the second style).

Examples of options that accept multiple values:

npm

npx eslint --global describe --global it tests/ 

yarn

yarn dlx eslint --global describe --global it tests/ 

pnpm

pnpm dlx eslint --global describe --global it tests/ 

bun

bunx eslint --global describe --global it tests/ 

OR

npm

npx eslint --global describe,it tests/ 

yarn

yarn dlx eslint --global describe,it tests/ 

pnpm

pnpm dlx eslint --global describe,it tests/ 

bun

bunx eslint --global describe,it tests/ 

Options

You can view all the CLI options by running npx eslint -h.

eslint [options] file.js [file.js] [dir]

Basic configuration:
  --no-config-lookup               Disable look up for eslint.config.*
  -c, --config path::String        Use this configuration instead of eslint.config.* look up
  --inspect-config                 Open the config inspector with the current configuration
  --ext [String]                   Specify additional file extensions to lint
  --global [String]                Define global variables
  --parser String                  Specify the parser to be used
  --parser-options Object          Specify parser options

Specify Rules and Plugins:
  --plugin [String]                Specify plugins
  --rule Object                    Specify rules

Fix Problems:
  --fix                            Automatically fix problems
  --fix-dry-run                    Automatically fix problems without saving the changes to the file system
  --fix-type Array                 Specify the types of fixes to apply (directive, problem, suggestion, layout)

Ignore Files:
  --no-ignore                      Disable use of ignore files and patterns
  --ignore-pattern [String]        Patterns of files to ignore

Use stdin:
  --stdin                          Lint code provided on <STDIN> - default: false
  --stdin-filename String          Specify filename to process STDIN as

Handle Warnings:
  --quiet                          Report errors only - default: false
  --max-warnings Int               Number of warnings to trigger nonzero exit code - default: -1

Output:
  -o, --output-file path::String   Specify file to write report to
  -f, --format String              Use a specific output format - default: stylish
  --color, --no-color              Force enabling/disabling of color

Inline configuration comments:
  --no-inline-config               Prevent comments from changing config or rules
  --report-unused-disable-directives  Adds reported errors for unused eslint-disable and eslint-enable directives
  --report-unused-disable-directives-severity String  Chooses severity level for reporting unused eslint-disable and eslint-enable directives - either: off, warn, error, 0, 1, or 2
  --report-unused-inline-configs String  Adds reported errors for unused eslint inline config comments - either: off, warn, error, 0, 1, or 2

Caching:
  --cache                          Only check changed files - default: false
  --cache-file path::String        Path to the cache file. Deprecated: use --cache-location - default: .eslintcache
  --cache-location path::String    Path to the cache file or directory
  --cache-strategy String          Strategy to use for detecting changed files in the cache - either: metadata or content - default: metadata

Suppressing Violations:
  --suppress-all                   Suppress all violations - default: false
  --suppress-rule [String]         Suppress specific rules
  --suppressions-location path::String  Specify the location of the suppressions file
  --prune-suppressions             Prune unused suppressions - default: false
  --pass-on-unpruned-suppressions  Ignore unused suppressions - default: false

Miscellaneous:
  --init                           Run config initialization wizard - default: false
  --env-info                       Output execution environment information - default: false
  --no-error-on-unmatched-pattern  Prevent errors when pattern is unmatched
  --exit-on-fatal-error            Exit with exit code 2 in case of fatal error - default: false
  --no-warn-ignored                Suppress warnings when the file list includes ignored files
  --pass-on-no-patterns            Exit with exit code 0 in case no file patterns are passed
  --debug                          Output debugging information
  -h, --help                       Show help
  -v, --version                    Output the version number
  --print-config path::String      Print the configuration for the given file
  --stats                          Add statistics to the lint report - default: false
  --flag [String]                  Enable a feature flag
  --mcp                            Start the ESLint MCP server
  --concurrency Int|String         Number of linting threads, auto to choose automatically, off for no multithreading - default: off

Basic Configuration

--no-config-lookup

Disables use of configuration from files.

  • Argument Type: No argument.
--no-config-lookup example

npm

npx eslint --no-config-lookup file.js 

yarn

yarn dlx eslint --no-config-lookup file.js 

pnpm

pnpm dlx eslint --no-config-lookup file.js 

bun

bunx eslint --no-config-lookup file.js 

-c, --config

This option allows you to specify an additional configuration file for ESLint (see Configure ESLint for more).

  • Argument Type: String. Path to file.
  • Multiple Arguments: No
-c, --config example

npm

npx eslint -c ~/my.eslint.config.js file.js 

yarn

yarn dlx eslint -c ~/my.eslint.config.js file.js 

pnpm

pnpm dlx eslint -c ~/my.eslint.config.js file.js 

bun

bunx eslint -c ~/my.eslint.config.js file.js 

This example uses the configuration file at ~/my.eslint.config.js, which is used instead of searching for an eslint.config.js file.

--inspect-config

This option runs npx @eslint/config-inspector@latest to start the config inspector. You can use the config inspector to better understand what your configuration is doing and which files it applies to. When you use this flag, the CLI does not perform linting.

  • Argument Type: No argument.
--inspect-config example

npm

npx eslint --inspect-config 

yarn

yarn dlx eslint --inspect-config 

pnpm

pnpm dlx eslint --inspect-config 

bun

bunx eslint --inspect-config 

--ext

This option allows you to specify additional file extensions to lint.

  • Argument Type: String. File extension.
  • Multiple Arguments: Yes
  • Default Value: By default, ESLint lints files with extensions .js, .mjs, .cjs, and additional extensions specified in the configuration file.

This option is primarily intended for use in combination with the --no-config-lookup option, since in that case there is no configuration file in which the additional extensions would be specified.

--ext example

npm

# Include .ts files
npx eslint . --ext .ts 

yarn

# Include .ts files
yarn dlx eslint . --ext .ts 

pnpm

# Include .ts files
pnpm dlx eslint . --ext .ts 

bun

# Include .ts files
bunx eslint . --ext .ts 

npm

# Include .ts and .tsx files
npx eslint . --ext .ts --ext .tsx 

yarn

# Include .ts and .tsx files
yarn dlx eslint . --ext .ts --ext .tsx 

pnpm

# Include .ts and .tsx files
pnpm dlx eslint . --ext .ts --ext .tsx 

bun

# Include .ts and .tsx files
bunx eslint . --ext .ts --ext .tsx 

npm

# Also include .ts and .tsx files
npx eslint . --ext .ts,.tsx 

yarn

# Also include .ts and .tsx files
yarn dlx eslint . --ext .ts,.tsx 

pnpm

# Also include .ts and .tsx files
pnpm dlx eslint . --ext .ts,.tsx 

bun

# Also include .ts and .tsx files
bunx eslint . --ext .ts,.tsx 

--global

This option defines global variables so that they are not flagged as undefined by the no-undef rule.

  • Argument Type: String. Name of the global variable. Any specified global variables are assumed to be read-only by default, but appending :true to a variable’s name ensures that no-undef also allows writes.
  • Multiple Arguments: Yes
--global example

npm

npx eslint --global require,exports:true file.js 

yarn

yarn dlx eslint --global require,exports:true file.js 

pnpm

pnpm dlx eslint --global require,exports:true file.js 

bun

bunx eslint --global require,exports:true file.js 

npm

npx eslint --global require --global exports:true 

yarn

yarn dlx eslint --global require --global exports:true 

pnpm

pnpm dlx eslint --global require --global exports:true 

bun

bunx eslint --global require --global exports:true 

--parser

This option allows you to specify a parser to be used by ESLint.

  • Argument Type: String. Parser to be used by ESLint.
  • Multiple Arguments: No
  • Default Value: espree
--parser example

npm

# Use TypeScript ESLint parser
npx eslint --parser @typescript-eslint/parser file.ts 

yarn

# Use TypeScript ESLint parser
yarn dlx eslint --parser @typescript-eslint/parser file.ts 

pnpm

# Use TypeScript ESLint parser
pnpm dlx eslint --parser @typescript-eslint/parser file.ts 

bun

# Use TypeScript ESLint parser
bunx eslint --parser @typescript-eslint/parser file.ts 

--parser-options

This option allows you to specify parser options to be used by ESLint. The available parser options are determined by the parser being used.

  • Argument Type: Key/value pair separated by colon (:).
  • Multiple Arguments: Yes
--parser-options example

npm

# fails with a parsing error
echo '3 ** 4' | npx eslint --stdin --parser-options ecmaVersion:6 

yarn

# fails with a parsing error
echo '3 ** 4' | yarn dlx eslint --stdin --parser-options ecmaVersion:6 

pnpm

# fails with a parsing error
echo '3 ** 4' | pnpm dlx eslint --stdin --parser-options ecmaVersion:6 

bun

# fails with a parsing error
echo '3 ** 4' | bunx eslint --stdin --parser-options ecmaVersion:6 

npm

# succeeds, yay!
echo '3 ** 4' | npx eslint --stdin --parser-options ecmaVersion:7 

yarn

# succeeds, yay!
echo '3 ** 4' | yarn dlx eslint --stdin --parser-options ecmaVersion:7 

pnpm

# succeeds, yay!
echo '3 ** 4' | pnpm dlx eslint --stdin --parser-options ecmaVersion:7 

bun

# succeeds, yay!
echo '3 ** 4' | bunx eslint --stdin --parser-options ecmaVersion:7 

Specify Rules and Plugins

--plugin

This option specifies a plugin to load.

  • Argument Type: String. Plugin name. You can optionally omit the prefix eslint-plugin- from the plugin name.
  • Multiple Arguments: Yes

Before using the plugin, you have to install it using npm.

--plugin example

npm

npx eslint --plugin jquery file.js 

yarn

yarn dlx eslint --plugin jquery file.js 

pnpm

pnpm dlx eslint --plugin jquery file.js 

bun

bunx eslint --plugin jquery file.js 

npm

npx eslint --plugin eslint-plugin-mocha file.js 

yarn

yarn dlx eslint --plugin eslint-plugin-mocha file.js 

pnpm

pnpm dlx eslint --plugin eslint-plugin-mocha file.js 

bun

bunx eslint --plugin eslint-plugin-mocha file.js 

--rule

This option specifies the rules to be used.

  • Argument Type: Rules and their configuration specified with levn format.
  • Multiple Arguments: Yes

These rules are merged with any rules specified with configuration files. If the rule is defined in a plugin, you have to prefix the rule ID with the plugin name and a /.

To ignore rules in configuration files and only run rules specified in the command line, use the --rule flag in combination with the --no-config-lookup flag.

--rule example

npm

# Apply single rule
npx eslint --rule 'quotes: [error, double]' 

yarn

# Apply single rule
yarn dlx eslint --rule 'quotes: [error, double]' 

pnpm

# Apply single rule
pnpm dlx eslint --rule 'quotes: [error, double]' 

bun

# Apply single rule
bunx eslint --rule 'quotes: [error, double]' 

npm

# Apply multiple rules
npx eslint --rule 'guard-for-in: error' --rule 'brace-style: [error, 1tbs]' 

yarn

# Apply multiple rules
yarn dlx eslint --rule 'guard-for-in: error' --rule 'brace-style: [error, 1tbs]' 

pnpm

# Apply multiple rules
pnpm dlx eslint --rule 'guard-for-in: error' --rule 'brace-style: [error, 1tbs]' 

bun

# Apply multiple rules
bunx eslint --rule 'guard-for-in: error' --rule 'brace-style: [error, 1tbs]' 

npm

# Apply rule from jquery plugin
npx eslint --rule 'jquery/dollar-sign: error' 

yarn

# Apply rule from jquery plugin
yarn dlx eslint --rule 'jquery/dollar-sign: error' 

pnpm

# Apply rule from jquery plugin
pnpm dlx eslint --rule 'jquery/dollar-sign: error' 

bun

# Apply rule from jquery plugin
bunx eslint --rule 'jquery/dollar-sign: error' 

npm

# Only apply rule from the command line
npx eslint --rule 'quotes: [error, double]' --no-config-lookup 

yarn

# Only apply rule from the command line
yarn dlx eslint --rule 'quotes: [error, double]' --no-config-lookup 

pnpm

# Only apply rule from the command line
pnpm dlx eslint --rule 'quotes: [error, double]' --no-config-lookup 

bun

# Only apply rule from the command line
bunx eslint --rule 'quotes: [error, double]' --no-config-lookup 

Fix Problems

--fix

This option instructs ESLint to try to fix as many issues as possible. The fixes are made to the actual files themselves and only the remaining unfixed issues are output.

  • Argument Type: No argument.

Not all problems are fixable using this option, and the option does not work in these situations:

  1. This option throws an error when code is piped to ESLint.
  2. This option has no effect on code that uses a processor, unless the processor opts into allowing autofixes.

If you want to fix code from stdin or otherwise want to get the fixes without actually writing them to the file, use the --fix-dry-run option.

--fix example

npm

npx eslint --fix file.js 

yarn

yarn dlx eslint --fix file.js 

pnpm

pnpm dlx eslint --fix file.js 

bun

bunx eslint --fix file.js 

--fix-dry-run

This option has the same effect as --fix with the difference that the fixes are not saved to the file system. Because the default formatter does not output the fixed code, you’ll have to use another formatter (e.g. --format json) to get the fixes.

  • Argument Type: No argument.

This makes it possible to fix code from stdin when used with the --stdin flag.

This flag can be useful for integrations (e.g. editor plugins) which need to autofix text from the command line without saving it to the filesystem.

--fix-dry-run example

npm

getSomeText | npx eslint --stdin --fix-dry-run --format json 

yarn

getSomeText | yarn dlx eslint --stdin --fix-dry-run --format json 

pnpm

getSomeText | pnpm dlx eslint --stdin --fix-dry-run --format json 

bun

getSomeText | bunx eslint --stdin --fix-dry-run --format json 

--fix-type

This option allows you to specify the type of fixes to apply when using either --fix or --fix-dry-run.

  • Argument Type: String. One of the following fix types:
    1. problem - fix potential errors in the code
    2. suggestion - apply fixes to the code that improve it
    3. layout - apply fixes that do not change the program structure (AST)
    4. directive - apply fixes to inline directives such as // eslint-disable
  • Multiple Arguments: Yes

This option is helpful if you are using another program to format your code, but you would still like ESLint to apply other types of fixes.

--fix-type example

npm

npx eslint --fix --fix-type suggestion . 

yarn

yarn dlx eslint --fix --fix-type suggestion . 

pnpm

pnpm dlx eslint --fix --fix-type suggestion . 

bun

bunx eslint --fix --fix-type suggestion . 

npm

npx eslint --fix --fix-type suggestion --fix-type problem . 

yarn

yarn dlx eslint --fix --fix-type suggestion --fix-type problem . 

pnpm

pnpm dlx eslint --fix --fix-type suggestion --fix-type problem . 

bun

bunx eslint --fix --fix-type suggestion --fix-type problem . 

npm

npx eslint --fix --fix-type suggestion,layout . 

yarn

yarn dlx eslint --fix --fix-type suggestion,layout . 

pnpm

pnpm dlx eslint --fix --fix-type suggestion,layout . 

bun

bunx eslint --fix --fix-type suggestion,layout . 

Ignore Files

--no-ignore

Disables excluding of files from --ignore-pattern flags and the ignores property in configuration.

  • Argument Type: No argument.
--no-ignore example

npm

npx eslint --no-ignore file.js 

yarn

yarn dlx eslint --no-ignore file.js 

pnpm

pnpm dlx eslint --no-ignore file.js 

bun

bunx eslint --no-ignore file.js 

--ignore-pattern

This option allows you to specify patterns of files to ignore.

  • Argument Type: String. The supported syntax is the same as for ignores patterns, which use minimatch syntax. You should quote your patterns in order to avoid shell interpretation of glob patterns.
  • Multiple Arguments: Yes
--ignore-pattern example

npm

npx eslint --ignore-pattern "/lib/" --ignore-pattern "/src/vendor/*" . 

yarn

yarn dlx eslint --ignore-pattern "/lib/" --ignore-pattern "/src/vendor/*" . 

pnpm

pnpm dlx eslint --ignore-pattern "/lib/" --ignore-pattern "/src/vendor/*" . 

bun

bunx eslint --ignore-pattern "/lib/" --ignore-pattern "/src/vendor/*" . 

Use stdin

--stdin

This option tells ESLint to read and lint source code from STDIN instead of from files. You can use this to pipe code to ESLint.

  • Argument Type: No argument.
--stdin example

npm

cat myFile.js | npx eslint --stdin 

yarn

cat myFile.js | yarn dlx eslint --stdin 

pnpm

cat myFile.js | pnpm dlx eslint --stdin 

bun

cat myFile.js | bunx eslint --stdin 

--stdin-filename

This option allows you to specify a filename to process STDIN as.

  • Argument Type: String. Path to file.
  • Multiple Arguments: No

This is useful when processing files from STDIN and you have rules which depend on the filename.

--stdin-filename example

npm

cat myFile.js | npx eslint --stdin --stdin-filename myfile.js 

yarn

cat myFile.js | yarn dlx eslint --stdin --stdin-filename myfile.js 

pnpm

cat myFile.js | pnpm dlx eslint --stdin --stdin-filename myfile.js 

bun

cat myFile.js | bunx eslint --stdin --stdin-filename myfile.js 

Handle Warnings

--quiet

This option allows you to disable reporting on warnings and running of rules set to warn. If you enable this option, only errors are reported by ESLint and only rules set to error will be run.

  • Argument Type: No argument.
--quiet example

npm

npx eslint --quiet file.js 

yarn

yarn dlx eslint --quiet file.js 

pnpm

pnpm dlx eslint --quiet file.js 

bun

bunx eslint --quiet file.js 

--max-warnings

This option allows you to specify a warning threshold, which can be used to force ESLint to exit with an error status if there are too many warning-level rule violations in your project.

  • Argument Type: Integer. The maximum number of warnings to allow. To prevent this behavior, do not use this option or specify -1 as the argument.
  • Multiple Arguments: No

Normally, if ESLint runs and finds no errors (only warnings), it exits with a success exit status. However, if --max-warnings is specified and the total warning count is greater than the specified threshold, ESLint exits with an error status.

--max-warnings example

npm

npx eslint --max-warnings 10 file.js 

yarn

yarn dlx eslint --max-warnings 10 file.js 

pnpm

pnpm dlx eslint --max-warnings 10 file.js 

bun

bunx eslint --max-warnings 10 file.js 

Output

-o, --output-file

Write the output of linting results to a specified file.

  • Argument Type: String. Path to file.
  • Multiple Arguments: No
-o, --output-file example

npm

npx eslint -o ./test/test.html 

yarn

yarn dlx eslint -o ./test/test.html 

pnpm

pnpm dlx eslint -o ./test/test.html 

bun

bunx eslint -o ./test/test.html 

-f, --format

This option specifies the output format for the console.

If you are using a custom formatter defined in a local file, you can specify the path to the custom formatter file.

An npm-installed formatter is resolved with or without eslint-formatter- prefix.

When specified, the given format is output to the console. If you’d like to save that output into a file, you can do so on the command line like so:

npm

# Saves the output into the `results.json` file.
npx eslint -f json file.js > results.json 

yarn

# Saves the output into the `results.json` file.
yarn dlx eslint -f json file.js > results.json 

pnpm

# Saves the output into the `results.json` file.
pnpm dlx eslint -f json file.js > results.json 

bun

# Saves the output into the `results.json` file.
bunx eslint -f json file.js > results.json 
-f, --format example

Use the built-in json formatter: