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
reactdrycomponentsreuse
Unify near-duplicate components behind one component with a variant prop
When two components are almost identical, merge them into one configurable component (e.g. a boolean/variant prop) instead of maintaining two copies that drift apart.
PR: hegnar-forum-web · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | // CalendarFilterWithArrows.tsx and CalendarFilter.tsx — 90% identical |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | function CalendarFilter({ showArrows = false, ...props }: Props) { |
| 2 | return <>{showArrows && <Arrows />}{/* shared body */}</>; |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)