@eslint-react/core 1.52.3-next.9 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14 -34
- package/dist/index.js +313 -453
- package/package.json +14 -22
- package/dist/index.d.mts +0 -565
- package/dist/index.mjs +0 -955
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, unit } 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.unit;
|
|
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,7 +54,81 @@ 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 unit;
|
|
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
|
|
111
|
+
var REACT_BUILTIN_HOOK_NAMES = [
|
|
112
|
+
"use",
|
|
113
|
+
"useActionState",
|
|
114
|
+
"useCallback",
|
|
115
|
+
"useContext",
|
|
116
|
+
"useDebugValue",
|
|
117
|
+
"useDeferredValue",
|
|
118
|
+
"useEffect",
|
|
119
|
+
"useFormStatus",
|
|
120
|
+
"useId",
|
|
121
|
+
"useImperativeHandle",
|
|
122
|
+
"useInsertionEffect",
|
|
123
|
+
"useLayoutEffect",
|
|
124
|
+
"useMemo",
|
|
125
|
+
"useOptimistic",
|
|
126
|
+
"useReducer",
|
|
127
|
+
"useRef",
|
|
128
|
+
"useState",
|
|
129
|
+
"useSyncExternalStore",
|
|
130
|
+
"useTransition"
|
|
131
|
+
];
|
|
129
132
|
function isReactHookName(name) {
|
|
130
133
|
return name === "use" || /^use[A-Z0-9]/.test(name);
|
|
131
134
|
}
|
|
@@ -133,34 +136,34 @@ function isReactHookName(name) {
|
|
|
133
136
|
// src/hook/hook-is.ts
|
|
134
137
|
function isReactHook(node) {
|
|
135
138
|
if (node == null) return false;
|
|
136
|
-
const id =
|
|
139
|
+
const id = AST14.getFunctionId(node);
|
|
137
140
|
return id?.name != null && isReactHookName(id.name);
|
|
138
141
|
}
|
|
139
142
|
function isReactHookCall(node) {
|
|
140
143
|
if (node == null) return false;
|
|
141
|
-
if (node.type !==
|
|
144
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) {
|
|
142
145
|
return false;
|
|
143
146
|
}
|
|
144
|
-
if (node.callee.type ===
|
|
147
|
+
if (node.callee.type === AST_NODE_TYPES.Identifier) {
|
|
145
148
|
return isReactHookName(node.callee.name);
|
|
146
149
|
}
|
|
147
|
-
if (node.callee.type ===
|
|
148
|
-
return node.callee.property.type ===
|
|
150
|
+
if (node.callee.type === AST_NODE_TYPES.MemberExpression) {
|
|
151
|
+
return node.callee.property.type === AST_NODE_TYPES.Identifier && isReactHookName(node.callee.property.name);
|
|
149
152
|
}
|
|
150
153
|
return false;
|
|
151
154
|
}
|
|
152
155
|
function isReactHookCallWithName(context, node) {
|
|
153
|
-
if (node == null || node.type !==
|
|
156
|
+
if (node == null || node.type !== AST_NODE_TYPES.CallExpression) return constFalse;
|
|
154
157
|
const {
|
|
155
|
-
importSource =
|
|
158
|
+
importSource = DEFAULT_ESLINT_REACT_SETTINGS.importSource,
|
|
156
159
|
skipImportCheck = true
|
|
157
|
-
} =
|
|
160
|
+
} = coerceSettings(context.settings);
|
|
158
161
|
const initialScope = context.sourceCode.getScope(node);
|
|
159
162
|
return (name) => {
|
|
160
163
|
switch (true) {
|
|
161
|
-
case (node.callee.type ===
|
|
164
|
+
case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === name):
|
|
162
165
|
return skipImportCheck || isInitializedFromReact(name, importSource, initialScope);
|
|
163
|
-
case (node.callee.type ===
|
|
166
|
+
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
167
|
return skipImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
|
|
165
168
|
default:
|
|
166
169
|
return false;
|
|
@@ -168,13 +171,13 @@ function isReactHookCallWithName(context, node) {
|
|
|
168
171
|
};
|
|
169
172
|
}
|
|
170
173
|
function isReactHookCallWithNameLoose(node) {
|
|
171
|
-
if (node == null || node.type !==
|
|
174
|
+
if (node == null || node.type !== AST_NODE_TYPES.CallExpression) return constFalse;
|
|
172
175
|
return (name) => {
|
|
173
176
|
switch (node.callee.type) {
|
|
174
|
-
case
|
|
177
|
+
case AST_NODE_TYPES.Identifier:
|
|
175
178
|
return node.callee.name === name;
|
|
176
|
-
case
|
|
177
|
-
return node.callee.property.type ===
|
|
179
|
+
case AST_NODE_TYPES.MemberExpression:
|
|
180
|
+
return node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === name;
|
|
178
181
|
default:
|
|
179
182
|
return false;
|
|
180
183
|
}
|
|
@@ -182,15 +185,15 @@ function isReactHookCallWithNameLoose(node) {
|
|
|
182
185
|
}
|
|
183
186
|
function isReactHookCallWithNameAlias(context, name, alias = []) {
|
|
184
187
|
const {
|
|
185
|
-
importSource =
|
|
188
|
+
importSource = DEFAULT_ESLINT_REACT_SETTINGS.importSource,
|
|
186
189
|
skipImportCheck = true
|
|
187
|
-
} =
|
|
190
|
+
} = coerceSettings(context.settings);
|
|
188
191
|
return (node) => {
|
|
189
192
|
const initialScope = context.sourceCode.getScope(node);
|
|
190
193
|
switch (true) {
|
|
191
|
-
case (node.callee.type ===
|
|
194
|
+
case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === name):
|
|
192
195
|
return skipImportCheck || isInitializedFromReact(name, importSource, initialScope);
|
|
193
|
-
case (node.callee.type ===
|
|
196
|
+
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
197
|
return skipImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
|
|
195
198
|
default:
|
|
196
199
|
return alias.some(isReactHookCallWithNameLoose(node));
|
|
@@ -199,45 +202,45 @@ function isReactHookCallWithNameAlias(context, name, alias = []) {
|
|
|
199
202
|
}
|
|
200
203
|
function isUseEffectCallLoose(node) {
|
|
201
204
|
if (node == null) return false;
|
|
202
|
-
if (node.type !==
|
|
205
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) {
|
|
203
206
|
return false;
|
|
204
207
|
}
|
|
205
208
|
switch (node.callee.type) {
|
|
206
|
-
case
|
|
209
|
+
case AST_NODE_TYPES.Identifier:
|
|
207
210
|
return /^use\w*Effect$/u.test(node.callee.name);
|
|
208
|
-
case
|
|
209
|
-
return node.callee.property.type ===
|
|
211
|
+
case AST_NODE_TYPES.MemberExpression:
|
|
212
|
+
return node.callee.property.type === AST_NODE_TYPES.Identifier && /^use\w*Effect$/u.test(node.callee.property.name);
|
|
210
213
|
default:
|
|
211
214
|
return false;
|
|
212
215
|
}
|
|
213
216
|
}
|
|
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 =
|
|
217
|
+
var isUseCall = flip(isReactHookCallWithName)("use");
|
|
218
|
+
var isUseActionStateCall = flip(isReactHookCallWithName)("useActionState");
|
|
219
|
+
var isUseCallbackCall = flip(isReactHookCallWithName)("useCallback");
|
|
220
|
+
var isUseContextCall = flip(isReactHookCallWithName)("useContext");
|
|
221
|
+
var isUseDebugValueCall = flip(isReactHookCallWithName)("useDebugValue");
|
|
222
|
+
var isUseDeferredValueCall = flip(isReactHookCallWithName)("useDeferredValue");
|
|
223
|
+
var isUseEffectCall = flip(isReactHookCallWithName)("useEffect");
|
|
224
|
+
var isUseFormStatusCall = flip(isReactHookCallWithName)("useFormStatus");
|
|
225
|
+
var isUseIdCall = flip(isReactHookCallWithName)("useId");
|
|
226
|
+
var isUseImperativeHandleCall = flip(isReactHookCallWithName)("useImperativeHandle");
|
|
227
|
+
var isUseInsertionEffectCall = flip(isReactHookCallWithName)("useInsertionEffect");
|
|
228
|
+
var isUseLayoutEffectCall = flip(isReactHookCallWithName)("useLayoutEffect");
|
|
229
|
+
var isUseMemoCall = flip(isReactHookCallWithName)("useMemo");
|
|
230
|
+
var isUseOptimisticCall = flip(isReactHookCallWithName)("useOptimistic");
|
|
231
|
+
var isUseReducerCall = flip(isReactHookCallWithName)("useReducer");
|
|
232
|
+
var isUseRefCall = flip(isReactHookCallWithName)("useRef");
|
|
233
|
+
var isUseStateCall = flip(isReactHookCallWithName)("useState");
|
|
234
|
+
var isUseSyncExternalStoreCall = flip(isReactHookCallWithName)("useSyncExternalStore");
|
|
235
|
+
var isUseTransitionCall = flip(isReactHookCallWithName)("useTransition");
|
|
233
236
|
|
|
234
237
|
// src/hook/hook-collector.ts
|
|
235
238
|
function useHookCollector() {
|
|
236
239
|
const hooks = /* @__PURE__ */ new Map();
|
|
237
240
|
const functionEntries = [];
|
|
238
241
|
const onFunctionEnter = (node) => {
|
|
239
|
-
const id =
|
|
240
|
-
const key =
|
|
242
|
+
const id = AST14.getFunctionId(node);
|
|
243
|
+
const key = getId();
|
|
241
244
|
const name = id?.name;
|
|
242
245
|
if (name != null && isReactHookName(name)) {
|
|
243
246
|
functionEntries.push({ key, node, isHook: true });
|
|
@@ -284,35 +287,33 @@ function useHookCollector() {
|
|
|
284
287
|
};
|
|
285
288
|
return { ctx, listeners };
|
|
286
289
|
}
|
|
287
|
-
function
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (pFunction !== pFunctionOfReturn) return false;
|
|
297
|
-
return isFunctionOfUseEffectSetup(pFunction);
|
|
290
|
+
function isReactHookId(id) {
|
|
291
|
+
switch (id.type) {
|
|
292
|
+
case AST_NODE_TYPES.Identifier:
|
|
293
|
+
return isReactHookName(id.name);
|
|
294
|
+
case AST_NODE_TYPES.MemberExpression:
|
|
295
|
+
return "name" in id.property && isReactHookName(id.property.name);
|
|
296
|
+
default:
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
298
299
|
}
|
|
299
300
|
function stringifyJsx(node) {
|
|
300
301
|
switch (node.type) {
|
|
301
|
-
case
|
|
302
|
+
case AST_NODE_TYPES.JSXIdentifier:
|
|
302
303
|
return node.name;
|
|
303
|
-
case
|
|
304
|
+
case AST_NODE_TYPES.JSXNamespacedName:
|
|
304
305
|
return `${node.namespace.name}:${node.name.name}`;
|
|
305
|
-
case
|
|
306
|
+
case AST_NODE_TYPES.JSXMemberExpression:
|
|
306
307
|
return `${stringifyJsx(node.object)}.${stringifyJsx(node.property)}`;
|
|
307
|
-
case
|
|
308
|
+
case AST_NODE_TYPES.JSXText:
|
|
308
309
|
return node.value;
|
|
309
|
-
case
|
|
310
|
+
case AST_NODE_TYPES.JSXOpeningElement:
|
|
310
311
|
return `<${stringifyJsx(node.name)}>`;
|
|
311
|
-
case
|
|
312
|
+
case AST_NODE_TYPES.JSXClosingElement:
|
|
312
313
|
return `</${stringifyJsx(node.name)}>`;
|
|
313
|
-
case
|
|
314
|
+
case AST_NODE_TYPES.JSXOpeningFragment:
|
|
314
315
|
return "<>";
|
|
315
|
-
case
|
|
316
|
+
case AST_NODE_TYPES.JSXClosingFragment:
|
|
316
317
|
return "</>";
|
|
317
318
|
}
|
|
318
319
|
}
|
|
@@ -325,21 +326,21 @@ function getAttributeName(context, node) {
|
|
|
325
326
|
// src/jsx/jsx-attribute.ts
|
|
326
327
|
function getAttribute(context, name, attributes, initialScope) {
|
|
327
328
|
return attributes.findLast((attr) => {
|
|
328
|
-
if (attr.type ===
|
|
329
|
+
if (attr.type === AST_NODE_TYPES.JSXAttribute) {
|
|
329
330
|
return getAttributeName(context, attr) === name;
|
|
330
331
|
}
|
|
331
332
|
if (initialScope == null) return false;
|
|
332
333
|
switch (attr.argument.type) {
|
|
333
|
-
case
|
|
334
|
-
const variable =
|
|
335
|
-
const variableNode =
|
|
336
|
-
if (variableNode?.type ===
|
|
337
|
-
return
|
|
334
|
+
case AST_NODE_TYPES.Identifier: {
|
|
335
|
+
const variable = VAR3.findVariable(attr.argument.name, initialScope);
|
|
336
|
+
const variableNode = VAR3.getVariableInitNode(variable, 0);
|
|
337
|
+
if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) {
|
|
338
|
+
return VAR3.findPropertyInProperties(name, variableNode.properties, initialScope) != null;
|
|
338
339
|
}
|
|
339
340
|
return false;
|
|
340
341
|
}
|
|
341
|
-
case
|
|
342
|
-
return
|
|
342
|
+
case AST_NODE_TYPES.ObjectExpression:
|
|
343
|
+
return VAR3.findPropertyInProperties(name, attr.argument.properties, initialScope) != null;
|
|
343
344
|
}
|
|
344
345
|
return false;
|
|
345
346
|
});
|
|
@@ -347,8 +348,8 @@ function getAttribute(context, name, attributes, initialScope) {
|
|
|
347
348
|
function getAttributeValue(context, node, name) {
|
|
348
349
|
const initialScope = context.sourceCode.getScope(node);
|
|
349
350
|
switch (node.type) {
|
|
350
|
-
case
|
|
351
|
-
if (node.value?.type ===
|
|
351
|
+
case AST_NODE_TYPES.JSXAttribute:
|
|
352
|
+
if (node.value?.type === AST_NODE_TYPES.Literal) {
|
|
352
353
|
return {
|
|
353
354
|
kind: "some",
|
|
354
355
|
node: node.value,
|
|
@@ -356,16 +357,16 @@ function getAttributeValue(context, node, name) {
|
|
|
356
357
|
value: node.value.value
|
|
357
358
|
};
|
|
358
359
|
}
|
|
359
|
-
if (node.value?.type ===
|
|
360
|
-
return
|
|
360
|
+
if (node.value?.type === AST_NODE_TYPES.JSXExpressionContainer) {
|
|
361
|
+
return VAR3.toStaticValue({
|
|
361
362
|
kind: "lazy",
|
|
362
363
|
node: node.value.expression,
|
|
363
364
|
initialScope
|
|
364
365
|
});
|
|
365
366
|
}
|
|
366
367
|
return { kind: "none", node, initialScope };
|
|
367
|
-
case
|
|
368
|
-
const staticValue =
|
|
368
|
+
case AST_NODE_TYPES.JSXSpreadAttribute: {
|
|
369
|
+
const staticValue = VAR3.toStaticValue({
|
|
369
370
|
kind: "lazy",
|
|
370
371
|
node: node.argument,
|
|
371
372
|
initialScope
|
|
@@ -373,7 +374,7 @@ function getAttributeValue(context, node, name) {
|
|
|
373
374
|
if (staticValue.kind === "none") {
|
|
374
375
|
return staticValue;
|
|
375
376
|
}
|
|
376
|
-
return
|
|
377
|
+
return match(staticValue.value).with({ [name]: P.select(P.any) }, (value) => ({
|
|
377
378
|
kind: "some",
|
|
378
379
|
node: node.argument,
|
|
379
380
|
initialScope,
|
|
@@ -405,13 +406,13 @@ var DEFAULT_JSX_DETECTION_HINT = 0n | JSXDetectionHint.SkipUndefined | JSXDetect
|
|
|
405
406
|
// src/jsx/jsx-detection.ts
|
|
406
407
|
function isJsxText(node) {
|
|
407
408
|
if (node == null) return false;
|
|
408
|
-
return node.type ===
|
|
409
|
+
return node.type === AST_NODE_TYPES.JSXText || node.type === AST_NODE_TYPES.Literal;
|
|
409
410
|
}
|
|
410
411
|
function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
411
412
|
if (node == null) return false;
|
|
412
|
-
if (
|
|
413
|
+
if (AST14.isJSX(node)) return true;
|
|
413
414
|
switch (node.type) {
|
|
414
|
-
case
|
|
415
|
+
case AST_NODE_TYPES.Literal: {
|
|
415
416
|
switch (typeof node.value) {
|
|
416
417
|
case "boolean":
|
|
417
418
|
return !(hint & JSXDetectionHint.SkipBooleanLiteral);
|
|
@@ -427,10 +428,10 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
427
428
|
}
|
|
428
429
|
return false;
|
|
429
430
|
}
|
|
430
|
-
case
|
|
431
|
+
case AST_NODE_TYPES.TemplateLiteral: {
|
|
431
432
|
return !(hint & JSXDetectionHint.SkipStringLiteral);
|
|
432
433
|
}
|
|
433
|
-
case
|
|
434
|
+
case AST_NODE_TYPES.ArrayExpression: {
|
|
434
435
|
if (node.elements.length === 0) {
|
|
435
436
|
return !(hint & JSXDetectionHint.SkipEmptyArray);
|
|
436
437
|
}
|
|
@@ -439,13 +440,13 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
439
440
|
}
|
|
440
441
|
return node.elements.some((n) => isJsxLike(code, n, hint));
|
|
441
442
|
}
|
|
442
|
-
case
|
|
443
|
+
case AST_NODE_TYPES.LogicalExpression: {
|
|
443
444
|
if (hint & JSXDetectionHint.StrictLogical) {
|
|
444
445
|
return isJsxLike(code, node.left, hint) && isJsxLike(code, node.right, hint);
|
|
445
446
|
}
|
|
446
447
|
return isJsxLike(code, node.left, hint) || isJsxLike(code, node.right, hint);
|
|
447
448
|
}
|
|
448
|
-
case
|
|
449
|
+
case AST_NODE_TYPES.ConditionalExpression: {
|
|
449
450
|
let leftHasJSX2 = function(node2) {
|
|
450
451
|
if (Array.isArray(node2.consequent)) {
|
|
451
452
|
if (node2.consequent.length === 0) {
|
|
@@ -465,39 +466,39 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
465
466
|
}
|
|
466
467
|
return leftHasJSX2(node) || rightHasJSX2(node);
|
|
467
468
|
}
|
|
468
|
-
case
|
|
469
|
+
case AST_NODE_TYPES.SequenceExpression: {
|
|
469
470
|
const exp = node.expressions.at(-1);
|
|
470
471
|
return isJsxLike(code, exp, hint);
|
|
471
472
|
}
|
|
472
|
-
case
|
|
473
|
+
case AST_NODE_TYPES.CallExpression: {
|
|
473
474
|
if (hint & JSXDetectionHint.SkipCreateElement) {
|
|
474
475
|
return false;
|
|
475
476
|
}
|
|
476
477
|
switch (node.callee.type) {
|
|
477
|
-
case
|
|
478
|
+
case AST_NODE_TYPES.Identifier:
|
|
478
479
|
return node.callee.name === "createElement";
|
|
479
|
-
case
|
|
480
|
-
return node.callee.property.type ===
|
|
480
|
+
case AST_NODE_TYPES.MemberExpression:
|
|
481
|
+
return node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "createElement";
|
|
481
482
|
}
|
|
482
483
|
return false;
|
|
483
484
|
}
|
|
484
|
-
case
|
|
485
|
+
case AST_NODE_TYPES.Identifier: {
|
|
485
486
|
const { name } = node;
|
|
486
487
|
if (name === "undefined") {
|
|
487
488
|
return !(hint & JSXDetectionHint.SkipUndefined);
|
|
488
489
|
}
|
|
489
|
-
if (
|
|
490
|
+
if (AST14.isJSXTagNameExpression(node)) {
|
|
490
491
|
return true;
|
|
491
492
|
}
|
|
492
|
-
const variable =
|
|
493
|
-
const variableNode = variable &&
|
|
493
|
+
const variable = VAR3.findVariable(name, code.getScope(node));
|
|
494
|
+
const variableNode = variable && VAR3.getVariableInitNode(variable, 0);
|
|
494
495
|
return !!variableNode && isJsxLike(code, variableNode, hint);
|
|
495
496
|
}
|
|
496
497
|
}
|
|
497
498
|
return false;
|
|
498
499
|
}
|
|
499
500
|
function getElementType(context, node) {
|
|
500
|
-
if (node.type ===
|
|
501
|
+
if (node.type === AST_NODE_TYPES.JSXFragment) {
|
|
501
502
|
return "";
|
|
502
503
|
}
|
|
503
504
|
return stringifyJsx(node.openingElement.name);
|
|
@@ -513,22 +514,22 @@ function hasAnyAttribute(context, names, attributes, initialScope) {
|
|
|
513
514
|
function hasEveryAttribute(context, names, attributes, initialScope) {
|
|
514
515
|
return names.every((n) => hasAttribute(context, n, attributes, initialScope));
|
|
515
516
|
}
|
|
516
|
-
function findParentAttribute(node, test =
|
|
517
|
+
function findParentAttribute(node, test = constTrue) {
|
|
517
518
|
const guard = (node2) => {
|
|
518
|
-
return node2.type ===
|
|
519
|
+
return node2.type === AST_NODE_TYPES.JSXAttribute && test(node2);
|
|
519
520
|
};
|
|
520
|
-
return
|
|
521
|
+
return AST14.findParentNode(node, guard);
|
|
521
522
|
}
|
|
522
523
|
function isHostElement(context, node) {
|
|
523
|
-
return node.type ===
|
|
524
|
+
return node.type === AST_NODE_TYPES.JSXElement && node.openingElement.name.type === AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.openingElement.name.name);
|
|
524
525
|
}
|
|
525
526
|
function isKeyedElement(context, node, initialScope) {
|
|
526
|
-
return node.type ===
|
|
527
|
+
return node.type === AST_NODE_TYPES.JSXElement && hasAttribute(context, "key", node.openingElement.attributes, initialScope);
|
|
527
528
|
}
|
|
528
529
|
function isFragmentElement(context, node, allowJSXFragment = false) {
|
|
529
530
|
if (node == null) return false;
|
|
530
|
-
if (node.type !==
|
|
531
|
-
if (node.type ===
|
|
531
|
+
if (node.type !== AST_NODE_TYPES.JSXElement && node.type !== AST_NODE_TYPES.JSXFragment) return false;
|
|
532
|
+
if (node.type === AST_NODE_TYPES.JSXFragment) return allowJSXFragment;
|
|
532
533
|
return getElementType(context, node).split(".").at(-1) === "Fragment";
|
|
533
534
|
}
|
|
534
535
|
|
|
@@ -568,9 +569,9 @@ function isClassComponent(node) {
|
|
|
568
569
|
if ("superClass" in node && node.superClass != null) {
|
|
569
570
|
const re = /^(?:Pure)?Component$/u;
|
|
570
571
|
switch (true) {
|
|
571
|
-
case node.superClass.type ===
|
|
572
|
+
case node.superClass.type === AST_NODE_TYPES.Identifier:
|
|
572
573
|
return re.test(node.superClass.name);
|
|
573
|
-
case (node.superClass.type ===
|
|
574
|
+
case (node.superClass.type === AST_NODE_TYPES.MemberExpression && node.superClass.property.type === AST_NODE_TYPES.Identifier):
|
|
574
575
|
return re.test(node.superClass.property.name);
|
|
575
576
|
}
|
|
576
577
|
}
|
|
@@ -580,119 +581,42 @@ function isPureComponent(node) {
|
|
|
580
581
|
if ("superClass" in node && node.superClass != null) {
|
|
581
582
|
const re = /^PureComponent$/u;
|
|
582
583
|
switch (true) {
|
|
583
|
-
case node.superClass.type ===
|
|
584
|
+
case node.superClass.type === AST_NODE_TYPES.Identifier:
|
|
584
585
|
return re.test(node.superClass.name);
|
|
585
|
-
case (node.superClass.type ===
|
|
586
|
+
case (node.superClass.type === AST_NODE_TYPES.MemberExpression && node.superClass.property.type === AST_NODE_TYPES.Identifier):
|
|
586
587
|
return re.test(node.superClass.property.name);
|
|
587
588
|
}
|
|
588
589
|
}
|
|
589
590
|
return false;
|
|
590
591
|
}
|
|
591
|
-
function isComponentDidCatch(node) {
|
|
592
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
|
|
593
|
-
}
|
|
594
|
-
function isComponentDidMount(node) {
|
|
595
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
596
|
-
}
|
|
597
|
-
function isComponentDidUpdate(node) {
|
|
598
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
599
|
-
}
|
|
600
|
-
function isComponentWillMount(node) {
|
|
601
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillMount";
|
|
602
|
-
}
|
|
603
|
-
function isComponentWillReceiveProps(node) {
|
|
604
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillReceiveProps";
|
|
605
|
-
}
|
|
606
|
-
function isComponentWillUnmount(node) {
|
|
607
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
|
|
608
|
-
}
|
|
609
|
-
function isComponentWillUpdate(node) {
|
|
610
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
611
|
-
}
|
|
612
|
-
function isGetChildContext(node) {
|
|
613
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getChildContext";
|
|
614
|
-
}
|
|
615
|
-
function isGetDefaultProps(node) {
|
|
616
|
-
return AST9__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDefaultProps";
|
|
617
|
-
}
|
|
618
|
-
function isGetInitialState(node) {
|
|
619
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getInitialState";
|
|
620
|
-
}
|
|
621
|
-
function isGetSnapshotBeforeUpdate(node) {
|
|
622
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getSnapshotBeforeUpdate";
|
|
623
|
-
}
|
|
624
|
-
function isShouldComponentUpdate(node) {
|
|
625
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
626
|
-
}
|
|
627
|
-
function isUnsafeComponentWillMount(node) {
|
|
628
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
629
|
-
}
|
|
630
|
-
function isUnsafeComponentWillReceiveProps(node) {
|
|
631
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
632
|
-
}
|
|
633
|
-
function isUnsafeComponentWillUpdate(node) {
|
|
634
|
-
return AST9__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
635
|
-
}
|
|
636
|
-
function isGetDerivedStateFromProps(node) {
|
|
637
|
-
return AST9__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
|
|
638
|
-
}
|
|
639
|
-
function isGetDerivedStateFromError(node) {
|
|
640
|
-
return AST9__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
|
|
641
|
-
}
|
|
642
|
-
function isRenderLike(node) {
|
|
643
|
-
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;
|
|
644
|
-
}
|
|
645
|
-
function isFunctionOfRender(node) {
|
|
646
|
-
if (!isRenderLike(node.parent)) {
|
|
647
|
-
return false;
|
|
648
|
-
}
|
|
649
|
-
return isClassComponent(node.parent.parent.parent);
|
|
650
|
-
}
|
|
651
592
|
function isRenderMethodLike(node) {
|
|
652
|
-
return
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
// src/component/component-hierarchy.ts
|
|
656
|
-
function isChildrenOfCreateElement(context, node) {
|
|
657
|
-
const parent = node.parent;
|
|
658
|
-
if (parent == null || parent.type !== types.AST_NODE_TYPES.CallExpression) return false;
|
|
659
|
-
if (!isCreateElementCall(context, parent)) return false;
|
|
660
|
-
return parent.arguments.slice(2).some((arg) => arg === node);
|
|
661
|
-
}
|
|
662
|
-
function isInsideRenderMethod(node) {
|
|
663
|
-
return AST9__namespace.findParentNode(node, (n) => isRenderLike(n) && isClassComponent(n.parent.parent)) != null;
|
|
664
|
-
}
|
|
665
|
-
function isFunctionOfComponentDidMount(node) {
|
|
666
|
-
return AST9__namespace.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
|
|
667
|
-
}
|
|
668
|
-
function isFunctionOfComponentWillUnmount(node) {
|
|
669
|
-
return AST9__namespace.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
|
|
670
|
-
}
|
|
671
|
-
function isFunctionOfRenderMethod(node) {
|
|
672
|
-
if (!isRenderMethodLike(node.parent)) {
|
|
673
|
-
return false;
|
|
674
|
-
}
|
|
675
|
-
return isClassComponent(node.parent.parent.parent);
|
|
593
|
+
return AST14.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name.startsWith("render") && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
|
|
676
594
|
}
|
|
677
595
|
|
|
678
596
|
// src/component/component-definition.ts
|
|
679
|
-
var isFunctionOfClassMethod =
|
|
680
|
-
type:
|
|
681
|
-
parent:
|
|
597
|
+
var isFunctionOfClassMethod = isMatching({
|
|
598
|
+
type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
|
|
599
|
+
parent: AST_NODE_TYPES.MethodDefinition
|
|
682
600
|
});
|
|
683
|
-
var isFunctionOfClassProperty =
|
|
684
|
-
type:
|
|
685
|
-
parent:
|
|
601
|
+
var isFunctionOfClassProperty = isMatching({
|
|
602
|
+
type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
|
|
603
|
+
parent: AST_NODE_TYPES.Property
|
|
686
604
|
});
|
|
687
|
-
var isFunctionOfObjectMethod =
|
|
688
|
-
type:
|
|
605
|
+
var isFunctionOfObjectMethod = isMatching({
|
|
606
|
+
type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
|
|
689
607
|
parent: {
|
|
690
|
-
type:
|
|
608
|
+
type: AST_NODE_TYPES.Property,
|
|
691
609
|
parent: {
|
|
692
|
-
type:
|
|
610
|
+
type: AST_NODE_TYPES.ObjectExpression
|
|
693
611
|
}
|
|
694
612
|
}
|
|
695
613
|
});
|
|
614
|
+
function isFunctionOfRenderMethod(node) {
|
|
615
|
+
if (!isRenderMethodLike(node.parent)) {
|
|
616
|
+
return false;
|
|
617
|
+
}
|
|
618
|
+
return isClassComponent(node.parent.parent.parent);
|
|
619
|
+
}
|
|
696
620
|
function isValidComponentDefinition(context, node, hint) {
|
|
697
621
|
if (isChildrenOfCreateElement(context, node) || isFunctionOfRenderMethod(node)) {
|
|
698
622
|
return false;
|
|
@@ -706,44 +630,44 @@ function isValidComponentDefinition(context, node, hint) {
|
|
|
706
630
|
if (hint & ComponentDetectionHint.SkipClassProperty && isFunctionOfClassProperty(node.parent)) {
|
|
707
631
|
return false;
|
|
708
632
|
}
|
|
709
|
-
if (hint & ComponentDetectionHint.SkipArrayMapArgument &&
|
|
633
|
+
if (hint & ComponentDetectionHint.SkipArrayMapArgument && AST14.isArrayMapCall(node.parent)) {
|
|
710
634
|
return false;
|
|
711
635
|
}
|
|
712
|
-
const significantParent =
|
|
636
|
+
const significantParent = AST14.findParentNode(
|
|
713
637
|
node,
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
638
|
+
AST14.isOneOf([
|
|
639
|
+
AST_NODE_TYPES.JSXExpressionContainer,
|
|
640
|
+
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
641
|
+
AST_NODE_TYPES.FunctionExpression,
|
|
642
|
+
AST_NODE_TYPES.Property,
|
|
643
|
+
AST_NODE_TYPES.ClassBody
|
|
720
644
|
])
|
|
721
645
|
);
|
|
722
|
-
return significantParent == null || significantParent.type !==
|
|
646
|
+
return significantParent == null || significantParent.type !== AST_NODE_TYPES.JSXExpressionContainer;
|
|
723
647
|
}
|
|
724
648
|
function isComponentWrapperCall(context, node) {
|
|
725
|
-
if (node.type !==
|
|
649
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
726
650
|
return isMemoCall(context, node) || isForwardRefCall(context, node);
|
|
727
651
|
}
|
|
728
652
|
function isComponentWrapperCallLoose(context, node) {
|
|
729
|
-
if (node.type !==
|
|
653
|
+
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
730
654
|
return isComponentWrapperCall(context, node) || isUseCallbackCall(context, node);
|
|
731
655
|
}
|
|
732
656
|
|
|
733
657
|
// src/component/component-id.ts
|
|
734
658
|
function getFunctionComponentId(context, node) {
|
|
735
|
-
const functionId =
|
|
659
|
+
const functionId = AST14.getFunctionId(node);
|
|
736
660
|
if (functionId != null) {
|
|
737
661
|
return functionId;
|
|
738
662
|
}
|
|
739
663
|
const { parent } = node;
|
|
740
|
-
if (parent.type ===
|
|
664
|
+
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) {
|
|
741
665
|
return parent.parent.id;
|
|
742
666
|
}
|
|
743
|
-
if (parent.type ===
|
|
667
|
+
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) {
|
|
744
668
|
return parent.parent.parent.id;
|
|
745
669
|
}
|
|
746
|
-
return
|
|
670
|
+
return unit;
|
|
747
671
|
}
|
|
748
672
|
|
|
749
673
|
// src/component/component-flag.ts
|
|
@@ -759,22 +683,22 @@ var ComponentFlag = {
|
|
|
759
683
|
// src/component/component-init-path.ts
|
|
760
684
|
function getComponentFlagFromInitPath(initPath) {
|
|
761
685
|
let flag = ComponentFlag.None;
|
|
762
|
-
if (initPath != null &&
|
|
686
|
+
if (initPath != null && AST14.hasCallInFunctionInitPath("memo", initPath)) {
|
|
763
687
|
flag |= ComponentFlag.Memo;
|
|
764
688
|
}
|
|
765
|
-
if (initPath != null &&
|
|
689
|
+
if (initPath != null && AST14.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
766
690
|
flag |= ComponentFlag.ForwardRef;
|
|
767
691
|
}
|
|
768
692
|
return flag;
|
|
769
693
|
}
|
|
770
694
|
function isComponentName(name) {
|
|
771
|
-
return
|
|
695
|
+
return RegExp.COMPONENT_NAME.test(name);
|
|
772
696
|
}
|
|
773
697
|
function isComponentNameLoose(name) {
|
|
774
|
-
return
|
|
698
|
+
return RegExp.COMPONENT_NAME_LOOSE.test(name);
|
|
775
699
|
}
|
|
776
700
|
function getComponentNameFromId(id) {
|
|
777
|
-
if (id == null) return
|
|
701
|
+
if (id == null) return unit;
|
|
778
702
|
return Array.isArray(id) ? id.map((n) => n.name).join(".") : id.name;
|
|
779
703
|
}
|
|
780
704
|
function hasNoneOrLooseComponentName(context, fn) {
|
|
@@ -795,14 +719,14 @@ function useComponentCollector(context, options = {}) {
|
|
|
795
719
|
const functionEntries = [];
|
|
796
720
|
const getCurrentEntry = () => functionEntries.at(-1);
|
|
797
721
|
const onFunctionEnter = (node) => {
|
|
798
|
-
const key =
|
|
722
|
+
const key = getId();
|
|
799
723
|
functionEntries.push({ key, node, hookCalls: [], isComponent: false });
|
|
800
724
|
};
|
|
801
725
|
const onFunctionExit = () => {
|
|
802
726
|
const entry = functionEntries.at(-1);
|
|
803
727
|
if (entry == null) return;
|
|
804
728
|
if (!entry.isComponent) return functionEntries.pop();
|
|
805
|
-
const rets =
|
|
729
|
+
const rets = AST14.getNestedReturnStatements(entry.node.body);
|
|
806
730
|
for (let i = rets.length - 1; i >= 0; i--) {
|
|
807
731
|
const ret = rets[i];
|
|
808
732
|
if (ret == null) continue;
|
|
@@ -833,17 +757,17 @@ function useComponentCollector(context, options = {}) {
|
|
|
833
757
|
const { body } = entry.node;
|
|
834
758
|
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, body, hint) && isValidComponentDefinition(context, entry.node, hint);
|
|
835
759
|
if (!isComponent) return;
|
|
836
|
-
const initPath =
|
|
760
|
+
const initPath = AST14.getFunctionInitPath(entry.node);
|
|
837
761
|
const id = getFunctionComponentId(context, entry.node);
|
|
838
762
|
const name = getComponentNameFromId(id);
|
|
839
|
-
const key =
|
|
763
|
+
const key = getId();
|
|
840
764
|
components.set(key, {
|
|
841
765
|
id,
|
|
842
766
|
key,
|
|
843
767
|
kind: "function",
|
|
844
768
|
name,
|
|
845
769
|
node: entry.node,
|
|
846
|
-
displayName:
|
|
770
|
+
displayName: unit,
|
|
847
771
|
flag: getComponentFlagFromInitPath(initPath),
|
|
848
772
|
hint,
|
|
849
773
|
hookCalls: entry.hookCalls,
|
|
@@ -851,10 +775,10 @@ function useComponentCollector(context, options = {}) {
|
|
|
851
775
|
});
|
|
852
776
|
},
|
|
853
777
|
...collectDisplayName ? {
|
|
854
|
-
[
|
|
778
|
+
[Selector.DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
|
|
855
779
|
const { left, right } = node;
|
|
856
|
-
if (left.type !==
|
|
857
|
-
const componentName = left.object.type ===
|
|
780
|
+
if (left.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
781
|
+
const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : unit;
|
|
858
782
|
const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
|
|
859
783
|
if (component == null) return;
|
|
860
784
|
component.displayName = right;
|
|
@@ -874,7 +798,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
874
798
|
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, node.argument, hint) && isValidComponentDefinition(context, entry.node, hint);
|
|
875
799
|
if (!isComponent) return;
|
|
876
800
|
entry.isComponent = true;
|
|
877
|
-
const initPath =
|
|
801
|
+
const initPath = AST14.getFunctionInitPath(entry.node);
|
|
878
802
|
const id = getFunctionComponentId(context, entry.node);
|
|
879
803
|
const name = getComponentNameFromId(id);
|
|
880
804
|
components.set(entry.key, {
|
|
@@ -883,7 +807,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
883
807
|
kind: "function",
|
|
884
808
|
name,
|
|
885
809
|
node: entry.node,
|
|
886
|
-
displayName:
|
|
810
|
+
displayName: unit,
|
|
887
811
|
flag: getComponentFlagFromInitPath(initPath),
|
|
888
812
|
hint,
|
|
889
813
|
hookCalls: entry.hookCalls,
|
|
@@ -905,8 +829,8 @@ function useComponentCollectorLegacy() {
|
|
|
905
829
|
if (!isClassComponent(node)) {
|
|
906
830
|
return;
|
|
907
831
|
}
|
|
908
|
-
const id =
|
|
909
|
-
const key =
|
|
832
|
+
const id = AST14.getClassId(node);
|
|
833
|
+
const key = getId();
|
|
910
834
|
const flag = isPureComponent(node) ? ComponentFlag.PureComponent : ComponentFlag.None;
|
|
911
835
|
components.set(
|
|
912
836
|
key,
|
|
@@ -917,7 +841,7 @@ function useComponentCollectorLegacy() {
|
|
|
917
841
|
name: id?.name,
|
|
918
842
|
node,
|
|
919
843
|
// TODO: Get displayName of class component
|
|
920
|
-
displayName:
|
|
844
|
+
displayName: unit,
|
|
921
845
|
flag,
|
|
922
846
|
hint: 0n,
|
|
923
847
|
// TODO: Get methods of class component
|
|
@@ -931,15 +855,75 @@ function useComponentCollectorLegacy() {
|
|
|
931
855
|
};
|
|
932
856
|
return { ctx, listeners };
|
|
933
857
|
}
|
|
934
|
-
|
|
858
|
+
function isComponentDidCatch(node) {
|
|
859
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
|
|
860
|
+
}
|
|
861
|
+
function isComponentDidMount(node) {
|
|
862
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
863
|
+
}
|
|
864
|
+
function isComponentDidUpdate(node) {
|
|
865
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
|
|
866
|
+
}
|
|
867
|
+
function isComponentWillMount(node) {
|
|
868
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillMount";
|
|
869
|
+
}
|
|
870
|
+
function isComponentWillReceiveProps(node) {
|
|
871
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillReceiveProps";
|
|
872
|
+
}
|
|
873
|
+
function isComponentWillUnmount(node) {
|
|
874
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
|
|
875
|
+
}
|
|
876
|
+
function isComponentWillUpdate(node) {
|
|
877
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
|
|
878
|
+
}
|
|
879
|
+
function isGetChildContext(node) {
|
|
880
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getChildContext";
|
|
881
|
+
}
|
|
882
|
+
function isGetDefaultProps(node) {
|
|
883
|
+
return AST14.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDefaultProps";
|
|
884
|
+
}
|
|
885
|
+
function isGetInitialState(node) {
|
|
886
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getInitialState";
|
|
887
|
+
}
|
|
888
|
+
function isGetSnapshotBeforeUpdate(node) {
|
|
889
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getSnapshotBeforeUpdate";
|
|
890
|
+
}
|
|
891
|
+
function isShouldComponentUpdate(node) {
|
|
892
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
|
|
893
|
+
}
|
|
894
|
+
function isUnsafeComponentWillMount(node) {
|
|
895
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
|
|
896
|
+
}
|
|
897
|
+
function isUnsafeComponentWillReceiveProps(node) {
|
|
898
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
|
|
899
|
+
}
|
|
900
|
+
function isUnsafeComponentWillUpdate(node) {
|
|
901
|
+
return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
|
|
902
|
+
}
|
|
903
|
+
function isGetDerivedStateFromProps(node) {
|
|
904
|
+
return AST14.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
|
|
905
|
+
}
|
|
906
|
+
function isGetDerivedStateFromError(node) {
|
|
907
|
+
return AST14.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
|
|
908
|
+
}
|
|
909
|
+
var ComponentPhaseRelevance = birecord({
|
|
935
910
|
mount: "unmount",
|
|
936
911
|
setup: "cleanup"
|
|
937
912
|
});
|
|
938
|
-
var isInversePhase =
|
|
913
|
+
var isInversePhase = dual(2, (a, b) => ComponentPhaseRelevance.get(a) === b);
|
|
914
|
+
function isRenderLike(node) {
|
|
915
|
+
return AST14.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
|
|
916
|
+
}
|
|
917
|
+
function isFunctionOfRender(node) {
|
|
918
|
+
if (!isRenderLike(node.parent)) {
|
|
919
|
+
return false;
|
|
920
|
+
}
|
|
921
|
+
return isClassComponent(node.parent.parent.parent);
|
|
922
|
+
}
|
|
939
923
|
function isRenderFunctionLoose(context, node) {
|
|
940
924
|
const { body, parent } = node;
|
|
941
|
-
if (
|
|
942
|
-
return parent.type ===
|
|
925
|
+
if (AST14.getFunctionId(node)?.name.startsWith("render")) {
|
|
926
|
+
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");
|
|
943
927
|
}
|
|
944
928
|
return isJsxLike(
|
|
945
929
|
context.sourceCode,
|
|
@@ -948,14 +932,14 @@ function isRenderFunctionLoose(context, node) {
|
|
|
948
932
|
);
|
|
949
933
|
}
|
|
950
934
|
function isRenderPropLoose(context, node) {
|
|
951
|
-
if (node.name.type !==
|
|
935
|
+
if (node.name.type !== AST_NODE_TYPES.JSXIdentifier) {
|
|
952
936
|
return false;
|
|
953
937
|
}
|
|
954
|
-
return node.name.name.startsWith("render") && node.value?.type ===
|
|
938
|
+
return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && AST14.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression);
|
|
955
939
|
}
|
|
956
940
|
function isDirectValueOfRenderPropertyLoose(node) {
|
|
957
941
|
const matching = (node2) => {
|
|
958
|
-
return node2.type ===
|
|
942
|
+
return node2.type === AST_NODE_TYPES.Property && node2.key.type === AST_NODE_TYPES.Identifier && node2.key.name.startsWith("render");
|
|
959
943
|
};
|
|
960
944
|
return matching(node) || node.parent != null && matching(node.parent);
|
|
961
945
|
}
|
|
@@ -963,143 +947,19 @@ function isDeclaredInRenderPropLoose(node) {
|
|
|
963
947
|
if (isDirectValueOfRenderPropertyLoose(node)) {
|
|
964
948
|
return true;
|
|
965
949
|
}
|
|
966
|
-
const parent =
|
|
967
|
-
if (parent?.type !==
|
|
950
|
+
const parent = AST14.findParentNode(node, AST14.is(AST_NODE_TYPES.JSXExpressionContainer))?.parent;
|
|
951
|
+
if (parent?.type !== AST_NODE_TYPES.JSXAttribute) {
|
|
968
952
|
return false;
|
|
969
953
|
}
|
|
970
|
-
return parent.name.type ===
|
|
954
|
+
return parent.name.type === AST_NODE_TYPES.JSXIdentifier && parent.name.name.startsWith("render");
|
|
971
955
|
}
|
|
972
956
|
function isThisSetState(node) {
|
|
973
957
|
const { callee } = node;
|
|
974
|
-
return callee.type ===
|
|
958
|
+
return callee.type === AST_NODE_TYPES.MemberExpression && AST14.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
|
|
975
959
|
}
|
|
976
960
|
function isAssignmentToThisState(node) {
|
|
977
961
|
const { left } = node;
|
|
978
|
-
return left.type ===
|
|
962
|
+
return left.type === AST_NODE_TYPES.MemberExpression && AST14.isThisExpression(left.object) && AST14.getPropertyName(left.property) === "state";
|
|
979
963
|
}
|
|
980
964
|
|
|
981
|
-
|
|
982
|
-
exports.ComponentFlag = ComponentFlag;
|
|
983
|
-
exports.ComponentPhaseRelevance = ComponentPhaseRelevance;
|
|
984
|
-
exports.DEFAULT_COMPONENT_DETECTION_HINT = DEFAULT_COMPONENT_DETECTION_HINT;
|
|
985
|
-
exports.DEFAULT_JSX_DETECTION_HINT = DEFAULT_JSX_DETECTION_HINT;
|
|
986
|
-
exports.JSXDetectionHint = JSXDetectionHint;
|
|
987
|
-
exports.findParentAttribute = findParentAttribute;
|
|
988
|
-
exports.getAttribute = getAttribute;
|
|
989
|
-
exports.getAttributeName = getAttributeName;
|
|
990
|
-
exports.getAttributeValue = getAttributeValue;
|
|
991
|
-
exports.getComponentFlagFromInitPath = getComponentFlagFromInitPath;
|
|
992
|
-
exports.getComponentNameFromId = getComponentNameFromId;
|
|
993
|
-
exports.getElementType = getElementType;
|
|
994
|
-
exports.getFunctionComponentId = getFunctionComponentId;
|
|
995
|
-
exports.getInstanceId = getInstanceId;
|
|
996
|
-
exports.hasAnyAttribute = hasAnyAttribute;
|
|
997
|
-
exports.hasAttribute = hasAttribute;
|
|
998
|
-
exports.hasEveryAttribute = hasEveryAttribute;
|
|
999
|
-
exports.hasNoneOrLooseComponentName = hasNoneOrLooseComponentName;
|
|
1000
|
-
exports.isAssignmentToThisState = isAssignmentToThisState;
|
|
1001
|
-
exports.isCaptureOwnerStack = isCaptureOwnerStack;
|
|
1002
|
-
exports.isCaptureOwnerStackCall = isCaptureOwnerStackCall;
|
|
1003
|
-
exports.isChildrenCount = isChildrenCount;
|
|
1004
|
-
exports.isChildrenCountCall = isChildrenCountCall;
|
|
1005
|
-
exports.isChildrenForEach = isChildrenForEach;
|
|
1006
|
-
exports.isChildrenForEachCall = isChildrenForEachCall;
|
|
1007
|
-
exports.isChildrenMap = isChildrenMap;
|
|
1008
|
-
exports.isChildrenMapCall = isChildrenMapCall;
|
|
1009
|
-
exports.isChildrenOfCreateElement = isChildrenOfCreateElement;
|
|
1010
|
-
exports.isChildrenOnly = isChildrenOnly;
|
|
1011
|
-
exports.isChildrenOnlyCall = isChildrenOnlyCall;
|
|
1012
|
-
exports.isChildrenToArray = isChildrenToArray;
|
|
1013
|
-
exports.isChildrenToArrayCall = isChildrenToArrayCall;
|
|
1014
|
-
exports.isClassComponent = isClassComponent;
|
|
1015
|
-
exports.isCloneElement = isCloneElement;
|
|
1016
|
-
exports.isCloneElementCall = isCloneElementCall;
|
|
1017
|
-
exports.isComponentDidCatch = isComponentDidCatch;
|
|
1018
|
-
exports.isComponentDidMount = isComponentDidMount;
|
|
1019
|
-
exports.isComponentDidUpdate = isComponentDidUpdate;
|
|
1020
|
-
exports.isComponentName = isComponentName;
|
|
1021
|
-
exports.isComponentNameLoose = isComponentNameLoose;
|
|
1022
|
-
exports.isComponentWillMount = isComponentWillMount;
|
|
1023
|
-
exports.isComponentWillReceiveProps = isComponentWillReceiveProps;
|
|
1024
|
-
exports.isComponentWillUnmount = isComponentWillUnmount;
|
|
1025
|
-
exports.isComponentWillUpdate = isComponentWillUpdate;
|
|
1026
|
-
exports.isComponentWrapperCall = isComponentWrapperCall;
|
|
1027
|
-
exports.isComponentWrapperCallLoose = isComponentWrapperCallLoose;
|
|
1028
|
-
exports.isCreateContext = isCreateContext;
|
|
1029
|
-
exports.isCreateContextCall = isCreateContextCall;
|
|
1030
|
-
exports.isCreateElement = isCreateElement;
|
|
1031
|
-
exports.isCreateElementCall = isCreateElementCall;
|
|
1032
|
-
exports.isCreateRef = isCreateRef;
|
|
1033
|
-
exports.isCreateRefCall = isCreateRefCall;
|
|
1034
|
-
exports.isDeclaredInRenderPropLoose = isDeclaredInRenderPropLoose;
|
|
1035
|
-
exports.isDirectValueOfRenderPropertyLoose = isDirectValueOfRenderPropertyLoose;
|
|
1036
|
-
exports.isForwardRef = isForwardRef;
|
|
1037
|
-
exports.isForwardRefCall = isForwardRefCall;
|
|
1038
|
-
exports.isFragmentElement = isFragmentElement;
|
|
1039
|
-
exports.isFunctionOfComponentDidMount = isFunctionOfComponentDidMount;
|
|
1040
|
-
exports.isFunctionOfComponentWillUnmount = isFunctionOfComponentWillUnmount;
|
|
1041
|
-
exports.isFunctionOfRender = isFunctionOfRender;
|
|
1042
|
-
exports.isFunctionOfRenderMethod = isFunctionOfRenderMethod;
|
|
1043
|
-
exports.isFunctionOfUseEffectCleanup = isFunctionOfUseEffectCleanup;
|
|
1044
|
-
exports.isFunctionOfUseEffectSetup = isFunctionOfUseEffectSetup;
|
|
1045
|
-
exports.isGetChildContext = isGetChildContext;
|
|
1046
|
-
exports.isGetDefaultProps = isGetDefaultProps;
|
|
1047
|
-
exports.isGetDerivedStateFromError = isGetDerivedStateFromError;
|
|
1048
|
-
exports.isGetDerivedStateFromProps = isGetDerivedStateFromProps;
|
|
1049
|
-
exports.isGetInitialState = isGetInitialState;
|
|
1050
|
-
exports.isGetSnapshotBeforeUpdate = isGetSnapshotBeforeUpdate;
|
|
1051
|
-
exports.isHostElement = isHostElement;
|
|
1052
|
-
exports.isInitializedFromReact = isInitializedFromReact;
|
|
1053
|
-
exports.isInsideRenderMethod = isInsideRenderMethod;
|
|
1054
|
-
exports.isInstanceIdEqual = isInstanceIdEqual;
|
|
1055
|
-
exports.isInversePhase = isInversePhase;
|
|
1056
|
-
exports.isJsxLike = isJsxLike;
|
|
1057
|
-
exports.isJsxText = isJsxText;
|
|
1058
|
-
exports.isKeyedElement = isKeyedElement;
|
|
1059
|
-
exports.isLazy = isLazy;
|
|
1060
|
-
exports.isLazyCall = isLazyCall;
|
|
1061
|
-
exports.isMemo = isMemo;
|
|
1062
|
-
exports.isMemoCall = isMemoCall;
|
|
1063
|
-
exports.isPureComponent = isPureComponent;
|
|
1064
|
-
exports.isReactAPI = isReactAPI;
|
|
1065
|
-
exports.isReactAPICall = isReactAPICall;
|
|
1066
|
-
exports.isReactHook = isReactHook;
|
|
1067
|
-
exports.isReactHookCall = isReactHookCall;
|
|
1068
|
-
exports.isReactHookCallWithName = isReactHookCallWithName;
|
|
1069
|
-
exports.isReactHookCallWithNameAlias = isReactHookCallWithNameAlias;
|
|
1070
|
-
exports.isReactHookCallWithNameLoose = isReactHookCallWithNameLoose;
|
|
1071
|
-
exports.isReactHookName = isReactHookName;
|
|
1072
|
-
exports.isRenderFunctionLoose = isRenderFunctionLoose;
|
|
1073
|
-
exports.isRenderLike = isRenderLike;
|
|
1074
|
-
exports.isRenderMethodLike = isRenderMethodLike;
|
|
1075
|
-
exports.isRenderPropLoose = isRenderPropLoose;
|
|
1076
|
-
exports.isShouldComponentUpdate = isShouldComponentUpdate;
|
|
1077
|
-
exports.isThisSetState = isThisSetState;
|
|
1078
|
-
exports.isUnsafeComponentWillMount = isUnsafeComponentWillMount;
|
|
1079
|
-
exports.isUnsafeComponentWillReceiveProps = isUnsafeComponentWillReceiveProps;
|
|
1080
|
-
exports.isUnsafeComponentWillUpdate = isUnsafeComponentWillUpdate;
|
|
1081
|
-
exports.isUseActionStateCall = isUseActionStateCall;
|
|
1082
|
-
exports.isUseCall = isUseCall;
|
|
1083
|
-
exports.isUseCallbackCall = isUseCallbackCall;
|
|
1084
|
-
exports.isUseContextCall = isUseContextCall;
|
|
1085
|
-
exports.isUseDebugValueCall = isUseDebugValueCall;
|
|
1086
|
-
exports.isUseDeferredValueCall = isUseDeferredValueCall;
|
|
1087
|
-
exports.isUseEffectCall = isUseEffectCall;
|
|
1088
|
-
exports.isUseEffectCallLoose = isUseEffectCallLoose;
|
|
1089
|
-
exports.isUseFormStatusCall = isUseFormStatusCall;
|
|
1090
|
-
exports.isUseIdCall = isUseIdCall;
|
|
1091
|
-
exports.isUseImperativeHandleCall = isUseImperativeHandleCall;
|
|
1092
|
-
exports.isUseInsertionEffectCall = isUseInsertionEffectCall;
|
|
1093
|
-
exports.isUseLayoutEffectCall = isUseLayoutEffectCall;
|
|
1094
|
-
exports.isUseMemoCall = isUseMemoCall;
|
|
1095
|
-
exports.isUseOptimisticCall = isUseOptimisticCall;
|
|
1096
|
-
exports.isUseReducerCall = isUseReducerCall;
|
|
1097
|
-
exports.isUseRefCall = isUseRefCall;
|
|
1098
|
-
exports.isUseStateCall = isUseStateCall;
|
|
1099
|
-
exports.isUseSyncExternalStoreCall = isUseSyncExternalStoreCall;
|
|
1100
|
-
exports.isUseTransitionCall = isUseTransitionCall;
|
|
1101
|
-
exports.isValidComponentDefinition = isValidComponentDefinition;
|
|
1102
|
-
exports.stringifyJsx = stringifyJsx;
|
|
1103
|
-
exports.useComponentCollector = useComponentCollector;
|
|
1104
|
-
exports.useComponentCollectorLegacy = useComponentCollectorLegacy;
|
|
1105
|
-
exports.useHookCollector = useHookCollector;
|
|
965
|
+
export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, REACT_BUILTIN_HOOK_NAMES, 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 };
|