tools: enable no-else-return ESLint rule#11159
Conversation
benchmark/_http-benchmarkers.js
Outdated
There was a problem hiding this comment.
I think these blank lines should be removed.
joyeecheung
left a comment
There was a problem hiding this comment.
Rubber stamp-y LGTM except style nits
test/parallel/test-fs-utimes.js
Outdated
test/parallel/test-buffer-fill.js
Outdated
test/parallel/test-buffer-fill.js
Outdated
lib/url.js
Outdated
lib/path.js
Outdated
lib/fs.js
Outdated
thefourtheye
left a comment
There was a problem hiding this comment.
I am not sure how the linter missed the indentation problems.
lib/_stream_readable.js
Outdated
lib/path.js
Outdated
Currently, it does not check the indentation of comments. This is planned to change in the next major release. |
cjihrig
left a comment
There was a problem hiding this comment.
LGTM with the extra empty lines removed.
|
I personally find it easier to visually parse code with the |
lib/url.js
Outdated
There was a problem hiding this comment.
Still some blank lines like this.
There was a problem hiding this comment.
That's the only one, I think, and that one makes sense to me. Will remove it if anyone disagrees.
|
Also if we were using |
If there is a `return` in an `if` block, an `else` block is unnecessary. It can simply be moved after the `if` block. This is in preparation for a lint rule to enforce this practice.
1735e53 to
078670e
Compare
|
I'm going to honor the preference expressed by @silverwind and @addaleax and close this. I don't feel strongly about it and it doesn't seem to come up as something in PR review comments. If someone else feels far more strongly about this than I do, feel free to re-open, comment, or open another PR. |
|
I missed this until now, but belatedly, LGTM, I like the else-less style. It cuts down on indentation, and makes clear that once a conditional has been handled by return, code can continue indentless and read more linearly. But I don't feel really strong about it, I can read the code either way. |
If an if block contains a return statement, the else block becomes unnecessary. Its contents can be placed outside of the block.
Refs: http://eslint.org/docs/rules/no-else-return
Inspired by #11148
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
tools test lib benchmark