sonar-web-frontend-reporters

sreporter is a Command-Line Interface to generate Front-End linters reporters for the SonarQube plugin

Sonar Web Front-End Reporters

sreporteris a Command-Line Interface to generate linters reporters for the SonarQubeplugin.

Usage

There is two way of using sonar-web-frontend-reporters:

  • The Command-Line Interface way
  • The NodeJS way

Installation

$ npm install sonar-web-frontend-reporters -g           // For CLI use
$ npm install sonar-web-frontend-reporters --save-dev   // For NodeJS use

Command-Line Interface

Launch the CLI by calling:

$ sreporter [options]

Options

The command line utility has several options. You can view the options by running eslint -h.

Usage: sreporter [options]

Options:

  -h, --help           output usage information
  -V, --version        output the version number
  -c, --config <path>  Use configuration from this file. Defaults to ./.sreporterrc
  --es5                launch CLI with ES5 backward compatibility

The Command-Line Interface uses a configuration file (default is .sreporterrc) to define the reporters configuration. The configuration file is mandatory in order to use the CLI.

Default options are as follows:

{
  "projectName": "Sonar Web Front-End Reporter",
  "csslint": {
    "src": "src/**/*.css",
    "report": "reports/sonar/csslint.json",
    "rulesFile": ".csslintrc"
  },
  "sasslint": {
    "src": "src/**/*.scss",
    "report": "reports/sonar/scsslint.json",
    "rulesFile": ".sass-lint.yml"
  },
  "sass-to-scsslint": {
    "src": "src/**/*.scss",
    "report": "reports/sonar/scsslint.json",
    "rulesFile": ".sass-lint.yml"
  },
  "htmlhint": {
    "src": "src/**/*.html",
    "report": "reports/sonar/htmlhint.json",
    "rulesFile": ".htmlhintrc"
  },
  "eslint": {
    "src": "src/**/*.js",
    "report": "reports/sonar/eslint.json",
    "rulesFile": ".eslintrc",
    "ignorePath": ".eslintignore"
  },
  "eslintangular": {
    "src": "src/**/*.js",
    "report": "eslint-angular.json",
    "rulesFile": ".eslintrc",
    "ignorePath": ".eslintignore"
  },
  "jshint": {
    "src": "src/**/*.js",
    "report": "reports/sonar/jshint.json",
    "rulesFile": ".jshintrc"
  },
  "tslint": {
    "src": "src/**/*.ts",
    "report": "reports/sonar/tslint.json",
    "rulesFile": ".tslintrc"
  }
}

Disabling a reporter

Disabling a reporter is as simple as removing it from the .sreporterrcfile.

You can also set it's property to false:

{
  "projectName": "Sonar Web Front-End Reporter",
  "csslint": false
}

ES5 backward compatibility

To use the CLI with older NodeJS versions, you can use the --es5option:

$ sreporter --es5

NodeJS

You can launch all reporters:

const SonarWebReporters = require('sonar-web-frontend-reporters').Reporters;

let sonarWebReporters = new SonarWebReporters('Sonar Web Front-End Reporters', {
  "csslint": {
    "src": "src/**/*.css",
    "report": "reports/sonar/csslint.json",
    "rulesFile": ".csslintrc"
  },
  "htmlhint": {
    "src": "src/**/*.html",
    "report": "reports/sonar/htmlhint.json",
    "rulesFile": ".htmlhintrc"
  },
  "eslint": {
    "src": "src/**/*.js",
    "report": "reports/sonar/eslint.json",
    "rulesFile": ".eslintrc"
  }
});

sonarWebReporters.launchReporters(() => {
  console.log('All reporters have been processed');
});

Or just one by one, e.g for CSSLint:

const CSSLintReporter = require('sonar-web-frontend-reporters').CSSLintReporter;

let cssLintReporter = new CSSLintReporter({
  src      : 'src/**/*.css',
  report   : 'reports/sonar/csslint.json',
  rulesFile: '.csslintrc'
}, 'Sonar Web Front-End Reporters');

