mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(linter): no unused errors should be warnings
This commit is contained in:
parent
3ac02fd838
commit
a6f9f96e16
4 changed files with 10 additions and 10 deletions
|
|
@ -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}"
|
||||
)));
|
||||
}
|
||||
|
|
@ -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}"
|
||||
))),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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"),
|
||||
|
|
@ -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.")
|
||||
}
|
||||
|
|
@ -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.")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue