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 ruleP2universalStack: React
reactreadabilitycontrol-flowearly-return
Order status checks loading, error, empty to avoid repeated negations
Guard render branches in the order loading -> error -> empty so each later check no longer has to re-test !isLoading.
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetsx
| 1 | if (!isLoading && error) return <Error/>; |
| 2 | if (!isLoading && !items.length) return <Empty/>; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | if (isLoading) return <Spinner/>; |
| 2 | if (error) return <Error/>; |
| 3 | if (!items.length) return <Empty/>; |
Explanation (EN)
Objašnjenje (HR)