Custom linter to check code quality (#2753)
This commit is contained in:
parent
366401f77a
commit
ecb126e74c
13 changed files with 7467 additions and 66 deletions
29
ts/util/lint/analyze_exceptions.ts
Normal file
29
ts/util/lint/analyze_exceptions.ts
Normal 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, ' '));
|
Loading…
Add table
Add a link
Reference in a new issue