@nx/eslint

The ESLint plugin contains executors, generator, plugin and utilities used for linting JavaScript/TypeScript projects within an Nx workspace.

Setting Up ESLint

Installation

Keep Nx Package Versions In Sync

Make sure to install the @nx/eslint version that matches the version of nx in your repository. If the version numbers get out of sync, you can encounter some difficult to debug errors. You can fix Nx version mismatches with this recipe.

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

Enable Inferred Tasks

Inferred Tasks

In Nx version 17.3, the @nx/eslint plugin can create inferred tasks for projects that have an ESLint configuration file present. This means you can run nx lint my-project for that project, even if there is no lint task defined in package.json or project.json.

To enable inferred tasks, add @nx/eslint/plugin to the plugins array in nx.json.

nx.json
1{ 2 "plugins": [ 3 { 4 "plugin": "@nx/eslint/plugin", 5 "options": { 6 "targetName": "lint" 7 } 8 } 9 ] 10} 11
Nx 15 and lower use @nrwl/ instead of @nx/

Task Inference Process

Identify Valid Projects

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:

  • .eslintrc
  • .eslintrc.js
  • .eslintrc.cjs
  • .eslintrc.yaml
  • .eslintrc.yml
  • .eslintrc.json
  • eslint.config.js

Name the Inferred Task

Once an ESLint configuration file has been identified, the task is created with the name you specify under targetName in the nx.json plugins array. The default name for inferred tasks is lint.

View and Edit Inferred Tasks

To view inferred tasks for a project, open the project details view in Nx Console or run nx show project my-project in the command line. Nx Console also provides a quick way to override the settings of an inferred task.

Lint

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

nx lint my-project

Utils

ESLint plugin

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

Package reference

Here is a list of all the executors and generators available from this package.

Guides

Executors

  • lint

    Run ESLint on a project.

Generators