You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.0 KiB

4 years ago
  1. /**
  2. * @fileoverview JSLint XML reporter
  3. * @author Ian Christian Myers
  4. */
  5. "use strict";
  6. const xmlEscape = require("../xml-escape");
  7. //------------------------------------------------------------------------------
  8. // Public Interface
  9. //------------------------------------------------------------------------------
  10. module.exports = function(results) {
  11. let output = "";
  12. output += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
  13. output += "<jslint>";
  14. results.forEach(result => {
  15. const messages = result.messages;
  16. output += `<file name="${result.filePath}">`;
  17. messages.forEach(message => {
  18. output += [
  19. `<issue line="${message.line}"`,
  20. `char="${message.column}"`,
  21. `evidence="${xmlEscape(message.source || "")}"`,
  22. `reason="${xmlEscape(message.message || "")}${message.ruleId ? ` (${message.ruleId})` : ""}" />`
  23. ].join(" ");
  24. });
  25. output += "</file>";
  26. });
  27. output += "</jslint>";
  28. return output;
  29. };