unixFormatter.js 495 B

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