@eslint-react/core 1.38.2 → 1.38.3-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +12 -12
- package/dist/index.mjs +11 -11
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -134,7 +134,7 @@ declare namespace useComponentCollectorLegacy {
|
|
|
134
134
|
*/
|
|
135
135
|
declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
|
|
136
136
|
|
|
137
|
-
declare function
|
|
137
|
+
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | _;
|
|
138
138
|
|
|
139
139
|
type ERComponentKind = "classComponent" | "functionComponent";
|
|
140
140
|
|
|
@@ -168,8 +168,8 @@ declare const RE_COMPONENT_NAME: RegExp;
|
|
|
168
168
|
declare const RE_COMPONENT_NAME_LOOSE: RegExp;
|
|
169
169
|
declare function isComponentName(name: string): boolean;
|
|
170
170
|
declare function isComponentNameLoose(name: string): boolean;
|
|
171
|
-
declare function
|
|
172
|
-
declare function hasNoneOrLooseComponentName(context: RuleContext,
|
|
171
|
+
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
|
|
172
|
+
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
173
173
|
|
|
174
174
|
type EREffectPhaseKind = "cleanup" | "setup";
|
|
175
175
|
type ERLifecyclePhaseKind = "mount" | "unmount";
|
|
@@ -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 { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, 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_COMPONENT_NAME_LOOSE, RE_HOOK_NAME,
|
|
394
|
+
export { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, 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_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/dist/index.d.ts
CHANGED
|
@@ -134,7 +134,7 @@ declare namespace useComponentCollectorLegacy {
|
|
|
134
134
|
*/
|
|
135
135
|
declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
|
|
136
136
|
|
|
137
|
-
declare function
|
|
137
|
+
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | _;
|
|
138
138
|
|
|
139
139
|
type ERComponentKind = "classComponent" | "functionComponent";
|
|
140
140
|
|
|
@@ -168,8 +168,8 @@ declare const RE_COMPONENT_NAME: RegExp;
|
|
|
168
168
|
declare const RE_COMPONENT_NAME_LOOSE: RegExp;
|
|
169
169
|
declare function isComponentName(name: string): boolean;
|
|
170
170
|
declare function isComponentNameLoose(name: string): boolean;
|
|
171
|
-
declare function
|
|
172
|
-
declare function hasNoneOrLooseComponentName(context: RuleContext,
|
|
171
|
+
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
|
|
172
|
+
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
173
173
|
|
|
174
174
|
type EREffectPhaseKind = "cleanup" | "setup";
|
|
175
175
|
type ERLifecyclePhaseKind = "mount" | "unmount";
|
|
@@ -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 { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, 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_COMPONENT_NAME_LOOSE, RE_HOOK_NAME,
|
|
394
|
+
export { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, 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_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/dist/index.js
CHANGED
|
@@ -862,7 +862,7 @@ function isComponentWrapperCall(context, node) {
|
|
|
862
862
|
}
|
|
863
863
|
return isMemoCall(context, node) || isForwardRefCall(context, node) || isReactHookCallWithNameLoose(node)("useCallback");
|
|
864
864
|
}
|
|
865
|
-
function
|
|
865
|
+
function getFunctionComponentId(context, node) {
|
|
866
866
|
const functionId = AST6__namespace.getFunctionIdentifier(node);
|
|
867
867
|
if (functionId != null) {
|
|
868
868
|
return functionId;
|
|
@@ -884,12 +884,12 @@ function isComponentName(name) {
|
|
|
884
884
|
function isComponentNameLoose(name) {
|
|
885
885
|
return RE_COMPONENT_NAME_LOOSE.test(name);
|
|
886
886
|
}
|
|
887
|
-
function
|
|
888
|
-
if (
|
|
889
|
-
return Array.isArray(
|
|
887
|
+
function getComponentNameFromId(id) {
|
|
888
|
+
if (id == null) return eff._;
|
|
889
|
+
return Array.isArray(id) ? id.map((n) => n.name).join(".") : id.name;
|
|
890
890
|
}
|
|
891
|
-
function hasNoneOrLooseComponentName(context,
|
|
892
|
-
const id =
|
|
891
|
+
function hasNoneOrLooseComponentName(context, fn) {
|
|
892
|
+
const id = getFunctionComponentId(context, fn);
|
|
893
893
|
if (id == null) return true;
|
|
894
894
|
const name = Array.isArray(id) ? id.at(-1)?.name : id.name;
|
|
895
895
|
return name != null && isComponentNameLoose(name);
|
|
@@ -1046,8 +1046,8 @@ function useComponentCollector(context, options = {}) {
|
|
|
1046
1046
|
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3__namespace.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
|
|
1047
1047
|
if (!isComponent) return;
|
|
1048
1048
|
const initPath = AST6__namespace.getFunctionInitPath(entry.node);
|
|
1049
|
-
const id =
|
|
1050
|
-
const name =
|
|
1049
|
+
const id = getFunctionComponentId(context, entry.node);
|
|
1050
|
+
const name = getComponentNameFromId(id);
|
|
1051
1051
|
const key = shared.getId();
|
|
1052
1052
|
components.set(key, {
|
|
1053
1053
|
id,
|
|
@@ -1087,8 +1087,8 @@ function useComponentCollector(context, options = {}) {
|
|
|
1087
1087
|
if (!isComponent) return;
|
|
1088
1088
|
entry.isComponent = true;
|
|
1089
1089
|
const initPath = AST6__namespace.getFunctionInitPath(entry.node);
|
|
1090
|
-
const id =
|
|
1091
|
-
const name =
|
|
1090
|
+
const id = getFunctionComponentId(context, entry.node);
|
|
1091
|
+
const name = getComponentNameFromId(id);
|
|
1092
1092
|
components.set(entry.key, {
|
|
1093
1093
|
id,
|
|
1094
1094
|
key: entry.key,
|
|
@@ -1221,8 +1221,8 @@ 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;
|
|
1224
|
-
exports.
|
|
1225
|
-
exports.
|
|
1224
|
+
exports.getComponentNameFromId = getComponentNameFromId;
|
|
1225
|
+
exports.getFunctionComponentId = getFunctionComponentId;
|
|
1226
1226
|
exports.getInstanceId = getInstanceId;
|
|
1227
1227
|
exports.hasNoneOrLooseComponentName = hasNoneOrLooseComponentName;
|
|
1228
1228
|
exports.hasValidHierarchy = hasValidHierarchy;
|
package/dist/index.mjs
CHANGED
|
@@ -835,7 +835,7 @@ function isComponentWrapperCall(context, node) {
|
|
|
835
835
|
}
|
|
836
836
|
return isMemoCall(context, node) || isForwardRefCall(context, node) || isReactHookCallWithNameLoose(node)("useCallback");
|
|
837
837
|
}
|
|
838
|
-
function
|
|
838
|
+
function getFunctionComponentId(context, node) {
|
|
839
839
|
const functionId = AST6.getFunctionIdentifier(node);
|
|
840
840
|
if (functionId != null) {
|
|
841
841
|
return functionId;
|
|
@@ -857,12 +857,12 @@ function isComponentName(name) {
|
|
|
857
857
|
function isComponentNameLoose(name) {
|
|
858
858
|
return RE_COMPONENT_NAME_LOOSE.test(name);
|
|
859
859
|
}
|
|
860
|
-
function
|
|
861
|
-
if (
|
|
862
|
-
return Array.isArray(
|
|
860
|
+
function getComponentNameFromId(id) {
|
|
861
|
+
if (id == null) return _;
|
|
862
|
+
return Array.isArray(id) ? id.map((n) => n.name).join(".") : id.name;
|
|
863
863
|
}
|
|
864
|
-
function hasNoneOrLooseComponentName(context,
|
|
865
|
-
const id =
|
|
864
|
+
function hasNoneOrLooseComponentName(context, fn) {
|
|
865
|
+
const id = getFunctionComponentId(context, fn);
|
|
866
866
|
if (id == null) return true;
|
|
867
867
|
const name = Array.isArray(id) ? id.at(-1)?.name : id.name;
|
|
868
868
|
return name != null && isComponentNameLoose(name);
|
|
@@ -1019,8 +1019,8 @@ function useComponentCollector(context, options = {}) {
|
|
|
1019
1019
|
const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
|
|
1020
1020
|
if (!isComponent) return;
|
|
1021
1021
|
const initPath = AST6.getFunctionInitPath(entry.node);
|
|
1022
|
-
const id =
|
|
1023
|
-
const name =
|
|
1022
|
+
const id = getFunctionComponentId(context, entry.node);
|
|
1023
|
+
const name = getComponentNameFromId(id);
|
|
1024
1024
|
const key = getId();
|
|
1025
1025
|
components.set(key, {
|
|
1026
1026
|
id,
|
|
@@ -1060,8 +1060,8 @@ function useComponentCollector(context, options = {}) {
|
|
|
1060
1060
|
if (!isComponent) return;
|
|
1061
1061
|
entry.isComponent = true;
|
|
1062
1062
|
const initPath = AST6.getFunctionInitPath(entry.node);
|
|
1063
|
-
const id =
|
|
1064
|
-
const name =
|
|
1063
|
+
const id = getFunctionComponentId(context, entry.node);
|
|
1064
|
+
const name = getComponentNameFromId(id);
|
|
1065
1065
|
components.set(entry.key, {
|
|
1066
1066
|
id,
|
|
1067
1067
|
key: entry.key,
|
|
@@ -1186,4 +1186,4 @@ function isFunctionOfUseEffectCleanup(node) {
|
|
|
1186
1186
|
return enclosingFunction === functionOfReturnStatement && isFunctionOfUseEffectSetup(enclosingFunction);
|
|
1187
1187
|
}
|
|
1188
1188
|
|
|
1189
|
-
export { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, ERComponentFlag, ERComponentHint, ERPhaseRelevance, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_HOOK_NAME,
|
|
1189
|
+
export { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, ERComponentFlag, ERComponentHint, ERPhaseRelevance, 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.38.
|
|
3
|
+
"version": "1.38.3-next.0",
|
|
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.6.2",
|
|
44
|
-
"@eslint-react/ast": "1.38.
|
|
45
|
-
"@eslint-react/eff": "1.38.
|
|
46
|
-
"@eslint-react/jsx": "1.38.
|
|
47
|
-
"@eslint-react/kit": "1.38.
|
|
48
|
-
"@eslint-react/shared": "1.38.
|
|
49
|
-
"@eslint-react/var": "1.38.
|
|
44
|
+
"@eslint-react/ast": "1.38.3-next.0",
|
|
45
|
+
"@eslint-react/eff": "1.38.3-next.0",
|
|
46
|
+
"@eslint-react/jsx": "1.38.3-next.0",
|
|
47
|
+
"@eslint-react/kit": "1.38.3-next.0",
|
|
48
|
+
"@eslint-react/shared": "1.38.3-next.0",
|
|
49
|
+
"@eslint-react/var": "1.38.3-next.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"tsup": "^8.4.0",
|