add option or comment hint to ignore 'Unreachable break after return' #757

Niggler opened this Issue Dec 1, 2012 · 4 comments


None yet

3 participants

Niggler commented Dec 1, 2012

I specifically ask about this condition because any straight-forward lex-compatible parser generator will use this pattern.

Zugwalt commented Feb 1, 2013

I would love this as well as often when debugging I'll just throw in a return statement but then jshint (run automatically) complains

Niggler commented Feb 1, 2013

@Zugwalt what I ended up doing was modifying my generator to wrap the user specified code in an if(true) block.

For example:

switch(foo) {
    /* ... */
    case bar:
        if(true) {
            /* insert code here */
    /* ... */

This is equivalent to the code without the braces and jshint doesn't complain :)

@Niggler Niggler closed this Apr 6, 2013

I don't know if this is older than this functionality, but I was just looking at the source, and the docs for JSLint, and this could do the trick as well

/*jshint -W027*/

The documentation says that sytax turns off those warnings everywhere, so I'm not sure if function scope works with those. Also I would like to note another use case for this is the use of a preprocessor. It would be nice to be able to lint before and after preprocessing if you take the time to set jshint options. So far I'm going to try the approach I just mentioned.

Update: It is function scoped.

@lukaszzdanikowski lukaszzdanikowski added a commit to lukaszzdanikowski/jshint that referenced this issue Apr 13, 2015
@lukaszzdanikowski lukaszzdanikowski [[FEAT]] Add option 'brkret' to suppress warning about unreachable br…
…eak after return statement

This options suppresses warnings about unreachable break after return. It is useful especially
with auto generated code.

Closes #757
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment