How Can Es-lint Be Configured To Warn/error If Usestate Is Used
I've not been able to find a rule, but is it possible to throw a warning or an error if someone attempts to reach for useState instead of the state provider? I'm hoping I don't nee
Solution 1:
You can use no-restricted-syntax
All you need to do is play around with AST Explorer. I have done it for you and you need to add this to your .eslintrc
file in rules
section.
In the example below depending upon your need you can either throw it as an error
or warn
.
"no-restricted-syntax":["error",{"selector":"CallExpression[callee.name='useState']","message":"Please use state provider instead."}],
Post a Comment for "How Can Es-lint Be Configured To Warn/error If Usestate Is Used"