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 CLIESLint 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:
yarnnpx eslint [options] [file|dir|glob]*
1
pnpmyarn dlx eslint [options] [file|dir|glob]*
1
bunpnpm dlx eslint [options] [file|dir|glob]*
1
bunx eslint [options] [file|dir|glob]*
1
Such as:
npmyarnnpx eslint file1.js file2.js
1
2
pnpmyarn dlx eslint file1.js file2.js
1
2
bunpnpm dlx eslint file1.js file2.js
1
2
bunx eslint file1.js file2.js
1
2
or
yarnpnpmyarn dlx eslint lib/**
1
2
pnpm dlx eslint lib/**
1
2
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:
pnpmyarn dlx eslint "lib/**"
1
pnpm dlx eslint "lib/**"
1
If you are using a flat configuration file (eslint.config.js
), you can also omit the file arguments and ESLint will use .
. For instance, these two lines perform the same operation:
If you are not using a flat configuration file, running ESLint without file arguments results in an error.
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
.
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:
npmyarnnpx eslint --global describe --global it tests/
1
pnpmyarn dlx eslint --global describe --global it tests/
1
bunpnpm dlx eslint --global describe --global it tests/
1
bunx eslint --global describe --global it tests/
1
OR
npmyarnnpx eslint --global describe,it tests/
1
pnpmyarn dlx eslint --global describe,it tests/
1
bunpnpm dlx eslint --global describe,it tests/
1
Optionsbunx eslint --global describe,it tests/
1
You can view all the CLI options by running npx eslint -h
.
Basic Configurationeslint [options] file.js [file.js] [dir] Basic configuration: --no-config-lookup Disable look up for eslint.config.js -c, --config path::String Use this configuration instead of eslint.config.js, eslint.config.mjs, or eslint.config.cjs --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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
--no-eslintrc
eslintrc Mode Only. Disables use of configuration from .eslintrc.*
and package.json
files. For flat config mode, use --no-config-lookup
instead.
--no-eslintrc
example npm
yarnnpx eslint --no-eslintrc file.js
1
pnpmyarn dlx eslint --no-eslintrc file.js
1
bunpnpm dlx eslint --no-eslintrc file.js
1
bunx eslint --no-eslintrc file.js
1
-c
, --config
This option allows you to specify an additional configuration file for ESLint (see Configure ESLint for more).
-c
, --config
example npm
yarnnpx eslint -c ~/my.eslint.config.js file.js
1
pnpmyarn dlx eslint -c ~/my.eslint.config.js file.js
1
bunpnpm dlx eslint -c ~/my.eslint.config.js file.js
1
bunx eslint -c ~/my.eslint.config.js file.js
1
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
Flat Config Mode Only. 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.
--inspect-config
example npm
yarnnpx eslint --inspect-config
1
pnpmyarn dlx eslint --inspect-config
1
bunpnpm dlx eslint --inspect-config
1
bunx eslint --inspect-config
1
--env
eslintrc Mode Only. This option enables specific environments.
Details about the global variables defined by each environment are available in the Specifying Environments documentation. This option only enables environments. It does not disable environments set in other configuration files. To specify multiple environments, separate them using commas, or use the option multiple times.
--env
example npm
yarnnpx eslint --env browser,node file.js
1
pnpmyarn dlx eslint --env browser,node file.js
1
bunpnpm dlx eslint --env browser,node file.js
1
npmbunx eslint --env browser,node file.js
1
yarnnpx eslint --env browser --env node file.js
1
pnpmyarn dlx eslint --env browser --env node file.js
1
bunpnpm dlx eslint --env browser --env node file.js
1
bunx eslint --env browser --env node file.js
1
--ext
This option allows you to specify additional file extensions to lint.
.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
yarnnpx eslint . --ext .ts
1
2
pnpmyarn dlx eslint . --ext .ts
1
2
bunpnpm dlx eslint . --ext .ts
1
2
npmbunx eslint . --ext .ts
1
2
yarnnpx eslint . --ext .ts --ext .tsx
1
2
pnpmyarn dlx eslint . --ext .ts --ext .tsx
1
2
bunpnpm dlx eslint . --ext .ts --ext .tsx
1
2
npmbunx eslint . --ext .ts --ext .tsx
1
2
yarnnpx eslint . --ext .ts,.tsx
1
2
pnpmyarn dlx eslint . --ext .ts,.tsx
1
2
bunpnpm dlx eslint . --ext .ts,.tsx
1
2
bunx eslint . --ext .ts,.tsx
1
2
--global
This option defines global variables so that they are not flagged as undefined by the no-undef
rule.
:true
to a variable’s name ensures that no-undef
also allows writes.--global
example npm
yarnnpx eslint --global require,exports:true file.js
1
pnpmyarn dlx eslint --global require,exports:true file.js
1
bunpnpm dlx eslint --global require,exports:true file.js
1
npmbunx eslint --global require,exports:true file.js
1
yarnnpx eslint --global require --global exports:true
1
pnpmyarn dlx eslint --global require --global exports:true
1
bunpnpm dlx eslint --global require --global exports:true
1
bunx eslint --global require --global exports:true
1
--parser
This option allows you to specify a parser to be used by ESLint.
espree
--parser
example npm
yarnnpx eslint --parser @typescript-eslint/parser file.ts
1
2
pnpmyarn dlx eslint --parser @typescript-eslint/parser file.ts
1
2
bunpnpm dlx eslint --parser @typescript-eslint/parser file.ts
1
2
bunx eslint --parser @typescript-eslint/parser file.ts
1
2
--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.
:
).--parser-options
example npm
yarnecho '3 ** 4' | npx eslint --stdin --parser-options ecmaVersion:6
1
2
pnpmecho '3 ** 4' | yarn dlx eslint --stdin --parser-options ecmaVersion:6
1
2
bunecho '3 ** 4' | pnpm dlx eslint --stdin --parser-options ecmaVersion:6
1
2
npmecho '3 ** 4' | bunx eslint --stdin --parser-options ecmaVersion:6
1
2
yarnecho '3 ** 4' | npx eslint --stdin --parser-options ecmaVersion:7
1
2
pnpmecho '3 ** 4' | yarn dlx eslint --stdin --parser-options ecmaVersion:7
1
2
bunecho '3 ** 4' | pnpm dlx eslint --stdin --parser-options ecmaVersion:7
1
2
echo '3 ** 4' | bunx eslint --stdin --parser-options ecmaVersion:7
1
2
--resolve-plugins-relative-to
eslintrc Mode Only. Changes the directory where plugins are resolved from.
This option should be used when plugins were installed by someone other than the end user. It should be set to the project directory of the project that has a dependency on the necessary plugins.
For example:
--config
flag), if the config uses plugins which are installed locally to itself, --resolve-plugins-relative-to
should be set to the directory containing the config file.--resolve-plugins-relative-to
to the top-level directory of the tool.--resolve-plugins-relative-to
example npm
yarnnpx eslint --config ~/personal-eslintrc.js --resolve-plugins-relative-to /usr/local/lib/
1
pnpmyarn dlx eslint --config ~/personal-eslintrc.js --resolve-plugins-relative-to /usr/local/lib/
1
bunpnpm dlx eslint --config ~/personal-eslintrc.js --resolve-plugins-relative-to /usr/local/lib/
1
Specify Rules and Pluginsbunx eslint --config ~/personal-eslintrc.js --resolve-plugins-relative-to /usr/local/lib/
1
--plugin
This option specifies a plugin to load.
eslint-plugin-
from the plugin name.Before using the plugin, you have to install it using npm.
--plugin
example npm
yarnnpx eslint --plugin jquery file.js
1
pnpmyarn dlx eslint --plugin jquery file.js
1
bunpnpm dlx eslint --plugin jquery file.js
1
npmbunx eslint --plugin jquery file.js
1
yarnnpx eslint --plugin eslint-plugin-mocha file.js
1
pnpmyarn dlx eslint --plugin eslint-plugin-mocha file.js
1
bunpnpm dlx eslint --plugin eslint-plugin-mocha file.js
1
bunx eslint --plugin eslint-plugin-mocha file.js
1
--rule
This option specifies the rules to be used.
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 .eslintrc
configuration files and only run rules specified in the command line, use the --rule
flag in combination with the --no-eslintrc
flag.
--rule
example npm
yarnnpx eslint --rule 'quotes: [error, double]'
1
2
pnpmyarn dlx eslint --rule 'quotes: [error, double]'
1
2
bunpnpm dlx eslint --rule 'quotes: [error, double]'
1
2
npmbunx eslint --rule 'quotes: [error, double]'
1
2
yarnnpx eslint --rule 'guard-for-in: error' --rule 'brace-style: [error, 1tbs]'
1
2
pnpmyarn dlx eslint --rule 'guard-for-in: error' --rule 'brace-style: [error, 1tbs]'
1
2
bunpnpm dlx eslint --rule 'guard-for-in: error' --rule 'brace-style: [error, 1tbs]'
1
2
npmbunx eslint --rule 'guard-for-in: error' --rule 'brace-style: [error, 1tbs]'
1
2
yarnnpx eslint --rule 'jquery/dollar-sign: error'
1
2
pnpmyarn dlx eslint --rule 'jquery/dollar-sign: error'
1
2
bunpnpm dlx eslint --rule 'jquery/dollar-sign: error'
1
2
npmbunx eslint --rule 'jquery/dollar-sign: error'
1
2
yarnnpx eslint --rule 'quotes: [error, double]' --no-eslintrc
1
2
pnpmyarn dlx eslint --rule 'quotes: [error, double]' --no-eslintrc
1
2
bunpnpm dlx eslint --rule 'quotes: [error, double]' --no-eslintrc
1
2
bunx eslint --rule 'quotes: [error, double]' --no-eslintrc
1
2
--rulesdir
Deprecated: Use rules from plugins instead.
eslintrc Mode Only. This option allows you to specify another directory from which to load rules files. This allows you to dynamically load new rules at run time. This is useful when you have custom rules that aren’t suitable for being bundled with ESLint.
Note that, as with core rules and plugin rules, you still need to enable the rules in configuration or via the --rule
CLI option in order to actually run those rules during linting. Specifying a rules directory with --rulesdir
does not automatically enable the rules within that directory.
--rulesdir
example npm
yarnnpx eslint --rulesdir my-rules/ file.js
1
pnpmyarn dlx eslint --rulesdir my-rules/ file.js
1
bunpnpm dlx eslint --rulesdir my-rules/ file.js
1
npmbunx eslint --rulesdir my-rules/ file.js
1
yarnnpx eslint --rulesdir my-rules/ --rulesdir my-other-rules/ file.js
1
pnpmyarn dlx eslint --rulesdir my-rules/ --rulesdir my-other-rules/ file.js
1
bunpnpm dlx eslint --rulesdir my-rules/ --rulesdir my-other-rules/ file.js
1
Fix Problemsbunx eslint --rulesdir my-rules/ --rulesdir my-other-rules/ file.js
1
--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.
Not all problems are fixable using this option, and the option does not work in these situations:
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
yarnnpx eslint --fix file.js
1
pnpmyarn dlx eslint --fix file.js
1
bunpnpm dlx eslint --fix file.js
1
bunx eslint --fix file.js
1
--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.
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
yarngetSomeText | npx eslint --stdin --fix-dry-run --format json
1
pnpmgetSomeText | yarn dlx eslint --stdin --fix-dry-run --format json
1
bungetSomeText | pnpm dlx eslint --stdin --fix-dry-run --format json
1
getSomeText | bunx eslint --stdin --fix-dry-run --format json
1
--fix-type
This option allows you to specify the type of fixes to apply when using either --fix
or --fix-dry-run
.
problem
- fix potential errors in the codesuggestion
- apply fixes to the code that improve itlayout
- apply fixes that do not change the program structure (AST)directive
- apply fixes to inline directives such as // eslint-disable
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
yarnnpx eslint --fix --fix-type suggestion .
1
pnpmyarn dlx eslint --fix --fix-type suggestion .
1
bunpnpm dlx eslint --fix --fix-type suggestion .
1
npmbunx eslint --fix --fix-type suggestion .
1
yarnnpx eslint --fix --fix-type suggestion --fix-type problem .
1
pnpmyarn dlx eslint --fix --fix-type suggestion --fix-type problem .
1
bunpnpm dlx eslint --fix --fix-type suggestion --fix-type problem .
1
npmbunx eslint --fix --fix-type suggestion --fix-type problem .
1
yarnnpx eslint --fix --fix-type suggestion,layout .
1
pnpmyarn dlx eslint --fix --fix-type suggestion,layout .
1
bunpnpm dlx eslint --fix --fix-type suggestion,layout .
1
Ignore Filesbunx eslint --fix --fix-type suggestion,layout .
1
--ignore-path
eslintrc Mode Only. This option allows you to specify the file to use as your .eslintignore
.
.eslintignore
in the current working directory.Note: --ignore-path
is only supported when using deprecated configuration. If you want to include patterns from a .gitignore
file in your eslint.config.js
file, please see including .gitignore
files.
--ignore-path
example npm
yarnnpx eslint --ignore-path tmp/.eslintignore file.js
1
pnpmyarn dlx eslint --ignore-path tmp/.eslintignore file.js
1
bunpnpm dlx eslint --ignore-path tmp/.eslintignore file.js
1
npmbunx eslint --ignore-path tmp/.eslintignore file.js
1
yarnnpx eslint --ignore-path .gitignore file.js
1
pnpmyarn dlx eslint --ignore-path .gitignore file.js
1
bunpnpm dlx eslint --ignore-path .gitignore file.js
1
bunx eslint --ignore-path .gitignore file.js
1
--no-ignore
Disables excluding of files from .eslintignore
files, --ignore-path
flags, --ignore-pattern
flags, and the ignorePatterns
property in config files.
--no-ignore
example npm
yarnnpx eslint --no-ignore file.js
1
pnpmyarn dlx eslint --no-ignore file.js
1
bunpnpm dlx eslint --no-ignore file.js
1
bunx eslint --no-ignore file.js
1
--ignore-pattern
This option allows you to specify patterns of files to ignore. In eslintrc mode, these are in addition to .eslintignore
.
.eslintignore
files, which use the same patterns as the .gitignore
specification. You should quote your patterns in order to avoid shell interpretation of glob patterns.--ignore-pattern
example npm
yarnnpx eslint --ignore-pattern "/lib/" --ignore-pattern "/src/vendor/*" .
1
pnpmyarn dlx eslint --ignore-pattern "/lib/" --ignore-pattern "/src/vendor/*" .
1
bunpnpm dlx eslint --ignore-pattern "/lib/" --ignore-pattern "/src/vendor/*" .
1
Use stdinbunx eslint --ignore-pattern "/lib/" --ignore-pattern "/src/vendor/*" .
1
--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.
--stdin
example npm
yarncat myFile.js | npx eslint --stdin
1
pnpmcat myFile.js | yarn dlx eslint --stdin
1
buncat myFile.js | pnpm dlx eslint --stdin
1
cat myFile.js | bunx eslint --stdin
1
--stdin-filename
This option allows you to specify a filename to process STDIN as.
This is useful when processing files from STDIN and you have rules which depend on the filename.
--stdin-filename
example npm
yarncat myFile.js | npx eslint --stdin --stdin-filename myfile.js
1
pnpmcat myFile.js | yarn dlx eslint --stdin --stdin-filename myfile.js
1
buncat myFile.js | pnpm dlx eslint --stdin --stdin-filename myfile.js
1
Handle Warningscat myFile.js | bunx eslint --stdin --stdin-filename myfile.js
1
--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.
--quiet
example npm
yarnnpx eslint --quiet file.js
1
pnpmyarn dlx eslint --quiet file.js
1
bunpnpm dlx eslint --quiet file.js
1
bunx eslint --quiet file.js
1
--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.
-1
as the argument.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.
When used alongside --quiet
, this will cause rules marked as warn to still be run, but not reported.
--max-warnings
example npm
yarnnpx eslint --max-warnings 10 file.js
1
pnpmyarn dlx eslint --max-warnings 10 file.js
1
bunpnpm dlx eslint --max-warnings 10 file.js
1
Outputbunx eslint --max-warnings 10 file.js
1
-o
, --output-file
Write the output of linting results to a specified file.
-o
, --output-file
example npm
yarnnpx eslint -o ./test/test.html
1
pnpmyarn dlx eslint -o ./test/test.html
1
bunpnpm dlx eslint -o ./test/test.html
1
bunx eslint -o ./test/test.html
1
-f
, --format
This option specifies the output format for the console.
stylish
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:
npmyarnnpx eslint -f json file.js > results.json
1
2
pnpmyarn dlx eslint -f json file.js > results.json
1
2
bunpnpm dlx eslint -f json file.js > results.json
1
2
bunx eslint -f json file.js > results.json
1
2
-f
, --format
example
Use the built-in json
formatter:
yarnnpx eslint --format json file.js
1
pnpmyarn dlx eslint --format json file.js
1
bunpnpm dlx eslint --format json file.js
1
bunx eslint --format json file.js
1
Use a local custom formatter:
npmyarnnpx eslint -f ./customformat.js file.js
1
pnpmyarn dlx eslint -f ./customformat.js file.js
1
bunpnpm dlx eslint -f ./customformat.js file.js
1
bunx eslint -f ./customformat.js file.js
1
Use an npm-installed formatter:
npmyarnnpm install eslint-formatter-pretty
1
pnpmyarn add eslint-formatter-pretty
1
bunpnpm add eslint-formatter-pretty
1
bun add eslint-formatter-pretty
1
Then run one of the following commands
npmyarnnpx eslint -f pretty file.js
1
pnpmyarn dlx eslint -f pretty file.js
1
bunpnpm dlx eslint -f pretty file.js
1
bunx eslint -f pretty file.js
1
or alternatively
npmyarnnpx eslint -f eslint-formatter-pretty file.js
1
pnpmyarn dlx eslint -f eslint-formatter-pretty file.js
1
bunpnpm dlx eslint -f eslint-formatter-pretty file.js
1
bunx eslint -f eslint-formatter-pretty file.js
1
--color
and --no-color
These options force the enabling/disabling of colorized output.
You can use these options to override the default behavior, which is to enable colorized output unless no TTY is detected, such as when piping eslint
through cat
or less
.
--color
and --no-color
example npm
yarnnpx eslint --color file.js | cat
1
pnpmyarn dlx eslint --color file.js | cat
1
bunpnpm dlx eslint --color file.js | cat
1
npmbunx eslint --color file.js | cat
1
yarnnpx eslint --no-color file.js
1
pnpmyarn dlx eslint --no-color file.js
1
bunpnpm dlx eslint --no-color file.js
1
bunx eslint --no-color file.js
1
--no-inline-config
This option prevents inline comments like /*eslint-disable*/
or /*global foo*/
from having any effect.
This allows you to set an ESLint config without files modifying it. All inline config comments are ignored, such as:
/*eslint-disable*/
/*eslint-enable*/
/*global*/
/*eslint*/
/*eslint-env*/
// eslint-disable-line
// eslint-disable-next-line
--no-inline-config
example npm
yarnnpx eslint --no-inline-config file.js
1
pnpmyarn dlx eslint --no-inline-config file.js
1
bunpnpm dlx eslint --no-inline-config file.js
1
bunx eslint --no-inline-config file.js
1
--report-unused-disable-directives
This option causes ESLint to report directive comments like // eslint-disable-line
when no errors would have been reported on that line anyway.
This can be useful to prevent future errors from unexpectedly being suppressed, by cleaning up old eslint-disable
and eslint-enable
comments which are no longer applicable.
When using this option, it is possible that new errors start being reported whenever ESLint or custom rules are upgraded.
For example, suppose a rule has a bug that causes it to report a false positive, and an eslint-disable
comment is added to suppress the incorrect report. If the bug is then fixed in a patch release of ESLint, the eslint-disable
comment becomes unused since ESLint is no longer generating an incorrect report. This results in a new reported error for the unused directive if the --report-unused-disable-directives
option is used.
--report-unused-disable-directives
example npm
yarnnpx eslint --report-unused-disable-directives file.js
1
pnpmyarn dlx eslint --report-unused-disable-directives file.js
1
bunpnpm dlx eslint --report-unused-disable-directives file.js
1
bunx eslint --report-unused-disable-directives file.js
1
--report-unused-disable-directives-severity
Same as --report-unused-disable-directives
, but allows you to specify the severity level (error
, warn
, off
) of the reported errors. Only one of these two options can be used at a time.
off
(or 0
)warn
(or 1
)error
(or 2
)linterOptions.reportUnusedDisableDirectives
configuration setting is used (which defaults to "warn"
).--report-unused-disable-directives-severity
example npm
yarnnpx eslint --report-unused-disable-directives-severity warn file.js
1
pnpmyarn dlx eslint --report-unused-disable-directives-severity warn file.js
1
bunpnpm dlx eslint --report-unused-disable-directives-severity warn file.js
1
bunx eslint --report-unused-disable-directives-severity warn file.js
1
--report-unused-inline-configs
This option causes ESLint to report inline config comments like /* eslint rule-name: "error" */
whose rule severity and any options match what’s already been configured.
off
(or 0
)warn
(or 1
)error
(or 2
)linterOptions.reportUnusedInlineConfigs
configuration setting is used (which defaults to "off"
).This can be useful to keep files clean and devoid of misleading clutter. Inline config comments are meant to change ESLint’s behavior in some way: if they change nothing, there is no reason to leave them in.
--report-unused-inline-configs
example
Cachingnpx eslint --report-unused-inline-configs error file.js
1
--cache
Store the info about processed files in order to only operate on the changed ones. Enabling this option can dramatically improve ESLint’s run time performance by ensuring that only changed files are linted. The cache is stored in .eslintcache
by default.
If you run ESLint with --cache
and then run ESLint without --cache
, the .eslintcache
file will be deleted. This is necessary because the results of the lint might change and make .eslintcache
invalid. If you want to control when the cache file is deleted, then use --cache-location
to specify an alternate location for the cache file.
Autofixed files are not placed in the cache. Subsequent linting that does not trigger an autofix will place it in the cache.
--cache
example npm
yarnnpx eslint --cache file.js
1
pnpmyarn dlx eslint --cache file.js
1
bunpnpm dlx eslint --cache file.js
1
bunx eslint --cache file.js
1
--cache-file
Deprecated: Use --cache-location
instead.
Path to the cache file. If none specified .eslintcache
is used. The file is created in the directory where the eslint
command is executed.
--cache-location
Specify the path to the cache location. Can be a file or a directory.
.cache_hashOfCWD
..eslintcache
is used. The file is created in the directory where the eslint
command is executed.If the directory for the cache does not exist make sure you add a trailing /
on *nix systems or \
on Windows. Otherwise, the path is assumed to be a file.
--cache-location
example npm
yarnnpx eslint "src/**/*.js" --cache --cache-location "/Users/user/.eslintcache/"
1
pnpmyarn dlx eslint "src/**/*.js" --cache --cache-location "/Users/user/.eslintcache/"
1
bunpnpm dlx eslint "src/**/*.js" --cache --cache-location "/Users/user/.eslintcache/"
1
bunx eslint "src/**/*.js" --cache --cache-location "/Users/user/.eslintcache/"
1
--cache-strategy
Strategy for the cache to use for detecting changed files.
metadata
content
metadata
The content
strategy can be useful in cases where the modification time of your files changes even if their contents have not. For example, this can happen during git operations like git clone
because git does not track file modification time.
--cache-strategy
example npm
yarnnpx eslint "src/**/*.js" --cache --cache-strategy content
1
pnpmyarn dlx eslint "src/**/*.js" --cache --cache-strategy content
1
bunpnpm dlx eslint "src/**/*.js" --cache --cache-strategy content
1
Suppressing Violationsbunx eslint "src/**/*.js" --cache --cache-strategy content
1
--suppress-all
Suppresses existing violations, so that they are not being reported in subsequent runs. It allows you to enable one or more lint rules and be notified only when new violations show up. The suppressions are stored in eslint-suppressions.json
by default, unless otherwise specified by --suppressions-location
. The file gets updated with the new suppressions.
--suppress-all
example npm
yarnnpx eslint "src/**/*.js" --suppress-all
1
pnpmyarn dlx eslint "src/**/*.js" --suppress-all
1
bunpnpm dlx eslint "src/**/*.js" --suppress-all
1
bunx eslint "src/**/*.js" --suppress-all
1
--suppress-rule
Suppresses violations for specific rules, so that they are not being reported in subsequent runs. Similar to --suppress-all
, the suppressions are stored in eslint-suppressions.json
by default, unless otherwise specified by --suppressions-location
. The file gets updated with the new suppressions.
--suppress-rule
example npm
yarnnpx eslint "src/**/*.js" --suppress-rule no-console --suppress-rule indent
1
pnpmyarn dlx eslint "src/**/*.js" --suppress-rule no-console --suppress-rule indent
1
bunpnpm dlx eslint "src/**/*.js" --suppress-rule no-console --suppress-rule indent
1
bunx eslint "src/**/*.js" --suppress-rule no-console --suppress-rule indent
1
--suppressions-location
Specify the path to the suppressions location. Can be a file or a directory.
suppressions_hashOfCWD
eslint-suppressions.json
is used. The file is created in the directory where the eslint
command is executed.--suppressions-location
example npm
yarnnpx eslint "src/**/*.js" --suppressions-location ".eslint-suppressions-example.json"
1
pnpmyarn dlx eslint "src/**/*.js" --suppressions-location ".eslint-suppressions-example.json"
1
bunpnpm dlx eslint "src/**/*.js" --suppressions-location ".eslint-suppressions-example.json"
1
bunx eslint "src/**/*.js" --suppressions-location ".eslint-suppressions-example.json"
1
--prune-suppressions
Prune unused suppressions from the suppressions file. This option is useful when you addressed one or more of the suppressed violations.
--prune-suppressions
example npm
yarnnpx eslint "src/**/*.js" --prune-suppressions
1
pnpmyarn dlx eslint "src/**/*.js" --prune-suppressions
1
bunpnpm dlx eslint "src/**/*.js" --prune-suppressions
1
bunx eslint "src/**/*.js" --prune-suppressions
1
--pass-on-unpruned-suppressions
Ignore unused suppressions. By default, ESLint exits with exit code 2
and displays an error message if there are unused suppressions in the suppressions file. When you use this flag, unused suppressions do not affect the exit code and ESLint doesn’t output an error about unused suppressions.
--pass-on-unpruned-suppressions
example npm
yarnnpx eslint "src/**/*.js" --pass-on-unpruned-suppressions
1
pnpmyarn dlx eslint "src/**/*.js" --pass-on-unpruned-suppressions
1
bunpnpm dlx eslint "src/**/*.js" --pass-on-unpruned-suppressions
1
Miscellaneousbunx eslint "src/**/*.js" --pass-on-unpruned-suppressions
1
--init
This option runs npm init @eslint/config
to start the config initialization wizard. It’s designed to help new users quickly create an eslint.config.js
file by answering a few questions. When you use this flag, the CLI does not perform linting.
The resulting configuration file is created in the current directory.
--init
example --env-info
This option outputs information about the execution environment, including the version of Node.js, npm, and local and global installations of ESLint.
The ESLint team may ask for this information to help solve bugs. When you use this flag, the CLI does not perform linting.
--env-info
example yarn
pnpmyarn dlx eslint --env-info
1
pnpm dlx eslint --env-info
1
--no-error-on-unmatched-pattern
This option prevents errors when a quoted glob pattern or --ext
is unmatched. This does not prevent errors when your shell can’t match a glob.
--no-error-on-unmatched-pattern
example npm
yarnnpx eslint --no-error-on-unmatched-pattern --ext .ts "lib/*"
1
pnpmyarn dlx eslint --no-error-on-unmatched-pattern --ext .ts "lib/*"
1
bunpnpm dlx eslint --no-error-on-unmatched-pattern --ext .ts "lib/*"
1
bunx eslint --no-error-on-unmatched-pattern --ext .ts "lib/*"
1
--exit-on-fatal-error
This option causes ESLint to exit with exit code 2 if one or more fatal parsing errors occur. Without this option, ESLint reports fatal parsing errors as rule violations.
--exit-on-fatal-error
example npm
yarnnpx eslint --exit-on-fatal-error file.js
1
pnpmyarn dlx eslint --exit-on-fatal-error file.js
1
bunpnpm dlx eslint --exit-on-fatal-error file.js
1
bunx eslint --exit-on-fatal-error file.js
1
--no-warn-ignored
Flat Config Mode Only. This option suppresses both File ignored by default
and File ignored because of a matching ignore pattern
warnings when an ignored filename is passed explicitly. It is useful when paired with --max-warnings 0
as it will prevent exit code 1 due to the aforementioned warning.
--no-warn-ignored
example npm
yarnnpx eslint --no-warn-ignored --max-warnings 0 ignored-file.js
1
pnpmyarn dlx eslint --no-warn-ignored --max-warnings 0 ignored-file.js
1
bunpnpm dlx eslint --no-warn-ignored --max-warnings 0 ignored-file.js
1
bunx eslint --no-warn-ignored --max-warnings 0 ignored-file.js
1
--pass-on-no-patterns
This option allows ESLint to exit with code 0 when no file or directory patterns are passed. Without this option, ESLint assumes you want to use .
as the pattern. (When running in legacy eslintrc mode, ESLint will exit with code 1.)
--pass-on-no-patterns
example npm
yarnnpx eslint --pass-on-no-patterns
1
pnpmyarn dlx eslint --pass-on-no-patterns
1
bunpnpm dlx eslint --pass-on-no-patterns
1
bunx eslint --pass-on-no-patterns
1
--debug
This option outputs debugging information to the console. Add this flag to an ESLint command line invocation in order to get extra debugging information while the command runs.
This information is useful when you’re seeing a problem and having a hard time pinpointing it. The ESLint team may ask for this debugging information to help solve bugs.
--debug
example npm
yarnnpx eslint --debug test.js
1
pnpmyarn dlx eslint --debug test.js
1
bunpnpm dlx eslint --debug test.js
1
bunx eslint --debug test.js
1
-h
, --help
This option outputs the help menu, displaying all of the available options. All other options are ignored when this is present. When you use this flag, the CLI does not perform linting.
-h
, --help
example -v
, --version
This option outputs the current ESLint version onto the console. All other options are ignored when this is present. When you use this flag, the CLI does not perform linting.
-v
, --version
example yarn
pnpmyarn dlx eslint --version
1
pnpm dlx eslint --version
1
--print-config
This option outputs the configuration to be used for the file passed. When present, no linting is performed and only config-related options are valid. When you use this flag, the CLI does not perform linting.
--print-config
example npm
yarnnpx eslint --print-config file.js
1
pnpmyarn dlx eslint --print-config file.js
1
bunpnpm dlx eslint --print-config file.js
1
bunx eslint --print-config file.js
1
--stats
This option adds a series of detailed performance statistics (see Stats type) such as the parse-, fix- and lint-times (time per rule) to result
objects that are passed to the formatter (see Stats CLI usage).
This option is intended for use with custom formatters that display statistics. It can also be used with the built-in json
formatter.
--stats
example npm
yarnnpx eslint --stats --format json file.js
1
pnpmyarn dlx eslint --stats --format json file.js
1
bunpnpm dlx eslint --stats --format json file.js
1
bunx eslint --stats --format json file.js
1
--flag
This option enables one or more feature flags for ESLint.
--flag
example npm
yarnnpx eslint --flag x_feature file.js
1
pnpmyarn dlx eslint --flag x_feature file.js
1
bunpnpm dlx eslint --flag x_feature file.js
1
bunx eslint --flag x_feature file.js
1
--mcp
This option starts the ESLint MCP server for use with AI agents.
--mcp
example Exit Codes
When linting files, ESLint exits with one of the following exit codes:
0
: Linting was successful and there are no linting errors. If the --max-warnings
flag is set to n
, the number of linting warnings is at most n
.1
: Linting was successful and there is at least one linting error, or there are more linting warnings than allowed by the --max-warnings
option.2
: Linting was unsuccessful due to a configuration problem or an internal error.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4