I have a problem with eslint, it gives me [Parsing Error The keyword import is reserve] this is only occur in sublime, in atom editor work well. I have eslint
.eslintrc.js
module.exports = {
"extends": "airbnb",
"plugins": [
"react"
]
};
package.json
{
"name": "paint",
"version": "0.0.0",
"description": "paint on the browser",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"paint",
"javascript"
],
"author": "",
"license": "ISC",
"devDependencies": {
"browserify": "^11.2.0",
"eslint": "^2.2.0",
"eslint-config-airbnb": "^2.1.1",
"eslint-plugin-react": "^3.11.2",
"gulp-babel": "^5.2.1",
"gulp-clean": "^0.3.1",
"gulp-stylus": "^2.2.0",
"vinyl-source-stream": "^1.1.0"
}
}
Spent 30 mins - trying all solutions but dint work, so sharing this one.
The issue is seen with
new react app
, and inVisual Code
, even at this time - Apr 2020..eslintrc.js
in the root folder (besidepackage.json
, or beside/src/
directory).eslintrc.js
.eslintrc.js
file contents:Hope that helps.
i also got this error in a meteor project and i could solved it setting sourceType to "module" more details can be found in Eslint docs: http://eslint.org/docs/user-guide/configuring#specifying-parser-options
This config worked for me. (I am using create-react-app but applicable to any eslint project)
.eslintrc (create file in root if it doesnt exist)
Add this to the root of your .eslintrc
and make sure to run:
The eslint option that solves the "The keyword import is reserved" error is
parserOptions.sourceType
. Setting it to"module"
allows theimport
keyword to be used..eslintrc
Docs: https://eslint.org/docs/user-guide/configuring#specifying-parser-options
I found this issue while creating the vue project (Used Editor: Visual Code)
Install babel-eslint package -> npm install babel-eslint
Create the .eslintrc.js file and add below code
module.exports = { root: true, parserOptions: { 'sourceType': 'module', parser: 'babel-eslint'
} }
=> npm run serve, that error will be resolved like magic.