@@ -22,18 +22,6 @@ interface LintResult extends tslint.LintResult {
22
22
fileNames : string [ ] ;
23
23
}
24
24
25
- async function _loadTslint ( ) {
26
- let tslint ;
27
- try {
28
- tslint = await import ( 'tslint' ) ;
29
- } catch {
30
- throw new Error ( 'Unable to find TSLint. Ensure TSLint is installed.' ) ;
31
- }
32
-
33
- return tslint ;
34
- }
35
-
36
-
37
25
async function _run (
38
26
options : TslintBuilderOptions ,
39
27
context : BuilderContext ,
@@ -55,11 +43,17 @@ async function _run(
55
43
throw new Error ( 'A "project" must be specified to enable type checking.' ) ;
56
44
}
57
45
58
- const projectTslint = await _loadTslint ( ) ;
46
+ let tslint ;
47
+ try {
48
+ tslint = await import ( 'tslint' ) ;
49
+ } catch {
50
+ throw new Error ( 'Unable to find TSLint. Ensure TSLint is installed.' ) ;
51
+ }
52
+
59
53
const tslintConfigPath = options . tslintConfig
60
54
? path . resolve ( systemRoot , options . tslintConfig )
61
55
: null ;
62
- const Linter = projectTslint . Linter ;
56
+ const Linter = tslint . Linter ;
63
57
64
58
let result : undefined | LintResult = undefined ;
65
59
if ( options . tsConfig ) {
@@ -72,7 +66,7 @@ async function _run(
72
66
let i = 0 ;
73
67
for ( const program of allPrograms ) {
74
68
const partial = await _lint (
75
- projectTslint ,
69
+ tslint ,
76
70
systemRoot ,
77
71
tslintConfigPath ,
78
72
options ,
@@ -102,15 +96,15 @@ async function _run(
102
96
context . reportProgress ( ++ i , allPrograms . length ) ;
103
97
}
104
98
} else {
105
- result = await _lint ( projectTslint , systemRoot , tslintConfigPath , options ) ;
99
+ result = await _lint ( tslint , systemRoot , tslintConfigPath , options ) ;
106
100
}
107
101
108
102
if ( result == undefined ) {
109
103
throw new Error ( 'Invalid lint configuration. Nothing to lint.' ) ;
110
104
}
111
105
112
106
if ( ! options . silent ) {
113
- const Formatter = projectTslint . findFormatter ( options . format || '' ) ;
107
+ const Formatter = tslint . findFormatter ( options . format || '' ) ;
114
108
if ( ! Formatter ) {
115
109
throw new Error ( `Invalid lint format "${ options . format } ".` ) ;
116
110
}
0 commit comments