claro-8.x-1.x-dev/scripts/js/eslint-stats-by-type.js

scripts/js/eslint-stats-by-type.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module.exports = function (results) {
  results = results || [];
 
  const errorType = {
    warnings: {},
    errors: {},
  };
 
  results.reduce((result, current) => {
    current.messages.forEach((msg) => {
      if (msg.severity === 1) {
        errorType.warnings[msg.ruleId] = errorType.warnings[msg.ruleId] + 1 || 1
      }
      if (msg.severity === 2) {
        errorType.errors[msg.ruleId] = errorType.errors[msg.ruleId] + 1 || 1
      }
    });
    return result;
  });
 
  const reduceErrorCounts = (errorType) => Object.entries(errorType).sort((a, b) => b[1] - a[1])
    .reduce((result, current) => result.concat([`${current[0]}: ${current[1]}`]), []).join('\n');
 
  const warnings = reduceErrorCounts(errorType.warnings);
  const errors = reduceErrorCounts(errorType.errors);
 
  return `
Errors:
${'='.repeat(30)}
${errors}
${'\n'.repeat(4)}
Warnings:
${'='.repeat(30)}
${warnings}`;
};

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc