Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(linter): remove meaningless span0 #5209

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/default_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use regex::{Regex, RegexBuilder};

use crate::{context::LintContext, rule::Rule, AstNode};

fn default_case_diagnostic(span0: Span) -> OxcDiagnostic {
fn default_case_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Require default cases in switch statements.")
.with_help("Add a default case.")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/default_case_last.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn default_case_last_diagnostic(span0: Span) -> OxcDiagnostic {
fn default_case_last_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Enforce default clauses in switch statements to be last")
.with_label(span0.label("Default clause should be the last clause."))
.with_label(span.label("Default clause should be the last clause."))
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/default_param_last.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn default_param_last_diagnostic(span0: Span) -> OxcDiagnostic {
fn default_param_last_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Default parameters should be last")
.with_help("Enforce default parameters to be last.")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/getter_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn getter_return_diagnostic(span0: Span) -> OxcDiagnostic {
fn getter_return_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Expected to always return a value in getter.")
.with_help("Return a value from all code paths in getter.")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/guard_for_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use oxc_span::{GetSpan, Span};

use crate::{context::LintContext, rule::Rule, AstNode};

fn guard_for_in_diagnostic(span0: Span) -> OxcDiagnostic {
fn guard_for_in_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Require `for-in` loops to include an `if` statement")
.with_help("The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype.")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_array_constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_array_constructor_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_array_constructor_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Disallow `Array` constructors")
.with_help("Use array literal instead")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_async_promise_executor_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Promise executor functions should not be `async`.").with_label(span0)
fn no_async_promise_executor_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Promise executor functions should not be `async`.").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_await_in_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_await_in_loop_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected `await` inside a loop.").with_label(span0)
fn no_await_in_loop_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected `await` inside a loop.").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_caller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_caller_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_caller_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Disallow the use of arguments.caller or arguments.callee")
.with_help("'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_case_declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_case_declarations_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected lexical declaration in case block.").with_label(span0)
fn no_case_declarations_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected lexical declaration in case block.").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_cond_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use oxc_span::{GetSpan, Span};

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_cond_assign_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_cond_assign_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Expected a conditional expression and instead saw an assignment")
.with_help("Consider wrapping the assignment in additional parentheses")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_console_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected console statement.").with_label(span0)
fn no_console_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected console statement.").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ fn constant_binary_operand(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic {
.with_label(span2)
}

fn constant_always_new(span0: Span) -> OxcDiagnostic {
fn constant_always_new(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected comparison to newly constructed object")
.with_help("These two values can never be equal")
.with_label(span0)
.with_label(span)
}

fn constant_both_always_new(span0: Span) -> OxcDiagnostic {
fn constant_both_always_new(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected comparison of two newly constructed objects")
.with_help("These two values can never be equal")
.with_label(span0)
.with_label(span)
}

impl Rule for NoConstantBinaryExpression {
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_constant_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use oxc_span::{GetSpan, Span};

use crate::{ast_util::IsConstant, context::LintContext, rule::Rule, AstNode};

fn no_constant_condition_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_constant_condition_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected constant condition")
.with_help("Constant expression as a test condition is not allowed")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_continue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_continue_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_continue_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected use of `continue` statement.")
.with_help("Do not use the `continue` statement.")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_debugger_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("`debugger` statement is not allowed").with_label(span0)
fn no_debugger_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("`debugger` statement is not allowed").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_delete_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use oxc_syntax::operator::UnaryOperator;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_delete_var_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("variables should not be deleted").with_label(span0)
fn no_delete_var_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("variables should not be deleted").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_div_regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_div_regex_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_div_regex_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("A regular expression literal can be confused with '/='.")
.with_help("Rewrite `/=` into `/[=]`")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use regex::Regex;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_empty_character_class_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_empty_character_class_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Empty character class")
.with_help("Try to remove empty character class `[]` in regexp literal")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_empty_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_empty_function_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_empty_function_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Disallow empty functions")
.with_help("Unexpected empty function block")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_empty_static_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_empty_static_block_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_empty_static_block_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Disallow empty static blocks")
.with_help("Unexpected empty static block.")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_eq_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use oxc_syntax::operator::BinaryOperator;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_eq_null_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_eq_null_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Use '===' to compare with null")
.with_help("Disallow `null` comparisons without type-checking operators.")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule};

fn no_eval_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eval can be harmful.").with_label(span0)
fn no_eval_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eval can be harmful.").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_ex_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule};

fn no_ex_assign_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Do not assign to the exception parameter.").with_help("If a catch clause in a try statement accidentally (or purposely) assigns another value to the exception parameter, it is impossible to refer to the error from that point on. Since there is no arguments object to offer alternative access to this data, assignment of the parameter is absolutely destructive.").with_label(span0)
fn no_ex_assign_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Do not assign to the exception parameter.").with_help("If a catch clause in a try statement accidentally (or purposely) assigns another value to the exception parameter, it is impossible to refer to the error from that point on. Since there is no arguments object to offer alternative access to this data, assignment of the parameter is absolutely destructive.").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ use oxc_syntax::operator::{LogicalOperator, UnaryOperator};

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_extra_double_negation_cast_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_extra_double_negation_cast_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Redundant double negation")
.with_help("Remove the double negation as it will already be coerced to a boolean")
.with_label(span0)
.with_label(span)
}

fn no_extra_boolean_cast_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_extra_boolean_cast_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Redundant Boolean call")
.with_help("Remove the Boolean call as it will already be coerced to a boolean")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_import_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use phf::phf_set;

use crate::{context::LintContext, rule::Rule};

fn no_import_assign_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_import_assign_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("do not assign to imported bindings")
.with_help("imported bindings are readonly")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_irregular_whitespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule};

fn no_irregular_whitespace_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_irregular_whitespace_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected irregular whitespace")
.with_help("Try to remove the irregular whitespace")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use oxc_span::{GetSpan, Span};

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_iterator_diagnostic(span0: Span) -> OxcDiagnostic {
fn no_iterator_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Reserved name '__iterator__'")
.with_help("Disallow the use of the `__iterator__` property.")
.with_label(span0)
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_loss_of_precision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_loss_of_precision_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("This number literal will lose precision at runtime.").with_label(span0)
fn no_loss_of_precision_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("This number literal will lose precision at runtime.").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_multi_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use oxc_span::Span;

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_multi_str_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected multi string.").with_label(span0)
fn no_multi_str_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected multi string.").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use oxc_span::{GetSpan, Span};

use crate::{context::LintContext, rule::Rule, AstNode};

fn no_new_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Do not use 'new' for side effects.").with_label(span0)
fn no_new_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Do not use 'new' for side effects.").with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
Loading