So which linter for TS does SonarCloud use?

I’m trying to understand status with Typescript linters and I’m confused.
I understood that we’re in the process of migration from tslist to eslint. And I know that Sonar has a few plugins for integrating with eslint/tslint.
But I’m not sure I understand very basic thing - does SonarCloud use its internal linter by default and tslint/eslint reports are optional or whole Sonar report based on tslint/eslint?
In my sonar-scanner output I have this:

2:55:39  INFO: Sensor SonarTS [typescript]
12:55:39  INFO: Since SonarTS v2.0, TypeScript analysis is performed by SonarJS analyzer v6.0 or 
 later. No TypeScript analysis is performed by SonarTS.
12:55:39  INFO: Sensor SonarTS [typescript] (done) | time=0ms
12:55:39  INFO: Sensor JaCoCo XML Report Importer [jacoco]
12:55:39  INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=9ms
12:55:39  INFO: Sensor JavaScript analysis [javascript]
12:55:41  INFO: Using TypeScript at: '/var/lib/jenkins/workspace/myjob/mycode'
12:55:42  INFO: 15 source files to be analyzed
12:55:43  INFO: 15/15 source files have been analyzed
12:55:43  INFO: Sensor SonarJS [javascript]
12:55:43  INFO: 15 source files to be analyzed
 12:55:44  INFO: Sensor SonarJS [javascript] (done) | time=973ms
12:55:44  INFO: 15/15 source files have been analyzed
12:55:44  INFO: Sensor JavaScript analysis [javascript] (done) | time=4953ms
12:55:44  INFO: Sensor SonarJS Coverage [javascript] 
12:55:44  INFO: Analysing [/var/lib/jenkins/workspace/myjob/coverage/lcov.info]
12:55:44  INFO: Sensor SonarJS Coverage [javascript] (done) | time=73ms
 12:55:44  INFO: Sensor TypeScript analysis [javascript]
12:55:45  INFO: Found 1 tsconfig.json file(s): [/var/lib/jenkins/workspace/myjob/tsconfig.json]
12:55:45  INFO: 237 source files to be analyzed
12:55:45  INFO: Analyzing 237 files using tsconfig: /var/lib/jenkins/workspace/myjob/tsconfig.json
12:56:07  INFO: 237/237 source files have been analyzed

Hello,

In SonarCloud the analysis of JavaScript and Typescript files are both done by SonarJS which provide rules for both languages.
SonarJS rely on eslint in the background to perform it’s analysis.

SonarTS, that you can see in the log, was relying on tslint but it is no longer performing any analysis, and is just there for some backward compatibility issues.

And finally eslint report are optional, but you want to configure it if you want all the eslint rules to be reported in SonarCloud, if you don’t then only the rules supported by SonarJS will appear in SonarCloud.

Hope this help!

1 Like

Thank you!
So SonarCloud runs SonarJS, which uses eslist with some rules developed by Sonar team.

If I understand properly we can add our own rules and/or tweak builtin Sonar rules?

You cannot add custom rules to SonarJS on SonarCloud.
But you can create custom rules for eslint, or enable some plugins for eslint and you will need to configure the eslint report to have the issues raised by those rules appear in SonarCloud.

1 Like