@eslint-react/core 1.48.3 → 2.0.0-next.1
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 +12 -33
- package/dist/index.js +283 -454
- package/package.json +10 -18
- 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.toString(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,23 @@ function useHookCollector() {
|
|
|
284
266
|
};
|
|
285
267
|
return { ctx, listeners };
|
|
286
268
|
}
|
|
287
|
-
function isFunctionOfUseEffectSetup(node) {
|
|
288
|
-
if (node == null) return false;
|
|
289
|
-
return node.parent?.type === types.AST_NODE_TYPES.CallExpression && node.parent.callee !== node && node.parent.callee.type === types.AST_NODE_TYPES.Identifier && node.parent.arguments.at(0) === node && isUseEffectCallLoose(node.parent);
|
|
290
|
-
}
|
|
291
|
-
function isFunctionOfUseEffectCleanup(node) {
|
|
292
|
-
if (node == null) return false;
|
|
293
|
-
const pReturn = AST9__namespace.findParentNode(node, AST9__namespace.is(types.AST_NODE_TYPES.ReturnStatement));
|
|
294
|
-
const pFunction = AST9__namespace.findParentNode(node, AST9__namespace.isFunction);
|
|
295
|
-
const pFunctionOfReturn = AST9__namespace.findParentNode(pReturn, AST9__namespace.isFunction);
|
|
296
|
-
if (pFunction !== pFunctionOfReturn) return false;
|
|
297
|
-
return isFunctionOfUseEffectSetup(pFunction);
|
|
298
|
-
}
|
|
299
269
|
function stringifyJsx(node) {
|
|
300
270
|
switch (node.type) {
|
|
301
|
-
case
|
|
271
|
+
case AST_NODE_TYPES.JSXIdentifier:
|
|
302
272
|
return node.name;
|
|
303
|
-
case
|
|
273
|
+
case AST_NODE_TYPES.JSXNamespacedName:
|
|
304
274
|
return `${node.namespace.name}:${node.name.name}`;
|
|
305
|
-
case
|
|
275
|
+
case AST_NODE_TYPES.JSXMemberExpression:
|
|
306
276
|
return `${stringifyJsx(node.object)}.${stringifyJsx(node.property)}`;
|
|
307
|
-
case
|
|
277
|
+
case AST_NODE_TYPES.JSXText:
|
|
308
278
|
return node.value;
|
|
309
|
-
case
|
|
279
|
+
case AST_NODE_TYPES.JSXOpeningElement:
|
|
310
280
|
return `<${stringifyJsx(node.name)}>`;
|
|
311
|
-
case
|
|
281
|
+
case AST_NODE_TYPES.JSXClosingElement:
|
|
312
282
|
return `</${stringifyJsx(node.name)}>`;
|
|
313
|
-
case
|
|
283
|
+
case AST_NODE_TYPES.JSXOpeningFragment:
|
|
314
284
|
return "<>";
|
|
315
|
-
case
|
|
285
|
+
case AST_NODE_TYPES.JSXClosingFragment:
|
|
316
286
|
return "</>";
|
|
317
287
|
}
|
|
318
288
|
}
|
|
@@ -325,21 +295,21 @@ function getAttributeName(context, node) {
|
|
|
325
295
|
// src/jsx/jsx-attribute.ts
|
|
326
296
|
function getAttribute(context, name, attributes, initialScope) {
|
|
327
297
|
return attributes.findLast((attr) => {
|
|
328
|
-
if (attr.type ===
|
|
298
|
+
if (attr.type === AST_NODE_TYPES.JSXAttribute) {
|
|
329
299
|
return getAttributeName(context, attr) === name;
|
|
330
300
|
}
|
|
331
301
|
if (initialScope == null) return false;
|
|
332
302
|
switch (attr.argument.type) {
|
|
333
|
-
case
|
|
334
|
-
const variable =
|
|
335
|
-
const variableNode =
|
|
336
|
-
if (variableNode?.type ===
|
|
337
|
-
return
|
|
303
|
+
case AST_NODE_TYPES.Identifier: {
|
|
304
|
+
const variable = VAR3.findVariable(attr.argument.name, initialScope);
|
|
305
|
+
const variableNode = VAR3.getVariableInitNode(variable, 0);
|
|
306
|
+
if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) {
|
|
307
|
+
return VAR3.findPropertyInProperties(name, variableNode.properties, initialScope) != null;
|
|
338
308
|
}
|
|
339
309
|
return false;
|
|
340
310
|
}
|
|
341
|
-
case
|
|
342
|
-
return
|
|
311
|
+
case AST_NODE_TYPES.ObjectExpression:
|
|
312
|
+
return VAR3.findPropertyInProperties(name, attr.argument.properties, initialScope) != null;
|
|
343
313
|
}
|
|
344
314
|
return false;
|
|
345
315
|
});
|
|
@@ -347,8 +317,8 @@ function getAttribute(context, name, attributes, initialScope) {
|
|
|
347
317
|
function getAttributeValue(context, node, name) {
|
|
348
318
|
const initialScope = context.sourceCode.getScope(node);
|
|
349
319
|
switch (node.type) {
|
|
350
|
-
case
|
|
351
|
-
if (node.value?.type ===
|
|
320
|
+
case AST_NODE_TYPES.JSXAttribute:
|
|
321
|
+
if (node.value?.type === AST_NODE_TYPES.Literal) {
|
|
352
322
|
return {
|
|
353
323
|
kind: "some",
|
|
354
324
|
node: node.value,
|
|
@@ -356,16 +326,16 @@ function getAttributeValue(context, node, name) {
|
|
|
356
326
|
value: node.value.value
|
|
357
327
|
};
|
|
358
328
|
}
|
|
359
|
-
if (node.value?.type ===
|
|
360
|
-
return
|
|
329
|
+
if (node.value?.type === AST_NODE_TYPES.JSXExpressionContainer) {
|
|
330
|
+
return VAR3.toStaticValue({
|
|
361
331
|
kind: "lazy",
|
|
362
332
|
node: node.value.expression,
|
|
363
333
|
initialScope
|
|
364
334
|
});
|
|
365
335
|
}
|
|
366
336
|
return { kind: "none", node, initialScope };
|
|
367
|
-
case
|
|
368
|
-
const staticValue =
|
|
337
|
+
case AST_NODE_TYPES.JSXSpreadAttribute: {
|
|
338
|
+
const staticValue = VAR3.toStaticValue({
|
|
369
339
|
kind: "lazy",
|
|
370
340
|
node: node.argument,
|
|
371
341
|
initialScope
|
|
@@ -373,7 +343,7 @@ function getAttributeValue(context, node, name) {
|
|
|
373
343
|
if (staticValue.kind === "none") {
|
|
374
344
|
return staticValue;
|
|
375
345
|
}
|
|
376
|
-
return
|
|
346
|
+
return match(staticValue.value).with({ [name]: P.select(P.any) }, (value) => ({
|
|
377
347
|
kind: "some",
|
|
378
348
|
node: node.argument,
|
|
379
349
|
initialScope,
|
|
@@ -405,13 +375,13 @@ var DEFAULT_JSX_DETECTION_HINT = 0n | JSXDetectionHint.SkipUndefined | JSXDetect
|
|
|
405
375
|
// src/jsx/jsx-detection.ts
|
|
406
376
|
function isJsxText(node) {
|
|
407
377
|
if (node == null) return false;
|
|
408
|
-
return node.type ===
|
|
378
|
+
return node.type === AST_NODE_TYPES.JSXText || node.type === AST_NODE_TYPES.Literal;
|
|
409
379
|
}
|
|
410
380
|
function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
411
381
|
if (node == null) return false;
|
|
412
|
-
if (
|
|
382
|
+
if (AST14.isJSX(node)) return true;
|
|
413
383
|
switch (node.type) {
|
|
414
|
-
case
|
|
384
|
+
case AST_NODE_TYPES.Literal: {
|
|
415
385
|
switch (typeof node.value) {
|
|
416
386
|
case "boolean":
|
|
417
387
|
return !(hint & JSXDetectionHint.SkipBooleanLiteral);
|
|
@@ -427,22 +397,22 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
427
397
|
}
|
|
428
398
|
return false;
|
|
429
399
|
}
|
|
430
|
-
case
|
|
400
|
+
case AST_NODE_TYPES.TemplateLiteral: {
|
|
431
401
|
return !(hint & JSXDetectionHint.SkipStringLiteral);
|
|
432
402
|
}
|
|
433
|
-
case
|
|
403
|
+
case AST_NODE_TYPES.ArrayExpression: {
|
|
434
404
|
if (hint & JSXDetectionHint.StrictArray) {
|
|
435
405
|
return node.elements.every((n) => isJsxLike(code, n, hint));
|
|
436
406
|
}
|
|
437
407
|
return node.elements.some((n) => isJsxLike(code, n, hint));
|
|
438
408
|
}
|
|
439
|
-
case
|
|
409
|
+
case AST_NODE_TYPES.LogicalExpression: {
|
|
440
410
|
if (hint & JSXDetectionHint.StrictLogical) {
|
|
441
411
|
return isJsxLike(code, node.left, hint) && isJsxLike(code, node.right, hint);
|
|
442
412
|
}
|
|
443
413
|
return isJsxLike(code, node.left, hint) || isJsxLike(code, node.right, hint);
|
|
444
414
|
}
|
|
445
|
-
case
|
|
415
|
+
case AST_NODE_TYPES.ConditionalExpression: {
|
|
446
416
|
let leftHasJSX2 = function(node2) {
|
|
447
417
|
if (Array.isArray(node2.consequent)) {
|
|
448
418
|
if (node2.consequent.length === 0) {
|
|
@@ -462,39 +432,39 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
462
432
|
}
|
|
463
433
|
return leftHasJSX2(node) || rightHasJSX2(node);
|
|
464
434
|
}
|
|
465
|
-
case
|
|
435
|
+
case AST_NODE_TYPES.SequenceExpression: {
|
|
466
436
|
const exp = node.expressions.at(-1);
|
|
467
437
|
return isJsxLike(code, exp, hint);
|
|
468
438
|
}
|
|
469
|
-
case
|
|
439
|
+
case AST_NODE_TYPES.CallExpression: {
|
|
470
440
|
if (hint & JSXDetectionHint.SkipCreateElement) {
|
|
471
441
|
return false;
|
|
472
442
|
}
|
|
473
443
|
switch (node.callee.type) {
|
|
474
|
-
case
|
|
444
|
+
case AST_NODE_TYPES.Identifier:
|
|
475
445
|
return node.callee.name === "createElement";
|
|
476
|
-
case
|
|
477
|
-
return node.callee.property.type ===
|
|
446
|
+
case AST_NODE_TYPES.MemberExpression:
|
|
447
|
+
return node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "createElement";
|
|
478
448
|
}
|
|
479
449
|
return false;
|
|
480
450
|
}
|
|
481
|
-
case
|
|
451
|
+
case AST_NODE_TYPES.Identifier: {
|
|
482
452
|
const { name } = node;
|
|
483
453
|
if (name === "undefined") {
|
|
484
454
|
return !(hint & JSXDetectionHint.SkipUndefined);
|
|
485
455
|
}
|
|
486
|
-
if (
|
|
456
|
+
if (AST14.isJSXTagNameExpression(node)) {
|
|
487
457
|
return true;
|
|
488
458
|
}
|
|
489
|
-
const variable =
|
|
490
|
-
const variableNode = variable &&
|
|
459
|
+
const variable = VAR3.findVariable(name, code.getScope(node));
|
|
460
|
+
const variableNode = variable && VAR3.getVariableInitNode(variable, 0);
|
|
491
461
|
return !!variableNode && isJsxLike(code, variableNode, hint);
|
|
492
462
|
}
|
|
493
463
|
}
|
|
494
464
|
return false;
|
|
495
465
|
}
|
|
496
466
|
function getElementType(context, node) {
|
|
497
|
-
if (node.type ===
|
|
467
|
+
if (node.type === AST_NODE_TYPES.JSXFragment) {
|
|
498
468
|
return "";
|
|
499
469
|
}
|
|
500
470
|
return stringifyJsx(node.openingElement.name);
|
|
@@ -510,22 +480,22 @@ function hasAnyAttribute(context, names, attributes, initialScope) {
|
|
|
510
480
|
function hasEveryAttribute(context, names, attributes, initialScope) {
|
|
511
481
|
return names.every((n) => hasAttribute(context, n, attributes, initialScope));
|
|
512
482
|
}
|
|
513
|
-
function findParentAttribute(node, test =
|
|
483
|
+
function findParentAttribute(node, test = constTrue) {
|
|
514
484
|
const guard = (node2) => {
|
|
515
|
-
return node2.type ===
|
|
485
|
+
return node2.type === AST_NODE_TYPES.JSXAttribute && test(node2);
|
|
516
486
|
};
|
|
517
|
-
return
|
|
487
|
+
return AST14.findParentNode(node, guard);
|
|
518
488
|
}
|
|
519
489
|
function isHostElement(context, node) {
|
|
520
|
-
return node.type ===
|
|
490
|
+
return node.type === AST_NODE_TYPES.JSXElement && node.openingElement.name.type === AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.openingElement.name.name);
|
|
521
491
|
}
|
|
522
492
|
function isKeyedElement(context, node, initialScope) {
|
|
523
|
-
return node.type ===
|
|
493
|
+
return node.type === AST_NODE_TYPES.JSXElement && hasAttribute(context, "key", node.openingElement.attributes, initialScope);
|
|
524
494
|
}
|
|
525
495
|
function isFragmentElement(context, node, allowJSXFragment = false) {
|
|
526
496
|
if (node == null) return false;
|
|
527
|
-
if (node.type !==
|
|
528
|
-
if (node.type ===
|
|
497
|
+
if (node.type !== AST_NODE_TYPES.JSXElement && node.type !== AST_NODE_TYPES.JSXFragment) return false;
|
|
498
|
+
if (node.type === AST_NODE_TYPES.JSXFragment) return allowJSXFragment;
|
|
529
499
|
return getElementType(context, node).split(".").at(-1) === "Fragment";
|
|
530
500
|
}
|
|
531
501
|
|
|
@@ -565,9 +535,9 @@ function isClassComponent(node) {
|
|
|
565
535
|
if ("superClass" in node && node.superClass != null) {
|
|
566
536
|
const re = /^(?:Pure)?Component$/u;
|
|
567
537
|
switch (true) {
|
|
568
|
-
case node.superClass.type ===
|
|
538
|
+
case node.superClass.type === AST_NODE_TYPES.Identifier:
|
|
569
539
|
return re.test(node.superClass.name);
|
|
570
|
-
case (node.superClass.type ===
|
|
540
|
+
case (node.superClass.type === AST_NODE_TYPES.MemberExpression && node.superClass.property.type === AST_NODE_TYPES.Identifier):
|
|
571
541
|
return re.test(node.superClass.property.name);
|
|
572
542
|
}
|
|
573
543
|
}
|
|
@@ -577,119 +547,42 @@ function isPureComponent(node) {
|
|
|
577
547
|
if ("superClass" in node && node.superClass != null) {
|
|
578
548
|
const re = /^PureComponent$/u;
|
|
579
549
|
switch (true) {
|
|
580
|
-
case node.superClass.type ===
|
|
550
|
+
case node.superClass.type === AST_NODE_TYPES.Identifier:
|
|
581
551
|
return re.test(node.superClass.name);
|
|
582
|
-
case (node.superClass.type ===
|
|
552
|
+
case (node.superClass.type === AST_NODE_TYPES.MemberExpression && node.superClass.property.type === AST_NODE_TYPES.Identifier):
|
|
583
553
|
return re.test(node.superClass.property.name);
|
|
584
554
|
}
|
|
585
555
|
}
|
|
586
556
|
return false;
|
|
587
557
|
}
|
|
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
558
|
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);
|
|
559
|
+
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
560
|
}
|
|
674
561
|
|
|
675
562
|
// src/component/component-definition.ts
|
|
676
|
-
var isFunctionOfClassMethod =
|
|
677
|
-
type:
|
|
678
|
-
parent:
|
|
563
|
+
var isFunctionOfClassMethod = isMatching({
|
|
564
|
+
type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
|
|
565
|
+
parent: AST_NODE_TYPES.MethodDefinition
|
|
679
566
|
});
|
|
680
|
-
var isFunctionOfClassProperty =
|
|
681
|
-
type:
|
|
682
|
-
parent:
|
|
567
|
+
var isFunctionOfClassProperty = isMatching({
|
|
568
|
+
type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
|
|
569
|
+
parent: AST_NODE_TYPES.Property
|
|
683
570
|
});
|
|
684
|
-
var isFunctionOfObjectMethod =
|
|
685
|
-
type:
|
|
571
|
+
var isFunctionOfObjectMethod = isMatching({
|
|
572
|
+
type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
|
|
686
573
|
parent: {
|
|
687
|
-
type:
|
|
574
|
+
type: AST_NODE_TYPES.Property,
|
|
688
575
|
parent: {
|
|
689
|
-
type:
|
|
576
|
+
type: AST_NODE_TYPES.ObjectExpression
|
|
690
577
|
}
|
|
691
578
|
}
|
|
692
579
|
});
|
|
580
|
+
function isFunctionOfRenderMethod(node) {
|
|
581
|
+
if (!isRenderMethodLike(node.parent)) {
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
return isClassComponent(node.parent.parent.parent);
|
|
585
|
+
}
|
|
693
586
|
function isValidComponentDefinition(context, node, hint) {
|
|
694
587
|
if (isChildrenOfCreateElement(context, node) || isFunctionOfRenderMethod(node)) {
|
|
695
588
|
return false;
|
|
@@ -703,44 +596,44 @@ function isValidComponentDefinition(context, node, hint) {
|
|
|
703
596
|
if (hint & ComponentDetectionHint.SkipClassProperty && isFunctionOfClassProperty(node.parent)) {
|
|
704
597
|
return false;
|
|
705
598
|
}
|
|
706
|
-
if (hint & ComponentDetectionHint.SkipArrayMapArgument &&
|
|
599
|
+
if (hint & ComponentDetectionHint.SkipArrayMapArgument && AST14.isArrayMapCall(node.parent)) {
|
|
707
600
|
return false;
|
|
708
601
|
}
|
|
709
|
-
const significantParent =
|
|
602
|
+
const significantParent = AST14.findParentNode(
|
|
710
603
|
node,
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
604
|
+
AST14.isOneOf([
|
|
605
|
+
AST_NODE_TYPES.JSXExpressionContainer,
|
|
606
|
+
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
607
|
+
AST_NODE_TYPES.FunctionExpression,
|
|
608
|
+
AST_NODE_TYPES.Property,
|
|
609
|
+
AST_NODE_TYPES.ClassBody
|
|
717
610
|
])
|
|
718
611
|
);
|
|
719
|
-
return significantParent == null || significantParent.type !==
|
|
612
|
+
return significantParent == null || significantParent.type !== AST_NODE_TYPES.JSXExpressionContainer;
|
|
720
613
|
}
|
|
721
614
|
function isComponentWrapperCall(context, node) {
|
|
722
|
-
if (node.type !==
|
|
615
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
723
616
|
return isMemoCall(context, node) || isForwardRefCall(context, node);
|
|
724
617
|
}
|
|
725
618
|
function isComponentWrapperCallLoose(context, node) {
|
|
726
|
-
if (node.type !==
|
|
619
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
727
620
|
return isComponentWrapperCall(context, node) || isUseCallbackCall(context, node);
|
|
728
621
|
}
|
|
729
622
|
|
|
730
623
|
// src/component/component-id.ts
|
|
731
624
|
function getFunctionComponentId(context, node) {
|
|
732
|
-
const functionId =
|
|
625
|
+
const functionId = AST14.getFunctionId(node);
|
|
733
626
|
if (functionId != null) {
|
|
734
627
|
return functionId;
|
|
735
628
|
}
|
|
736
629
|
const { parent } = node;
|
|
737
|
-
if (parent.type ===
|
|
630
|
+
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
631
|
return parent.parent.id;
|
|
739
632
|
}
|
|
740
|
-
if (parent.type ===
|
|
633
|
+
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
634
|
return parent.parent.parent.id;
|
|
742
635
|
}
|
|
743
|
-
return
|
|
636
|
+
return _;
|
|
744
637
|
}
|
|
745
638
|
|
|
746
639
|
// src/component/component-flag.ts
|
|
@@ -756,22 +649,22 @@ var ComponentFlag = {
|
|
|
756
649
|
// src/component/component-init-path.ts
|
|
757
650
|
function getComponentFlagFromInitPath(initPath) {
|
|
758
651
|
let flag = ComponentFlag.None;
|
|
759
|
-
if (initPath != null &&
|
|
652
|
+
if (initPath != null && AST14.hasCallInFunctionInitPath("memo", initPath)) {
|
|
760
653
|
flag |= ComponentFlag.Memo;
|
|
761
654
|
}
|
|
762
|
-
if (initPath != null &&
|
|
655
|
+
if (initPath != null && AST14.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
763
656
|
flag |= ComponentFlag.ForwardRef;
|
|
764
657
|
}
|
|
765
658
|
return flag;
|
|
766
659
|
}
|
|
767
660
|
function isComponentName(name) {
|
|
768
|
-
return
|
|
661
|
+
return RegExp.COMPONENT_NAME.test(name);
|
|
769
662
|
}
|
|
770
663
|
function isComponentNameLoose(name) {
|
|
771
|
-
return
|
|
664
|
+
return RegExp.COMPONENT_NAME_LOOSE.test(name);
|
|
772
665
|
}
|
|
773
666
|
function getComponentNameFromId(id) {
|
|
774
|
-
if (id == null) return
|
|
667
|
+
if (id == null) return _;
|
|
775
668
|
return Array.isArray(id) ? id.map((n) => n.name).join(".") : id.name;
|
|
776
669
|
}
|
|
777
670
|
function hasNoneOrLooseComponentName(context, fn) {
|
|
@@ -792,14 +685,14 @@ function useComponentCollector(context, options = {}) {
|
|
|
792
685
|
const functionEntries = [];
|
|
793
686
|
const getCurrentEntry = () => functionEntries.at(-1);
|
|
794
687
|
const onFunctionEnter = (node) => {
|
|
795
|
-
const key =
|
|
688
|
+
const key = getId();
|
|
796
689
|
functionEntries.push({ key, node, hookCalls: [], isComponent: false });
|
|
797
690
|
};
|
|
798
691
|
const onFunctionExit = () => {
|
|
799
692
|
const entry = functionEntries.at(-1);
|
|
800
693
|
if (entry == null) return;
|
|
801
694
|
if (!entry.isComponent) return functionEntries.pop();
|
|
802
|
-
const shouldDrop =
|
|
695
|
+
const shouldDrop = AST14.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
|
|
803
696
|
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !isJsxLike(context.sourceCode, r.argument, hint);
|
|
804
697
|
});
|
|
805
698
|
if (shouldDrop) {
|
|
@@ -826,17 +719,17 @@ function useComponentCollector(context, options = {}) {
|
|
|
826
719
|
const { body } = entry.node;
|
|
827
720
|
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, body, hint) && isValidComponentDefinition(context, entry.node, hint);
|
|
828
721
|
if (!isComponent) return;
|
|
829
|
-
const initPath =
|
|
722
|
+
const initPath = AST14.getFunctionInitPath(entry.node);
|
|
830
723
|
const id = getFunctionComponentId(context, entry.node);
|
|
831
724
|
const name = getComponentNameFromId(id);
|
|
832
|
-
const key =
|
|
725
|
+
const key = getId();
|
|
833
726
|
components.set(key, {
|
|
834
727
|
id,
|
|
835
728
|
key,
|
|
836
729
|
kind: "function",
|
|
837
730
|
name,
|
|
838
731
|
node: entry.node,
|
|
839
|
-
displayName:
|
|
732
|
+
displayName: _,
|
|
840
733
|
flag: getComponentFlagFromInitPath(initPath),
|
|
841
734
|
hint,
|
|
842
735
|
hookCalls: entry.hookCalls,
|
|
@@ -844,10 +737,10 @@ function useComponentCollector(context, options = {}) {
|
|
|
844
737
|
});
|
|
845
738
|
},
|
|
846
739
|
...collectDisplayName ? {
|
|
847
|
-
[
|
|
740
|
+
[Selector.DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
|
|
848
741
|
const { left, right } = node;
|
|
849
|
-
if (left.type !==
|
|
850
|
-
const componentName = left.object.type ===
|
|
742
|
+
if (left.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
743
|
+
const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : _;
|
|
851
744
|
const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
|
|
852
745
|
if (component == null) return;
|
|
853
746
|
component.displayName = right;
|
|
@@ -867,7 +760,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
867
760
|
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, node.argument, hint) && isValidComponentDefinition(context, entry.node, hint);
|
|
868
761
|
if (!isComponent) return;
|
|
869
762
|
entry.isComponent = true;
|
|
870
|
-
const initPath =
|
|
763
|
+
const initPath = AST14.getFunctionInitPath(entry.node);
|
|
871
764
|
const id = getFunctionComponentId(context, entry.node);
|
|
872
765
|
const name = getComponentNameFromId(id);
|
|
873
766
|
components.set(entry.key, {
|
|
@@ -876,7 +769,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
876
769
|
kind: "function",
|
|
877
770
|
name,
|
|
878
771
|
node: entry.node,
|
|
879
|
-
displayName:
|
|
772
|
+
displayName: _,
|
|
880
773
|
flag: getComponentFlagFromInitPath(initPath),
|
|
881
774
|
hint,
|
|
882
775
|
hookCalls: entry.hookCalls,
|
|
@@ -898,8 +791,8 @@ function useComponentCollectorLegacy() {
|
|
|
898
791
|
if (!isClassComponent(node)) {
|
|
899
792
|
return;
|
|
900
793
|
}
|
|
901
|
-
const id =
|
|
902
|
-
const key =
|
|
794
|
+
const id = AST14.getClassId(node);
|
|
795
|
+
const key = getId();
|
|
903
796
|
const flag = isPureComponent(node) ? ComponentFlag.PureComponent : ComponentFlag.None;
|
|
904
797
|
components.set(
|
|
905
798
|
key,
|
|
@@ -910,7 +803,7 @@ function useComponentCollectorLegacy() {
|
|
|
910
803
|
name: id?.name,
|
|
911
804
|
node,
|
|
912
805
|
// TODO: Get displayName of class component
|
|
913
|
-
displayName:
|
|
806
|
+
displayName: _,
|
|
914
807
|
flag,
|
|
915
808
|
hint: 0n,
|
|
916
809
|
// TODO: Get methods of class component
|
|
@@ -924,15 +817,75 @@ function useComponentCollectorLegacy() {
|
|
|
924
817
|
};
|
|
925
818
|
return { ctx, listeners };
|
|
926
819
|
}
|
|
927
|
-
|
|
820
|
+
function isComponentDidCatch(node) {
|
|
821
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
|
|
822
|
+
}
|
|
823
|
+
function isComponentDidMount(node) {
|
|
824
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
825
|
+
}
|
|
826
|
+
function isComponentDidUpdate(node) {
|
|
827
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
828
|
+
}
|
|
829
|
+
function isComponentWillMount(node) {
|
|
830
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillMount";
|
|
831
|
+
}
|
|
832
|
+
function isComponentWillReceiveProps(node) {
|
|
833
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillReceiveProps";
|
|
834
|
+
}
|
|
835
|
+
function isComponentWillUnmount(node) {
|
|
836
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
|
|
837
|
+
}
|
|
838
|
+
function isComponentWillUpdate(node) {
|
|
839
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
840
|
+
}
|
|
841
|
+
function isGetChildContext(node) {
|
|
842
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getChildContext";
|
|
843
|
+
}
|
|
844
|
+
function isGetDefaultProps(node) {
|
|
845
|
+
return AST14.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDefaultProps";
|
|
846
|
+
}
|
|
847
|
+
function isGetInitialState(node) {
|
|
848
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getInitialState";
|
|
849
|
+
}
|
|
850
|
+
function isGetSnapshotBeforeUpdate(node) {
|
|
851
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getSnapshotBeforeUpdate";
|
|
852
|
+
}
|
|
853
|
+
function isShouldComponentUpdate(node) {
|
|
854
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
855
|
+
}
|
|
856
|
+
function isUnsafeComponentWillMount(node) {
|
|
857
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
858
|
+
}
|
|
859
|
+
function isUnsafeComponentWillReceiveProps(node) {
|
|
860
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
861
|
+
}
|
|
862
|
+
function isUnsafeComponentWillUpdate(node) {
|
|
863
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
864
|
+
}
|
|
865
|
+
function isGetDerivedStateFromProps(node) {
|
|
866
|
+
return AST14.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
|
|
867
|
+
}
|
|
868
|
+
function isGetDerivedStateFromError(node) {
|
|
869
|
+
return AST14.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
|
|
870
|
+
}
|
|
871
|
+
var ComponentPhaseRelevance = birecord({
|
|
928
872
|
mount: "unmount",
|
|
929
873
|
setup: "cleanup"
|
|
930
874
|
});
|
|
931
|
-
var isInversePhase =
|
|
875
|
+
var isInversePhase = dual(2, (a, b) => ComponentPhaseRelevance.get(a) === b);
|
|
876
|
+
function isRenderLike(node) {
|
|
877
|
+
return AST14.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
|
|
878
|
+
}
|
|
879
|
+
function isFunctionOfRender(node) {
|
|
880
|
+
if (!isRenderLike(node.parent)) {
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
return isClassComponent(node.parent.parent.parent);
|
|
884
|
+
}
|
|
932
885
|
function isRenderFunctionLoose(context, node) {
|
|
933
886
|
const { body, parent } = node;
|
|
934
|
-
if (
|
|
935
|
-
return parent.type ===
|
|
887
|
+
if (AST14.getFunctionId(node)?.name.startsWith("render")) {
|
|
888
|
+
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
889
|
}
|
|
937
890
|
return isJsxLike(
|
|
938
891
|
context.sourceCode,
|
|
@@ -941,14 +894,14 @@ function isRenderFunctionLoose(context, node) {
|
|
|
941
894
|
);
|
|
942
895
|
}
|
|
943
896
|
function isRenderPropLoose(context, node) {
|
|
944
|
-
if (node.name.type !==
|
|
897
|
+
if (node.name.type !== AST_NODE_TYPES.JSXIdentifier) {
|
|
945
898
|
return false;
|
|
946
899
|
}
|
|
947
|
-
return node.name.name.startsWith("render") && node.value?.type ===
|
|
900
|
+
return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && AST14.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression);
|
|
948
901
|
}
|
|
949
902
|
function isDirectValueOfRenderPropertyLoose(node) {
|
|
950
903
|
const matching = (node2) => {
|
|
951
|
-
return node2.type ===
|
|
904
|
+
return node2.type === AST_NODE_TYPES.Property && node2.key.type === AST_NODE_TYPES.Identifier && node2.key.name.startsWith("render");
|
|
952
905
|
};
|
|
953
906
|
return matching(node) || node.parent != null && matching(node.parent);
|
|
954
907
|
}
|
|
@@ -956,143 +909,19 @@ function isDeclaredInRenderPropLoose(node) {
|
|
|
956
909
|
if (isDirectValueOfRenderPropertyLoose(node)) {
|
|
957
910
|
return true;
|
|
958
911
|
}
|
|
959
|
-
const parent =
|
|
960
|
-
if (parent?.type !==
|
|
912
|
+
const parent = AST14.findParentNode(node, AST14.is(AST_NODE_TYPES.JSXExpressionContainer))?.parent;
|
|
913
|
+
if (parent?.type !== AST_NODE_TYPES.JSXAttribute) {
|
|
961
914
|
return false;
|
|
962
915
|
}
|
|
963
|
-
return parent.name.type ===
|
|
916
|
+
return parent.name.type === AST_NODE_TYPES.JSXIdentifier && parent.name.name.startsWith("render");
|
|
964
917
|
}
|
|
965
918
|
function isThisSetState(node) {
|
|
966
919
|
const { callee } = node;
|
|
967
|
-
return callee.type ===
|
|
920
|
+
return callee.type === AST_NODE_TYPES.MemberExpression && AST14.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
|
|
968
921
|
}
|
|
969
922
|
function isAssignmentToThisState(node) {
|
|
970
923
|
const { left } = node;
|
|
971
|
-
return left.type ===
|
|
924
|
+
return left.type === AST_NODE_TYPES.MemberExpression && AST14.isThisExpression(left.object) && AST14.getPropertyName(left.property) === "state";
|
|
972
925
|
}
|
|
973
926
|
|
|
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;
|
|
927
|
+
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, 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 };
|