@@ -312,28 +312,10 @@ impl LintRunner {
312312 . filter ( |path| !ignore_matcher. should_ignore ( Path :: new ( path) ) )
313313 . collect :: < Vec < Arc < OsStr > > > ( ) ;
314314
315- // Run type-aware linting through tsgolint
316- // TODO: Add a warning message if `tsgolint` cannot be found, but type-aware rules are enabled
317- if self . options . type_aware {
318- let state = match TsGoLintState :: try_new ( options. cwd ( ) , config_store. clone ( ) ) {
319- Ok ( state) => state,
320- Err ( err) => {
321- print_and_flush_stdout ( stdout, & err) ;
322- return CliRunResult :: TsGoLintError ;
323- }
324- } ;
325-
326- if let Err ( err) =
327- state. with_silent ( misc_options. silent ) . lint ( & files_to_lint, tx_error. clone ( ) )
328- {
329- print_and_flush_stdout ( stdout, & err) ;
330- return CliRunResult :: TsGoLintError ;
331- }
332- }
333-
334- let linter = Linter :: new ( LintOptions :: default ( ) , config_store, external_linter)
335- . with_fix ( fix_options. fix_kind ( ) )
336- . with_report_unused_directives ( report_unused_directives) ;
315+ let linter =
316+ Linter :: new ( LintOptions :: default ( ) , config_store. clone ( ) , external_linter)
317+ . with_fix ( fix_options. fix_kind ( ) )
318+ . with_report_unused_directives ( report_unused_directives) ;
337319
338320 let number_of_files = files_to_lint. len ( ) ;
339321
@@ -358,21 +340,41 @@ impl LintRunner {
358340
359341 let number_of_rules = linter. number_of_rules ( self . options . type_aware ) ;
360342
343+ let cwd = options. cwd ( ) . to_path_buf ( ) ;
344+
361345 // Spawn linting in another thread so diagnostics can be printed immediately from diagnostic_service.run.
362- rayon:: spawn ( move || {
363- let has_external_linter = linter. has_external_linter ( ) ;
346+ {
347+ let tx_error = tx_error. clone ( ) ;
348+ let files_to_lint = files_to_lint. clone ( ) ;
349+ rayon:: spawn ( move || {
350+ let has_external_linter = linter. has_external_linter ( ) ;
351+
352+ let mut lint_service = LintService :: new ( linter, options) ;
353+ lint_service. with_paths ( files_to_lint) ;
354+
355+ // Use `RawTransferFileSystem` if `ExternalLinter` exists.
356+ // This reads the source text into start of allocator, instead of the end.
357+ if has_external_linter {
358+ lint_service. with_file_system ( Box :: new ( RawTransferFileSystem ) ) ;
359+ }
364360
365- let mut lint_service = LintService :: new ( linter, options) ;
366- lint_service. with_paths ( files_to_lint) ;
361+ lint_service. run ( & tx_error) ;
362+ } ) ;
363+ }
367364
368- // Use `RawTransferFileSystem` if `ExternalLinter` exists.
369- // This reads the source text into start of allocator, instead of the end.
370- if has_external_linter {
371- lint_service. with_file_system ( Box :: new ( RawTransferFileSystem ) ) ;
365+ // Run type-aware linting through tsgolint
366+ // TODO: Add a warning message if `tsgolint` cannot be found, but type-aware rules are enabled
367+ if self . options . type_aware {
368+ if let Err ( err) = TsGoLintState :: new ( & cwd, config_store)
369+ . with_silent ( misc_options. silent )
370+ . lint ( & files_to_lint, tx_error)
371+ {
372+ print_and_flush_stdout ( stdout, & err) ;
373+ return CliRunResult :: TsGoLintError ;
372374 }
373-
374- lint_service . run ( & tx_error) ;
375- } ) ;
375+ } else {
376+ drop ( tx_error) ;
377+ }
376378
377379 let diagnostic_result = diagnostic_service. run ( stdout) ;
378380
0 commit comments