Must-share information (formatted with Markdown):
- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension): 8.9.8
- how is SonarQube deployed: zip, Docker, Helm: Docker
- what are you trying to achieve: Successful scan of a dedicated
tsconfig
file for Sonar Scanner - what have you tried so far to achieve this: See below
Hi there,
I’m currently running into an issue where Sonar Scanner doesn’t seem to evaluate overrides. Our service contains a base tsconfig.json
file that has "target": "es2021"
. This doesn’t seem to be a respected value via Sonar Scanner 4:
ERROR: Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext'.Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref'.
I also saw that because of this error, it ends up impacting the main projects view downstream in that it shows that the main branch analysis is empty:
Steps I’ve taken
So I ended up porting over to a tsconfig.sonar.json
file that extends
our base but that didn’t seem to work when I set the target
to a valid choice, in this case esnext
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "esnext",
"lib": [
"esnext",
"dom"
],
},
}
Although I’ve confirmed that the extends
works at a tsc
level, it seems to choke at the Sonar Scanner level when I set sonar.typescript.tsconfigPath=tsconfig.sonar.json
and continues to think that target
is es2021
(which is inherited from the base tsconfig.json
file.
Please advise as the only workaround I’ve found is to copy-paste the entire tsconfig.json
file and just replace target
.
Thanks.