Jez
Jez

Reputation: 2454

SonarQube analysis fails on ES2015 syntax - but it's apparently supported?

It says here (http://docs.sonarqube.org/display/PLUG/JavaScript+Plugin) that the SonarQube JS plugin has supported ES6 (which I believe is also know as ES2015) since version 2.0.

I have version 2.8 installed in SonarQube 4.5.6, but I see errors like this in my analysis log -

17:54:58.185 ERROR - Parse error at line 21 column 17:

     'individualIndex': -1,
     'individualName': {},
     'individualSearchResults': [],
     'individualEmail': '',
     'individualMobile': '',
     'dunsNumberRequired': false,
     'allDone': false
    });
  }

  static actions = {
                 ^

...and that looks to me like SonarRunner is tripping on the static keyword.

So - does SonarQube really support ES2015? Or do I need to configure it differently, perhaps? My config is as follows -

sonar.projectKey=my-project
sonar.projectName=My Project
sonar.projectVersion=$BUILD_NUMBER
sonar.exclusions=node_modules/**,tests/**,bin/**,config/**,docs/
sonar.sources=.
sonar.javascript.lcov.reportPath=coverage/lcov.info

Thanks.

Upvotes: 1

Views: 807

Answers (1)

a better oliver
a better oliver

Reputation: 26848

static actions = {

This is a static class property and those are not part of the ES 2015 spec. So the SonarQube JS plugin is right to complain about it. Class properties are currently at a proposal stage, so it's unclear when (or if) they will make it into the language.

The status and development of the ECMAScript language can be confusing at times. The fact that transpilers support most proposals (i.e. features that are not part of any specification yet) makes the situation even worse.

If you want to target a specific version of ECMAScript, but are unsure about the supported features, then you can, of course, consult the language sepecification. I can also recommend this compatibility table.

Upvotes: 2

Related Questions