ESLint is a static analysis tool for Javascript code. ESLint covers both code quality and coding style issues.
If you'd like to install it globally:
npm install -g eslint
If you'd like install it as a dev dependency of your project:
npm install eslint --save-dev
To generate a .eslintrc.* config file:
npx eslint --init
Done. See the ESLint Getting Started guide for more info.
It lives under the eslint
namespace and has the following configurable parameters:
# grumphp.yml
grumphp:
tasks:
eslint:
bin: node_modules/.bin/eslint
triggered_by: [js, jsx, ts, tsx, vue]
whitelist_patterns:
- /^resources\/js\/(.*)/
config: .eslintrc.json
ignore_path: .eslintignore
debug: false
format: ~
max_warnings: ~
no_eslintrc: false
quiet: false
bin
Default: null
The path to your eslint bin executable. Not necessary if eslint is in your $PATH. Can be used to specify path to project's eslint over globally installed eslint.
triggered_by
Default: [js, jsx, ts, tsx, vue]
This is a list of extensions which will trigger the ESLint task.
whitelist_patterns
Default: []
This is a list of regex patterns that will filter files to validate. With this option you can specify the folders containing javascript files and thus skip folders like /tests/ or the /vendor/ directory. This option is used in conjunction with the parameter triggered_by
.
For example: to whitelist files in resources/js/
(Laravel's JS directory) and assets/js/
(Symfony's JS directory) you can use:
whitelist_patterns:
- /^resources\/js\/(.*)/
- /^assets\/js\/(.*)/
config
Default: null
The path to your eslint's configuration file. Not necessary if using a standard eslintrc name, eg. .eslintrc.json, .eslint.js, or .eslint.yml
ignore_path
Default: null
The path to your eslint's ignore file (eslint.org). Not necessary if using standard .eslintignore name.
debug
Default: false
Turn on debug mode (eslint.org).
format
Default: null
Output format, eslint will use stylish
by default. Other handy ones on cli are compact
, codeframe
and table
(see full list on eslint.org).
max_warnings
Default: null
Number of warnings (not errors) that are allowed before eslint exits with error status (eslint.org).
no_eslintrc
Default: false
Set to true to ignore local .eslint config file (eslint.org).
quiet
Default: null
Report errors only (no warnings). eslint.org
other settings
Any other eslint settings (such as rules, env, ignore patterns, etc.) should be able to be set through an eslint config file (instructions to generate a config file at top of document).