From cac1fc9f4c80dd00374b5ca800570fbbed38a47a Mon Sep 17 00:00:00 2001 From: Cameron A McHenry Date: Tue, 12 Nov 2024 20:06:20 -0500 Subject: [PATCH] fix(linter): revert unmatched rule error (#7257) - related to https://github.com/oxc-project/oxc/issues/6988 This is causing a lot of errors currently such as https://github.com/oxc-project/oxc/issues/7233. I think we need to handle rule names more robustly first: - https://github.com/oxc-project/oxc/issues/7240 - https://github.com/oxc-project/oxc/issues/7082 - https://github.com/oxc-project/oxc/discussions/7242 then, I think we can revisit this and maybe implement it as an actual lint plugin too? https://github.com/oxc-project/oxc/discussions/7086 --- apps/oxlint/src/lint.rs | 3 --- apps/oxlint/src/result.rs | 21 +++------------------ crates/oxc_linter/src/builder.rs | 15 --------------- 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index 32b52130c5a1f1..0c58ab36965564 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -244,9 +244,6 @@ mod test { let options = lint_command().run_inner(new_args.as_slice()).unwrap(); match LintRunner::new(options).run() { CliRunResult::LintResult(lint_result) => lint_result, - CliRunResult::LintError { error } => { - panic!("{error}") - } other => panic!("{other:?}"), } } diff --git a/apps/oxlint/src/result.rs b/apps/oxlint/src/result.rs index bfd953337c97e8..49f01e213881b6 100644 --- a/apps/oxlint/src/result.rs +++ b/apps/oxlint/src/result.rs @@ -7,21 +7,10 @@ use std::{ #[derive(Debug)] pub enum CliRunResult { None, - InvalidOptions { - message: String, - }, - PathNotFound { - paths: Vec, - }, - /// Indicates that there was an error trying to run the linter and it was - /// not able to complete linting successfully. - LintError { - error: String, - }, + InvalidOptions { message: String }, + PathNotFound { paths: Vec }, LintResult(LintResult), - PrintConfigResult { - config_file: String, - }, + PrintConfigResult { config_file: String }, } /// A summary of a complete linter run. @@ -58,10 +47,6 @@ impl Termination for CliRunResult { println!("Path {paths:?} does not exist."); ExitCode::from(1) } - Self::LintError { error } => { - eprintln!("Error: {error}"); - ExitCode::from(1) - } Self::LintResult(LintResult { duration, number_of_rules, diff --git a/crates/oxc_linter/src/builder.rs b/crates/oxc_linter/src/builder.rs index 2148411cf58919..3c28d22f847283 100644 --- a/crates/oxc_linter/src/builder.rs +++ b/crates/oxc_linter/src/builder.rs @@ -3,7 +3,6 @@ use std::{ fmt, }; -use oxc_diagnostics::{Error, OxcDiagnostic}; use oxc_span::CompactStr; use rustc_hash::FxHashSet; @@ -102,20 +101,6 @@ impl LinterBuilder { oxlintrc_rules.override_rules(&mut builder.rules, all_rules.as_slice()); } - #[expect(clippy::print_stderr)] - if !oxlintrc_rules.unknown_rules.is_empty() { - let rules = oxlintrc_rules - .unknown_rules - .iter() - .map(|r| r.full_name()) - .collect::>() - .join("\n"); - let error = Error::from(OxcDiagnostic::warn(format!( - "The following rules do not match the currently supported rules:\n{rules}" - ))); - eprintln!("{error:?}"); - } - builder }