@putout/plugin-types 10.4.0 → 10.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -3
- package/lib/apply-is-nan/index.js +5 -0
- package/lib/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,9 +13,10 @@ npm i putout @putout/plugin-types -D
|
|
|
13
13
|
|
|
14
14
|
## Rules
|
|
15
15
|
|
|
16
|
-
- ✅ [apply-is-array](#apply-is-array);
|
|
17
|
-
- ✅ [apply-number](#apply-number);
|
|
18
16
|
- ✅ [apply-boolean](#apply-boolean);
|
|
17
|
+
- ✅ [apply-number](#apply-number);
|
|
18
|
+
- ✅ [apply-is-array](#apply-is-array);
|
|
19
|
+
- ✅ [apply-is-nan](#apply-is-nan);
|
|
19
20
|
- ✅ [convert-typeof-to-is-type](#convert-typeof-to-is-type);
|
|
20
21
|
- ✅ [declare](#declare);
|
|
21
22
|
- ✅ [remove-double-negations](#remove-double-negations);
|
|
@@ -29,8 +30,9 @@ npm i putout @putout/plugin-types -D
|
|
|
29
30
|
{
|
|
30
31
|
"rules": {
|
|
31
32
|
"types/apply-boolean": "on",
|
|
32
|
-
"types/apply-is-array": "on",
|
|
33
33
|
"types/apply-number": "on",
|
|
34
|
+
"types/apply-is-array": "on",
|
|
35
|
+
"types/apply-is-nan": "on",
|
|
34
36
|
"types/declare": "on",
|
|
35
37
|
"types/convert-typeof-to-istype": "on",
|
|
36
38
|
"types/remove-useless-conversion": "on",
|
|
@@ -97,6 +99,8 @@ const a = {
|
|
|
97
99
|
|
|
98
100
|
> The `Array.isArray()` method determines whether the passed value is an `Array`.
|
|
99
101
|
> When checking for `Array` instance, `Array.isArray()` is preferred over `instanceof` because it works through `iframes`.
|
|
102
|
+
>
|
|
103
|
+
> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)
|
|
100
104
|
|
|
101
105
|
### ❌ Example of incorrect code
|
|
102
106
|
|
|
@@ -129,6 +133,29 @@ In case of using `inline` option:
|
|
|
129
133
|
Array.isArray(x);
|
|
130
134
|
```
|
|
131
135
|
|
|
136
|
+
## apply-is-nan
|
|
137
|
+
|
|
138
|
+
> The `NaN` global property is a value representing Not-A-Number: `NaN !== NaN`.
|
|
139
|
+
>
|
|
140
|
+
> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN)
|
|
141
|
+
|
|
142
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/e8ff80a3f522626c2d049b771692ced1/7ea6eb75d7d39f20654753fc2d800f7d881abaca)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
### ❌ Example of incorrect code
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
if (a === NaN)
|
|
149
|
+
console.log();
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### ✅ Example of correct code
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
if (Number.isNaN(a))
|
|
156
|
+
console.log();
|
|
157
|
+
```
|
|
158
|
+
|
|
132
159
|
## declare
|
|
133
160
|
|
|
134
161
|
Based on [`@putout/operator-declare`](https://github.com/coderaiser/putout/tree/master/packages/operator-declare#putoutoperator-declare-).
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as applyIsNan from './apply-is-nan/index.js';
|
|
1
2
|
import * as applyBoolean from './apply-boolean/index.js';
|
|
2
3
|
import * as applyNumber from './apply-number/index.js';
|
|
3
4
|
import * as applyIsArray from './apply-is-array/index.js';
|
|
@@ -18,4 +19,5 @@ export const rules = {
|
|
|
18
19
|
'remove-useless-typeof': removeUselessTypeof,
|
|
19
20
|
'apply-number': applyNumber,
|
|
20
21
|
'apply-boolean': applyBoolean,
|
|
22
|
+
'apply-is-nan': applyIsNan,
|
|
21
23
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-types",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin adds ability to transform code related to types assertions",
|