Skip to content

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.

convert-to-flat-config

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

Usage:

Terminal window
nx generate @nx/eslint:convert-to-flat-config [options]

Options

OptionTypeDescriptionDefault
skipFormatbooleanSkip formatting files.false

convert-to-inferred

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]

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

workspace-rule

Create a new Workspace Lint Rule.

Examples

{% tabs %} {% tab label=“Create 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

{% /tab %} {% tab label=“Custom sub-folder” %}

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.

{% /tab %} {% /tabs %}


Usage:

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

Arguments:

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

Options

OptionTypeDescriptionDefault
directorystring [required]Create the rule under this directory within tools/eslint-rules/ (can be nested)."rules"
## Getting Help
You can get help for any generator by adding the `--help` flag:
```bash
nx generate @nx/eslint:<generator> --help
```