diff options
Diffstat (limited to 'packages/tslint-config/test/lintrunner.ts')
-rw-r--r-- | packages/tslint-config/test/lintrunner.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/tslint-config/test/lintrunner.ts b/packages/tslint-config/test/lintrunner.ts new file mode 100644 index 000000000..fcd1b6844 --- /dev/null +++ b/packages/tslint-config/test/lintrunner.ts @@ -0,0 +1,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); +}; |