Skip to content

Commit 65311d0

Browse files
committed
fix(linter): remove duplicate rule/scope from diagnostic (#11531)
1 parent 85b80dc commit 65311d0

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

crates/oxc_linter/src/rules/eslint/no_const_assign.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ use oxc_span::Span;
66
use crate::{context::LintContext, rule::Rule};
77

88
fn no_const_assign_diagnostic(name: &str, decl_span: Span, assign_span: Span) -> OxcDiagnostic {
9-
OxcDiagnostic::warn(format!(
10-
"eslint(no-const-assign): Unexpected re-assignment of const variable {name}"
11-
))
12-
.with_labels([
9+
OxcDiagnostic::warn(format!("Unexpected re-assignment of const variable {name}")).with_labels([
1310
decl_span.label(format!("{name} is declared here as const")),
1411
assign_span.label(format!("{name} is re-assigned here")),
1512
])

crates/oxc_linter/src/snapshots/eslint_no_const_assign.snap

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,135 @@
11
---
22
source: crates/oxc_linter/src/tester.rs
33
---
4-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
4+
eslint(no-const-assign): Unexpected re-assignment of const variable x
55
╭─[no_const_assign.tsx:1:7]
66
1const x = 0; x = 1;
77
· ┬ ┬
88
· │ ╰── x is re-assigned here
99
· ╰── x is declared here as const
1010
╰────
1111

12-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
12+
eslint(no-const-assign): Unexpected re-assignment of const variable x
1313
╭─[no_const_assign.tsx:1:11]
1414
1const {a: x} = {a: 0}; x = 1;
1515
· ┬ ┬
1616
· │ ╰── x is re-assigned here
1717
· ╰── x is declared here as const
1818
╰────
1919

20-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
20+
eslint(no-const-assign): Unexpected re-assignment of const variable x
2121
╭─[no_const_assign.tsx:1:7]
2222
1const x = 0; ({x} = {x: 1});
2323
· ┬ ┬
2424
· │ ╰── x is re-assigned here
2525
· ╰── x is declared here as const
2626
╰────
2727

28-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
28+
eslint(no-const-assign): Unexpected re-assignment of const variable x
2929
╭─[no_const_assign.tsx:1:7]
3030
1const x = 0; ({a: x = 1} = {});
3131
· ┬ ┬
3232
· │ ╰── x is re-assigned here
3333
· ╰── x is declared here as const
3434
╰────
3535

36-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
36+
eslint(no-const-assign): Unexpected re-assignment of const variable x
3737
╭─[no_const_assign.tsx:1:7]
3838
1const x = 0; x += 1;
3939
· ┬ ┬
4040
· │ ╰── x is re-assigned here
4141
· ╰── x is declared here as const
4242
╰────
4343

44-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
44+
eslint(no-const-assign): Unexpected re-assignment of const variable x
4545
╭─[no_const_assign.tsx:1:7]
4646
1const x = 0; ++x;
4747
· ┬ ┬
4848
· │ ╰── x is re-assigned here
4949
· ╰── x is declared here as const
5050
╰────
5151

52-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable i
52+
eslint(no-const-assign): Unexpected re-assignment of const variable i
5353
╭─[no_const_assign.tsx:1:12]
5454
1for (const i = 0; i < 10; ++i) { foo(i); }
5555
· ┬ ┬
5656
· │ ╰── i is re-assigned here
5757
· ╰── i is declared here as const
5858
╰────
5959

60-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
60+
eslint(no-const-assign): Unexpected re-assignment of const variable x
6161
╭─[no_const_assign.tsx:1:7]
6262
1const x = 0; x = 1; x = 2;
6363
· ┬ ┬
6464
· │ ╰── x is re-assigned here
6565
· ╰── x is declared here as const
6666
╰────
6767

68-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
68+
eslint(no-const-assign): Unexpected re-assignment of const variable x
6969
╭─[no_const_assign.tsx:1:7]
7070
1const x = 0; x = 1; x = 2;
7171
· ┬ ┬
7272
· │ ╰── x is re-assigned here
7373
· ╰── x is declared here as const
7474
╰────
7575

76-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
76+
eslint(no-const-assign): Unexpected re-assignment of const variable x
7777
╭─[no_const_assign.tsx:1:7]
7878
1const x = 0; function foo() { x = x + 1; }
7979
· ┬ ┬
8080
· │ ╰── x is re-assigned here
8181
· ╰── x is declared here as const
8282
╰────
8383

84-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
84+
eslint(no-const-assign): Unexpected re-assignment of const variable x
8585
╭─[no_const_assign.tsx:1:7]
8686
1const x = 0; function foo(a) { x = a; }
8787
· ┬ ┬
8888
· │ ╰── x is re-assigned here
8989
· ╰── x is declared here as const
9090
╰────
9191

92-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
92+
eslint(no-const-assign): Unexpected re-assignment of const variable x
9393
╭─[no_const_assign.tsx:1:7]
9494
1const x = 0; while (true) { x = x + 1; }
9595
· ┬ ┬
9696
· │ ╰── x is re-assigned here
9797
· ╰── x is declared here as const
9898
╰────
9999

100-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
100+
eslint(no-const-assign): Unexpected re-assignment of const variable x
101101
╭─[no_const_assign.tsx:1:7]
102102
1const x = 0; function foo(a) { function bar(b) { x = b; } bar(123); }
103103
· ┬ ┬
104104
· │ ╰── x is re-assigned here
105105
· ╰── x is declared here as const
106106
╰────
107107

108-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable x
108+
eslint(no-const-assign): Unexpected re-assignment of const variable x
109109
╭─[no_const_assign.tsx:1:1]
110110
1x = 123; const x = 1;
111111
· ┬ ┬
112112
· │ ╰── x is declared here as const
113113
· ╰── x is re-assigned here
114114
╰────
115115

116-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable d
116+
eslint(no-const-assign): Unexpected re-assignment of const variable d
117117
╭─[no_const_assign.tsx:1:24]
118118
1const [a, b, ...[c, ...d]] = [1, 2, 3, 4, 5]; d = 123
119119
· ┬ ┬
120120
· │ ╰── d is re-assigned here
121121
· ╰── d is declared here as const
122122
╰────
123123

124-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable d
124+
eslint(no-const-assign): Unexpected re-assignment of const variable d
125125
╭─[no_const_assign.tsx:1:7]
126126
1const d = 123; [a, b, ...[c, ...d]] = [1, 2, 3, 4, 5]
127127
· ┬ ┬
128128
· │ ╰── d is re-assigned here
129129
· ╰── d is declared here as const
130130
╰────
131131

132-
eslint(no-const-assign): eslint(no-const-assign): Unexpected re-assignment of const variable b
132+
eslint(no-const-assign): Unexpected re-assignment of const variable b
133133
╭─[no_const_assign.tsx:1:7]
134134
1const b = 0; ({a, ...b} = {a: 1, c: 2, d: 3})
135135
· ┬ ┬

0 commit comments

Comments
 (0)