mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(linter): add missing error message prefix to eslint/no-const-assign
This commit is contained in:
parent
d5a2161785
commit
cc078d6e77
2 changed files with 21 additions and 18 deletions
|
|
@ -6,7 +6,10 @@ use oxc_span::Span;
|
|||
use crate::{context::LintContext, rule::Rule};
|
||||
|
||||
fn no_const_assign_diagnostic(name: &str, decl_span: Span, assign_span: Span) -> OxcDiagnostic {
|
||||
OxcDiagnostic::warn(format!("Unexpected re-assignment of const variable {name}")).with_labels([
|
||||
OxcDiagnostic::warn(format!(
|
||||
"eslint(no-const-assign): Unexpected re-assignment of const variable {name}"
|
||||
))
|
||||
.with_labels([
|
||||
decl_span.label(format!("{name} is declared here as const")),
|
||||
assign_span.label(format!("{name} is re-assigned here")),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
source: crates/oxc_linter/src/tester.rs
|
||||
snapshot_kind: text
|
||||
---
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const x = 0; x = 1;
|
||||
· ┬ ┬
|
||||
|
|
@ -10,7 +10,7 @@ snapshot_kind: text
|
|||
· ╰── x is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:11]
|
||||
1 │ const {a: x} = {a: 0}; x = 1;
|
||||
· ┬ ┬
|
||||
|
|
@ -18,7 +18,7 @@ snapshot_kind: text
|
|||
· ╰── x is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const x = 0; ({x} = {x: 1});
|
||||
· ┬ ┬
|
||||
|
|
@ -26,7 +26,7 @@ snapshot_kind: text
|
|||
· ╰── x is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const x = 0; ({a: x = 1} = {});
|
||||
· ┬ ┬
|
||||
|
|
@ -34,7 +34,7 @@ snapshot_kind: text
|
|||
· ╰── x is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const x = 0; x += 1;
|
||||
· ┬ ┬
|
||||
|
|
@ -42,7 +42,7 @@ snapshot_kind: text
|
|||
· ╰── x is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const x = 0; ++x;
|
||||
· ┬ ┬
|
||||
|
|
@ -50,7 +50,7 @@ snapshot_kind: text
|
|||
· ╰── x is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable i
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable i
|
||||
╭─[no_const_assign.tsx:1:12]
|
||||
1 │ for (const i = 0; i < 10; ++i) { foo(i); }
|
||||
· ┬ ┬
|
||||
|
|
@ -58,7 +58,7 @@ snapshot_kind: text
|
|||
· ╰── i is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const x = 0; x = 1; x = 2;
|
||||
· ┬ ┬
|
||||
|
|
@ -66,7 +66,7 @@ snapshot_kind: text
|
|||
· ╰── x is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const x = 0; x = 1; x = 2;
|
||||
· ┬ ┬
|
||||
|
|
@ -74,7 +74,7 @@ snapshot_kind: text
|
|||
· ╰── x is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const x = 0; function foo() { x = x + 1; }
|
||||
· ┬ ┬
|
||||
|
|
@ -82,7 +82,7 @@ snapshot_kind: text
|
|||
· ╰── x is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const x = 0; function foo(a) { x = a; }
|
||||
· ┬ ┬
|
||||
|
|
@ -90,7 +90,7 @@ snapshot_kind: text
|
|||
· ╰── x is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const x = 0; while (true) { x = x + 1; }
|
||||
· ┬ ┬
|
||||
|
|
@ -98,7 +98,7 @@ snapshot_kind: text
|
|||
· ╰── x is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const x = 0; function foo(a) { function bar(b) { x = b; } bar(123); }
|
||||
· ┬ ┬
|
||||
|
|
@ -106,7 +106,7 @@ snapshot_kind: text
|
|||
· ╰── x is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
|
||||
╭─[no_const_assign.tsx:1:1]
|
||||
1 │ x = 123; const x = 1;
|
||||
· ┬ ┬
|
||||
|
|
@ -114,7 +114,7 @@ snapshot_kind: text
|
|||
· ╰── x is re-assigned here
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable d
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable d
|
||||
╭─[no_const_assign.tsx:1:24]
|
||||
1 │ const [a, b, ...[c, ...d]] = [1, 2, 3, 4, 5]; d = 123
|
||||
· ┬ ┬
|
||||
|
|
@ -122,7 +122,7 @@ snapshot_kind: text
|
|||
· ╰── d is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable d
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable d
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const d = 123; [a, b, ...[c, ...d]] = [1, 2, 3, 4, 5]
|
||||
· ┬ ┬
|
||||
|
|
@ -130,7 +130,7 @@ snapshot_kind: text
|
|||
· ╰── d is declared here as const
|
||||
╰────
|
||||
|
||||
⚠ eslint(no-const-assign): Unexpected re-assignment of const variable b
|
||||
⚠ eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable b
|
||||
╭─[no_const_assign.tsx:1:7]
|
||||
1 │ const b = 0; ({a, ...b} = {a: 1, c: 2, d: 3})
|
||||
· ┬ ┬
|
||||
|
|
|
|||
Loading…
Reference in a new issue