@@ -18,36 +18,17 @@ use crate::linter::options::UnusedDisableDirectives;
1818use crate :: linter:: {
1919 error_with_position:: DiagnosticReport ,
2020 isolated_lint_handler:: { IsolatedLintHandler , IsolatedLintHandlerOptions } ,
21- options:: { LintOptions as LSPLintOptions , Run } ,
21+ options:: LintOptions as LSPLintOptions ,
2222} ;
2323use crate :: utils:: normalize_path;
2424use crate :: { ConcurrentHashMap , LINT_CONFIG_FILE } ;
2525
2626use super :: config_walker:: ConfigWalker ;
2727
28- #[ derive( Debug , PartialEq , Eq ) ]
29- pub enum ServerLinterRun {
30- OnType ,
31- OnSave ,
32- Always ,
33- }
34-
35- impl ServerLinterRun {
36- fn matches ( & self , run : Run ) -> bool {
37- matches ! (
38- ( self , run) ,
39- ( ServerLinterRun :: OnType , Run :: OnType )
40- | ( ServerLinterRun :: OnSave , Run :: OnSave )
41- | ( ServerLinterRun :: Always , _)
42- )
43- }
44- }
45-
4628pub struct ServerLinter {
4729 isolated_linter : Arc < Mutex < IsolatedLintHandler > > ,
4830 ignore_matcher : LintIgnoreMatcher ,
4931 gitignore_glob : Vec < Gitignore > ,
50- lint_on_run : Run ,
5132 diagnostics : ServerLinterDiagnostics ,
5233 extended_paths : FxHashSet < PathBuf > ,
5334}
@@ -171,7 +152,6 @@ impl ServerLinter {
171152 ) ,
172153 gitignore_glob : Self :: create_ignore_glob ( & root_path) ,
173154 extended_paths,
174- lint_on_run : options. run ,
175155 diagnostics : ServerLinterDiagnostics :: default ( ) ,
176156 }
177157 }
@@ -279,9 +259,7 @@ impl ServerLinter {
279259 pub async fn revalidate_diagnostics ( & self , uris : Vec < Uri > ) -> Vec < ( String , Vec < Diagnostic > ) > {
280260 let mut diagnostics = Vec :: with_capacity ( uris. len ( ) ) ;
281261 for uri in uris {
282- if let Some ( file_diagnostic) =
283- self . run_single ( & uri, None , ServerLinterRun :: Always ) . await
284- {
262+ if let Some ( file_diagnostic) = self . run_single ( & uri, None ) . await {
285263 diagnostics. push ( (
286264 uri. to_string ( ) ,
287265 file_diagnostic. into_iter ( ) . map ( |d| d. diagnostic ) . collect ( ) ,
@@ -317,15 +295,7 @@ impl ServerLinter {
317295 & self ,
318296 uri : & Uri ,
319297 content : Option < String > ,
320- run_type : ServerLinterRun ,
321298 ) -> Option < Vec < DiagnosticReport > > {
322- let run = matches ! ( run_type, ServerLinterRun :: Always ) || run_type. matches ( self . lint_on_run ) ;
323-
324- // return `None` when both tools do not want to be used
325- if !run {
326- return None ;
327- }
328-
329299 if self . is_ignored ( uri) {
330300 return None ;
331301 }
@@ -460,66 +430,6 @@ mod test {
460430 assert ! ( result_empty. is_none( ) ) ;
461431 }
462432
463- #[ test]
464- #[ cfg( not( target_endian = "big" ) ) ]
465- fn test_lint_on_run_on_type_on_type ( ) {
466- Tester :: new (
467- "fixtures/linter/lint_on_run/on_type" ,
468- Some ( LintOptions { type_aware : true , run : Run :: OnType , ..Default :: default ( ) } ) ,
469- )
470- . test_and_snapshot_single_file_with_run_type ( "on-type.ts" , Run :: OnType ) ;
471- }
472-
473- #[ test]
474- #[ cfg( not( target_endian = "big" ) ) ]
475- fn test_lint_on_run_on_save_on_save ( ) {
476- Tester :: new (
477- "fixtures/linter/lint_on_run/on_save" ,
478- Some ( LintOptions {
479- type_aware : true ,
480- run : Run :: OnType ,
481- fix_kind : LintFixKindFlag :: All ,
482- ..Default :: default ( )
483- } ) ,
484- )
485- . test_and_snapshot_single_file_with_run_type ( "on-save.ts" , Run :: OnSave ) ;
486- }
487-
488- #[ test]
489- #[ cfg( not( target_endian = "big" ) ) ]
490- fn test_lint_on_run_on_save_on_type ( ) {
491- Tester :: new (
492- "fixtures/linter/lint_on_run/on_save" ,
493- Some ( LintOptions { type_aware : true , run : Run :: OnSave , ..Default :: default ( ) } ) ,
494- )
495- . test_and_snapshot_single_file_with_run_type ( "on-type.ts" , Run :: OnType ) ;
496- }
497-
498- #[ test]
499- #[ cfg( not( target_endian = "big" ) ) ]
500- fn test_lint_on_run_on_type_on_save ( ) {
501- Tester :: new (
502- "fixtures/linter/lint_on_run/on_save" ,
503- Some ( LintOptions {
504- type_aware : true ,
505- run : Run :: OnType ,
506- fix_kind : LintFixKindFlag :: All ,
507- ..Default :: default ( )
508- } ) ,
509- )
510- . test_and_snapshot_single_file_with_run_type ( "on-save.ts" , Run :: OnSave ) ;
511- }
512-
513- #[ test]
514- #[ cfg( not( target_endian = "big" ) ) ]
515- fn test_lint_on_run_on_type_on_save_without_type_aware ( ) {
516- Tester :: new (
517- "fixtures/linter/lint_on_run/on_type" ,
518- Some ( LintOptions { type_aware : false , run : Run :: OnType , ..Default :: default ( ) } ) ,
519- )
520- . test_and_snapshot_single_file_with_run_type ( "on-save-no-type-aware.ts" , Run :: OnSave ) ;
521- }
522-
523433 #[ test]
524434 fn test_no_errors ( ) {
525435 Tester :: new ( "fixtures/linter/no_errors" , None )
0 commit comments