Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rule @typescript-eslint/prefer-enum-initializers #269

Merged
merged 1 commit into from
Dec 21, 2022

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Dec 19, 2022

The rule @typescript-eslint/prefer-enum-initializers has been added. This rule ensures that we use initializers for enums.

Uninitialized enums are hazardous because they implicitly assign each entry a sequential number value. This means that adding a new entry to the enum changes the value of every following entry. This can be confusing and unexpected, especially if this enum is stored in persisted state and now has a different meaning than before. Initialized enums, on the other hand, never unexpectedly change values.

This is a breaking change.

The rule `@typescript-eslint/prefer-enum-initializers` has been added.
This rule ensures that we use initializers for enums.

Uninitialized enums are hazardous because they implicitly assign each
entry a sequential number value. This means that adding a new entry to
the enum changes the value of every following entry. This can be
confusing and unexpected, especially if this enum is stored in
persisted state and now has a different meaning than before.
Initialized enums, on the other hand, never unexpectedly change values.

This is a breaking change.
@Gudahtt Gudahtt marked this pull request as ready for review December 19, 2022 13:16
@Gudahtt Gudahtt requested a review from a team as a code owner December 19, 2022 13:16
@Gudahtt Gudahtt merged commit ee34163 into main Dec 21, 2022
@Gudahtt Gudahtt deleted the prefer-enum-initializers branch December 21, 2022 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants