@eslint-react/core 1.24.0-next.2 → 1.24.0-next.4
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.mts +46 -43
- package/dist/index.d.ts +46 -43
- package/dist/index.js +25 -29
- package/dist/index.mjs +25 -29
- package/package.json +6 -7
package/dist/index.d.mts
CHANGED
|
@@ -2,10 +2,9 @@ import * as AST from '@eslint-react/ast';
|
|
|
2
2
|
import * as _eslint_react_eff from '@eslint-react/eff';
|
|
3
3
|
import { _ } from '@eslint-react/eff';
|
|
4
4
|
import { TSESTree } from '@typescript-eslint/types';
|
|
5
|
-
import * as
|
|
6
|
-
import { RuleContext } from '@eslint-react/
|
|
5
|
+
import * as _eslint_react_shared from '@eslint-react/shared';
|
|
6
|
+
import { RuleContext, CustomComponentNormalized } from '@eslint-react/shared';
|
|
7
7
|
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
8
|
-
import { CustomComponentNormalized } from '@eslint-react/shared';
|
|
9
8
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
10
9
|
import { Scope } from '@typescript-eslint/scope-manager';
|
|
11
10
|
import { SyntaxKind } from 'typescript';
|
|
@@ -79,7 +78,11 @@ interface ERClassComponent extends ERSemanticNode {
|
|
|
79
78
|
}
|
|
80
79
|
type ERComponent = ERClassComponent | ERFunctionComponent;
|
|
81
80
|
|
|
82
|
-
|
|
81
|
+
interface ComponentCollectorOptions {
|
|
82
|
+
collectDisplayName?: boolean;
|
|
83
|
+
collectHookCalls?: boolean;
|
|
84
|
+
}
|
|
85
|
+
declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: ComponentCollectorOptions): {
|
|
83
86
|
readonly ctx: {
|
|
84
87
|
readonly getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
|
|
85
88
|
readonly getCurrentEntries: () => {
|
|
@@ -96,6 +99,11 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint): {
|
|
|
96
99
|
} | undefined;
|
|
97
100
|
};
|
|
98
101
|
readonly listeners: {
|
|
102
|
+
readonly "ReturnStatement[type]": (node: TSESTree.ReturnStatement) => void;
|
|
103
|
+
readonly "CallExpression[type]:exit"?: (node: TSESTree.CallExpression) => void;
|
|
104
|
+
readonly "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']"?: (node: TSESTree.AssignmentExpression & {
|
|
105
|
+
left: TSESTree.MemberExpression;
|
|
106
|
+
}) => void;
|
|
99
107
|
readonly ":function[type]": (node: AST.TSESTreeFunction) => void;
|
|
100
108
|
readonly ":function[type]:exit": () => {
|
|
101
109
|
key: string;
|
|
@@ -104,11 +112,6 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint): {
|
|
|
104
112
|
isComponent: boolean;
|
|
105
113
|
} | undefined;
|
|
106
114
|
readonly "ArrowFunctionExpression[type][body.type!='BlockStatement']": () => void;
|
|
107
|
-
readonly "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']": (node: TSESTree.AssignmentExpression & {
|
|
108
|
-
left: TSESTree.MemberExpression;
|
|
109
|
-
}) => void;
|
|
110
|
-
readonly "CallExpression[type]:exit": (node: TSESTree.CallExpression) => void;
|
|
111
|
-
readonly "ReturnStatement[type]": (node: TSESTree.ReturnStatement) => void;
|
|
112
115
|
};
|
|
113
116
|
};
|
|
114
117
|
|
|
@@ -2499,80 +2502,80 @@ declare function isReactAPIWithName(name: string): ReturnType<typeof isFromReact
|
|
|
2499
2502
|
declare function isReactAPIWithName(name: string, member: string): ReturnType<typeof isFromReactMember>;
|
|
2500
2503
|
declare function isReactAPICallWithName(name: string): ReturnType<typeof isCallFromReact>;
|
|
2501
2504
|
declare function isReactAPICallWithName(name: string, member: string): ReturnType<typeof isCallFromReactMember>;
|
|
2502
|
-
declare const isChildrenCount: (node: MemberExpression, context:
|
|
2503
|
-
declare const isChildrenForEach: (node: MemberExpression, context:
|
|
2504
|
-
declare const isChildrenMap: (node: MemberExpression, context:
|
|
2505
|
-
declare const isChildrenOnly: (node: MemberExpression, context:
|
|
2506
|
-
declare const isChildrenToArray: (node: MemberExpression, context:
|
|
2507
|
-
declare const isCloneElement: (node: Identifier | MemberExpression, context:
|
|
2508
|
-
declare const isCreateContext: (node: Identifier | MemberExpression, context:
|
|
2509
|
-
declare const isCreateElement: (node: Identifier | MemberExpression, context:
|
|
2510
|
-
declare const isCreateRef: (node: Identifier | MemberExpression, context:
|
|
2511
|
-
declare const isForwardRef: (node: Identifier | MemberExpression, context:
|
|
2512
|
-
declare const isMemo: (node: Identifier | MemberExpression, context:
|
|
2505
|
+
declare const isChildrenCount: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2506
|
+
declare const isChildrenForEach: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2507
|
+
declare const isChildrenMap: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2508
|
+
declare const isChildrenOnly: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2509
|
+
declare const isChildrenToArray: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2510
|
+
declare const isCloneElement: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2511
|
+
declare const isCreateContext: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2512
|
+
declare const isCreateElement: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2513
|
+
declare const isCreateRef: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2514
|
+
declare const isForwardRef: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2515
|
+
declare const isMemo: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2513
2516
|
declare const isChildrenCountCall: {
|
|
2514
|
-
(context:
|
|
2517
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
|
|
2515
2518
|
callee: MemberExpression;
|
|
2516
2519
|
};
|
|
2517
|
-
(node: Node, context:
|
|
2520
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
|
|
2518
2521
|
callee: MemberExpression;
|
|
2519
2522
|
};
|
|
2520
2523
|
};
|
|
2521
2524
|
declare const isChildrenForEachCall: {
|
|
2522
|
-
(context:
|
|
2525
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
|
|
2523
2526
|
callee: MemberExpression;
|
|
2524
2527
|
};
|
|
2525
|
-
(node: Node, context:
|
|
2528
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
|
|
2526
2529
|
callee: MemberExpression;
|
|
2527
2530
|
};
|
|
2528
2531
|
};
|
|
2529
2532
|
declare const isChildrenMapCall: {
|
|
2530
|
-
(context:
|
|
2533
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
|
|
2531
2534
|
callee: MemberExpression;
|
|
2532
2535
|
};
|
|
2533
|
-
(node: Node, context:
|
|
2536
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
|
|
2534
2537
|
callee: MemberExpression;
|
|
2535
2538
|
};
|
|
2536
2539
|
};
|
|
2537
2540
|
declare const isChildrenOnlyCall: {
|
|
2538
|
-
(context:
|
|
2541
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
|
|
2539
2542
|
callee: MemberExpression;
|
|
2540
2543
|
};
|
|
2541
|
-
(node: Node, context:
|
|
2544
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
|
|
2542
2545
|
callee: MemberExpression;
|
|
2543
2546
|
};
|
|
2544
2547
|
};
|
|
2545
2548
|
declare const isChildrenToArrayCall: {
|
|
2546
|
-
(context:
|
|
2549
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
|
|
2547
2550
|
callee: MemberExpression;
|
|
2548
2551
|
};
|
|
2549
|
-
(node: Node, context:
|
|
2552
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
|
|
2550
2553
|
callee: MemberExpression;
|
|
2551
2554
|
};
|
|
2552
2555
|
};
|
|
2553
2556
|
declare const isCloneElementCall: {
|
|
2554
|
-
(context:
|
|
2555
|
-
(node: Node, context:
|
|
2557
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
|
|
2558
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2556
2559
|
};
|
|
2557
2560
|
declare const isCreateContextCall: {
|
|
2558
|
-
(context:
|
|
2559
|
-
(node: Node, context:
|
|
2561
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
|
|
2562
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2560
2563
|
};
|
|
2561
2564
|
declare const isCreateElementCall: {
|
|
2562
|
-
(context:
|
|
2563
|
-
(node: Node, context:
|
|
2565
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
|
|
2566
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2564
2567
|
};
|
|
2565
2568
|
declare const isCreateRefCall: {
|
|
2566
|
-
(context:
|
|
2567
|
-
(node: Node, context:
|
|
2569
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
|
|
2570
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2568
2571
|
};
|
|
2569
2572
|
declare const isForwardRefCall: {
|
|
2570
|
-
(context:
|
|
2571
|
-
(node: Node, context:
|
|
2573
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
|
|
2574
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2572
2575
|
};
|
|
2573
2576
|
declare const isMemoCall: {
|
|
2574
|
-
(context:
|
|
2575
|
-
(node: Node, context:
|
|
2577
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
|
|
2578
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2576
2579
|
};
|
|
2577
2580
|
|
|
2578
|
-
export { DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementNameAndRepresentName, getFunctionComponentIdentifier, getId, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
|
2581
|
+
export { type ComponentCollectorOptions, DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementNameAndRepresentName, getFunctionComponentIdentifier, getId, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,9 @@ import * as AST from '@eslint-react/ast';
|
|
|
2
2
|
import * as _eslint_react_eff from '@eslint-react/eff';
|
|
3
3
|
import { _ } from '@eslint-react/eff';
|
|
4
4
|
import { TSESTree } from '@typescript-eslint/types';
|
|
5
|
-
import * as
|
|
6
|
-
import { RuleContext } from '@eslint-react/
|
|
5
|
+
import * as _eslint_react_shared from '@eslint-react/shared';
|
|
6
|
+
import { RuleContext, CustomComponentNormalized } from '@eslint-react/shared';
|
|
7
7
|
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
8
|
-
import { CustomComponentNormalized } from '@eslint-react/shared';
|
|
9
8
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
10
9
|
import { Scope } from '@typescript-eslint/scope-manager';
|
|
11
10
|
import { SyntaxKind } from 'typescript';
|
|
@@ -79,7 +78,11 @@ interface ERClassComponent extends ERSemanticNode {
|
|
|
79
78
|
}
|
|
80
79
|
type ERComponent = ERClassComponent | ERFunctionComponent;
|
|
81
80
|
|
|
82
|
-
|
|
81
|
+
interface ComponentCollectorOptions {
|
|
82
|
+
collectDisplayName?: boolean;
|
|
83
|
+
collectHookCalls?: boolean;
|
|
84
|
+
}
|
|
85
|
+
declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: ComponentCollectorOptions): {
|
|
83
86
|
readonly ctx: {
|
|
84
87
|
readonly getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
|
|
85
88
|
readonly getCurrentEntries: () => {
|
|
@@ -96,6 +99,11 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint): {
|
|
|
96
99
|
} | undefined;
|
|
97
100
|
};
|
|
98
101
|
readonly listeners: {
|
|
102
|
+
readonly "ReturnStatement[type]": (node: TSESTree.ReturnStatement) => void;
|
|
103
|
+
readonly "CallExpression[type]:exit"?: (node: TSESTree.CallExpression) => void;
|
|
104
|
+
readonly "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']"?: (node: TSESTree.AssignmentExpression & {
|
|
105
|
+
left: TSESTree.MemberExpression;
|
|
106
|
+
}) => void;
|
|
99
107
|
readonly ":function[type]": (node: AST.TSESTreeFunction) => void;
|
|
100
108
|
readonly ":function[type]:exit": () => {
|
|
101
109
|
key: string;
|
|
@@ -104,11 +112,6 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint): {
|
|
|
104
112
|
isComponent: boolean;
|
|
105
113
|
} | undefined;
|
|
106
114
|
readonly "ArrowFunctionExpression[type][body.type!='BlockStatement']": () => void;
|
|
107
|
-
readonly "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']": (node: TSESTree.AssignmentExpression & {
|
|
108
|
-
left: TSESTree.MemberExpression;
|
|
109
|
-
}) => void;
|
|
110
|
-
readonly "CallExpression[type]:exit": (node: TSESTree.CallExpression) => void;
|
|
111
|
-
readonly "ReturnStatement[type]": (node: TSESTree.ReturnStatement) => void;
|
|
112
115
|
};
|
|
113
116
|
};
|
|
114
117
|
|
|
@@ -2499,80 +2502,80 @@ declare function isReactAPIWithName(name: string): ReturnType<typeof isFromReact
|
|
|
2499
2502
|
declare function isReactAPIWithName(name: string, member: string): ReturnType<typeof isFromReactMember>;
|
|
2500
2503
|
declare function isReactAPICallWithName(name: string): ReturnType<typeof isCallFromReact>;
|
|
2501
2504
|
declare function isReactAPICallWithName(name: string, member: string): ReturnType<typeof isCallFromReactMember>;
|
|
2502
|
-
declare const isChildrenCount: (node: MemberExpression, context:
|
|
2503
|
-
declare const isChildrenForEach: (node: MemberExpression, context:
|
|
2504
|
-
declare const isChildrenMap: (node: MemberExpression, context:
|
|
2505
|
-
declare const isChildrenOnly: (node: MemberExpression, context:
|
|
2506
|
-
declare const isChildrenToArray: (node: MemberExpression, context:
|
|
2507
|
-
declare const isCloneElement: (node: Identifier | MemberExpression, context:
|
|
2508
|
-
declare const isCreateContext: (node: Identifier | MemberExpression, context:
|
|
2509
|
-
declare const isCreateElement: (node: Identifier | MemberExpression, context:
|
|
2510
|
-
declare const isCreateRef: (node: Identifier | MemberExpression, context:
|
|
2511
|
-
declare const isForwardRef: (node: Identifier | MemberExpression, context:
|
|
2512
|
-
declare const isMemo: (node: Identifier | MemberExpression, context:
|
|
2505
|
+
declare const isChildrenCount: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2506
|
+
declare const isChildrenForEach: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2507
|
+
declare const isChildrenMap: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2508
|
+
declare const isChildrenOnly: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2509
|
+
declare const isChildrenToArray: (node: MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2510
|
+
declare const isCloneElement: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2511
|
+
declare const isCreateContext: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2512
|
+
declare const isCreateElement: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2513
|
+
declare const isCreateRef: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2514
|
+
declare const isForwardRef: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2515
|
+
declare const isMemo: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
|
|
2513
2516
|
declare const isChildrenCountCall: {
|
|
2514
|
-
(context:
|
|
2517
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
|
|
2515
2518
|
callee: MemberExpression;
|
|
2516
2519
|
};
|
|
2517
|
-
(node: Node, context:
|
|
2520
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
|
|
2518
2521
|
callee: MemberExpression;
|
|
2519
2522
|
};
|
|
2520
2523
|
};
|
|
2521
2524
|
declare const isChildrenForEachCall: {
|
|
2522
|
-
(context:
|
|
2525
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
|
|
2523
2526
|
callee: MemberExpression;
|
|
2524
2527
|
};
|
|
2525
|
-
(node: Node, context:
|
|
2528
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
|
|
2526
2529
|
callee: MemberExpression;
|
|
2527
2530
|
};
|
|
2528
2531
|
};
|
|
2529
2532
|
declare const isChildrenMapCall: {
|
|
2530
|
-
(context:
|
|
2533
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
|
|
2531
2534
|
callee: MemberExpression;
|
|
2532
2535
|
};
|
|
2533
|
-
(node: Node, context:
|
|
2536
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
|
|
2534
2537
|
callee: MemberExpression;
|
|
2535
2538
|
};
|
|
2536
2539
|
};
|
|
2537
2540
|
declare const isChildrenOnlyCall: {
|
|
2538
|
-
(context:
|
|
2541
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
|
|
2539
2542
|
callee: MemberExpression;
|
|
2540
2543
|
};
|
|
2541
|
-
(node: Node, context:
|
|
2544
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
|
|
2542
2545
|
callee: MemberExpression;
|
|
2543
2546
|
};
|
|
2544
2547
|
};
|
|
2545
2548
|
declare const isChildrenToArrayCall: {
|
|
2546
|
-
(context:
|
|
2549
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
|
|
2547
2550
|
callee: MemberExpression;
|
|
2548
2551
|
};
|
|
2549
|
-
(node: Node, context:
|
|
2552
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
|
|
2550
2553
|
callee: MemberExpression;
|
|
2551
2554
|
};
|
|
2552
2555
|
};
|
|
2553
2556
|
declare const isCloneElementCall: {
|
|
2554
|
-
(context:
|
|
2555
|
-
(node: Node, context:
|
|
2557
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
|
|
2558
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2556
2559
|
};
|
|
2557
2560
|
declare const isCreateContextCall: {
|
|
2558
|
-
(context:
|
|
2559
|
-
(node: Node, context:
|
|
2561
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
|
|
2562
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2560
2563
|
};
|
|
2561
2564
|
declare const isCreateElementCall: {
|
|
2562
|
-
(context:
|
|
2563
|
-
(node: Node, context:
|
|
2565
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
|
|
2566
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2564
2567
|
};
|
|
2565
2568
|
declare const isCreateRefCall: {
|
|
2566
|
-
(context:
|
|
2567
|
-
(node: Node, context:
|
|
2569
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
|
|
2570
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2568
2571
|
};
|
|
2569
2572
|
declare const isForwardRefCall: {
|
|
2570
|
-
(context:
|
|
2571
|
-
(node: Node, context:
|
|
2573
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
|
|
2574
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2572
2575
|
};
|
|
2573
2576
|
declare const isMemoCall: {
|
|
2574
|
-
(context:
|
|
2575
|
-
(node: Node, context:
|
|
2577
|
+
(context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
|
|
2578
|
+
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2576
2579
|
};
|
|
2577
2580
|
|
|
2578
|
-
export { DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementNameAndRepresentName, getFunctionComponentIdentifier, getId, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
|
2581
|
+
export { type ComponentCollectorOptions, DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementNameAndRepresentName, getFunctionComponentIdentifier, getId, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isSetupFunction, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/dist/index.js
CHANGED
|
@@ -328,13 +328,7 @@ function useHookCollector() {
|
|
|
328
328
|
if (hook == null) {
|
|
329
329
|
return;
|
|
330
330
|
}
|
|
331
|
-
|
|
332
|
-
...hook,
|
|
333
|
-
hookCalls: [
|
|
334
|
-
...hook.hookCalls,
|
|
335
|
-
node
|
|
336
|
-
]
|
|
337
|
-
});
|
|
331
|
+
hook.hookCalls.push(node);
|
|
338
332
|
}
|
|
339
333
|
};
|
|
340
334
|
return { ctx, listeners };
|
|
@@ -489,7 +483,9 @@ function getComponentFlag(initPath) {
|
|
|
489
483
|
}
|
|
490
484
|
return flag;
|
|
491
485
|
}
|
|
492
|
-
|
|
486
|
+
var displayNameAssignmentSelector = "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']";
|
|
487
|
+
function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options = {}) {
|
|
488
|
+
const { collectDisplayName = false, collectHookCalls = false } = options;
|
|
493
489
|
const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) };
|
|
494
490
|
const components = /* @__PURE__ */ new Map();
|
|
495
491
|
const functionEntries = [];
|
|
@@ -552,29 +548,29 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
|
|
|
552
548
|
initPath
|
|
553
549
|
});
|
|
554
550
|
},
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
displayName: right
|
|
565
|
-
});
|
|
566
|
-
},
|
|
567
|
-
"CallExpression[type]:exit"(node) {
|
|
568
|
-
if (!isReactHookCall(node)) {
|
|
569
|
-
return;
|
|
551
|
+
...collectDisplayName ? {
|
|
552
|
+
[displayNameAssignmentSelector](node) {
|
|
553
|
+
const { left, right } = node;
|
|
554
|
+
const componentName = left.object.type === types.AST_NODE_TYPES.Identifier ? left.object.name : eff._;
|
|
555
|
+
const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
|
|
556
|
+
if (component == null) {
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
component.displayName = right;
|
|
570
560
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
561
|
+
} : {},
|
|
562
|
+
...collectHookCalls ? {
|
|
563
|
+
"CallExpression[type]:exit"(node) {
|
|
564
|
+
if (!isReactHookCall(node)) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
const entry = getCurrentEntry();
|
|
568
|
+
if (entry == null) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
entry.hookCalls.push(node);
|
|
574
572
|
}
|
|
575
|
-
|
|
576
|
-
functionEntries.push({ ...entry, hookCalls: [...entry.hookCalls, node] });
|
|
577
|
-
},
|
|
573
|
+
} : {},
|
|
578
574
|
"ReturnStatement[type]"(node) {
|
|
579
575
|
const entry = getCurrentEntry();
|
|
580
576
|
if (entry == null) {
|
package/dist/index.mjs
CHANGED
|
@@ -304,13 +304,7 @@ function useHookCollector() {
|
|
|
304
304
|
if (hook == null) {
|
|
305
305
|
return;
|
|
306
306
|
}
|
|
307
|
-
|
|
308
|
-
...hook,
|
|
309
|
-
hookCalls: [
|
|
310
|
-
...hook.hookCalls,
|
|
311
|
-
node
|
|
312
|
-
]
|
|
313
|
-
});
|
|
307
|
+
hook.hookCalls.push(node);
|
|
314
308
|
}
|
|
315
309
|
};
|
|
316
310
|
return { ctx, listeners };
|
|
@@ -465,7 +459,9 @@ function getComponentFlag(initPath) {
|
|
|
465
459
|
}
|
|
466
460
|
return flag;
|
|
467
461
|
}
|
|
468
|
-
|
|
462
|
+
var displayNameAssignmentSelector = "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']";
|
|
463
|
+
function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options = {}) {
|
|
464
|
+
const { collectDisplayName = false, collectHookCalls = false } = options;
|
|
469
465
|
const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) };
|
|
470
466
|
const components = /* @__PURE__ */ new Map();
|
|
471
467
|
const functionEntries = [];
|
|
@@ -528,29 +524,29 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT) {
|
|
|
528
524
|
initPath
|
|
529
525
|
});
|
|
530
526
|
},
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
displayName: right
|
|
541
|
-
});
|
|
542
|
-
},
|
|
543
|
-
"CallExpression[type]:exit"(node) {
|
|
544
|
-
if (!isReactHookCall(node)) {
|
|
545
|
-
return;
|
|
527
|
+
...collectDisplayName ? {
|
|
528
|
+
[displayNameAssignmentSelector](node) {
|
|
529
|
+
const { left, right } = node;
|
|
530
|
+
const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : _;
|
|
531
|
+
const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
|
|
532
|
+
if (component == null) {
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
component.displayName = right;
|
|
546
536
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
537
|
+
} : {},
|
|
538
|
+
...collectHookCalls ? {
|
|
539
|
+
"CallExpression[type]:exit"(node) {
|
|
540
|
+
if (!isReactHookCall(node)) {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
const entry = getCurrentEntry();
|
|
544
|
+
if (entry == null) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
entry.hookCalls.push(node);
|
|
550
548
|
}
|
|
551
|
-
|
|
552
|
-
functionEntries.push({ ...entry, hookCalls: [...entry.hookCalls, node] });
|
|
553
|
-
},
|
|
549
|
+
} : {},
|
|
554
550
|
"ReturnStatement[type]"(node) {
|
|
555
551
|
const entry = getCurrentEntry();
|
|
556
552
|
if (entry == null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.24.0-next.
|
|
3
|
+
"version": "1.24.0-next.4",
|
|
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": {
|
|
@@ -38,12 +38,11 @@
|
|
|
38
38
|
"@typescript-eslint/types": "^8.19.1",
|
|
39
39
|
"@typescript-eslint/utils": "^8.19.1",
|
|
40
40
|
"ts-pattern": "^5.6.0",
|
|
41
|
-
"@eslint-react/ast": "1.24.0-next.
|
|
42
|
-
"@eslint-react/
|
|
43
|
-
"@eslint-react/
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/var": "1.24.0-next.2"
|
|
41
|
+
"@eslint-react/ast": "1.24.0-next.4",
|
|
42
|
+
"@eslint-react/jsx": "1.24.0-next.4",
|
|
43
|
+
"@eslint-react/eff": "1.24.0-next.4",
|
|
44
|
+
"@eslint-react/shared": "1.24.0-next.4",
|
|
45
|
+
"@eslint-react/var": "1.24.0-next.4"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"tsup": "^8.3.5",
|