Enables the powerful SonarTS analyzer.
TypeScript version >=2.2
- Node.js >=6
First Analysis of a TypeScript Project
- Install SonarQube Server (see Setup and Upgrade for more details)
- Install SonarQube Scanner and be sure your can call sonar-scanner from the directory where you have your source code
Install SonarTS (see Installing a Plugin for more details)
- If missing, install node.js on the machine where you run analysis
In your project, make sure to have typescript as a project dependency or dev dependency. If it's not the case, add it :
cd your-project-folder; npm install --only=dev typescript
If you can't have typescript as a project dependency you can set your 'NODE_PATH' variable to point to your globally installed typescript, but this is generally discouraged in the node.js documentation.
Run your analysis with the SonarQube Scanner by executing the following command from the root directory of the project:
- Follow the link provided at the end of the analysis to browse your project's quality in SonarQube UI
Assuming steps 1-3 above have already been completed, you'll want to encapsulate your analysis parameters in a sonar-project.properties file at the root of your project (see a sample project on GitHub: https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner). Then subsequent analyses can simply be run with:
Configuring Rule Profile
SonarTS provides 2 rule profiles out of the box: "Sonar way" (default) and "Sonar way Recommended".
"Sonar way" Profile
"Sonar way" profile is activated by default. It defines a trimmed list of high-value/low-noise rules useful in almost any TypeScript development context. You can check out the list of rules belonging to "Sonar way" on SonarCloud.
"Sonar way Recommended" Profile
"Sonar way Recommended" contains all rules from "Sonar way" (bugs and pitfall detection), plus more rules that mandate high code readability and long-term project evolution. You can check out the list of rules belonging to "Sonar way Recommended" on SonarCloud.
Above Predefined Rule Profiles
By using SonarQube UI you can create your own rule profiles and activate even more rules which are valuable in your development context.
SonarTS specific properties
Can be used to explicitly set location of Node.js executable. If not set analysis will use node from the
List of file path patterns to be excluded from analysis of TypeScript files. Default value is `**/node_modules/**,**/bower_components/**`
With SonarTS, you can also: