Custom linter to check code quality (#2753)

This commit is contained in:
Scott Nonnenberg 2018-09-20 15:24:52 -07:00 committed by GitHub
parent 366401f77a
commit ecb126e74c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 7467 additions and 66 deletions

View file

@ -0,0 +1,29 @@
// tslint:disable no-console
import { join } from 'path';
import { fromPairs, groupBy, map } from 'lodash';
import { ExceptionType } from './types';
import { loadJSON } from './util';
const exceptionsPath = join(__dirname, 'exceptions.json');
const exceptions: Array<ExceptionType> = loadJSON(exceptionsPath);
const byRule = groupBy(exceptions, 'rule');
const byRuleThenByCategory = fromPairs(
map(byRule, (list, ruleName) => {
const byCategory = groupBy(list, 'reasonCategory');
return [
ruleName,
fromPairs(
map(byCategory, (innerList, categoryName) => {
return [categoryName, innerList.length];
})
),
];
})
);
console.log(JSON.stringify(byRuleThenByCategory, null, ' '));