Skip to content

Commit 0f24366

Browse files
authored
fix(linter): correct labels for redundant comparisons (#11620)
The labels were displayed in an opposite order.
1 parent e0ae6b2 commit 0f24366

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

crates/oxc_linter/src/rules/oxc/const_comparisons.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ fn redundant_left_hand_side(left_span: Span, right_span: Span, help: String) ->
1616
OxcDiagnostic::warn("Left-hand side of `&&` operator has no effect.")
1717
.with_help(help)
1818
.with_labels([
19-
left_span.label("If this evaluates to `true`"),
20-
right_span.label("This will always evaluate to true."),
19+
right_span.label("If this evaluates to `true`"),
20+
left_span.label("This will always evaluate to true."),
2121
])
2222
}
2323

2424
fn redundant_right_hand_side(right_span: Span, left_span: Span, help: String) -> OxcDiagnostic {
2525
OxcDiagnostic::warn("Right-hand side of `&&` operator has no effect.")
2626
.with_help(help)
2727
.with_labels([
28-
right_span.label("If this evaluates to `true`"),
29-
left_span.label("This will always evaluate to true."),
28+
left_span.label("If this evaluates to `true`"),
29+
right_span.label("This will always evaluate to true."),
3030
])
3131
}
3232

crates/oxc_linter/src/snapshots/oxc_const_comparisons.snap

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,53 +68,53 @@ source: crates/oxc_linter/src/tester.rs
6868
╭─[const_comparisons.tsx:1:1]
6969
1status_code < 200 && status_code <= 299;
7070
· ────────┬──────── ─────────┬────────
71-
· │ ╰── If this evaluates to `true`
72-
· ╰── This will always evaluate to true.
71+
· │ ╰── This will always evaluate to true.
72+
· ╰── If this evaluates to `true`
7373
╰────
7474
help: if `status_code < 200` evaluates to true, `status_code <= 299` will always evaluate to true as well
7575

7676
oxc(const-comparisons): Left-hand side of `&&` operator has no effect.
7777
╭─[const_comparisons.tsx:1:1]
7878
1status_code > 200 && status_code >= 299;
7979
· ────────┬──────── ─────────┬────────
80-
· │ ╰── This will always evaluate to true.
81-
· ╰── If this evaluates to `true`
80+
· │ ╰── If this evaluates to `true`
81+
· ╰── This will always evaluate to true.
8282
╰────
8383
help: if `status_code >= 299` evaluates to true, `status_code > 200` will always evaluate to true as well
8484

8585
oxc(const-comparisons): Left-hand side of `&&` operator has no effect.
8686
╭─[const_comparisons.tsx:1:1]
8787
1status_code >= 500 && status_code > 500;
8888
· ─────────┬──────── ────────┬────────
89-
· │ ╰── This will always evaluate to true.
90-
· ╰── If this evaluates to `true`
89+
· │ ╰── If this evaluates to `true`
90+
· ╰── This will always evaluate to true.
9191
╰────
9292
help: if `status_code > 500` evaluates to true, `status_code >= 500` will always evaluate to true as well
9393

9494
oxc(const-comparisons): Right-hand side of `&&` operator has no effect.
9595
╭─[const_comparisons.tsx:1:1]
9696
1status_code > 500 && status_code >= 500;
9797
· ────────┬──────── ─────────┬────────
98-
· │ ╰── If this evaluates to `true`
99-
· ╰── This will always evaluate to true.
98+
· │ ╰── This will always evaluate to true.
99+
· ╰── If this evaluates to `true`
100100
╰────
101101
help: if `status_code > 500` evaluates to true, `status_code >= 500` will always evaluate to true as well
102102

103103
oxc(const-comparisons): Left-hand side of `&&` operator has no effect.
104104
╭─[const_comparisons.tsx:1:1]
105105
1status_code <= 500 && status_code < 500;
106106
· ─────────┬──────── ────────┬────────
107-
· │ ╰── This will always evaluate to true.
108-
· ╰── If this evaluates to `true`
107+
· │ ╰── If this evaluates to `true`
108+
· ╰── This will always evaluate to true.
109109
╰────
110110
help: if `status_code < 500` evaluates to true, `status_code <= 500` will always evaluate to true as well
111111

