ESLint experimentalObjectRestSpread不适用

时间:2016-08-19 07:28:47

标签: javascript reactjs eslint babel

ESLint仍在投掷error Parsing error: Unexpected token ..,我似乎无法弄明白为什么。

.eslintrc.js

module.exports = {
    extends: "devmountain/react-config"
    , rules: {
        quotes: [ 1, "double" ]
    }
    , "ecmaVersion": 6
    , "ecmaFeatures": {
        "experimentalObjectRestSpread": true
    }
};

here

延伸

有问题的代码:this.setState( { ...this.state, editorState } );

2 个答案:

答案 0 :(得分:2)

ecmaFeaturesecmaVersion选项位于parserOptions下。例如:

...
"extends": "devmountain/react-config",
"parserOptions": {
    "ecmaFeatures": {
        "experimentalObjectRestSpread": true
    },
    "ecmaVersion": 6
},
...

答案 1 :(得分:0)

在v6.0.0(及更高版本)中,已弃用的experimentalObjectRestSpread选项为removed

这是新代码:

{
  "parserOptions": {
    "ecmaVersion": 2018
  }
}