Skip to content

enumInitializers

Reports enum members without explicit initial values.

✅ This rule is included in the ts logical presets.

TypeScript enums assign sequentially increasing numbers to members that don’t have explicit values. This behavior can cause unintended value changes if enum members are reordered, added, or removed. Explicitly initializing each enum member prevents these issues and makes the code’s intent clearer.

enum Status {
Pending,
Active,
Completed,
}
enum Direction {
Up,
Down,
}

This rule is not configurable.

If the numeric values of enum members are not important to your project, you may not need this rule. This can be the case when enums are only used for type safety and the actual runtime values are never inspected or stored externally.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.