Search code examples
reactjsphpstormstandards

Unexpected token = for a arrow Function using StandardJS


Why the Standard JS is saying that the sign = is a unexpected token? I'm using PhpStorm.

The code works perfectly, I'm just following the tutorial from https://github.com/whoisandy/react-rangeslider and got this error.

handleOnChange = (value) => {
 this.setState({
  volume: value
 })
}

enter image description here


Solution

  • Error comes from Standard linter, not from PHPStorm parser, that's why changing JavaScript language version in preferences doesn't help... You are using ES7 proposal for class properties (https://github.com/tc39/proposal-class-public-fields). But it's not yet a part of any spec, and the parser used by Standard linter doesn't support it. You need using a different parser here - see https://standardjs.com/#how-do-i-use-experimental-javascript-es-next-features