Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Auto fix `no-unneeded-ternary` changes code behavior #8507
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
The following code (line 3) is considered an error by the
var value = 'a' var canSet = true var result = value ? value : canSet ? 'unset' : 'can not set' // NOTE: `result` is 'a'
var value = 'a' var canSet = true var result = value || canSet ? 'unset' : 'can not set' // NOTE: `result` is 'unset'
What did you expect to happen?
Parens should probably be added in this situation. This code would have maintained the same behavior:
var result = value || (canSet ? 'unset' : 'can not set')
Related issue: standard/standard#866