Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
redchair123 opened this issue Dec 1, 2012 · 4 comments
Closed

Comments

@redchair123
Copy link

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

@aarsilv
Copy link

aarsilv 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

@redchair123
Copy link
Author

@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 */
        }
        break;
    /* ... */
}

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

@jimisaacs
Copy link

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*/

@jimisaacs
Copy link

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 added a commit to lukaszzdanikowski/jshint that referenced this issue Apr 13, 2015
…eak after return statement

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

Closes jshint#757
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants