SonarJS failed to parse optional chaining

How do I get the SonarJS plugin to parse modern JS syntax? It’s failing to parse optional chaining, which is a feature introduced in ES2020, and the latest version of the plugin says it only supports up to ES2019.

I see some issues about this regarding TypeScript, but I am not using TypeScript.

Hey there. What version of SonarQube are you using, and what’s the exact error you’re getting?

Here’s an example failure:

     23:21:30.838 DEBUG: Unable to parse file with java-based frontend (some rules will not be executed): app/components/something.js
     23:21:30.838 DEBUG: Parse error at line 10 column 53:
     
      3: export default class SomeComponent extends Component {
      ...omitted...
      9:   get foo() {
     10:     return this.args.foo?.includes('hi');

Versions:

  • SonarQube server 8.5.1 (Enterprise 8.5.1.38104)
  • JavaScript/TypeScript Code Quality and Security 6.5.0.13383 (javascript)
  • I see this executable in my logs: /usr/bin/sonar-scanner-3.3.0.1492, but I’m not sure if I can trust the version in the filename. Not sure how to determine what the actual version is.

Hey there.

These were DEBUG level warnings safe to ignore, but that you won’t find anymore in the latest version of SonarQube (v8.7) as the Java-based frontend was removed in SonarQube v8.6 where we moved to a fully eslint-based parser. Optional chaining should be supported in all cases for all rules now.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.