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 requiresNode.js for installation. Follow the instructions in theGetting Started Guide to install ESLint.
Most users usenpx 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 filesnpx eslint file1.js file2.jsyarn
# Run on two filesyarn dlx eslint file1.js file2.jspnpm
# Run on two filespnpm dlx eslint file1.js file2.jsbun
# Run on two filesbunx eslint file1.js file2.jsor
npm
# Run on multiple filesnpx eslint lib/**yarn
# Run on multiple filesyarn dlx eslint lib/**pnpm
# Run on multiple filespnpm dlx eslint lib/**bun
# Run on multiple filesbunx 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 nodeglob 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/**"If you are using aflat 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:
npm
npx eslint.yarn
yarn dlx eslint.pnpm
pnpm dlx eslint.bun
bunx eslint.npm
npx eslintyarn
yarn dlx eslintpnpm
pnpm dlx eslintbun
bunx eslintIf 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 asYarn orpnpm to run ESLint. For pnpm usepnpm dlx eslint and for Yarn useyarn 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 runningnpx eslint -h.
eslint [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 optionsSpecify Rules and Plugins: --plugin [String] Specify plugins --rule Object Specify rulesFix 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 ignoreUse stdin: --stdin Lint code provided on <STDIN> - default: false --stdin-filename String Specify filename to process STDIN asHandle Warnings: --quiet Report errors only - default: false --max-warnings Int Number of warnings to trigger nonzero exit code - default: -1Output: -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 colorInline 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 2Caching: --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: metadataSuppressing 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: falseMiscellaneous: --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: offBasic Configuration
--no-config-lookup
Flat Config Mode Only. Disables use of configuration from files.
- Argument Type: No argument.
--no-config-lookup example
npm
npx eslint --no-config-lookup file.jsyarn
yarn dlx eslint --no-config-lookup file.jspnpm
pnpm dlx eslint --no-config-lookup file.jsbun
bunx eslint --no-config-lookup file.js--no-eslintrc
eslintrc Mode Only. Disables use of configuration from.eslintrc.* andpackage.json files. For flat config mode, use--no-config-lookup instead.
- Argument Type: No argument.
--no-eslintrc example
npm
npx eslint --no-eslintrc file.jsyarn
yarn dlx eslint --no-eslintrc file.jspnpm
pnpm dlx eslint --no-eslintrc file.jsbun
bunx eslint --no-eslintrc file.js-c,--config
This option allows you to specify an additional configuration file for ESLint (seeConfigure ESLint for more).
- Argument Type: String. Path to file.
- Multiple Arguments: No
-c,--config example
npm
npx eslint-c ~/my.eslint.config.js file.jsyarn
yarn dlx eslint-c ~/my.eslint.config.js file.jspnpm
pnpm dlx eslint-c ~/my.eslint.config.js file.jsbun
bunx eslint-c ~/my.eslint.config.js file.jsThis example uses the configuration file at~/my.eslint.config.js, which is used instead of searching for aneslint.config.js file.
--inspect-config
Flat Config Mode Only. This option runsnpx @eslint/config-inspector@latest to start theconfig 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-configyarn
yarn dlx eslint --inspect-configpnpm
pnpm dlx eslint --inspect-configbun
bunx eslint --inspect-config--env
eslintrc Mode Only. This option enables specific environments.
- Argument Type: String. One of the available environments.
- Multiple Arguments: Yes
Details about the global variables defined by each environment are available in theSpecifying 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
npx eslint--env browser,node file.jsyarn
yarn dlx eslint--env browser,node file.jspnpm
pnpm dlx eslint--env browser,node file.jsbun
bunx eslint--env browser,node file.jsnpm
npx eslint--env browser--envnode file.jsyarn
yarn dlx eslint--env browser--envnode file.jspnpm
pnpm dlx eslint--env browser--envnode file.jsbun
bunx eslint--env browser--envnode file.js--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 extensionsspecified 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 filesnpx eslint.--ext .tsyarn
# Include .ts filesyarn dlx eslint.--ext .tspnpm
# Include .ts filespnpm dlx eslint.--ext .tsbun
# Include .ts filesbunx eslint.--ext .tsnpm
# Include .ts and .tsx filesnpx eslint.--ext .ts--ext .tsxyarn
# Include .ts and .tsx filesyarn dlx eslint.--ext .ts--ext .tsxpnpm
# Include .ts and .tsx filespnpm dlx eslint.--ext .ts--ext .tsxbun
# Include .ts and .tsx filesbunx eslint.--ext .ts--ext .tsxnpm
# Also include .ts and .tsx filesnpx eslint.--ext .ts,.tsxyarn
# Also include .ts and .tsx filesyarn dlx eslint.--ext .ts,.tsxpnpm
# Also include .ts and .tsx filespnpm dlx eslint.--ext .ts,.tsxbun
# Also include .ts and .tsx filesbunx eslint.--ext .ts,.tsx--global
This option defines global variables so that they are not flagged as undefined by theno-undef rule.
- Argument Type: String. Name of the global variable. Any specified global variables are assumed to be read-only by default, but appending
:trueto a variable’s name ensures thatno-undefalso allows writes. - Multiple Arguments: Yes
--global example
npm
npx eslint--global require,exports:true file.jsyarn
yarn dlx eslint--global require,exports:true file.jspnpm
pnpm dlx eslint--global require,exports:true file.jsbun
bunx eslint--global require,exports:true file.jsnpm
npx eslint--global require--global exports:trueyarn
yarn dlx eslint--global require--global exports:truepnpm
pnpm dlx eslint--global require--global exports:truebun
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 parsernpx eslint--parser @typescript-eslint/parser file.tsyarn
# Use TypeScript ESLint parseryarn dlx eslint--parser @typescript-eslint/parser file.tspnpm
# Use TypeScript ESLint parserpnpm dlx eslint--parser @typescript-eslint/parser file.tsbun
# Use TypeScript ESLint parserbunx 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 errorecho'3 ** 4'| npx eslint--stdin --parser-options ecmaVersion:6yarn
# fails with a parsing errorecho'3 ** 4'|yarn dlx eslint--stdin --parser-options ecmaVersion:6pnpm
# fails with a parsing errorecho'3 ** 4'|pnpm dlx eslint--stdin --parser-options ecmaVersion:6bun
# fails with a parsing errorecho'3 ** 4'| bunx eslint--stdin --parser-options ecmaVersion:6npm
# succeeds, yay!echo'3 ** 4'| npx eslint--stdin --parser-options ecmaVersion:7yarn
# succeeds, yay!echo'3 ** 4'|yarn dlx eslint--stdin --parser-options ecmaVersion:7pnpm
# succeeds, yay!echo'3 ** 4'|pnpm dlx eslint--stdin --parser-options ecmaVersion:7bun
# succeeds, yay!echo'3 ** 4'| bunx eslint--stdin --parser-options ecmaVersion:7--resolve-plugins-relative-to
eslintrc Mode Only. Changes the directory where plugins are resolved from.
- Argument Type: String. Path to directory.
- Multiple Arguments: No
- Default Value: By default, plugins are resolved from the directory in which your configuration file is found.
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:
- When using a config file that is located outside of the current project (with the
--configflag), if the config uses plugins which are installed locally to itself,--resolve-plugins-relative-toshould be set to the directory containing the config file. - If an integration has dependencies on ESLint and a set of plugins, and the tool invokes ESLint on behalf of the user with a preset configuration, the tool should set
--resolve-plugins-relative-toto the top-level directory of the tool.
--resolve-plugins-relative-to example
npm
npx eslint--config ~/personal-eslintrc.js --resolve-plugins-relative-to /usr/local/lib/yarn
yarn dlx eslint--config ~/personal-eslintrc.js --resolve-plugins-relative-to /usr/local/lib/pnpm
pnpm dlx eslint--config ~/personal-eslintrc.js --resolve-plugins-relative-to /usr/local/lib/bun
bunx eslint--config ~/personal-eslintrc.js --resolve-plugins-relative-to /usr/local/lib/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.jsyarn
yarn dlx eslint--plugin jquery file.jspnpm
pnpm dlx eslint--plugin jquery file.jsbun
bunx eslint--plugin jquery file.jsnpm
npx eslint--plugin eslint-plugin-mocha file.jsyarn
yarn dlx eslint--plugin eslint-plugin-mocha file.jspnpm
pnpm dlx eslint--plugin eslint-plugin-mocha file.jsbun
bunx eslint--plugin eslint-plugin-mocha file.js--rule
This option specifies the rules to be used.
- Argument Type: Rules and their configuration specified withlevn 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 rulenpx eslint--rule'quotes: [error, double]'yarn
# Apply single ruleyarn dlx eslint--rule'quotes: [error, double]'pnpm
# Apply single rulepnpm dlx eslint--rule'quotes: [error, double]'bun
# Apply single rulebunx eslint--rule'quotes: [error, double]'npm
# Apply multiple rulesnpx eslint--rule'guard-for-in: error'--rule'brace-style: [error, 1tbs]'yarn
# Apply multiple rulesyarn dlx eslint--rule'guard-for-in: error'--rule'brace-style: [error, 1tbs]'pnpm
# Apply multiple rulespnpm dlx eslint--rule'guard-for-in: error'--rule'brace-style: [error, 1tbs]'bun
# Apply multiple rulesbunx eslint--rule'guard-for-in: error'--rule'brace-style: [error, 1tbs]'npm
# Apply rule from jquery pluginnpx eslint--rule'jquery/dollar-sign: error'yarn
# Apply rule from jquery pluginyarn dlx eslint--rule'jquery/dollar-sign: error'pnpm
# Apply rule from jquery pluginpnpm dlx eslint--rule'jquery/dollar-sign: error'bun
# Apply rule from jquery pluginbunx eslint--rule'jquery/dollar-sign: error'npm
# Only apply rule from the command linenpx eslint--rule'quotes: [error, double]' --no-config-lookupyarn
# Only apply rule from the command lineyarn dlx eslint--rule'quotes: [error, double]' --no-config-lookuppnpm
# Only apply rule from the command linepnpm dlx eslint--rule'quotes: [error, double]' --no-config-lookupbun
# Only apply rule from the command linebunx eslint--rule'quotes: [error, double]' --no-config-lookup--rulesdir
Deprecated: Userules from custom 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.
- Argument Type: String. Path to directory. The rules in your custom rules directory must follow the same format as bundled rules to work properly.
- Multiple Arguments: Yes
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
npx eslint--rulesdir my-rules/ file.jsyarn
yarn dlx eslint--rulesdir my-rules/ file.jspnpm
pnpm dlx eslint--rulesdir my-rules/ file.jsbun
bunx eslint--rulesdir my-rules/ file.jsnpm
npx eslint--rulesdir my-rules/--rulesdir my-other-rules/ file.jsyarn
yarn dlx eslint--rulesdir my-rules/--rulesdir my-other-rules/ file.jspnpm
pnpm dlx eslint--rulesdir my-rules/--rulesdir my-other-rules/ file.jsbun
bunx eslint--rulesdir my-rules/--rulesdir my-other-rules/ file.jsFix Problems
--fix
This option instructs ESLint to try tofix 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:
- This option throws an error when code is piped to ESLint.
- This option has no effect on code that uses a processor, unless the processor opts into allowing autofixes.
If you want to fix code fromstdin 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.jsyarn
yarn dlx eslint--fix file.jspnpm
pnpm dlx eslint--fix file.jsbun
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 fromstdin 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 jsonyarn
getSomeText|yarn dlx eslint--stdin --fix-dry-run--format jsonpnpm
getSomeText|pnpm dlx eslint--stdin --fix-dry-run--format jsonbun
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:
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
- 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
--ignore-path
eslintrc Mode Only. This option allows you to specify the file to use as your.eslintignore.
- Argument Type: String. Path to file.
- Multiple Arguments: No
- Default Value: By default, ESLint looks for
.eslintignorein the current working directory.
Note:--ignore-path is only supported when usingdeprecated configuration. If you want to include patterns from a.gitignore file in youreslint.config.js file, please seeincluding.gitignore files.
--ignore-path example
npm
npx eslint --ignore-path tmp/.eslintignore file.jsyarn
yarn dlx eslint --ignore-path tmp/.eslintignore file.jspnpm
pnpm dlx eslint --ignore-path tmp/.eslintignore file.jsbun
bunx eslint --ignore-path tmp/.eslintignore file.jsnpm
npx eslint --ignore-path .gitignore file.jsyarn
yarn dlx eslint --ignore-path .gitignore file.jspnpm
pnpm dlx eslint --ignore-path .gitignore file.jsbun
bunx eslint --ignore-path .gitignore file.js--no-ignore
Disables excluding of files from--ignore-pattern flags and theignores property in configuration. In eslintrc mode,.eslintignore files,--ignore-path flags, and theignorePatterns property in configuration are also disabled.
- Argument Type: No argument.
--no-ignore example
npm
npx eslint --no-ignore file.jsyarn
yarn dlx eslint --no-ignore file.jspnpm
pnpm dlx eslint --no-ignore file.jsbun
bunx eslint --no-ignore file.js--ignore-pattern
This option allows you to specify patterns of files to ignore. In eslintrc mode, these are in addition to.eslintignore.
- Argument Type: String. The supported syntax is the same as for
ignorespatterns, which useminimatch syntax. In eslintrc mode, the syntax is the same as for.eslintignorefiles, which use the same patterns as the.gitignorespecification. 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--stdinyarn
cat myFile.js|yarn dlx eslint--stdinpnpm
cat myFile.js|pnpm dlx eslint--stdinbun
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.jsyarn
cat myFile.js|yarn dlx eslint--stdin --stdin-filename myfile.jspnpm
cat myFile.js|pnpm dlx eslint--stdin --stdin-filename myfile.jsbun
cat myFile.js| bunx eslint--stdin --stdin-filename myfile.jsHandle 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.jsyarn
yarn dlx eslint--quiet file.jspnpm
pnpm dlx eslint--quiet file.jsbun
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
-1as 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.
When used alongside--quiet, this will cause rules marked as warn to still be run, but not reported.
--max-warnings example
npm
npx eslint --max-warnings10 file.jsyarn
yarn dlx eslint --max-warnings10 file.jspnpm
pnpm dlx eslint --max-warnings10 file.jsbun
bunx eslint --max-warnings10 file.jsOutput
-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.htmlyarn
yarn dlx eslint-o ./test/test.htmlpnpm
pnpm dlx eslint-o ./test/test.htmlbun
bunx eslint-o ./test/test.html-f,--format
This option specifies the output format for the console.
- Argument Type: String. One of thebuilt-in formatters or a custom formatter.
- Multiple Arguments: No
- Default Value:
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 withouteslint-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.jsonyarn
# Saves the output into the `results.json` file.yarn dlx eslint-f json file.js> results.jsonpnpm
# Saves the output into the `results.json` file.pnpm dlx eslint-f json file.js> results.jsonbun
# Saves the output into the `results.json` file.bunx eslint-f json file.js> results.json-f,--format example
Use the built-injson formatter:
npm
npx eslint--format json file.jsyarn
yarn dlx eslint--format json file.jspnpm
pnpm dlx eslint--format json file.jsbun
bunx eslint--format json file.jsUse a local custom formatter:
npm
npx eslint-f ./customformat.js file.jsyarn
yarn dlx eslint-f ./customformat.js file.jspnpm
pnpm dlx eslint-f ./customformat.js file.jsbun
bunx eslint-f ./customformat.js file.jsUse an npm-installed formatter:
npm
npminstall eslint-formatter-prettyyarn
yarnadd eslint-formatter-prettypnpm
pnpmadd eslint-formatter-prettybun
bunadd eslint-formatter-prettyThen run one of the following commands
npm
npx eslint-f pretty file.jsyarn
yarn dlx eslint-f pretty file.jspnpm
pnpm dlx eslint-f pretty file.jsbun
bunx eslint-f pretty file.jsor alternatively
npm
npx eslint-f eslint-formatter-pretty file.jsyarn
yarn dlx eslint-f eslint-formatter-pretty file.jspnpm
pnpm dlx eslint-f eslint-formatter-pretty file.jsbun
bunx eslint-f eslint-formatter-pretty file.js--color and--no-color
These options force the enabling/disabling of colorized output.
- Argument Type: No argument.
You can use these options to override the default behavior, which is to enable colorized output unless no TTY is detected, such as when pipingeslint throughcat orless.
--color and--no-color example
npm
npx eslint--color file.js|catyarn
yarn dlx eslint--color file.js|catpnpm
pnpm dlx eslint--color file.js|catbun
bunx eslint--color file.js|catnpm
npx eslint --no-color file.jsyarn
yarn dlx eslint --no-color file.jspnpm
pnpm dlx eslint --no-color file.jsbun
bunx eslint --no-color file.jsInline Configuration Comments
--no-inline-config
This option prevents inline comments like/*eslint-disable*/ or/*global foo*/ from having any effect.
- Argument Type: No argument.
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
npx eslint --no-inline-config file.jsyarn
yarn dlx eslint --no-inline-config file.jspnpm
pnpm dlx eslint --no-inline-config file.jsbun
bunx eslint --no-inline-config file.js--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.
- Argument Type: No argument.
This can be useful to prevent future errors from unexpectedly being suppressed, by cleaning up oldeslint-disable andeslint-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 aneslint-disable comment is added to suppress the incorrect report. If the bug is then fixed in a patch release of ESLint, theeslint-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
npx eslint --report-unused-disable-directives file.jsyarn
yarn dlx eslint --report-unused-disable-directives file.jspnpm
pnpm dlx eslint --report-unused-disable-directives file.jsbun
bunx eslint --report-unused-disable-directives file.js--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.
- Argument Type: String. One of the following values:
off(or0)warn(or1)error(or2)
- Multiple Arguments: No
- Default Value: By default,
linterOptions.reportUnusedDisableDirectivesconfiguration setting is used (which defaults to"warn").
--report-unused-disable-directives-severity example
npm
npx eslint --report-unused-disable-directives-severity warn file.jsyarn
yarn dlx eslint --report-unused-disable-directives-severity warn file.jspnpm
pnpm dlx eslint --report-unused-disable-directives-severity warn file.jsbun
bunx eslint --report-unused-disable-directives-severity warn file.js--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.
- Argument Type: String. One of the following values:
off(or0)warn(or1)error(or2)
- Multiple Arguments: No
- Default Value: By default,
linterOptions.reportUnusedInlineConfigsconfiguration 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
npx eslint --report-unused-inline-configs error file.jsCaching
--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.
- Argument Type: No argument.
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
npx eslint--cache file.jsyarn
yarn dlx eslint--cache file.jspnpm
pnpm dlx eslint--cache file.jsbun
bunx eslint--cache file.js--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 theeslint command is executed.
--cache-location
Specify the path to the cache location. Can be a file or a directory.
- Argument Type: String. Path to file or directory. If a directory is specified, a cache file is created inside the specified folder. The name of the file is based on the hash of the current working directory, e.g.:
.cache_hashOfCWD. - Multiple Arguments: No
- Default Value: If no location is specified,
.eslintcacheis used. The file is created in the directory where theeslintcommand 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
npx eslint"src/**/*.js"--cache --cache-location"/Users/user/.eslintcache/"yarn
yarn dlx eslint"src/**/*.js"--cache --cache-location"/Users/user/.eslintcache/"pnpm
pnpm dlx eslint"src/**/*.js"--cache --cache-location"/Users/user/.eslintcache/"bun
bunx eslint"src/**/*.js"--cache --cache-location"/Users/user/.eslintcache/"--cache-strategy
Strategy for the cache to use for detecting changed files.
- Argument Type: String. One of the following values:
metadatacontent
- Multiple Arguments: No
- Default Value:
metadata
Thecontent 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 likegit clone because git does not track file modification time.
--cache-strategy example
npm
npx eslint"src/**/*.js"--cache --cache-strategy contentyarn
yarn dlx eslint"src/**/*.js"--cache --cache-strategy contentpnpm
pnpm dlx eslint"src/**/*.js"--cache --cache-strategy contentbun
bunx eslint"src/**/*.js"--cache --cache-strategy contentSuppressing Violations
--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 ineslint-suppressions.json by default, unless otherwise specified by--suppressions-location. The file gets updated with the new suppressions.
- Argument Type: No argument.
--suppress-all example
npm
npx eslint"src/**/*.js" --suppress-allyarn
yarn dlx eslint"src/**/*.js" --suppress-allpnpm
pnpm dlx eslint"src/**/*.js" --suppress-allbun
bunx eslint"src/**/*.js" --suppress-all--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 ineslint-suppressions.json by default, unless otherwise specified by--suppressions-location. The file gets updated with the new suppressions.
- Argument Type: String. Rule ID.
- Multiple Arguments: Yes
--suppress-rule example
npm
npx eslint"src/**/*.js" --suppress-rule no-console --suppress-rule indentyarn
yarn dlx eslint"src/**/*.js" --suppress-rule no-console --suppress-rule indentpnpm
pnpm dlx eslint"src/**/*.js" --suppress-rule no-console --suppress-rule indentbun
bunx eslint"src/**/*.js" --suppress-rule no-console --suppress-rule indent--suppressions-location
Specify the path to the suppressions location. Can be a file or a directory.
- Argument Type: String. Path to file. If a directory is specified, a cache file is created inside the specified folder. The name of the file is based on the hash of the current working directory, e.g.:
suppressions_hashOfCWD - Multiple Arguments: No
- Default Value: If no location is specified,
eslint-suppressions.jsonis used. The file is created in the directory where theeslintcommand is executed.
--suppressions-location example
npm
npx eslint"src/**/*.js" --suppressions-location".eslint-suppressions-example.json"yarn
yarn dlx eslint"src/**/*.js" --suppressions-location".eslint-suppressions-example.json"pnpm
pnpm dlx eslint"src/**/*.js" --suppressions-location".eslint-suppressions-example.json"bun
bunx eslint"src/**/*.js" --suppressions-location".eslint-suppressions-example.json"--prune-suppressions
Prune unused suppressions from the suppressions file. This option is useful when you addressed one or more of the suppressed violations.
- Argument Type: No argument.
--prune-suppressions example
npm
npx eslint"src/**/*.js" --prune-suppressionsyarn
yarn dlx eslint"src/**/*.js" --prune-suppressionspnpm
pnpm dlx eslint"src/**/*.js" --prune-suppressionsbun
bunx eslint"src/**/*.js" --prune-suppressions--pass-on-unpruned-suppressions
Ignore unused suppressions. By default, ESLint exits with exit code2 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.
- Argument Type: No argument.
--pass-on-unpruned-suppressions example
npm
npx eslint"src/**/*.js" --pass-on-unpruned-suppressionsyarn
yarn dlx eslint"src/**/*.js" --pass-on-unpruned-suppressionspnpm
pnpm dlx eslint"src/**/*.js" --pass-on-unpruned-suppressionsbun
bunx eslint"src/**/*.js" --pass-on-unpruned-suppressionsMiscellaneous
--init
This option runsnpm init @eslint/config to start the config initialization wizard. It’s designed to help new users quickly create aneslint.config.js file by answering a few questions. When you use this flag, the CLI does not perform linting.
- Argument Type: No argument.
The resulting configuration file is created in the current directory.
--init example
npm
npx eslint--inityarn
yarn dlx eslint--initpnpm
pnpm dlx eslint--initbun
bunx eslint--init--env-info
This option outputs information about the execution environment, including the version of Node.js, npm, and local and global installations of ESLint.
- Argument Type: No argument.
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
npm
npx eslint --env-infoyarn
yarn dlx eslint --env-infopnpm
pnpm dlx eslint --env-infobun
bunx eslint --env-info--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.
- Argument Type: No argument.
--no-error-on-unmatched-pattern example
npm
npx eslint --no-error-on-unmatched-pattern--ext .ts"lib/*"yarn
yarn dlx eslint --no-error-on-unmatched-pattern--ext .ts"lib/*"pnpm
pnpm dlx eslint --no-error-on-unmatched-pattern--ext .ts"lib/*"bun
bunx eslint --no-error-on-unmatched-pattern--ext .ts"lib/*"--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.
- Argument Type: No argument.
--exit-on-fatal-error example
npm
npx eslint --exit-on-fatal-error file.jsyarn
yarn dlx eslint --exit-on-fatal-error file.jspnpm
pnpm dlx eslint --exit-on-fatal-error file.jsbun
bunx eslint --exit-on-fatal-error file.js--no-warn-ignored
Flat Config Mode Only. This option suppresses bothFile ignored by default andFile 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.
- Argument Type: No argument.
--no-warn-ignored example
npm
npx eslint --no-warn-ignored --max-warnings0 ignored-file.jsyarn
yarn dlx eslint --no-warn-ignored --max-warnings0 ignored-file.jspnpm
pnpm dlx eslint --no-warn-ignored --max-warnings0 ignored-file.jsbun
bunx eslint --no-warn-ignored --max-warnings0 ignored-file.js--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.)
- Argument Type: No argument.
--pass-on-no-patterns example
npm
npx eslint --pass-on-no-patternsyarn
yarn dlx eslint --pass-on-no-patternspnpm
pnpm dlx eslint --pass-on-no-patternsbun
bunx eslint --pass-on-no-patterns--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.
- Argument Type: No argument.
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
npx eslint--debug test.jsyarn
yarn dlx eslint--debug test.jspnpm
pnpm dlx eslint--debug test.jsbun
bunx eslint--debug test.js-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.
- Argument Type: No argument.
-h,--help example
npm
npx eslint--helpyarn
yarn dlx eslint--helppnpm
pnpm dlx eslint--helpbun
bunx eslint--help-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.
- Argument Type: No argument.
-v,--version example
npm
npx eslint--versionyarn
yarn dlx eslint--versionpnpm
pnpm dlx eslint--versionbun
bunx eslint--version--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.
- Argument Type: String. Path to file.
- Multiple Arguments: No
--print-config example
npm
npx eslint --print-config file.jsyarn
yarn dlx eslint --print-config file.jspnpm
pnpm dlx eslint --print-config file.jsbun
bunx eslint --print-config file.js--stats
This option adds a series of detailed performance statistics (seeStats type) such as theparse-,fix- andlint-times (time per rule) toresult objects that are passed to the formatter (seeStats CLI usage).
- Argument Type: No argument.
This option is intended for use with custom formatters that display statistics. It can also be used with the built-injson formatter.
--stats example
npm
npx eslint--stats--format json file.jsyarn
yarn dlx eslint--stats--format json file.jspnpm
pnpm dlx eslint--stats--format json file.jsbun
bunx eslint--stats--format json file.js--flag
This option enables one or more feature flags for ESLint.
- Argument Type: String. A feature identifier.
- Multiple Arguments: Yes
--flag example
npm
npx eslint--flag x_feature file.jsyarn
yarn dlx eslint--flag x_feature file.jspnpm
pnpm dlx eslint--flag x_feature file.jsbun
bunx eslint--flag x_feature file.js--mcp
This option starts the ESLint MCP server for use with AI agents.
- Argument Type: No argument.
- Multiple Arguments: No
--mcp example
npm
npx eslint--mcpyarn
yarn dlx eslint--mcppnpm
pnpm dlx eslint--mcpbun
bunx eslint--mcp--concurrency
This option controls the number of worker threads used to lint files.
- Argument Type: Int|String. A positive integer,
autooroff. - Multiple Arguments: No
- Default Value:
off
The valueoff causes all files to be linted in the main thread. The valueauto attempts to determine the best setting automatically.
--concurrency example
npm
npx eslint--concurrency autoyarn
yarn dlx eslint--concurrency autopnpm
pnpm dlx eslint--concurrency autobun
bunx eslint--concurrency autoExit 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-warningsflag is set ton, the number of linting warnings is at mostn.1: Linting was successful and there is at least one linting error, or there are more linting warnings than allowed by the--max-warningsoption.2: Linting was unsuccessful due to a configuration problem or an internal error.