@nx/eslint

The ESLint plugin integrates ESLint with Nx. It allows you to run ESLint through Nx with caching enabled. It also includes code generators to help you set up ESLint in your workspace.

Setting Up @nx/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:

โฏ

nx add @nx/eslint

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 and files to lint. 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
  • 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.

View Inferred Tasks

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.

@nx/eslint Configuration

The @nx/eslint/plugin is configured in 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
  • The targetName option controls the name of the inferred ESLint tasks. The default name is lint.

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, generators and migrations available from this package.

Guides

Executors

  • lint

    Run ESLint on a project.

Generators

Migrations

  • 20.3.x

  • add-file-extensions-to-overrides

    Update ESLint flat config to include .cjs, .mjs, .cts, and .mts files in overrides (if needed)

    Version: 20.3.0-beta.1
  • 20.2.x

  • update-typescript-eslint-v8.13.0

    Update TypeScript ESLint packages to v8.13.0 if they are already on v8

    Version: 20.2.0-beta.5
  • 19.5.x

  • 19.5.0-package-updates

    Version: 19.5.0-beta.1

    Packages

    NameVersionAlways Add to package.json
    @typescript-eslint/parser^7.16.0Update only
    @typescript-eslint/eslint-plugin^7.16.0Update only
    @typescript-eslint/utils^7.16.0Update only
  • 18.2.x

  • 18.2.0-package-updates

    Version: 18.2.0-beta.0

    Packages

    NameVersionAlways Add to package.json
    @typescript-eslint/parser^7.3.0Update only
    @typescript-eslint/eslint-plugin^7.3.0Update only
    @typescript-eslint/utils^7.3.0Update only
    eslint~8.57.0Update only
  • 17.3.x

  • 17.3.0-package-updates

    Version: 17.3.0-beta.0

    Packages

    NameVersionAlways Add to package.json
    @typescript-eslint/parser^6.13.2Update only
    @typescript-eslint/eslint-plugin^6.13.2Update only
    @typescript-eslint/utils^6.13.2Update only
  • 17.2.x

  • move-options-to-target-defaults

    Move executor options to target defaults

    Version: 17.2.9

    17.2.0-package-updates

    Version: 17.2.0-beta.2

    Packages

    NameVersionAlways Add to package.json
    eslint~8.48.0Update only

    simplify-eslint-patterns

    Simplify eslintFilePatterns

    Version: 17.2.0-beta.0
  • 17.1.x

  • update-typescript-eslint

    Updates for @typescript-utils/utils v6.9.1+

    Version: 17.1.0-beta.1

    17.1.0-package-updates

    Version: 17.1.0-beta.1

    Packages

    NameVersionAlways Add to package.json
    @typescript-eslint/parser^6.9.1Update only
    @typescript-eslint/eslint-plugin^6.9.1Update only
    @typescript-eslint/utils^6.9.1Update only
  • 17.0.x

  • 17.0.0-package-updates

    Version: 17.0.0-rc.2

    Packages

    NameVersionAlways Add to package.json
    eslint-config-prettier^9.0.0Update only

    update-17-0-0-rename-to-eslint

    update-17-0-0-rename-to-eslint

    Version: 17.0.0-beta.7