-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
tools: enable no-else-return ESLint rule #11159
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
Conversation
benchmark/_http-benchmarkers.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these blank lines should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rubber stamp-y LGTM except style nits
test/parallel/test-fs-utimes.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is off
test/parallel/test-buffer-fill.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is off
test/parallel/test-buffer-fill.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is off
lib/url.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is deleted
lib/path.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is off
lib/fs.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is off
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how the linter missed the indentation problems.
lib/_stream_readable.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation.
lib/path.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation.
Currently, it does not check the indentation of comments. This is planned to change in the next major release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still some blank lines like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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