Skip to content

Commit

Permalink
refactor(eslint): convert with_labels to with_label where applicable (#…
Browse files Browse the repository at this point in the history
…3946)

Following earlier work in d6437fe prefer `with_label` over
`with_labels`. Automatically converted using CoccinelleForRust.

---

I noticed some conversions of `with_labels` to `with_label` for a single
span in #3854 and in my recent
pull requests. The Linux kernel uses Coccinelle to automatically
converted helper functions, so I was wondering if there was something
similar for Rust as Coccinelle only does C. It turns out that there is a
[Coccinelle for
Rust](https://gitlab.inria.fr/coccinelle/coccinelleforrust), so I wrote
a small Coccinelle rule to automatically convert all rules. (This PR
only touches eslint, I am happy to run it for the whole rules directory,
this is more a test if the project is willing to accept such massive
automatic refactors).

To convert this automatically build the tool, and save the snippet below
as `with_labels.cocci` and run:

```
~/code/coccinelleforrust/target/debug/cfr --apply --coccifile with_labels.cocci  crates/oxc_linter/src/rules/eslint
```

with_labels.cocci:
```
@@
expression E, OxcDiagnostic;
@@

OxcDiagnostic.
- with_labels([E.into()])
+ with_label(E)
```
  • Loading branch information
jelly committed Jun 27, 2024
1 parent d80ebb1 commit 1cca2a8
Show file tree
Hide file tree
Showing 78 changed files with 98 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ fn expect_return(x0: &str, span1: Span) -> OxcDiagnostic {
"eslint(array-callback-return): Missing return on some path for array method {x0:?}"
))
.with_help(format!("Array method {x0:?} needs to have valid return on all code paths"))
.with_labels([span1.into()])
.with_label(span1)
}

fn expect_no_return(x0: &str, span1: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!(
"eslint(array-callback-return): Unexpected return for array method {x0:?}"
))
.with_help(format!("Array method {x0:?} expects no useless return from the function"))
.with_labels([span1.into()])
.with_label(span1)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/default_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn default_case_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(default-case): Require default cases in switch statements.")
.with_help("Add a default case.")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/default_param_last.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn default_param_last_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(default-param-last): Default parameters should be last")
.with_help("Enforce default parameters to be last.")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/eqeqeq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn eqeqeq_diagnostic(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("eslint(eqeqeq): Expected {x1} and instead saw {x0}"))
.with_help(format!("Prefer {x1} operator"))
.with_labels([span2.into()])
.with_label(span2)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/getter_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn getter_return_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(getter-return): Expected to always return a value in getter.")
.with_help("Return a value from all code paths in getter.")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/guard_for_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn guard_for_in_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(guard-for-in): 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_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/max_classes_per_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn max_classes_per_file_diagnostic(total: usize, max: usize, span1: Span) -> Oxc
"eslint(max-classes-per-file): File has too many classes ({total}). Maximum allowed is {max}",
))
.with_help("Reduce the number of classes in this file")
.with_labels([span1.into()])
.with_label(span1)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/max_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{context::LintContext, rule::Rule};
fn max_lines_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("eslint(max-lines): {x0:?}"))
.with_help("Reduce the number of lines in this file")
.with_labels([span1.into()])
.with_label(span1)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/max_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn max_params_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic {
.with_help(
"This rule enforces a maximum number of parameters allowed in function definitions.",
)
.with_labels([span1.into()])
.with_label(span1)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_array_constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn no_array_constructor_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-array-constructor): Disallow `Array` constructors")
.with_help("Use array literal instead")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn no_async_promise_executor_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(
"eslint(no-async-promise-executor): Promise executor functions should not be `async`.",
)
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_await_in_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};

fn no_await_in_loop_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-await-in-loop): Unexpected `await` inside a loop.")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_bitwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn no_bitwise_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("eslint(no-bitwise): Unexpected use of {x0:?}"))
.with_help("bitwise operators are not allowed, maybe you mistyped `&&` or `||`")
.with_labels([span1.into()])
.with_label(span1)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_caller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn no_caller_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-caller): 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_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_case_declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn no_case_declarations_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(
"eslint(no-case-declarations): Unexpected lexical declaration in case block.",
)
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_compare_neg_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn no_compare_neg_zero_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic {
"eslint(no-compare-neg-zero): Do not use the {x0} operator to compare against -0."
))
.with_help("Use Object.is(x, -0) to test equality with -0 and use 0 for other cases")
.with_labels([span1.into()])
.with_label(span1)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_cond_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn no_cond_assign_diagnostic(span0: Span) -> OxcDiagnostic {
"eslint(no-cond-assign): Expected a conditional expression and instead saw an assignment",
)
.with_help("Consider wrapping the assignment in additional parentheses")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
3 changes: 1 addition & 2 deletions crates/oxc_linter/src/rules/eslint/no_console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use oxc_span::Span;
use crate::{context::LintContext, rule::Rule, AstNode};

fn no_console_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-console): Unexpected console statement.")
.with_labels([span0.into()])
OxcDiagnostic::warn("eslint(no-console): Unexpected console statement.").with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,27 @@ declare_oxc_lint!(
fn constant_short_circuit(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("eslint(no-constant-binary-expression): Unexpected constant {x0:?} on the left-hand side of a {x1:?} expression"))
.with_help("This expression always evaluates to the constant on the left-hand side")
.with_labels([span2.into()])
.with_label(span2)
}

