SonarJS: not able to parse with optional-chaining/nullables

sonarjs
javascript

(Sven Großmann) #1

Hello,

currently I am using SonarQube with SonarJS version 5.0 (build 6962). My source files are es2017 files which are transpiled using babel. Thus, there are some features, which lead Sonar into not beeing able to parse some source files.

Especially with using babel plugins, for instance ‘plugin-proposal-optional-chaining’, this leads into parser errors:
ERROR: Parse error at line 74 column 37:

73:     const browserData = bowser.getParser(ctx.request.header['user-agent']).parse().parsedResult;
74:     const test = ctx.request.body?.test;
                                                       ^

Is there any way to install babel-plugins to the sonar analyzer or are there any other workarounds, that let me analyse my source files?


(Colin Mueller) #2

Greetings Sven,

We support new syntax as it reaches Stage 2 in the ECMAScript Proposal Process. Optional Chaining is in Stage 1.

Colin