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

24
ts/util/lint/util.ts Normal file
View file

@ -0,0 +1,24 @@
// tslint:disable no-console
import { readFileSync } from 'fs';
import { orderBy } from 'lodash';
import { ExceptionType } from './types';
export const ENCODING = 'utf8';
export function loadJSON(target: string) {
try {
const contents = readFileSync(target, ENCODING);
return JSON.parse(contents);
} catch (error) {
console.log(`Error loading JSON from ${target}: ${error.stack}`);
throw error;
}
}
export function sortExceptions(exceptions: Array<ExceptionType>) {
return orderBy(exceptions, ['path', 'lineNumber', 'rule']);
}