We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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-useless-ternary
I was looking for a rule to forbid ternary that equivalent to a "logical or" expression.
The only thing I got is no-unneeded-ternary rule, it checks x ? x : 1 behind an option. Even if I set defaultAssignment: false, this rule only check identifier
no-unneeded-ternary
x ? x : 1
defaultAssignment: false
foo ? foo : bar;
foo.bar ? foo.bar : foo.baz
foo || bar;
foo.bar || foo.baz;
We should check all expressions instead of identifiers only.
This rule is safe to fix to logical or(||), but sometimes ?? operator maybe better.
||
??
So, we may want to use the suggestions API to draw attention?
The text was updated successfully, but these errors were encountered:
Missing case, not everyone enables no-negated-condition
!bar ? foo : bar;
Sorry, something went wrong.
Accepted.
another case
foo?.bar ? foo.bar : qux
Should we name it prefer-logical-operator or prefer-logical-operator-over-ternary to be more specific?
prefer-logical-operator
prefer-logical-operator-over-ternary
fisker
Successfully merging a pull request may close this issue.
Description
I was looking for a rule to forbid ternary that equivalent to a "logical or" expression.
The only thing I got is
no-unneeded-ternary
rule, it checksx ? x : 1
behind an option. Even if I setdefaultAssignment: false
, this rule only check identifierFail
Pass
Additional Info
We should check all expressions instead of identifiers only.
This rule is safe to fix to logical or(
||
), but sometimes??
operator maybe better.So, we may want to use the suggestions API to draw attention?
The text was updated successfully, but these errors were encountered: