Skip to content
Nx Cloud CI is in private beta 10.6× faster average CI time with 79% less compute. Join the beta

The @nx/eslint plugin provides various generators to help you create and configure eslint projects within your Nx workspace. Below is a complete reference for all available generators and their options.

For an overview of the plugin and setup instructions, see the @nx/eslint introduction.

Convert an Nx workspace’s ESLint configs to use Flat Config.

Usage:

Terminal window
nx generate @nx/eslint:convert-to-flat-config [options]
OptionTypeDescriptionDefault
--eslintConfigFormatstringThe format of the generated ESLint flat config files."mjs"
--keepExistingVersionsbooleanKeep the existing versions of any ESLint-related packages already declared in package.json instead of overwriting them. Only newly added packages are installed, at the versions for the ESLint major the workspace declares (v9 when it declares none).false
--skipFormatbooleanSkip formatting files.false

Convert existing Eslint project(s) using @nx/eslint:lint executor to use @nx/eslint/plugin. Defaults to migrating all projects. Pass ‘—project’ to migrate only one target.

Usage:

Terminal window
nx generate @nx/eslint:convert-to-inferred [options]
OptionTypeDescriptionDefault
--projectstringThe project to convert from using the @nx/eslint:lint executor to use @nx/eslint/plugin.
--skipFormatbooleanWhether to format files at the end of the migration.false

Create a new Workspace Lint Rule.

This command will generate a new workspace lint rule called my-custom-rule. The new rule will be generated in tools/eslint-rules/rules folder:

Terminal window
nx g @nx/eslint:workspace-rule my-custom-rule

We can change the default sub-folder from rules and specify a custom one:

Terminal window
nx g @nx/eslint:workspace-rule --name=my-custom-rule --directory=my/custom/path

The command above will generate the rule in tools/eslint-rules/my/custom/path folder.


Usage:

Terminal window
nx generate @nx/eslint:workspace-rule [options]

Arguments:

Terminal window
nx generate @nx/eslint:workspace-rule <name> [options]
OptionTypeDescriptionDefault
--directorystring [required]Create the rule under this directory within tools/eslint-rules/ (can be nested)."rules"

You can get help for any generator by adding the --help flag:

Terminal window
nx generate @nx/eslint:<generator> --help