我在方括号上得到了意想不到的代币。
我已经尝试设置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
}
}我应该能够构建代码,但eslint抛出错误,说意外令牌。
发布于 2019-08-20 08:35:02
请注意,支持JSX语法与支持React不同。React将ESLint无法识别的特定语义应用于JSX语法。如果您正在使用eslint-plugin-react并希望使用React语义,我们建议您使用React。同样,支持ES6语法与支持新的ES6全局变量(例如,像Set这样的新类型)是不同的。对于ES6语法,请使用{ "parserOptions": { "ecmaVersion": 6 } };对于新的ES6全局变量,请使用{ "env": { "es6": true } }。
发布于 2019-08-20 13:26:49
尝试以下配置:
eslintrc.js:
module.exports = {
root: true,
"extends": "eslint:recommended",
};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": {
}
}https://stackoverflow.com/questions/57565238
复制相似问题