@@ -311,26 +311,7 @@ impl LintRunner {
311311 . filter ( |path| !ignore_matcher. should_ignore ( Path :: new ( path) ) )
312312 . collect :: < Vec < Arc < OsStr > > > ( ) ;
313313
314- // Run type-aware linting through tsgolint
315- // TODO: Add a warning message if `tsgolint` cannot be found, but type-aware rules are enabled
316- if self . options . type_aware {
317- let state = match TsGoLintState :: try_new ( options. cwd ( ) , config_store. clone ( ) ) {
318- Ok ( state) => state,
319- Err ( err) => {
320- print_and_flush_stdout ( stdout, & err) ;
321- return CliRunResult :: TsGoLintError ;
322- }
323- } ;
324-
325- if let Err ( err) =
326- state. with_silent ( misc_options. silent ) . lint ( & files_to_lint, tx_error. clone ( ) )
327- {
328- print_and_flush_stdout ( stdout, & err) ;
329- return CliRunResult :: TsGoLintError ;
330- }
331- }
332-
333- let linter = Linter :: new ( LintOptions :: default ( ) , config_store, external_linter)
314+ let linter = Linter :: new ( LintOptions :: default ( ) , config_store. clone ( ) , external_linter)
334315 . with_fix ( fix_options. fix_kind ( ) )
335316 . with_report_unused_directives ( report_unused_directives) ;
336317
@@ -357,35 +338,56 @@ impl LintRunner {
357338
358339 let number_of_rules = linter. number_of_rules ( self . options . type_aware ) ;
359340
341+ let cwd = options. cwd ( ) . to_path_buf ( ) ;
342+
360343 // Spawn linting in another thread so diagnostics can be printed immediately from diagnostic_service.run.
361- rayon:: spawn ( move || {
362- let has_external_linter = linter. has_external_linter ( ) ;
363-
364- let mut lint_service = LintService :: new ( linter, options) ;
365- lint_service. with_paths ( files_to_lint) ;
366-
367- // Use `RawTransferFileSystem` if `ExternalLinter` exists.
368- // This reads the source text into start of allocator, instead of the end.
369- if has_external_linter {
370- #[ cfg( all(
371- feature = "napi" ,
372- target_pointer_width = "64" ,
373- target_endian = "little"
374- ) ) ]
375- lint_service. with_file_system ( Box :: new ( crate :: js_plugins:: RawTransferFileSystem ) ) ;
376-
377- #[ cfg( not( all(
378- feature = "napi" ,
379- target_pointer_width = "64" ,
380- target_endian = "little"
381- ) ) ) ]
382- unreachable ! (
383- "On unsupported platforms, or with `napi` Cargo feature disabled, `ExternalLinter` should not exist"
384- ) ;
385- }
344+ {
345+ let tx_error = tx_error. clone ( ) ;
346+ let files_to_lint = files_to_lint. clone ( ) ;
347+ rayon:: spawn ( move || {
348+ let has_external_linter = linter. has_external_linter ( ) ;
349+
350+ let mut lint_service = LintService :: new ( linter, options) ;
351+ lint_service. with_paths ( files_to_lint) ;
352+
353+ // Use `RawTransferFileSystem` if `ExternalLinter` exists.
354+ // This reads the source text into start of allocator, instead of the end.
355+ if has_external_linter {
356+ #[ cfg( all(
357+ feature = "napi" ,
358+ target_pointer_width = "64" ,
359+ target_endian = "little"
360+ ) ) ]
361+ lint_service
362+ . with_file_system ( Box :: new ( crate :: js_plugins:: RawTransferFileSystem ) ) ;
363+
364+ #[ cfg( not( all(
365+ feature = "napi" ,
366+ target_pointer_width = "64" ,
367+ target_endian = "little"
368+ ) ) ) ]
369+ unreachable ! (
370+ "On unsupported platforms, or with `napi` Cargo feature disabled, `ExternalLinter` should not exist"
371+ ) ;
372+ }
373+
374+ lint_service. run ( & tx_error) ;
375+ } ) ;
376+ }
386377
387- lint_service. run ( & tx_error) ;
388- } ) ;
378+ // Run type-aware linting through tsgolint
379+ // TODO: Add a warning message if `tsgolint` cannot be found, but type-aware rules are enabled
380+ if self . options . type_aware {
381+ if let Err ( err) = TsGoLintState :: new ( & cwd, config_store)
382+ . with_silent ( misc_options. silent )
383+ . lint ( & files_to_lint, tx_error)
384+ {
385+ print_and_flush_stdout ( stdout, & err) ;
386+ return CliRunResult :: TsGoLintError ;
387+ }
388+ } else {
389+ drop ( tx_error) ;
390+ }
389391
390392 let diagnostic_result = diagnostic_service. run ( stdout) ;
391393
0 commit comments