-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
react/require-render-return
doesn't account for switch statement
#543
Comments
If the return is wrapped in an render() {
var test = true;
if (test) {
return <div></div>;
}
else {
return <div></div>;
}
} |
I tried to fix this in jseminck@2a51f23 and jseminck@0bf8e3f It now works with switch and if statements. I also added tests for a nested if and switch statement. Additionally added another commit that makes sure that every child of the if and switch statements has a return statement: @yannickcr @ljharb would be good if any of you could take a look at the code as I'm not really all that familiar with ASTs. It was quite challenging (but definitely a fun exercise). |
The tests look good (although the error messages could be more helpful/tailored to the error condition) - I'm not up to the task of reviewing the AST stuff. |
I'll look at improving the error message(s) and documentation and then make a PR. Also I ran into the same issue reported in #542 already, e.g. that |
Thanks for the details and the fix, but I rewrote the rule to use the component detection and fix #542 at the same time. |
This example throws error
Your render method should have return statement
even though an element is being returned.The text was updated successfully, but these errors were encountered: