Why does jshint complain about linebreak within expression?

Chiel ten Brinke picture Chiel ten Brinke · Jan 8, 2013 · Viewed 8.4k times · Source

When passing the following code to jshint, it considers the linebreak in the if-condition to be bad, saying "Bad line breaking before '&&'."

if (1 == 1 
        && true) {
    console.log("hello world");
}

However, having the linebreak after '&&' is fine.

if (1 == 1 && 
        true) {
    console.log("hello world");
}

Why does jshint consider the first to be wrong and the latter to be right?

Answer

bfavaretto picture bfavaretto · Jan 8, 2013

According to a discussion on GitHub:

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.

The laxbreak option is on its way to deprecation, but I'm not sure if the default jshint behavior will change.