Skip to content

Instantly share code, notes, and snippets.

@jahredhope
Created September 18, 2017 11:00
Show Gist options
  • Save jahredhope/53aa2f0e6126444c896af56c0a1d114d to your computer and use it in GitHub Desktop.
Save jahredhope/53aa2f0e6126444c896af56c0a1d114d to your computer and use it in GitHub Desktop.
Takes an eslint json file and pulls out the count of each error
// eslint -f json . > output.json
const data = require('./output.json');
const result = {};
const files = new Set();
data
.filter(({ warningCount, errorCount }) => warningCount > 0 || errorCount > 0)
.forEach(fileProps => {
const { messages, filePath } = fileProps;
messages.forEach(props => {
const { ruleId } = props;
if (ruleId === 'no-unused-vars') {
files.add(filePath);
}
if (!result[ruleId]) {
result[ruleId] = 1;
} else {
result[ruleId]++;
}
});
});
console.log(result);
console.log('Files with issues', files.size);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment