-
Notifications
You must be signed in to change notification settings - Fork 11
Description
This rule was added to angluar-eslint's recommended ruleset as of v20. We had to disable it in our configuration, due to required effort to update existing source, but we should revisit that descision.
Angular provides an automatic migration (ng generate @angular/core:inject) to replace constructor arguments with inject()-initialized class fields, but it's not smart. It puts new the fields immediately before the constructor, but they need to be declared/initialized before any other field initializers that depend on them. For automation purposes (and probably as general convention), that means we want them declared at the top of the class. @typescript-eslint/member-ordering doesn't have an automated fix-up, nor the ability to take initializers into acount . The Perfectionist sort-classes rule has both of those, and I made an attempt to use that rule instead. We can configure their rule to enforce (and automate) fields initialized with inject(... being put before all other fields. But I wasn't able to prevent it from auto-sorting getter/setter pairs with different access modifiers apart from each other (which violates the grouped-accessor-pairs rule).