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 ruleP2stack specificStack: react
reacthookseslint
Satisfy consistent-return in effects with explicit returns
useEffect should return a cleanup function or nothing; when other branches return, use return undefined to keep the rule happy.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | useEffect(() => { |
| 2 | if (!ready) return; |
| 3 | return () => cleanup(); |
| 4 | }, [ready]); // inconsistent return paths |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | useEffect(() => { |
| 2 | if (!ready) return undefined; |
| 3 | return () => cleanup(); |
| 4 | }, [ready]); |
Explanation (EN)
Objašnjenje (HR)