eslint-react
eslint-react copied to clipboard
[feat] ensure-custom-hooks-follow-naming-convention
Describe the problem
If someone wrote a hook like getUserRbac()
that under the hood calls hooks.
I don't know this is a hook (maybe the hook call is nested n level deep abstraction). I'll treat this as a normal function and invoke it inside conditions, loops, etc, which will break rules-of-hooks.
This will cause crash and bigger issue will be it crash only on some edge cases (when conditions changes, and hook calls mismatch is detected by React).
Describe the solution you'd like
Basically, something similar to ensure-custom-hooks-using-other-hooks
, which detects if current a function is using a hook and give warning/error.
Simplest way is just check,
- Inside current function, if any of the function's name start with "use".
Alternatives considered
No response
Additional context
No response