@nrwl/linter:eslint
ESLint Lint Target.
Options can be configured in project.json
when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets.
ESLint Lint Target.
Options can be configured in project.json
when defining the executor, or when invoking it. Read more about how to configure targets and executors here: https://nx.dev/reference/project-configuration#targets.
Linter can be configured in multiple ways. The basic way is to provide only lintFilePatterns
, which is a mandatory property. This tells us where to look for files to lint.
project.json
:
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": ["apps/frontend/**/*.ts"]
}
}
Linter provides an automated way of fixing known issues. To ensure that those changes are properly cached, we need to add an outputs
property to the lint
target. Omitting the outputs
property would produce an invalid cache record. Both of these properties are set by default when scaffolding a new project.
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/frontend/**/*.ts"]
}
}
With these settings, we can run the command with a --fix
flag:
nx run frontend:lint --fix
We can also set this flag via project configuration to always fix files when running lint:
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/frontend/**/*.ts"],
"fix": true
}
}
[]
One or more files/dirs/globs to pass directly to ESLint's lintFiles()
method.
The name of the ESLint configuration file.
stylish
ESLint Output formatter (https://eslint.org/docs/user-guide/formatters).
false
Fixes linting errors (may overwrite linted files).
false
Report errors only - default: false
.
false
Only check changed files.
Path to the cache file or directory.
metadata
metadata
, content
Strategy to use for detecting changed files in the cache.
false
Succeeds even if there was linting errors.
When set to true
, the linter will invalidate its cache when any of its dependencies changes.
The path of the .eslintignore
file.
-1
Number of warnings to trigger nonzero exit code - default: -1
.
false
The equivalent of the --no-eslintrc
flag on the ESLint CLI, it is false
by default.
File to write report to.
[]
The equivalent of the --rulesdir
flag on the ESLint CLI.
The equivalent of the --resolve-plugins-relative-to
flag on the ESLint CLI.
off
, warn
, error
The equivalent of the --report-unused-disable-directives
flag on the ESLint CLI.
false
Hide output text.