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
@babel/eslint-parser showing unexpected token errors when used with eslint-plugin-import and static class properties #12955
Comments
Hey @reintroducing! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly. If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite." |
The error is thrown from Acorn. According to https://github.com/benmosher/eslint-plugin-import#importparsers, you need to tell I think it is a bug of {
settings: {
"import/parsers": {
"@babel/eslint-parser": [".js"],
},
}
} |
ahhh, thanks for clarifying. are the root parser settings made available to rules? |
@JLHwung changing the parser does fix the test code i provided, however in the larger application that this resides in, the usage of
I get about 50 of those logged. I was under the impression that node_modules should be ignored, so not sure what is going on here either. EDIT: For what its worth we are like | | close to replacing moment with date-fns and have an actively open PR for the change that needs to be reviewed/merged, but it is interesting nonetheless that its erroring like this. |
@reintroducing I think that it's because you are using a |
@nicolo-ribaudo we are using the |
Yeah, for The reason for the difference is that there are two possible use cases: sometimes you want to keep your config where it applies ( The reason that |
@nicolo-ribaudo you're correct, offloading the preset extension to |
I'm closing this issue since it's not caused by Babel. Starting from the next release we'll suggest using |
Yeah but it's a question specific to ESLint, not related to Babel 😅 |
Bug Report
Current behavior
When running the linter with the plugins in the title, I'm seeing the following issues:
This is the result of including static class properties in the
Foo
file even though the associated babel configuration supports it. If you open examples/Foo.js and comment out lines 5-7, you don't see the errors anymore (other new errors are present as a result, but those are all valid).I'm attaching a zip file to demonstrate the issue clearly. Please download and unzip the file, run
npm i && npm run lint
to see the issue.eslint-issue.zip
Expected behavior
There should be no errors reported associated with the code.
Environment
Possible Solution
Additional context
This only surfaced after installing eslint-plugin-import but does not actually seem to be related to the plugin itself. I was actively discussing this in import-js/eslint-plugin-import#1995 with @ljharb but we don't think the issue is with that plugin rather something in the parser here.
The text was updated successfully, but these errors were encountered: