Typescript contents considered invalid for all files

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube 10.2 (build 77647)
  • how is SonarQube deployed: zip, Docker, Helm
    On premises server
  • what are you trying to achieve
    Scan mixed language project containing several vue/vite subprojects
  • what have you tried so far to achieve this
    Gitlab sonar-scan job integrated into project, captured output
    Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

The project has two variants: site and rfss
The directory structure for tsconfig files looks like

./site/vui-sc/node_modules/fastq/test/tsconfig.json
./site/vui-sc/node_modules/@vue/tsconfig
./site/vui-sc/node_modules/@vue/tsconfig/tsconfig.node.json
./site/vui-sc/node_modules/@vue/tsconfig/tsconfig.json
./site/vui-sc/node_modules/@vue/tsconfig/tsconfig.web.json
./site/vui-sc/node_modules/type-fest/source/tsconfig-json.d.ts
./site/vui-sc/node_modules/estree-walker/types/tsconfig.tsbuildinfo
./site/vui-sc/tsconfig.json
./site/vui-sc/tsconfig.config.json
./rfss/rfss-manager/ui/node_modules/fastq/test/tsconfig.json
./rfss/rfss-manager/ui/node_modules/@vue/tsconfig
./rfss/rfss-manager/ui/node_modules/@vue/tsconfig/tsconfig.node.json
./rfss/rfss-manager/ui/node_modules/@vue/tsconfig/tsconfig.json
./rfss/rfss-manager/ui/node_modules/@vue/tsconfig/tsconfig.web.json
./rfss/rfss-manager/ui/node_modules/type-fest/source/tsconfig-json.d.ts
./rfss/rfss-manager/ui/node_modules/estree-walker/types/tsconfig.tsbuildinfo
./rfss/rfss-manager/ui/tsconfig.json
./rfss/rfss-manager/ui/tsconfig.config.json
./rfss/rfss-controller/ui/node_modules/fastq/test/tsconfig.json
./rfss/rfss-controller/ui/node_modules/@vue/tsconfig
./rfss/rfss-controller/ui/node_modules/@vue/tsconfig/tsconfig.node.json
./rfss/rfss-controller/ui/node_modules/@vue/tsconfig/tsconfig.json
./rfss/rfss-controller/ui/node_modules/@vue/tsconfig/tsconfig.web.json
./rfss/rfss-controller/ui/node_modules/type-fest/source/tsconfig-json.d.ts
./rfss/rfss-controller/ui/node_modules/estree-walker/types/tsconfig.tsbuildinfo
./rfss/rfss-controller/ui/tsconfig.json
./rfss/rfss-controller/ui/tsconfig.config.json
./rfss/fleet-manager/ui/node_modules/svg-pathdata/tsconfig.json
./rfss/fleet-manager/ui/node_modules/html2canvas/tsconfig.json
./rfss/fleet-manager/ui/node_modules/fastq/test/tsconfig.json
./rfss/fleet-manager/ui/node_modules/@vue/tsconfig
./rfss/fleet-manager/ui/node_modules/@vue/tsconfig/tsconfig.node.json
./rfss/fleet-manager/ui/node_modules/@vue/tsconfig/tsconfig.json
./rfss/fleet-manager/ui/node_modules/@vue/tsconfig/tsconfig.web.json
./rfss/fleet-manager/ui/node_modules/type-fest/source/tsconfig-json.d.ts
./rfss/fleet-manager/ui/node_modules/estree-walker/types/tsconfig.tsbuildinfo
./rfss/fleet-manager/ui/tsconfig.json
./rfss/fleet-manager/ui/tsconfig.config.json

Example contents of a tsconfig.json file is

{
  "extends": "@vue/tsconfig/tsconfig.web.json",
  "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
  "compilerOptions": {
    "baseUrl": ".",
    "lib": ["ES2021", "DOM"],
    "paths": {
      "@/*": ["./src/*"]
    },
    "sourceMap": true
  },

  "references": [
    {
      "path": "./tsconfig.config.json"
    }
  ]
}

