@@ -6,6 +6,8 @@ import * as glob from 'glob';
66import * as path from 'path' ;
77import { satisfies } from 'semver' ;
88import * as ts from 'typescript' ;
9+ // @ignoreDep tslint - used only for type information
10+ import * as tslint from 'tslint' ;
911import { requireProjectModule } from '../utilities/require-project-module' ;
1012
1113const SilentError = require ( 'silent-error' ) ;
@@ -41,9 +43,9 @@ export default Task.extend({
4143 return Promise . resolve ( 0 ) ;
4244 }
4345
44- const tslint = requireProjectModule ( projectRoot , 'tslint' ) ;
45- const Linter = tslint . Linter ;
46- const Configuration = tslint . Configuration ;
46+ const projectTslint = requireProjectModule ( projectRoot , 'tslint' ) as typeof tslint ;
47+ const Linter = projectTslint . Linter ;
48+ const Configuration = projectTslint . Configuration ;
4749
4850 const result = lintConfigs
4951 . map ( ( config ) => {
@@ -69,9 +71,9 @@ export default Task.extend({
6971
7072 const linter = new Linter ( lintOptions , program ) ;
7173
72- let lastDirectory : string ;
73- let configLoad : any ;
74- files . forEach ( ( file ) => {
74+ let lastDirectory ;
75+ let configLoad ;
76+ for ( const file of files ) {
7577 // The linter retrieves the SourceFile TS node directly if a program is used
7678 const fileContents = program ? undefined : getFileContents ( file ) ;
7779
@@ -83,13 +85,13 @@ export default Task.extend({
8385 }
8486
8587 linter . lint ( file , fileContents , configLoad . results ) ;
86- } ) ;
88+ }
8789
8890 return linter . getResult ( ) ;
8991 } )
9092 . reduce ( ( total , current ) => {
9193 const failures = current . failures
92- . filter ( ( cf : any ) => ! total . failures . some ( ( ef : any ) => ef . equals ( cf ) ) ) ;
94+ . filter ( cf => ! total . failures . some ( ef => ef . equals ( cf ) ) ) ;
9395 total . failures = total . failures . concat ( ...failures ) ;
9496
9597 if ( current . fixes ) {
@@ -102,7 +104,7 @@ export default Task.extend({
102104 } ) ;
103105
104106 if ( ! options . silent ) {
105- const Formatter = tslint . findFormatter ( options . format ) ;
107+ const Formatter = projectTslint . findFormatter ( options . format ) ;
106108 if ( ! Formatter ) {
107109 throw new SilentError ( chalk . red ( `Invalid lint format "${ options . format } ".` ) ) ;
108110 }
@@ -134,13 +136,17 @@ export default Task.extend({
134136 }
135137} ) ;
136138
137- function getFilesToLint ( program : ts . Program , lintConfig : CliLintConfig , Linter : any ) : string [ ] {
139+ function getFilesToLint (
140+ program : ts . Program ,
141+ lintConfig : CliLintConfig ,
142+ linter : typeof tslint . Linter ,
143+ ) : string [ ] {
138144 let files : string [ ] = [ ] ;
139145
140146 if ( lintConfig . files ) {
141147 files = Array . isArray ( lintConfig . files ) ? lintConfig . files : [ lintConfig . files ] ;
142148 } else if ( program ) {
143- files = Linter . getFileNames ( program ) ;
149+ files = linter . getFileNames ( program ) ;
144150 }
145151
146152 let globOptions = { } ;
0 commit comments