JS:棉绒错误:意外令牌=

时间:2018-08-16 08:21:33

标签: javascript reactjs eslint standardjs

我确实收到标准的Js棉绒错误

/lib/with-apollo-client.js:7:24: Parsing error: Unexpected token =

此代码段(来自https://github.com/zeit/next.js/blob/canary/examples/with-apollo/lib/with-apollo-client.js

import initApollo from './init-apollo'
import Head from 'next/head'
import { getDataFromTree } from 'react-apollo'

export default (App) => {
  return class Apollo extends React.Component {
    static displayName = 'withApollo(App)' // <-
    static async getInitialProps (ctx) {
    // ...
    }
  }
}

这有什么问题?我正在使用standardJs 11.0.1

1 个答案:

答案 0 :(得分:0)

我认为这是因为您不能通过这种方式定义类属性,而无需进行转换:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#Instance_properties