-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: .npmignore package.json
- Loading branch information
Showing
52 changed files
with
3,232 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["latest"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
samples/ | ||
test/mocks/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,6 +136,7 @@ | |
"globals": { | ||
"module": true, | ||
"inject": true, | ||
"require": true | ||
"require": true, | ||
"process": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,10 @@ samples/ | |
reports/ | ||
node_modules/ | ||
test/ | ||
.editorconfig | ||
.eslintignore | ||
.eslintrc | ||
.travis.yml | ||
yarn.lock | ||
.git* | ||
.babelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,14 @@ You can also set it's property to `false`: | |
} | ||
``` | ||
|
||
#### ES5 backward compatibility | ||
|
||
To use the CLI with older NodeJS versions, you can use the `--es5` option: | ||
|
||
```sh | ||
$ sreporter --es5 | ||
``` | ||
|
||
### NodeJS | ||
|
||
You can launch all reporters: | ||
|
@@ -139,11 +147,20 @@ cssLintReporter.launch(() => { | |
}); | ||
``` | ||
|
||
#### ES5 backward compatibility | ||
|
||
To use it with older NodeJS versions, you can require the reporters this way: | ||
|
||
```js | ||
const SonarWebReporters = require('sonar-web-frontend-reporters').ES5.Reporters; | ||
const CSSLintReporter = require('sonar-web-frontend-reporters').ES5.CSSLintReporter; | ||
``` | ||
|
||
## Available reporters | ||
|
||
* CSSLint | ||
* SASSLint | ||
* SASSLint to SCSSLint (convert SASSLint rules to SCSSLint rules) | ||
* SASSLint to SCSSLint (convert SASSLint rules to SCSSLint rules, because the SonarQube plugin doesn't support SASSLint rules) | ||
* HTMLHint | ||
* ESLint | ||
* ESLint for AngularJS | ||
|
@@ -161,7 +178,7 @@ The main reasons for this **3.0** version were that: | |
|
||
> Warning: | ||
> | ||
> 3.x version is compatible with NodeJS version **>= 6.9.1** | ||
> 3.x version is compatible with NodeJS version **>= 6.5.0** with ES6 support and **>= 4.4.5** with ES5 backward compatibility | ||
You can still use the Gulp version by installing `[email protected]`. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,14 @@ | ||
#!/usr/bin/env node | ||
|
||
/* eslint no-console:off */ | ||
|
||
const fs = require('fs'), | ||
chalk = require('chalk'), | ||
ReporterType = require('../reporters/reporter.enum'), | ||
ReporterFactory = require('../reporters/reporter.factory'); | ||
|
||
class CLIEngine { | ||
|
||
constructor () { | ||
if (!fs.existsSync('./.sreporterrc')) { | ||
throw new Error('.sreporterrc file is missing'); | ||
} | ||
|
||
this.options = JSON.parse(fs.readFileSync('./.sreporterrc', 'utf8')); | ||
} | ||
|
||
/** | ||
* Launch the Sonar Web Front-End Reporters. | ||
* It automatically launch reporters registered under `ReporterType`. | ||
*/ | ||
launchReporters () { | ||
Object.keys(ReporterType).forEach((key) => this.launch(ReporterType[key], this.options)); | ||
} | ||
|
||
/** | ||
* Launch a reporter. | ||
* | ||
* @param {ReporterType} type Type of the reporter to be launched | ||
* @param {Object} options `.sreporterrc` file content | ||
*/ | ||
launch (type, options) { | ||
let opts = options[type], | ||
reporter = ReporterFactory.create(type, opts, options.projectName); | ||
|
||
if (opts) { | ||
reporter.launch(() => { | ||
console.info(chalk.green(`\u2714 ${chalk.green.bold(reporter.linterName)} has been generated under ${opts.report}`)); | ||
}); | ||
} else { | ||
console.info(chalk.gray(`\u002D ${chalk.gray.bold(reporter.linterName)} has been ignored`)); | ||
} | ||
} | ||
|
||
var es5 = (process.argv.indexOf('--es5') > -1), | ||
CLIEngine; | ||
|
||
// Use ES5 backward compatibility ? | ||
if (es5) { | ||
CLIEngine = require('../build/cli'); | ||
} else { | ||
CLIEngine = require('../lib/cli'); | ||
} | ||
|
||
let cli = new CLIEngine(); | ||
var cli = new CLIEngine(); | ||
cli.launchReporters(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
Reporters: require('./reporters'), | ||
CSSLintReporter: require('./reporters/csslint.reporter'), | ||
ESLintReporter: require('./reporters/eslint.reporter'), | ||
ESLintAngularReporter: require('./reporters/eslint-angular.reporter'), | ||
HTMLHintReporter: require('./reporters/htmlhint.reporter'), | ||
JSHintReporter: require('./reporters/jshint.reporter'), | ||
TSLintReporter: require('./reporters/tslint.reporter'), | ||
SASSLintReporter: require('./reporters/sasslint.reporter'), | ||
SASSToSCSSLintReporter: require('./reporters/sass-to-scsslint.reporter'), | ||
ES5: { | ||
Reporters: require('../build/reporters'), | ||
CSSLintReporter: require('../build/reporters/csslint.reporter'), | ||
ESLintReporter: require('../build/reporters/eslint.reporter'), | ||
ESLintAngularReporter: require('../build/reporters/eslint-angular.reporter'), | ||
HTMLHintReporter: require('../build/reporters/htmlhint.reporter'), | ||
JSHintReporter: require('../build/reporters/jshint.reporter'), | ||
TSLintReporter: require('../build/reporters/tslint.reporter'), | ||
SASSLintReporter: require('../build/reporters/sasslint.reporter'), | ||
SASSToSCSSLintReporter: require('../build/reporters/sass-to-scsslint.reporter') | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
'use strict'; | ||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
/* eslint no-console:off */ | ||
|
||
var fs = require('fs'), | ||
chalk = require('chalk'), | ||
ReporterType = require('./reporter.enum'), | ||
ReporterFactory = require('./reporter.factory'); | ||
|
||
var CLIEngine = function () { | ||
function CLIEngine() { | ||
_classCallCheck(this, CLIEngine); | ||
|
||
if (!fs.existsSync('./.sreporterrc')) { | ||
throw new Error('.sreporterrc file is missing'); | ||
} | ||
|
||
this.options = JSON.parse(fs.readFileSync('./.sreporterrc', 'utf8')); | ||
} | ||
|
||
/** | ||
* Launch the Sonar Web Front-End Reporters. | ||
* It automatically launch reporters registered under `ReporterType`. | ||
*/ | ||
|
||
|
||
_createClass(CLIEngine, [{ | ||
key: 'launchReporters', | ||
value: function launchReporters() { | ||
var _this = this; | ||
|
||
Object.keys(ReporterType).forEach(function (key) { | ||
return _this.launch(ReporterType[key], _this.options); | ||
}); | ||
} | ||
|
||
/** | ||
* Launch a reporter. | ||
* | ||
* @param {ReporterType} type Type of the reporter to be launched | ||
* @param {Object} options `.sreporterrc` file content | ||
*/ | ||
|
||
}, { | ||
key: 'launch', | ||
value: function launch(type, options) { | ||
var opts = options[type], | ||
reporter = ReporterFactory.create(type, opts, options.projectName); | ||
|
||
if (opts) { | ||
reporter.launch(function () { | ||
console.info(chalk.green('\u2714 ' + chalk.green.bold(reporter.linterName) + ' has been generated under ' + opts.report)); | ||
}); | ||
} else { | ||
console.info(chalk.gray('- ' + chalk.gray.bold(reporter.linterName) + ' has been ignored')); | ||
} | ||
} | ||
}]); | ||
|
||
return CLIEngine; | ||
}(); | ||
|
||
module.exports = CLIEngine; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
var ReporterType = { | ||
CSSLINT: 'csslint', | ||
ESLINT: 'eslint', | ||
ESLINTANGULAR: 'eslintangular', | ||
HTMLHINT: 'htmlhint', | ||
JSHINT: 'jshint', | ||
TSLINT: 'tslint', | ||
SASSLINT: 'sasslint', | ||
SASS_TO_SCSSLINT: 'sass-to-scsslint' | ||
}; | ||
|
||
module.exports = ReporterType; |
Oops, something went wrong.