question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@babel/eslint-parser does not have default parserOptions (but babel-eslint did)

See original GitHub issue

Bug 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kaicataldocommented, Aug 17, 2020

Apologies for the delay on my end. I’ve verified this and located the source of the bug. Working on a PR right now.

0reactions
kaicataldocommented, Aug 4, 2020

Thanks for doing some detective work. Will take a look today or tomorrow so we can hopefully get this fixed ASAP.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found