@putout/plugin-types 8.0.0 → 9.0.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.
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
compare,
|
|
5
|
+
getBindingPath,
|
|
6
|
+
extract,
|
|
7
|
+
} = operator;
|
|
4
8
|
|
|
5
9
|
const NAMES = {
|
|
6
10
|
function: 'isFn',
|
|
@@ -10,6 +14,7 @@ const NAMES = {
|
|
|
10
14
|
undefined: 'isUndefined',
|
|
11
15
|
symbol: 'isSymbol',
|
|
12
16
|
bigint: 'isBigInt',
|
|
17
|
+
Object: 'isObject',
|
|
13
18
|
};
|
|
14
19
|
|
|
15
20
|
const EQUAL = 'typeof __a === "__b"';
|
|
@@ -53,10 +58,11 @@ export const report = () => `Use function to check type instead of 'typeof' or '
|
|
|
53
58
|
export const match = () => ({
|
|
54
59
|
[EQUAL]: check,
|
|
55
60
|
[NOT_EQUAL]: check,
|
|
56
|
-
|
|
61
|
+
|
|
57
62
|
[NOT_EQUAL_INSTANCE_OF]: check,
|
|
58
63
|
[EQUAL_UNDEFINED]: check,
|
|
59
64
|
[NOT_EQUAL_UNDEFINED]: check,
|
|
65
|
+
[EQUAL_INSTANCE_OF]: check,
|
|
60
66
|
});
|
|
61
67
|
|
|
62
68
|
export const replace = () => ({
|
|
@@ -88,7 +94,7 @@ function check({__a, __b}, path) {
|
|
|
88
94
|
if (path.parentPath.isFunction())
|
|
89
95
|
return false;
|
|
90
96
|
|
|
91
|
-
if (__b && isBind(path, __b
|
|
97
|
+
if (__b && isBind(path, extract(__b)))
|
|
92
98
|
return false;
|
|
93
99
|
|
|
94
100
|
return getBindingPath(path, __a);
|
|
@@ -103,7 +109,13 @@ function isBind(path, name) {
|
|
|
103
109
|
return false;
|
|
104
110
|
|
|
105
111
|
if (bindingPath.isVariableDeclarator()) {
|
|
106
|
-
const
|
|
112
|
+
const initPath = bindingPath.get('init');
|
|
113
|
+
|
|
114
|
+
if (!initPath.isFunction())
|
|
115
|
+
return true;
|
|
116
|
+
|
|
117
|
+
const {body} = initPath.node;
|
|
118
|
+
|
|
107
119
|
return !compare(body, fnBody);
|
|
108
120
|
}
|
|
109
121
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-types",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.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",
|
|
@@ -32,22 +32,23 @@
|
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@putout/eslint-flat": "^3.0.0",
|
|
35
|
+
"@putout/plugin-declare-before-reference": "*",
|
|
35
36
|
"@putout/plugin-putout": "*",
|
|
36
|
-
"@putout/test": "^
|
|
37
|
+
"@putout/test": "^15.0.0",
|
|
37
38
|
"c8": "^10.0.0",
|
|
38
|
-
"eslint": "^
|
|
39
|
+
"eslint": "^10.0.0-alpha.0",
|
|
39
40
|
"eslint-plugin-n": "^17.0.0",
|
|
40
|
-
"eslint-plugin-putout": "^
|
|
41
|
-
"madrun": "^
|
|
41
|
+
"eslint-plugin-putout": "^29.0.0",
|
|
42
|
+
"madrun": "^12.0.0",
|
|
42
43
|
"montag": "^1.2.1",
|
|
43
44
|
"nodemon": "^3.0.1"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
46
|
-
"putout": ">=
|
|
47
|
+
"putout": ">=41"
|
|
47
48
|
},
|
|
48
49
|
"license": "MIT",
|
|
49
50
|
"engines": {
|
|
50
|
-
"node": ">=
|
|
51
|
+
"node": ">=22"
|
|
51
52
|
},
|
|
52
53
|
"publishConfig": {
|
|
53
54
|
"access": "public"
|