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
[no-unnecessary-condition] What's the point of ignoreRhs: false
option?
#1017
Comments
Here's a use-case: xojs/eslint-config-xo-typescript#17 |
With rules it's much better to implement them with zero options and relax them over time as people find cases that are reasonable to want to ignore. In this case, the rule was implemented strictly, making the assumption that you didn't use short circuiting - Then someone decided to add the option, because they felt that it should be safe to allow short circuiting. Whilst adding a new option is a minor feature bump, turning on the option as default is a major breaking bump. I'm not sure if it's a good idea to turn it on by default - in 3.7 they are implementing optional chaining and nullish coalescing, which will handle many of the cases people use short circuiting for. That's a point for discussion however |
I guess that's about
That's a good point, I can see how someone would like to enforce that and it fits |
Sorry, I forget which one had what at PR time. I'm not sure if there is a case for having the option turned off in no-unnecessary-condition. |
Original author here, unless I'm misreading @ark120202's comment, it's not a question of changing the default; it's that the option is unnecessary and can be removed altogether. And I think they're right. Instead of using an option to determine when the right-hand-side should be checked, it should be done by the context of the expression. In the context of a condition, (e.g. I'll see if I can make the changes to make this happen. I'm not sure if it'll count as a breaking change to remove an option and unify both cases. |
Related: #1118 Removing an option is a breaking change. It is not backward compatible. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Commenting on an issue like this is not the place to report or discuss unrelated bugs. |
I am probably missing something, but reading through all of comments in original PR (#699) I couldn't find a reason to include
ignoreRhs
option. It probably made sense forstrict-boolean-expressions
, but I can't think of any cases where I'd wantreturn items.length && items[0].toUpperCase()
to be reported, since there is no condition part.At the same time I think RHS should always be reported when used in a condition, like:
(note:
items.length && items[0].toUpperCase()
from docs isn't correct example for this rule, sincetoUpperCase
returns possibly falsy value)EDIT: Actually, I think it might make sense for this to be behavior for
strict-boolean-expressions
as well. Looks like that option was added just to avoid breaking change, see palantir/tslint#4447.The text was updated successfully, but these errors were encountered: