Created
October 4, 2021 20:34
-
-
Save eban5/5ca91e59b334d8106172a2edabaefc6d to your computer and use it in GitHub Desktop.
Format the output of ESLint to group by rule-id
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
// breakdown by type (ruleId) | |
module.exports = function (results) { | |
const processed = results | |
.filter((result) => result.messages.length > 0) | |
.map((result) => result.messages.map((item) => item.ruleId)) | |
.flat(); | |
const filtered = processed.reduce((acc, val) => { | |
acc[val] = acc[val] === undefined ? 1 : (acc[val] += 1); | |
return acc; | |
}, {}); | |
console.log(filtered); | |
return processed; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment