arrow function Parsing error: Unexpected token >

arrow function Parsing error: Unexpected token >

我在第 7 行遇到语法错误。我不明白为什么。这是下面的代码,下面是错误的图片。我意识到这个问题可能重复,但我找不到解决问题的方法。

var arr = [1, 2, 3];

arr.indexOf() == -1;

var arr = [{id: 1}, {id: 2}, {id: 3}];

var usersIds = arr.map(user => user.id);

arr.map(user => user.id).forEach( id => { console.log(id) } );

arr.map(user=> user.status = "ACTIVE");

.eslintrc:

{
  "plugins": [
    "more"
  ],

  "rules": {
    'more/no-void-map': 2,
    "more/no-c-like-loops": 2,
    "more/prefer-includes": 2,
    "more/no-then": 2,
    "more/no-window": 2,
    "more/no-numeric-endings-for-variables": 2,
    "more/force-native-methods": 2,
    "more/no-duplicated-chains": 2,
    "more/classbody-starts-with-newline": [2, 'never']
  }
}

错误:

我从新安装的软件包 eslint 收到错误,如果有帮助的话。

以下是我的 eslint 和 node 版本:

可能是您的 esLint 版本过时了。能不能再看看esLint的版本是否兼容es6的Arrow functions

或许你可以试试babel-eslint

您需要设置:

"parserOptions": {
    "ecmaVersion": 6
}

在您的 eslint 配置文件中启用 ES6 解析器。默认解析器是 ES5 解析器。箭头函数在 ES5 中无效。