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).
frontend ruleP1stack specificStack: react
reactapi-designencapsulationreusability
Design components so callers can use them without external coordination
Encapsulate a feature in one component whose usage is self-contained; avoid splitting it into two components that the caller must wire together by matching ids/config, even if internal logic is complex.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | // caller must keep the id in two places in sync |
| 2 | <AdvertisementComponent placement='sky-high' /> |
| 3 | <AdLoader slotConfig={adSlotConfig('sky-high')} /> |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | // one component owns its own config |
| 2 | <AdComponent placement='sky-high' position='high' type='skyscraper' hasLabel /> |
Explanation (EN)
Objašnjenje (HR)