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 ruleP2stack specificStack: typescript
typescripttypesdry
Extract reused union types into a named type alias
Define a named type alias for a union that appears in more than one place instead of repeating the inline union at each use site.
PR: vinify-frontend · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codets
| 1 | function setAlign(value: 'left' | 'center' | 'right') {} |
| 2 | const current: 'left' | 'center' | 'right' = 'left'; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | type Alignment = 'left' | 'center' | 'right'; |
| 2 | function setAlign(value: Alignment) {} |
| 3 | const current: Alignment = 'left'; |
Explanation (EN)
Objašnjenje (HR)