fn constant_binary_operand(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(
"eslint(no-constant-binary-expression): Unexpected constant binary expression",
)
.with_help(format!("This compares constantly with the {x0}-hand side of the {x1}"))
.with_labels([span2.into()])
.with_label(span2)
}

fn constant_always_new(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(
"eslint(no-constant-binary-expression): Unexpected comparison to newly constructed object",
)
.with_help("These two values can never be equal")
.with_labels([span0.into()])
.with_label(span0)
}

fn constant_both_always_new(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-constant-binary-expression): Unexpected comparison of two newly constructed objects").with_help("These two values can never be equal").with_labels([span0.into()])
OxcDiagnostic::warn("eslint(no-constant-binary-expression): Unexpected comparison of two newly constructed objects").with_help("These two values can never be equal").with_label(span0)
}

impl Rule for NoConstantBinaryExpression {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{ast_util::IsConstant, context::LintContext, rule::Rule, AstNode};
fn no_constant_condition_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-constant-condition): Unexpected constant condition")
.with_help("Constant expression as a test condition is not allowed")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn no_constructor_return_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(
"eslint(no-constructor-return): Unexpected return statement in constructor.",
)
.with_labels([span.into()])
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_continue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn no_continue_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-continue): Unexpected use of `continue` statement.")
.with_help("Do not use the `continue` statement.")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_control_regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{ast_util::extract_regex_flags, context::LintContext, rule::Rule, Ast
fn no_control_regex_diagnostic(x0: &str, span1: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-control-regex): Unexpected control character(s)")
.with_help(format!("Unexpected control character(s) in regular expression: \"{x0}\""))
.with_labels([span1.into()])
.with_label(span1)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};

fn no_debugger_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-debugger): `debugger` statement is not allowed")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
3 changes: 1 addition & 2 deletions crates/oxc_linter/src/rules/eslint/no_delete_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use oxc_syntax::operator::UnaryOperator;
use crate::{context::LintContext, rule::Rule, AstNode};

fn no_delete_var_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-delete-var): variables should not be deleted")
.with_labels([span0.into()])
OxcDiagnostic::warn("eslint(no-delete-var): variables should not be deleted").with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_div_regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn no_div_regex_diagnostic(span0: Span) -> OxcDiagnostic {
"eslint(no-div-regex): A regular expression literal can be confused with '/='.",
)
.with_help("Rewrite `/=` into `/[=]`")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn no_empty_character_class_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-empty-character-class): Empty character class")
.with_help("Try to remove empty character class `[]` in regexp literal")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_empty_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn no_empty_function_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-empty-function): Disallow empty functions")
.with_help("Unexpected empty function block")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn no_empty_static_block_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-empty-static-block): Disallow empty static blocks")
.with_help("Unexpected empty static block.")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_eq_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn no_eq_null_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-eq-null): Use '===' to compare with null")
.with_help("Disallow `null` comparisons without type-checking operators.")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use oxc_span::Span;
use crate::{context::LintContext, rule::Rule};

fn no_eval_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-eval): eval can be harmful.").with_labels([span0.into()])
OxcDiagnostic::warn("eslint(no-eval): eval can be harmful.").with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_ex_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use oxc_span::Span;
use crate::{context::LintContext, rule::Rule};

fn no_ex_assign_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-ex-assign): 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_labels([span0.into()])
OxcDiagnostic::warn("eslint(no-ex-assign): 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)
}

#[derive(Debug, Default, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_linter/src/rules/eslint/no_extra_boolean_cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn no_extra_double_negation_cast_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-extra-boolean-cast): Redundant double negation")
.with_help("Remove the double negation as it will already be coerced to a boolean")
.with_labels([span0.into()])
.with_label(span0)
}

fn no_extra_boolean_cast_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-extra-boolean-cast): Redundant Boolean call")
.with_help("Remove the Boolean call as it will already be coerced to a boolean")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
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 @@ -22,17 +22,17 @@ use crate::{context::LintContext, rule::Rule, AstNode};

fn no_fallthrough_case_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::error("eslint(no-fallthrough): Expected a 'break' statement before 'case'.")
.with_labels([span.into()])
.with_label(span)
}

fn no_fallthrough_default_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::error("eslint(no-fallthrough): Expected a 'break' statement before 'default'.")
.with_labels([span.into()])
.with_label(span)
}

fn no_unused_fallthrough_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::error("eslint(no-fallthrough): Found a comment that would permit fallthrough, but case cannot fall through.")
.with_labels([span.into()])
.with_label(span)
}

const DEFAULT_FALLTHROUGH_COMMENT_PATTERN: &str = r"falls?\s?through";
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_import_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{context::LintContext, rule::Rule};
fn no_import_assign_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-import-assign): do not assign to imported bindings")
.with_help("imported bindings are readonly")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn no_inner_declarations_diagnostic(x0: &str, x1: &str, span2: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-inner-declarations): Variable or `function` declarations are not allowed in nested blocks")
.with_help(format!("Move {x0} declaration to {x1} root"))
.with_labels([span2.into()])
.with_label(span2)
}

#[derive(Debug, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{context::LintContext, rule::Rule};
fn no_irregular_whitespace_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-irregular-whitespace): Unexpected irregular whitespace")
.with_help("Try to remove the irregular whitespace")
.with_labels([span0.into()])
.with_label(span0)
}

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{context::LintContext, rule::Rule, AstNode};
fn no_iterator_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("eslint(no-iterator): Reserved name '__iterator__'")
.with_help("Disallow the use of the `__iterator__` property.")
.with_labels([span0.into()])
.with_label(span0)
}

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

0 comments on commit 1cca2a8

Please sign in to comment.