@eslint-react/core 1.50.0-next.0 → 2.0.0-beta.14
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/dist/index.d.ts +13 -32
- package/dist/index.js +292 -453
- package/package.json +14 -22
- package/dist/index.d.mts +0 -565
- package/dist/index.mjs +0 -948
package/dist/index.js
CHANGED
|
@@ -1,102 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
2
|
+
import * as AST14 from '@eslint-react/ast';
|
|
3
|
+
import { flip, dual, constFalse, identity, constTrue, _ } from '@eslint-react/eff';
|
|
4
|
+
import { RegExp, Selector } from '@eslint-react/kit';
|
|
5
|
+
import { coerceSettings, DEFAULT_ESLINT_REACT_SETTINGS, getId } from '@eslint-react/shared';
|
|
6
|
+
import * as VAR3 from '@eslint-react/var';
|
|
7
|
+
import { isMatching, P, match } from 'ts-pattern';
|
|
8
|
+
import birecord from 'birecord';
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
var eff = require('@eslint-react/eff');
|
|
5
|
-
var kit = require('@eslint-react/kit');
|
|
6
|
-
var shared = require('@eslint-react/shared');
|
|
7
|
-
var types = require('@typescript-eslint/types');
|
|
8
|
-
var VAR3 = require('@eslint-react/var');
|
|
9
|
-
var tsPattern = require('ts-pattern');
|
|
10
|
-
var birecord = require('birecord');
|
|
11
|
-
|
|
12
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
|
|
14
|
-
function _interopNamespace(e) {
|
|
15
|
-
if (e && e.__esModule) return e;
|
|
16
|
-
var n = Object.create(null);
|
|
17
|
-
if (e) {
|
|
18
|
-
Object.keys(e).forEach(function (k) {
|
|
19
|
-
if (k !== 'default') {
|
|
20
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return e[k]; }
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
n.default = e;
|
|
29
|
-
return Object.freeze(n);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
var AST9__namespace = /*#__PURE__*/_interopNamespace(AST9);
|
|
33
|
-
var VAR3__namespace = /*#__PURE__*/_interopNamespace(VAR3);
|
|
34
|
-
var birecord__default = /*#__PURE__*/_interopDefault(birecord);
|
|
35
|
-
|
|
36
|
-
// src/component/component-collector.ts
|
|
37
|
-
function getInstanceId(node, prev) {
|
|
38
|
-
switch (true) {
|
|
39
|
-
case (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init === prev):
|
|
40
|
-
return node.id;
|
|
41
|
-
case (node.type === types.AST_NODE_TYPES.AssignmentExpression && node.right === prev):
|
|
42
|
-
return node.left;
|
|
43
|
-
case (node.type === types.AST_NODE_TYPES.PropertyDefinition && node.value === prev):
|
|
44
|
-
return node.key;
|
|
45
|
-
case (node.type === types.AST_NODE_TYPES.BlockStatement || node.type === types.AST_NODE_TYPES.Program || node.parent === node):
|
|
46
|
-
return eff._;
|
|
47
|
-
default:
|
|
48
|
-
return getInstanceId(node.parent, node);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function getRequireExpressionArguments(node) {
|
|
52
|
-
return tsPattern.match(node).with({ type: types.AST_NODE_TYPES.CallExpression, arguments: tsPattern.P.select(), callee: { type: types.AST_NODE_TYPES.Identifier, name: "require" } }, eff.identity).with({ type: types.AST_NODE_TYPES.MemberExpression, object: tsPattern.P.select() }, getRequireExpressionArguments).otherwise(() => null);
|
|
53
|
-
}
|
|
54
|
-
function isInitializedFromReact(name, importSource, initialScope) {
|
|
55
|
-
if (name.toLowerCase() === "react") return true;
|
|
56
|
-
const latestDef = VAR3__namespace.findVariable(name, initialScope)?.defs.at(-1);
|
|
57
|
-
if (latestDef == null) return false;
|
|
58
|
-
const { node, parent } = latestDef;
|
|
59
|
-
if (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init != null) {
|
|
60
|
-
const { init } = node;
|
|
61
|
-
if (init.type === types.AST_NODE_TYPES.MemberExpression && init.object.type === types.AST_NODE_TYPES.Identifier) {
|
|
62
|
-
return isInitializedFromReact(init.object.name, importSource, initialScope);
|
|
63
|
-
}
|
|
64
|
-
if (init.type === types.AST_NODE_TYPES.Identifier) {
|
|
65
|
-
return isInitializedFromReact(init.name, importSource, initialScope);
|
|
66
|
-
}
|
|
67
|
-
const args = getRequireExpressionArguments(init);
|
|
68
|
-
const arg0 = args?.[0];
|
|
69
|
-
if (arg0 == null || !AST9__namespace.isLiteral(arg0, "string")) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
return arg0.value === importSource || arg0.value.startsWith(`${importSource}/`);
|
|
73
|
-
}
|
|
74
|
-
return parent?.type === types.AST_NODE_TYPES.ImportDeclaration && parent.source.value === importSource;
|
|
75
|
-
}
|
|
76
|
-
function isInstanceIdEqual(context, a, b) {
|
|
77
|
-
return AST9__namespace.isNodeEqual(a, b) || VAR3__namespace.isNodeValueEqual(a, b, [
|
|
78
|
-
context.sourceCode.getScope(a),
|
|
79
|
-
context.sourceCode.getScope(b)
|
|
80
|
-
]);
|
|
81
|
-
}
|
|
10
|
+
// src/component/component-children.ts
|
|
82
11
|
function isReactAPI(api) {
|
|
83
12
|
const func = (context, node) => {
|
|
84
13
|
if (node == null) return false;
|
|
85
14
|
const getText = (n) => context.sourceCode.getText(n);
|
|
86
|
-
const name =
|
|
15
|
+
const name = AST14.toStringFormat(node, getText);
|
|
87
16
|
if (name === api) return true;
|
|
88
17
|
if (name.substring(name.indexOf(".") + 1) === api) return true;
|
|
89
18
|
return false;
|
|
90
19
|
};
|
|
91
|
-
return
|
|
20
|
+
return dual(2, func);
|
|
92
21
|
}
|
|
93
22
|
function isReactAPICall(api) {
|
|
94
23
|
const func = (context, node) => {
|
|
95
24
|
if (node == null) return false;
|
|
96
|
-
if (node.type !==
|
|
25
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
97
26
|
return isReactAPI(api)(context, node.callee);
|
|
98
27
|
};
|
|
99
|
-
return
|
|
28
|
+
return dual(2, func);
|
|
100
29
|
}
|
|
101
30
|
var isCaptureOwnerStack = isReactAPI("captureOwnerStack");
|
|
102
31
|
var isChildrenCount = isReactAPI("Children.count");
|
|
@@ -125,6 +54,59 @@ var isForwardRefCall = isReactAPICall("forwardRef");
|
|
|
125
54
|
var isMemoCall = isReactAPICall("memo");
|
|
126
55
|
var isLazyCall = isReactAPICall("lazy");
|
|
127
56
|
|
|
57
|
+
// src/component/component-children.ts
|
|
58
|
+
function isChildrenOfCreateElement(context, node) {
|
|
59
|
+
const parent = node.parent;
|
|
60
|
+
if (parent == null || parent.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
61
|
+
if (!isCreateElementCall(context, parent)) return false;
|
|
62
|
+
return parent.arguments.slice(2).some((arg) => arg === node);
|
|
63
|
+
}
|
|
64
|
+
function getInstanceId(node, prev) {
|
|
65
|
+
switch (true) {
|
|
66
|
+
case (node.type === AST_NODE_TYPES.VariableDeclarator && node.init === prev):
|
|
67
|
+
return node.id;
|
|
68
|
+
case (node.type === AST_NODE_TYPES.AssignmentExpression && node.right === prev):
|
|
69
|
+
return node.left;
|
|
70
|
+
case (node.type === AST_NODE_TYPES.PropertyDefinition && node.value === prev):
|
|
71
|
+
return node.key;
|
|
72
|
+
case (node.type === AST_NODE_TYPES.BlockStatement || node.type === AST_NODE_TYPES.Program || node.parent === node):
|
|
73
|
+
return _;
|
|
74
|
+
default:
|
|
75
|
+
return getInstanceId(node.parent, node);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function getRequireExpressionArguments(node) {
|
|
79
|
+
return match(node).with({ type: AST_NODE_TYPES.CallExpression, arguments: P.select(), callee: { type: AST_NODE_TYPES.Identifier, name: "require" } }, identity).with({ type: AST_NODE_TYPES.MemberExpression, object: P.select() }, getRequireExpressionArguments).otherwise(() => null);
|
|
80
|
+
}
|
|
81
|
+
function isInitializedFromReact(name, importSource, initialScope) {
|
|
82
|
+
if (name.toLowerCase() === "react") return true;
|
|
83
|
+
const latestDef = VAR3.findVariable(name, initialScope)?.defs.at(-1);
|
|
84
|
+
if (latestDef == null) return false;
|
|
85
|
+
const { node, parent } = latestDef;
|
|
86
|
+
if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init != null) {
|
|
87
|
+
const { init } = node;
|
|
88
|
+
if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) {
|
|
89
|
+
return isInitializedFromReact(init.object.name, importSource, initialScope);
|
|
90
|
+
}
|
|
91
|
+
if (init.type === AST_NODE_TYPES.Identifier) {
|
|
92
|
+
return isInitializedFromReact(init.name, importSource, initialScope);
|
|
93
|
+
}
|
|
94
|
+
const args = getRequireExpressionArguments(init);
|
|
95
|
+
const arg0 = args?.[0];
|
|
96
|
+
if (arg0 == null || !AST14.isLiteral(arg0, "string")) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
return arg0.value === importSource || arg0.value.startsWith(`${importSource}/`);
|
|
100
|
+
}
|
|
101
|
+
return parent?.type === AST_NODE_TYPES.ImportDeclaration && parent.source.value === importSource;
|
|
102
|
+
}
|
|
103
|
+
function isInstanceIdEqual(context, a, b) {
|
|
104
|
+
return AST14.isNodeEqual(a, b) || VAR3.isNodeValueEqual(a, b, [
|
|
105
|
+
context.sourceCode.getScope(a),
|
|
106
|
+
context.sourceCode.getScope(b)
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
|
|
128
110
|
// src/hook/hook-name.ts
|
|
129
111
|
function isReactHookName(name) {
|
|
130
112
|
return name === "use" || /^use[A-Z0-9]/.test(name);
|
|
@@ -133,34 +115,34 @@ function isReactHookName(name) {
|
|
|
133
115
|
// src/hook/hook-is.ts
|
|
134
116
|
function isReactHook(node) {
|
|
135
117
|
if (node == null) return false;
|
|
136
|
-
const id =
|
|
118
|
+
const id = AST14.getFunctionId(node);
|
|
137
119
|
return id?.name != null && isReactHookName(id.name);
|
|
138
120
|
}
|
|
139
121
|
function isReactHookCall(node) {
|
|
140
122
|
if (node == null) return false;
|
|
141
|
-
if (node.type !==
|
|
123
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) {
|
|
142
124
|
return false;
|
|
143
125
|
}
|
|
144
|
-
if (node.callee.type ===
|
|
126
|
+
if (node.callee.type === AST_NODE_TYPES.Identifier) {
|
|
145
127
|
return isReactHookName(node.callee.name);
|
|
146
128
|
}
|
|
147
|
-
if (node.callee.type ===
|
|
148
|
-
return node.callee.property.type ===
|
|
129
|
+
if (node.callee.type === AST_NODE_TYPES.MemberExpression) {
|
|
130
|
+
return node.callee.property.type === AST_NODE_TYPES.Identifier && isReactHookName(node.callee.property.name);
|
|
149
131
|
}
|
|
150
132
|
return false;
|
|
151
133
|
}
|
|
152
134
|
function isReactHookCallWithName(context, node) {
|
|
153
|
-
if (node == null || node.type !==
|
|
135
|
+
if (node == null || node.type !== AST_NODE_TYPES.CallExpression) return constFalse;
|
|
154
136
|
const {
|
|
155
|
-
importSource =
|
|
137
|
+
importSource = DEFAULT_ESLINT_REACT_SETTINGS.importSource,
|
|
156
138
|
skipImportCheck = true
|
|
157
|
-
} =
|
|
139
|
+
} = coerceSettings(context.settings);
|
|
158
140
|
const initialScope = context.sourceCode.getScope(node);
|
|
159
141
|
return (name) => {
|
|
160
142
|
switch (true) {
|
|
161
|
-
case (node.callee.type ===
|
|
143
|
+
case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === name):
|
|
162
144
|
return skipImportCheck || isInitializedFromReact(name, importSource, initialScope);
|
|
163
|
-
case (node.callee.type ===
|
|
145
|
+
case (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
|
|
164
146
|
return skipImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
|
|
165
147
|
default:
|
|
166
148
|
return false;
|
|
@@ -168,13 +150,13 @@ function isReactHookCallWithName(context, node) {
|
|
|
168
150
|
};
|
|
169
151
|
}
|
|
170
152
|
function isReactHookCallWithNameLoose(node) {
|
|
171
|
-
if (node == null || node.type !==
|
|
153
|
+
if (node == null || node.type !== AST_NODE_TYPES.CallExpression) return constFalse;
|
|
172
154
|
return (name) => {
|
|
173
155
|
switch (node.callee.type) {
|
|
174
|
-
case
|
|
156
|
+
case AST_NODE_TYPES.Identifier:
|
|
175
157
|
return node.callee.name === name;
|
|
176
|
-
case
|
|
177
|
-
return node.callee.property.type ===
|
|
158
|
+
case AST_NODE_TYPES.MemberExpression:
|
|
159
|
+
return node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === name;
|
|
178
160
|
default:
|
|
179
161
|
return false;
|
|
180
162
|
}
|
|
@@ -182,15 +164,15 @@ function isReactHookCallWithNameLoose(node) {
|
|
|
182
164
|
}
|
|
183
165
|
function isReactHookCallWithNameAlias(context, name, alias = []) {
|
|
184
166
|
const {
|
|
185
|
-
importSource =
|
|
167
|
+
importSource = DEFAULT_ESLINT_REACT_SETTINGS.importSource,
|
|
186
168
|
skipImportCheck = true
|
|
187
|
-
} =
|
|
169
|
+
} = coerceSettings(context.settings);
|
|
188
170
|
return (node) => {
|
|
189
171
|
const initialScope = context.sourceCode.getScope(node);
|
|
190
172
|
switch (true) {
|
|
191
|
-
case (node.callee.type ===
|
|
173
|
+
case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === name):
|
|
192
174
|
return skipImportCheck || isInitializedFromReact(name, importSource, initialScope);
|
|
193
|
-
case (node.callee.type ===
|
|
175
|
+
case (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
|
|
194
176
|
return skipImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
|
|
195
177
|
default:
|
|
196
178
|
return alias.some(isReactHookCallWithNameLoose(node));
|
|
@@ -199,45 +181,45 @@ function isReactHookCallWithNameAlias(context, name, alias = []) {
|
|
|
199
181
|
}
|
|
200
182
|
function isUseEffectCallLoose(node) {
|
|
201
183
|
if (node == null) return false;
|
|
202
|
-
if (node.type !==
|
|
184
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) {
|
|
203
185
|
return false;
|
|
204
186
|
}
|
|
205
187
|
switch (node.callee.type) {
|
|
206
|
-
case
|
|
188
|
+
case AST_NODE_TYPES.Identifier:
|
|
207
189
|
return /^use\w*Effect$/u.test(node.callee.name);
|
|
208
|
-
case
|
|
209
|
-
return node.callee.property.type ===
|
|
190
|
+
case AST_NODE_TYPES.MemberExpression:
|
|
191
|
+
return node.callee.property.type === AST_NODE_TYPES.Identifier && /^use\w*Effect$/u.test(node.callee.property.name);
|
|
210
192
|
default:
|
|
211
193
|
return false;
|
|
212
194
|
}
|
|
213
195
|
}
|
|
214
|
-
var isUseCall =
|
|
215
|
-
var isUseActionStateCall =
|
|
216
|
-
var isUseCallbackCall =
|
|
217
|
-
var isUseContextCall =
|
|
218
|
-
var isUseDebugValueCall =
|
|
219
|
-
var isUseDeferredValueCall =
|
|
220
|
-
var isUseEffectCall =
|
|
221
|
-
var isUseFormStatusCall =
|
|
222
|
-
var isUseIdCall =
|
|
223
|
-
var isUseImperativeHandleCall =
|
|
224
|
-
var isUseInsertionEffectCall =
|
|
225
|
-
var isUseLayoutEffectCall =
|
|
226
|
-
var isUseMemoCall =
|
|
227
|
-
var isUseOptimisticCall =
|
|
228
|
-
var isUseReducerCall =
|
|
229
|
-
var isUseRefCall =
|
|
230
|
-
var isUseStateCall =
|
|
231
|
-
var isUseSyncExternalStoreCall =
|
|
232
|
-
var isUseTransitionCall =
|
|
196
|
+
var isUseCall = flip(isReactHookCallWithName)("use");
|
|
197
|
+
var isUseActionStateCall = flip(isReactHookCallWithName)("useActionState");
|
|
198
|
+
var isUseCallbackCall = flip(isReactHookCallWithName)("useCallback");
|
|
199
|
+
var isUseContextCall = flip(isReactHookCallWithName)("useContext");
|
|
200
|
+
var isUseDebugValueCall = flip(isReactHookCallWithName)("useDebugValue");
|
|
201
|
+
var isUseDeferredValueCall = flip(isReactHookCallWithName)("useDeferredValue");
|
|
202
|
+
var isUseEffectCall = flip(isReactHookCallWithName)("useEffect");
|
|
203
|
+
var isUseFormStatusCall = flip(isReactHookCallWithName)("useFormStatus");
|
|
204
|
+
var isUseIdCall = flip(isReactHookCallWithName)("useId");
|
|
205
|
+
var isUseImperativeHandleCall = flip(isReactHookCallWithName)("useImperativeHandle");
|
|
206
|
+
var isUseInsertionEffectCall = flip(isReactHookCallWithName)("useInsertionEffect");
|
|
207
|
+
var isUseLayoutEffectCall = flip(isReactHookCallWithName)("useLayoutEffect");
|
|
208
|
+
var isUseMemoCall = flip(isReactHookCallWithName)("useMemo");
|
|
209
|
+
var isUseOptimisticCall = flip(isReactHookCallWithName)("useOptimistic");
|
|
210
|
+
var isUseReducerCall = flip(isReactHookCallWithName)("useReducer");
|
|
211
|
+
var isUseRefCall = flip(isReactHookCallWithName)("useRef");
|
|
212
|
+
var isUseStateCall = flip(isReactHookCallWithName)("useState");
|
|
213
|
+
var isUseSyncExternalStoreCall = flip(isReactHookCallWithName)("useSyncExternalStore");
|
|
214
|
+
var isUseTransitionCall = flip(isReactHookCallWithName)("useTransition");
|
|
233
215
|
|
|
234
216
|
// src/hook/hook-collector.ts
|
|
235
217
|
function useHookCollector() {
|
|
236
218
|
const hooks = /* @__PURE__ */ new Map();
|
|
237
219
|
const functionEntries = [];
|
|
238
220
|
const onFunctionEnter = (node) => {
|
|
239
|
-
const id =
|
|
240
|
-
const key =
|
|
221
|
+
const id = AST14.getFunctionId(node);
|
|
222
|
+
const key = getId();
|
|
241
223
|
const name = id?.name;
|
|
242
224
|
if (name != null && isReactHookName(name)) {
|
|
243
225
|
functionEntries.push({ key, node, isHook: true });
|
|
@@ -284,35 +266,33 @@ function useHookCollector() {
|
|
|
284
266
|
};
|
|
285
267
|
return { ctx, listeners };
|
|
286
268
|
}
|
|
287
|
-
function
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (pFunction !== pFunctionOfReturn) return false;
|
|
297
|
-
return isFunctionOfUseEffectSetup(pFunction);
|
|
269
|
+
function isReactHookId(id) {
|
|
270
|
+
switch (id.type) {
|
|
271
|
+
case AST_NODE_TYPES.Identifier:
|
|
272
|
+
return isReactHookName(id.name);
|
|
273
|
+
case AST_NODE_TYPES.MemberExpression:
|
|
274
|
+
return "name" in id.property && isReactHookName(id.property.name);
|
|
275
|
+
default:
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
298
278
|
}
|
|
299
279
|
function stringifyJsx(node) {
|
|
300
280
|
switch (node.type) {
|
|
301
|
-
case
|
|
281
|
+
case AST_NODE_TYPES.JSXIdentifier:
|
|
302
282
|
return node.name;
|
|
303
|
-
case
|
|
283
|
+
case AST_NODE_TYPES.JSXNamespacedName:
|
|
304
284
|
return `${node.namespace.name}:${node.name.name}`;
|
|
305
|
-
case
|
|
285
|
+
case AST_NODE_TYPES.JSXMemberExpression:
|
|
306
286
|
return `${stringifyJsx(node.object)}.${stringifyJsx(node.property)}`;
|
|
307
|
-
case
|
|
287
|
+
case AST_NODE_TYPES.JSXText:
|
|
308
288
|
return node.value;
|
|
309
|
-
case
|
|
289
|
+
case AST_NODE_TYPES.JSXOpeningElement:
|
|
310
290
|
return `<${stringifyJsx(node.name)}>`;
|
|
311
|
-
case
|
|
291
|
+
case AST_NODE_TYPES.JSXClosingElement:
|
|
312
292
|
return `</${stringifyJsx(node.name)}>`;
|
|
313
|
-
case
|
|
293
|
+
case AST_NODE_TYPES.JSXOpeningFragment:
|
|
314
294
|
return "<>";
|
|
315
|
-
case
|
|
295
|
+
case AST_NODE_TYPES.JSXClosingFragment:
|
|
316
296
|
return "</>";
|
|
317
297
|
}
|
|
318
298
|
}
|
|
@@ -325,21 +305,21 @@ function getAttributeName(context, node) {
|
|
|
325
305
|
// src/jsx/jsx-attribute.ts
|
|
326
306
|
function getAttribute(context, name, attributes, initialScope) {
|
|
327
307
|
return attributes.findLast((attr) => {
|
|
328
|
-
if (attr.type ===
|
|
308
|
+
if (attr.type === AST_NODE_TYPES.JSXAttribute) {
|
|
329
309
|
return getAttributeName(context, attr) === name;
|
|
330
310
|
}
|
|
331
311
|
if (initialScope == null) return false;
|
|
332
312
|
switch (attr.argument.type) {
|
|
333
|
-
case
|
|
334
|
-
const variable =
|
|
335
|
-
const variableNode =
|
|
336
|
-
if (variableNode?.type ===
|
|
337
|
-
return
|
|
313
|
+
case AST_NODE_TYPES.Identifier: {
|
|
314
|
+
const variable = VAR3.findVariable(attr.argument.name, initialScope);
|
|
315
|
+
const variableNode = VAR3.getVariableInitNode(variable, 0);
|
|
316
|
+
if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) {
|
|
317
|
+
return VAR3.findPropertyInProperties(name, variableNode.properties, initialScope) != null;
|
|
338
318
|
}
|
|
339
319
|
return false;
|
|
340
320
|
}
|
|
341
|
-
case
|
|
342
|
-
return
|
|
321
|
+
case AST_NODE_TYPES.ObjectExpression:
|
|
322
|
+
return VAR3.findPropertyInProperties(name, attr.argument.properties, initialScope) != null;
|
|
343
323
|
}
|
|
344
324
|
return false;
|
|
345
325
|
});
|
|
@@ -347,8 +327,8 @@ function getAttribute(context, name, attributes, initialScope) {
|
|
|
347
327
|
function getAttributeValue(context, node, name) {
|
|
348
328
|
const initialScope = context.sourceCode.getScope(node);
|
|
349
329
|
switch (node.type) {
|
|
350
|
-
case
|
|
351
|
-
if (node.value?.type ===
|
|
330
|
+
case AST_NODE_TYPES.JSXAttribute:
|
|
331
|
+
if (node.value?.type === AST_NODE_TYPES.Literal) {
|
|
352
332
|
return {
|
|
353
333
|
kind: "some",
|
|
354
334
|
node: node.value,
|
|
@@ -356,16 +336,16 @@ function getAttributeValue(context, node, name) {
|
|
|
356
336
|
value: node.value.value
|
|
357
337
|
};
|
|
358
338
|
}
|
|
359
|
-
if (node.value?.type ===
|
|
360
|
-
return
|
|
339
|
+
if (node.value?.type === AST_NODE_TYPES.JSXExpressionContainer) {
|
|
340
|
+
return VAR3.toStaticValue({
|
|
361
341
|
kind: "lazy",
|
|
362
342
|
node: node.value.expression,
|
|
363
343
|
initialScope
|
|
364
344
|
});
|
|
365
345
|
}
|
|
366
346
|
return { kind: "none", node, initialScope };
|
|
367
|
-
case
|
|
368
|
-
const staticValue =
|
|
347
|
+
case AST_NODE_TYPES.JSXSpreadAttribute: {
|
|
348
|
+
const staticValue = VAR3.toStaticValue({
|
|
369
349
|
kind: "lazy",
|
|
370
350
|
node: node.argument,
|
|
371
351
|
initialScope
|
|
@@ -373,7 +353,7 @@ function getAttributeValue(context, node, name) {
|
|
|
373
353
|
if (staticValue.kind === "none") {
|
|
374
354
|
return staticValue;
|
|
375
355
|
}
|
|
376
|
-
return
|
|
356
|
+
return match(staticValue.value).with({ [name]: P.select(P.any) }, (value) => ({
|
|
377
357
|
kind: "some",
|
|
378
358
|
node: node.argument,
|
|
379
359
|
initialScope,
|
|
@@ -405,13 +385,13 @@ var DEFAULT_JSX_DETECTION_HINT = 0n | JSXDetectionHint.SkipUndefined | JSXDetect
|
|
|
405
385
|
// src/jsx/jsx-detection.ts
|
|
406
386
|
function isJsxText(node) {
|
|
407
387
|
if (node == null) return false;
|
|
408
|
-
return node.type ===
|
|
388
|
+
return node.type === AST_NODE_TYPES.JSXText || node.type === AST_NODE_TYPES.Literal;
|
|
409
389
|
}
|
|
410
390
|
function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
411
391
|
if (node == null) return false;
|
|
412
|
-
if (
|
|
392
|
+
if (AST14.isJSX(node)) return true;
|
|
413
393
|
switch (node.type) {
|
|
414
|
-
case
|
|
394
|
+
case AST_NODE_TYPES.Literal: {
|
|
415
395
|
switch (typeof node.value) {
|
|
416
396
|
case "boolean":
|
|
417
397
|
return !(hint & JSXDetectionHint.SkipBooleanLiteral);
|
|
@@ -427,22 +407,22 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
427
407
|
}
|
|
428
408
|
return false;
|
|
429
409
|
}
|
|
430
|
-
case
|
|
410
|
+
case AST_NODE_TYPES.TemplateLiteral: {
|
|
431
411
|
return !(hint & JSXDetectionHint.SkipStringLiteral);
|
|
432
412
|
}
|
|
433
|
-
case
|
|
413
|
+
case AST_NODE_TYPES.ArrayExpression: {
|
|
434
414
|
if (hint & JSXDetectionHint.StrictArray) {
|
|
435
415
|
return node.elements.every((n) => isJsxLike(code, n, hint));
|
|
436
416
|
}
|
|
437
417
|
return node.elements.some((n) => isJsxLike(code, n, hint));
|
|
438
418
|
}
|
|
439
|
-
case
|
|
419
|
+
case AST_NODE_TYPES.LogicalExpression: {
|
|
440
420
|
if (hint & JSXDetectionHint.StrictLogical) {
|
|
441
421
|
return isJsxLike(code, node.left, hint) && isJsxLike(code, node.right, hint);
|
|
442
422
|
}
|
|
443
423
|
return isJsxLike(code, node.left, hint) || isJsxLike(code, node.right, hint);
|
|
444
424
|
}
|
|
445
|
-
case
|
|
425
|
+
case AST_NODE_TYPES.ConditionalExpression: {
|
|
446
426
|
let leftHasJSX2 = function(node2) {
|
|
447
427
|
if (Array.isArray(node2.consequent)) {
|
|
448
428
|
if (node2.consequent.length === 0) {
|
|
@@ -462,39 +442,39 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
462
442
|
}
|
|
463
443
|
return leftHasJSX2(node) || rightHasJSX2(node);
|
|
464
444
|
}
|
|
465
|
-
case
|
|
445
|
+
case AST_NODE_TYPES.SequenceExpression: {
|
|
466
446
|
const exp = node.expressions.at(-1);
|
|
467
447
|
return isJsxLike(code, exp, hint);
|
|
468
448
|
}
|
|
469
|
-
case
|
|
449
|
+
case AST_NODE_TYPES.CallExpression: {
|
|
470
450
|
if (hint & JSXDetectionHint.SkipCreateElement) {
|
|
471
451
|
return false;
|
|
472
452
|
}
|
|
473
453
|
switch (node.callee.type) {
|
|
474
|
-
case
|
|
454
|
+
case AST_NODE_TYPES.Identifier:
|
|
475
455
|
return node.callee.name === "createElement";
|
|
476
|
-
case
|
|
477
|
-
return node.callee.property.type ===
|
|
456
|
+
case AST_NODE_TYPES.MemberExpression:
|
|
457
|
+
return node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "createElement";
|
|
478
458
|
}
|
|
479
459
|
return false;
|
|
480
460
|
}
|
|
481
|
-
case
|
|
461
|
+
case AST_NODE_TYPES.Identifier: {
|
|
482
462
|
const { name } = node;
|
|
483
463
|
if (name === "undefined") {
|
|
484
464
|
return !(hint & JSXDetectionHint.SkipUndefined);
|
|
485
465
|
}
|
|
486
|
-
if (
|
|
466
|
+
if (AST14.isJSXTagNameExpression(node)) {
|
|
487
467
|
return true;
|
|
488
468
|
}
|
|
489
|
-
const variable =
|
|
490
|
-
const variableNode = variable &&
|
|
469
|
+
const variable = VAR3.findVariable(name, code.getScope(node));
|
|
470
|
+
const variableNode = variable && VAR3.getVariableInitNode(variable, 0);
|
|
491
471
|
return !!variableNode && isJsxLike(code, variableNode, hint);
|
|
492
472
|
}
|
|
493
473
|
}
|
|
494
474
|
return false;
|
|
495
475
|
}
|
|
496
476
|
function getElementType(context, node) {
|
|
497
|
-
if (node.type ===
|
|
477
|
+
if (node.type === AST_NODE_TYPES.JSXFragment) {
|
|
498
478
|
return "";
|
|
499
479
|
}
|
|
500
480
|
return stringifyJsx(node.openingElement.name);
|
|
@@ -510,22 +490,22 @@ function hasAnyAttribute(context, names, attributes, initialScope) {
|
|
|
510
490
|
function hasEveryAttribute(context, names, attributes, initialScope) {
|
|
511
491
|
return names.every((n) => hasAttribute(context, n, attributes, initialScope));
|
|
512
492
|
}
|
|
513
|
-
function findParentAttribute(node, test =
|
|
493
|
+
function findParentAttribute(node, test = constTrue) {
|
|
514
494
|
const guard = (node2) => {
|
|
515
|
-
return node2.type ===
|
|
495
|
+
return node2.type === AST_NODE_TYPES.JSXAttribute && test(node2);
|
|
516
496
|
};
|
|
517
|
-
return
|
|
497
|
+
return AST14.findParentNode(node, guard);
|
|
518
498
|
}
|
|
519
499
|
function isHostElement(context, node) {
|
|
520
|
-
return node.type ===
|
|
500
|
+
return node.type === AST_NODE_TYPES.JSXElement && node.openingElement.name.type === AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.openingElement.name.name);
|
|
521
501
|
}
|
|
522
502
|
function isKeyedElement(context, node, initialScope) {
|
|
523
|
-
return node.type ===
|
|
503
|
+
return node.type === AST_NODE_TYPES.JSXElement && hasAttribute(context, "key", node.openingElement.attributes, initialScope);
|
|
524
504
|
}
|
|
525
505
|
function isFragmentElement(context, node, allowJSXFragment = false) {
|
|
526
506
|
if (node == null) return false;
|
|
527
|
-
if (node.type !==
|
|
528
|
-
if (node.type ===
|
|
507
|
+
if (node.type !== AST_NODE_TYPES.JSXElement && node.type !== AST_NODE_TYPES.JSXFragment) return false;
|
|
508
|
+
if (node.type === AST_NODE_TYPES.JSXFragment) return allowJSXFragment;
|
|
529
509
|
return getElementType(context, node).split(".").at(-1) === "Fragment";
|
|
530
510
|
}
|
|
531
511
|
|
|
@@ -565,9 +545,9 @@ function isClassComponent(node) {
|
|
|
565
545
|
if ("superClass" in node && node.superClass != null) {
|
|
566
546
|
const re = /^(?:Pure)?Component$/u;
|
|
567
547
|
switch (true) {
|
|
568
|
-
case node.superClass.type ===
|
|
548
|
+
case node.superClass.type === AST_NODE_TYPES.Identifier:
|
|
569
549
|
return re.test(node.superClass.name);
|
|
570
|
-
case (node.superClass.type ===
|
|
550
|
+
case (node.superClass.type === AST_NODE_TYPES.MemberExpression && node.superClass.property.type === AST_NODE_TYPES.Identifier):
|
|
571
551
|
return re.test(node.superClass.property.name);
|
|
572
552
|
}
|
|
573
553
|
}
|
|
@@ -577,119 +557,42 @@ function isPureComponent(node) {
|
|
|
577
557
|
if ("superClass" in node && node.superClass != null) {
|
|
578
558
|
const re = /^PureComponent$/u;
|
|
579
559
|
switch (true) {
|
|
580
|
-
case node.superClass.type ===
|
|
560
|
+
case node.superClass.type === AST_NODE_TYPES.Identifier:
|
|
581
561
|
return re.test(node.superClass.name);
|
|
582
|
-
case (node.superClass.type ===
|
|
562
|
+
case (node.superClass.type === AST_NODE_TYPES.MemberExpression && node.superClass.property.type === AST_NODE_TYPES.Identifier):
|
|
583
563
|
return re.test(node.superClass.property.name);
|
|
584
564
|
}
|
|
585
565
|
}
|
|
586
566
|
return false;
|
|
587
567
|
}
|
|
588
|
-
function isComponentDidCatch(node) {
|
|
589
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
|
|
590
|
-
}
|
|
591
|
-
function isComponentDidMount(node) {
|
|
592
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
593
|
-
}
|
|
594
|
-
function isComponentDidUpdate(node) {
|
|
595
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
596
|
-
}
|
|
597
|
-
function isComponentWillMount(node) {
|
|
598
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillMount";
|
|
599
|
-
}
|
|
600
|
-
function isComponentWillReceiveProps(node) {
|
|
601
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillReceiveProps";
|
|
602
|
-
}
|
|
603
|
-
function isComponentWillUnmount(node) {
|
|
604
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
|
|
605
|
-
}
|
|
606
|
-
function isComponentWillUpdate(node) {
|
|
607
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
608
|
-
}
|
|
609
|
-
function isGetChildContext(node) {
|
|
610
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getChildContext";
|
|
611
|
-
}
|
|
612
|
-
function isGetDefaultProps(node) {
|
|
613
|
-
return AST9__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDefaultProps";
|
|
614
|
-
}
|
|
615
|
-
function isGetInitialState(node) {
|
|
616
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getInitialState";
|
|
617
|
-
}
|
|
618
|
-
function isGetSnapshotBeforeUpdate(node) {
|
|
619
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getSnapshotBeforeUpdate";
|
|
620
|
-
}
|
|
621
|
-
function isShouldComponentUpdate(node) {
|
|
622
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
623
|
-
}
|
|
624
|
-
function isUnsafeComponentWillMount(node) {
|
|
625
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
626
|
-
}
|
|
627
|
-
function isUnsafeComponentWillReceiveProps(node) {
|
|
628
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
629
|
-
}
|
|
630
|
-
function isUnsafeComponentWillUpdate(node) {
|
|
631
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
632
|
-
}
|
|
633
|
-
function isGetDerivedStateFromProps(node) {
|
|
634
|
-
return AST9__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
|
|
635
|
-
}
|
|
636
|
-
function isGetDerivedStateFromError(node) {
|
|
637
|
-
return AST9__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
|
|
638
|
-
}
|
|
639
|
-
function isRenderLike(node) {
|
|
640
|
-
return AST9__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration;
|
|
641
|
-
}
|
|
642
|
-
function isFunctionOfRender(node) {
|
|
643
|
-
if (!isRenderLike(node.parent)) {
|
|
644
|
-
return false;
|
|
645
|
-
}
|
|
646
|
-
return isClassComponent(node.parent.parent.parent);
|
|
647
|
-
}
|
|
648
568
|
function isRenderMethodLike(node) {
|
|
649
|
-
return
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
// src/component/component-hierarchy.ts
|
|
653
|
-
function isChildrenOfCreateElement(context, node) {
|
|
654
|
-
const parent = node.parent;
|
|
655
|
-
if (parent == null || parent.type !== types.AST_NODE_TYPES.CallExpression) return false;
|
|
656
|
-
if (!isCreateElementCall(context, parent)) return false;
|
|
657
|
-
return parent.arguments.slice(2).some((arg) => arg === node);
|
|
658
|
-
}
|
|
659
|
-
function isInsideRenderMethod(node) {
|
|
660
|
-
return AST9__namespace.findParentNode(node, (n) => isRenderLike(n) && isClassComponent(n.parent.parent)) != null;
|
|
661
|
-
}
|
|
662
|
-
function isFunctionOfComponentDidMount(node) {
|
|
663
|
-
return AST9__namespace.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
|
|
664
|
-
}
|
|
665
|
-
function isFunctionOfComponentWillUnmount(node) {
|
|
666
|
-
return AST9__namespace.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
|
|
667
|
-
}
|
|
668
|
-
function isFunctionOfRenderMethod(node) {
|
|
669
|
-
if (!isRenderMethodLike(node.parent)) {
|
|
670
|
-
return false;
|
|
671
|
-
}
|
|
672
|
-
return isClassComponent(node.parent.parent.parent);
|
|
569
|
+
return AST14.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name.startsWith("render") && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
|
|
673
570
|
}
|
|
674
571
|
|
|
675
572
|
// src/component/component-definition.ts
|
|
676
|
-
var isFunctionOfClassMethod =
|
|
677
|
-
type:
|
|
678
|
-
parent:
|
|
573
|
+
var isFunctionOfClassMethod = isMatching({
|
|
574
|
+
type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
|
|
575
|
+
parent: AST_NODE_TYPES.MethodDefinition
|
|
679
576
|
});
|
|
680
|
-
var isFunctionOfClassProperty =
|
|
681
|
-
type:
|
|
682
|
-
parent:
|
|
577
|
+
var isFunctionOfClassProperty = isMatching({
|
|
578
|
+
type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
|
|
579
|
+
parent: AST_NODE_TYPES.Property
|
|
683
580
|
});
|
|
684
|
-
var isFunctionOfObjectMethod =
|
|
685
|
-
type:
|
|
581
|
+
var isFunctionOfObjectMethod = isMatching({
|
|
582
|
+
type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
|
|
686
583
|
parent: {
|
|
687
|
-
type:
|
|
584
|
+
type: AST_NODE_TYPES.Property,
|
|
688
585
|
parent: {
|
|
689
|
-
type:
|
|
586
|
+
type: AST_NODE_TYPES.ObjectExpression
|
|
690
587
|
}
|
|
691
588
|
}
|
|
692
589
|
});
|
|
590
|
+
function isFunctionOfRenderMethod(node) {
|
|
591
|
+
if (!isRenderMethodLike(node.parent)) {
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
return isClassComponent(node.parent.parent.parent);
|
|
595
|
+
}
|
|
693
596
|
function isValidComponentDefinition(context, node, hint) {
|
|
694
597
|
if (isChildrenOfCreateElement(context, node) || isFunctionOfRenderMethod(node)) {
|
|
695
598
|
return false;
|
|
@@ -703,44 +606,44 @@ function isValidComponentDefinition(context, node, hint) {
|
|
|
703
606
|
if (hint & ComponentDetectionHint.SkipClassProperty && isFunctionOfClassProperty(node.parent)) {
|
|
704
607
|
return false;
|
|
705
608
|
}
|
|
706
|
-
if (hint & ComponentDetectionHint.SkipArrayMapArgument &&
|
|
609
|
+
if (hint & ComponentDetectionHint.SkipArrayMapArgument && AST14.isArrayMapCall(node.parent)) {
|
|
707
610
|
return false;
|
|
708
611
|
}
|
|
709
|
-
const significantParent =
|
|
612
|
+
const significantParent = AST14.findParentNode(
|
|
710
613
|
node,
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
614
|
+
AST14.isOneOf([
|
|
615
|
+
AST_NODE_TYPES.JSXExpressionContainer,
|
|
616
|
+
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
617
|
+
AST_NODE_TYPES.FunctionExpression,
|
|
618
|
+
AST_NODE_TYPES.Property,
|
|
619
|
+
AST_NODE_TYPES.ClassBody
|
|
717
620
|
])
|
|
718
621
|
);
|
|
719
|
-
return significantParent == null || significantParent.type !==
|
|
622
|
+
return significantParent == null || significantParent.type !== AST_NODE_TYPES.JSXExpressionContainer;
|
|
720
623
|
}
|
|
721
624
|
function isComponentWrapperCall(context, node) {
|
|
722
|
-
if (node.type !==
|
|
625
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
723
626
|
return isMemoCall(context, node) || isForwardRefCall(context, node);
|
|
724
627
|
}
|
|
725
628
|
function isComponentWrapperCallLoose(context, node) {
|
|
726
|
-
if (node.type !==
|
|
629
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
727
630
|
return isComponentWrapperCall(context, node) || isUseCallbackCall(context, node);
|
|
728
631
|
}
|
|
729
632
|
|
|
730
633
|
// src/component/component-id.ts
|
|
731
634
|
function getFunctionComponentId(context, node) {
|
|
732
|
-
const functionId =
|
|
635
|
+
const functionId = AST14.getFunctionId(node);
|
|
733
636
|
if (functionId != null) {
|
|
734
637
|
return functionId;
|
|
735
638
|
}
|
|
736
639
|
const { parent } = node;
|
|
737
|
-
if (parent.type ===
|
|
640
|
+
if (parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent) && parent.parent.type === AST_NODE_TYPES.VariableDeclarator && parent.parent.id.type === AST_NODE_TYPES.Identifier) {
|
|
738
641
|
return parent.parent.id;
|
|
739
642
|
}
|
|
740
|
-
if (parent.type ===
|
|
643
|
+
if (parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent) && parent.parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent.parent) && parent.parent.parent.type === AST_NODE_TYPES.VariableDeclarator && parent.parent.parent.id.type === AST_NODE_TYPES.Identifier) {
|
|
741
644
|
return parent.parent.parent.id;
|
|
742
645
|
}
|
|
743
|
-
return
|
|
646
|
+
return _;
|
|
744
647
|
}
|
|
745
648
|
|
|
746
649
|
// src/component/component-flag.ts
|
|
@@ -756,22 +659,22 @@ var ComponentFlag = {
|
|
|
756
659
|
// src/component/component-init-path.ts
|
|
757
660
|
function getComponentFlagFromInitPath(initPath) {
|
|
758
661
|
let flag = ComponentFlag.None;
|
|
759
|
-
if (initPath != null &&
|
|
662
|
+
if (initPath != null && AST14.hasCallInFunctionInitPath("memo", initPath)) {
|
|
760
663
|
flag |= ComponentFlag.Memo;
|
|
761
664
|
}
|
|
762
|
-
if (initPath != null &&
|
|
665
|
+
if (initPath != null && AST14.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
763
666
|
flag |= ComponentFlag.ForwardRef;
|
|
764
667
|
}
|
|
765
668
|
return flag;
|
|
766
669
|
}
|
|
767
670
|
function isComponentName(name) {
|
|
768
|
-
return
|
|
671
|
+
return RegExp.COMPONENT_NAME.test(name);
|
|
769
672
|
}
|
|
770
673
|
function isComponentNameLoose(name) {
|
|
771
|
-
return
|
|
674
|
+
return RegExp.COMPONENT_NAME_LOOSE.test(name);
|
|
772
675
|
}
|
|
773
676
|
function getComponentNameFromId(id) {
|
|
774
|
-
if (id == null) return
|
|
677
|
+
if (id == null) return _;
|
|
775
678
|
return Array.isArray(id) ? id.map((n) => n.name).join(".") : id.name;
|
|
776
679
|
}
|
|
777
680
|
function hasNoneOrLooseComponentName(context, fn) {
|
|
@@ -792,14 +695,14 @@ function useComponentCollector(context, options = {}) {
|
|
|
792
695
|
const functionEntries = [];
|
|
793
696
|
const getCurrentEntry = () => functionEntries.at(-1);
|
|
794
697
|
const onFunctionEnter = (node) => {
|
|
795
|
-
const key =
|
|
698
|
+
const key = getId();
|
|
796
699
|
functionEntries.push({ key, node, hookCalls: [], isComponent: false });
|
|
797
700
|
};
|
|
798
701
|
const onFunctionExit = () => {
|
|
799
702
|
const entry = functionEntries.at(-1);
|
|
800
703
|
if (entry == null) return;
|
|
801
704
|
if (!entry.isComponent) return functionEntries.pop();
|
|
802
|
-
const shouldDrop =
|
|
705
|
+
const shouldDrop = AST14.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
|
|
803
706
|
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !isJsxLike(context.sourceCode, r.argument, hint);
|
|
804
707
|
});
|
|
805
708
|
if (shouldDrop) {
|
|
@@ -826,17 +729,17 @@ function useComponentCollector(context, options = {}) {
|
|
|
826
729
|
const { body } = entry.node;
|
|
827
730
|
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, body, hint) && isValidComponentDefinition(context, entry.node, hint);
|
|
828
731
|
if (!isComponent) return;
|
|
829
|
-
const initPath =
|
|
732
|
+
const initPath = AST14.getFunctionInitPath(entry.node);
|
|
830
733
|
const id = getFunctionComponentId(context, entry.node);
|
|
831
734
|
const name = getComponentNameFromId(id);
|
|
832
|
-
const key =
|
|
735
|
+
const key = getId();
|
|
833
736
|
components.set(key, {
|
|
834
737
|
id,
|
|
835
738
|
key,
|
|
836
739
|
kind: "function",
|
|
837
740
|
name,
|
|
838
741
|
node: entry.node,
|
|
839
|
-
displayName:
|
|
742
|
+
displayName: _,
|
|
840
743
|
flag: getComponentFlagFromInitPath(initPath),
|
|
841
744
|
hint,
|
|
842
745
|
hookCalls: entry.hookCalls,
|
|
@@ -844,10 +747,10 @@ function useComponentCollector(context, options = {}) {
|
|
|
844
747
|
});
|
|
845
748
|
},
|
|
846
749
|
...collectDisplayName ? {
|
|
847
|
-
[
|
|
750
|
+
[Selector.DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
|
|
848
751
|
const { left, right } = node;
|
|
849
|
-
if (left.type !==
|
|
850
|
-
const componentName = left.object.type ===
|
|
752
|
+
if (left.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
753
|
+
const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : _;
|
|
851
754
|
const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
|
|
852
755
|
if (component == null) return;
|
|
853
756
|
component.displayName = right;
|
|
@@ -867,7 +770,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
867
770
|
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, node.argument, hint) && isValidComponentDefinition(context, entry.node, hint);
|
|
868
771
|
if (!isComponent) return;
|
|
869
772
|
entry.isComponent = true;
|
|
870
|
-
const initPath =
|
|
773
|
+
const initPath = AST14.getFunctionInitPath(entry.node);
|
|
871
774
|
const id = getFunctionComponentId(context, entry.node);
|
|
872
775
|
const name = getComponentNameFromId(id);
|
|
873
776
|
components.set(entry.key, {
|
|
@@ -876,7 +779,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
876
779
|
kind: "function",
|
|
877
780
|
name,
|
|
878
781
|
node: entry.node,
|
|
879
|
-
displayName:
|
|
782
|
+
displayName: _,
|
|
880
783
|
flag: getComponentFlagFromInitPath(initPath),
|
|
881
784
|
hint,
|
|
882
785
|
hookCalls: entry.hookCalls,
|
|
@@ -898,8 +801,8 @@ function useComponentCollectorLegacy() {
|
|
|
898
801
|
if (!isClassComponent(node)) {
|
|
899
802
|
return;
|
|
900
803
|
}
|
|
901
|
-
const id =
|
|
902
|
-
const key =
|
|
804
|
+
const id = AST14.getClassId(node);
|
|
805
|
+
const key = getId();
|
|
903
806
|
const flag = isPureComponent(node) ? ComponentFlag.PureComponent : ComponentFlag.None;
|
|
904
807
|
components.set(
|
|
905
808
|
key,
|
|
@@ -910,7 +813,7 @@ function useComponentCollectorLegacy() {
|
|
|
910
813
|
name: id?.name,
|
|
911
814
|
node,
|
|
912
815
|
// TODO: Get displayName of class component
|
|
913
|
-
displayName:
|
|
816
|
+
displayName: _,
|
|
914
817
|
flag,
|
|
915
818
|
hint: 0n,
|
|
916
819
|
// TODO: Get methods of class component
|
|
@@ -924,15 +827,75 @@ function useComponentCollectorLegacy() {
|
|
|
924
827
|
};
|
|
925
828
|
return { ctx, listeners };
|
|
926
829
|
}
|
|
927
|
-
|
|
830
|
+
function isComponentDidCatch(node) {
|
|
831
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
|
|
832
|
+
}
|
|
833
|
+
function isComponentDidMount(node) {
|
|
834
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
835
|
+
}
|
|
836
|
+
function isComponentDidUpdate(node) {
|
|
837
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
838
|
+
}
|
|
839
|
+
function isComponentWillMount(node) {
|
|
840
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillMount";
|
|
841
|
+
}
|
|
842
|
+
function isComponentWillReceiveProps(node) {
|
|
843
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillReceiveProps";
|
|
844
|
+
}
|
|
845
|
+
function isComponentWillUnmount(node) {
|
|
846
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
|
|
847
|
+
}
|
|
848
|
+
function isComponentWillUpdate(node) {
|
|
849
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
850
|
+
}
|
|
851
|
+
function isGetChildContext(node) {
|
|
852
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getChildContext";
|
|
853
|
+
}
|
|
854
|
+
function isGetDefaultProps(node) {
|
|
855
|
+
return AST14.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDefaultProps";
|
|
856
|
+
}
|
|
857
|
+
function isGetInitialState(node) {
|
|
858
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getInitialState";
|
|
859
|
+
}
|
|
860
|
+
function isGetSnapshotBeforeUpdate(node) {
|
|
861
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getSnapshotBeforeUpdate";
|
|
862
|
+
}
|
|
863
|
+
function isShouldComponentUpdate(node) {
|
|
864
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
865
|
+
}
|
|
866
|
+
function isUnsafeComponentWillMount(node) {
|
|
867
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
868
|
+
}
|
|
869
|
+
function isUnsafeComponentWillReceiveProps(node) {
|
|
870
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
871
|
+
}
|
|
872
|
+
function isUnsafeComponentWillUpdate(node) {
|
|
873
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
874
|
+
}
|
|
875
|
+
function isGetDerivedStateFromProps(node) {
|
|
876
|
+
return AST14.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
|
|
877
|
+
}
|
|
878
|
+
function isGetDerivedStateFromError(node) {
|
|
879
|
+
return AST14.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
|
|
880
|
+
}
|
|
881
|
+
var ComponentPhaseRelevance = birecord({
|
|
928
882
|
mount: "unmount",
|
|
929
883
|
setup: "cleanup"
|
|
930
884
|
});
|
|
931
|
-
var isInversePhase =
|
|
885
|
+
var isInversePhase = dual(2, (a, b) => ComponentPhaseRelevance.get(a) === b);
|
|
886
|
+
function isRenderLike(node) {
|
|
887
|
+
return AST14.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
|
|
888
|
+
}
|
|
889
|
+
function isFunctionOfRender(node) {
|
|
890
|
+
if (!isRenderLike(node.parent)) {
|
|
891
|
+
return false;
|
|
892
|
+
}
|
|
893
|
+
return isClassComponent(node.parent.parent.parent);
|
|
894
|
+
}
|
|
932
895
|
function isRenderFunctionLoose(context, node) {
|
|
933
896
|
const { body, parent } = node;
|
|
934
|
-
if (
|
|
935
|
-
return parent.type ===
|
|
897
|
+
if (AST14.getFunctionId(node)?.name.startsWith("render")) {
|
|
898
|
+
return parent.type === AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
|
|
936
899
|
}
|
|
937
900
|
return isJsxLike(
|
|
938
901
|
context.sourceCode,
|
|
@@ -941,14 +904,14 @@ function isRenderFunctionLoose(context, node) {
|
|
|
941
904
|
);
|
|
942
905
|
}
|
|
943
906
|
function isRenderPropLoose(context, node) {
|
|
944
|
-
if (node.name.type !==
|
|
907
|
+
if (node.name.type !== AST_NODE_TYPES.JSXIdentifier) {
|
|
945
908
|
return false;
|
|
946
909
|
}
|
|
947
|
-
return node.name.name.startsWith("render") && node.value?.type ===
|
|
910
|
+
return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && AST14.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression);
|
|
948
911
|
}
|
|
949
912
|
function isDirectValueOfRenderPropertyLoose(node) {
|
|
950
913
|
const matching = (node2) => {
|
|
951
|
-
return node2.type ===
|
|
914
|
+
return node2.type === AST_NODE_TYPES.Property && node2.key.type === AST_NODE_TYPES.Identifier && node2.key.name.startsWith("render");
|
|
952
915
|
};
|
|
953
916
|
return matching(node) || node.parent != null && matching(node.parent);
|
|
954
917
|
}
|
|
@@ -956,143 +919,19 @@ function isDeclaredInRenderPropLoose(node) {
|
|
|
956
919
|
if (isDirectValueOfRenderPropertyLoose(node)) {
|
|
957
920
|
return true;
|
|
958
921
|
}
|
|
959
|
-
const parent =
|
|
960
|
-
if (parent?.type !==
|
|
922
|
+
const parent = AST14.findParentNode(node, AST14.is(AST_NODE_TYPES.JSXExpressionContainer))?.parent;
|
|
923
|
+
if (parent?.type !== AST_NODE_TYPES.JSXAttribute) {
|
|
961
924
|
return false;
|
|
962
925
|
}
|
|
963
|
-
return parent.name.type ===
|
|
926
|
+
return parent.name.type === AST_NODE_TYPES.JSXIdentifier && parent.name.name.startsWith("render");
|
|
964
927
|
}
|
|
965
928
|
function isThisSetState(node) {
|
|
966
929
|
const { callee } = node;
|
|
967
|
-
return callee.type ===
|
|
930
|
+
return callee.type === AST_NODE_TYPES.MemberExpression && AST14.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
|
|
968
931
|
}
|
|
969
932
|
function isAssignmentToThisState(node) {
|
|
970
933
|
const { left } = node;
|
|
971
|
-
return left.type ===
|
|
934
|
+
return left.type === AST_NODE_TYPES.MemberExpression && AST14.isThisExpression(left.object) && AST14.getPropertyName(left.property) === "state";
|
|
972
935
|
}
|
|
973
936
|
|
|
974
|
-
|
|
975
|
-
exports.ComponentFlag = ComponentFlag;
|
|
976
|
-
exports.ComponentPhaseRelevance = ComponentPhaseRelevance;
|
|
977
|
-
exports.DEFAULT_COMPONENT_DETECTION_HINT = DEFAULT_COMPONENT_DETECTION_HINT;
|
|
978
|
-
exports.DEFAULT_JSX_DETECTION_HINT = DEFAULT_JSX_DETECTION_HINT;
|
|
979
|
-
exports.JSXDetectionHint = JSXDetectionHint;
|
|
980
|
-
exports.findParentAttribute = findParentAttribute;
|
|
981
|
-
exports.getAttribute = getAttribute;
|
|
982
|
-
exports.getAttributeName = getAttributeName;
|
|
983
|
-
exports.getAttributeValue = getAttributeValue;
|
|
984
|
-
exports.getComponentFlagFromInitPath = getComponentFlagFromInitPath;
|
|
985
|
-
exports.getComponentNameFromId = getComponentNameFromId;
|
|
986
|
-
exports.getElementType = getElementType;
|
|
987
|
-
exports.getFunctionComponentId = getFunctionComponentId;
|
|
988
|
-
exports.getInstanceId = getInstanceId;
|
|
989
|
-
exports.hasAnyAttribute = hasAnyAttribute;
|
|
990
|
-
exports.hasAttribute = hasAttribute;
|
|
991
|
-
exports.hasEveryAttribute = hasEveryAttribute;
|
|
992
|
-
exports.hasNoneOrLooseComponentName = hasNoneOrLooseComponentName;
|
|
993
|
-
exports.isAssignmentToThisState = isAssignmentToThisState;
|
|
994
|
-
exports.isCaptureOwnerStack = isCaptureOwnerStack;
|
|
995
|
-
exports.isCaptureOwnerStackCall = isCaptureOwnerStackCall;
|
|
996
|
-
exports.isChildrenCount = isChildrenCount;
|
|
997
|
-
exports.isChildrenCountCall = isChildrenCountCall;
|
|
998
|
-
exports.isChildrenForEach = isChildrenForEach;
|
|
999
|
-
exports.isChildrenForEachCall = isChildrenForEachCall;
|
|
1000
|
-
exports.isChildrenMap = isChildrenMap;
|
|
1001
|
-
exports.isChildrenMapCall = isChildrenMapCall;
|
|
1002
|
-
exports.isChildrenOfCreateElement = isChildrenOfCreateElement;
|
|
1003
|
-
exports.isChildrenOnly = isChildrenOnly;
|
|
1004
|
-
exports.isChildrenOnlyCall = isChildrenOnlyCall;
|
|
1005
|
-
exports.isChildrenToArray = isChildrenToArray;
|
|
1006
|
-
exports.isChildrenToArrayCall = isChildrenToArrayCall;
|
|
1007
|
-
exports.isClassComponent = isClassComponent;
|
|
1008
|
-
exports.isCloneElement = isCloneElement;
|
|
1009
|
-
exports.isCloneElementCall = isCloneElementCall;
|
|
1010
|
-
exports.isComponentDidCatch = isComponentDidCatch;
|
|
1011
|
-
exports.isComponentDidMount = isComponentDidMount;
|
|
1012
|
-
exports.isComponentDidUpdate = isComponentDidUpdate;
|
|
1013
|
-
exports.isComponentName = isComponentName;
|
|
1014
|
-
exports.isComponentNameLoose = isComponentNameLoose;
|
|
1015
|
-
exports.isComponentWillMount = isComponentWillMount;
|
|
1016
|
-
exports.isComponentWillReceiveProps = isComponentWillReceiveProps;
|
|
1017
|
-
exports.isComponentWillUnmount = isComponentWillUnmount;
|
|
1018
|
-
exports.isComponentWillUpdate = isComponentWillUpdate;
|
|
1019
|
-
exports.isComponentWrapperCall = isComponentWrapperCall;
|
|
1020
|
-
exports.isComponentWrapperCallLoose = isComponentWrapperCallLoose;
|
|
1021
|
-
exports.isCreateContext = isCreateContext;
|
|
1022
|
-
exports.isCreateContextCall = isCreateContextCall;
|
|
1023
|
-
exports.isCreateElement = isCreateElement;
|
|
1024
|
-
exports.isCreateElementCall = isCreateElementCall;
|
|
1025
|
-
exports.isCreateRef = isCreateRef;
|
|
1026
|
-
exports.isCreateRefCall = isCreateRefCall;
|
|
1027
|
-
exports.isDeclaredInRenderPropLoose = isDeclaredInRenderPropLoose;
|
|
1028
|
-
exports.isDirectValueOfRenderPropertyLoose = isDirectValueOfRenderPropertyLoose;
|
|
1029
|
-
exports.isForwardRef = isForwardRef;
|
|
1030
|
-
exports.isForwardRefCall = isForwardRefCall;
|
|
1031
|
-
exports.isFragmentElement = isFragmentElement;
|
|
1032
|
-
exports.isFunctionOfComponentDidMount = isFunctionOfComponentDidMount;
|
|
1033
|
-
exports.isFunctionOfComponentWillUnmount = isFunctionOfComponentWillUnmount;
|
|
1034
|
-
exports.isFunctionOfRender = isFunctionOfRender;
|
|
1035
|
-
exports.isFunctionOfRenderMethod = isFunctionOfRenderMethod;
|
|
1036
|
-
exports.isFunctionOfUseEffectCleanup = isFunctionOfUseEffectCleanup;
|
|
1037
|
-
exports.isFunctionOfUseEffectSetup = isFunctionOfUseEffectSetup;
|
|
1038
|
-
exports.isGetChildContext = isGetChildContext;
|
|
1039
|
-
exports.isGetDefaultProps = isGetDefaultProps;
|
|
1040
|
-
exports.isGetDerivedStateFromError = isGetDerivedStateFromError;
|
|
1041
|
-
exports.isGetDerivedStateFromProps = isGetDerivedStateFromProps;
|
|
1042
|
-
exports.isGetInitialState = isGetInitialState;
|
|
1043
|
-
exports.isGetSnapshotBeforeUpdate = isGetSnapshotBeforeUpdate;
|
|
1044
|
-
exports.isHostElement = isHostElement;
|
|
1045
|
-
exports.isInitializedFromReact = isInitializedFromReact;
|
|
1046
|
-
exports.isInsideRenderMethod = isInsideRenderMethod;
|
|
1047
|
-
exports.isInstanceIdEqual = isInstanceIdEqual;
|
|
1048
|
-
exports.isInversePhase = isInversePhase;
|
|
1049
|
-
exports.isJsxLike = isJsxLike;
|
|
1050
|
-
exports.isJsxText = isJsxText;
|
|
1051
|
-
exports.isKeyedElement = isKeyedElement;
|
|
1052
|
-
exports.isLazy = isLazy;
|
|
1053
|
-
exports.isLazyCall = isLazyCall;
|
|
1054
|
-
exports.isMemo = isMemo;
|
|
1055
|
-
exports.isMemoCall = isMemoCall;
|
|
1056
|
-
exports.isPureComponent = isPureComponent;
|
|
1057
|
-
exports.isReactAPI = isReactAPI;
|
|
1058
|
-
exports.isReactAPICall = isReactAPICall;
|
|
1059
|
-
exports.isReactHook = isReactHook;
|
|
1060
|
-
exports.isReactHookCall = isReactHookCall;
|
|
1061
|
-
exports.isReactHookCallWithName = isReactHookCallWithName;
|
|
1062
|
-
exports.isReactHookCallWithNameAlias = isReactHookCallWithNameAlias;
|
|
1063
|
-
exports.isReactHookCallWithNameLoose = isReactHookCallWithNameLoose;
|
|
1064
|
-
exports.isReactHookName = isReactHookName;
|
|
1065
|
-
exports.isRenderFunctionLoose = isRenderFunctionLoose;
|
|
1066
|
-
exports.isRenderLike = isRenderLike;
|
|
1067
|
-
exports.isRenderMethodLike = isRenderMethodLike;
|
|
1068
|
-
exports.isRenderPropLoose = isRenderPropLoose;
|
|
1069
|
-
exports.isShouldComponentUpdate = isShouldComponentUpdate;
|
|
1070
|
-
exports.isThisSetState = isThisSetState;
|
|
1071
|
-
exports.isUnsafeComponentWillMount = isUnsafeComponentWillMount;
|
|
1072
|
-
exports.isUnsafeComponentWillReceiveProps = isUnsafeComponentWillReceiveProps;
|
|
1073
|
-
exports.isUnsafeComponentWillUpdate = isUnsafeComponentWillUpdate;
|
|
1074
|
-
exports.isUseActionStateCall = isUseActionStateCall;
|
|
1075
|
-
exports.isUseCall = isUseCall;
|
|
1076
|
-
exports.isUseCallbackCall = isUseCallbackCall;
|
|
1077
|
-
exports.isUseContextCall = isUseContextCall;
|
|
1078
|
-
exports.isUseDebugValueCall = isUseDebugValueCall;
|
|
1079
|
-
exports.isUseDeferredValueCall = isUseDeferredValueCall;
|
|
1080
|
-
exports.isUseEffectCall = isUseEffectCall;
|
|
1081
|
-
exports.isUseEffectCallLoose = isUseEffectCallLoose;
|
|
1082
|
-
exports.isUseFormStatusCall = isUseFormStatusCall;
|
|
1083
|
-
exports.isUseIdCall = isUseIdCall;
|
|
1084
|
-
exports.isUseImperativeHandleCall = isUseImperativeHandleCall;
|
|
1085
|
-
exports.isUseInsertionEffectCall = isUseInsertionEffectCall;
|
|
1086
|
-
exports.isUseLayoutEffectCall = isUseLayoutEffectCall;
|
|
1087
|
-
exports.isUseMemoCall = isUseMemoCall;
|
|
1088
|
-
exports.isUseOptimisticCall = isUseOptimisticCall;
|
|
1089
|
-
exports.isUseReducerCall = isUseReducerCall;
|
|
1090
|
-
exports.isUseRefCall = isUseRefCall;
|
|
1091
|
-
exports.isUseStateCall = isUseStateCall;
|
|
1092
|
-
exports.isUseSyncExternalStoreCall = isUseSyncExternalStoreCall;
|
|
1093
|
-
exports.isUseTransitionCall = isUseTransitionCall;
|
|
1094
|
-
exports.isValidComponentDefinition = isValidComponentDefinition;
|
|
1095
|
-
exports.stringifyJsx = stringifyJsx;
|
|
1096
|
-
exports.useComponentCollector = useComponentCollector;
|
|
1097
|
-
exports.useComponentCollectorLegacy = useComponentCollectorLegacy;
|
|
1098
|
-
exports.useHookCollector = useHookCollector;
|
|
937
|
+
export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getComponentFlagFromInitPath, getComponentNameFromId, getElementType, getFunctionComponentId, getInstanceId, hasAnyAttribute, hasAttribute, hasEveryAttribute, hasNoneOrLooseComponentName, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFunctionOfRender, isFunctionOfRenderMethod, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHostElement, isInitializedFromReact, isInstanceIdEqual, isInversePhase, isJsxLike, isJsxText, isKeyedElement, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookId, isReactHookName, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|