File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,11 @@ impl Rule for NoSelfCompare {
48
48
return ;
49
49
}
50
50
51
- if binary_expr. left . content_eq ( & binary_expr. right ) {
51
+ if binary_expr
52
+ . left
53
+ . without_parentheses ( )
54
+ . content_eq ( binary_expr. right . without_parentheses ( ) )
55
+ {
52
56
ctx. diagnostic ( no_self_compare_diagnostic (
53
57
binary_expr. left . span ( ) ,
54
58
binary_expr. right . span ( ) ,
@@ -84,6 +88,9 @@ fn test() {
84
88
( "x < x" , None ) ,
85
89
( "x >= x" , None ) ,
86
90
( "x <= x" , None ) ,
91
+ ( "x > (x)" , None ) ,
92
+ ( "(x) == x" , None ) ,
93
+ ( "(x) >= ((x))" , None ) ,
87
94
( "foo.bar().baz.qux >= foo.bar ().baz .qux" , None ) ,
88
95
( "class C { #field; foo() { this.#field === this.#field; } }" , None ) ,
89
96
] ;
Original file line number Diff line number Diff line change @@ -92,6 +92,27 @@ source: crates/oxc_linter/src/tester.rs
92
92
╰────
93
93
help: If you are testing for NaN, you can use Number.isNaN function .
94
94
95
+ ⚠ eslint(no -self -compare ): Both sides of this comparison are exactly the same
96
+ ╭─[no_self_compare.tsx:1:1]
97
+ 1 │ x > (x )
98
+ · ─ ───
99
+ ╰────
100
+ help: If you are testing for NaN, you can use Number.isNaN function .
101
+
102
+ ⚠ eslint(no -self -compare ): Both sides of this comparison are exactly the same
103
+ ╭─[no_self_compare.tsx:1:1]
104
+ 1 │ (x ) == x
105
+ · ─── ─
106
+ ╰────
107
+ help: If you are testing for NaN, you can use Number.isNaN function .
108
+
109
+ ⚠ eslint(no -self -compare ): Both sides of this comparison are exactly the same
110
+ ╭─[no_self_compare.tsx:1:1]
111
+ 1 │ (x ) >= ((x ))
112
+ · ─── ─────
113
+ ╰────
114
+ help: If you are testing for NaN, you can use Number.isNaN function .
115
+
95
116
⚠ eslint(no -self -compare ): Both sides of this comparison are exactly the same
96
117
╭─[no_self_compare.tsx:1:1]
97
118
1 │ foo.bar().baz.qux >= foo.bar ().baz .qux
You can’t perform that action at this time.
0 commit comments