Skip to content

Commit

Permalink
chore(linter): change categories of some rules and also add some help…
Browse files Browse the repository at this point in the history
… messages

no-new-array -> suspicious
prefer-add-event-listener -> suspicious
prefer-date-now -> pedantic
  • Loading branch information
Boshen committed Nov 8, 2023
1 parent 8e8508b commit 26fd006
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
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 @@ -10,7 +10,7 @@ use crate::{context::LintContext, rule::Rule};

#[derive(Debug, Error, Diagnostic)]
#[error("eslint(no-ex-assign): Do not assign to the exception parameter.")]
#[diagnostic(severity(warning))]
#[diagnostic(severity(warning), 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."))]
struct NoExAssignDiagnostic(#[label] pub Span);

#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/unicorn/no_new_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ declare_oxc_lint!(
/// const array = [42];
/// ```
NoNewArray,
correctness
suspicious
);

impl Rule for NoNewArray {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ declare_oxc_lint!(
/// foo.addEventListener('click', () => {});
/// ```
PreferAddEventListener,
correctness
suspicious
);

impl Rule for PreferAddEventListener {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/unicorn/prefer_date_now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ declare_oxc_lint!(
/// const ts = Date.now();
/// ```
PreferDateNow,
correctness
pedantic
);

impl Rule for PreferDateNow {
Expand Down
10 changes: 10 additions & 0 deletions crates/oxc_linter/src/snapshots/no_ex_assign.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,39 @@ expression: no_ex_assign
1try { } catch (e) { e = 10; }
· ─
╰────
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.

eslint(no-ex-assign): Do not assign to the exception parameter.
╭─[no_ex_assign.tsx:1:1]
1try { } catch (ex) { ex = 10; }
· ──
╰────
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.

eslint(no-ex-assign): Do not assign to the exception parameter.
╭─[no_ex_assign.tsx:1:1]
1try { } catch (ex) { [ex] = []; }
· ──
╰────
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.

eslint(no-ex-assign): Do not assign to the exception parameter.
╭─[no_ex_assign.tsx:1:1]
1try { } catch (ex) { ({x: ex = 0} = {}); }
· ──
╰────
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.

eslint(no-ex-assign): Do not assign to the exception parameter.
╭─[no_ex_assign.tsx:1:1]
1try { } catch ({message}) { message = 10; }
· ───────
╰────
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.


0 comments on commit 26fd006

Please sign in to comment.