@eslint-react/core 1.24.0-next.9 → 1.24.1-beta.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 +33 -22
- package/dist/index.d.ts +33 -22
- package/dist/index.js +72 -89
- package/dist/index.mjs +65 -81
- package/package.json +11 -11
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as AST from '@eslint-react/ast';
|
|
2
2
|
import * as _eslint_react_shared from '@eslint-react/shared';
|
|
3
|
-
import { RuleContext
|
|
3
|
+
import { RuleContext } from '@eslint-react/shared';
|
|
4
4
|
import { TSESTree } from '@typescript-eslint/types';
|
|
5
5
|
import { _ } from '@eslint-react/eff';
|
|
6
6
|
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
@@ -45,15 +45,13 @@ declare const ERComponentHint: {
|
|
|
45
45
|
};
|
|
46
46
|
declare const DEFAULT_COMPONENT_HINT: bigint;
|
|
47
47
|
|
|
48
|
-
type
|
|
49
|
-
declare const
|
|
48
|
+
type ERComponentFlag = bigint;
|
|
49
|
+
declare const ERComponentFlag: {
|
|
50
50
|
None: bigint;
|
|
51
51
|
PureComponent: bigint;
|
|
52
|
-
|
|
53
|
-
type ERFunctionComponentFlag = bigint;
|
|
54
|
-
declare const ERFunctionComponentFlag: {
|
|
55
|
-
None: bigint;
|
|
52
|
+
CreateElement: bigint;
|
|
56
53
|
Memo: bigint;
|
|
54
|
+
Async: bigint;
|
|
57
55
|
ForwardRef: bigint;
|
|
58
56
|
};
|
|
59
57
|
|
|
@@ -61,7 +59,7 @@ interface ERFunctionComponent extends ERSemanticNode {
|
|
|
61
59
|
id: _ | TSESTree.Identifier | TSESTree.Identifier[];
|
|
62
60
|
kind: "function";
|
|
63
61
|
node: AST.TSESTreeFunction;
|
|
64
|
-
flag:
|
|
62
|
+
flag: ERComponentFlag;
|
|
65
63
|
hint: ERComponentHint;
|
|
66
64
|
initPath: _ | AST.FunctionInitPath;
|
|
67
65
|
hookCalls: TSESTree.CallExpression[];
|
|
@@ -71,7 +69,7 @@ interface ERClassComponent extends ERSemanticNode {
|
|
|
71
69
|
id: _ | TSESTree.Identifier;
|
|
72
70
|
kind: "class";
|
|
73
71
|
node: AST.TSESTreeClass;
|
|
74
|
-
flag:
|
|
72
|
+
flag: ERComponentFlag;
|
|
75
73
|
hint: ERComponentHint;
|
|
76
74
|
methods: AST.TSESTreeMethodOrProperty[];
|
|
77
75
|
displayName: _ | TSESTree.Expression;
|
|
@@ -82,6 +80,13 @@ interface ComponentCollectorOptions {
|
|
|
82
80
|
collectDisplayName?: boolean;
|
|
83
81
|
collectHookCalls?: boolean;
|
|
84
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Get a ctx and listeners for the rule to collect function components
|
|
85
|
+
* @param context The ESLint rule context
|
|
86
|
+
* @param hint The hint to use
|
|
87
|
+
* @param options The options to use
|
|
88
|
+
* @returns The component collector
|
|
89
|
+
*/
|
|
85
90
|
declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: ComponentCollectorOptions): {
|
|
86
91
|
readonly ctx: {
|
|
87
92
|
readonly getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
|
|
@@ -101,9 +106,6 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint, opti
|
|
|
101
106
|
readonly listeners: {
|
|
102
107
|
readonly "ReturnStatement[type]": (node: TSESTree.ReturnStatement) => void;
|
|
103
108
|
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;
|
|
107
109
|
readonly ":function[type]": (node: AST.TSESTreeFunction) => void;
|
|
108
110
|
readonly ":function[type]:exit": () => {
|
|
109
111
|
key: string;
|
|
@@ -115,6 +117,10 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint, opti
|
|
|
115
117
|
};
|
|
116
118
|
};
|
|
117
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Get a ctx and listeners for the rule to collect class components
|
|
122
|
+
* @returns The context and listeners for the rule
|
|
123
|
+
*/
|
|
118
124
|
declare function useComponentCollectorLegacy(): {
|
|
119
125
|
readonly ctx: {
|
|
120
126
|
readonly getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
|
|
@@ -125,6 +131,17 @@ declare function useComponentCollectorLegacy(): {
|
|
|
125
131
|
};
|
|
126
132
|
};
|
|
127
133
|
|
|
134
|
+
/**
|
|
135
|
+
* The ESQuery selector for a component display name assignment expression
|
|
136
|
+
*/
|
|
137
|
+
declare const COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
|
|
138
|
+
/**
|
|
139
|
+
* Check if the node is a component display name assignment expression
|
|
140
|
+
* @param node The AST node
|
|
141
|
+
* @returns `true` if the node is a component display name assignment
|
|
142
|
+
*/
|
|
143
|
+
declare function isComponentDisplayNameAssignment(node: TSESTree.Node | _): node is TSESTree.AssignmentExpression;
|
|
144
|
+
|
|
128
145
|
declare function getFunctionComponentIdentifier(node: AST.TSESTreeFunction, context: RuleContext): TSESTree.Identifier | TSESTree.Identifier[] | _;
|
|
129
146
|
|
|
130
147
|
type ERComponentKind = "classComponent" | "functionComponent";
|
|
@@ -155,9 +172,6 @@ declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
|
|
|
155
172
|
*/
|
|
156
173
|
declare function isInsideRenderMethod(node: TSESTree.Node): boolean;
|
|
157
174
|
|
|
158
|
-
type EREffectMethodKind = "useEffect" | "useInsertionEffect" | "useLayoutEffect";
|
|
159
|
-
type ERLifecycleMethodKind = "componentDidMount" | "componentWillUnmount";
|
|
160
|
-
|
|
161
175
|
declare const RE_COMPONENT_NAME: RegExp;
|
|
162
176
|
declare function getComponentNameFromIdentifier(node: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
|
|
163
177
|
declare function isComponentName(name: string): boolean;
|
|
@@ -241,13 +255,11 @@ declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClas
|
|
|
241
255
|
*/
|
|
242
256
|
declare function isPureComponent(node: TSESTree.Node): boolean;
|
|
243
257
|
|
|
244
|
-
type EREffectKind = "
|
|
258
|
+
type EREffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
|
|
245
259
|
|
|
246
260
|
declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | _): boolean | undefined;
|
|
247
261
|
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node): boolean | undefined;
|
|
248
262
|
|
|
249
|
-
declare function getElementNameOnJsxAndHtml(node: TSESTree.JSXOpeningElement, context: RuleContext, polymorphicPropName?: string, additionalComponents?: CustomComponentNormalized[]): [string, string];
|
|
250
|
-
|
|
251
263
|
/**
|
|
252
264
|
* Determines whether inside `createElement`'s props.
|
|
253
265
|
* @param node The AST node to check
|
|
@@ -321,8 +333,6 @@ interface ERSemanticEntry {
|
|
|
321
333
|
phase: ERPhaseKind;
|
|
322
334
|
}
|
|
323
335
|
|
|
324
|
-
declare const getId: () => string;
|
|
325
|
-
|
|
326
336
|
/**
|
|
327
337
|
* Checks if the given node is a call expression to the given function or method of the pragma
|
|
328
338
|
* @param name The name of the function or method to check
|
|
@@ -351,7 +361,7 @@ type IsCallFromReactMember = {
|
|
|
351
361
|
};
|
|
352
362
|
declare function isCallFromReactMember(pragmaMemberName: string, name: string): IsCallFromReactMember;
|
|
353
363
|
|
|
354
|
-
declare function isInitializedFromReact(name: string,
|
|
364
|
+
declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
|
|
355
365
|
|
|
356
366
|
/**********************************************
|
|
357
367
|
* DO NOT MODIFY THIS FILE MANUALLY *
|
|
@@ -1964,6 +1974,7 @@ declare interface TSImportEqualsRequireDeclaration extends TSImportEqualsDeclara
|
|
|
1964
1974
|
declare interface TSImportType extends BaseNode {
|
|
1965
1975
|
type: AST_NODE_TYPES.TSImportType;
|
|
1966
1976
|
argument: TypeNode;
|
|
1977
|
+
attributes: ImportAttribute[];
|
|
1967
1978
|
qualifier: EntityName | null;
|
|
1968
1979
|
typeArguments: TSTypeParameterInstantiation | null;
|
|
1969
1980
|
}
|
|
@@ -2575,4 +2586,4 @@ declare const isMemoCall: {
|
|
|
2575
2586
|
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2576
2587
|
};
|
|
2577
2588
|
|
|
2578
|
-
export { type ComponentCollectorOptions, DEFAULT_COMPONENT_HINT, type ERClassComponent,
|
|
2589
|
+
export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, type ComponentCollectorOptions, DEFAULT_COMPONENT_HINT, type ERClassComponent, type ERComponent, ERComponentFlag, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, type ERHook, type ERHookKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDisplayNameAssignment, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as AST from '@eslint-react/ast';
|
|
2
2
|
import * as _eslint_react_shared from '@eslint-react/shared';
|
|
3
|
-
import { RuleContext
|
|
3
|
+
import { RuleContext } from '@eslint-react/shared';
|
|
4
4
|
import { TSESTree } from '@typescript-eslint/types';
|
|
5
5
|
import { _ } from '@eslint-react/eff';
|
|
6
6
|
import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
@@ -45,15 +45,13 @@ declare const ERComponentHint: {
|
|
|
45
45
|
};
|
|
46
46
|
declare const DEFAULT_COMPONENT_HINT: bigint;
|
|
47
47
|
|
|
48
|
-
type
|
|
49
|
-
declare const
|
|
48
|
+
type ERComponentFlag = bigint;
|
|
49
|
+
declare const ERComponentFlag: {
|
|
50
50
|
None: bigint;
|
|
51
51
|
PureComponent: bigint;
|
|
52
|
-
|
|
53
|
-
type ERFunctionComponentFlag = bigint;
|
|
54
|
-
declare const ERFunctionComponentFlag: {
|
|
55
|
-
None: bigint;
|
|
52
|
+
CreateElement: bigint;
|
|
56
53
|
Memo: bigint;
|
|
54
|
+
Async: bigint;
|
|
57
55
|
ForwardRef: bigint;
|
|
58
56
|
};
|
|
59
57
|
|
|
@@ -61,7 +59,7 @@ interface ERFunctionComponent extends ERSemanticNode {
|
|
|
61
59
|
id: _ | TSESTree.Identifier | TSESTree.Identifier[];
|
|
62
60
|
kind: "function";
|
|
63
61
|
node: AST.TSESTreeFunction;
|
|
64
|
-
flag:
|
|
62
|
+
flag: ERComponentFlag;
|
|
65
63
|
hint: ERComponentHint;
|
|
66
64
|
initPath: _ | AST.FunctionInitPath;
|
|
67
65
|
hookCalls: TSESTree.CallExpression[];
|
|
@@ -71,7 +69,7 @@ interface ERClassComponent extends ERSemanticNode {
|
|
|
71
69
|
id: _ | TSESTree.Identifier;
|
|
72
70
|
kind: "class";
|
|
73
71
|
node: AST.TSESTreeClass;
|
|
74
|
-
flag:
|
|
72
|
+
flag: ERComponentFlag;
|
|
75
73
|
hint: ERComponentHint;
|
|
76
74
|
methods: AST.TSESTreeMethodOrProperty[];
|
|
77
75
|
displayName: _ | TSESTree.Expression;
|
|
@@ -82,6 +80,13 @@ interface ComponentCollectorOptions {
|
|
|
82
80
|
collectDisplayName?: boolean;
|
|
83
81
|
collectHookCalls?: boolean;
|
|
84
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Get a ctx and listeners for the rule to collect function components
|
|
85
|
+
* @param context The ESLint rule context
|
|
86
|
+
* @param hint The hint to use
|
|
87
|
+
* @param options The options to use
|
|
88
|
+
* @returns The component collector
|
|
89
|
+
*/
|
|
85
90
|
declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: ComponentCollectorOptions): {
|
|
86
91
|
readonly ctx: {
|
|
87
92
|
readonly getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
|
|
@@ -101,9 +106,6 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint, opti
|
|
|
101
106
|
readonly listeners: {
|
|
102
107
|
readonly "ReturnStatement[type]": (node: TSESTree.ReturnStatement) => void;
|
|
103
108
|
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;
|
|
107
109
|
readonly ":function[type]": (node: AST.TSESTreeFunction) => void;
|
|
108
110
|
readonly ":function[type]:exit": () => {
|
|
109
111
|
key: string;
|
|
@@ -115,6 +117,10 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint, opti
|
|
|
115
117
|
};
|
|
116
118
|
};
|
|
117
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Get a ctx and listeners for the rule to collect class components
|
|
122
|
+
* @returns The context and listeners for the rule
|
|
123
|
+
*/
|
|
118
124
|
declare function useComponentCollectorLegacy(): {
|
|
119
125
|
readonly ctx: {
|
|
120
126
|
readonly getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
|
|
@@ -125,6 +131,17 @@ declare function useComponentCollectorLegacy(): {
|
|
|
125
131
|
};
|
|
126
132
|
};
|
|
127
133
|
|
|
134
|
+
/**
|
|
135
|
+
* The ESQuery selector for a component display name assignment expression
|
|
136
|
+
*/
|
|
137
|
+
declare const COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
|
|
138
|
+
/**
|
|
139
|
+
* Check if the node is a component display name assignment expression
|
|
140
|
+
* @param node The AST node
|
|
141
|
+
* @returns `true` if the node is a component display name assignment
|
|
142
|
+
*/
|
|
143
|
+
declare function isComponentDisplayNameAssignment(node: TSESTree.Node | _): node is TSESTree.AssignmentExpression;
|
|
144
|
+
|
|
128
145
|
declare function getFunctionComponentIdentifier(node: AST.TSESTreeFunction, context: RuleContext): TSESTree.Identifier | TSESTree.Identifier[] | _;
|
|
129
146
|
|
|
130
147
|
type ERComponentKind = "classComponent" | "functionComponent";
|
|
@@ -155,9 +172,6 @@ declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
|
|
|
155
172
|
*/
|
|
156
173
|
declare function isInsideRenderMethod(node: TSESTree.Node): boolean;
|
|
157
174
|
|
|
158
|
-
type EREffectMethodKind = "useEffect" | "useInsertionEffect" | "useLayoutEffect";
|
|
159
|
-
type ERLifecycleMethodKind = "componentDidMount" | "componentWillUnmount";
|
|
160
|
-
|
|
161
175
|
declare const RE_COMPONENT_NAME: RegExp;
|
|
162
176
|
declare function getComponentNameFromIdentifier(node: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
|
|
163
177
|
declare function isComponentName(name: string): boolean;
|
|
@@ -241,13 +255,11 @@ declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClas
|
|
|
241
255
|
*/
|
|
242
256
|
declare function isPureComponent(node: TSESTree.Node): boolean;
|
|
243
257
|
|
|
244
|
-
type EREffectKind = "
|
|
258
|
+
type EREffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
|
|
245
259
|
|
|
246
260
|
declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | _): boolean | undefined;
|
|
247
261
|
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node): boolean | undefined;
|
|
248
262
|
|
|
249
|
-
declare function getElementNameOnJsxAndHtml(node: TSESTree.JSXOpeningElement, context: RuleContext, polymorphicPropName?: string, additionalComponents?: CustomComponentNormalized[]): [string, string];
|
|
250
|
-
|
|
251
263
|
/**
|
|
252
264
|
* Determines whether inside `createElement`'s props.
|
|
253
265
|
* @param node The AST node to check
|
|
@@ -321,8 +333,6 @@ interface ERSemanticEntry {
|
|
|
321
333
|
phase: ERPhaseKind;
|
|
322
334
|
}
|
|
323
335
|
|
|
324
|
-
declare const getId: () => string;
|
|
325
|
-
|
|
326
336
|
/**
|
|
327
337
|
* Checks if the given node is a call expression to the given function or method of the pragma
|
|
328
338
|
* @param name The name of the function or method to check
|
|
@@ -351,7 +361,7 @@ type IsCallFromReactMember = {
|
|
|
351
361
|
};
|
|
352
362
|
declare function isCallFromReactMember(pragmaMemberName: string, name: string): IsCallFromReactMember;
|
|
353
363
|
|
|
354
|
-
declare function isInitializedFromReact(name: string,
|
|
364
|
+
declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
|
|
355
365
|
|
|
356
366
|
/**********************************************
|
|
357
367
|
* DO NOT MODIFY THIS FILE MANUALLY *
|
|
@@ -1964,6 +1974,7 @@ declare interface TSImportEqualsRequireDeclaration extends TSImportEqualsDeclara
|
|
|
1964
1974
|
declare interface TSImportType extends BaseNode {
|
|
1965
1975
|
type: AST_NODE_TYPES.TSImportType;
|
|
1966
1976
|
argument: TypeNode;
|
|
1977
|
+
attributes: ImportAttribute[];
|
|
1967
1978
|
qualifier: EntityName | null;
|
|
1968
1979
|
typeArguments: TSTypeParameterInstantiation | null;
|
|
1969
1980
|
}
|
|
@@ -2575,4 +2586,4 @@ declare const isMemoCall: {
|
|
|
2575
2586
|
(node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
|
|
2576
2587
|
};
|
|
2577
2588
|
|
|
2578
|
-
export { type ComponentCollectorOptions, DEFAULT_COMPONENT_HINT, type ERClassComponent,
|
|
2589
|
+
export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, type ComponentCollectorOptions, DEFAULT_COMPONENT_HINT, type ERClassComponent, type ERComponent, ERComponentFlag, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, type ERHook, type ERHookKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDisplayNameAssignment, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, 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
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var AST8 = require('@eslint-react/ast');
|
|
4
4
|
var eff = require('@eslint-react/eff');
|
|
5
|
-
var
|
|
5
|
+
var JSX3 = require('@eslint-react/jsx');
|
|
6
|
+
var shared = require('@eslint-react/shared');
|
|
6
7
|
var types = require('@typescript-eslint/types');
|
|
7
8
|
var VAR = require('@eslint-react/var');
|
|
8
|
-
var shared = require('@eslint-react/shared');
|
|
9
|
-
require('ts-pattern');
|
|
10
9
|
var birecord = require('birecord');
|
|
11
10
|
|
|
12
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -30,35 +29,12 @@ function _interopNamespace(e) {
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
var AST8__namespace = /*#__PURE__*/_interopNamespace(AST8);
|
|
33
|
-
var
|
|
32
|
+
var JSX3__namespace = /*#__PURE__*/_interopNamespace(JSX3);
|
|
34
33
|
var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
|
|
35
34
|
var birecord__default = /*#__PURE__*/_interopDefault(birecord);
|
|
36
35
|
|
|
37
36
|
// src/component/component-collector.ts
|
|
38
|
-
function
|
|
39
|
-
const name = JSX4__namespace.getElementName(node);
|
|
40
|
-
if (name === name.toLowerCase()) return [name, name];
|
|
41
|
-
const component = additionalComponents.findLast((c) => c.name === name || c.re.test(name));
|
|
42
|
-
if (component != null) return [name, component.as];
|
|
43
|
-
if (polymorphicPropName == null) return [name, name];
|
|
44
|
-
const initialScope = context.sourceCode.getScope(node);
|
|
45
|
-
const attributeNode = JSX4__namespace.getAttributeNode(
|
|
46
|
-
polymorphicPropName,
|
|
47
|
-
initialScope,
|
|
48
|
-
node.attributes
|
|
49
|
-
);
|
|
50
|
-
if (attributeNode == null) return [name, name];
|
|
51
|
-
const polymorphicPropValue = VAR__namespace.toResolved(JSX4__namespace.getAttributeStaticValue(attributeNode, initialScope)).value;
|
|
52
|
-
if (typeof polymorphicPropValue === "string") {
|
|
53
|
-
return [name, polymorphicPropValue];
|
|
54
|
-
}
|
|
55
|
-
return [name, name];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// src/utils/get-id.ts
|
|
59
|
-
var id = 0n;
|
|
60
|
-
var getId = () => (id++).toString();
|
|
61
|
-
function isInitializedFromReact(name, initialScope, importSource = "react") {
|
|
37
|
+
function isInitializedFromReact(name, importSource, initialScope) {
|
|
62
38
|
return name.toLowerCase() === "react" || VAR__namespace.isInitializedFromSource(
|
|
63
39
|
name,
|
|
64
40
|
importSource,
|
|
@@ -76,12 +52,13 @@ function isFromReact(name) {
|
|
|
76
52
|
}
|
|
77
53
|
return node.name === name;
|
|
78
54
|
}
|
|
55
|
+
const importSource = settings.importSource ?? shared.DEFAULT_ESLINT_REACT_SETTINGS.importSource;
|
|
79
56
|
const initialScope = context.sourceCode.getScope(node);
|
|
80
57
|
if (node.type === types.AST_NODE_TYPES.MemberExpression) {
|
|
81
|
-
return node.object.type === types.AST_NODE_TYPES.Identifier && node.property.type === types.AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name,
|
|
58
|
+
return node.object.type === types.AST_NODE_TYPES.Identifier && node.property.type === types.AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name, importSource, initialScope);
|
|
82
59
|
}
|
|
83
60
|
if (node.name === name) {
|
|
84
|
-
return isInitializedFromReact(name,
|
|
61
|
+
return isInitializedFromReact(name, importSource, initialScope);
|
|
85
62
|
}
|
|
86
63
|
return false;
|
|
87
64
|
};
|
|
@@ -101,14 +78,15 @@ function isFromReactMember(memberName, name) {
|
|
|
101
78
|
}
|
|
102
79
|
return false;
|
|
103
80
|
}
|
|
81
|
+
const importSource = settings.importSource ?? shared.DEFAULT_ESLINT_REACT_SETTINGS.importSource;
|
|
104
82
|
const initialScope = context.sourceCode.getScope(node);
|
|
105
83
|
if (node.property.type !== types.AST_NODE_TYPES.Identifier || node.property.name !== name) {
|
|
106
84
|
return false;
|
|
107
85
|
}
|
|
108
86
|
if (node.object.type === types.AST_NODE_TYPES.Identifier && node.object.name === memberName) {
|
|
109
|
-
return isInitializedFromReact(node.object.name,
|
|
87
|
+
return isInitializedFromReact(node.object.name, importSource, initialScope);
|
|
110
88
|
}
|
|
111
|
-
if (node.object.type === types.AST_NODE_TYPES.MemberExpression && node.object.object.type === types.AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name,
|
|
89
|
+
if (node.object.type === types.AST_NODE_TYPES.MemberExpression && node.object.object.type === types.AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name, importSource, initialScope) && node.object.property.type === types.AST_NODE_TYPES.Identifier) {
|
|
112
90
|
return node.object.property.name === memberName;
|
|
113
91
|
}
|
|
114
92
|
return false;
|
|
@@ -191,8 +169,8 @@ function isReactHookName(name) {
|
|
|
191
169
|
// src/hook/is.ts
|
|
192
170
|
function isReactHook(node) {
|
|
193
171
|
if (node == null) return eff._;
|
|
194
|
-
const
|
|
195
|
-
return
|
|
172
|
+
const id = AST8__namespace.getFunctionIdentifier(node);
|
|
173
|
+
return id?.name != null && isReactHookName(id.name);
|
|
196
174
|
}
|
|
197
175
|
function isReactHookCall(node) {
|
|
198
176
|
if (node == null) return false;
|
|
@@ -210,13 +188,14 @@ function isReactHookCall(node) {
|
|
|
210
188
|
function isReactHookCallWithName(node, context) {
|
|
211
189
|
if (node == null) return eff.returnFalse;
|
|
212
190
|
const settings = shared.unsafeDecodeSettings(context.settings);
|
|
191
|
+
const importSource = settings.importSource ?? "react";
|
|
192
|
+
const initialScope = context.sourceCode.getScope(node);
|
|
213
193
|
return (name) => {
|
|
214
|
-
const initialScope = context.sourceCode.getScope(node);
|
|
215
194
|
switch (true) {
|
|
216
195
|
case (node.callee.type === types.AST_NODE_TYPES.Identifier && node.callee.name === name):
|
|
217
|
-
return !settings.strictImportCheck || isInitializedFromReact(name,
|
|
196
|
+
return !settings.strictImportCheck || isInitializedFromReact(name, importSource, initialScope);
|
|
218
197
|
case (node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
|
|
219
|
-
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name,
|
|
198
|
+
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
|
|
220
199
|
default:
|
|
221
200
|
return false;
|
|
222
201
|
}
|
|
@@ -237,13 +216,14 @@ function isReactHookCallWithNameLoose(node) {
|
|
|
237
216
|
}
|
|
238
217
|
function isReactHookCallWithNameAlias(name, context, alias) {
|
|
239
218
|
const settings = shared.unsafeDecodeSettings(context);
|
|
219
|
+
const importSource = settings.importSource ?? "react";
|
|
240
220
|
return (node) => {
|
|
241
221
|
const initialScope = context.sourceCode.getScope(node);
|
|
242
222
|
switch (true) {
|
|
243
223
|
case (node.callee.type === types.AST_NODE_TYPES.Identifier && node.callee.name === name):
|
|
244
|
-
return !settings.strictImportCheck || isInitializedFromReact(name,
|
|
224
|
+
return !settings.strictImportCheck || isInitializedFromReact(name, importSource, initialScope);
|
|
245
225
|
case (node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
|
|
246
|
-
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name,
|
|
226
|
+
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
|
|
247
227
|
default:
|
|
248
228
|
return alias.some(isReactHookCallWithNameLoose(node));
|
|
249
229
|
}
|
|
@@ -287,13 +267,13 @@ function useHookCollector() {
|
|
|
287
267
|
const hooks = /* @__PURE__ */ new Map();
|
|
288
268
|
const fEntries = [];
|
|
289
269
|
const onFunctionEnter = (node) => {
|
|
290
|
-
const
|
|
291
|
-
const name =
|
|
270
|
+
const id = AST8__namespace.getFunctionIdentifier(node);
|
|
271
|
+
const name = id?.name;
|
|
292
272
|
if (name != null && isReactHookName(name)) {
|
|
293
|
-
const key = getId();
|
|
273
|
+
const key = shared.getId();
|
|
294
274
|
fEntries.push({ key, node });
|
|
295
275
|
hooks.set(key, {
|
|
296
|
-
id
|
|
276
|
+
id,
|
|
297
277
|
key,
|
|
298
278
|
kind: "function",
|
|
299
279
|
name,
|
|
@@ -339,7 +319,7 @@ function useHookCollector() {
|
|
|
339
319
|
return { ctx, listeners };
|
|
340
320
|
}
|
|
341
321
|
var ERComponentHint = {
|
|
342
|
-
...
|
|
322
|
+
...JSX3__namespace.JSXValueHint,
|
|
343
323
|
// 1n << 0n - 1n << 63n are reserved for JSXValueHint
|
|
344
324
|
// Skip function component created by React.memo
|
|
345
325
|
SkipMemo: 1n << 64n,
|
|
@@ -355,24 +335,26 @@ var ERComponentHint = {
|
|
|
355
335
|
SkipClassProperty: 1n << 69n
|
|
356
336
|
};
|
|
357
337
|
var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipMapCallback | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipEmptyArray | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
|
|
338
|
+
var COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
|
|
339
|
+
"AssignmentExpression",
|
|
340
|
+
"[type]",
|
|
341
|
+
"[operator='=']",
|
|
342
|
+
"[left.type='MemberExpression']",
|
|
343
|
+
"[left.property.name='displayName']"
|
|
344
|
+
].join("");
|
|
345
|
+
function isComponentDisplayNameAssignment(node) {
|
|
346
|
+
if (node == null) return false;
|
|
347
|
+
return node.type === types.AST_NODE_TYPES.AssignmentExpression && node.operator === "=" && node.left.type === types.AST_NODE_TYPES.MemberExpression && node.left.property.type === types.AST_NODE_TYPES.Identifier && node.left.property.name === "displayName";
|
|
348
|
+
}
|
|
358
349
|
|
|
359
350
|
// src/component/component-flag.ts
|
|
360
|
-
var
|
|
351
|
+
var ERComponentFlag = {
|
|
361
352
|
None: 0n,
|
|
362
|
-
PureComponent: 1n << 0n
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
None: 0n,
|
|
368
|
-
Memo: 1n << 0n,
|
|
369
|
-
ForwardRef: 1n << 1n
|
|
370
|
-
// Reserved for future use
|
|
371
|
-
// CreateElement: 1n << 2n,
|
|
372
|
-
// Reserved for future use
|
|
373
|
-
// hasHooks: 1n << 3n,
|
|
374
|
-
// Reserved for future use
|
|
375
|
-
// Async: 1n << 4n,
|
|
353
|
+
PureComponent: 1n << 0n,
|
|
354
|
+
CreateElement: 1n << 1n,
|
|
355
|
+
Memo: 1n << 2n,
|
|
356
|
+
Async: 1n << 3n,
|
|
357
|
+
ForwardRef: 1n << 4n
|
|
376
358
|
};
|
|
377
359
|
function isComponentWrapperCall(node, context) {
|
|
378
360
|
if (node.type !== types.AST_NODE_TYPES.CallExpression) {
|
|
@@ -418,6 +400,8 @@ function isPureComponent(node) {
|
|
|
418
400
|
}
|
|
419
401
|
return false;
|
|
420
402
|
}
|
|
403
|
+
|
|
404
|
+
// src/component/component-lifecycle.ts
|
|
421
405
|
function isComponentDidMount(node) {
|
|
422
406
|
return AST8__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
423
407
|
}
|
|
@@ -460,9 +444,9 @@ function isComponentName(name) {
|
|
|
460
444
|
return RE_COMPONENT_NAME.test(name);
|
|
461
445
|
}
|
|
462
446
|
function hasNoneOrValidComponentName(node, context) {
|
|
463
|
-
const
|
|
464
|
-
if (
|
|
465
|
-
const name = Array.isArray(
|
|
447
|
+
const id = getFunctionComponentIdentifier(node, context);
|
|
448
|
+
if (id == null) return true;
|
|
449
|
+
const name = Array.isArray(id) ? id.at(-1)?.name : id.name;
|
|
466
450
|
return name != null && isComponentName(name);
|
|
467
451
|
}
|
|
468
452
|
|
|
@@ -496,16 +480,15 @@ function hasValidHierarchy(node, context, hint) {
|
|
|
496
480
|
return boundaryNode == null || boundaryNode.type !== types.AST_NODE_TYPES.JSXExpressionContainer;
|
|
497
481
|
}
|
|
498
482
|
function getComponentFlag(initPath) {
|
|
499
|
-
let flag =
|
|
483
|
+
let flag = ERComponentFlag.None;
|
|
500
484
|
if (initPath != null && AST8__namespace.hasCallInFunctionInitPath("memo", initPath)) {
|
|
501
|
-
flag |=
|
|
485
|
+
flag |= ERComponentFlag.Memo;
|
|
502
486
|
}
|
|
503
487
|
if (initPath != null && AST8__namespace.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
504
|
-
flag |=
|
|
488
|
+
flag |= ERComponentFlag.ForwardRef;
|
|
505
489
|
}
|
|
506
490
|
return flag;
|
|
507
491
|
}
|
|
508
|
-
var displayNameAssignmentSelector = "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']";
|
|
509
492
|
function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options = {}) {
|
|
510
493
|
const { collectDisplayName = false, collectHookCalls = false } = options;
|
|
511
494
|
const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) };
|
|
@@ -513,7 +496,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
513
496
|
const functionEntries = [];
|
|
514
497
|
const getCurrentEntry = () => functionEntries.at(-1);
|
|
515
498
|
const onFunctionEnter = (node) => {
|
|
516
|
-
const key = getId();
|
|
499
|
+
const key = shared.getId();
|
|
517
500
|
functionEntries.push({ key, node, hookCalls: [], isComponent: false });
|
|
518
501
|
};
|
|
519
502
|
const onFunctionExit = () => {
|
|
@@ -523,7 +506,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
523
506
|
return functionEntries.pop();
|
|
524
507
|
}
|
|
525
508
|
const shouldDrop = AST8__namespace.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
|
|
526
|
-
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !
|
|
509
|
+
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3__namespace.isJSXValue(r.argument, jsxCtx, hint);
|
|
527
510
|
});
|
|
528
511
|
if (shouldDrop) {
|
|
529
512
|
components.delete(entry.key);
|
|
@@ -549,16 +532,16 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
549
532
|
return;
|
|
550
533
|
}
|
|
551
534
|
const { body } = entry.node;
|
|
552
|
-
const isComponent = hasNoneOrValidComponentName(entry.node, context) &&
|
|
535
|
+
const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3__namespace.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
|
|
553
536
|
if (!isComponent) {
|
|
554
537
|
return;
|
|
555
538
|
}
|
|
556
539
|
const initPath = AST8__namespace.getFunctionInitPath(entry.node);
|
|
557
|
-
const
|
|
558
|
-
const name = getComponentNameFromIdentifier(
|
|
559
|
-
const key = getId();
|
|
540
|
+
const id = getFunctionComponentIdentifier(entry.node, context);
|
|
541
|
+
const name = getComponentNameFromIdentifier(id);
|
|
542
|
+
const key = shared.getId();
|
|
560
543
|
components.set(key, {
|
|
561
|
-
id
|
|
544
|
+
id,
|
|
562
545
|
key,
|
|
563
546
|
kind: "function",
|
|
564
547
|
name,
|
|
@@ -571,8 +554,9 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
571
554
|
});
|
|
572
555
|
},
|
|
573
556
|
...collectDisplayName ? {
|
|
574
|
-
[
|
|
557
|
+
[COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
|
|
575
558
|
const { left, right } = node;
|
|
559
|
+
if (left.type !== types.AST_NODE_TYPES.MemberExpression) return;
|
|
576
560
|
const componentName = left.object.type === types.AST_NODE_TYPES.Identifier ? left.object.name : eff._;
|
|
577
561
|
const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
|
|
578
562
|
if (component == null) {
|
|
@@ -598,17 +582,17 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
598
582
|
if (entry == null) {
|
|
599
583
|
return;
|
|
600
584
|
}
|
|
601
|
-
const isComponent = hasNoneOrValidComponentName(entry.node, context) &&
|
|
585
|
+
const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3__namespace.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
|
|
602
586
|
if (!isComponent) {
|
|
603
587
|
return;
|
|
604
588
|
}
|
|
605
589
|
functionEntries.pop();
|
|
606
590
|
functionEntries.push({ ...entry, isComponent });
|
|
607
591
|
const initPath = AST8__namespace.getFunctionInitPath(entry.node);
|
|
608
|
-
const
|
|
609
|
-
const name = getComponentNameFromIdentifier(
|
|
592
|
+
const id = getFunctionComponentIdentifier(entry.node, context);
|
|
593
|
+
const name = getComponentNameFromIdentifier(id);
|
|
610
594
|
components.set(entry.key, {
|
|
611
|
-
id
|
|
595
|
+
id,
|
|
612
596
|
key: entry.key,
|
|
613
597
|
kind: "function",
|
|
614
598
|
name,
|
|
@@ -635,16 +619,16 @@ function useComponentCollectorLegacy() {
|
|
|
635
619
|
if (!isClassComponent(node)) {
|
|
636
620
|
return;
|
|
637
621
|
}
|
|
638
|
-
const
|
|
639
|
-
const key = getId();
|
|
640
|
-
const flag = isPureComponent(node) ?
|
|
622
|
+
const id = AST8__namespace.getClassIdentifier(node);
|
|
623
|
+
const key = shared.getId();
|
|
624
|
+
const flag = isPureComponent(node) ? ERComponentFlag.PureComponent : ERComponentFlag.None;
|
|
641
625
|
components.set(
|
|
642
626
|
key,
|
|
643
627
|
{
|
|
644
|
-
id
|
|
628
|
+
id,
|
|
645
629
|
key,
|
|
646
630
|
kind: "class",
|
|
647
|
-
name:
|
|
631
|
+
name: id?.name,
|
|
648
632
|
node,
|
|
649
633
|
// TODO: Get displayName of class component
|
|
650
634
|
displayName: eff._,
|
|
@@ -671,12 +655,12 @@ function isRenderFunctionLoose(node, context) {
|
|
|
671
655
|
if (AST8__namespace.getFunctionIdentifier(node)?.name.startsWith("render")) {
|
|
672
656
|
return parent.type === types.AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === types.AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === types.AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
|
|
673
657
|
}
|
|
674
|
-
return
|
|
658
|
+
return JSX3__namespace.isJSXValue(
|
|
675
659
|
body,
|
|
676
660
|
{
|
|
677
661
|
getScope: (node2) => context.sourceCode.getScope(node2)
|
|
678
662
|
},
|
|
679
|
-
|
|
663
|
+
JSX3__namespace.JSXValueHint.SkipNullLiteral | JSX3__namespace.JSXValueHint.SkipUndefined | JSX3__namespace.JSXValueHint.StrictLogical | JSX3__namespace.JSXValueHint.StrictConditional
|
|
680
664
|
);
|
|
681
665
|
}
|
|
682
666
|
function isRenderPropLoose(node, context) {
|
|
@@ -716,17 +700,15 @@ function isFunctionOfUseEffectCleanup(node) {
|
|
|
716
700
|
return nearFunction === nearFunctionOfReturn && isFunctionOfUseEffectSetup(nearFunction);
|
|
717
701
|
}
|
|
718
702
|
|
|
703
|
+
exports.COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR = COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR;
|
|
719
704
|
exports.DEFAULT_COMPONENT_HINT = DEFAULT_COMPONENT_HINT;
|
|
720
|
-
exports.
|
|
705
|
+
exports.ERComponentFlag = ERComponentFlag;
|
|
721
706
|
exports.ERComponentHint = ERComponentHint;
|
|
722
|
-
exports.ERFunctionComponentFlag = ERFunctionComponentFlag;
|
|
723
707
|
exports.ERPhaseRelevance = ERPhaseRelevance;
|
|
724
708
|
exports.RE_COMPONENT_NAME = RE_COMPONENT_NAME;
|
|
725
709
|
exports.RE_HOOK_NAME = RE_HOOK_NAME;
|
|
726
710
|
exports.getComponentNameFromIdentifier = getComponentNameFromIdentifier;
|
|
727
|
-
exports.getElementNameOnJsxAndHtml = getElementNameOnJsxAndHtml;
|
|
728
711
|
exports.getFunctionComponentIdentifier = getFunctionComponentIdentifier;
|
|
729
|
-
exports.getId = getId;
|
|
730
712
|
exports.hasNoneOrValidComponentName = hasNoneOrValidComponentName;
|
|
731
713
|
exports.isCallFromReact = isCallFromReact;
|
|
732
714
|
exports.isCallFromReactMember = isCallFromReactMember;
|
|
@@ -746,6 +728,7 @@ exports.isCloneElement = isCloneElement;
|
|
|
746
728
|
exports.isCloneElementCall = isCloneElementCall;
|
|
747
729
|
exports.isComponentDidCatch = isComponentDidCatch;
|
|
748
730
|
exports.isComponentDidMount = isComponentDidMount;
|
|
731
|
+
exports.isComponentDisplayNameAssignment = isComponentDisplayNameAssignment;
|
|
749
732
|
exports.isComponentName = isComponentName;
|
|
750
733
|
exports.isComponentWillUnmount = isComponentWillUnmount;
|
|
751
734
|
exports.isCreateContext = isCreateContext;
|
package/dist/index.mjs
CHANGED
|
@@ -1,37 +1,13 @@
|
|
|
1
1
|
import * as AST8 from '@eslint-react/ast';
|
|
2
2
|
import { flip, dual, _, returnFalse } from '@eslint-react/eff';
|
|
3
|
-
import * as
|
|
3
|
+
import * as JSX3 from '@eslint-react/jsx';
|
|
4
|
+
import { unsafeDecodeSettings, DEFAULT_ESLINT_REACT_SETTINGS, getId } from '@eslint-react/shared';
|
|
4
5
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
5
6
|
import * as VAR from '@eslint-react/var';
|
|
6
|
-
import { unsafeDecodeSettings } from '@eslint-react/shared';
|
|
7
|
-
import 'ts-pattern';
|
|
8
7
|
import birecord from 'birecord';
|
|
9
8
|
|
|
10
9
|
// src/component/component-collector.ts
|
|
11
|
-
function
|
|
12
|
-
const name = JSX4.getElementName(node);
|
|
13
|
-
if (name === name.toLowerCase()) return [name, name];
|
|
14
|
-
const component = additionalComponents.findLast((c) => c.name === name || c.re.test(name));
|
|
15
|
-
if (component != null) return [name, component.as];
|
|
16
|
-
if (polymorphicPropName == null) return [name, name];
|
|
17
|
-
const initialScope = context.sourceCode.getScope(node);
|
|
18
|
-
const attributeNode = JSX4.getAttributeNode(
|
|
19
|
-
polymorphicPropName,
|
|
20
|
-
initialScope,
|
|
21
|
-
node.attributes
|
|
22
|
-
);
|
|
23
|
-
if (attributeNode == null) return [name, name];
|
|
24
|
-
const polymorphicPropValue = VAR.toResolved(JSX4.getAttributeStaticValue(attributeNode, initialScope)).value;
|
|
25
|
-
if (typeof polymorphicPropValue === "string") {
|
|
26
|
-
return [name, polymorphicPropValue];
|
|
27
|
-
}
|
|
28
|
-
return [name, name];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// src/utils/get-id.ts
|
|
32
|
-
var id = 0n;
|
|
33
|
-
var getId = () => (id++).toString();
|
|
34
|
-
function isInitializedFromReact(name, initialScope, importSource = "react") {
|
|
10
|
+
function isInitializedFromReact(name, importSource, initialScope) {
|
|
35
11
|
return name.toLowerCase() === "react" || VAR.isInitializedFromSource(
|
|
36
12
|
name,
|
|
37
13
|
importSource,
|
|
@@ -49,12 +25,13 @@ function isFromReact(name) {
|
|
|
49
25
|
}
|
|
50
26
|
return node.name === name;
|
|
51
27
|
}
|
|
28
|
+
const importSource = settings.importSource ?? DEFAULT_ESLINT_REACT_SETTINGS.importSource;
|
|
52
29
|
const initialScope = context.sourceCode.getScope(node);
|
|
53
30
|
if (node.type === AST_NODE_TYPES.MemberExpression) {
|
|
54
|
-
return node.object.type === AST_NODE_TYPES.Identifier && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name,
|
|
31
|
+
return node.object.type === AST_NODE_TYPES.Identifier && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name, importSource, initialScope);
|
|
55
32
|
}
|
|
56
33
|
if (node.name === name) {
|
|
57
|
-
return isInitializedFromReact(name,
|
|
34
|
+
return isInitializedFromReact(name, importSource, initialScope);
|
|
58
35
|
}
|
|
59
36
|
return false;
|
|
60
37
|
};
|
|
@@ -74,14 +51,15 @@ function isFromReactMember(memberName, name) {
|
|
|
74
51
|
}
|
|
75
52
|
return false;
|
|
76
53
|
}
|
|
54
|
+
const importSource = settings.importSource ?? DEFAULT_ESLINT_REACT_SETTINGS.importSource;
|
|
77
55
|
const initialScope = context.sourceCode.getScope(node);
|
|
78
56
|
if (node.property.type !== AST_NODE_TYPES.Identifier || node.property.name !== name) {
|
|
79
57
|
return false;
|
|
80
58
|
}
|
|
81
59
|
if (node.object.type === AST_NODE_TYPES.Identifier && node.object.name === memberName) {
|
|
82
|
-
return isInitializedFromReact(node.object.name,
|
|
60
|
+
return isInitializedFromReact(node.object.name, importSource, initialScope);
|
|
83
61
|
}
|
|
84
|
-
if (node.object.type === AST_NODE_TYPES.MemberExpression && node.object.object.type === AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name,
|
|
62
|
+
if (node.object.type === AST_NODE_TYPES.MemberExpression && node.object.object.type === AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name, importSource, initialScope) && node.object.property.type === AST_NODE_TYPES.Identifier) {
|
|
85
63
|
return node.object.property.name === memberName;
|
|
86
64
|
}
|
|
87
65
|
return false;
|
|
@@ -164,8 +142,8 @@ function isReactHookName(name) {
|
|
|
164
142
|
// src/hook/is.ts
|
|
165
143
|
function isReactHook(node) {
|
|
166
144
|
if (node == null) return _;
|
|
167
|
-
const
|
|
168
|
-
return
|
|
145
|
+
const id = AST8.getFunctionIdentifier(node);
|
|
146
|
+
return id?.name != null && isReactHookName(id.name);
|
|
169
147
|
}
|
|
170
148
|
function isReactHookCall(node) {
|
|
171
149
|
if (node == null) return false;
|
|
@@ -183,13 +161,14 @@ function isReactHookCall(node) {
|
|
|
183
161
|
function isReactHookCallWithName(node, context) {
|
|
184
162
|
if (node == null) return returnFalse;
|
|
185
163
|
const settings = unsafeDecodeSettings(context.settings);
|
|
164
|
+
const importSource = settings.importSource ?? "react";
|
|
165
|
+
const initialScope = context.sourceCode.getScope(node);
|
|
186
166
|
return (name) => {
|
|
187
|
-
const initialScope = context.sourceCode.getScope(node);
|
|
188
167
|
switch (true) {
|
|
189
168
|
case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === name):
|
|
190
|
-
return !settings.strictImportCheck || isInitializedFromReact(name,
|
|
169
|
+
return !settings.strictImportCheck || isInitializedFromReact(name, importSource, initialScope);
|
|
191
170
|
case (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
|
|
192
|
-
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name,
|
|
171
|
+
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
|
|
193
172
|
default:
|
|
194
173
|
return false;
|
|
195
174
|
}
|
|
@@ -210,13 +189,14 @@ function isReactHookCallWithNameLoose(node) {
|
|
|
210
189
|
}
|
|
211
190
|
function isReactHookCallWithNameAlias(name, context, alias) {
|
|
212
191
|
const settings = unsafeDecodeSettings(context);
|
|
192
|
+
const importSource = settings.importSource ?? "react";
|
|
213
193
|
return (node) => {
|
|
214
194
|
const initialScope = context.sourceCode.getScope(node);
|
|
215
195
|
switch (true) {
|
|
216
196
|
case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === name):
|
|
217
|
-
return !settings.strictImportCheck || isInitializedFromReact(name,
|
|
197
|
+
return !settings.strictImportCheck || isInitializedFromReact(name, importSource, initialScope);
|
|
218
198
|
case (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
|
|
219
|
-
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name,
|
|
199
|
+
return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
|
|
220
200
|
default:
|
|
221
201
|
return alias.some(isReactHookCallWithNameLoose(node));
|
|
222
202
|
}
|
|
@@ -260,13 +240,13 @@ function useHookCollector() {
|
|
|
260
240
|
const hooks = /* @__PURE__ */ new Map();
|
|
261
241
|
const fEntries = [];
|
|
262
242
|
const onFunctionEnter = (node) => {
|
|
263
|
-
const
|
|
264
|
-
const name =
|
|
243
|
+
const id = AST8.getFunctionIdentifier(node);
|
|
244
|
+
const name = id?.name;
|
|
265
245
|
if (name != null && isReactHookName(name)) {
|
|
266
246
|
const key = getId();
|
|
267
247
|
fEntries.push({ key, node });
|
|
268
248
|
hooks.set(key, {
|
|
269
|
-
id
|
|
249
|
+
id,
|
|
270
250
|
key,
|
|
271
251
|
kind: "function",
|
|
272
252
|
name,
|
|
@@ -312,7 +292,7 @@ function useHookCollector() {
|
|
|
312
292
|
return { ctx, listeners };
|
|
313
293
|
}
|
|
314
294
|
var ERComponentHint = {
|
|
315
|
-
...
|
|
295
|
+
...JSX3.JSXValueHint,
|
|
316
296
|
// 1n << 0n - 1n << 63n are reserved for JSXValueHint
|
|
317
297
|
// Skip function component created by React.memo
|
|
318
298
|
SkipMemo: 1n << 64n,
|
|
@@ -328,24 +308,26 @@ var ERComponentHint = {
|
|
|
328
308
|
SkipClassProperty: 1n << 69n
|
|
329
309
|
};
|
|
330
310
|
var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipMapCallback | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipEmptyArray | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
|
|
311
|
+
var COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
|
|
312
|
+
"AssignmentExpression",
|
|
313
|
+
"[type]",
|
|
314
|
+
"[operator='=']",
|
|
315
|
+
"[left.type='MemberExpression']",
|
|
316
|
+
"[left.property.name='displayName']"
|
|
317
|
+
].join("");
|
|
318
|
+
function isComponentDisplayNameAssignment(node) {
|
|
319
|
+
if (node == null) return false;
|
|
320
|
+
return node.type === AST_NODE_TYPES.AssignmentExpression && node.operator === "=" && node.left.type === AST_NODE_TYPES.MemberExpression && node.left.property.type === AST_NODE_TYPES.Identifier && node.left.property.name === "displayName";
|
|
321
|
+
}
|
|
331
322
|
|
|
332
323
|
// src/component/component-flag.ts
|
|
333
|
-
var
|
|
324
|
+
var ERComponentFlag = {
|
|
334
325
|
None: 0n,
|
|
335
|
-
PureComponent: 1n << 0n
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
None: 0n,
|
|
341
|
-
Memo: 1n << 0n,
|
|
342
|
-
ForwardRef: 1n << 1n
|
|
343
|
-
// Reserved for future use
|
|
344
|
-
// CreateElement: 1n << 2n,
|
|
345
|
-
// Reserved for future use
|
|
346
|
-
// hasHooks: 1n << 3n,
|
|
347
|
-
// Reserved for future use
|
|
348
|
-
// Async: 1n << 4n,
|
|
326
|
+
PureComponent: 1n << 0n,
|
|
327
|
+
CreateElement: 1n << 1n,
|
|
328
|
+
Memo: 1n << 2n,
|
|
329
|
+
Async: 1n << 3n,
|
|
330
|
+
ForwardRef: 1n << 4n
|
|
349
331
|
};
|
|
350
332
|
function isComponentWrapperCall(node, context) {
|
|
351
333
|
if (node.type !== AST_NODE_TYPES.CallExpression) {
|
|
@@ -391,6 +373,8 @@ function isPureComponent(node) {
|
|
|
391
373
|
}
|
|
392
374
|
return false;
|
|
393
375
|
}
|
|
376
|
+
|
|
377
|
+
// src/component/component-lifecycle.ts
|
|
394
378
|
function isComponentDidMount(node) {
|
|
395
379
|
return AST8.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
396
380
|
}
|
|
@@ -433,9 +417,9 @@ function isComponentName(name) {
|
|
|
433
417
|
return RE_COMPONENT_NAME.test(name);
|
|
434
418
|
}
|
|
435
419
|
function hasNoneOrValidComponentName(node, context) {
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
438
|
-
const name = Array.isArray(
|
|
420
|
+
const id = getFunctionComponentIdentifier(node, context);
|
|
421
|
+
if (id == null) return true;
|
|
422
|
+
const name = Array.isArray(id) ? id.at(-1)?.name : id.name;
|
|
439
423
|
return name != null && isComponentName(name);
|
|
440
424
|
}
|
|
441
425
|
|
|
@@ -469,16 +453,15 @@ function hasValidHierarchy(node, context, hint) {
|
|
|
469
453
|
return boundaryNode == null || boundaryNode.type !== AST_NODE_TYPES.JSXExpressionContainer;
|
|
470
454
|
}
|
|
471
455
|
function getComponentFlag(initPath) {
|
|
472
|
-
let flag =
|
|
456
|
+
let flag = ERComponentFlag.None;
|
|
473
457
|
if (initPath != null && AST8.hasCallInFunctionInitPath("memo", initPath)) {
|
|
474
|
-
flag |=
|
|
458
|
+
flag |= ERComponentFlag.Memo;
|
|
475
459
|
}
|
|
476
460
|
if (initPath != null && AST8.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
477
|
-
flag |=
|
|
461
|
+
flag |= ERComponentFlag.ForwardRef;
|
|
478
462
|
}
|
|
479
463
|
return flag;
|
|
480
464
|
}
|
|
481
|
-
var displayNameAssignmentSelector = "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']";
|
|
482
465
|
function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options = {}) {
|
|
483
466
|
const { collectDisplayName = false, collectHookCalls = false } = options;
|
|
484
467
|
const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) };
|
|
@@ -496,7 +479,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
496
479
|
return functionEntries.pop();
|
|
497
480
|
}
|
|
498
481
|
const shouldDrop = AST8.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
|
|
499
|
-
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !
|
|
482
|
+
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3.isJSXValue(r.argument, jsxCtx, hint);
|
|
500
483
|
});
|
|
501
484
|
if (shouldDrop) {
|
|
502
485
|
components.delete(entry.key);
|
|
@@ -522,16 +505,16 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
522
505
|
return;
|
|
523
506
|
}
|
|
524
507
|
const { body } = entry.node;
|
|
525
|
-
const isComponent = hasNoneOrValidComponentName(entry.node, context) &&
|
|
508
|
+
const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
|
|
526
509
|
if (!isComponent) {
|
|
527
510
|
return;
|
|
528
511
|
}
|
|
529
512
|
const initPath = AST8.getFunctionInitPath(entry.node);
|
|
530
|
-
const
|
|
531
|
-
const name = getComponentNameFromIdentifier(
|
|
513
|
+
const id = getFunctionComponentIdentifier(entry.node, context);
|
|
514
|
+
const name = getComponentNameFromIdentifier(id);
|
|
532
515
|
const key = getId();
|
|
533
516
|
components.set(key, {
|
|
534
|
-
id
|
|
517
|
+
id,
|
|
535
518
|
key,
|
|
536
519
|
kind: "function",
|
|
537
520
|
name,
|
|
@@ -544,8 +527,9 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
544
527
|
});
|
|
545
528
|
},
|
|
546
529
|
...collectDisplayName ? {
|
|
547
|
-
[
|
|
530
|
+
[COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
|
|
548
531
|
const { left, right } = node;
|
|
532
|
+
if (left.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
549
533
|
const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : _;
|
|
550
534
|
const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
|
|
551
535
|
if (component == null) {
|
|
@@ -571,17 +555,17 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
571
555
|
if (entry == null) {
|
|
572
556
|
return;
|
|
573
557
|
}
|
|
574
|
-
const isComponent = hasNoneOrValidComponentName(entry.node, context) &&
|
|
558
|
+
const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
|
|
575
559
|
if (!isComponent) {
|
|
576
560
|
return;
|
|
577
561
|
}
|
|
578
562
|
functionEntries.pop();
|
|
579
563
|
functionEntries.push({ ...entry, isComponent });
|
|
580
564
|
const initPath = AST8.getFunctionInitPath(entry.node);
|
|
581
|
-
const
|
|
582
|
-
const name = getComponentNameFromIdentifier(
|
|
565
|
+
const id = getFunctionComponentIdentifier(entry.node, context);
|
|
566
|
+
const name = getComponentNameFromIdentifier(id);
|
|
583
567
|
components.set(entry.key, {
|
|
584
|
-
id
|
|
568
|
+
id,
|
|
585
569
|
key: entry.key,
|
|
586
570
|
kind: "function",
|
|
587
571
|
name,
|
|
@@ -608,16 +592,16 @@ function useComponentCollectorLegacy() {
|
|
|
608
592
|
if (!isClassComponent(node)) {
|
|
609
593
|
return;
|
|
610
594
|
}
|
|
611
|
-
const
|
|
595
|
+
const id = AST8.getClassIdentifier(node);
|
|
612
596
|
const key = getId();
|
|
613
|
-
const flag = isPureComponent(node) ?
|
|
597
|
+
const flag = isPureComponent(node) ? ERComponentFlag.PureComponent : ERComponentFlag.None;
|
|
614
598
|
components.set(
|
|
615
599
|
key,
|
|
616
600
|
{
|
|
617
|
-
id
|
|
601
|
+
id,
|
|
618
602
|
key,
|
|
619
603
|
kind: "class",
|
|
620
|
-
name:
|
|
604
|
+
name: id?.name,
|
|
621
605
|
node,
|
|
622
606
|
// TODO: Get displayName of class component
|
|
623
607
|
displayName: _,
|
|
@@ -644,12 +628,12 @@ function isRenderFunctionLoose(node, context) {
|
|
|
644
628
|
if (AST8.getFunctionIdentifier(node)?.name.startsWith("render")) {
|
|
645
629
|
return parent.type === AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
|
|
646
630
|
}
|
|
647
|
-
return
|
|
631
|
+
return JSX3.isJSXValue(
|
|
648
632
|
body,
|
|
649
633
|
{
|
|
650
634
|
getScope: (node2) => context.sourceCode.getScope(node2)
|
|
651
635
|
},
|
|
652
|
-
|
|
636
|
+
JSX3.JSXValueHint.SkipNullLiteral | JSX3.JSXValueHint.SkipUndefined | JSX3.JSXValueHint.StrictLogical | JSX3.JSXValueHint.StrictConditional
|
|
653
637
|
);
|
|
654
638
|
}
|
|
655
639
|
function isRenderPropLoose(node, context) {
|
|
@@ -689,4 +673,4 @@ function isFunctionOfUseEffectCleanup(node) {
|
|
|
689
673
|
return nearFunction === nearFunctionOfReturn && isFunctionOfUseEffectSetup(nearFunction);
|
|
690
674
|
}
|
|
691
675
|
|
|
692
|
-
export { DEFAULT_COMPONENT_HINT,
|
|
676
|
+
export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, DEFAULT_COMPONENT_HINT, ERComponentFlag, ERComponentHint, ERPhaseRelevance, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDisplayNameAssignment, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, 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.24.
|
|
3
|
+
"version": "1.24.1-beta.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": {
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"./package.json"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
37
|
-
"@typescript-eslint/type-utils": "^8.
|
|
38
|
-
"@typescript-eslint/types": "^8.
|
|
39
|
-
"@typescript-eslint/utils": "^8.
|
|
36
|
+
"@typescript-eslint/scope-manager": "^8.21.0",
|
|
37
|
+
"@typescript-eslint/type-utils": "^8.21.0",
|
|
38
|
+
"@typescript-eslint/types": "^8.21.0",
|
|
39
|
+
"@typescript-eslint/utils": "^8.21.0",
|
|
40
40
|
"birecord": "^0.1.1",
|
|
41
|
-
"ts-pattern": "^5.6.
|
|
42
|
-
"@eslint-react/ast": "1.24.
|
|
43
|
-
"@eslint-react/eff": "1.24.
|
|
44
|
-
"@eslint-react/jsx": "1.24.
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
41
|
+
"ts-pattern": "^5.6.2",
|
|
42
|
+
"@eslint-react/ast": "1.24.1-beta.1",
|
|
43
|
+
"@eslint-react/eff": "1.24.1-beta.1",
|
|
44
|
+
"@eslint-react/jsx": "1.24.1-beta.1",
|
|
45
|
+
"@eslint-react/shared": "1.24.1-beta.1",
|
|
46
|
+
"@eslint-react/var": "1.24.1-beta.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"tsup": "^8.3.5",
|