【发布时间】:2020-11-12 09:01:27
【问题描述】:
我有一个非常简单的 React reducer,而 eslint 抱怨我如何传播状态。下面是代码。我预计会没事的。我也在下面粘贴我的 .eslintrc。
function quizReducer(state, action) {
switch (action.type) {
case RESET_QUIZ:
return {
...state,
currentQuestion: 0,
currentAnswer: '',
}
default:
return state
}
}
eslintrc
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"destructuring": true,
"spread": true,
"experimentalObjectRestSpread": true
}
},
"plugins": ["react-hooks"],
"rules": {
//additional rules here
"react-hooks/rules-of-hooks": "error"
}
}
错误在...状态行并且是
ESLint: Parsing error: Unexpected token ...
【问题讨论】:
-
“抱怨”——你能说得具体一点吗?
-
抱歉,忘记添加了。我会更新问题(正忙于格式化)
标签: javascript reactjs ecmascript-6 eslint