cssLintReporter.launch(() => {
  console.log('CSSLint reporter has been generated under reports/sonar/csslint.json');
});

ES5 backward compatibility

To use it with older NodeJS versions, you can require the reporters this way:

var SonarWebReporters = require('sonar-web-frontend-reporters/build/reporters');
var CSSLintReporter = require('sonar-web-frontend-reporters/build/reporters/csslint.reporter');

Available reporters

  • CSSLint
  • SASSLint
  • SASSLint to SCSSLint (convert SASSLint rules to SCSSLint rules, because the SonarQube plugin doesn't support SASSLint rules)
  • HTMLHint
  • ESLint
  • ESLint for AngularJS
  • JSHint
  • TSLint

Migrating from 2.x to 3.x

2.x and 3.x versions aren't compatible one to another.

The main reasons for this 3.0version were that:

  • We wanted to remove the Gulp abstraction and create a cleaner and more reusable/maintainable code in full ES6 ;
  • We needed to use it in a Webpack project and the integration wasn't that easy.

Warning:

3.x version is compatible with NodeJS version >= 6.5.0with ES6 support and >= 4.4.5with ES5 backward compatibility

You can still use the Gulp version by installing sonar-web-frontend-reporters@2.1.1.

However, you can also use it with Gulp this way:

let CSSLintReporter = require('sonar-web-frontend-reporters').CSSLintReporter;

gulp.task('csslint:reporter', (done) => {
  let cssLintReporter = new CSSLintReporter({
    src      : 'src/**/*.css',
    report   : 'reports/sonar/csslint.json',
    rulesFile: '.csslintrc'
  }, 'Sonar Web Front-End Reporters');

  cssLintReporter.launch(() => done());
});

Contributing

License

ISC License

Copyright (c) 2016 Groupe SII

HomePage

https://github.com/groupe-sii/sonar-web-frontend-reporters#readme

Repository

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


上一篇:ttys
下一篇:实用 WebGL 图像处理入门

相关推荐

  • 理想中的Jenkins+Sonar+Github代码质量管理

    背景 前阵子老美的Audit要求各个开发组截图各自repository的Sonar Analysis Report,我跑去Sonarqube一看。。。好家伙!全是红灯,简直惨不忍睹 clipbo...

    2 年前
  • 多人协同开发如何保证代码质量!看看这篇《理想中的Jenkins+Sonar+Github代码质量管理》

    背景 前阵子老美的Audit要求各个开发组截图各自repository的Sonar Analysis Report,我跑去Sonarqube一看。。。好家伙!全是红灯,简直惨不忍睹 clipbo...

    2 年前
  • 动态服务器 Note-FrontEnd-32

    动态服务器的相关知识,内容包括什么是动态服务器、实现用户注册功能、实现用户登录功能、标记用户已登录、显示用户名、防篡改 userid、Question &amp; Answer。

    4 个月前
  • tslint-sonarts

    SonarTS rules for TSLint SonarTS Build Status(https://travisci.org/SonarSource/SonarTS.svg?branch=...

    2 年前
  • truffle-reporters

    Reporters for Truffle modules trufflereporters CDN by jsDelivr A free, fast, and relia...

    1 年前
  • sp-frontend

    undefined This project was bootstrapped with Create React App(https://github.com/facebookincubator/...

    5 个月前
  • sonarqube-scanner

    SonarQube/SonarCloud Scanner for the JavaScript world NPM module to run SonarQube/SonarCloud analy...

    2 年前
  • sonar-scanner

    Wrap sonarscanner as a node module nodesonarscanner ================== Wrap SonarQube Scanner(http...

    15 小时前
  • motionbank-systems-frontend

    Combined frontend project for Motion Bank web services comment: (ACHTUNG This is an autogenerated ...

    6 个月前
  • mocha-sonarqube-reporter

    mocha reporter for sonar (6) mochasonarqubereporter mocha unit test reporter for sonar (6.2) ...

    2 年前

官方社区

扫码加入 JavaScript 社区