Skip to content

The ESLint plugin integrates ESLint with Nx. Run ESLint through Nx with caching enabled, and use the included code generators to set up ESLint in your workspace.

The @nx/eslint plugin supports the following package versions.

PackageSupported Versions
eslint^8.0.0 || ^9.0.0

Nx generators install the latest supported versions automatically when scaffolding new projects.

In any Nx workspace, you can install @nx/eslint by running the following command:

Terminal window
nx add @nx/eslint

This will install the correct version of @nx/eslint.

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
  • .eslintrc.mjs
  • .eslintrc.cjs
  • .eslintrc.yaml
  • .eslintrc.yml
  • .eslintrc.json
  • eslint.config.js
  • eslint.config.mjs
  • eslint.config.cjs

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.

To view inferred tasks for a project, open the project details view in Nx Console or run nx show project my-project --web in the command line.

The @nx/eslint/plugin is configured in the plugins array in nx.json.

nx.json
{
"plugins": [
{
"plugin": "@nx/eslint/plugin",
"options": {
"targetName": "lint"
}
}
]
}
  • The targetName option controls the name of the inferred ESLint tasks. The default name is lint.

You can lint an application or a library with the following command:

Terminal window
nx lint my-project

Read about our dedicated ESLint plugin - eslint-plugin-nx.