Using the Atom editor, with the linter-eslint package installed, I have a node.mjs script that uses ES6 module's import statement to import various node modules.
The script runs fine when I run it with node's --experimental-modules flag. However, while editing with Atom, linter-eslint says:
Parsing error: Unexpected token import (Fatal)
This parsing error is NOT being caused by the ecmascript "import" statements that I have at the top of my code file. Instead, it is actually caused by the fact that eslint considers "import" a reserved token that can only be used in import statements and therefore cannot be used by the import.meta object (as shown in this code line below):
const __dirname = path.dirname(new URL(import.meta.url).pathname);
My .eslintrc.js file has these parser options:
'parserOptions':
{
'ecmaVersion': 2018,
'sourceType': 'module'
}
How can I configure eslint to ignore this particular error?
"parser": "babel-eslint"
eslint config as in the linked issue? – BergiparserOptions
. – Bergieslint.parserOptions.parser = 'babel-eslint'
. However, I should be setting it how you said:eslint.parser = 'babel-eslint'
. These properties are of the main eslint object; they're NOT properties of theparserOptions
object. – Lonnie Best