Skip to content

Instantly share code, notes, and snippets.

@eban5
Created October 4, 2021 20:34
Show Gist options
  • Save eban5/5ca91e59b334d8106172a2edabaefc6d to your computer and use it in GitHub Desktop.
Save eban5/5ca91e59b334d8106172a2edabaefc6d to your computer and use it in GitHub Desktop.
Format the output of ESLint to group by rule-id
// 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