@@ -15,12 +15,13 @@ use crate::{
1515 rules:: RULES ,
1616} ;
1717
18- use super :: Config ;
18+ use super :: { Config , categories :: OxlintCategories } ;
1919
2020#[ must_use = "You dropped your builder without building a Linter! Did you mean to call .build()?" ]
2121pub struct ConfigStoreBuilder {
2222 pub ( super ) rules : FxHashMap < RuleEnum , AllowWarnDeny > ,
2323 config : LintConfig ,
24+ categories : OxlintCategories ,
2425 overrides : OxlintOverrides ,
2526 cache : RulesCache ,
2627
@@ -43,11 +44,12 @@ impl ConfigStoreBuilder {
4344 pub fn empty ( ) -> Self {
4445 let config = LintConfig :: default ( ) ;
4546 let rules = FxHashMap :: default ( ) ;
47+ let categories: OxlintCategories = OxlintCategories :: default ( ) ;
4648 let overrides = OxlintOverrides :: default ( ) ;
4749 let cache = RulesCache :: new ( config. plugins ) ;
4850 let extended_paths = Vec :: new ( ) ;
4951
50- Self { rules, config, overrides, cache, extended_paths }
52+ Self { rules, config, categories , overrides, cache, extended_paths }
5153 }
5254
5355 /// Warn on all rules in all plugins and categories, including those in `nursery`.
@@ -57,10 +59,11 @@ impl ConfigStoreBuilder {
5759 pub fn all ( ) -> Self {
5860 let config = LintConfig { plugins : LintPlugins :: all ( ) , ..LintConfig :: default ( ) } ;
5961 let overrides = OxlintOverrides :: default ( ) ;
62+ let categories: OxlintCategories = OxlintCategories :: default ( ) ;
6063 let cache = RulesCache :: new ( config. plugins ) ;
6164 let rules = RULES . iter ( ) . map ( |rule| ( rule. clone ( ) , AllowWarnDeny :: Warn ) ) . collect ( ) ;
6265 let extended_paths = Vec :: new ( ) ;
63- Self { rules, config, overrides, cache, extended_paths }
66+ Self { rules, config, categories , overrides, cache, extended_paths }
6467 }
6568
6669 /// Create a [`ConfigStoreBuilder`] from a loaded or manually built [`Oxlintrc`].
@@ -138,6 +141,12 @@ impl ConfigStoreBuilder {
138141 Self :: warn_correctness ( oxlintrc. plugins . unwrap_or_default ( ) )
139142 } ;
140143
144+ let mut categories = oxlintrc. categories . clone ( ) ;
145+
146+ if !start_empty {
147+ categories. insert ( RuleCategory :: Correctness , AllowWarnDeny :: Warn ) ;
148+ }
149+
141150 let config = LintConfig {
142151 plugins : oxlintrc. plugins . unwrap_or_default ( ) ,
143152 settings : oxlintrc. settings ,
@@ -147,8 +156,14 @@ impl ConfigStoreBuilder {
147156 } ;
148157 let cache = RulesCache :: new ( config. plugins ) ;
149158
150- let mut builder =
151- Self { rules, config, overrides : oxlintrc. overrides , cache, extended_paths } ;
159+ let mut builder = Self {
160+ rules,
161+ config,
162+ categories,
163+ overrides : oxlintrc. overrides ,
164+ cache,
165+ extended_paths,
166+ } ;
152167
153168 for filter in oxlintrc. categories . filters ( ) {
154169 builder = builder. with_filter ( & filter) ;
@@ -183,6 +198,11 @@ impl ConfigStoreBuilder {
183198 self
184199 }
185200
201+ pub fn with_categories ( mut self , categories : OxlintCategories ) -> Self {
202+ self . categories = categories;
203+ self
204+ }
205+
186206 /// Enable or disable a set of plugins, leaving unrelated plugins alone.
187207 ///
188208 /// See [`ConfigStoreBuilder::with_plugins`] for details on how plugin configuration affects your
@@ -285,7 +305,7 @@ impl ConfigStoreBuilder {
285305 self . rules . into_iter ( ) . collect :: < Vec < _ > > ( )
286306 } ;
287307 rules. sort_unstable_by_key ( |( r, _) | r. id ( ) ) ;
288- Config :: new ( rules, self . config , self . overrides )
308+ Config :: new ( rules, self . categories , self . config , self . overrides )
289309 }
290310
291311 /// Warn for all correctness rules in the given set of plugins.
0 commit comments