SonarQube TypeScript plugin

I use SonarQube (live demo) a fair bit to monitor code quality metrics, but there’s no in-built support nor published community plugins for TypeScript analysis – so I’m writing one.

I intend two core features:

  • Measure code quality by running against TsLint
  • Measure unit test coverage by processing an LCOV file
Running an alpha version of SonarTsPlugin against a random TypeScript project from GitHub shows code issues but no code coverage - yet

Running an alpha version of SonarTsPlugin against a random TypeScript project from GitHub shows code issues but no code coverage – yet

The first of those two goals isn’t that far away at all – above is a screenshot from the alpha version running locally. If you’re interested in helping, drop me an email!

6 thoughts on “SonarQube TypeScript plugin

  1. Richard

    Hi,

    I’d be interested in helping test this – we currently don’t include the generated .js files in the project – and as we are using the vs bootstrapper plugin these .js files are not included in the analysis for javascript rules or coverage

    Any chance I could get a copy of the plugin to test?

    Many thanks
    Richard

    Reply
  2. Jonny Oenning

    Hi,

    I’m wondering if you made any progress on SonarQube typescript code coverage. I’m writing this from a post from yourself dated 19 / Jan / 2015.

    Thanks
    Jonny

    Reply
    1. Pablissimo Post author

      If you’re using Chutzpah (or some tool that can output LCOV) then yeah, the plugin as it stands will pull in coverage data. For Chutzpah you’ll need to use the new UseSourceMaps setting to map between your .js files and source .ts files (which will cause the LCOV to be output against the .ts files).

      In your sonar properties file, add a key value pair similar to:
      sonar.ts.lcov.reportpath=lcov.dat

      where lcov.dat is the properties-file-relative path to the LCOV data.

      Reply
  3. Arvind Das

    Hi
    Getting this error,
    projects/vCoreUI/app/main.ts” “/home/arvind/projects/vApp/app/services/organisation.service.ts”
    13:52:23.339 ERROR – TsLint Err: module.js:457
    13:52:23.339 ERROR – TsLint Err: throw err;
    13:52:23.340 ERROR – TsLint Err: ^
    13:52:23.340 ERROR – TsLint Err:
    13:52:23.341 ERROR – TsLint Err: Error: Cannot find module ‘/home/arvind/projects/vApp/”/usr/local/bin/tslint”‘
    13:52:23.342 ERROR – TsLint Err: at Function.Module._resolveFilename (module.js:455:15)
    13:52:23.342 ERROR – TsLint Err: at Function.Module._load (module.js:403:25)
    13:52:23.342 ERROR – TsLint Err: at Module.runMain (module.js:590:10)
    13:52:23.342 ERROR – TsLint Err: at run (bootstrap_node.js:394:7)
    13:52:23.342 ERROR – TsLint Err: at startup (bootstrap_node.js:149:9)
    13:52:23.342 ERROR – TsLint Err: at bootstrap_node.js:509:3
    13:52:23.401 INFO – Sensor com.pablissimo.sonar.TsLintSensor (done) | time=166ms
    13:52:23.401 INFO – Sensor LOCSensor
    13:52:23.482 INFO – Sensor LOCSensor (done) | time=81ms
    Not sure why it is not able to find the module.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *