Jshint: Allow line breaking before && or ||

Created on 24 Feb 2011  ·  7Comments  ·  Source: jshint/jshint

For multiple line conditions it might be more readable if the && and || are at the beginning of the line. JSHint however does not allow this, resulting in the error "Bad line breaking before '&&'."

if (a
    && b
    && c
    && (
        d
        || e
    )
){
    /* yay! */
}

Example: http://jsfiddle.net/AkeF3/1/

Most helpful comment

This error is still in 2.7.0.

I added "-W014": true to .jshintrc to get rid of this error (https://github.com/jshint/jshint/blob/e47168f5aa9576819830554f1b37dc0d49b76d31/src/messages.js#L90).

All 7 comments

This may cause problems like semi colon insertion and old javascript parsers breaking. Please check a large range of browsers.

You can use laxbreak:true to bypass line breaking checks.

@Raynos are there seriously any parser that deviate that much from the spec?

:+1:

This error is still in 2.7.0.

I added "-W014": true to .jshintrc to get rid of this error (https://github.com/jshint/jshint/blob/e47168f5aa9576819830554f1b37dc0d49b76d31/src/messages.js#L90).

@Raynos : Can you recommend a resource for which JS parsers might meet this failure?

This may cause problems like semi colon insertion and old javascript parsers breaking. Please check a large range of browsers.

Why was this closed? Is it considered a duplicate of https://github.com/jshint/jshint/issues/735?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NemoStein picture NemoStein  ·  7Comments

voronianski picture voronianski  ·  8Comments

TheSavior picture TheSavior  ·  3Comments

stefanuddenberg picture stefanuddenberg  ·  7Comments

Daniel-Hug picture Daniel-Hug  ·  3Comments