【发布时间】:2017-10-20 18:10:08
【问题描述】:
这是我的 .eslintrc
{
"plugins": ["react"],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"es6": true,
"browser": true,
"node": true,
"mocha": true
},
"extends": ["eslint:recommended", "plugin:react/recommended", "standard"],
"rules": {}
}
这是我的组件:
class Index extends React.Component {
static async getInitialProps({ req }) {
....
}
}
Eslint 抱怨 getInitialProps:
Parsing error: Unexpected token getInitialProps
除了添加禁止注释之外,还有什么方法可以让 eslint 接受 getInitialProps 声明?
【问题讨论】:
-
可能由于
static async而需要使用babel-eslint? -
为什么 getInitialProps 是异步的?这可能是您的问题。