@nx/eslint - Generators
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-to-flat-config
Section titled “convert-to-flat-config”Convert an Nx workspace’s ESLint configs to use Flat Config.
Usage:
nx generate @nx/eslint:convert-to-flat-config [options]Options
Section titled “Options”| Option | Type | Description | Default |
|---|---|---|---|
--eslintConfigFormat | string | The format of the generated ESLint flat config files. | "mjs" |
--keepExistingVersions | boolean | Keep 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 |
--skipFormat | boolean | Skip formatting files. | false |
convert-to-inferred
Section titled “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:
nx generate @nx/eslint:convert-to-inferred [options]Options
Section titled “Options”| Option | Type | Description | Default |
|---|---|---|---|
--project | string | The project to convert from using the @nx/eslint:lint executor to use @nx/eslint/plugin. | |
--skipFormat | boolean | Whether to format files at the end of the migration. | false |
workspace-rule
Section titled “workspace-rule”Create a new Workspace Lint Rule.
Create rule
Section titled “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:
nx g @nx/eslint:workspace-rule my-custom-ruleCustom sub-folder
Section titled “Custom sub-folder”We can change the default sub-folder from rules and specify a custom one:
nx g @nx/eslint:workspace-rule --name=my-custom-rule --directory=my/custom/pathThe command above will generate the rule in tools/eslint-rules/my/custom/path folder.
Usage:
nx generate @nx/eslint:workspace-rule [options]Arguments:
nx generate @nx/eslint:workspace-rule <name> [options]Options
Section titled “Options”| Option | Type | Description | Default |
|---|---|---|---|
--directory | string [required] | Create the rule under this directory within tools/eslint-rules/ (can be nested). | "rules" |
Getting Help
Section titled “Getting Help”You can get help for any generator by adding the --help flag:
nx generate @nx/eslint:<generator> --help