-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Change Request: Support generic types for Rule.RuleModule type #19521
Copy link
Copy link
Closed
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusioncoreRelates to ESLint's core APIs and featuresRelates to ESLint's core APIs and featuresenhancementThis change enhances an existing feature of ESLintThis change enhances an existing feature of ESLinttypesRelated to TypeScript typesRelated to TypeScript types
Metadata
Metadata
Assignees
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusioncoreRelates to ESLint's core APIs and featuresRelates to ESLint's core APIs and featuresenhancementThis change enhances an existing feature of ESLintThis change enhances an existing feature of ESLinttypesRelated to TypeScript typesRelated to TypeScript types
Type
Projects
Status
Complete
ESLint version
v9.22.0
What problem do you want to solve?
Hello,
Currently, the
Rule.RuleModuletype is not generic, which prevents me from extending theExtRuleDocsproperty with custom properties.Please take a look at the source code below.
https://github.com/eslint/eslint/blob/main/lib/types/index.d.ts#L554-L562
For example:
When I try to add
my-custom-propertytometa.docs, I get a type error becauseExtRuleDocsis simply initialized as{}with no way to extend its functionality.I’d like to suggest adding support for generic types in
Rule.RuleModuleto allow for greater flexibility.What do you think is the correct solution?
RuleModuletype cannot be extended.RuleModuletype can be extended using generics, allowing users to define custom types.As a result, We can define a custom
ExtRuleDocstype like the code below:Please note that this change does not affect ESLint's current behavior. Looking forward to your comments on this!
Participation
Additional comments
No response