1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var tslint_1 = require("tslint");
|
4 | var typescript_1 = require("typescript");
|
5 | var util_1 = require("util");
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | function lint(linter, config, filePath, fileContents) {
|
14 | linter.lint(filePath, fileContents, config);
|
15 | }
|
16 | exports.lint = lint;
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function getLintResult(linter) {
|
23 | return linter.getResult();
|
24 | }
|
25 | exports.getLintResult = getLintResult;
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | function typeCheck(context, program, linterOptions) {
|
34 | if (util_1.isObject(linterOptions) && linterOptions.typeCheck) {
|
35 | return Promise.resolve(typescript_1.getPreEmitDiagnostics(program));
|
36 | }
|
37 | return Promise.resolve([]);
|
38 | }
|
39 | exports.typeCheck = typeCheck;
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | function createProgram(context, tsConfig) {
|
47 | return tslint_1.Linter.createProgram(tsConfig, context.rootDir);
|
48 | }
|
49 | exports.createProgram = createProgram;
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | function getFileNames(context, program) {
|
57 | return tslint_1.Linter.getFileNames(program);
|
58 | }
|
59 | exports.getFileNames = getFileNames;
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | function getTsLintConfig(tsLintConfig, linterOptions) {
|
67 | var config = tslint_1.Configuration.loadConfigurationFromPath(tsLintConfig);
|
68 | Object.assign(config, util_1.isObject(linterOptions) ? { linterOptions: linterOptions } : {});
|
69 | return config;
|
70 | }
|
71 | exports.getTsLintConfig = getTsLintConfig;
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | function createLinter(context, program) {
|
79 | return new tslint_1.Linter({
|
80 | fix: false
|
81 | }, program);
|
82 | }
|
83 | exports.createLinter = createLinter;
|