@@ -305,21 +305,10 @@ impl LintRunner {
305
305
. filter ( |path| !ignore_matcher. should_ignore ( Path :: new ( path) ) )
306
306
. collect :: < Vec < Arc < OsStr > > > ( ) ;
307
307
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) ;
323
312
324
313
let number_of_files = files_to_lint. len ( ) ;
325
314
@@ -344,21 +333,41 @@ impl LintRunner {
344
333
345
334
let number_of_rules = linter. number_of_rules ( self . options . type_aware ) ;
346
335
336
+ let cwd = options. cwd ( ) . to_path_buf ( ) ;
337
+
347
338
// 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
+ }
351
357
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)
355
364
{
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 ;
358
367
}
359
-
360
- lint_service . run ( & tx_error) ;
361
- } ) ;
368
+ } else {
369
+ drop ( tx_error) ;
370
+ }
362
371
363
372
let diagnostic_result = diagnostic_service. run ( stdout) ;
364
373
@@ -1250,4 +1259,13 @@ mod test {
1250
1259
let args = & [ "--type-aware" , "no-floating-promises" , "-c" , "config-test.json" ] ;
1251
1260
Tester :: new ( ) . with_cwd ( "fixtures/tsgolint" . into ( ) ) . test_and_snapshot ( args) ;
1252
1261
}
1262
+
1263
+ #[ test]
1264
+ #[ cfg( not( target_endian = "big" ) ) ]
1265
+ fn test_type_aware_rule_disable_directive ( ) {
1266
+ let args = & [ "--type-aware" , "-D" , "no-floating-promises" ] ;
1267
+ Tester :: new ( )
1268
+ . with_cwd ( "fixtures/type_aware_rule_disable_directive" . into ( ) )
1269
+ . test_and_snapshot ( args) ;
1270
+ }
1253
1271
}
0 commit comments