-
Notifications
You must be signed in to change notification settings - Fork 2
/
stylishFormatter.js
29 lines (29 loc) · 954 Bytes
/
stylishFormatter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/// <reference path="../typings/stylish.d.ts"/>
"use strict";
var _ = require("lodash");
var Reporter = require("./reporter");
var Formatter = (function () {
function Formatter() {
this.files = {};
}
Formatter.prototype.format = function (failures) {
this.invertLints(failures);
var output = "";
_.forEach(this.files, function (linterOutput) {
var reporter = new Reporter(linterOutput, linterOutput[0].fileName, { bell: false });
output += reporter.toString();
});
return output;
};
Formatter.prototype.invertLints = function (failures) {
var _this = this;
failures.forEach(function (failure) {
if (!_this.files[failure.fileName]) {
_this.files[failure.fileName] = [];
}
_this.files[failure.fileName].push(failure);
});
};
return Formatter;
}());
exports.Formatter = Formatter;