当将以下代码传递给 jshint 时,它认为 if 条件中的换行符是错误的,并显示“Bad line breaking before '&&'。”
if (1 == 1
&& true) {
console.log("hello world");
}
但是,在 '&&' 之后有换行符是可以的。
if (1 == 1 &&
true) {
console.log("hello world");
}
为什么jshint认为前者是错的而后者是对的?
最佳答案
This may cause problems like semi colon insertion and old javascript parsers breaking. Please check a large range of browsers.
<罢工> This check can be disabled with laxbreak:true
罢工>。
laxbreak
选项即将弃用,但我不确定默认的 jshint 行为是否会改变。
关于javascript - 为什么 jshint 提示表达式中的换行符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14214160/