mirror of
https://github.com/hanzoai/eslint.git
synced 2026-10-30 19:38:10 +00:00
* feat: implement api support for bulk-suppressions * Implement PR feedback * Assume normalized options Co-authored-by: Francesco Trotta <[email protected]> * Assume normalized options Co-authored-by: Francesco Trotta <[email protected]> * Implement PR feedback * Additional feedback * Correct test placement --------- Co-authored-by: Francesco Trotta <[email protected]>
47 lines
941 B
JavaScript
47 lines
941 B
JavaScript
/**
|
|
* @fileoverview Helpers for counting errors and warnings in lint messages.
|
|
* @author Nicholas C. Zakas
|
|
* @author Blake Sager
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* It will calculate the error and warning count for collection of messages per file
|
|
* @param {LintMessage[]} messages Collection of messages
|
|
* @returns {Object} Contains the stats
|
|
*/
|
|
function calculateStatsPerFile(messages) {
|
|
const stat = {
|
|
errorCount: 0,
|
|
fatalErrorCount: 0,
|
|
warningCount: 0,
|
|
fixableErrorCount: 0,
|
|
fixableWarningCount: 0,
|
|
};
|
|
|
|
for (let i = 0; i < messages.length; i++) {
|
|
const message = messages[i];
|
|
|
|
if (message.fatal || message.severity === 2) {
|
|
stat.errorCount++;
|
|
if (message.fatal) {
|
|
stat.fatalErrorCount++;
|
|
}
|
|
if (message.fix) {
|
|
stat.fixableErrorCount++;
|
|
}
|
|
} else {
|
|
stat.warningCount++;
|
|
if (message.fix) {
|
|
stat.fixableWarningCount++;
|
|
}
|
|
}
|
|
}
|
|
return stat;
|
|
}
|
|
|
|
module.exports = {
|
|
calculateStatsPerFile,
|
|
};
|