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 ruleP1stack specificStack: typescript
typescriptinterfacesdrytypes
Define interfaces for config and repeated object shapes
Give recurring object shapes (config sections, error messages, props) named interfaces and reuse them.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | const errors = { |
| 2 | 404: { title: '...', message: '...' }, |
| 3 | other: { title: '...', message: '...' }, |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | interface IErrorMessage { title: string; message: string; } |
| 2 | const errors: { 404: IErrorMessage; other: IErrorMessage } = { |
| 3 | 404: { title: '...', message: '...' }, |
| 4 | other: { title: '...', message: '...' }, |
| 5 | }; |
Explanation (EN)
Objašnjenje (HR)