Can ECMA version be setup to the scanner?

Currently our code is written under ECMA 2018 version, but seems SonarQube is using the latest version. I didn’t find anything where i can set ecmascript version. Does it have such function? to switch between different versions?

Hey there.

Can you give an example of where you need to provide this information? i.e. what’s currently not working well related to the version of ECMA you’re using?

Hi Colin
Here is an example

sonarCube recommend the Optional Chaining Operator (?.) here
but it is a features of ECMAScript 2020
so if we set the sonarCube rules to check ECMAScript 2018 this won’t be a issue
And if we change our code as suggested, it won’t work, since this operator is not available in 2018 version.
Is there any other solution besides changing our ECMA version?

1 Like

Hello Gia,

Thank you for the feedback.

I have opened a ticket to track this proposal: JS-483.

Hi Gia,

One workaround would be to disable the offending rule in the Quality Profile of the project.

Could you share the reasons why you are forced to stay in ES2018? This could help us to better understand and cover your use case.

Well we are not forced to stay in ES2018.
I think it was set like that at the beginning of the project, not change since

Thanks, happy to hear that:)

Thanks for your reply Gia.

Could you share where is the limiting factor? For example TypeScript compiler, Webpack configuration, other?

In principle, all modern engines support the latest version of ECMAScript, including Node.js and browsers.