Command Line Interface (2023)

To run ESLint on Node.js, you must have npm installed. If npm is not installed, follow the instructions here:

Once npm is installed, run the following

npm i -g eslint

This installs the ESLint CLI from the npm repository. To run ESLint, use the following format:

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

Such as:

eslint file1.js file2.js


eslint lib/**

Please note that when passing a glob as a parameter, it will be 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:

eslint "lib/**"


The command line utility has several options. You can view the options by running eslint -h.

eslint [options] file.js [file.js] [dir]Basic configuration: -c, --config path::String Use configuration from this file or shareable config --no-eslintrc Disable use of configuration from .eslintrc --env [String] Specify environments --ext [String] Specify JavaScript file extensions - default: .js --global [String] Define global variables --parser String Specify the parser to be used --parser-options Object Specify parser optionsCaching: --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 directorySpecifying rules and plugins: --rulesdir [path::String] Use additional rules from this directory --plugin [String] Specify plugins --rule Object Specify rulesIgnoring files: --ignore-path path::String Specify path of ignore file --no-ignore Disable use of ignore files and patterns --ignore-pattern [String] Pattern of files to ignore (in addition to those in .eslintignore)Using stdin: --stdin Lint code provided on <STDIN> - default: false --stdin-filename String Specify filename to process STDIN asHandling 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 colorMiscellaneous: --init Run config initialization wizard - default: false --fix Automatically fix problems --debug Output debugging information -h, --help Show help -v, --version Output the version number --no-inline-config Prevent comments from changing config or rules --print-config path::String Print the configuration for the given file

Options that accept array 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).


eslint --ext .jsx --ext .js lib/eslint --ext .jsx,.js lib/

Basic configuration

-c, --config

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


eslint -c ~/my-eslint.json file.js

This example uses the configuration file at ~/my-eslint.json.

It also accepts a module ID of a sharable config.


eslint -c myconfig file.js
(Video) Command Line Interface (CLI) For Beginners

This example directly uses the sharable config eslint-config-myconfig.


Disables use of configuration from .eslintrc and package.json files.


eslint --no-eslintrc file.js


This option enables specific environments. Details about the global variables defined by each environment are available on the configuration 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.


eslint --env browser,node file.jseslint --env browser --env node file.js


This option allows you to specify which file extensions ESLint will use when searching for JavaScript files in the directories you specify.By default, it uses .js as the only file extension.


# Use only .js2 extensioneslint . --ext .js2# Use both .js and .js2eslint . --ext .js --ext .js2# Also use both .js and .js2eslint . --ext .js,.js2

Note: --ext is only used when the arguments are directories. If you use glob patterns or file names, then --ext is ignored.

For example, eslint lib/* --ext .js will match all files within the lib/ directory, regardless of extension.


This option defines global variables so that they will not be flagged as undefined by the no-undef rule. Any specified global variables are assumed to be read-only by default, but appending :true to a variable’s name ensures that no-undef will also allow writes. To specify multiple global variables, separate them using commas, or use the option multiple times.


eslint --global require,exports:true file.jseslint --global require --global exports:true


This option allows you to specify a parser to be used by eslint. By default, espree will be used.


This option allows you to specify parser options to be used by eslint. Note that the available parser options are determined by the parser being used.


echo '3 ** 4' | eslint --stdin --parser-options=ecmaVersion:6 # will fail with a parsing errorecho '3 ** 4' | eslint --stdin --parser-options=ecmaVersion:7 # succeeds, yay!



Store the info about processed files in order to only operate on the changed ones. The cache is stored in .eslintcache by default. Enabling this option can dramatically improve ESLint’s running time by ensuring that only changed files are linted.

Note: 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.


Path to the cache file. If none specified .eslintcache will be used. The file will be created in the directory where the eslint command is executed. Deprecated: Use --cache-location instead.


Path to the cache location. Can be a file or a directory. If no location is specified, .eslintcache will be used. In that case, the file will be created in the directory where the eslint command is executed.

(Video) Keyboards & Command Line Interfaces: Crash Course Computer Science #22

If a directory is specified, a cache file will be created inside the specified folder. The name of the file will be based on the hash of the current working directory (CWD). e.g.: .cache_hashOfCWD

Important note: If the directory for the cache does not exist make sure you add a trailing / on *nix systems or \ in windows. Otherwise the path will be assumed to be a file.


eslint "src/**/*.js" --cache --cache-location "/Users/user/.eslintcache/"

Specifying rules and plugins


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.


eslint --rulesdir my-rules/ file.js

The rules in your custom rules directory must follow the same format as bundled rules to work properly. You can also specify multiple locations for custom rules by including multiple --rulesdir options:

eslint --rulesdir my-rules/ --rulesdir my-other-rules/ file.js

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.


This option specifies a plugin to load. You can omit the prefix eslint-plugin- from the plugin name.

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


