@@ -100,6 +100,49 @@ impl ConfigStoreBuilder {
100100 oxlintrc : Oxlintrc ,
101101 external_linter : Option < & ExternalLinter > ,
102102 external_plugin_store : & mut ExternalPluginStore ,
103+ ) -> Result < Self , ConfigBuilderError > {
104+ let parent_path =
105+ oxlintrc. path . parent ( ) . map_or_else ( || PathBuf :: from ( "." ) , std:: path:: Path :: to_path_buf) ;
106+
107+ Self :: from_oxlintrc_with_ignore_root (
108+ start_empty,
109+ oxlintrc,
110+ external_linter,
111+ external_plugin_store,
112+ parent_path. as_path ( ) ,
113+ )
114+ }
115+
116+ /// Similar to the [`ConfigStoreBuilder::from_oxlintrc`] method, but
117+ /// applies the config on top of a default [`Oxlintrc`].
118+ /// The ignore root of this file, should be the current working directory.
119+ /// Even if the file is not located at the current working directory.
120+ ///
121+ /// # Errors
122+ ///
123+ /// Returns [`ConfigBuilderError::InvalidConfigFile`] if a referenced config file is not valid.
124+ pub fn from_base_oxlintrc (
125+ cwd : & Path ,
126+ start_empty : bool ,
127+ oxlintrc : Oxlintrc ,
128+ external_linter : Option < & ExternalLinter > ,
129+ external_plugin_store : & mut ExternalPluginStore ,
130+ ) -> Result < Self , ConfigBuilderError > {
131+ Self :: from_oxlintrc_with_ignore_root (
132+ start_empty,
133+ oxlintrc,
134+ external_linter,
135+ external_plugin_store,
136+ cwd,
137+ )
138+ }
139+
140+ fn from_oxlintrc_with_ignore_root (
141+ start_empty : bool ,
142+ oxlintrc : Oxlintrc ,
143+ external_linter : Option < & ExternalLinter > ,
144+ external_plugin_store : & mut ExternalPluginStore ,
145+ ignore_root : & Path ,
103146 ) -> Result < Self , ConfigBuilderError > {
104147 // TODO: this can be cached to avoid re-computing the same oxlintrc
105148 fn resolve_oxlintrc_config (
@@ -167,7 +210,6 @@ impl ConfigStoreBuilder {
167210
168211 let resolver = Resolver :: default ( ) ;
169212
170- #[ expect( clippy:: missing_panics_doc, reason = "oxlintrc.path is always a file path" ) ]
171213 let oxlintrc_dir = oxlintrc. path . parent ( ) . unwrap ( ) ;
172214
173215 for plugin_specifier in & external_plugins {
@@ -201,7 +243,7 @@ impl ConfigStoreBuilder {
201243 globals : oxlintrc. globals ,
202244 ignore_patterns : LintConfig :: resolve_oxlintrc_ignore_patterns (
203245 & oxlintrc. ignore_patterns ,
204- & oxlintrc . path ,
246+ ignore_root ,
205247 ) ,
206248 path : Some ( oxlintrc. path ) ,
207249 } ;
0 commit comments