@@ -10,6 +10,7 @@ use super::{
1010} ;
1111use crate :: {
1212 AllowWarnDeny , LintPlugins ,
13+ external_plugin_store:: { ExternalPluginStore , ExternalRuleId } ,
1314 rules:: { RULES , RuleEnum } ,
1415} ;
1516
@@ -19,11 +20,17 @@ pub struct ResolvedLinterState {
1920 // TODO: Arc + Vec -> SyncVec? It would save a pointer dereference.
2021 pub rules : Arc < [ ( RuleEnum , AllowWarnDeny ) ] > ,
2122 pub config : Arc < LintConfig > ,
23+
24+ pub external_rules : Vec < ( ExternalRuleId , AllowWarnDeny ) > ,
2225}
2326
2427impl Clone for ResolvedLinterState {
2528 fn clone ( & self ) -> Self {
26- Self { rules : Arc :: clone ( & self . rules ) , config : Arc :: clone ( & self . config ) }
29+ Self {
30+ rules : Arc :: clone ( & self . rules ) ,
31+ config : Arc :: clone ( & self . config ) ,
32+ external_rules : self . external_rules . clone ( ) ,
33+ }
2734 }
2835}
2936
@@ -64,6 +71,7 @@ impl Config {
6471 . into_boxed_slice ( ) ,
6572 ) ,
6673 config : Arc :: new ( config) ,
74+ external_rules : vec ! [ ] , // FIXME(camc314)
6775 } ,
6876 base_rules : rules,
6977 categories,
@@ -179,7 +187,11 @@ impl Config {
179187
180188 let rules =
181189 rules. into_iter ( ) . filter ( |( _, severity) | severity. is_warn_deny ( ) ) . collect :: < Vec < _ > > ( ) ;
182- ResolvedLinterState { rules : Arc :: from ( rules. into_boxed_slice ( ) ) , config }
190+ ResolvedLinterState {
191+ rules : Arc :: from ( rules. into_boxed_slice ( ) ) ,
192+ config,
193+ external_rules : vec ! [ ] , // FIXME(camc314)
194+ }
183195 }
184196}
185197
@@ -192,11 +204,20 @@ impl Config {
192204pub struct ConfigStore {
193205 base : Config ,
194206 nested_configs : FxHashMap < PathBuf , Config > ,
207+ external_plugin_store : Arc < ExternalPluginStore > ,
195208}
196209
197210impl ConfigStore {
198- pub fn new ( base_config : Config , nested_configs : FxHashMap < PathBuf , Config > ) -> Self {
199- Self { base : base_config, nested_configs }
211+ pub fn new (
212+ base_config : Config ,
213+ nested_configs : FxHashMap < PathBuf , Config > ,
214+ external_plugin_store : ExternalPluginStore ,
215+ ) -> Self {
216+ Self {
217+ base : base_config,
218+ nested_configs,
219+ external_plugin_store : Arc :: new ( external_plugin_store) ,
220+ }
200221 }
201222
202223 pub fn number_of_rules ( & self ) -> Option < usize > {
@@ -212,6 +233,7 @@ impl ConfigStore {
212233 }
213234
214235 pub ( crate ) fn resolve ( & self , path : & Path ) -> ResolvedLinterState {
236+ dbg ! ( & self . external_plugin_store) ;
215237 let resolved_config = if self . nested_configs . is_empty ( ) {
216238 & self . base
217239 } else if let Some ( config) = self . get_nearest_config ( path) {
@@ -243,7 +265,7 @@ mod test {
243265
244266 use super :: { ConfigStore , OxlintOverrides } ;
245267 use crate :: {
246- AllowWarnDeny , BuiltinLintPlugins , LintPlugins , RuleEnum ,
268+ AllowWarnDeny , BuiltinLintPlugins , ExternalPluginStore , LintPlugins , RuleEnum ,
247269 config:: {
248270 LintConfig , OxlintEnv , OxlintGlobals , OxlintSettings , categories:: OxlintCategories ,
249271 config_store:: Config ,
@@ -272,6 +294,7 @@ mod test {
272294 let store = ConfigStore :: new (
273295 Config :: new ( base_rules, OxlintCategories :: default ( ) , LintConfig :: default ( ) , overrides) ,
274296 FxHashMap :: default ( ) ,
297+ ExternalPluginStore :: default ( ) ,
275298 ) ;
276299
277300 let rules_for_source_file = store. resolve ( "App.tsx" . as_ref ( ) ) ;
@@ -294,6 +317,7 @@ mod test {
294317 let store = ConfigStore :: new (
295318 Config :: new ( base_rules, OxlintCategories :: default ( ) , LintConfig :: default ( ) , overrides) ,
296319 FxHashMap :: default ( ) ,
320+ ExternalPluginStore :: default ( ) ,
297321 ) ;
298322
299323 let rules_for_source_file = store. resolve ( "App.tsx" . as_ref ( ) ) ;
@@ -317,6 +341,7 @@ mod test {
317341 let store = ConfigStore :: new (
318342 Config :: new ( base_rules, OxlintCategories :: default ( ) , LintConfig :: default ( ) , overrides) ,
319343 FxHashMap :: default ( ) ,
344+ ExternalPluginStore :: default ( ) ,
320345 ) ;
321346 assert_eq ! ( store. number_of_rules( ) , Some ( 1 ) ) ;
322347
@@ -340,6 +365,7 @@ mod test {
340365 let store = ConfigStore :: new (
341366 Config :: new ( base_rules, OxlintCategories :: default ( ) , LintConfig :: default ( ) , overrides) ,
342367 FxHashMap :: default ( ) ,
368+ ExternalPluginStore :: default ( ) ,
343369 ) ;
344370 assert_eq ! ( store. number_of_rules( ) , Some ( 1 ) ) ;
345371
@@ -363,6 +389,7 @@ mod test {
363389 let store = ConfigStore :: new (
364390 Config :: new ( base_rules, OxlintCategories :: default ( ) , LintConfig :: default ( ) , overrides) ,
365391 FxHashMap :: default ( ) ,
392+ ExternalPluginStore :: default ( ) ,
366393 ) ;
367394 assert_eq ! ( store. number_of_rules( ) , Some ( 1 ) ) ;
368395
@@ -395,6 +422,7 @@ mod test {
395422 let store = ConfigStore :: new (
396423 Config :: new ( vec ! [ ] , OxlintCategories :: default ( ) , base_config, overrides) ,
397424 FxHashMap :: default ( ) ,
425+ ExternalPluginStore :: default ( ) ,
398426 ) ;
399427
400428 assert_eq ! ( store. base. base. config. plugins. builtin, BuiltinLintPlugins :: IMPORT ) ;
@@ -438,6 +466,7 @@ mod test {
438466 let store = ConfigStore :: new (
439467 Config :: new ( vec ! [ ] , OxlintCategories :: default ( ) , base_config, overrides) ,
440468 FxHashMap :: default ( ) ,
469+ ExternalPluginStore :: default ( ) ,
441470 ) ;
442471 assert ! ( !store. base. base. config. env. contains( "React" ) ) ;
443472
@@ -465,6 +494,7 @@ mod test {
465494 let store = ConfigStore :: new (
466495 Config :: new ( vec ! [ ] , OxlintCategories :: default ( ) , base_config, overrides) ,
467496 FxHashMap :: default ( ) ,
497+ ExternalPluginStore :: default ( ) ,
468498 ) ;
469499 assert ! ( store. base. base. config. env. contains( "es2024" ) ) ;
470500
@@ -493,6 +523,7 @@ mod test {
493523 let store = ConfigStore :: new (
494524 Config :: new ( vec ! [ ] , OxlintCategories :: default ( ) , base_config, overrides) ,
495525 FxHashMap :: default ( ) ,
526+ ExternalPluginStore :: default ( ) ,
496527 ) ;
497528 assert ! ( !store. base. base. config. globals. is_enabled( "React" ) ) ;
498529 assert ! ( !store. base. base. config. globals. is_enabled( "Secret" ) ) ;
@@ -526,6 +557,7 @@ mod test {
526557 let store = ConfigStore :: new (
527558 Config :: new ( vec ! [ ] , OxlintCategories :: default ( ) , base_config, overrides) ,
528559 FxHashMap :: default ( ) ,
560+ ExternalPluginStore :: default ( ) ,
529561 ) ;
530562 assert ! ( store. base. base. config. globals. is_enabled( "React" ) ) ;
531563 assert ! ( store. base. base. config. globals. is_enabled( "Secret" ) ) ;
0 commit comments