112112
oxc(const-comparisons): Right-hand side of `&&` operator has no effect.
113113
╭─[const_comparisons.tsx:1:1]
114114
1status_code < 500 && status_code <= 500;
115115
· ────────┬──────── ─────────┬────────
116-
· │ ╰── If this evaluates to `true`
117-
· ╰── This will always evaluate to true.
116+
· │ ╰── This will always evaluate to true.
117+
· ╰── If this evaluates to `true`
118118
╰────
119119
help: if `status_code < 500` evaluates to true, `status_code <= 500` will always evaluate to true as well
120120

@@ -185,53 +185,53 @@ source: crates/oxc_linter/src/tester.rs
185185
╭─[const_comparisons.tsx:1:10]
186186
1foo() && status_code >= 500 && status_code > 500;
187187
· ─────────┬──────── ────────┬────────
188-
· │ ╰── This will always evaluate to true.
189-
· ╰── If this evaluates to `true`
188+
· │ ╰── If this evaluates to `true`
189+
· ╰── This will always evaluate to true.
190190
╰────
191191
help: if `status_code > 500` evaluates to true, `status_code >= 500` will always evaluate to true as well
192192

193193
oxc(const-comparisons): Left-hand side of `&&` operator has no effect.
194194
╭─[const_comparisons.tsx:1:1]
195195
1status_code <= 500 && foo() && status_code < 500;
196196
· ─────────┬──────── ────────┬────────
197-
· │ ╰── This will always evaluate to true.
198-
· ╰── If this evaluates to `true`
197+
· │ ╰── If this evaluates to `true`
198+
· ╰── This will always evaluate to true.
199199
╰────
200200
help: if `status_code < 500` evaluates to true, `status_code <= 500` will always evaluate to true as well
201201

202202
oxc(const-comparisons): Left-hand side of `&&` operator has no effect.
203203
╭─[const_comparisons.tsx:1:1]
204204
1status_code >= 500 && response && status_code > 500;
205205
· ─────────┬──────── ────────┬────────
206-
· │ ╰── This will always evaluate to true.
207-
· ╰── If this evaluates to `true`
206+
· │ ╰── If this evaluates to `true`
207+
· ╰── This will always evaluate to true.
208208
╰────
209209
help: if `status_code > 500` evaluates to true, `status_code >= 500` will always evaluate to true as well
210210

211211
oxc(const-comparisons): Right-hand side of `&&` operator has no effect.
212212
╭─[const_comparisons.tsx:1:13]
213213
1response && status_code > 500 && status_code >= 500;
214214
· ────────┬──────── ─────────┬────────
215-
· │ ╰── If this evaluates to `true`
216-
· ╰── This will always evaluate to true.
215+
· │ ╰── This will always evaluate to true.
216+
· ╰── If this evaluates to `true`
217217
╰────
218218
help: if `status_code > 500` evaluates to true, `status_code >= 500` will always evaluate to true as well
219219

220220
oxc(const-comparisons): Left-hand side of `&&` operator has no effect.
221221
╭─[const_comparisons.tsx:1:1]
222222
1status_code <= 500 && response && status_code < 500;
223223
· ─────────┬──────── ────────┬────────
224-
· │ ╰── This will always evaluate to true.
225-
· ╰── If this evaluates to `true`
224+
· │ ╰── If this evaluates to `true`
225+
· ╰── This will always evaluate to true.
226226
╰────
227227
help: if `status_code < 500` evaluates to true, `status_code <= 500` will always evaluate to true as well
228228

229229
oxc(const-comparisons): Right-hand side of `&&` operator has no effect.
230230
╭─[const_comparisons.tsx:1:1]
231231
1status_code < 500 && response && status_code <= 500;
232232
· ────────┬──────── ─────────┬────────
233-
· │ ╰── If this evaluates to `true`
234-
· ╰── This will always evaluate to true.
233+
· │ ╰── This will always evaluate to true.
234+
· ╰── If this evaluates to `true`
235235
╰────
236236
help: if `status_code < 500` evaluates to true, `status_code <= 500` will always evaluate to true as well
237237

0 commit comments

Comments
 (0)