[英]error eslint parsing: unexpected token eslint error
i am getting unexpected token on the square bracket. 我在方括号中得到了意外的令牌。
i have tried setting the eslint parameters and install babel-eslint but nothing works for me. 我曾尝试设置eslint参数并安装babel-eslint,但对我来说没有任何用。
const [state,dispatch] = useReducer(createUserReducer,
{
email: '',
password: '',
verifyPassword: ''
});
my eslint configuration:
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true,
"blockBindings": true,
"experimentalObjectRestSpread": true
}
},
"extends": "rallycoding",
"rules": {
"react/require-extension": "off",
"global-require": 0,
"no-unused-vars": 0,
"unexpected-token": 0
}
}
I should be able to build the code but eslint is throwing error saying unexpected token. 我应该能够构建代码,但是eslint抛出错误,提示意外的令牌。
Please note that supporting JSX
syntax is not the same as supporting React
. 请注意,支持
JSX
语法与支持React
并不相同。 React
applies specific semantics to JSX
syntax that ESLint doesn't recognize. React
将特定的语义应用于ESLint无法识别的JSX
语法。 We recommend using eslint-plugin-react
if you are using React
and want React
semantics. 如果您使用
React
并需要React
语义,建议使用eslint-plugin-react
。 By the same token, supporting ES6 syntax is not the same as supporting new ES6
globals (eg, new types such as Set). 同样,支持ES6语法与支持新的
ES6
全局变量(例如,诸如Set之类的新类型)并不相同。 For ES6
syntax, use { "parserOptions": { "ecmaVersion": 6 } }
; 对于
ES6
语法,请使用{ "parserOptions": { "ecmaVersion": 6 } }
; for new ES6
global variables, use { "env": { "es6": true } }
. 对于新的
ES6
全局变量,请使用{ "env": { "es6": true } }
。
Try these configurations : 尝试以下配置:
eslintrc.js :
eslintrc.js:
module.exports = {
root: true,
"extends": "eslint:recommended",
};
eslintrc.json :
eslintrc.json:
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"google"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.