Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upNested ternaries are rewritten to mean something else than the original code #1262
Comments
This comment has been minimized.
This comment has been minimized.
|
This is not good, would you mind filing a bug upstream with eslint, and then linking that issue here? Thanks |
This comment has been minimized.
This comment has been minimized.
|
Pasting the same code: /* eslint-disable no-console */
/* eslint-env browser */
/*eslint no-unneeded-ternary: ["error", { "defaultAssignment": false }]*/
var foos = ['fubar']
var foo = undefined
var defaultFoos = ['snafu']
var fubar = foos ? foos : foo ? [foo] : defaultFoos
console.log(fubar)in ESLints demo page produces the expected result. Maybe Standard is running an older version of ESLInt? Maybe related: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
stale
bot
commented
Jul 1, 2019
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
stale
bot
added
the
stale
label
Jul 1, 2019
stale
bot
closed this
Jul 8, 2019
This comment has been minimized.
This comment has been minimized.
|
This is fixed upstream and should be fixed in Standard 13, install with |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
anddoutoi commentedMar 25, 2019
•
edited
This is due to not taking into account Operator Precedence when rewriting the code.
Run the following code in the console:
Output is:
Go to https://standardjs.com/demo.html, paste the code (or use this demo github gist link) and click Correct errors using --fix .
The code is rewritten to:
Running this in a console outputs:
Standard has changed the actual meaning of the code.