File tree 3 files changed +396
-1
lines changed
3 files changed +396
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,14 @@ if (foo == NaN) {
25
25
if (foo != NaN ) {
26
26
// ...
27
27
}
28
+
29
+ if (foo == Number .NaN ) {
30
+ // ...
31
+ }
32
+
33
+ if (foo != Number .NaN ) {
34
+ // ...
35
+ }
28
36
```
29
37
30
38
Examples of ** correct** code for this rule:
@@ -77,6 +85,26 @@ switch (NaN) {
77
85
break ;
78
86
// ...
79
87
}
88
+
89
+ switch (foo) {
90
+ case Number .NaN :
91
+ bar ();
92
+ break ;
93
+ case 1 :
94
+ baz ();
95
+ break ;
96
+ // ...
97
+ }
98
+
99
+ switch (Number .NaN ) {
100
+ case a:
101
+ bar ();
102
+ break ;
103
+ case b:
104
+ baz ();
105
+ break ;
106
+ // ...
107
+ }
80
108
```
81
109
82
110
Examples of ** correct** code for this rule with ` "enforceForSwitchCase" ` option set to ` true ` (default):
@@ -126,6 +154,26 @@ switch (NaN) {
126
154
break ;
127
155
// ...
128
156
}
157
+
158
+ switch (foo) {
159
+ case Number .NaN :
160
+ bar ();
161
+ break ;
162
+ case 1 :
163
+ baz ();
164
+ break ;
165
+ // ...
166
+ }
167
+
168
+ switch (Number .NaN ) {
169
+ case a:
170
+ bar ();
171
+ break ;
172
+ case b:
173
+ baz ();
174
+ break ;
175
+ // ...
176
+ }
129
177
```
130
178
131
179
### enforceForIndexOf
Original file line number Diff line number Diff line change @@ -21,7 +21,10 @@ const astUtils = require("./utils/ast-utils");
21
21
* @returns {boolean } `true` if the node is 'NaN' identifier.
22
22
*/
23
23
function isNaNIdentifier ( node ) {
24
- return Boolean ( node ) && node . type === "Identifier" && node . name === "NaN" ;
24
+ return Boolean ( node ) && (
25
+ astUtils . isSpecificId ( node , "NaN" ) ||
26
+ astUtils . isSpecificMemberAccess ( node , "Number" , "NaN" )
27
+ ) ;
25
28
}
26
29
27
30
//------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments