@eslint-react/core 1.39.0-beta.0 → 1.39.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +30 -30
- package/dist/index.d.ts +30 -30
- package/dist/index.js +16 -16
- package/dist/index.mjs +14 -14
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -6,11 +6,11 @@ import { _ } from '@eslint-react/eff';
|
|
|
6
6
|
import * as birecord from 'birecord';
|
|
7
7
|
import { Scope } from '@typescript-eslint/scope-manager';
|
|
8
8
|
|
|
9
|
-
type
|
|
9
|
+
type ComponentCollectorHint = bigint;
|
|
10
10
|
/**
|
|
11
11
|
* hints for component collector
|
|
12
12
|
*/
|
|
13
|
-
declare const
|
|
13
|
+
declare const ComponentCollectorHint: {
|
|
14
14
|
/**
|
|
15
15
|
* Skip function component created by React.memo
|
|
16
16
|
*/
|
|
@@ -50,7 +50,7 @@ declare const ERComponentHint: {
|
|
|
50
50
|
};
|
|
51
51
|
declare const DEFAULT_COMPONENT_HINT: bigint;
|
|
52
52
|
|
|
53
|
-
interface
|
|
53
|
+
interface SemanticNode {
|
|
54
54
|
id: _ | TSESTree.Identifier | TSESTree.Identifier[];
|
|
55
55
|
key: string;
|
|
56
56
|
kind: string;
|
|
@@ -60,8 +60,8 @@ interface ERSemanticNode {
|
|
|
60
60
|
hint: bigint;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
type
|
|
64
|
-
declare const
|
|
63
|
+
type ComponentFlag = bigint;
|
|
64
|
+
declare const ComponentFlag: {
|
|
65
65
|
None: bigint;
|
|
66
66
|
PureComponent: bigint;
|
|
67
67
|
CreateElement: bigint;
|
|
@@ -70,26 +70,26 @@ declare const ERComponentFlag: {
|
|
|
70
70
|
Async: bigint;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
interface
|
|
73
|
+
interface FunctionComponent extends SemanticNode {
|
|
74
74
|
id: _ | TSESTree.Identifier | TSESTree.Identifier[];
|
|
75
75
|
kind: "function";
|
|
76
76
|
node: AST.TSESTreeFunction;
|
|
77
|
-
flag:
|
|
78
|
-
hint:
|
|
77
|
+
flag: ComponentFlag;
|
|
78
|
+
hint: ComponentCollectorHint;
|
|
79
79
|
initPath: _ | AST.FunctionInitPath;
|
|
80
80
|
hookCalls: TSESTree.CallExpression[];
|
|
81
81
|
displayName: _ | TSESTree.Expression;
|
|
82
82
|
}
|
|
83
|
-
interface
|
|
83
|
+
interface ClassComponent extends SemanticNode {
|
|
84
84
|
id: _ | TSESTree.Identifier;
|
|
85
85
|
kind: "class";
|
|
86
86
|
node: AST.TSESTreeClass;
|
|
87
|
-
flag:
|
|
88
|
-
hint:
|
|
87
|
+
flag: ComponentFlag;
|
|
88
|
+
hint: ComponentCollectorHint;
|
|
89
89
|
methods: AST.TSESTreeMethodOrProperty[];
|
|
90
90
|
displayName: _ | TSESTree.Expression;
|
|
91
91
|
}
|
|
92
|
-
type
|
|
92
|
+
type Component = ClassComponent | FunctionComponent;
|
|
93
93
|
|
|
94
94
|
type FunctionEntry = {
|
|
95
95
|
key: string;
|
|
@@ -101,11 +101,11 @@ declare namespace useComponentCollector {
|
|
|
101
101
|
type Options = {
|
|
102
102
|
collectDisplayName?: boolean;
|
|
103
103
|
collectHookCalls?: boolean;
|
|
104
|
-
hint?:
|
|
104
|
+
hint?: ComponentCollectorHint;
|
|
105
105
|
};
|
|
106
106
|
type ReturnType = {
|
|
107
107
|
ctx: {
|
|
108
|
-
getAllComponents: (node: TSESTree.Program) => Map<string,
|
|
108
|
+
getAllComponents: (node: TSESTree.Program) => Map<string, FunctionComponent>;
|
|
109
109
|
getCurrentEntries: () => FunctionEntry[];
|
|
110
110
|
getCurrentEntry: () => FunctionEntry | _;
|
|
111
111
|
};
|
|
@@ -123,7 +123,7 @@ declare function useComponentCollector(context: RuleContext, options?: useCompon
|
|
|
123
123
|
declare namespace useComponentCollectorLegacy {
|
|
124
124
|
type ReturnType = {
|
|
125
125
|
ctx: {
|
|
126
|
-
getAllComponents: (node: TSESTree$1.Program) => Map<string,
|
|
126
|
+
getAllComponents: (node: TSESTree$1.Program) => Map<string, ClassComponent>;
|
|
127
127
|
};
|
|
128
128
|
listeners: ESLintUtils.RuleListener;
|
|
129
129
|
};
|
|
@@ -136,7 +136,7 @@ declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.Retu
|
|
|
136
136
|
|
|
137
137
|
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | _;
|
|
138
138
|
|
|
139
|
-
type
|
|
139
|
+
type ComponentKind = "classComponent" | "functionComponent";
|
|
140
140
|
|
|
141
141
|
declare function isComponentDidMount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
142
142
|
declare function isComponentWillUnmount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
@@ -171,16 +171,16 @@ declare function isComponentNameLoose(name: string): boolean;
|
|
|
171
171
|
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
|
|
172
172
|
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
173
173
|
|
|
174
|
-
type
|
|
175
|
-
type
|
|
176
|
-
type
|
|
177
|
-
declare const
|
|
174
|
+
type ComponentEffectPhaseKind = "cleanup" | "setup";
|
|
175
|
+
type ComponentLifecyclePhaseKind = "mount" | "unmount";
|
|
176
|
+
type ComponentPhaseKind = ComponentEffectPhaseKind | ComponentLifecyclePhaseKind;
|
|
177
|
+
declare const ComponentPhaseRelevance: birecord.BiRecord<{
|
|
178
178
|
readonly mount: "unmount";
|
|
179
179
|
readonly setup: "cleanup";
|
|
180
180
|
}>;
|
|
181
181
|
declare const isInversePhase: {
|
|
182
|
-
(a:
|
|
183
|
-
(a:
|
|
182
|
+
(a: ComponentPhaseKind): (b: ComponentPhaseKind) => boolean;
|
|
183
|
+
(a: ComponentPhaseKind, b: ComponentPhaseKind): boolean;
|
|
184
184
|
};
|
|
185
185
|
|
|
186
186
|
/**
|
|
@@ -233,7 +233,7 @@ declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolea
|
|
|
233
233
|
*/
|
|
234
234
|
declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
|
|
235
235
|
|
|
236
|
-
type
|
|
236
|
+
type ComponentStateKind = "actionState" | "state";
|
|
237
237
|
declare function isThisSetState(node: TSESTree.CallExpression): boolean;
|
|
238
238
|
declare function isAssignmentToThisState(node: TSESTree.AssignmentExpression): boolean;
|
|
239
239
|
|
|
@@ -258,12 +258,12 @@ declare function isPureComponent(node: TSESTree.Node): boolean;
|
|
|
258
258
|
*/
|
|
259
259
|
declare const DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
|
|
260
260
|
|
|
261
|
-
type
|
|
261
|
+
type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
|
|
262
262
|
|
|
263
263
|
declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | _): boolean;
|
|
264
264
|
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node | _): boolean;
|
|
265
265
|
|
|
266
|
-
interface
|
|
266
|
+
interface Hook extends SemanticNode {
|
|
267
267
|
id: TSESTree.Identifier | _;
|
|
268
268
|
node: AST.TSESTreeFunction;
|
|
269
269
|
name: string;
|
|
@@ -273,14 +273,14 @@ interface ERHook extends ERSemanticNode {
|
|
|
273
273
|
declare namespace useHookCollector {
|
|
274
274
|
type ReturnType = {
|
|
275
275
|
ctx: {
|
|
276
|
-
getAllHooks(node: TSESTree$1.Program): Map<string,
|
|
276
|
+
getAllHooks(node: TSESTree$1.Program): Map<string, Hook>;
|
|
277
277
|
};
|
|
278
278
|
listeners: ESLintUtils.RuleListener;
|
|
279
279
|
};
|
|
280
280
|
}
|
|
281
281
|
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
282
282
|
|
|
283
|
-
type
|
|
283
|
+
type HookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "useDebugValue" | "useDeferredValue" | "useEffect" | "useId" | "useImperativeHandle" | "useInsertionEffect" | "useLayoutEffect" | "useMemo" | "useOptimistic" | "useReducer" | "useRef" | "useState" | "useSyncExternalStore" | "useTransition";
|
|
284
284
|
|
|
285
285
|
declare const RE_HOOK_NAME: RegExp;
|
|
286
286
|
declare function isReactHookName(name: string): boolean;
|
|
@@ -317,9 +317,9 @@ declare const isUseStateCall: (context: RuleContext, node: TSESTree.Node | undef
|
|
|
317
317
|
declare const isUseSyncExternalStoreCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
318
318
|
declare const isUseTransitionCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
319
319
|
|
|
320
|
-
interface
|
|
320
|
+
interface SemanticEntry {
|
|
321
321
|
node: TSESTree.Node;
|
|
322
|
-
phase:
|
|
322
|
+
phase: ComponentPhaseKind;
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
/** @internal */
|
|
@@ -391,4 +391,4 @@ declare const isCreateRefCall: isCallFromReact.ReturnType;
|
|
|
391
391
|
declare const isForwardRefCall: isCallFromReact.ReturnType;
|
|
392
392
|
declare const isMemoCall: isCallFromReact.ReturnType;
|
|
393
393
|
|
|
394
|
-
export {
|
|
394
|
+
export { type ClassComponent, type Component, ComponentCollectorHint, type ComponentEffectPhaseKind, ComponentFlag, type ComponentKind, type ComponentLifecyclePhaseKind, type ComponentPhaseKind, ComponentPhaseRelevance, type ComponentStateKind, DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, type EffectKind, type FunctionComponent, type Hook, type HookKind, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_HOOK_NAME, type SemanticEntry, type SemanticNode, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, hasValidHierarchy, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentNameLoose, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isReactHookNameLoose, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,11 +6,11 @@ import { _ } from '@eslint-react/eff';
|
|
|
6
6
|
import * as birecord from 'birecord';
|
|
7
7
|
import { Scope } from '@typescript-eslint/scope-manager';
|
|
8
8
|
|
|
9
|
-
type
|
|
9
|
+
type ComponentCollectorHint = bigint;
|
|
10
10
|
/**
|
|
11
11
|
* hints for component collector
|
|
12
12
|
*/
|
|
13
|
-
declare const
|
|
13
|
+
declare const ComponentCollectorHint: {
|
|
14
14
|
/**
|
|
15
15
|
* Skip function component created by React.memo
|
|
16
16
|
*/
|
|
@@ -50,7 +50,7 @@ declare const ERComponentHint: {
|
|
|
50
50
|
};
|
|
51
51
|
declare const DEFAULT_COMPONENT_HINT: bigint;
|
|
52
52
|
|
|
53
|
-
interface
|
|
53
|
+
interface SemanticNode {
|
|
54
54
|
id: _ | TSESTree.Identifier | TSESTree.Identifier[];
|
|
55
55
|
key: string;
|
|
56
56
|
kind: string;
|
|
@@ -60,8 +60,8 @@ interface ERSemanticNode {
|
|
|
60
60
|
hint: bigint;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
type
|
|
64
|
-
declare const
|
|
63
|
+
type ComponentFlag = bigint;
|
|
64
|
+
declare const ComponentFlag: {
|
|
65
65
|
None: bigint;
|
|
66
66
|
PureComponent: bigint;
|
|
67
67
|
CreateElement: bigint;
|
|
@@ -70,26 +70,26 @@ declare const ERComponentFlag: {
|
|
|
70
70
|
Async: bigint;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
interface
|
|
73
|
+
interface FunctionComponent extends SemanticNode {
|
|
74
74
|
id: _ | TSESTree.Identifier | TSESTree.Identifier[];
|
|
75
75
|
kind: "function";
|
|
76
76
|
node: AST.TSESTreeFunction;
|
|
77
|
-
flag:
|
|
78
|
-
hint:
|
|
77
|
+
flag: ComponentFlag;
|
|
78
|
+
hint: ComponentCollectorHint;
|
|
79
79
|
initPath: _ | AST.FunctionInitPath;
|
|
80
80
|
hookCalls: TSESTree.CallExpression[];
|
|
81
81
|
displayName: _ | TSESTree.Expression;
|
|
82
82
|
}
|
|
83
|
-
interface
|
|
83
|
+
interface ClassComponent extends SemanticNode {
|
|
84
84
|
id: _ | TSESTree.Identifier;
|
|
85
85
|
kind: "class";
|
|
86
86
|
node: AST.TSESTreeClass;
|
|
87
|
-
flag:
|
|
88
|
-
hint:
|
|
87
|
+
flag: ComponentFlag;
|
|
88
|
+
hint: ComponentCollectorHint;
|
|
89
89
|
methods: AST.TSESTreeMethodOrProperty[];
|
|
90
90
|
displayName: _ | TSESTree.Expression;
|
|
91
91
|
}
|
|
92
|
-
type
|
|
92
|
+
type Component = ClassComponent | FunctionComponent;
|
|
93
93
|
|
|
94
94
|
type FunctionEntry = {
|
|
95
95
|
key: string;
|
|
@@ -101,11 +101,11 @@ declare namespace useComponentCollector {
|
|
|
101
101
|
type Options = {
|
|
102
102
|
collectDisplayName?: boolean;
|
|
103
103
|
collectHookCalls?: boolean;
|
|
104
|
-
hint?:
|
|
104
|
+
hint?: ComponentCollectorHint;
|
|
105
105
|
};
|
|
106
106
|
type ReturnType = {
|
|
107
107
|
ctx: {
|
|
108
|
-
getAllComponents: (node: TSESTree.Program) => Map<string,
|
|
108
|
+
getAllComponents: (node: TSESTree.Program) => Map<string, FunctionComponent>;
|
|
109
109
|
getCurrentEntries: () => FunctionEntry[];
|
|
110
110
|
getCurrentEntry: () => FunctionEntry | _;
|
|
111
111
|
};
|
|
@@ -123,7 +123,7 @@ declare function useComponentCollector(context: RuleContext, options?: useCompon
|
|
|
123
123
|
declare namespace useComponentCollectorLegacy {
|
|
124
124
|
type ReturnType = {
|
|
125
125
|
ctx: {
|
|
126
|
-
getAllComponents: (node: TSESTree$1.Program) => Map<string,
|
|
126
|
+
getAllComponents: (node: TSESTree$1.Program) => Map<string, ClassComponent>;
|
|
127
127
|
};
|
|
128
128
|
listeners: ESLintUtils.RuleListener;
|
|
129
129
|
};
|
|
@@ -136,7 +136,7 @@ declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.Retu
|
|
|
136
136
|
|
|
137
137
|
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | _;
|
|
138
138
|
|
|
139
|
-
type
|
|
139
|
+
type ComponentKind = "classComponent" | "functionComponent";
|
|
140
140
|
|
|
141
141
|
declare function isComponentDidMount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
142
142
|
declare function isComponentWillUnmount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
@@ -171,16 +171,16 @@ declare function isComponentNameLoose(name: string): boolean;
|
|
|
171
171
|
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
|
|
172
172
|
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
173
173
|
|
|
174
|
-
type
|
|
175
|
-
type
|
|
176
|
-
type
|
|
177
|
-
declare const
|
|
174
|
+
type ComponentEffectPhaseKind = "cleanup" | "setup";
|
|
175
|
+
type ComponentLifecyclePhaseKind = "mount" | "unmount";
|
|
176
|
+
type ComponentPhaseKind = ComponentEffectPhaseKind | ComponentLifecyclePhaseKind;
|
|
177
|
+
declare const ComponentPhaseRelevance: birecord.BiRecord<{
|
|
178
178
|
readonly mount: "unmount";
|
|
179
179
|
readonly setup: "cleanup";
|
|
180
180
|
}>;
|
|
181
181
|
declare const isInversePhase: {
|
|
182
|
-
(a:
|
|
183
|
-
(a:
|
|
182
|
+
(a: ComponentPhaseKind): (b: ComponentPhaseKind) => boolean;
|
|
183
|
+
(a: ComponentPhaseKind, b: ComponentPhaseKind): boolean;
|
|
184
184
|
};
|
|
185
185
|
|
|
186
186
|
/**
|
|
@@ -233,7 +233,7 @@ declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolea
|
|
|
233
233
|
*/
|
|
234
234
|
declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
|
|
235
235
|
|
|
236
|
-
type
|
|
236
|
+
type ComponentStateKind = "actionState" | "state";
|
|
237
237
|
declare function isThisSetState(node: TSESTree.CallExpression): boolean;
|
|
238
238
|
declare function isAssignmentToThisState(node: TSESTree.AssignmentExpression): boolean;
|
|
239
239
|
|
|
@@ -258,12 +258,12 @@ declare function isPureComponent(node: TSESTree.Node): boolean;
|
|
|
258
258
|
*/
|
|
259
259
|
declare const DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
|
|
260
260
|
|
|
261
|
-
type
|
|
261
|
+
type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
|
|
262
262
|
|
|
263
263
|
declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | _): boolean;
|
|
264
264
|
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node | _): boolean;
|
|
265
265
|
|
|
266
|
-
interface
|
|
266
|
+
interface Hook extends SemanticNode {
|
|
267
267
|
id: TSESTree.Identifier | _;
|
|
268
268
|
node: AST.TSESTreeFunction;
|
|
269
269
|
name: string;
|
|
@@ -273,14 +273,14 @@ interface ERHook extends ERSemanticNode {
|
|
|
273
273
|
declare namespace useHookCollector {
|
|
274
274
|
type ReturnType = {
|
|
275
275
|
ctx: {
|
|
276
|
-
getAllHooks(node: TSESTree$1.Program): Map<string,
|
|
276
|
+
getAllHooks(node: TSESTree$1.Program): Map<string, Hook>;
|
|
277
277
|
};
|
|
278
278
|
listeners: ESLintUtils.RuleListener;
|
|
279
279
|
};
|
|
280
280
|
}
|
|
281
281
|
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
282
282
|
|
|
283
|
-
type
|
|
283
|
+
type HookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "useDebugValue" | "useDeferredValue" | "useEffect" | "useId" | "useImperativeHandle" | "useInsertionEffect" | "useLayoutEffect" | "useMemo" | "useOptimistic" | "useReducer" | "useRef" | "useState" | "useSyncExternalStore" | "useTransition";
|
|
284
284
|
|
|
285
285
|
declare const RE_HOOK_NAME: RegExp;
|
|
286
286
|
declare function isReactHookName(name: string): boolean;
|
|
@@ -317,9 +317,9 @@ declare const isUseStateCall: (context: RuleContext, node: TSESTree.Node | undef
|
|
|
317
317
|
declare const isUseSyncExternalStoreCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
318
318
|
declare const isUseTransitionCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
319
319
|
|
|
320
|
-
interface
|
|
320
|
+
interface SemanticEntry {
|
|
321
321
|
node: TSESTree.Node;
|
|
322
|
-
phase:
|
|
322
|
+
phase: ComponentPhaseKind;
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
/** @internal */
|
|
@@ -391,4 +391,4 @@ declare const isCreateRefCall: isCallFromReact.ReturnType;
|
|
|
391
391
|
declare const isForwardRefCall: isCallFromReact.ReturnType;
|
|
392
392
|
declare const isMemoCall: isCallFromReact.ReturnType;
|
|
393
393
|
|
|
394
|
-
export {
|
|
394
|
+
export { type ClassComponent, type Component, ComponentCollectorHint, type ComponentEffectPhaseKind, ComponentFlag, type ComponentKind, type ComponentLifecyclePhaseKind, type ComponentPhaseKind, ComponentPhaseRelevance, type ComponentStateKind, DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, type EffectKind, type FunctionComponent, type Hook, type HookKind, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_HOOK_NAME, type SemanticEntry, type SemanticNode, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, hasValidHierarchy, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentNameLoose, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isReactHookNameLoose, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/dist/index.js
CHANGED
|
@@ -815,7 +815,7 @@ function useHookCollector() {
|
|
|
815
815
|
};
|
|
816
816
|
return { ctx, listeners };
|
|
817
817
|
}
|
|
818
|
-
var
|
|
818
|
+
var ComponentCollectorHint = {
|
|
819
819
|
/**
|
|
820
820
|
* 1n << 0n - 1n << 63n are reserved for JSXValueHint
|
|
821
821
|
*/
|
|
@@ -845,10 +845,10 @@ var ERComponentHint = {
|
|
|
845
845
|
*/
|
|
846
846
|
SkipClassProperty: 1n << 69n
|
|
847
847
|
};
|
|
848
|
-
var DEFAULT_COMPONENT_HINT = 0n |
|
|
848
|
+
var DEFAULT_COMPONENT_HINT = 0n | ComponentCollectorHint.SkipBooleanLiteral | ComponentCollectorHint.SkipEmptyArray | ComponentCollectorHint.SkipArrayMapArgument | ComponentCollectorHint.SkipNumberLiteral | ComponentCollectorHint.SkipStringLiteral | ComponentCollectorHint.SkipUndefined | ComponentCollectorHint.StrictArray | ComponentCollectorHint.StrictConditional | ComponentCollectorHint.StrictLogical;
|
|
849
849
|
|
|
850
850
|
// src/component/component-flag.ts
|
|
851
|
-
var
|
|
851
|
+
var ComponentFlag = {
|
|
852
852
|
None: 0n,
|
|
853
853
|
PureComponent: 1n << 0n,
|
|
854
854
|
CreateElement: 1n << 1n,
|
|
@@ -959,16 +959,16 @@ function hasValidHierarchy(context, node, hint) {
|
|
|
959
959
|
if (isChildrenOfCreateElement(context, node) || isFunctionOfRenderMethod(node)) {
|
|
960
960
|
return false;
|
|
961
961
|
}
|
|
962
|
-
if (hint &
|
|
962
|
+
if (hint & ComponentCollectorHint.SkipObjectMethod && isFunctionOfObjectMethod(node.parent)) {
|
|
963
963
|
return false;
|
|
964
964
|
}
|
|
965
|
-
if (hint &
|
|
965
|
+
if (hint & ComponentCollectorHint.SkipClassMethod && isFunctionOfClassMethod(node.parent)) {
|
|
966
966
|
return false;
|
|
967
967
|
}
|
|
968
|
-
if (hint &
|
|
968
|
+
if (hint & ComponentCollectorHint.SkipClassProperty && isFunctionOfClassProperty(node.parent)) {
|
|
969
969
|
return false;
|
|
970
970
|
}
|
|
971
|
-
if (hint &
|
|
971
|
+
if (hint & ComponentCollectorHint.SkipArrayMapArgument && AST6__namespace.isArrayMapCallLoose(node.parent)) {
|
|
972
972
|
return false;
|
|
973
973
|
}
|
|
974
974
|
const boundaryNode = AST6__namespace.findParentNode(
|
|
@@ -1106,12 +1106,12 @@ function useComponentCollector(context, options = {}) {
|
|
|
1106
1106
|
return { ctx, listeners };
|
|
1107
1107
|
}
|
|
1108
1108
|
function getComponentFlag(initPath) {
|
|
1109
|
-
let flag =
|
|
1109
|
+
let flag = ComponentFlag.None;
|
|
1110
1110
|
if (initPath != null && AST6__namespace.hasCallInFunctionInitPath("memo", initPath)) {
|
|
1111
|
-
flag |=
|
|
1111
|
+
flag |= ComponentFlag.Memo;
|
|
1112
1112
|
}
|
|
1113
1113
|
if (initPath != null && AST6__namespace.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
1114
|
-
flag |=
|
|
1114
|
+
flag |= ComponentFlag.ForwardRef;
|
|
1115
1115
|
}
|
|
1116
1116
|
return flag;
|
|
1117
1117
|
}
|
|
@@ -1129,7 +1129,7 @@ function useComponentCollectorLegacy() {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
const id = AST6__namespace.getClassIdentifier(node);
|
|
1131
1131
|
const key = shared.getId();
|
|
1132
|
-
const flag = isPureComponent(node) ?
|
|
1132
|
+
const flag = isPureComponent(node) ? ComponentFlag.PureComponent : ComponentFlag.None;
|
|
1133
1133
|
components.set(
|
|
1134
1134
|
key,
|
|
1135
1135
|
{
|
|
@@ -1153,11 +1153,11 @@ function useComponentCollectorLegacy() {
|
|
|
1153
1153
|
};
|
|
1154
1154
|
return { ctx, listeners };
|
|
1155
1155
|
}
|
|
1156
|
-
var
|
|
1156
|
+
var ComponentPhaseRelevance = birecord__default.default({
|
|
1157
1157
|
mount: "unmount",
|
|
1158
1158
|
setup: "cleanup"
|
|
1159
1159
|
});
|
|
1160
|
-
var isInversePhase = eff.dual(2, (a, b) =>
|
|
1160
|
+
var isInversePhase = eff.dual(2, (a, b) => ComponentPhaseRelevance.get(a) === b);
|
|
1161
1161
|
function isRenderFunctionLoose(context, node) {
|
|
1162
1162
|
const { body, parent } = node;
|
|
1163
1163
|
if (AST6__namespace.getFunctionIdentifier(node)?.name.startsWith("render")) {
|
|
@@ -1213,11 +1213,11 @@ function isFunctionOfUseEffectCleanup(node) {
|
|
|
1213
1213
|
return enclosingFunction === functionOfReturnStatement && isFunctionOfUseEffectSetup(enclosingFunction);
|
|
1214
1214
|
}
|
|
1215
1215
|
|
|
1216
|
+
exports.ComponentCollectorHint = ComponentCollectorHint;
|
|
1217
|
+
exports.ComponentFlag = ComponentFlag;
|
|
1218
|
+
exports.ComponentPhaseRelevance = ComponentPhaseRelevance;
|
|
1216
1219
|
exports.DEFAULT_COMPONENT_HINT = DEFAULT_COMPONENT_HINT;
|
|
1217
1220
|
exports.DISPLAY_NAME_ASSIGNMENT_SELECTOR = DISPLAY_NAME_ASSIGNMENT_SELECTOR;
|
|
1218
|
-
exports.ERComponentFlag = ERComponentFlag;
|
|
1219
|
-
exports.ERComponentHint = ERComponentHint;
|
|
1220
|
-
exports.ERPhaseRelevance = ERPhaseRelevance;
|
|
1221
1221
|
exports.RE_COMPONENT_NAME = RE_COMPONENT_NAME;
|
|
1222
1222
|
exports.RE_COMPONENT_NAME_LOOSE = RE_COMPONENT_NAME_LOOSE;
|
|
1223
1223
|
exports.RE_HOOK_NAME = RE_HOOK_NAME;
|
package/dist/index.mjs
CHANGED
|
@@ -788,7 +788,7 @@ function useHookCollector() {
|
|
|
788
788
|
};
|
|
789
789
|
return { ctx, listeners };
|
|
790
790
|
}
|
|
791
|
-
var
|
|
791
|
+
var ComponentCollectorHint = {
|
|
792
792
|
/**
|
|
793
793
|
* 1n << 0n - 1n << 63n are reserved for JSXValueHint
|
|
794
794
|
*/
|
|
@@ -818,10 +818,10 @@ var ERComponentHint = {
|
|
|
818
818
|
*/
|
|
819
819
|
SkipClassProperty: 1n << 69n
|
|
820
820
|
};
|
|
821
|
-
var DEFAULT_COMPONENT_HINT = 0n |
|
|
821
|
+
var DEFAULT_COMPONENT_HINT = 0n | ComponentCollectorHint.SkipBooleanLiteral | ComponentCollectorHint.SkipEmptyArray | ComponentCollectorHint.SkipArrayMapArgument | ComponentCollectorHint.SkipNumberLiteral | ComponentCollectorHint.SkipStringLiteral | ComponentCollectorHint.SkipUndefined | ComponentCollectorHint.StrictArray | ComponentCollectorHint.StrictConditional | ComponentCollectorHint.StrictLogical;
|
|
822
822
|
|
|
823
823
|
// src/component/component-flag.ts
|
|
824
|
-
var
|
|
824
|
+
var ComponentFlag = {
|
|
825
825
|
None: 0n,
|
|
826
826
|
PureComponent: 1n << 0n,
|
|
827
827
|
CreateElement: 1n << 1n,
|
|
@@ -932,16 +932,16 @@ function hasValidHierarchy(context, node, hint) {
|
|
|
932
932
|
if (isChildrenOfCreateElement(context, node) || isFunctionOfRenderMethod(node)) {
|
|
933
933
|
return false;
|
|
934
934
|
}
|
|
935
|
-
if (hint &
|
|
935
|
+
if (hint & ComponentCollectorHint.SkipObjectMethod && isFunctionOfObjectMethod(node.parent)) {
|
|
936
936
|
return false;
|
|
937
937
|
}
|
|
938
|
-
if (hint &
|
|
938
|
+
if (hint & ComponentCollectorHint.SkipClassMethod && isFunctionOfClassMethod(node.parent)) {
|
|
939
939
|
return false;
|
|
940
940
|
}
|
|
941
|
-
if (hint &
|
|
941
|
+
if (hint & ComponentCollectorHint.SkipClassProperty && isFunctionOfClassProperty(node.parent)) {
|
|
942
942
|
return false;
|
|
943
943
|
}
|
|
944
|
-
if (hint &
|
|
944
|
+
if (hint & ComponentCollectorHint.SkipArrayMapArgument && AST6.isArrayMapCallLoose(node.parent)) {
|
|
945
945
|
return false;
|
|
946
946
|
}
|
|
947
947
|
const boundaryNode = AST6.findParentNode(
|
|
@@ -1079,12 +1079,12 @@ function useComponentCollector(context, options = {}) {
|
|
|
1079
1079
|
return { ctx, listeners };
|
|
1080
1080
|
}
|
|
1081
1081
|
function getComponentFlag(initPath) {
|
|
1082
|
-
let flag =
|
|
1082
|
+
let flag = ComponentFlag.None;
|
|
1083
1083
|
if (initPath != null && AST6.hasCallInFunctionInitPath("memo", initPath)) {
|
|
1084
|
-
flag |=
|
|
1084
|
+
flag |= ComponentFlag.Memo;
|
|
1085
1085
|
}
|
|
1086
1086
|
if (initPath != null && AST6.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
1087
|
-
flag |=
|
|
1087
|
+
flag |= ComponentFlag.ForwardRef;
|
|
1088
1088
|
}
|
|
1089
1089
|
return flag;
|
|
1090
1090
|
}
|
|
@@ -1102,7 +1102,7 @@ function useComponentCollectorLegacy() {
|
|
|
1102
1102
|
}
|
|
1103
1103
|
const id = AST6.getClassIdentifier(node);
|
|
1104
1104
|
const key = getId();
|
|
1105
|
-
const flag = isPureComponent(node) ?
|
|
1105
|
+
const flag = isPureComponent(node) ? ComponentFlag.PureComponent : ComponentFlag.None;
|
|
1106
1106
|
components.set(
|
|
1107
1107
|
key,
|
|
1108
1108
|
{
|
|
@@ -1126,11 +1126,11 @@ function useComponentCollectorLegacy() {
|
|
|
1126
1126
|
};
|
|
1127
1127
|
return { ctx, listeners };
|
|
1128
1128
|
}
|
|
1129
|
-
var
|
|
1129
|
+
var ComponentPhaseRelevance = birecord({
|
|
1130
1130
|
mount: "unmount",
|
|
1131
1131
|
setup: "cleanup"
|
|
1132
1132
|
});
|
|
1133
|
-
var isInversePhase = dual(2, (a, b) =>
|
|
1133
|
+
var isInversePhase = dual(2, (a, b) => ComponentPhaseRelevance.get(a) === b);
|
|
1134
1134
|
function isRenderFunctionLoose(context, node) {
|
|
1135
1135
|
const { body, parent } = node;
|
|
1136
1136
|
if (AST6.getFunctionIdentifier(node)?.name.startsWith("render")) {
|
|
@@ -1186,4 +1186,4 @@ function isFunctionOfUseEffectCleanup(node) {
|
|
|
1186
1186
|
return enclosingFunction === functionOfReturnStatement && isFunctionOfUseEffectSetup(enclosingFunction);
|
|
1187
1187
|
}
|
|
1188
1188
|
|
|
1189
|
-
export {
|
|
1189
|
+
export { ComponentCollectorHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_HOOK_NAME, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, hasValidHierarchy, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentNameLoose, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isReactHookNameLoose, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.39.0-
|
|
3
|
+
"version": "1.39.0-next.1",
|
|
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": {
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"@typescript-eslint/utils": "^8.28.0",
|
|
42
42
|
"birecord": "^0.1.1",
|
|
43
43
|
"ts-pattern": "^5.7.0",
|
|
44
|
-
"@eslint-react/ast": "1.39.0-
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
44
|
+
"@eslint-react/ast": "1.39.0-next.1",
|
|
45
|
+
"@eslint-react/eff": "1.39.0-next.1",
|
|
46
|
+
"@eslint-react/jsx": "1.39.0-next.1",
|
|
47
|
+
"@eslint-react/kit": "1.39.0-next.1",
|
|
48
|
+
"@eslint-react/var": "1.39.0-next.1",
|
|
49
|
+
"@eslint-react/shared": "1.39.0-next.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"tsup": "^8.4.0",
|