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 ruleP1universalStack: React
reactcomponent-designcompositionreusabilityapi-design
Expose composition props instead of baking variant-specific markup into a component
For reusable components, accept slot/adornment props (e.g. startAdornment/endAdornment) so parents control variant-specific UI, rather than hard-coding it inside.
PR: hegnar-zephr-components · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | const FormInput = ({ onToggle }) => ( |
| 2 | <> |
| 3 | <input /> |
| 4 | {onToggle && <button onClick={onToggle}>SHOW</button>} |
| 5 | </> |
| 6 | ); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | interface FormInputProps { endAdornment?: JSX.Element; } |
| 2 | const FormInput = ({ endAdornment }: FormInputProps) => ( |
| 3 | <> |
| 4 | <input /> |
| 5 | {endAdornment} |
| 6 | </> |
| 7 | ); |
Explanation (EN)
Objašnjenje (HR)