2024-03-19

SonarQube plugins for AngularJS and Javascript you may not know

https://sylvainleroy.com/wp-admin/options-general.php?page=ad-inserter.php#tab-2

In this article, I will present you with two new plugins that you will never find on the SonarQube marketplace (for some good reasons).

Keep reading if you are developing in TypeScript, AngularJS 2, Javascript.

AngularJS 2, TypeScript training

Check the training.

Recently, I received an AngularJS 2 + TypeScript training course in Serial SA. The training has been performed by the NinjaSquad. The course and these guys are really great and I can recommend with configence that everyone should take that training.

AngularJS2 course

However, that is no the subject of this post.

I have been developing in AngularJS 2 and TypeScript and (Node.JS) since and I felt the need to have Continuous quality control on that project. I am a big user of SonarQube and I tried to find my happiness in the huge list of rules but I found none.

At least up to version 6.0 (a quite recent one), AngularJS2 and TypeScript are not supported.

Plugin for TypeScript / AngularJS2

Download the plugin.

I found on Github a plugin made by Pablissimo, a great guy with a lot of courage.

He built a SonarQube plugin for TypeScript and it worked well 🙂

The plugin can be downloaded on GitHub here. Copy it in your SonarPlugin plugins folder and everything should be fine.

Notice: This SonarPlugin is relying on the tool tslintand its configuration. If you want to enable the TypeScript analysis with SonarQube, don’t forget to do in your project :

  npm install -g tslint
  tslint --init

Plugin for

Download the plugin.

The analyzer of SonarQube is great and the guys have injected a serious effort into it to make it fast and reliable. SonarQube also provides some really interesting rules. The unique downside is that Javascript frameworks and toolings are moving faster than the SonarQube. plugin. And currently, the solution is lacking AngularJS, … rules.

I decided to make a fork of the previous plugin made by Pablissimo and to build a version for ESLint.

Indeed ESLint is the most popular static analysis tool for Javascript (Linter) right now among Developers. Even JSCS has merged with it recently. And ESLint is providing several plugins very useful ( the full is in their README):

In the same way as above, you will need to initialize ESLint if you did not already have it :

  npm install --save-dev eslint
  npm install --save-dev eslint-plugin-angular
  npm install --save-dev eslint-config-angular
  estlint --init

My Sonar plugin is also using an external linter (ESLint) to add more functionalities to SonarQube. If you are developing in the previous frameworks, let’s use it and give me feedback.

And once SonarQube has developed the right set of rules that you need, switch on the standard SonarQube analyzer.

Sylvain Leroy

Senior Software Quality Manager and Solution Architect in Switzerland, I have previously created my own company, Tocea, in Software Quality Assurance. Now I am offering my knowledge and services in a small IT Consulting company : Byoskill and a website www.byoskill.com Currently living in Lausanne (CH)

View all posts by Sylvain Leroy →