tapFormatter.js 809 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. /**
  3. * @type {import('stylelint').Formatter}
  4. */
  5. const tapFormatter = (results) => {
  6. const lines = [`TAP version 13\n1..${results.length}`];
  7. for (const [index, result] of results.entries()) {
  8. lines.push(
  9. `${result.errored ? 'not ok' : 'ok'} ${index + 1} - ${result.ignored ? 'ignored ' : ''}${
  10. result.source
  11. }`,
  12. );
  13. if (result.warnings.length > 0) {
  14. lines.push('---', 'messages:');
  15. for (const warning of result.warnings) {
  16. lines.push(
  17. ` - message: "${warning.text}"`,
  18. ` severity: ${warning.severity}`,
  19. ` data:`,
  20. ` line: ${warning.line}`,
  21. ` column: ${warning.column}`,
  22. ` ruleId: ${warning.rule}`,
  23. );
  24. }
  25. lines.push('---');
  26. }
  27. }
  28. lines.push('');
  29. return lines.join('\n');
  30. };
  31. module.exports = tapFormatter;