Solution-style tsconfig files

SonarQube works with solution-style tsconfig with this setting in sonar-project.properties:

sonar.typescript.tsconfigPath=tsconfig.lint.json

You need to point into a tsconfig which includes the src folder (or whatever directory with the code):
For instance, I’m reusing the same one that I have for Eslint:

{
  "extends": "./tsconfig.base.json",
  "compilerOptions": {
    "noEmit": true
  },
  "include": ["src"]
}

The issue now is located at SonarLint, it tries to read tsconfig.json and because it does not contain anything it skips all the files and the errors are not displayed in the IDE:

[Info  - 11:26:36.639] Found 1 tsconfig.json file(s): [/Users/gllamas/projects/recall2-POC-starter/tsconfig.json]
[Debug - 11:26:36.698] /Users/gllamas/projects/recall2-POC-starter/src/app/app.component.ts matched NO_CONFIG
[Info  - 11:26:36.699] 1 source files to be analyzed
[Info  - 11:26:36.699] Skipping 1 files with no tsconfig.json
[Debug - 11:26:36.700] Skipped files: [uri=file:///Users/gllamas/projects/recall2-POC-starter/src/app/app.component.ts]

If we had a property for specifying the tsconfig path it would be solved.

Hello, thank you for your feedback.

FYI, most properties available on scanner side can be set as “analysis properties” in the SonarLint settings.

  • In IntelliJ, you’ll find them under “Settings” > “Tools” > “SonarLint” > “Project Settings” > “Analysis properties”
  • In VSCode, you can set them using the sonarlint.analyzerProperties entry
  • In Eclipse, this will be under “Preferences” > “SonarLint” > “Analyzer Properties”

This should allow you to set the sonar.typescript.tsconfigPath to the right location.

There is a small caveat: if the file is located outside of the folders opened in the IDE, this might not work as expected.

Thank you!!! SonarQube/SonarLint works again with Angular 10.

  "sonarlint.analyzerProperties": {
    "sonar.typescript.tsconfigPath": "tsconfig.lint.json"
  }
1 Like

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