@eslint-react/core 2.7.5-beta.3 → 2.7.5-beta.5
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 +50 -38
- package/dist/index.js +35 -35
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -127,21 +127,6 @@ declare const ComponentDetectionHint: {
|
|
|
127
127
|
*/
|
|
128
128
|
declare const DEFAULT_COMPONENT_DETECTION_HINT: bigint;
|
|
129
129
|
//#endregion
|
|
130
|
-
//#region src/component/component-phase.d.ts
|
|
131
|
-
type ComponentEffectPhaseKind = "cleanup" | "setup";
|
|
132
|
-
type ComponentLifecyclePhaseKind = "mount" | "unmount";
|
|
133
|
-
type ComponentPhaseKind = ComponentEffectPhaseKind | ComponentLifecyclePhaseKind;
|
|
134
|
-
declare const ComponentPhaseRelevance: birecord0.BiRecord<{
|
|
135
|
-
readonly mount: "unmount";
|
|
136
|
-
readonly setup: "cleanup";
|
|
137
|
-
}>;
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region src/semantic/semantic-entry.d.ts
|
|
140
|
-
interface SemanticEntry {
|
|
141
|
-
node: TSESTree.Node;
|
|
142
|
-
phase: ComponentPhaseKind;
|
|
143
|
-
}
|
|
144
|
-
//#endregion
|
|
145
130
|
//#region src/semantic/semantic-node.d.ts
|
|
146
131
|
interface SemanticNode {
|
|
147
132
|
id: unit | TSESTree.Node;
|
|
@@ -153,6 +138,18 @@ interface SemanticNode {
|
|
|
153
138
|
hint: bigint;
|
|
154
139
|
}
|
|
155
140
|
//#endregion
|
|
141
|
+
//#region src/semantic/semantic-func.d.ts
|
|
142
|
+
interface SemanticFunc extends SemanticNode {
|
|
143
|
+
id: AST.FunctionID | unit;
|
|
144
|
+
node: AST.TSESTreeFunction;
|
|
145
|
+
name: string | unit;
|
|
146
|
+
type: TSESTree.TSTypeAnnotation | unit;
|
|
147
|
+
body: TSESTree.BlockStatement | TSESTree.Expression;
|
|
148
|
+
directives: TSESTree.StringLiteral[];
|
|
149
|
+
parameters: TSESTree.Parameter[];
|
|
150
|
+
typeParameters: TSESTree.TSTypeParameterDeclaration | unit;
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
156
153
|
//#region src/component/component-flag.d.ts
|
|
157
154
|
type ComponentFlag = bigint;
|
|
158
155
|
declare const ComponentFlag: {
|
|
@@ -168,7 +165,7 @@ declare const ComponentFlag: {
|
|
|
168
165
|
/**
|
|
169
166
|
* Represents a React function component
|
|
170
167
|
*/
|
|
171
|
-
interface
|
|
168
|
+
interface FunctionComponentSemanticNode extends SemanticNode {
|
|
172
169
|
/**
|
|
173
170
|
* The identifier or identifier sequence of the component
|
|
174
171
|
*/
|
|
@@ -217,7 +214,7 @@ interface FunctionComponent extends SemanticNode {
|
|
|
217
214
|
/**
|
|
218
215
|
* Represents a React class component
|
|
219
216
|
*/
|
|
220
|
-
interface
|
|
217
|
+
interface ClassComponentSemanticNode extends SemanticNode {
|
|
221
218
|
/**
|
|
222
219
|
* The identifier of the component
|
|
223
220
|
*/
|
|
@@ -250,7 +247,7 @@ interface ClassComponent extends SemanticNode {
|
|
|
250
247
|
/**
|
|
251
248
|
* Union type representing either a class or function component
|
|
252
249
|
*/
|
|
253
|
-
type
|
|
250
|
+
type ComponentSemanticNode = ClassComponentSemanticNode | FunctionComponentSemanticNode;
|
|
254
251
|
//#endregion
|
|
255
252
|
//#region src/component/component-collector.d.ts
|
|
256
253
|
type FunctionEntry$1 = {
|
|
@@ -271,7 +268,7 @@ declare namespace useComponentCollector {
|
|
|
271
268
|
};
|
|
272
269
|
type ReturnType = {
|
|
273
270
|
ctx: {
|
|
274
|
-
getAllComponents: (node: TSESTree.Program) =>
|
|
271
|
+
getAllComponents: (node: TSESTree.Program) => FunctionComponentSemanticNode[];
|
|
275
272
|
getCurrentEntries: () => FunctionEntry$1[];
|
|
276
273
|
getCurrentEntry: () => FunctionEntry$1 | unit;
|
|
277
274
|
};
|
|
@@ -290,7 +287,7 @@ declare function useComponentCollector(context: RuleContext, options?: useCompon
|
|
|
290
287
|
declare namespace useComponentCollectorLegacy {
|
|
291
288
|
type ReturnType = {
|
|
292
289
|
ctx: {
|
|
293
|
-
getAllComponents: (node: TSESTree$1.Program) =>
|
|
290
|
+
getAllComponents: (node: TSESTree$1.Program) => ClassComponentSemanticNode[];
|
|
294
291
|
};
|
|
295
292
|
visitor: ESLintUtils.RuleListener;
|
|
296
293
|
};
|
|
@@ -329,7 +326,7 @@ declare function isComponentDefinition(context: RuleContext, node: AST.TSESTreeF
|
|
|
329
326
|
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): AST.FunctionID | unit;
|
|
330
327
|
//#endregion
|
|
331
328
|
//#region src/component/component-init-path.d.ts
|
|
332
|
-
declare function getComponentFlagFromInitPath(initPath:
|
|
329
|
+
declare function getComponentFlagFromInitPath(initPath: FunctionComponentSemanticNode["initPath"]): bigint;
|
|
333
330
|
//#endregion
|
|
334
331
|
//#region src/component/component-is.d.ts
|
|
335
332
|
/**
|
|
@@ -400,6 +397,15 @@ declare function isComponentNameLoose(name: string): boolean;
|
|
|
400
397
|
*/
|
|
401
398
|
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
402
399
|
//#endregion
|
|
400
|
+
//#region src/component/component-phase.d.ts
|
|
401
|
+
type ComponentEffectPhaseKind = "cleanup" | "setup";
|
|
402
|
+
type ComponentLifecyclePhaseKind = "mount" | "unmount";
|
|
403
|
+
type ComponentPhaseKind = ComponentEffectPhaseKind | ComponentLifecyclePhaseKind;
|
|
404
|
+
declare const ComponentPhaseRelevance: birecord0.BiRecord<{
|
|
405
|
+
readonly mount: "unmount";
|
|
406
|
+
readonly setup: "cleanup";
|
|
407
|
+
}>;
|
|
408
|
+
//#endregion
|
|
403
409
|
//#region src/component/component-phase-helpers.d.ts
|
|
404
410
|
declare const isInversePhase: {
|
|
405
411
|
(a: ComponentPhaseKind): (b: ComponentPhaseKind) => boolean;
|
|
@@ -504,16 +510,22 @@ declare function isComponentWrapperCallback(context: RuleContext, node: TSESTree
|
|
|
504
510
|
declare function isComponentWrapperCallbackLoose(context: RuleContext, node: TSESTree.Node): boolean;
|
|
505
511
|
//#endregion
|
|
506
512
|
//#region src/function/function-semantic-node.d.ts
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
513
|
+
/**
|
|
514
|
+
* Represents a React function
|
|
515
|
+
*/
|
|
516
|
+
interface ClientFunctionSemanticNode extends SemanticFunc {
|
|
517
|
+
/**
|
|
518
|
+
* The kind of function
|
|
519
|
+
*/
|
|
520
|
+
kind: "client-function";
|
|
521
|
+
}
|
|
522
|
+
interface ServerFunctionSemanticNode extends SemanticFunc {
|
|
523
|
+
/**
|
|
524
|
+
* The kind of function
|
|
525
|
+
*/
|
|
526
|
+
kind: "server-function";
|
|
516
527
|
}
|
|
528
|
+
type FunctionSemanticNode = ClientFunctionSemanticNode | ServerFunctionSemanticNode;
|
|
517
529
|
//#endregion
|
|
518
530
|
//#region src/hierarchy/find-enclosing-component-or-hook.d.ts
|
|
519
531
|
type FindEnclosingComponentOrHookFilter = (n: TSESTree.Node, name: string | null) => boolean;
|
|
@@ -546,7 +558,7 @@ declare function isUseEffectSetupCallback(node: TSESTree.Node | unit): boolean;
|
|
|
546
558
|
declare function isUseEffectCleanupCallback(node: TSESTree.Node | unit): boolean;
|
|
547
559
|
//#endregion
|
|
548
560
|
//#region src/hook/hook-semantic-node.d.ts
|
|
549
|
-
interface
|
|
561
|
+
interface HookSemanticNode extends SemanticNode {
|
|
550
562
|
id: AST.FunctionID | unit;
|
|
551
563
|
node: AST.TSESTreeFunction;
|
|
552
564
|
name: string;
|
|
@@ -562,7 +574,7 @@ type FunctionEntry = {
|
|
|
562
574
|
declare namespace useHookCollector {
|
|
563
575
|
type ReturnType = {
|
|
564
576
|
ctx: {
|
|
565
|
-
getAllHooks(node: TSESTree$1.Program):
|
|
577
|
+
getAllHooks(node: TSESTree$1.Program): HookSemanticNode[];
|
|
566
578
|
getCurrentEntries(): FunctionEntry[];
|
|
567
579
|
getCurrentEntry(): FunctionEntry | unit;
|
|
568
580
|
};
|
|
@@ -577,7 +589,7 @@ declare namespace useHookCollector {
|
|
|
577
589
|
declare function useHookCollector(context: RuleContext): useHookCollector.ReturnType;
|
|
578
590
|
//#endregion
|
|
579
591
|
//#region src/hook/hook-id.d.ts
|
|
580
|
-
declare function
|
|
592
|
+
declare function isHookId(id: TSESTree.Node): id is TSESTree.Identifier | TSESTree.MemberExpression;
|
|
581
593
|
//#endregion
|
|
582
594
|
//#region src/hook/hook-is.d.ts
|
|
583
595
|
/**
|
|
@@ -585,20 +597,20 @@ declare function isReactHookId(id: TSESTree.Node): id is TSESTree.Identifier | T
|
|
|
585
597
|
* @param node The function node to check
|
|
586
598
|
* @returns True if the function is a React Hook, false otherwise
|
|
587
599
|
*/
|
|
588
|
-
declare function
|
|
600
|
+
declare function isHook(node: AST.TSESTreeFunction | unit): boolean;
|
|
589
601
|
/**
|
|
590
602
|
* Check if the given node is a React Hook call by its name.
|
|
591
603
|
* @param node The node to check.
|
|
592
604
|
* @returns `true` if the node is a React Hook call, `false` otherwise.
|
|
593
605
|
*/
|
|
594
|
-
declare function
|
|
606
|
+
declare function isHookCall(node: TSESTree.Node | unit): node is TSESTree.CallExpression;
|
|
595
607
|
/**
|
|
596
608
|
* Checks if a node is a call to a specific React hook.
|
|
597
609
|
* Returns a function that accepts a hook name to check against.
|
|
598
610
|
* @param node The AST node to check
|
|
599
611
|
* @returns A function that takes a hook name and returns boolean
|
|
600
612
|
*/
|
|
601
|
-
declare function
|
|
613
|
+
declare function isHookCallWithName(node: TSESTree.Node | unit): (name: string) => boolean;
|
|
602
614
|
/**
|
|
603
615
|
* Detects useEffect calls and variations (useLayoutEffect, etc.) using regex pattern.
|
|
604
616
|
* @param node The AST node to check
|
|
@@ -641,7 +653,7 @@ declare const REACT_BUILTIN_HOOK_NAMES: readonly ["use", "useActionState", "useC
|
|
|
641
653
|
* @param name The name of the identifier to check.
|
|
642
654
|
* @see https://github.com/facebook/react/blob/1d6c8168db1d82713202e842df3167787ffa00ed/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts#L16
|
|
643
655
|
*/
|
|
644
|
-
declare function
|
|
656
|
+
declare function isHookName(name: string): boolean;
|
|
645
657
|
//#endregion
|
|
646
658
|
//#region src/jsx/jsx-attribute.d.ts
|
|
647
659
|
/**
|
|
@@ -871,4 +883,4 @@ declare function isInitializedFromRef(name: string, initialScope: Scope): boolea
|
|
|
871
883
|
*/
|
|
872
884
|
declare function isRefName(name: string): boolean;
|
|
873
885
|
//#endregion
|
|
874
|
-
export {
|
|
886
|
+
export { ClassComponentSemanticNode, ClientFunctionSemanticNode, ComponentDetectionHint, ComponentEffectPhaseKind, ComponentFlag, ComponentKind, ComponentLifecyclePhaseKind, ComponentPhaseKind, ComponentPhaseRelevance, ComponentSemanticNode, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, FindEnclosingComponentOrHookFilter, FunctionComponentSemanticNode, FunctionSemanticNode, HookSemanticNode, JsxAttributeValue, JsxConfig, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, SemanticFunc, SemanticNode, ServerFunctionSemanticNode, findEnclosingComponentOrHook, findParentJsxAttribute, getComponentFlagFromInitPath, getFunctionComponentId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, getPhaseKindOfFunction, hasNoneOrLooseComponentName, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidMountCallback, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUnmountCallback, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isComponentWrapperCallback, isComponentWrapperCallbackLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHook, isHookCall, isHookCallWithName, isHookId, isHookName, isInitializedFromReact, isInitializedFromReactNative, isInitializedFromRef, isInsideComponentOrHook, isInversePhase, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isRefName, isRender, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStoreCall, isUseTransitionCall, resolveJsxAttributeValue, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/dist/index.js
CHANGED
|
@@ -124,7 +124,7 @@ const REACT_BUILTIN_HOOK_NAMES = [
|
|
|
124
124
|
* @param name The name of the identifier to check.
|
|
125
125
|
* @see https://github.com/facebook/react/blob/1d6c8168db1d82713202e842df3167787ffa00ed/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts#L16
|
|
126
126
|
*/
|
|
127
|
-
function
|
|
127
|
+
function isHookName(name) {
|
|
128
128
|
return name === "use" || /^use[A-Z0-9]/.test(name);
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -135,12 +135,12 @@ function isReactHookName(name) {
|
|
|
135
135
|
* @param node The function node to check
|
|
136
136
|
* @returns True if the function is a React Hook, false otherwise
|
|
137
137
|
*/
|
|
138
|
-
function
|
|
138
|
+
function isHook(node) {
|
|
139
139
|
if (node == null) return false;
|
|
140
140
|
const id = AST.getFunctionId(node);
|
|
141
141
|
switch (id?.type) {
|
|
142
|
-
case AST_NODE_TYPES.Identifier: return
|
|
143
|
-
case AST_NODE_TYPES.MemberExpression: return "name" in id.property &&
|
|
142
|
+
case AST_NODE_TYPES.Identifier: return isHookName(id.name);
|
|
143
|
+
case AST_NODE_TYPES.MemberExpression: return "name" in id.property && isHookName(id.property.name);
|
|
144
144
|
default: return false;
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -149,11 +149,11 @@ function isReactHook(node) {
|
|
|
149
149
|
* @param node The node to check.
|
|
150
150
|
* @returns `true` if the node is a React Hook call, `false` otherwise.
|
|
151
151
|
*/
|
|
152
|
-
function
|
|
152
|
+
function isHookCall(node) {
|
|
153
153
|
if (node == null) return false;
|
|
154
154
|
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
155
|
-
if (node.callee.type === AST_NODE_TYPES.Identifier) return
|
|
156
|
-
if (node.callee.type === AST_NODE_TYPES.MemberExpression) return node.callee.property.type === AST_NODE_TYPES.Identifier &&
|
|
155
|
+
if (node.callee.type === AST_NODE_TYPES.Identifier) return isHookName(node.callee.name);
|
|
156
|
+
if (node.callee.type === AST_NODE_TYPES.MemberExpression) return node.callee.property.type === AST_NODE_TYPES.Identifier && isHookName(node.callee.property.name);
|
|
157
157
|
return false;
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
@@ -162,7 +162,7 @@ function isReactHookCall(node) {
|
|
|
162
162
|
* @param node The AST node to check
|
|
163
163
|
* @returns A function that takes a hook name and returns boolean
|
|
164
164
|
*/
|
|
165
|
-
function
|
|
165
|
+
function isHookCallWithName(node) {
|
|
166
166
|
if (node == null || node.type !== AST_NODE_TYPES.CallExpression) return constFalse;
|
|
167
167
|
return (name) => {
|
|
168
168
|
switch (node.callee.type) {
|
|
@@ -202,25 +202,25 @@ function isUseStateLikeCall(node, additionalStateHooks = { test: constFalse }) {
|
|
|
202
202
|
return false;
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
|
-
const isUseCall = flip(
|
|
206
|
-
const isUseActionStateCall = flip(
|
|
207
|
-
const isUseCallbackCall = flip(
|
|
208
|
-
const isUseContextCall = flip(
|
|
209
|
-
const isUseDebugValueCall = flip(
|
|
210
|
-
const isUseDeferredValueCall = flip(
|
|
211
|
-
const isUseEffectCall = flip(
|
|
212
|
-
const isUseFormStatusCall = flip(
|
|
213
|
-
const isUseIdCall = flip(
|
|
214
|
-
const isUseImperativeHandleCall = flip(
|
|
215
|
-
const isUseInsertionEffectCall = flip(
|
|
216
|
-
const isUseLayoutEffectCall = flip(
|
|
217
|
-
const isUseMemoCall = flip(
|
|
218
|
-
const isUseOptimisticCall = flip(
|
|
219
|
-
const isUseReducerCall = flip(
|
|
220
|
-
const isUseRefCall = flip(
|
|
221
|
-
const isUseStateCall = flip(
|
|
222
|
-
const isUseSyncExternalStoreCall = flip(
|
|
223
|
-
const isUseTransitionCall = flip(
|
|
205
|
+
const isUseCall = flip(isHookCallWithName)("use");
|
|
206
|
+
const isUseActionStateCall = flip(isHookCallWithName)("useActionState");
|
|
207
|
+
const isUseCallbackCall = flip(isHookCallWithName)("useCallback");
|
|
208
|
+
const isUseContextCall = flip(isHookCallWithName)("useContext");
|
|
209
|
+
const isUseDebugValueCall = flip(isHookCallWithName)("useDebugValue");
|
|
210
|
+
const isUseDeferredValueCall = flip(isHookCallWithName)("useDeferredValue");
|
|
211
|
+
const isUseEffectCall = flip(isHookCallWithName)("useEffect");
|
|
212
|
+
const isUseFormStatusCall = flip(isHookCallWithName)("useFormStatus");
|
|
213
|
+
const isUseIdCall = flip(isHookCallWithName)("useId");
|
|
214
|
+
const isUseImperativeHandleCall = flip(isHookCallWithName)("useImperativeHandle");
|
|
215
|
+
const isUseInsertionEffectCall = flip(isHookCallWithName)("useInsertionEffect");
|
|
216
|
+
const isUseLayoutEffectCall = flip(isHookCallWithName)("useLayoutEffect");
|
|
217
|
+
const isUseMemoCall = flip(isHookCallWithName)("useMemo");
|
|
218
|
+
const isUseOptimisticCall = flip(isHookCallWithName)("useOptimistic");
|
|
219
|
+
const isUseReducerCall = flip(isHookCallWithName)("useReducer");
|
|
220
|
+
const isUseRefCall = flip(isHookCallWithName)("useRef");
|
|
221
|
+
const isUseStateCall = flip(isHookCallWithName)("useState");
|
|
222
|
+
const isUseSyncExternalStoreCall = flip(isHookCallWithName)("useSyncExternalStore");
|
|
223
|
+
const isUseTransitionCall = flip(isHookCallWithName)("useTransition");
|
|
224
224
|
|
|
225
225
|
//#endregion
|
|
226
226
|
//#region src/hook/hook-callback.ts
|
|
@@ -246,10 +246,10 @@ function isUseEffectCleanupCallback(node) {
|
|
|
246
246
|
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region src/hook/hook-id.ts
|
|
249
|
-
function
|
|
249
|
+
function isHookId(id) {
|
|
250
250
|
switch (id.type) {
|
|
251
|
-
case AST_NODE_TYPES.Identifier: return
|
|
252
|
-
case AST_NODE_TYPES.MemberExpression: return "name" in id.property &&
|
|
251
|
+
case AST_NODE_TYPES.Identifier: return isHookName(id.name);
|
|
252
|
+
case AST_NODE_TYPES.MemberExpression: return "name" in id.property && isHookName(id.property.name);
|
|
253
253
|
default: return false;
|
|
254
254
|
}
|
|
255
255
|
}
|
|
@@ -270,7 +270,7 @@ function useHookCollector(context) {
|
|
|
270
270
|
const onFunctionEnter = (node) => {
|
|
271
271
|
const id = AST.getFunctionId(node);
|
|
272
272
|
const key = idGen$2.next();
|
|
273
|
-
if (id != null &&
|
|
273
|
+
if (id != null && isHookId(id)) {
|
|
274
274
|
functionEntries.push({
|
|
275
275
|
key,
|
|
276
276
|
node,
|
|
@@ -309,7 +309,7 @@ function useHookCollector(context) {
|
|
|
309
309
|
":function": onFunctionEnter,
|
|
310
310
|
":function:exit": onFunctionExit,
|
|
311
311
|
CallExpression(node) {
|
|
312
|
-
if (!
|
|
312
|
+
if (!isHookCall(node)) return;
|
|
313
313
|
const fEntry = getCurrentEntry();
|
|
314
314
|
if (fEntry?.key == null) return;
|
|
315
315
|
const hook = hooks.get(fEntry.key);
|
|
@@ -1004,7 +1004,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
1004
1004
|
component.displayName = right;
|
|
1005
1005
|
} } : {},
|
|
1006
1006
|
...collectHookCalls ? { "CallExpression:exit"(node) {
|
|
1007
|
-
if (!
|
|
1007
|
+
if (!isHookCall(node)) return;
|
|
1008
1008
|
const entry = getCurrentEntry();
|
|
1009
1009
|
if (entry == null) return;
|
|
1010
1010
|
entry.hookCalls.push(node);
|
|
@@ -1248,7 +1248,7 @@ function isDeclaredInRenderPropLoose(node) {
|
|
|
1248
1248
|
*/
|
|
1249
1249
|
function findEnclosingComponentOrHook(node, test = (n, name) => {
|
|
1250
1250
|
if (name == null) return false;
|
|
1251
|
-
return isComponentNameLoose(name) ||
|
|
1251
|
+
return isComponentNameLoose(name) || isHookName(name);
|
|
1252
1252
|
}) {
|
|
1253
1253
|
const enclosingNode = AST.findParentNode(node, (n) => {
|
|
1254
1254
|
if (!AST.isFunction(n)) return false;
|
|
@@ -1304,4 +1304,4 @@ function isInitializedFromRef(name, initialScope) {
|
|
|
1304
1304
|
}
|
|
1305
1305
|
|
|
1306
1306
|
//#endregion
|
|
1307
|
-
export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, findEnclosingComponentOrHook, findParentJsxAttribute, getComponentFlagFromInitPath, getFunctionComponentId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, getPhaseKindOfFunction, hasNoneOrLooseComponentName, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidMountCallback, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUnmountCallback, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isComponentWrapperCallback, isComponentWrapperCallbackLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isInitializedFromReact, isInitializedFromReactNative, isInitializedFromRef, isInsideComponentOrHook, isInversePhase, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall,
|
|
1307
|
+
export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JsxDetectionHint, JsxEmit, REACT_BUILTIN_HOOK_NAMES, findEnclosingComponentOrHook, findParentJsxAttribute, getComponentFlagFromInitPath, getFunctionComponentId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, getPhaseKindOfFunction, hasNoneOrLooseComponentName, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidMountCallback, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUnmountCallback, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isComponentWrapperCallback, isComponentWrapperCallbackLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHook, isHookCall, isHookCallWithName, isHookId, isHookName, isInitializedFromReact, isInitializedFromReactNative, isInitializedFromRef, isInsideComponentOrHook, isInversePhase, isJsxFragmentElement, isJsxHostElement, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isRefName, isRender, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStoreCall, isUseTransitionCall, resolveJsxAttributeValue, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "2.7.5-beta.
|
|
3
|
+
"version": "2.7.5-beta.5",
|
|
4
4
|
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"@typescript-eslint/utils": "^8.54.0",
|
|
36
36
|
"birecord": "^0.1.1",
|
|
37
37
|
"ts-pattern": "^5.9.0",
|
|
38
|
-
"@eslint-react/
|
|
39
|
-
"@eslint-react/
|
|
40
|
-
"@eslint-react/
|
|
41
|
-
"@eslint-react/
|
|
38
|
+
"@eslint-react/ast": "2.7.5-beta.5",
|
|
39
|
+
"@eslint-react/shared": "2.7.5-beta.5",
|
|
40
|
+
"@eslint-react/var": "2.7.5-beta.5",
|
|
41
|
+
"@eslint-react/eff": "2.7.5-beta.5"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsdown": "^0.20.1",
|