React 17 support

When running a create-react-app (React 17) through SonarCloud, I get the following error:
ERROR: Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'.
In my tsconfig.json, jsx is set to react-jsx. This is the default option for React 17 apps.
This results in Sonar skipping all files because it’s skipping files with no tsconfig.json.

Raw logs (CI running on Azure DevOps):
INFO: Found 1 tsconfig.json file(s): [/home/vsts/work/1/s/tsconfig.json]
ERROR: Argument for ‘–jsx’ option must be: ‘preserve’, ‘react-native’, ‘react’.
INFO: 6 source files to be analyzed
INFO: Skipping 6 files with no tsconfig.json
INFO: 6/6 source files have been analyzed

Hey there.

Under the hood, Typescript v3.8.3 is being used for analysis. react-jsx, long story short, is an option that became supported by Typescript in v4.1 (that was quite the effort to find :laughing:)

Support for this version of Typescript by our analyzers should be coming “soon” (SonarSource/SonarJS #2383).

In the meantime, you might try creating a dummy tsconfig.json file that you supply to the sonar.typescript.tsconfigPath using a supported option for the --jsx argument. I’m not sure what will happen, but it’s worth a try!

2 Likes

Hey!

Indeed, I noticed Sonar using TS v3.8.3 instead of the version used in our project v4.x.
For us the quickest fix was to downgrade to TS 3.x because we’re in early stages of development.

Thanks for your response!

@Colin I see that ticket has now been closed and a Pull Request was merged to solve it on SonarQube.

However the problem still persists on SonarCloud. I’ve been paying for SonarCloud but it has not been able to analyze any of my Typescript files for over a month now :frowning:

Any update on when this change will make it into SonarCloud?

I would expect it gets deployed next week.

1 Like

Hey @MarkLyck and @luuktap – give it a try now!