react-hook-review
React Hook Review
Review hooks against coding principles and usage patterns. Report findings by severity.
Treat C1, C7, and C14 as opinionated conventions unless the target codebase explicitly adopts them. Report them as stronger findings when the repository standard is clear; otherwise phrase them as consistency recommendations.
Coding Principles Checklist
Required (11 items)
-
Return values (C1) — Always return objects, even for single values.
{ value }not bare primitives. Why: Named fields, order-independent, extensible without breaking changes. -
SSR-safe init (C2) —
useState(FIXED)+useEffect(sync). No browser API in initializer. Why: Server has nowindow— crashes or hydration mismatch. Note: For explicitly client-only hooks, a guarded lazy initializer can be acceptable. -
Cleanup (C3) — Every useEffect with side effects returns cleanup (listeners, timers, AbortController). Why: Memory leaks. StrictMode double-mount exposes missing cleanup immediately.