-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
independently-controllable rules #7
Comments
@jrr This is a solid suggestion 👍 Initially, I went with the approach It can be changed, though. I will consider splitting the rule into multiple ones with lesser individual scopes Out of curiosity, what is your use case for enabling hooks in regular functions? 😄 |
Initially I'd like to set all the rules I'm already in compliance with to For this particular rule, though, there may be some places we'll never comply, and think it's Probably Okay. For example, when we need to call a hook from tests or storybook, which make heavy use of lambdas. |
I gave some thought into this issue. Having multiple rules means that the parser and rule logic would have to be invoked multiple times due to the limitations of TSLint. One walker cannot report violations of multiple rules. This can still be achieved, it's just that the performance may be worse than when having a single rule with controllable options. How about adding options to a single "react-hooks-nesting": {
"severity": "error",
"options": {
"allow-using-hooks-in-all-functions": true
}
} That would make the rule walker ignore violations connected with checking the function's name. What do you think? Would that be sufficient? |
Thanks for looking into this!
Yikes, that's disappointing. Do you happen to know if ESLint (with the ts parser) has this limitation? Your proposal would unblock me on this issue, but doesn't help with the general goal of granularly tightening rules, gradually over time. I wouldn't bother unless anyone else is clamoring for it; I'll probably just keep severity set to warning, suppress in source code, and/or try my luck with ESLint. |
I think I might have worded that incorrectly. I meant that the walker and rule logic would have to be invoked multiple times. The parser runs once and parses the file into an AST that is then provided to every rules' walkers. Still, the walker (the class that explores the AST) has to once for every rule and for every This is not as bad as running the parser multiple times but still adds some overhead compared to a single rule with one walker that reports violations conditionally, based on the options.
Sure, I will consider splitting it into multiple rules in the future, but currently, I do not have the time to implement it. I heard |
Closing because the world has moved on to eslint. |
I'd like to disable
A hook cannot be used inside of another function
, but keep all the others (e.g.A hook cannot appear inside an if statement
), but they seem to be all fall under the rulereact-hooks-nesting
.Can rules be independently controlled?
The text was updated successfully, but these errors were encountered: