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 ruleP2project specificStack: React
reusedrycomponentsdiscoverability
Reuse an existing component before building a new one
Before implementing UI from scratch, check whether the codebase already has a component for it (e.g. an existing Tooltip) and reuse it.
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | // reimplementing a hover tooltip inline in LinkPopover |
| 2 | const [show, setShow] = useState(false); |
| 3 | {show && <div className={styles.tip}>...</div>} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | import Tooltip from '@/components/Tooltip'; |
| 2 | <Tooltip text="...">{children}</Tooltip> |
Explanation (EN)
Objašnjenje (HR)