Skip to content

Commit

Permalink
fix(linter): do not infer lint tasks for projects without files to li…
Browse files Browse the repository at this point in the history
…nt (#22944)
  • Loading branch information
leosvelperez authored Apr 23, 2024
1 parent 739e2e7 commit 1e4324f
Show file tree
Hide file tree
Showing 4 changed files with 318 additions and 163 deletions.
4 changes: 3 additions & 1 deletion docs/generated/packages/eslint/documents/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This will install the correct version of `@nx/eslint`.

### How @nx/eslint Infers Tasks

The `@nx/eslint` plugin will create a task for any project that has an ESLint configuration file present. Any of the following files will be recognized as an ESLint configuration file:
The `@nx/eslint` plugin will create a task for any project that has an ESLint configuration file present and files to lint. Any of the following files will be recognized as an ESLint configuration file:

- `.eslintrc`
- `.eslintrc.js`
Expand All @@ -33,6 +33,8 @@ The `@nx/eslint` plugin will create a task for any project that has an ESLint co

Because ESLint applies configuration files to all subdirectories, the `@nx/eslint` plugin will also infer tasks for projects in subdirectories. So, if there is an ESLint configuration file in the root of the repository, every project will have an inferred ESLint task.

Even if a project has an ESLint configuration file, it will only have an inferred ESLint task if there are files to lint. Otherwise, the task will not be created. Therefore, if you don't want an ESLint task to be inferred for a particular project, make sure the project files are properly excluded from ESLint.

### View Inferred Tasks

To view inferred tasks for a project, open the [project details view](/concepts/inferred-tasks) in Nx Console or run `nx show project my-project --web` in the command line.
Expand Down
4 changes: 3 additions & 1 deletion docs/shared/packages/eslint/eslint.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This will install the correct version of `@nx/eslint`.

### How @nx/eslint Infers Tasks

The `@nx/eslint` plugin will create a task for any project that has an ESLint configuration file present. Any of the following files will be recognized as an ESLint configuration file:
The `@nx/eslint` plugin will create a task for any project that has an ESLint configuration file present and files to lint. Any of the following files will be recognized as an ESLint configuration file:

- `.eslintrc`
- `.eslintrc.js`
Expand All @@ -33,6 +33,8 @@ The `@nx/eslint` plugin will create a task for any project that has an ESLint co

Because ESLint applies configuration files to all subdirectories, the `@nx/eslint` plugin will also infer tasks for projects in subdirectories. So, if there is an ESLint configuration file in the root of the repository, every project will have an inferred ESLint task.

Even if a project has an ESLint configuration file, it will only have an inferred ESLint task if there are files to lint. Otherwise, the task will not be created. Therefore, if you don't want an ESLint task to be inferred for a particular project, make sure the project files are properly excluded from ESLint.

### View Inferred Tasks

To view inferred tasks for a project, open the [project details view](/concepts/inferred-tasks) in Nx Console or run `nx show project my-project --web` in the command line.
Expand Down
Loading

0 comments on commit 1e4324f

Please sign in to comment.