UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

42 lines (39 loc) 1.18 kB
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray'; import { readFileSync } from '../fs/fs.mjs'; import '../nodejs/crypto.mjs'; import '../nodejs/fs.mjs'; import '../nodejs/os.mjs'; function parseEslintError(_ref) { var lintReportFile = _ref.lintReportFile; var report = readFileSync(lintReportFile, true) || {}; var errors = (report.results || []).filter(function (item) { return !!item.errorCount; }); var total = errors.reduce(function (acc, item) { return acc + item.errorCount; }, 0); var errorMap = errors.reduce(function (acc, item) { acc.push.apply(acc, _toConsumableArray(item.messages.filter(function (item) { return item.severity == 2; }).map(function (msg) { return Object.assign(Object.assign({}, msg), { filePath: item.filePath, errorCount: item.errorCount }); }))); return acc; }, []).reduce(function (acc, item) { if (!acc[item.ruleId]) { item.number = 1; acc[item.ruleId] = item; } else { acc[item.ruleId].number += 1; } return acc; }, {}); return { errorMap: errorMap, total: total }; } export { parseEslintError };