3bdc9f91915c2b72e62e769ec311a8c927a624fa.svn-base
1.46 KB
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
// Author: Vasili Sviridov
// http://github.com/vsviridov
module.exports =
{
reporter: function (results)
{
"use strict";
var files = {},
out = [],
pairs = {
"&": "&",
'"': """,
"'": "'",
"<": "<",
">": ">"
},
file, i, issue;
function encode(s) {
for (var r in pairs) {
if (typeof(s) !== "undefined") {
s = s.replace(new RegExp(r, "g"), pairs[r]);
}
}
return s || "";
}
results.forEach(function (result) {
result.file = result.file.replace(/^\.\//, '');
if (!files[result.file]) {
files[result.file] = [];
}
files[result.file].push(result.error);
});
out.push("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
out.push("<jslint>");
for (file in files) {
out.push("\t<file name=\"" + file + "\">");
for (i = 0; i < files[file].length; i++) {
issue = files[file][i];
out.push("\t\t<issue line=\"" + issue.line + "\" char=\"" + issue.character + "\" reason=\"" + encode(issue.reason) + "\" evidence=\"" + encode(issue.evidence) + "\" />");
}
out.push("\t</file>");
}
out.push("</jslint>");
process.stdout.write(out.join("\n") + "\n");
}
};