I have the following code in JavaScript:
var a = num ? 5 : "five";
Code seems to be workable. But JSLint warns like this:
#2 Expected '?' at column 9, not column 15. var a = h ? 5 : "qwerty"; // Line 10, Pos 15 #3 Expected ':' at column 9, not column 19. var a = h ? 5 : "qwerty"; // Line 10, Pos 19
So what the problem is? How to disable such warnings?
Its opinion is that:
The ternary operator can be visually confusing, so
?
question mark and:
colon always begin a line and increase the indentation by 4 spaces.var a = h ? 5 : "qwerty";
To fix either comply with the rule or tick messy whitespace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With