-
-
Notifications
You must be signed in to change notification settings - Fork 412
prefer-ternary
: Check if + return/throw
#1221
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
cb1a37f
to
9bbfe66
Compare
//cc @fregante @JounQin https://github.com/fisker/eslint-plugin-unicorn/pull/282/files I run this on our codebase, feel losing readability, look good to you? |
Indeed there’s an existing issue with that rule:
a possible improvement would be to put the condition on its own constant. Edit: #1079 (comment) |
LGTM except @fregante mentioned. |
This if (a) {
return 1;
}
if (b) {
return 2;
}
if (c) {
return 3;
} else {
return 4;
} seems fine to fix to if (a) {
return 1;
}
if (b) {
return 2;
}
return c ? 3 : 4; But if (a) {
return 1;
}
if (b) {
return 2;
}
if (c) {
return 3;
}
return 4; seems bad to fix to if (a) {}
if (b) {}
return c ? 3 : 4 |
Example this line https://github.com/fisker/eslint-plugin-unicorn/pull/282/files#diff-b6b472744fff513bca9c7577f37bc75b74371f8f7fab1621e4aae16ce15793dcL53, there are many other |
Agreed |
Closing as this has been open for multiple years now without any activity. |
Fixes #1116