-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.js
25 lines (24 loc) · 975 Bytes
/
index.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
var escape = require('lodash/escape');
var checkstyleVersion = '4.3'; // Why? Because that's what ESLint uses, I suppose
module.exports = function(stylelintResults) {
var xml = '<?xml version="1.0" encoding="utf-8"?>';
xml += '\n<checkstyle version="' + checkstyleVersion + '">';
stylelintResults.forEach(function(stylelintResult) {
xml += '\n <file name="' + escape(stylelintResult.source) + '">';
if (!stylelintResult.warnings.length) {
xml += '</file>';
return;
}
stylelintResult.warnings.forEach(function(warning) {
xml += '\n <error source="' + escape('stylelint.rules.' + warning.rule) + '" ';
xml += 'line="' + escape(warning.line) + '" ';
xml += 'column="' + escape(warning.column) + '" ';
xml += 'severity="' + escape(warning.severity) + '" ';
xml += 'message="' + escape(warning.text) + '" ';
xml += '/>';
});
xml += '\n </file>';
});
xml += '\n</checkstyle>';
return xml;
}