Why did eslint report the wrong no-mixed-operators?

const invalidTunnelIds = result.data && result.data.invalidTunnelIds || []

this code feels normal. I don"t know why eslint reported it wrong.

Mar.20,2021

your code may be executed correctly, but eslint's suggestion is that you should be clear about your intention. It is possible that your intention is
result.data & & (result.data.invalidTunnelIds | | [])
or
(result.data & & result.data.invalidTunnelIds) | | []
but no matter which intention it is, it is recommended that you clearly mark it. Eslint is not only to ensure the correct execution of your code, but also to standardize your code


eslint checks that the code specification is irregular and does not necessarily consider the logic of the code. This rule tells you not to & & | mix
if you don't want to follow this rule, you can ignore

in the rule field of the .eslintrc.js file.
'no-mixed-operators': [0],
Menu