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
newline-before-return: false positive #6090
Comments
Here is the minimal code sample reporting this error: a=function() {
{// dummy
}
return} Going to fix it. |
It looks like a bug in espree. For some reason there is leading comment for return statement. Didn't find why there it is atm. |
Pinging @kaicataldo: Didn't you fix something similar to this in espree recently? |
Yes - thought I had finally found a solution that covered all cases in Espree. Will take a look at this ASAP - thanks for investigating, @zxqfox! |
Thank you for finishing this ;-) |
@zxqfox Actually, did you confirm that this issue occurs with Espree? I'm noticing the issue creator is using babel-eslint, which uses Babel's Babylon parser. Babylon uses essentially the same algorithm as Espree for comment attachment, and the changes I made to Espree that fix this haven't been ported over yet. It's a known issue: babel/babel-eslint#289 |
@kaicataldo My bad. I should run What you think about tests? Do we need them? |
I added tests when I bumped the Espree version in ESLint, I'm always for more test coverage if there are cases we aren't testing already :D I don't remember there being tests for the cases in the original post - i.e. comments inside and at the end of 'while' and 'for' loops. The bug in question would happen when a block would end with a comment inside it - it would then get attached as a leading comment to the next node. Sorry, not at my computer right now or I'd check! |
@justineakehurst Would you mind checking if this happens with the default parser? If not, this is unfortunately out of our hands, but it does look like the babel-eslint is aware of the issue (see comment above) |
@kaicataldo I confirmed that when I switch the parser to 'espree' from 'babel-eslint', the problem goes away. |
@justineakehurst Thanks! I'm going to close this now for the reasons above. |
What version of ESLint are you using?
v2.9.0
What parser (default, Babel-ESLint, etc.) are you using?
babel-eslint
Please show your full configuration:
Plus .eslintrc:
What did you do? Please include the actual source code causing the issue.
also, here:
What did you expect to happen?
I would expect that newline-before-return would think I had a newline before the return, as the code above shows.
What actually happened? Please include the actual, raw output from ESLint.
The text was updated successfully, but these errors were encountered: