8000 fix(linter): improve eslint/no-unsafe-negation diagnostic (#11520) · oxc-project/oxc@17883e3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 17883e3

Browse files
committed
fix(linter): improve eslint/no-unsafe-negation diagnostic (#11520)
1 parent 8c89937 commit 17883e3

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ use oxc_syntax::operator::UnaryOperator;
77
use crate::{AstNode, context::LintContext, fixer::RuleFixer, rule::Rule};
88

99
fn no_unsafe_negation_diagnostic(operator: &str, span: Span) -> OxcDiagnostic {
10-
OxcDiagnostic::warn(format!("Unexpected negating the left operand of '{operator}' operator"))
11-
.with_help(format!(
12-
"Use `()` to negate the whole expression, as '!' binds more closely than '{operator}'"
13-
))
14-
.with_label(span)
10+
OxcDiagnostic::warn(format!(
11+
"Unexpected negation of the left operand of '{operator}' operator."
12+
))
13+
.with_help(format!(
14+
"Use `()` to negate the whole expression, as '!' binds more closely than '{operator}'"
15+
))
16+
.with_label(span)
1517
}
1618

1719
#[derive(Debug, Default, Clone)]

crates/oxc_linter/src/snapshots/eslint_no_unsafe_negation.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,84 @@
11
---
22
source: crates/oxc_linter/src/tester.rs
33
---
4-
eslint(no-unsafe-negation): Unexpected negating the left operand of 'in' operator
4+
eslint(no-unsafe-negation): Unexpected negation of the left operand of 'in' operator.
55
╭─[no_unsafe_negation.tsx:1:1]
66
1!a in b
77
· ──
88
╰────
99
help: Use `()` to negate the whole expression, as '!' binds more closely than 'in'
1010

11-
eslint(no-unsafe-negation): Unexpected negating the left operand of 'in' operator
11+
eslint(no-unsafe-negation): Unexpected negation of the left operand of 'in' operator.
1212
╭─[no_unsafe_negation.tsx:1:2]
1313
1 │ (!a in b)
1414
· ──
1515
╰────
1616
help: Use `()` to negate the whole expression, as '!' binds more closely than 'in'
1717

18-
eslint(no-unsafe-negation): Unexpected negating the left operand of 'in' operator
18+
eslint(no-unsafe-negation): Unexpected negation of the left operand of 'in' operator.
1919
╭─[no_unsafe_negation.tsx:1:1]
2020
1!(a) in b
2121
· ────
2222
╰────
2323
help: Use `()` to negate the whole expression, as '!' binds more closely than 'in'
2424

25-
eslint(no-unsafe-negation): Unexpected negating the left operand of 'instanceof' operator
25+
eslint(no-unsafe-negation): Unexpected negation of the left operand of 'instanceof' operator.
2626
╭─[no_unsafe_negation.tsx:1:1]
2727
1!a instanceof b
2828
· ──
2929
╰────
3030
help: Use `()` to negate the whole expression, as '!' binds more closely than 'instanceof'
3131

32-
eslint(no-unsafe-negation): Unexpected negating the left operand of 'instanceof' operator
32+
eslint(no-unsafe-negation): Unexpected negation of the left operand of 'instanceof' operator.
3333
╭─[no_unsafe_negation.tsx:1:2]
3434
1 │ (!a instanceof b)
3535
· ──
3636
╰────
3737
help: Use `()` to negate the whole expression, as '!' binds more closely than 'instanceof'
3838

39-
eslint(no-unsafe-negation): Unexpected negating the left operand of 'instanceof' operator
39+
eslint(no-unsafe-negation): Unexpected negation of the left operand of 'instanceof' operator.
4040
╭─[no_unsafe_negation.tsx:1:1]
4141
1!(a) instanceof b
4242
· ────
4343
╰────
4444
help: Use `()` to negate the whole expression, as '!' binds more closely than 'instanceof'
4545

46-
eslint(no-unsafe-negation): Unexpected negating the left operand of 'in' operator
46+
eslint(no-unsafe-negation): Unexpected negation of the left operand of 'in' operator.
4747
╭─[no_unsafe_negation.tsx:1:9]
4848
1 │ (y=>{if(!/s/ in(l)){}})
4949
· ────
5050
╰────
5151
help: Use `()` to negate the whole expression, as '!' binds more closely than 'in'
5252

53-
eslint(no-unsafe-negation): Unexpected negating the left operand of '<' operator
53+
eslint(no-unsafe-negation): Unexpected negation of the left operand of '<' operator.
5454
╭─[no_unsafe_negation.tsx:1:5]
5555
1if (! a < b) {}
5656
· ───
5757
╰────
5858
help: Use `()` to negate the whole expression, as '!' binds more closely than '<'
5959

60-
eslint(no-unsafe-negation): Unexpected negating the left operand of '>' operator
60+
eslint(no-unsafe-negation): Unexpected negation of the left operand of '>' operator.
6161
╭─[no_unsafe_negation.tsx:1:8]
6262
1while (! a > b) {}
6363
· ───
6464
╰────
6565
help: Use `()` to negate the whole expression, as '!' binds more closely than '>'
6666

67-
eslint(no-unsafe-negation): Unexpected negating the left operand of '<=' operator
67+
eslint(no-unsafe-negation): Unexpected negation of the left operand of '<=' operator.
6868
╭─[no_unsafe_negation.tsx:1:7]
6969
1foo = ! a <= b;
7070
· ───
7171
╰────
7272
help: Use `()` to negate the whole expression, as '!' binds more closely than '<='
7373

74-
eslint(no-unsafe-negation): Unexpected negating the left operand of '>=' operator
74+
eslint(no-unsafe-negation): Unexpected negation of the left operand of '>=' operator.
7575
╭─[no_unsafe_negation.tsx:1:7]
7676
1foo = ! a >= b;
7777
· ───
7878
╰────
7979
help: Use `()` to negate the whole expression, as '!' binds more closely than '>='
8080

81-
eslint(no-unsafe-negation): Unexpected negating the left operand of '<=' operator
81+
eslint(no-unsafe-negation): Unexpected negation of the left operand of '<=' operator.
8282
╭─[no_unsafe_negation.tsx:1:1]
8383
1! a <= b
8484
· ───

0 commit comments

Comments
 (0)
0