-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtext.js
60 lines (50 loc) · 1.53 KB
/
text.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(function() {
'use strict';
var colors = require('colors');
module.exports = {
id: 'text',
/**
* Return content to be printed before all file results.
* @return {String} to prepend before all results
*/
startFormat: function() {
return '';
},
/**
* Return content to be printed after all file results.
* @return {String} to append after all results
*/
endFormat: function() {
return '';
},
formatResults: function(messages, filename, options) {
var output = '';
/**
* Capitalize and return given string.
* @param str {String} to capitalize
* @return {String} capitalized
*/
var capitalize = function(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
};
if (messages.length === 0) {
return options.quiet ? '' : filename + ': Lint Free!';
}
var len = messages.length;
output += ('* File: '.bold + filename + ' has ' + len + ' error/s.\n').red;
for (var x = 0; x < len; x++) {
if(options.printElement && messages[x].element ) {
output += messages[x].element + '\n';
}
output += capitalize(messages[x].type).red + ': ';
output += capitalize(messages[x].rule.name) + '\n';
output += 'Description: '.red + capitalize(messages[x].rule.message) + '\n';
output += 'Rule URL: '.red + messages[x].rule.ruleUrl + '\n';
if (x < len) {
output += '\n';
}
}
return output;
}
};
}());