Sonarlint fails linting .ts files with tsconfig --module on es2020

Versions used

  • SonarJS,
  • Sonarlint 4.14.1,
  • Intellij 2020.3

Error observed

the matching tsconfig has es2020 as the compiler module option. This is recommended by the latest Angular version.

 "compilerOptions": {
    "module": "es2020",

SonarLint fails linting tsconfig files:

1/3 files analyzed, current file: [uri=file:///<path-to-file>]
Failed to analyze file [[uri=file:///<path-to-file>]]: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'.

Potential workaround

I managed to setup a shadow tsconfig (tsconfig-sonar.json) and added a Analysis property to use this tsconfig file for Sonarlint. In the shadow tsconfig I changed the module option to “esnext”. This works but we dont want to have a shadow tsconfig just for Sonarlint, obviously.

Thanks for fixing or helping!

hello @Tobias_M ,

do you use connected mode? If yes, you should try to update SonarQube to the latest version, which will support es2020 for module setting.
If not, upcoming release of SonarLint should include more recent JS analyzer which will support this.