Expected sourceFile.imports[0] to be the synthesized JSX runtime import (sonarjs/S1874)

I’m running a code analysis with npm sonar-scanner command in a bitbucket pipeline script over a react typescript monorepo that is using the automatic JSX runtime (jsx: "react-jsx")

Since a couple of days I started having an error without any infrastructure change.

Node version: 24.13
Typescript version: 5.9.3
sonarqube-scanner@4.3.5

This is the bitbucket-pipelines.yml snippet that calls sonar-scanner:

- export SONAR_TSCONFIG_PATHS=$(find apps/*/tsconfig.json packages/*/tsconfig.json 2>/dev/null | paste -sd,)

- >
  pnpm --dir . exec sonar-scanner
  -Dsonar.projectBaseDir=.
  -Dsonar.sources=$SONAR_SOURCES
  -Dsonar.tests=$SONAR_SOURCES
  -Dsonar.typescript.tsconfigPaths=$SONAR_TSCONFIG_PATHS
  -Dsonar.qualitygate.wait=true

This is the error:

[INFO]  ScannerEngine: Plugin version: [12.1.0.39434]
[INFO]  ScannerEngine: Resolving provided TSConfig files using '/opt/atlassian/pipelines/agent/build/apps/server/tsconfig.json,/opt/atlassian/pipelines/agent/build/apps/web/tsconfig.json,/opt/atlassian/pipelines/agent/build/packages/api/tsconfig.json,...'
[ERROR] ScannerEngine: Error: Debug Failure. False expression: Expected sourceFile.imports[0] to be the synthesized JSX runtime import
[ERROR] ScannerEngine: Occurred while linting /opt/atlassian/pipelines/agent/build/packages/api/src/components/global-search/global-search.tsx:1
[ERROR] ScannerEngine: Rule: "sonarjs/S1874"
[ERROR] ScannerEngine:     at qwl (/opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:542:546754)
[ERROR] ScannerEngine:     at k5t (/opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:542:295906)
[ERROR] ScannerEngine:     at jfe (/opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:542:296127)
[ERROR] ScannerEngine:     at Bse (/opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:542:294738)
[ERROR] ScannerEngine:     at Hst (/opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:542:298355)
[ERROR] ScannerEngine:     at nvl (/opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:542:291812)
[ERROR] ScannerEngine:     at kbl (/opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:542:391798)
[ERROR] ScannerEngine:     at tp (/opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:542:389655)
[ERROR] ScannerEngine:     at i_ (/opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:542:385046)
[ERROR] ScannerEngine:     at /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:542:361572
[INFO]  ScannerEngine: Found 14 tsconfig.json file(s): [/opt/atlassian/pipelines/agent/build/apps/server/tsconfig.json, /opt/atlassian/pipelines/agent/build/apps/web/tsconfig.json, /opt/atlassian/pipelines/agent/build/packages/api/tsconfig.json, ...]

From what I could see, the plugin version changed. Before it was using version 12.0.0.38664 and we did not have any errors. Now with version 12.1.0.39434 we have the issue.

The error occurs on multiple .tsx files during analysis. The scanner continues but reports these errors for many TSX files.

tsconfig.json configuration:

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "target": "ES6",
    "lib": ["DOM", "DOM.Iterable", "ESNext"]
  }
}

Also checked the Quality profiles for our project in sonarcloud.io to see if there were any new sonar profile rules, and that is not the case.

Any ideas?

Thanks in advance.

1 Like

Additionally, is there a way to force the ScannerEngine (for SonarCloud) to use a specific plugin version?

Thanks once again.

Hi @riddleit,

Thank you for the detailed report and for tracking down the plugin version change that introduced the problem!

This is indeed a crash in the analyzer. Rule S1874 is sensitive to the order in which tsconfig files are processed: it may crash when a .tsx file is first encountered through a tsconfig without "jsx": "react-jsx". Plugin 12.1.0 introduced a change to
how tsconfig files are discovered and processed, which likely altered that order and explains why the crash now happens consistently in your project.

We’ve created a Jira ticket to track the fix.

In the meantime, it may help to ensure tsconfigs that declare "jsx": "react-jsx" are listed first in sonar.typescript.tsconfigPaths. Here is an updated version of your pipeline snippet that attempts this automatically:

export SONAR_TSCONFIG_PATHS=$(
  (
    fgrep -l react-jsx apps/*/tsconfig.json packages/*/tsconfig.json 2>/dev/null
    fgrep -L react-jsx apps/*/tsconfig.json packages/*/tsconfig.json 2>/dev/null
  ) | paste -sd,
)

Note that this only matches tsconfigs that directly declare "jsx": "react-jsx". If your jsx setting is inherited from a base tsconfig via extends, you may need to list the jsx tsconfigs manually at the front of the list.

Regarding your question about pinning the plugin version: to our knowledge this is not possible on SonarCloud, as the plugin is managed centrally by SonarSource — but feel free to reach out to our support team if you need confirmation on this.

Sorry for the trouble, and thanks again for helping us improve the tool!

1 Like

Hi @francois.mora ,

Thanks for your reply and for creating the ticket with your analysis.

Hope this is fixed soon :slightly_smiling_face:

Thanks once again for your support.

Cheers

1 Like