UNPKG

htmlhint

Version:

The Static Code Analysis Tool for your HTML

57 lines (49 loc) 1.14 kB
var xml = require('xml') var checkstyleFormatter = function (formatter) { formatter.on('end', function (event) { var arrFiles = [] var arrAllMessages = event.arrAllMessages arrAllMessages.forEach(function (fileInfo) { var arrMessages = fileInfo.messages var arrErrors = [] arrMessages.forEach(function (message) { arrErrors.push({ error: { _attr: { line: message.line, column: message.col, severity: message.type, message: message.message, source: 'htmlhint.' + message.rule.id, }, }, }) }) arrFiles.push({ file: [ { _attr: { name: fileInfo.file, }, }, ].concat(arrErrors), }) }) var objXml = { checkstyle: [ { _attr: { version: '4.3', }, }, ].concat(arrFiles), } console.log( xml(objXml, { declaration: true, indent: ' ', }) ) }) } module.exports = checkstyleFormatter