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
24
ts/util/lint/util.ts
Normal file
24
ts/util/lint/util.ts
Normal 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']);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue