Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Make `no-cond-assign` work for ternaries too #10091
What rule do you want to change?
Does this change cause the rule to produce more or fewer warnings?
How will the change be implemented? (New option, new default behavior, etc.)?
I guess new default?
Please provide some example code that this change will affect:
const str = (x = 0) ? 'zero' : 'non-zero'
What does the rule currently do for this code?
No warnings are produced
What will the rule do after it's changed?
Produce an "Unexpected assignment" warning for the condition of the ternary
Thanks for the proposal. I think your example is actually different from other cases that
const str = (x = (0 ? 'zero' : 'non-zero'))
In other words, the "condition" of the ternary isn't the assignment
referenced this issue
Mar 21, 2018
I'm not sure if this will really be a worthwhile change, due to the fact that replacing two
It might be better to use
I won't stand in the way of this. If we can get a champion for this rule (or if not-an-aardvark, VictorHom, or Aladdin-ADD champion and we get one more
I do think we might need to bikeshed on which of the cases I highlighted above should be supported by this rule. It would be good to agree on that before we accept the proposal.
@not-an-aardvark Agreed that we should definitely fix that case.
I'm more worried about