-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Enable the no-else-return
ESLint rule
#7935
Enable the no-else-return
ESLint rule
#7935
Conversation
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.
Looks good. I think we need add smarts to the preprocessor, so it would be able to remove statements after throw/return (to remove rest of the // eslint-disable-line no-else-return
)?
@@ -283,9 +283,8 @@ function approximateFraction(x) { | |||
// Select closest of the neighbours to x. | |||
if (x_ - a / b < c / d - x_) { | |||
return x_ === x ? [a, b] : [b, a]; | |||
} else { | |||
return x_ === x ? [c, d] : [d, c]; |
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.
let's introduce e.g. result
local that will store return value
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.
Sure; I've added a result
variable now.
That'd be nice, but I think it might be better suited for a followup PR. /botio test |
See #7942 |
} | ||
return (108 / 841) * (x - 4 / 29); |
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.
This comment was lost somehow: could you add 'result' local here as well?
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.
Sure, it's fixed now!
Using `else` after `return` is not necessary, and can often lead to unnecessarily cluttered code. By using the `no-else-return` rule in ESLint we can avoid this pattern, see http://eslint.org/docs/rules/no-else-return.
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/65f8a3f7f9a413d/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/65f8a3f7f9a413d/output.txt Total script time: 2.24 mins Published |
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/fc59d910b062e96/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/73fc0b230c841e6/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/73fc0b230c841e6/output.txt Total script time: 25.68 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/fc59d910b062e96/output.txt Total script time: 26.69 mins
|
Thank you! |
Enable the `no-else-return` ESLint rule
Using
else
afterreturn
is not necessary, and can often lead to unnecessarily cluttered code. By using theno-else-return
rule in ESLint we can avoid this pattern, see http://eslint.org/docs/rules/no-else-return.Please note: This is one ESLint rules that could perhaps be considered a bit too opinionated by some people, so even though I'd like enable it, I understand if others do not.
Easier reviewing with: https://github.com/mozilla/pdf.js/pull/7935/files?w=1.