tapFormatter.js 895 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. ` endLine: ${warning.endLine}`,
  23. ` endColumn: ${warning.endColumn}`,
  24. ` ruleId: ${warning.rule}`,
  25. );
  26. }
  27. lines.push('---');
  28. }
  29. }
  30. lines.push('');
  31. return lines.join('\n');
  32. };
  33. module.exports = tapFormatter;