Enum names
- Selector:
enum - Required:
PascalCase - Custom: forbids
I*/T*prefix and some plural-ish forms (*es,*sbut not*usor*ss)
Why This Rule
PascalCase: Enums are types, so they follow the same convention as classes and interfaces.
Singular names: Enums represent a category or type, not a collection:
StatusnotStatuses- the enum represents the concept of "status"OrderTypenotOrderTypes- it's a type classificationDirectionnotDirections- it's a category
Why singular reads better:
ts
// Good - reads naturally
if (order.status === Status.PENDING) {
}
// Bad - awkward phrasing
if (order.status === Statuses.PENDING) {
}The singular form makes usage read like natural language: "the order's status is PENDING" not "the order's statuses is PENDING."
Exception: Names ending in *us (like Status, Radius) are allowed because they're singular Latin words, not plural forms.
References:
- Singular vs. Plural Naming for Enumerations - Stack Overflow
- Enums considered harmful - Matt Pocock
- TypeScript Handbook - Enums
✅ Good
ts
enum OrderStatus {
PENDING, // WHY: singular enum name with UPPER_CASE members
}
enum Direction {
NORTH, // WHY: singular, reads naturally in comparisons
}
enum RoomFacilityAccess {
PRIVATE, // WHY: singular, even if ends with 'ss'
}❌ Bad
ts
enum OrderStatuses {
PENDING, // WHY: plural enum type name is awkward when used in comparisons
}
enum BadPlural {
ITEM, // WHY: enum named like a collection can be confusing for callers
}