mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
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:
parent
8e8508b5f4
commit
26fd0069d8
5 changed files with 14 additions and 4 deletions
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ declare_oxc_lint!(
|
|||
/// const array = [42];
|
||||
/// ```
|
||||
NoNewArray,
|
||||
correctness
|
||||
suspicious
|
||||
);
|
||||
|
||||
impl Rule for NoNewArray {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ declare_oxc_lint!(
|
|||
/// foo.addEventListener('click', () => {});
|
||||
/// ```
|
||||
PreferAddEventListener,
|
||||
correctness
|
||||
suspicious
|
||||
);
|
||||
|
||||
impl Rule for PreferAddEventListener {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ declare_oxc_lint!(
|
|||
/// const ts = Date.now();
|
||||
/// ```
|
||||
PreferDateNow,
|
||||
correctness
|
||||
pedantic
|
||||
);
|
||||
|
||||
impl Rule for PreferDateNow {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue