eslint-react icon indicating copy to clipboard operation
eslint-react copied to clipboard

[feat] ensure-custom-hooks-follow-naming-convention

Open LalitSinghRana opened this issue 9 months ago • 0 comments

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

LalitSinghRana avatar Apr 26 '24 18:04 LalitSinghRana