87a38be548c98030c43a393e4e13a1f8861d51ab8080ddd7671f107d18ea0cd87f39e55c89247b1257b75946f482d3ffb3d38a2e39a0d2486ac1f123b34519 766 B

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. const concat = require('../utils').concat;
  3. const chalk = require('chalk');
  4. const infos = [
  5. 'You may use special comments to disable some warnings.',
  6. 'Use ' + chalk.yellow('// eslint-disable-next-line') + ' to ignore the next line.',
  7. 'Use ' + chalk.yellow('/* eslint-disable */') + ' to ignore all warnings in a file.'
  8. ];
  9. function displayError(error) {
  10. return [error.message, '']
  11. }
  12. function format(errors, type) {
  13. const lintErrors = errors.filter(e => e.type === 'lint-error');
  14. if (lintErrors.length > 0) {
  15. const flatten = (accum, curr) => accum.concat(curr);
  16. return concat(
  17. lintErrors
  18. .map(error => displayError(error))
  19. .reduce(flatten, []),
  20. infos
  21. )
  22. }
  23. return [];
  24. }
  25. module.exports = format;