Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Do not couple a generic interface to a more specific one
Picking fields from a narrower interface to define a broader/more generic one inverts the dependency direction; define the shared shape independently.
Bad example
| 1 | type InstrumentInfo = Pick<ITickerTag, 'milistreamId' | 'name' | 'symbol'>; |
Explanation (EN)
Deriving a core contract from a UI-specific consumer reverses the intended ownership.
Objašnjenje (HR)
Good example
| 1 | interface InstrumentInfo { milistreamId: string; name: string; symbol: string; } |
| 2 | interface ITickerTag extends InstrumentInfo { /* extra fields */ } |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
When a reusable domain shape depends on a consumer-specific interface, extract the common shape into the lower-level module and let consumers extend it.
Exceptions / Tradeoffs (EN)
A Pick from a stable canonical source type is often correct. Do not call a one-way dependency circular unless the reverse dependency or architectural inversion actually exists.