Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Keep domain aliases while reusing shared primitives
When a shared primitive already exists, reuse it under a domain-specific alias so the code stays both consistent and readable.
Bad example
| 1 | import type { SortOrderUpper } from 'enums/SortOptions'; |
| 2 |
|
| 3 | interface GetPortfolioTransactionsProps { |
| 4 | order?: SortOrderUpper; |
| 5 | } |
Explanation (EN)
This reuses the primitive, but it also removes domain context from the API surface. Readers have to infer what the order refers to.
Objašnjenje (HR)
Ovo ponovno koristi primitiv, ali uklanja domenski kontekst s API surfacea. Citac mora zakljucivati na sto se order odnosi.
Good example
| 1 | import type { SortOrderUpper } from 'enums/SortOptions'; |
| 2 |
|
| 3 | export type PortfolioTransactionOrder = SortOrderUpper; |
| 4 |
|
| 5 | interface GetPortfolioTransactionsProps { |
| 6 | order?: PortfolioTransactionOrder; |
| 7 | } |
Explanation (EN)
The code reuses the shared primitive while preserving domain meaning at the call site and in API contracts.
Objašnjenje (HR)
Kod ponovno koristi shared primitiv, ali zadrzava domensko znacenje na call siteu i u API contractima.
Notes (EN)
Prefer this pattern when the shape is shared but the meaning is domain-specific.
Bilješke (HR)
Preferiraj ovaj obrazac kada je shape shared, ali je znacenje domain-specific.
Exceptions / Tradeoffs (EN)
If the alias adds no clarity and is only a thin rename with no meaningful usage boundary, the shared primitive can be used directly.
Iznimke / Tradeoffi (HR)
Ako alias ne dodaje jasnocu i samo je tanko preimenovanje bez stvarne usage granice, shared primitiv se moze koristiti direktno.