@@ -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}
@@ -172,7 +153,6 @@ impl ServerLinter {
172153 ) ,
173154 gitignore_glob : Self :: create_ignore_glob ( & root_path) ,
174155 extended_paths,
175- lint_on_run : options. run ,
176156 diagnostics : ServerLinterDiagnostics :: default ( ) ,
177157 }
178158 }
@@ -280,9 +260,7 @@ impl ServerLinter {
280260 pub async fn revalidate_diagnostics ( & self , uris : Vec < Uri > ) -> Vec < ( String , Vec < Diagnostic > ) > {
281261 let mut diagnostics = Vec :: with_capacity ( uris. len ( ) ) ;
282262 for uri in uris {
283- if let Some ( file_diagnostic) =
284- self . run_single ( & uri, None , ServerLinterRun :: Always ) . await
285- {
263+ if let Some ( file_diagnostic) = self . run_single ( & uri, None ) . await {
286264 diagnostics. push ( (
287265 uri. to_string ( ) ,
288266 file_diagnostic. into_iter ( ) . map ( |d| d. diagnostic ) . collect ( ) ,
@@ -318,15 +296,7 @@ impl ServerLinter {
318296 & self ,
319297 uri : & Uri ,
320298 content : Option < String > ,
321- run_type : ServerLinterRun ,
322299 ) -> Option < Vec < DiagnosticReport > > {
323- let run = matches ! ( run_type, ServerLinterRun :: Always ) || run_type. matches ( self . lint_on_run ) ;
324-
325- // return `None` when both tools do not want to be used
326- if !run {
327- return None ;
328- }
329-
330300 if self . is_ignored ( uri) {
331301 return None ;
332302 }
@@ -461,71 +431,6 @@ mod test {
461431 assert ! ( result_empty. is_none( ) ) ;
462432 }
463433
464- #[ test]
465- #[ cfg( not( target_endian = "big" ) ) ]
466- fn test_lint_on_run_on_type_on_type ( ) {
467- Tester :: new (
468- "fixtures/linter/lint_on_run/on_type" ,
469- Some ( LintOptions {
470- type_aware : true ,
471- run : Run :: OnType ,
472- fix_kind : LintFixKindFlag :: All ,
473- ..Default :: default ( )
474- } ) ,
475- )
476- . test_and_snapshot_single_file_with_run_type ( "on-type.ts" , Run :: OnType ) ;
477- }
478-
479- #[ test]
480- #[ cfg( not( target_endian = "big" ) ) ]
481- fn test_lint_on_run_on_save_on_save ( ) {
482- Tester :: new (
483- "fixtures/linter/lint_on_run/on_save" ,
484- Some ( LintOptions {
485- type_aware : true ,
486- run : Run :: OnType ,
487- fix_kind : LintFixKindFlag :: All ,
488- ..Default :: default ( )
489- } ) ,
490- )
491- . test_and_snapshot_single_file_with_run_type ( "on-save.ts" , Run :: OnSave ) ;
492- }
493-
494- #[ test]
495- #[ cfg( not( target_endian = "big" ) ) ]
496- fn test_lint_on_run_on_save_on_type ( ) {
497- Tester :: new (
498- "fixtures/linter/lint_on_run/on_save" ,
499- Some ( LintOptions { type_aware : true , run : Run :: OnSave , ..Default :: default ( ) } ) ,
500- )
501- . test_and_snapshot_single_file_with_run_type ( "on-type.ts" , Run :: OnType ) ;
502- }
503-
504- #[ test]
505- #[ cfg( not( target_endian = "big" ) ) ]
506- fn test_lint_on_run_on_type_on_save ( ) {
507- Tester :: new (
508- "fixtures/linter/lint_on_run/on_save" ,
509- Some ( LintOptions {
510- type_aware : true ,
511- run : Run :: OnType ,
512- fix_kind : LintFixKindFlag :: All ,
513- ..Default :: default ( )
514- } ) ,
515- )
516- . test_and_snapshot_single_file_with_run_type ( "on-save.ts" , Run :: OnSave ) ;
517- }
518-
519- #[ test]
520- #[ cfg( not( target_endian = "big" ) ) ]
521- fn test_lint_on_run_on_type_on_save_without_type_aware ( ) {
522- Tester :: new (
523- "fixtures/linter/lint_on_run/on_type" ,
524- Some ( LintOptions { type_aware : false , run : Run :: OnType , ..Default :: default ( ) } ) ,
525- )
526- . test_and_snapshot_single_file_with_run_type ( "on-save-no-type-aware.ts" , Run :: OnSave ) ;
527- }
528-
529434 #[ test]
530435 fn test_no_errors ( ) {
531436 Tester :: new ( "fixtures/linter/no_errors" , None )
0 commit comments