Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Declare component props as an interface, even when extending another type
Use interface Props extends Base {} instead of type Props = Base for component props, for consistency and extensibility.
Bad example
| 1 | type RowProps = Item; |
Explanation (EN)
A bare alias breaks from the props-as-interface convention and is awkward to extend later when the component needs an extra prop.
Objašnjenje (HR)
Goli alias odstupa od konvencije props-kao-interface i nezgodan je za prosirivanje kasnije kad komponenta treba dodatni prop.
Good example
| 1 | interface RowProps extends Item {} |
Explanation (EN)
An interface that extends the base type matches the convention and leaves room to add component-specific props cleanly.
Objašnjenje (HR)
Interface koji prosiruje bazni tip prati konvenciju i ostavlja prostor za cisto dodavanje propsa specificnih za komponentu.
Exceptions / Tradeoffs (EN)
When the props type needs unions, mapped types, or other features interfaces can't express, a type alias is correct.
Iznimke / Tradeoffi (HR)
Kad props tip treba unije, mapirane tipove ili druge mogucnosti koje interface ne moze izraziti, type alias je ispravan.