@babel/eslint-parser does not have default parserOptions (but babel-eslint did)
See original GitHub issueBug Report
I just tried out replacing babel-eslint
with the @babel/eslint-parser
, and the first thing I encountered were a few instances of the error:
Parsing error: ImportDeclaration should appear when the mode is ES6 and in the module context
After doing a little digging, I realized that I needed to set the parserOptions in my eslint config like this:
parserOptions: {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"modules": true
}
}
I’m filing this as a bug report because babel-eslint
provides default parserOptions here but the new @babel/eslint-parser
package does not.
I’d vote that either these defaults should be used for @babel/eslint-parser
as well, or else there should be a very prominent message in the package’s README explaining that defaults are no longer provided (I bet that’d save more issues like this one being opened in the future 😃 )
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Declaring babel plugins for @babel/eslint-parser in .eslintrc
cwd() is B directory, but the @babel/xxx deps is in cli node_modules.The babel/core can not find plugins in B . Parsing error: Cannot...
Read more >Updating babel-eslint to @babel/eslint-parser for React apps
From npm 7 peer dependencies are installed by default. And then update our parserOptions to pass this option through to Babel:
Read more >@babel/eslint-parser - NPM Package Overview - Socket
ESLint's default parser and core rules only support the latest final ECMAScript standard and do not support experimental (such as new features) ...
Read more >babel/parser
The Babel parser (previously Babylon) is a JavaScript parser used in Babel. The latest ECMAScript version enabled by default (ES2020). Comment attachment.
Read more >@babel/eslint-parser - npm
ESLint parser that allows for linting of experimental syntax transformed by Babel. Latest version: 7.19.1, last published: 3 months ago.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Apologies for the delay on my end. I’ve verified this and located the source of the bug. Working on a PR right now.
Thanks for doing some detective work. Will take a look today or tomorrow so we can hopefully get this fixed ASAP.