A short snippet from the sonar scanner log output indicates that it cannot traverse the path/extends structure and therefore, ignores each of the typescript files in the project(s). I tried providing all of the paths in the sonar-project.properties file but that doesn’t seem to help.
Short snippet showing the pattern of errors:

INFO: Resolving TSConfig files using 'site/vui-sc/ site/vui-sc/node_modules/,rfss/rfss-manager/ui/node_modules,rfss/rfss-controller/ui/node_modules/,rfss/fleet-manager/ui,rfss/rfss-controller/ui,rfss/fleet-manager/ui/node_modules/,rfss/rfss-manager/ui' from property sonar.typescript.tsconfigPaths
INFO: Found 0 TSConfig file(s): []
INFO: Found 4 tsconfig.json file(s): [/builds/core-network/tn9400/p25core/site/vui-sc/tsconfig.json, /builds/core-network/tn9400/p25core/rfss/rfss-manager/ui/tsconfig.json, /builds/core-network/tn9400/p25core/rfss/rfss-controller/ui/tsconfig.json, /builds/core-network/tn9400/p25core/rfss/fleet-manager/ui/tsconfig.json]
WARN: Could not find tsconfig.json: /node_modules/@vue/tsconfig/tsconfig.web.json/tsconfig.json; falling back to an empty configuration.
WARN: Could not find tsconfig.json: /node_modules/@vue/tsconfig/tsconfig.web.json/tsconfig.json; falling back to an empty configuration.
WARN: Could not find tsconfig.json: /node_modules/@vue/tsconfig/tsconfig.web.json/tsconfig.json; falling back to an empty configuration.
WARN: Could not find tsconfig.json: /node_modules/@vue/tsconfig/tsconfig.web.json/tsconfig.json; falling back to an empty configuration.
WARN: Could not find tsconfig.json: /node_modules/@vue/tsconfig/tsconfig.node.json/tsconfig.json; falling back to an empty configuration.
WARN: Could not find tsconfig.json: /node_modules/@vue/tsconfig/tsconfig.node.json/tsconfig.json; falling back to an empty configuration.
WARN: Could not find tsconfig.json: /node_modules/@vue/tsconfig/tsconfig.node.json/tsconfig.json; falling back to an empty configuration.
WARN: Could not find tsconfig.json: /node_modules/@vue/tsconfig/tsconfig.node.json/tsconfig.json; falling back to an empty configuration.
INFO: Analyzing 123 files using tsconfig: /builds/core-network/tn9400/p25core/rfss/rfss-manager/ui/tsconfig.json
INFO: 314 source files to be analyzed
ERROR: Failed to analyze file [rfss/rfss-manager/ui/src/views/tools/UserAdd.vue]: File '@vue/tsconfig/tsconfig.web.json' not found.
.....
INFO: 314/314 source files have been analyzed
INFO: Hit the cache for 0 out of 314
INFO: Miss the cache for 314 out of 314: ANALYSIS_MODE_INELIGIBLE [314/314]
INFO: Sensor JavaScript/TypeScript analysis [javascript] (done) | time=561120ms

hi @searler ,

sorry for the late answer. Could you please try to run npm install before the analysis? To analyze vue files we need to have the dependency in tsconfig available.

Does the sonarqube wrapper information not work, npm install is part of the build for the product which is run with the wrapper. We don’t run anything other than sonar-scanner in the analyse step.

The other potential problem, one variant calls npm install once
The other variant calls it three times, once for each UI sub-project
How do I need to call npm install for the scanner such that it can pick them all apart?

I copy some autogenerated files from the build into the checkout for the C++ analysis.
If I copy the tsconfig files from the build into place at the same time would that resolve the issue?

Thanks for the hint, I am implementing the pipeline and checking with SonarQube but know nothing at all about TypeScript, Vue or Vite. It appears that running at least the npm install in the correct directories for a clean checkout is sufficient to allow SonarQube to scan the Typescript files.

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