chore(linter): change categories of some rules and also add some help messages

no-new-array -> suspicious
prefer-add-event-listener -> suspicious
prefer-date-now -> pedantic
This commit is contained in:
Boshen 2023-11-08 10:52:11 +08:00
parent 8e8508b5f4
commit 26fd0069d8
No known key found for this signature in database
GPG key ID: 234DA6A7079C6801
5 changed files with 14 additions and 4 deletions

View file

@ -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)]

View file

@ -37,7 +37,7 @@ declare_oxc_lint!(
/// const array = [42];
/// ```
NoNewArray,
correctness
suspicious
);
impl Rule for NoNewArray {

View file

@ -39,7 +39,7 @@ declare_oxc_lint!(
/// foo.addEventListener('click', () => {});
/// ```
PreferAddEventListener,
correctness
suspicious
);
impl Rule for PreferAddEventListener {

View file

@ -53,7 +53,7 @@ declare_oxc_lint!(
/// const ts = Date.now();
/// ```
PreferDateNow,
correctness
pedantic
);
impl Rule for PreferDateNow {

View file

@ -7,29 +7,39 @@ expression: no_ex_assign
1 │ try { } 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]
1 │ try { } 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]
1 │ try { } 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]
1 │ try { } 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]
1 │ try { } 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.