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
.eslintr
Not sure about it but try to rename your file to .eslintrc and just use
{
"extends": "airbnb",
"plugins": ["react"]
};
Also be sure you have the required packages installed. github.com/airbnb/javascript
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.
Based on @Manohar Reddy Poreddy answer, if you are also using Prettier in VSCode, your .eslintrc.js
file should look like:
module.exports = {
env: {
commonjs: true,
node: true,
browser: true,
es6: true,
jest: true,
},
//extends: ['eslint:recommended', 'plugin:react/recommended'],
extends: ['plugin:prettier/recommended'],
globals: {},
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['react', 'import', 'react-hooks', 'prettier'],
ignorePatterns: ['node_modules/'],
rules: {
'prettier/prettier': 'error',
},
settings: {
react: {
version: 'latest', // "detect" automatically picks the version you have installed.
},
},
};
Spent 30 mins - trying all solutions but dint work, so sharing this one.
The issue is seen with new react app
, and in Visual Code
, even at this time - Apr 2020.
.eslintrc.js
in the root folder (beside package.json
, or beside /src/
directory).eslintrc.js
.eslintrc.js
file contents:
module.exports = {
env: {
commonjs: true,
node: true,
browser: true,
es6: true,
jest: true,
},
extends: ["eslint:recommended", "plugin:react/recommended"],
globals: {},
parser: "babel-eslint",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: "module",
},
plugins: ["react", "import", "react-hooks"],
ignorePatterns: ["node_modules/"],
rules: {},
settings: {
react: {
version: "latest", // "detect" automatically picks the version you have installed.
},
},
};
Hope that helps.