eslint Parsing error: Unexpected token =

2020-08-23 11:30发布

Why is eslint throwing this error? The Javascript runs without issue inside of React Native. The code was taken from the react-navigation example at : https://reactnavigation.org/docs/intro/

Javascript:

static navigationOptions = { header: null };

eslint error:

error  Parsing error: Unexpected token =

.eslintrc.js file:

module.exports = {
    "extends": "standard",
    "plugins": [
      "react",
      "react-native"
    ]
};

1条回答
Lonely孤独者°
2楼-- · 2020-08-23 11:49

The syntax is not yet standardised, but a stage-2 proposal for inclusion in Javascript (see "Class Fields" on https://github.com/tc39/proposals).

Try adding the following option above "extends" in your .eslintrc.js:

"parser": "babel-eslint",
查看更多
登录 后发表回答