Created
November 21, 2023 08:35
-
-
Save louis-young/b086a3e43ab017dda6ace993095d1b4e to your computer and use it in GitHub Desktop.
ESLint formatter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (results) => { | |
const byRuleId = results.reduce((map, current) => { | |
for (const { column, line, ruleId } of current.messages) { | |
if (!map[ruleId]) { | |
map[ruleId] = []; | |
} | |
const occurrence = `${current.filePath}:${line}:${column}`; | |
map[ruleId].push(occurrence); | |
} | |
return map; | |
}, {}); | |
return Object.entries(byRuleId) | |
.map(([ruleId, occurrences]) => ({ | |
ruleId, | |
total: occurrences.length, | |
})) | |
.sort((a, b) => b.total - a.total) | |
.map((rule) => `${rule.ruleId}: ${rule.total}`) | |
.join("\n"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment