eslint解析错误:意外的令牌=

Jer*_*emy 8 javascript reactjs eslint react-native

为什么eslint会抛出这个错误?Javascript在React Native中运行没有问题.该代码取自反应导航示例:https://reactnavigation.org/docs/intro/

使用Javascript:

static navigationOptions = { header: null };
Run Code Online (Sandbox Code Playgroud)

夹板错误:

error  Parsing error: Unexpected token =
Run Code Online (Sandbox Code Playgroud)

.eslintrc.js文件:

module.exports = {
    "extends": "standard",
    "plugins": [
      "react",
      "react-native"
    ]
};
Run Code Online (Sandbox Code Playgroud)

ben*_*xen 23

语法尚未标准化,但是包含在Javascript中的第2阶段提议(请参阅https://github.com/tc39/proposals上的"类字段" ).

尝试在.eslintrc.js中的"extends"上面添加以下选项:

"parser": "babel-eslint",
Run Code Online (Sandbox Code Playgroud)