0

I'm using standardJS (eslint). For this line I do get a parsing error: Unexpected token = (null), which I do not understand:

static displayName = `WithData(${getComponentDisplayName(ComposedComponent)})`

Do I have to add any configuration? I am just using this in my package.json:

"standard": {
  "env": [
    "mocha"
  ],
  "global": [
    "React"
  ]
}
user3142695
  • 15,844
  • 47
  • 176
  • 332
  • Does helper funciton WithData start with a capital letter? – Alexander Vitanov Oct 23 '17 at 19:19
  • Not sure if this is the issue but I almost never see `\`` instead of a `'` – David Lee Oct 23 '17 at 19:20
  • Is this line within a `class`? It's probably expecting `displayName` [to be a method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static) as class-level fields aren't yet part of the language. They're currently a "Stage 3" [proposal](https://github.com/tc39/proposals#active-proposals). – Jonathan Lonowski Oct 23 '17 at 19:22
  • @DavidLee [Template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) – Jonathan Lonowski Oct 23 '17 at 19:22
  • @JonathanLonowski Learned something new today, thanks! – David Lee Oct 23 '17 at 19:24

1 Answers1

0

I've added the "parser": "babel-eslint" option for standardJS.

user3142695
  • 15,844
  • 47
  • 176
  • 332