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