SonarQube: Integrate ESLint for JavaScript in SonarQube?

17,895

Solution 1

Yes, there is still no plugin for ESLint, and this is part of the strategy, but in the other direction.

In fact, our first plugins were for external analyzers, and over time we realized that simply aggregating other tools' results didn't truly serve the community because that community was coming to us with rule bugs, requests and suggestions for improvement - and all we could do was refer them on the tools' makers.

So we started writing our own rules instead for better responsiveness and, we believe, enhanced accuracy.

I urge you to take the rules you feel are missing to the SonarQube Google Group

Edit The strategy has come full circle. SonarJS now imports ESLint reports.

Solution 2

You have a good option here: https://github.com/sleroy/SonarEsLintPlugin

From the docs:

• Install Node.js

• Install EsLint (3+) with npm install -g eslint, or ensure it is installed locally against your project

• If you're installing globally, find the path to EsLint and copy it - will be similar to C:\Users\ [Username]\AppData\Roaming\npm\node_modules\eslint\bin\eslint.js on Windows

• Copy .jar file (downloaded from https://github.com/sleroy/SonarEsLintPlugin/releases page) to SonarQube extensions folder

• Restart SonarQube server

• Browse to SonarQube web interface, login as Admin, hit up Settings

• Hit the Rules tab, then the EsLint rule set, then apply it to your project - alter rule activation as required

Solution 3

I have not tried it yet, but I've just discovered this plugin that seems to be very promising for any front end project:

https://github.com/groupe-sii/sonar-web-frontend-plugin

It may worth giving a try

Share:
17,895
Stelos10
Author by

Stelos10

Updated on June 23, 2022

Comments

  • Stelos10
    Stelos10 about 2 years

    We have determined our rules, which should be used for JavaScript code, with ESLint. Now we want to integrate ESLint to SonarQube as we did it before the same way with Checkstyle for JavaCode.

    Under the following link it is described why SonarQube doesn't want to provide a plugin for ESLint: http://www.sonarqube.org/sonarqube-javascript-plugin-why-compete-with-jslint-and-jshint/

    Is there still no plugin fir ESLint in SonarQube? Isn't this part of a marketing strategy? There is also a plugin for Checkstyle, FindBugs etc... Why does SonarQube suddenly stop to support the integration of other code analysing tools?

  • manuc66
    manuc66 about 6 years
    It seems that the situation is evolving : jira.sonarsource.com/browse/MMF-1231
  • hunt
    hunt over 5 years
    Latest update to the plugin SonarJS (v5.0 – Oct 04, 2018) now imports issues found by eslint plugin docs.sonarqube.org/display/PLUG/SonarJS
  • Mig82
    Mig82 over 3 years
    I wonder... would it not be better to just have Sonar run with the EsLint config as much as possible? Just a thought.