@nx/eslint:lint
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.
Monorepo World: October 7, 2024Monorepo World: October 7, 2024Join us!
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:
1"lint": {
2 "executor": "@nx/eslint:lint",
3 "options": {
4 "lintFilePatterns": ["apps/frontend/**/*.ts"]
5 }
6}
7Linter 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.
1"lint": {
2 "executor": "@nx/eslint:lint",
3 "outputs": ["{options.outputFile}"],
4 "options": {
5 "lintFilePatterns": ["apps/frontend/**/*.ts"]
6 }
7}
8With these settings, we can run the command with a --fix flag:
1nx run frontend:lint --fix
2We can also set this flag via project configuration to always fix files when running lint:
1"lint": {
2 "executor": "@nx/eslint:lint",
3 "outputs": ["{options.outputFile}"],
4 "options": {
5 "lintFilePatterns": ["apps/frontend/**/*.ts"],
6 "fix": true
7 }
8}
9The name of the ESLint configuration file.
stylishESLint Output formatter (https://eslint.org/docs/user-guide/formatters).
falseFixes linting errors (may overwrite linted files).
falseReport errors only - default: false.
falseOnly check changed files.
Path to the cache file or directory.
metadatametadata, contentStrategy to use for detecting changed files in the cache.
trueWhen set to false, equivalent of the --no-error-on-unmatched-pattern flag on the ESLint CLI.
falseSucceeds 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. Not supported for Flat Config.
[{projectRoot}]One or more files/dirs/globs to pass directly to ESLint's lintFiles() method.
-1Number of warnings to trigger nonzero exit code - default: -1.
falseThe equivalent of the --no-eslintrc flag on the ESLint CLI, it is false by default.
File to write report to.
The equivalent of the --print-config flag on the ESLint CLI.
[]The equivalent of the --rulesdir flag on the ESLint CLI.
The equivalent of the --resolve-plugins-relative-to flag on the ESLint CLI. Not supported for Flat Config.
off, warn, errorThe equivalent of the --report-unused-disable-directives flag on the ESLint CLI.
falseHide output text.