- SonarJS 126.96.36.19957,
- Sonarlint 4.14.1,
- Intellij 2020.3
the matching tsconfig has es2020 as the compiler module option. This is recommended by the latest Angular version.
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'.
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.
thanks for the reply.
Yes, I am using connected mode and we are using SonarQube * Version 8.3.1 (build 34397). Is this a problem? This server has many projects and a lot of people ware working with it - and for some with a very similar setup as in my team, it works. Unfortunately, I dont have the right to update or check the config of the server…
I saw a related issue, though. In my log it says
Execute Sensor: TypeScript analysis
Deploying eslint-bridge into /Users/munt/Library/Caches/JetBrains/IntelliJIdea2020.3/tmp/sonarlint/.sonartmp_12962327805879000198/eslint-bridge-bundle
Deploying bundle (done) | time=3618ms
TypeScript location set via property sonar.typescript.internal.typescriptLocation=/Users/munt/Library/Application Support/JetBrains/IntelliJIdea2020.3/plugins/sonarlint-intellij
Using TypeScript at: '/Users/munt/Library/Application Support/JetBrains/IntelliJIdea2020.3/plugins/sonarlint-intellij'
I checked the typescript version that is in sonarlint-intellij:
This version does indeed not support the module option ‘es2020’. I tried to overwrite the
sonar.typescript.internal.typescriptLocation in order to use newer typescript versions, but in the log it still says to use the typescript in sonartlint-intellij.
So the new questions are: why is an old typescript version used and how can I overwrite the setting?
I found a workaround fix for my problem. When I copy a more recent Typescript version (e.g. 4.0.3) in the folder where the sonarlint-intellij plugin is looking for typescript, it works.
It would be great, though, when the plugin would allow to use the typescript version of the project since it is also using the tsconfig.json of the project!
can you clarify whether
a) you consider this behaviour of SonarLint a bug that will be resolved in upcoming release or
b) this is due to connected mode with the outdated version 8.3.1 (build 34397) of Sonarqube?
hello @Tobias_M ,
sorry for the late reply, I missed this thread.
we changed the way we work with TS in the more recent versions of JS analyzer. Since SonarQube 8.6 we embed ourselves the latest version of TypeScript available at the time of the release, so if you upgrade to this version it should support the new
We tried before to use some heuristics to find the TS version used by the project, but this was complicated and error prone, we think that embedding latest TS into the analyzer itself will work better.