blob: fcd1b68444ee12480516c7e0d48c20ac986236e2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import * as path from 'path';
import { Configuration, Linter, Replacement } from 'tslint';
export const helper = (src: string, rule: string) => {
const linter = new Linter({ fix: false });
linter.lint(
'',
src,
Configuration.parseConfigFile({
rules: {
[rule]: true,
},
rulesDirectory: path.join(__dirname, '../rules'),
}),
);
return linter.getResult();
};
export const getFixedResult = (src: string, rule: string) => {
const result = helper(src, rule);
const fixes = [].concat.apply(result.failures.map(x => x.getFix()));
return Replacement.applyFixes(src, fixes);
};
|