Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP1universalStack: typescript
enumsmodelingbooleansreadability
Model mutually-exclusive states as an enum, not parallel booleans
When a value can be one of several exclusive states, expose a single enum so consumers don't recombine booleans into logic; keep enums logic-free.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | if (isRegistered && !isActive) return Level.Registered; |
| 2 | if (isActive && !isAdmin && !isBanned) return Level.Active; // logic recombined from flags |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // The source computes the level; the consumer just reads the enum value |
| 2 | return accessLevel; // Level.Registered | Level.Active | Level.Admin | ... |
Explanation (EN)
Objašnjenje (HR)