Skip to content

Commit 46e33d5

Browse files
committed
fix(linter): improve error handling in config file lookup (#12391)
1 parent 4621872 commit 46e33d5

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

apps/oxlint/src/lint.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,15 @@ impl LintRunner {
449449
}
450450
}
451451
for directory in directories {
452-
if let Ok(config) = Self::find_oxlint_config_in_directory(directory) {
453-
nested_oxlintrc.insert(directory, config);
452+
#[expect(clippy::match_same_arms)]
453+
match Self::find_oxlint_config_in_directory(directory) {
454+
Ok(Some(v)) => {
455+
nested_oxlintrc.insert(directory, v);
456+
}
457+
Ok(None) => {}
458+
Err(_) => {
459+
// TODO(camc314): report this error
460+
}
454461
}
455462
}
456463

@@ -502,18 +509,12 @@ impl LintRunner {
502509
/// Looks in a directory for an oxlint config file, returns the oxlint config if it exists
503510
/// and returns `Err` if none exists or the file is invalid. Does not apply the default
504511
/// config file.
505-
fn find_oxlint_config_in_directory(dir: &Path) -> Result<Oxlintrc, String> {
512+
fn find_oxlint_config_in_directory(dir: &Path) -> Result<Option<Oxlintrc>, OxcDiagnostic> {
506513
let possible_config_path = dir.join(Self::DEFAULT_OXLINTRC);
507514
if possible_config_path.is_file() {
508-
Oxlintrc::from_file(&possible_config_path).map_err(|e| {
509-
let handler = GraphicalReportHandler::new();
510-
let mut err = String::new();
511-
handler.render_report(&mut err, &e).unwrap();
512-
err
513-
})
515+
Oxlintrc::from_file(&possible_config_path).map(Some)
514516
} else {
515-
// TODO: Better error handling here.
516-
Err("No oxlint config file found".to_string())
517+
Ok(None)
517518
}
518519
}
519520

0 commit comments

Comments
 (0)