简体   繁体   中英

JS: Lint error: Unexpected token =

I do get an standardJs lint error

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

for this snippet, which is from 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) {
    // ...
    }
  }
}

What is wrong with that? I'm using standardJs 11.0.1

I believe this is because you cannot define class properties in this way without a transform:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM