canonical
Version:
Canonical code style linter and formatter for JavaScript, SCSS and CSS.
27 lines (25 loc) • 937 B
JavaScript
function escapeAttrValue(attrValue) {
return String(attrValue)
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/</g, '<')
.replace(/>/g, '>');
}
module.exports = function(errorCollection) {
console.log('<?xml version="1.0" encoding="utf-8"?>\n<checkstyle version="4.3">');
errorCollection.forEach(function(errors) {
console.log(' <file name="' + escapeAttrValue(errors.getFilename()) + '">');
errors.getErrorList().forEach(function(error) {
console.log(
' <error ' +
'line="' + error.line + '" ' +
'column="' + (error.column + 1) + '" ' +
'severity="error" ' +
'message="' + escapeAttrValue(error.message) + '" ' +
'source="jscs" />'
);
});
console.log(' </file>');
});
console.log('</checkstyle>');
};