eslint --plugin jquery file.jseslint --plugin eslint-plugin-mocha file.js


This option specifies rules to be used. These rules will be merged with any rules specified with configuration files. (You can use --no-eslintrc to change that behavior.) To define multiple rules, separate them using commas, or use the option multiple times. The levn format is used for specifying the rules.

If the rule is defined within a plugin, you have to prefix the rule ID with the plugin name and a /.


eslint --rule 'quotes: [2, double]'eslint --rule 'guard-for-in: 2' --rule 'brace-style: [2, 1tbs]'eslint --rule 'jquery/dollar-sign: 2'

Ignoring files


This option allows you to specify the file to use as your .eslintignore. By default, ESLint looks in the current working directory for .eslintignore. You can override this behavior by providing a path to a different file.


eslint --ignore-path tmp/.eslintignore file.jseslint --ignore-path .gitignore file.js


Disables excluding of files from .eslintignore, --ignore-path and --ignore-pattern.


(Video) Command Line Crash Course

eslint --no-ignore file.js


This option allows you to specify patterns of files to ignore (in addition to those in .eslintignore). You can repeat the option to provide multiple patterns. The supported syntax is the same as in the .eslintignore file. You should quote your patterns in order to avoid shell interpretation of glob patterns.


eslint --ignore-pattern '/lib/' --ignore-pattern '/src/vendor/*' .

Using 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.


cat myfile.js | eslint --stdin


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.


cat myfile.js | eslint --stdin --stdin-filename=myfile.js

Handling warnings


This option allows you to disable reporting on warnings. If you enable this option, only errors are reported by ESLint.


eslint --quiet file.js


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.

Normally, if ESLint runs and finds no errors (only warnings), it will exit with a success exit status. However, if --max-warnings is specified and the total warning count is greater than the specified threshold, ESLint will exit with an error status. Specifying a threshold of -1 or omitting this option will prevent this behavior.


eslint --max-warnings 10 file.js


-o, --output-file

Enable report to be written to a file.


eslint -o ./test/test.html

When specified, the given format is output into the provided file name.

-f, --format

This option specifies the output format for the console. Possible formats are:

  • checkstyle
  • codeframe
  • compact
  • html
  • jslint-xml
  • json
  • junit
  • stylish (the default)
  • table
  • tap
  • unix
  • visualstudio


(Video) Windows Command Line Tutorial - 1 - Introduction to the Command Prompt

eslint -f compact file.js

You can also use a custom formatter from the command line by specifying a path to the custom formatter file.


eslint -f ./customformat.js file.js

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:

eslint -f compact file.js > results.txt

This saves the output into the results.txt file.

--color, --no-color

This option forces the enabling/disabling of colorized output. You can use this 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.


eslint --color file.js | cateslint --no-color file.js



This option will start config initialization wizard. It’s designed to help new users quickly create .eslintrc file by answering a few questions, choosing a popular style guide, or inspecting your source files and attempting to automatically generate a suitable configuration.

The resulting configuration file will be created in the current directory.


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:

  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.


This option outputs debugging information to the console. 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.

-h, --help

This option outputs the help menu, displaying all of the available options. All other options are ignored when this is present.

-v, --version

This option outputs the current ESLint version onto the console. All other options are ignored when this is present.


This option prevents inline comments like /*eslint-disable*/ or/*global foo*/ from having any effect. This allows you to set an ESLintconfig without files modifying it. All inline config comments are ignored, e.g.:

  • /*eslint-disable*/
  • /*eslint-enable*/
  • /*global*/
  • /*eslint*/
  • /*eslint-env*/
  • // eslint-disable-line
  • // eslint-disable-next-line


eslint --no-inline-config file.js


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.


eslint --print-config file.js

Ignoring files from linting

ESLint supports .eslintignore files to exclude files from the linting process when ESLint operates on a directory. Files given as individual CLI arguments will be exempt from exclusion. The .eslintignore file is a plain text file containing one pattern per line. It can be located in any of the target directory’s ancestors; it will affect files in its containing directory as well as all sub-directories. Here’s a simple example of a .eslintignore file:

(Video) Graphical User Interface (GUI) vs Command Line Interface (CLI)


A more detailed breakdown of supported patterns and directories ESLint ignores by default can be found in Configuring ESLint.


1. I created a Command Line Game for you // 5-Minute Node.js CLI Project
2. Deep Dive: AWS Command Line Interface
(Amazon Web Services)
3. What is command line interface and what are benefits of using command line interface? - #Linux
(Being Skilled)
4. Getting Started with Command Line Interface
(Amazon Web Services)
5. Proxmox VE Full Course: Class 12 - The Command-Line Interface
(Learn Linux TV)
6. Jenkins Beginner Tutorial 4 - How to use CLI (command line interface)
(Automation Step by Step)
Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated: 12/16/2022

Views: 5423

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.