Rules Hub
Code Ruleset
← 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
Return only a cleanup function or undefined from effects; explicit return undefined is a lint convention, not a React requirement.
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]); |
Explanation (EN)
Different return spellings can violate a configured style rule, but bare return is not a React error.
Objašnjenje (HR)
Good example
New codetypescript
| 1 | useEffect(() => { |
| 2 | if (!ready) return undefined; |
| 3 | return () => cleanup(); |
| 4 | }, [ready]); |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Effects may return a cleanup function or undefined. Follow the configured consistent-return style only when it applies.
Exceptions / Tradeoffs (EN)
A bare return already evaluates to undefined and is valid React behavior. Never return a Promise by making the effect callback async.