Rule Proposal 'prefer-enum-initializers' #2268
Labels
enhancement: new plugin rule
New rule request for eslint-plugin
good first issue
Good for newcomers
has pr
there is a PR raised to close this
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Proposal
Proposal Result
The name and message are just an example.
Actual Result
n/a

Additional Info
Enum infers sequential numbers automatically when initializers are omitted:
With this approach, if new values are declared without following the existing order and the value of the enum has been saved in an external source, we will have inconsistencies between the saved value and the new representation, example:
And removing an option from the enum is not possible, unless it is the last option in the enum, otherwise the order will break as well.
For the my current company's eslint-preset we've implemented a simple version of this rule here. As dealing with
enum
s intypescript
can have its trade-offs, I'd like to know if this would be useful to others.Oh and thanks for the great work with all these packages! They are being extremely useful and effective in guaranteeing the quality of our code 😁 🙌
The text was updated successfully, but these errors were encountered: