@putout/plugin-types 10.3.0 → 10.4.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 +22 -0
- package/lib/apply-boolean/index.js +14 -0
- package/lib/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ npm i putout @putout/plugin-types -D
|
|
|
15
15
|
|
|
16
16
|
- ✅ [apply-is-array](#apply-is-array);
|
|
17
17
|
- ✅ [apply-number](#apply-number);
|
|
18
|
+
- ✅ [apply-boolean](#apply-boolean);
|
|
18
19
|
- ✅ [convert-typeof-to-is-type](#convert-typeof-to-is-type);
|
|
19
20
|
- ✅ [declare](#declare);
|
|
20
21
|
- ✅ [remove-double-negations](#remove-double-negations);
|
|
@@ -27,6 +28,7 @@ npm i putout @putout/plugin-types -D
|
|
|
27
28
|
```json
|
|
28
29
|
{
|
|
29
30
|
"rules": {
|
|
31
|
+
"types/apply-boolean": "on",
|
|
30
32
|
"types/apply-is-array": "on",
|
|
31
33
|
"types/apply-number": "on",
|
|
32
34
|
"types/declare": "on",
|
|
@@ -39,6 +41,26 @@ npm i putout @putout/plugin-types -D
|
|
|
39
41
|
}
|
|
40
42
|
```
|
|
41
43
|
|
|
44
|
+
## apply-boolean
|
|
45
|
+
|
|
46
|
+
> The `Boolean()` constructor creates `Boolean` objects. When called as a function, it returns primitive values of type `Boolean`.
|
|
47
|
+
>
|
|
48
|
+
> (c) [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)
|
|
49
|
+
|
|
50
|
+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/150f85ffc72f6f84249e75f38e21c081/d1588cd27f8854232cb08a4656bf238412501ef9).
|
|
51
|
+
|
|
52
|
+
### ❌ Example of incorrect code
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
!!(a || b);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### ✅ Example of correct code
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
Boolean(a || b);
|
|
62
|
+
```
|
|
63
|
+
|
|
42
64
|
## apply-number
|
|
43
65
|
|
|
44
66
|
> The `Number` constructor contains constants and methods for working with numbers. Values of other types can be converted to numbers using the `Number()` function
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {removeParens} = operator;
|
|
4
|
+
|
|
5
|
+
export const report = () => `Use 'Boolean' instead of '!!'`;
|
|
6
|
+
|
|
7
|
+
export const replace = () => ({
|
|
8
|
+
'!!__a': (vars, path) => {
|
|
9
|
+
const __aPath = path.get('argument.argument');
|
|
10
|
+
removeParens(__aPath);
|
|
11
|
+
|
|
12
|
+
return 'Boolean(__a)';
|
|
13
|
+
},
|
|
14
|
+
});
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as applyBoolean from './apply-boolean/index.js';
|
|
1
2
|
import * as applyNumber from './apply-number/index.js';
|
|
2
3
|
import * as applyIsArray from './apply-is-array/index.js';
|
|
3
4
|
import * as declare from './declare/index.js';
|
|
@@ -16,4 +17,5 @@ export const rules = {
|
|
|
16
17
|
'remove-double-negations': removeDoubleNegations,
|
|
17
18
|
'remove-useless-typeof': removeUselessTypeof,
|
|
18
19
|
'apply-number': applyNumber,
|
|
20
|
+
'apply-boolean': applyBoolean,
|
|
19
21
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-types",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.4.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",
|