UNPKG

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