Skip to content

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

Merged
Gudahtt merged 1 commit intomainfrom
prefer-enum-initializers
Dec 21, 2022
Merged

Add rule @typescript-eslint/prefer-enum-initializers#269
Gudahtt merged 1 commit intomainfrom
prefer-enum-initializers

Conversation

@Gudahtt
Copy link
Copy Markdown
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