-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Disallow redundant return statements (no-useless-return) #694
Comments
Yup, sounds good On Tue, Nov 22, 2016 at 10:18 PM Feross Aboukhadijeh <
|
What about early exits? if (!param) return
return 2 + 3 Still work? Or if (cond) {
foo()
return
}
bar() |
@dcousens Yep, those will still work. The rule only prevents useless returns like: function foo () {
if (cond) {
console.log('hi')
return
}
} |
ACK then |
This will be part of standard v9. The ecosystem impact is 3 repos, with one statement in each requiring modification. |
A
return
statement with nothing after it is redundant, and has no effect on the runtime behavior of a function. This can be confusing, so it’s better to disallow these redundant statements.http://eslint.org/docs/rules/no-useless-return
The text was updated successfully, but these errors were encountered: