Skip to content

Commit

Permalink
fix(linter): no unused errors should be warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Aug 5, 2024
1 parent 3ac02fd commit a6f9f96
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/func_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl TryFrom<&serde_json::Value> for FuncNamesConfig {

fn try_from(raw: &serde_json::Value) -> Result<Self, Self::Error> {
if !raw.is_string() {
return Err(OxcDiagnostic::error(format!(
return Err(OxcDiagnostic::warn(format!(
"Expecting string for eslint/func-names configuration, got {raw}"
)));
}
Expand All @@ -37,7 +37,7 @@ impl TryFrom<&serde_json::Value> for FuncNamesConfig {
"always" => Ok(FuncNamesConfig::Always),
"as-needed" => Ok(FuncNamesConfig::AsNeeded),
"never" => Ok(FuncNamesConfig::Never),
v => Err(OxcDiagnostic::error(format!(
v => Err(OxcDiagnostic::warn(format!(
"Expecting always, as-needed or never for eslint/func-names configuration, got {v}"
))),
}
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_linter/src/rules/eslint/no_fallthrough.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ use rustc_hash::{FxHashMap, FxHashSet};
use crate::{context::LintContext, rule::Rule, AstNode};

fn no_fallthrough_case_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::error("Expected a 'break' statement before 'case'.").with_label(span)
OxcDiagnostic::warn("Expected a 'break' statement before 'case'.").with_label(span)
}

fn no_fallthrough_default_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::error("Expected a 'break' statement before 'default'.").with_label(span)
OxcDiagnostic::warn("Expected a 'break' statement before 'default'.").with_label(span)
}

fn no_unused_fallthrough_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::error(
OxcDiagnostic::warn(
"Found a comment that would permit fallthrough, but case cannot fall through.",
)
.with_label(span)
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_unreachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use oxc_span::{GetSpan, Span};
use crate::{context::LintContext, rule::Rule};

fn no_unreachable_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::error("Unreachable code.").with_label(span)
OxcDiagnostic::warn("Unreachable code.").with_label(span)
}

/// <https://github.com/eslint/eslint/blob/069aa680c78b8516b9a1b568519f1d01e74fb2a2/lib/rules/no-unreachable.js#L196>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn declared(symbol: &Symbol<'_, '_>) -> OxcDiagnostic {
let pronoun = pronoun_for_symbol(symbol.flags());
let name = symbol.name();

OxcDiagnostic::error(format!("{pronoun} '{name}' is {verb} but never used."))
OxcDiagnostic::warn(format!("{pronoun} '{name}' is {verb} but never used."))
.with_label(symbol.span().label(format!("'{name}' is declared here")))
.with_help(help)
}
Expand All @@ -54,7 +54,7 @@ pub fn assign(symbol: &Symbol<'_, '_>, assign_span: Span) -> OxcDiagnostic {
let pronoun = pronoun_for_symbol(symbol.flags());
let name = symbol.name();

OxcDiagnostic::error(format!("{pronoun} '{name}' is assigned a value but never used."))
OxcDiagnostic::warn(format!("{pronoun} '{name}' is assigned a value but never used."))
.with_labels([
symbol.span().label(format!("'{name}' is declared here")),
assign_span.label("it was last assigned here"),
Expand All @@ -66,7 +66,7 @@ pub fn assign(symbol: &Symbol<'_, '_>, assign_span: Span) -> OxcDiagnostic {
pub fn param(symbol: &Symbol<'_, '_>) -> OxcDiagnostic {
let name = symbol.name();

OxcDiagnostic::error(format!("Parameter '{name}' is declared but never used."))
OxcDiagnostic::warn(format!("Parameter '{name}' is declared but never used."))
.with_label(symbol.span().label(format!("'{name}' is declared here")))
.with_help("Consider removing this parameter.")
}
Expand All @@ -76,7 +76,7 @@ pub fn imported(symbol: &Symbol<'_, '_>) -> OxcDiagnostic {
let pronoun = pronoun_for_symbol(symbol.flags());
let name = symbol.name();

OxcDiagnostic::error(format!("{pronoun} '{name}' is imported but never used."))
OxcDiagnostic::warn(format!("{pronoun} '{name}' is imported but never used."))
.with_label(symbol.span().label(format!("'{name}' is imported here")))
.with_help("Consider removing this import.")
}

0 comments on commit a6f9f96

Please sign in to comment.