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).
backend ruleP2universalStack: typescript
configurationencapsulationdryenums
Don't create enums that just duplicate config data
Instead of an enum that mirrors a config file and re-exposes its values, add the needed property to the config and expose it through the owning service.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | enum FormPlaceholders { |
| 2 | Newsletter = 'newsletter', |
| 3 | Stock = 'stock', |
| 4 | } // duplicates the config file |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // add a className property to the config, then: |
| 2 | class FormConfig { |
| 3 | formComponentClass(placeholder: string): string { |
| 4 | return this.config[placeholder].className; |
| 5 | } |
| 6 | } |
Explanation (EN)
Objašnjenje (HR)