@@ -305,21 +305,10 @@ impl LintRunner {
305305 . filter ( |path| !ignore_matcher. should_ignore ( Path :: new ( path) ) )
306306 . collect :: < Vec < Arc < OsStr > > > ( ) ;
307307
308- // Run type-aware linting through tsgolint
309- // TODO: Add a warning message if `tsgolint` cannot be found, but type-aware rules are enabled
310- if self . options . type_aware {
311- if let Err ( err) = TsGoLintState :: new ( options. cwd ( ) , config_store. clone ( ) )
312- . with_silent ( misc_options. silent )
313- . lint ( & files_to_lint, tx_error. clone ( ) )
314- {
315- print_and_flush_stdout ( stdout, & err) ;
316- return CliRunResult :: TsGoLintError ;
317- }
318- }
319-
320- let linter = Linter :: new ( LintOptions :: default ( ) , config_store, self . external_linter )
321- . with_fix ( fix_options. fix_kind ( ) )
322- . with_report_unused_directives ( report_unused_directives) ;
308+ let linter =
309+ Linter :: new ( LintOptions :: default ( ) , config_store. clone ( ) , self . external_linter )
310+ . with_fix ( fix_options. fix_kind ( ) )
311+ . with_report_unused_directives ( report_unused_directives) ;
323312
324313 let number_of_files = files_to_lint. len ( ) ;
325314
@@ -344,21 +333,41 @@ impl LintRunner {
344333
345334 let number_of_rules = linter. number_of_rules ( self . options . type_aware ) ;
346335
336+ let cwd = options. cwd ( ) . to_path_buf ( ) ;
337+
347338 // Spawn linting in another thread so diagnostics can be printed immediately from diagnostic_service.run.
348- rayon:: spawn ( move || {
349- let mut lint_service = LintService :: new ( linter, options) ;
350- lint_service. with_paths ( files_to_lint) ;
339+ {
340+ let tx_error = tx_error. clone ( ) ;
341+ let files_to_lint = files_to_lint. clone ( ) ;
342+ rayon:: spawn ( move || {
343+ let mut lint_service = LintService :: new ( linter, options) ;
344+ lint_service. with_paths ( files_to_lint) ;
345+
346+ // Use `RawTransferFileSystem` if `oxlint2` feature is enabled.
347+ // This reads the source text into start of allocator, instead of the end.
348+ #[ cfg( all( feature = "oxlint2" , not( feature = "disable_oxlint2" ) ) ) ]
349+ {
350+ use crate :: raw_fs:: RawTransferFileSystem ;
351+ lint_service. with_file_system ( Box :: new ( RawTransferFileSystem ) ) ;
352+ }
353+
354+ lint_service. run ( & tx_error) ;
355+ } ) ;
356+ }
351357
352- // Use `RawTransferFileSystem` if `oxlint2` feature is enabled.
353- // This reads the source text into start of allocator, instead of the end.
354- #[ cfg( all( feature = "oxlint2" , not( feature = "disable_oxlint2" ) ) ) ]
358+ // Run type-aware linting through tsgolint
359+ // TODO: Add a warning message if `tsgolint` cannot be found, but type-aware rules are enabled
360+ if self . options . type_aware {
361+ if let Err ( err) = TsGoLintState :: new ( & cwd, config_store)
362+ . with_silent ( misc_options. silent )
363+ . lint ( & files_to_lint, tx_error)
355364 {
356- use crate :: raw_fs :: RawTransferFileSystem ;
357- lint_service . with_file_system ( Box :: new ( RawTransferFileSystem ) ) ;
365+ print_and_flush_stdout ( stdout , & err ) ;
366+ return CliRunResult :: TsGoLintError ;
358367 }
359-
360- lint_service . run ( & tx_error) ;
361- } ) ;
368+ } else {
369+ drop ( tx_error) ;
370+ }
362371
363372 let diagnostic_result = diagnostic_service. run ( stdout) ;
364373
0 commit comments