score:290

Accepted answer

i think the problem is that you are trying to use the deprecated babel-eslint parser, last updated a year ago, which looks like it doesn't support es6 modules. updating to the latest parser seems to work, at least for simple linting.

so, do this:

  • in package.json, update the line "babel-eslint": "^10.0.2", to "@babel/eslint-parser": "^7.5.4",. this works with the code above but it may be better to use the latest version, which at the time of writing is 7.16.3.
  • run npm i from a terminal/command prompt in the folder
  • in .eslintrc, update the parser line "parser": "babel-eslint", to "parser": "@babel/eslint-parser",
  • in .eslintrc, add "requireconfigfile": false, to the parseroptions section (underneath "ecmaversion": 8,) (i needed this or babel was looking for config files i don't have)
  • run the command to lint a file

then, for me with just your two configuration files, the error goes away and i get appropriate linting errors.

score:-3

"@babel/eslint-parser" depends on "@babel/core". so after "npm install @babel/eslint-parser -s", u should npm i @babel/core -s

score:0

in visual studio code, remove eslint extension, and install again.

score:1

this can happen with quite a lot of lately released frameworks like vuejs or nuxt, mostly because of the usage of esm modules (not fully or at all supported by older node.js versions).

the fastest approach for this is to use something like nvm, after installing it, you could run:

  • nvm i 16 (v16 is the latest lts as of time of writing)
  • nvm use 16

and you'll be running the project with a full esm support.
you can double check that by running node -v.


Related Query

More Query from same tag