LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

eslint

pluggable JavaScript and TypeScript linter

TLDR

Lint JavaScript files
$ eslint [file.js]
copy
Lint directory recursively
$ eslint [src/]
copy
Fix auto-fixable issues
$ eslint --fix [file.js]
copy
Specify config file
$ eslint -c [.eslintrc.json] [file.js]
copy
Output in specific format
$ eslint -f [json] [file.js]
copy
Create a configuration file interactively
$ npm init @eslint/config
copy
Lint files piped on stdin
$ cat [file.js] | eslint --stdin
copy

SYNOPSIS

eslint [options] [files|dirs]

DESCRIPTION

ESLint is the standard linting tool for JavaScript and TypeScript. It statically analyzes code to find problems, enforce coding standards, and catch bugs before runtime.Rules are highly configurable. Plugins extend functionality for React, Vue, TypeScript, and other frameworks. The --fix flag automatically corrects many issues.ESLint integrates with editors and CI systems, making it central to JavaScript development workflows.

PARAMETERS

FILES

Files or directories to lint.
--fix
Automatically fix problems.
-c, --config FILE
Configuration file.
-f, --format FORMAT
Output format.
--cache
Only check files that changed since the last run.
--quiet
Report errors only, suppressing warnings.
--max-warnings N
Exit with an error if more than N warnings are found.
--no-eslintrc
Ignore configuration files (legacy config only).
--rulesdir DIR
Load additional custom rules from a directory (deprecated).
--stdin
Lint source read from standard input.
--help
Display help information.

CONFIGURATION

eslint.config.js (flat config)

The default configuration file since ESLint v9. It exports an array of config objects defining files, rules, plugins and language options. Also available as eslint.config.mjs or eslint.config.cjs.
.eslintrc.js / .eslintrc.json / .eslintrc.yml (legacy)
The pre-v9 "eslintrc" format. Deprecated and no longer searched for by default in v9, and slated for removal in v10.

INSTALL

sudo pacman -S eslint
copy
brew install eslint
copy
nix profile install nixpkgs#eslint
copy

CAVEATS

Since ESLint v9 the flat config (eslint.config.js) is the default and the legacy .eslintrc format, the --ext flag, --no-eslintrc and the built-in `--init` command have been removed or replaced; use `npm init @eslint/config` to scaffold a config. Plugin compatibility varies between the two config systems. Large codebases benefit from --cache.

HISTORY

ESLint was created by Nicholas C. Zakas in 2013 as a more pluggable and configurable alternative to JSHint. It became the dominant JavaScript linter due to its extensibility.

SEE ALSO

prettier(1), tsc(1), jshint(1)

RESOURCES

Copied to clipboard
Kai