@@ -29,10 +29,10 @@ use oxc::{
2929} ;
3030use oxc_formatter:: { FormatOptions , Formatter } ;
3131use oxc_index:: Idx ;
32- use oxc_linter:: { ConfigStore , ConfigStoreBuilder , LintOptions , Linter , ModuleRecord } ;
32+ use oxc_linter:: { ConfigStore , ConfigStoreBuilder , LintOptions , Linter , ModuleRecord , Oxlintrc } ;
3333use oxc_napi:: { Comment , OxcError , convert_utf8_to_utf16} ;
3434
35- use crate :: options:: { OxcOptions , OxcRunOptions } ;
35+ use crate :: options:: { OxcLinterOptions , OxcOptions , OxcRunOptions } ;
3636
3737mod options;
3838
@@ -94,7 +94,7 @@ impl Oxc {
9494 } = options;
9595 let run_options = run_options. unwrap_or_default ( ) ;
9696 let parser_options = parser_options. unwrap_or_default ( ) ;
97- let _linter_options = linter_options. unwrap_or_default ( ) ;
97+ let linter_options = linter_options. unwrap_or_default ( ) ;
9898 let minifier_options = minifier_options. unwrap_or_default ( ) ;
9999 let codegen_options = codegen_options. unwrap_or_default ( ) ;
100100 let transform_options = transform_options. unwrap_or_default ( ) ;
@@ -151,7 +151,7 @@ impl Oxc {
151151 }
152152
153153 let linter_module_record = Arc :: new ( ModuleRecord :: new ( & path, & module_record, & semantic) ) ;
154- self . run_linter ( & run_options, & path, & program, & linter_module_record) ;
154+ self . run_linter ( & run_options, & linter_options , & path, & program, & linter_module_record) ;
155155
156156 self . run_formatter ( & run_options, & source_text, source_type) ;
157157
@@ -277,6 +277,7 @@ impl Oxc {
277277 fn run_linter (
278278 & mut self ,
279279 run_options : & OxcRunOptions ,
280+ linter_options : & OxcLinterOptions ,
280281 path : & Path ,
281282 program : & Program ,
282283 module_record : & Arc < ModuleRecord > ,
@@ -285,7 +286,16 @@ impl Oxc {
285286 if run_options. lint . unwrap_or_default ( ) && self . diagnostics . is_empty ( ) {
286287 let semantic_ret = SemanticBuilder :: new ( ) . with_cfg ( true ) . build ( program) ;
287288 let semantic = Rc :: new ( semantic_ret. semantic ) ;
288- let lint_config = ConfigStoreBuilder :: default ( ) . build ( ) ;
289+ let lint_config = if linter_options. config . is_some ( ) {
290+ let oxlintrc =
291+ Oxlintrc :: from_string ( & linter_options. config . clone ( ) . unwrap ( ) . to_string ( ) )
292+ . unwrap_or_default ( ) ;
293+ let config_builder =
294+ ConfigStoreBuilder :: from_oxlintrc ( false , oxlintrc. clone ( ) ) . unwrap_or_default ( ) ;
295+ config_builder. build ( )
296+ } else {
297+ ConfigStoreBuilder :: default ( ) . build ( )
298+ } ;
289299 let linter_ret = Linter :: new (
290300 LintOptions :: default ( ) ,
291301 ConfigStore :: new ( lint_config, FxHashMap :: default ( ) ) ,
0 commit comments