2
这是我.eslintrceslint抱怨getInitialProps
{
"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声明除了添加压制注释?
也许你需要使用巴贝尔,eslint由于'静态async' ? – Scott
getInitialProps为什么是异步?这可能是你的问题。 – robbymurphy