Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Match direct children returns to the component contract
Use a fragment when grouping or an element-only contract requires it; returning children directly is valid with compatible types.
Bad example
| 1 | if (!params) return children; |
Explanation (EN)
A broad children type may not satisfy an intentionally element-only return contract.
Objašnjenje (HR)
Good example
| 1 | if (!params) return <>{children}</>; |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Wrap children only when an actual API/type contract requires an element or grouping, and verify the installed React/TypeScript support.
Exceptions / Tradeoffs (EN)
Modern components can return ReactNode directly. An unnecessary fragment can affect identity in nested shape transitions; do not add one solely because children are not JSX.Element.