@@ -18,6 +18,7 @@ use discovery::ConfigFileDiscovery;
18
18
use discovery:: ConfigFolder ;
19
19
use discovery:: DenoOrPkgJson ;
20
20
use indexmap:: IndexMap ;
21
+ use indexmap:: IndexSet ;
21
22
use std:: borrow:: Cow ;
22
23
use std:: collections:: BTreeMap ;
23
24
use std:: collections:: HashSet ;
@@ -1442,11 +1443,38 @@ impl WorkspaceDirectory {
1442
1443
None => return Ok ( member_config) ,
1443
1444
} ;
1444
1445
// combine the configs
1446
+ let root_opts = root_config. options ;
1447
+ let member_opts = member_config. options ;
1448
+
1449
+ // 1. Merge workspace root + member plugins
1450
+ // 2. Workspace member can filter out plugins by negating
1451
+ // like this: `!my-plugin`
1452
+ // 3. Remove duplicates in case a plugin was defined in both
1453
+ // workspace root and member.
1454
+ let excluded_plugins: HashSet < String > = HashSet :: from_iter (
1455
+ member_opts
1456
+ . plugins
1457
+ . iter ( )
1458
+ . filter ( |plugin| plugin. starts_with ( '!' ) )
1459
+ . map ( |plugin| plugin[ 1 ..] . to_string ( ) ) ,
1460
+ ) ;
1461
+
1462
+ let filtered_plugins = IndexSet :: < String > :: from_iter (
1463
+ root_opts
1464
+ . plugins
1465
+ . into_iter ( )
1466
+ . chain ( member_opts. plugins )
1467
+ . filter ( |plugin| {
1468
+ !plugin. starts_with ( '!' ) && !excluded_plugins. contains ( plugin)
1469
+ } ) ,
1470
+ )
1471
+ . into_iter ( )
1472
+ . collect :: < Vec < _ > > ( ) ;
1473
+
1445
1474
Ok ( LintConfig {
1446
1475
options : LintOptionsConfig {
1476
+ plugins : filtered_plugins,
1447
1477
rules : {
1448
- let root_opts = root_config. options ;
1449
- let member_opts = member_config. options ;
1450
1478
LintRulesConfig {
1451
1479
tags : combine_option_vecs (
1452
1480
root_opts. rules . tags ,
@@ -2761,6 +2789,7 @@ mod test {
2761
2789
"include" : [ "rule1" ] ,
2762
2790
"exclude" : [ "rule2" ] ,
2763
2791
} ,
2792
+ "plugins" : [ "jsr:@deno/test-plugin1" , "jsr:@deno/test-plugin3" ]
2764
2793
}
2765
2794
} ) ,
2766
2795
json ! ( {
@@ -2770,7 +2799,12 @@ mod test {
2770
2799
"rules" : {
2771
2800
"tags" : [ "tag1" ] ,
2772
2801
"include" : [ "rule2" ] ,
2773
- }
2802
+ } ,
2803
+ "plugins" : [
2804
+ "jsr:@deno/test-plugin1" ,
2805
+ "jsr:@deno/test-plugin2" ,
2806
+ "!jsr:@deno/test-plugin3"
2807
+ ]
2774
2808
}
2775
2809
} ) ,
2776
2810
) ;
@@ -2800,6 +2834,10 @@ mod test {
2800
2834
include: Some ( vec![ "rule1" . to_string( ) , "rule2" . to_string( ) ] ) ,
2801
2835
exclude: Some ( vec![ ] )
2802
2836
} ,
2837
+ plugins: vec![
2838
+ "jsr:@deno/test-plugin1" . to_string( ) ,
2839
+ "jsr:@deno/test-plugin2" . to_string( )
2840
+ ] ,
2803
2841
} ,
2804
2842
files: FilePatterns {
2805
2843
base: root_dir( ) . join( "member" ) ,
@@ -2827,6 +2865,10 @@ mod test {
2827
2865
include: Some ( vec![ "rule1" . to_string( ) ] ) ,
2828
2866
exclude: Some ( vec![ "rule2" . to_string( ) ] )
2829
2867
} ,
2868
+ plugins: vec![
2869
+ "jsr:@deno/test-plugin1" . to_string( ) ,
2870
+ "jsr:@deno/test-plugin3" . to_string( )
2871
+ ]
2830
2872
} ,
2831
2873
files: FilePatterns {
2832
2874
base: root_dir( ) ,
0 commit comments