Make it easier to centrally manage tech-specific eslint rules #27918
daiscog
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, when generating a new Angular library with the
@nx/angular:library
generator, the new project's.eslintrc.json
comes with a set of Angular-specific overrides. E.g., for*.html
files, it"extends": ["plugin:@nx/angular-template"],
, and provides an emptyrules
object for customization.Let's say I have a monorepo with a dozen or so Angular libraries, plus some other non-Angular ones, and I want to add a new lint rule for all Angular templates that isn't enabled OOTB by the
@nx/angular-template
plugin. I have to manually add that rule to therules
object in all of my Angular libraries' individual.eslintrc.json
files.It would be far better if I had a central file - say
tools/eslint/configs/angular-templates.json
- that all of the Angular projects in my monorepo could extend from, instead of directly extending from"plugin:@nx/angular-template"
. Then I can just add the additional rule in one place and have it apply to all projects.I can set this up manually myself (and I have done so). However, it's not exactly convenient to have to either:
.eslintrc.json
file to make it extend my centralized base config file, or@nx/angular:library
generator which edits the generated config file accordingly (and get the team to remember to use the workspace generator, not the nx one directly).Additionally, until the issue #22477 is addressed, changes to my centralized config file won't cause cache invalidation when using inferred lint targets.
Therefore I'd like to suggest that the following changes are made to the conventional/default monorepo layout:
tools/eslint-rules
(the default dir for workspace-specific eslint rules) becomestools/eslint/rules
tools/eslint/configs
directory is added as the default dir for workspace-specific eslint configstools/eslint/configs
that extends the tech-specific defaults from the@nx/eslint-plugin
package (e.g., the@nx/angular:library
generator createstools/eslint/configs/angular-templates.json
which"extends": ["plugin:@nx/angular-template"],
, and provides an emptyrules
object for customization)..eslintrc.json
files generated by the tech-specific project generators extend the base eslint config file undertools/eslint/configs
instead of extending the@nx/eslint-plugin
config directly.{workspaceRoot}/tools/eslint/configs/**/*
added to themThese changes would make it much easier by default to manage common eslint configs across a large and varied monorepo.
Beta Was this translation helpful? Give feedback.
All reactions