Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upDisallow redundant return statements (no-useless-return) #694
Comments
feross
added
the
enhancement
label
Nov 22, 2016
feross
added this to the
standard v9 milestone
Nov 22, 2016
This comment has been minimized.
This comment has been minimized.
|
Yup, sounds good On Tue, Nov 22, 2016 at 10:18 PM Feross Aboukhadijeh <
|
This comment has been minimized.
This comment has been minimized.
|
What about early exits? if (!param) return
return 2 + 3Still work? Or if (cond) {
foo()
return
}
bar() |
This comment has been minimized.
This comment has been minimized.
|
@dcousens Yep, those will still work. The rule only prevents useless returns like: function foo () {
if (cond) {
console.log('hi')
return
}
} |
This comment has been minimized.
This comment has been minimized.
|
ACK then |
feross
added a commit
to standard/eslint-config-standard
that referenced
this issue
Feb 9, 2017
This comment has been minimized.
This comment has been minimized.
|
This will be part of standard v9. The ecosystem impact is 3 repos, with one statement in each requiring modification. |
feross commentedNov 22, 2016
A
returnstatement 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