UNPKG

528 BJavaScriptView Raw
1'use strict';
2
3const _ = require('lodash');
4
5/**
6 * @type {import('stylelint').Formatter}
7 */
8const unixFormatter = (results) => {
9 const lines = _.flatMap(results, (result) =>
10 result.warnings.map(
11 (warning) =>
12 `${result.source}:${warning.line}:${warning.column}: ` +
13 `${warning.text} [${warning.severity}]\n`,
14 ),
15 );
16 const total = lines.length;
17 let output = lines.join('');
18
19 if (total > 0) {
20 output += `\n${total} problem${total !== 1 ? 's' : ''}\n`;
21 }
22
23 return output;
24};
25
26module.exports = unixFormatter;