@eslint-react/core 1.28.1-beta.0 → 1.28.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 +37 -2063
- package/dist/index.d.ts +37 -2063
- package/dist/index.js +89 -91
- package/dist/index.mjs +85 -87
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as AST7 from '@eslint-react/ast';
|
|
2
2
|
import { flip, dual, constFalse, identity, _ } from '@eslint-react/eff';
|
|
3
3
|
import * as JSX3 from '@eslint-react/jsx';
|
|
4
4
|
import { DEFAULT_ESLINT_REACT_SETTINGS as DEFAULT_ESLINT_REACT_SETTINGS$1, unsafeDecodeSettings, getId } from '@eslint-react/shared';
|
|
@@ -481,6 +481,17 @@ var ESLintReactSettingsSchema = object({
|
|
|
481
481
|
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
482
482
|
...parse(ESLintReactSettingsSchema, {}),
|
|
483
483
|
importSource: "react"};
|
|
484
|
+
var DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
|
|
485
|
+
"AssignmentExpression",
|
|
486
|
+
"[type]",
|
|
487
|
+
"[operator='=']",
|
|
488
|
+
"[left.type='MemberExpression']",
|
|
489
|
+
"[left.property.name='displayName']"
|
|
490
|
+
].join("");
|
|
491
|
+
function isDisplayNameAssignment(node) {
|
|
492
|
+
if (node == null) return false;
|
|
493
|
+
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";
|
|
494
|
+
}
|
|
484
495
|
function getRequireExpressionArguments(node) {
|
|
485
496
|
return match(node).with({ type: AST_NODE_TYPES.CallExpression, arguments: P.select(), callee: { type: AST_NODE_TYPES.Identifier, name: "require" } }, identity).with({ type: AST_NODE_TYPES.MemberExpression, object: P.select() }, getRequireExpressionArguments).otherwise(() => _);
|
|
486
497
|
}
|
|
@@ -499,7 +510,7 @@ function isInitializedFromReact(name, importSource, initialScope) {
|
|
|
499
510
|
}
|
|
500
511
|
const args = getRequireExpressionArguments(init);
|
|
501
512
|
const arg0 = args?.[0];
|
|
502
|
-
if (arg0 == null || !
|
|
513
|
+
if (arg0 == null || !AST7.isKindOfLiteral(arg0, "string")) {
|
|
503
514
|
return false;
|
|
504
515
|
}
|
|
505
516
|
return arg0.value === importSource || arg0.value.startsWith(`${importSource}/`);
|
|
@@ -530,82 +541,69 @@ function isFromReactStrict(node, name, importSource, initialScope) {
|
|
|
530
541
|
}
|
|
531
542
|
}
|
|
532
543
|
function isFromReact(name) {
|
|
533
|
-
return (context, node) => {
|
|
544
|
+
return dual(2, (context, node) => {
|
|
545
|
+
if (node == null) return false;
|
|
534
546
|
const { importSource = defaultImportSource, skipImportCheck = true } = unsafeDecodeSettings(context.settings);
|
|
535
547
|
if (skipImportCheck) return isFromReactLoose(node, name);
|
|
536
548
|
return isFromReactStrict(node, name, importSource, context.sourceCode.getScope(node));
|
|
537
|
-
};
|
|
549
|
+
});
|
|
538
550
|
}
|
|
539
|
-
function
|
|
540
|
-
return (context, node) => {
|
|
551
|
+
function isFromReactObject(objectName, propertyName) {
|
|
552
|
+
return dual(2, (context, node) => {
|
|
553
|
+
if (node?.type !== AST_NODE_TYPES.MemberExpression) return false;
|
|
541
554
|
const { importSource = defaultImportSource, skipImportCheck = true } = unsafeDecodeSettings(context.settings);
|
|
542
555
|
const { object: object2, property } = node;
|
|
543
|
-
if (skipImportCheck) return isFromReactLoose(object2,
|
|
556
|
+
if (skipImportCheck) return isFromReactLoose(object2, objectName) && isFromReactLoose(property, propertyName);
|
|
544
557
|
return isFromReactStrict(
|
|
545
558
|
object2,
|
|
546
|
-
|
|
559
|
+
objectName,
|
|
547
560
|
importSource,
|
|
548
561
|
context.sourceCode.getScope(object2)
|
|
549
|
-
) &&
|
|
550
|
-
};
|
|
562
|
+
) && isFromReactLoose(property, propertyName);
|
|
563
|
+
});
|
|
551
564
|
}
|
|
552
|
-
|
|
553
|
-
// src/utils/is-call-from-react.ts
|
|
554
565
|
function isCallFromReact(name) {
|
|
555
566
|
return dual(2, (context, node) => {
|
|
556
567
|
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
557
|
-
if (!AST8.isOneOf([AST_NODE_TYPES.Identifier, AST_NODE_TYPES.MemberExpression])(node.callee)) return false;
|
|
558
568
|
return isFromReact(name)(context, node.callee);
|
|
559
569
|
});
|
|
560
570
|
}
|
|
561
|
-
function
|
|
571
|
+
function isCallFromReactObject(objectName, propertyName) {
|
|
562
572
|
return dual(2, (context, node) => {
|
|
563
573
|
if (node.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
564
|
-
|
|
565
|
-
return isFromReactMember(pragmaMemberName, name)(context, node.callee);
|
|
574
|
+
return isFromReactObject(objectName, propertyName)(context, node.callee);
|
|
566
575
|
});
|
|
567
576
|
}
|
|
568
|
-
var DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
|
|
569
|
-
"AssignmentExpression",
|
|
570
|
-
"[type]",
|
|
571
|
-
"[operator='=']",
|
|
572
|
-
"[left.type='MemberExpression']",
|
|
573
|
-
"[left.property.name='displayName']"
|
|
574
|
-
].join("");
|
|
575
|
-
function isDisplayNameAssignment(node) {
|
|
576
|
-
if (node == null) return false;
|
|
577
|
-
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";
|
|
578
|
-
}
|
|
579
577
|
|
|
580
578
|
// src/utils/is-react-api.ts
|
|
581
|
-
function
|
|
582
|
-
return
|
|
583
|
-
}
|
|
584
|
-
function
|
|
585
|
-
return
|
|
586
|
-
}
|
|
587
|
-
var isChildrenCount =
|
|
588
|
-
var isChildrenForEach =
|
|
589
|
-
var isChildrenMap =
|
|
590
|
-
var isChildrenOnly =
|
|
591
|
-
var isChildrenToArray =
|
|
592
|
-
var isCloneElement =
|
|
593
|
-
var isCreateContext =
|
|
594
|
-
var isCreateElement =
|
|
595
|
-
var isCreateRef =
|
|
596
|
-
var isForwardRef =
|
|
597
|
-
var isMemo =
|
|
598
|
-
var isChildrenCountCall =
|
|
599
|
-
var isChildrenForEachCall =
|
|
600
|
-
var isChildrenMapCall =
|
|
601
|
-
var isChildrenOnlyCall =
|
|
602
|
-
var isChildrenToArrayCall =
|
|
603
|
-
var isCloneElementCall =
|
|
604
|
-
var isCreateContextCall =
|
|
605
|
-
var isCreateElementCall =
|
|
606
|
-
var isCreateRefCall =
|
|
607
|
-
var isForwardRefCall =
|
|
608
|
-
var isMemoCall =
|
|
579
|
+
function isReactAPI(arg0, arg1) {
|
|
580
|
+
return arg1 == null ? isFromReact(arg0) : isFromReactObject(arg0, arg1);
|
|
581
|
+
}
|
|
582
|
+
function isReactAPICall(arg0, arg1) {
|
|
583
|
+
return arg1 == null ? isCallFromReact(arg0) : isCallFromReactObject(arg0, arg1);
|
|
584
|
+
}
|
|
585
|
+
var isChildrenCount = isReactAPI("Children", "count");
|
|
586
|
+
var isChildrenForEach = isReactAPI("Children", "forEach");
|
|
587
|
+
var isChildrenMap = isReactAPI("Children", "map");
|
|
588
|
+
var isChildrenOnly = isReactAPI("Children", "only");
|
|
589
|
+
var isChildrenToArray = isReactAPI("Children", "toArray");
|
|
590
|
+
var isCloneElement = isReactAPI("cloneElement");
|
|
591
|
+
var isCreateContext = isReactAPI("createContext");
|
|
592
|
+
var isCreateElement = isReactAPI("createElement");
|
|
593
|
+
var isCreateRef = isReactAPI("createRef");
|
|
594
|
+
var isForwardRef = isReactAPI("forwardRef");
|
|
595
|
+
var isMemo = isReactAPI("memo");
|
|
596
|
+
var isChildrenCountCall = isReactAPICall("Children", "count");
|
|
597
|
+
var isChildrenForEachCall = isReactAPICall("Children", "forEach");
|
|
598
|
+
var isChildrenMapCall = isReactAPICall("Children", "map");
|
|
599
|
+
var isChildrenOnlyCall = isReactAPICall("Children", "only");
|
|
600
|
+
var isChildrenToArrayCall = isReactAPICall("Children", "toArray");
|
|
601
|
+
var isCloneElementCall = isReactAPICall("cloneElement");
|
|
602
|
+
var isCreateContextCall = isReactAPICall("createContext");
|
|
603
|
+
var isCreateElementCall = isReactAPICall("createElement");
|
|
604
|
+
var isCreateRefCall = isReactAPICall("createRef");
|
|
605
|
+
var isForwardRefCall = isReactAPICall("forwardRef");
|
|
606
|
+
var isMemoCall = isReactAPICall("memo");
|
|
609
607
|
|
|
610
608
|
// src/hook/hook-name.ts
|
|
611
609
|
var RE_HOOK_NAME = /^use[A-Z\d]/u;
|
|
@@ -616,7 +614,7 @@ function isReactHookName(name) {
|
|
|
616
614
|
// src/hook/is.ts
|
|
617
615
|
function isReactHook(node) {
|
|
618
616
|
if (node == null) return _;
|
|
619
|
-
const id =
|
|
617
|
+
const id = AST7.getFunctionIdentifier(node);
|
|
620
618
|
return id?.name != null && isReactHookName(id.name);
|
|
621
619
|
}
|
|
622
620
|
function isReactHookCall(node) {
|
|
@@ -712,13 +710,13 @@ var isUseTransitionCall = flip(isReactHookCallWithName)("useTransition");
|
|
|
712
710
|
|
|
713
711
|
// src/hook/hierarchy.ts
|
|
714
712
|
function isInsideReactHook(node) {
|
|
715
|
-
return isReactHook(
|
|
713
|
+
return isReactHook(AST7.findParentNode(node, AST7.isFunction));
|
|
716
714
|
}
|
|
717
715
|
function useHookCollector() {
|
|
718
716
|
const hooks = /* @__PURE__ */ new Map();
|
|
719
717
|
const functionEntries = [];
|
|
720
718
|
const onFunctionEnter = (node) => {
|
|
721
|
-
const id =
|
|
719
|
+
const id = AST7.getFunctionIdentifier(node);
|
|
722
720
|
const key = getId();
|
|
723
721
|
const name = id?.name;
|
|
724
722
|
if (name != null && isReactHookName(name)) {
|
|
@@ -814,7 +812,7 @@ function isComponentWrapperCall(context, node) {
|
|
|
814
812
|
return isMemoCall(context, node) || isForwardRefCall(context, node) || isReactHookCallWithNameLoose(node)("useCallback");
|
|
815
813
|
}
|
|
816
814
|
function getFunctionComponentIdentifier(context, node) {
|
|
817
|
-
const functionId =
|
|
815
|
+
const functionId = AST7.getFunctionIdentifier(node);
|
|
818
816
|
if (functionId != null) {
|
|
819
817
|
return functionId;
|
|
820
818
|
}
|
|
@@ -842,9 +840,9 @@ function hasNoneOrValidComponentName(context, node) {
|
|
|
842
840
|
return name != null && isComponentName(name);
|
|
843
841
|
}
|
|
844
842
|
function isInsideCreateElementProps(context, node) {
|
|
845
|
-
const call =
|
|
843
|
+
const call = AST7.findParentNode(node, isCreateElementCall(context));
|
|
846
844
|
if (call == null) return false;
|
|
847
|
-
const prop =
|
|
845
|
+
const prop = AST7.findParentNode(node, AST7.is(AST_NODE_TYPES.ObjectExpression));
|
|
848
846
|
if (prop == null) return false;
|
|
849
847
|
return prop === call.arguments[1];
|
|
850
848
|
}
|
|
@@ -881,28 +879,28 @@ function isPureComponent(node) {
|
|
|
881
879
|
|
|
882
880
|
// src/component/component-lifecycle.ts
|
|
883
881
|
function isComponentDidMount(node) {
|
|
884
|
-
return
|
|
882
|
+
return AST7.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
885
883
|
}
|
|
886
884
|
function isComponentWillUnmount(node) {
|
|
887
|
-
return
|
|
885
|
+
return AST7.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
|
|
888
886
|
}
|
|
889
887
|
function isComponentDidCatch(node) {
|
|
890
|
-
return
|
|
888
|
+
return AST7.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
|
|
891
889
|
}
|
|
892
890
|
function isGetDerivedStateFromError(node) {
|
|
893
|
-
return
|
|
891
|
+
return AST7.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
|
|
894
892
|
}
|
|
895
893
|
function isGetDerivedStateFromProps(node) {
|
|
896
|
-
return
|
|
894
|
+
return AST7.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
|
|
897
895
|
}
|
|
898
896
|
function isFunctionOfComponentDidMount(node) {
|
|
899
|
-
return
|
|
897
|
+
return AST7.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
|
|
900
898
|
}
|
|
901
899
|
function isFunctionOfComponentWillUnmount(node) {
|
|
902
|
-
return
|
|
900
|
+
return AST7.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
|
|
903
901
|
}
|
|
904
902
|
function isRenderMethodLike(node) {
|
|
905
|
-
return
|
|
903
|
+
return AST7.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
|
|
906
904
|
}
|
|
907
905
|
function isFunctionOfRenderMethod(node) {
|
|
908
906
|
if (!isRenderMethodLike(node.parent)) {
|
|
@@ -911,7 +909,7 @@ function isFunctionOfRenderMethod(node) {
|
|
|
911
909
|
return isClassComponent(node.parent.parent.parent);
|
|
912
910
|
}
|
|
913
911
|
function isInsideRenderMethod(node) {
|
|
914
|
-
return
|
|
912
|
+
return AST7.findParentNode(node, (node2) => isRenderMethodLike(node2) && isClassComponent(node2.parent.parent)) != null;
|
|
915
913
|
}
|
|
916
914
|
|
|
917
915
|
// src/component/hierarchy.ts
|
|
@@ -919,7 +917,7 @@ function hasValidHierarchy(context, node, hint) {
|
|
|
919
917
|
if (isChildrenOfCreateElement(context, node) || isFunctionOfRenderMethod(node)) {
|
|
920
918
|
return false;
|
|
921
919
|
}
|
|
922
|
-
if (hint & ERComponentHint.SkipMapCallback &&
|
|
920
|
+
if (hint & ERComponentHint.SkipMapCallback && AST7.isMapCallLoose(node.parent)) {
|
|
923
921
|
return false;
|
|
924
922
|
}
|
|
925
923
|
if (hint & ERComponentHint.SkipObjectMethod && isFunctionOfObjectMethod(node.parent)) {
|
|
@@ -931,9 +929,9 @@ function hasValidHierarchy(context, node, hint) {
|
|
|
931
929
|
if (hint & ERComponentHint.SkipClassProperty && isFunctionOfClassProperty(node.parent)) {
|
|
932
930
|
return false;
|
|
933
931
|
}
|
|
934
|
-
const boundaryNode =
|
|
932
|
+
const boundaryNode = AST7.findParentNode(
|
|
935
933
|
node,
|
|
936
|
-
|
|
934
|
+
AST7.isOneOf([
|
|
937
935
|
AST_NODE_TYPES.JSXExpressionContainer,
|
|
938
936
|
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
939
937
|
AST_NODE_TYPES.FunctionExpression,
|
|
@@ -968,7 +966,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
968
966
|
const entry = functionEntries.at(-1);
|
|
969
967
|
if (entry == null) return;
|
|
970
968
|
if (!entry.isComponent) return functionEntries.pop();
|
|
971
|
-
const shouldDrop =
|
|
969
|
+
const shouldDrop = AST7.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
|
|
972
970
|
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3.isJSXValue(r.argument, jsxCtx, hint);
|
|
973
971
|
});
|
|
974
972
|
if (shouldDrop) {
|
|
@@ -995,7 +993,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
995
993
|
const { body } = entry.node;
|
|
996
994
|
const isComponent = hasNoneOrValidComponentName(context, entry.node) && JSX3.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
|
|
997
995
|
if (!isComponent) return;
|
|
998
|
-
const initPath =
|
|
996
|
+
const initPath = AST7.getFunctionInitPath(entry.node);
|
|
999
997
|
const id = getFunctionComponentIdentifier(context, entry.node);
|
|
1000
998
|
const name = getComponentNameFromIdentifier(id);
|
|
1001
999
|
const key = getId();
|
|
@@ -1036,7 +1034,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
1036
1034
|
const isComponent = hasNoneOrValidComponentName(context, entry.node) && JSX3.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
|
|
1037
1035
|
if (!isComponent) return;
|
|
1038
1036
|
entry.isComponent = true;
|
|
1039
|
-
const initPath =
|
|
1037
|
+
const initPath = AST7.getFunctionInitPath(entry.node);
|
|
1040
1038
|
const id = getFunctionComponentIdentifier(context, entry.node);
|
|
1041
1039
|
const name = getComponentNameFromIdentifier(id);
|
|
1042
1040
|
components.set(entry.key, {
|
|
@@ -1057,10 +1055,10 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
1057
1055
|
}
|
|
1058
1056
|
function getComponentFlag(initPath) {
|
|
1059
1057
|
let flag = ERComponentFlag.None;
|
|
1060
|
-
if (initPath != null &&
|
|
1058
|
+
if (initPath != null && AST7.hasCallInFunctionInitPath("memo", initPath)) {
|
|
1061
1059
|
flag |= ERComponentFlag.Memo;
|
|
1062
1060
|
}
|
|
1063
|
-
if (initPath != null &&
|
|
1061
|
+
if (initPath != null && AST7.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
1064
1062
|
flag |= ERComponentFlag.ForwardRef;
|
|
1065
1063
|
}
|
|
1066
1064
|
return flag;
|
|
@@ -1077,7 +1075,7 @@ function useComponentCollectorLegacy() {
|
|
|
1077
1075
|
if (!isClassComponent(node)) {
|
|
1078
1076
|
return;
|
|
1079
1077
|
}
|
|
1080
|
-
const id =
|
|
1078
|
+
const id = AST7.getClassIdentifier(node);
|
|
1081
1079
|
const key = getId();
|
|
1082
1080
|
const flag = isPureComponent(node) ? ERComponentFlag.PureComponent : ERComponentFlag.None;
|
|
1083
1081
|
components.set(
|
|
@@ -1110,7 +1108,7 @@ var ERPhaseRelevance = birecord({
|
|
|
1110
1108
|
var isInversePhase = dual(2, (a, b) => ERPhaseRelevance.get(a) === b);
|
|
1111
1109
|
function isRenderFunctionLoose(context, node) {
|
|
1112
1110
|
const { body, parent } = node;
|
|
1113
|
-
if (
|
|
1111
|
+
if (AST7.getFunctionIdentifier(node)?.name.startsWith("render")) {
|
|
1114
1112
|
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");
|
|
1115
1113
|
}
|
|
1116
1114
|
return JSX3.isJSXValue(
|
|
@@ -1125,7 +1123,7 @@ function isRenderPropLoose(context, node) {
|
|
|
1125
1123
|
if (node.name.type !== AST_NODE_TYPES.JSXIdentifier) {
|
|
1126
1124
|
return false;
|
|
1127
1125
|
}
|
|
1128
|
-
return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer &&
|
|
1126
|
+
return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && AST7.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression);
|
|
1129
1127
|
}
|
|
1130
1128
|
function isDirectValueOfRenderPropertyLoose(node) {
|
|
1131
1129
|
const matching = (node2) => {
|
|
@@ -1137,7 +1135,7 @@ function isDeclaredInRenderPropLoose(node) {
|
|
|
1137
1135
|
if (isDirectValueOfRenderPropertyLoose(node)) {
|
|
1138
1136
|
return true;
|
|
1139
1137
|
}
|
|
1140
|
-
const parent =
|
|
1138
|
+
const parent = AST7.findParentNode(node, AST7.is(AST_NODE_TYPES.JSXExpressionContainer))?.parent;
|
|
1141
1139
|
if (parent?.type !== AST_NODE_TYPES.JSXAttribute) {
|
|
1142
1140
|
return false;
|
|
1143
1141
|
}
|
|
@@ -1145,17 +1143,17 @@ function isDeclaredInRenderPropLoose(node) {
|
|
|
1145
1143
|
}
|
|
1146
1144
|
function isThisSetState(node) {
|
|
1147
1145
|
const { callee } = node;
|
|
1148
|
-
return callee.type === AST_NODE_TYPES.MemberExpression &&
|
|
1146
|
+
return callee.type === AST_NODE_TYPES.MemberExpression && AST7.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
|
|
1149
1147
|
}
|
|
1150
1148
|
function isFunctionOfUseEffectSetup(node) {
|
|
1151
1149
|
if (node == null) return _;
|
|
1152
1150
|
return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.callee !== node && node.parent.callee.type === AST_NODE_TYPES.Identifier && node.parent.arguments.at(0) === node && isUseEffectCallLoose(node.parent);
|
|
1153
1151
|
}
|
|
1154
1152
|
function isFunctionOfUseEffectCleanup(node) {
|
|
1155
|
-
const nearReturn =
|
|
1156
|
-
const nearFunction =
|
|
1157
|
-
const nearFunctionOfReturn =
|
|
1153
|
+
const nearReturn = AST7.findParentNode(node, AST7.is(AST_NODE_TYPES.ReturnStatement));
|
|
1154
|
+
const nearFunction = AST7.findParentNode(node, AST7.isFunction);
|
|
1155
|
+
const nearFunctionOfReturn = AST7.findParentNode(nearReturn, AST7.isFunction);
|
|
1158
1156
|
return nearFunction === nearFunctionOfReturn && isFunctionOfUseEffectSetup(nearFunction);
|
|
1159
1157
|
}
|
|
1160
1158
|
|
|
1161
|
-
export { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, ERComponentFlag, ERComponentHint, ERPhaseRelevance, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, hasValidHierarchy, isCallFromReact,
|
|
1159
|
+
export { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, ERComponentFlag, ERComponentHint, ERPhaseRelevance, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, hasValidHierarchy, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isDisplayNameAssignment, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, 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.28.1-beta.
|
|
3
|
+
"version": "1.28.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": {
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"@typescript-eslint/utils": "^8.25.0",
|
|
42
42
|
"birecord": "^0.1.1",
|
|
43
43
|
"ts-pattern": "^5.6.2",
|
|
44
|
-
"@eslint-react/ast": "1.28.1-beta.
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/shared": "1.28.1-beta.
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/var": "1.28.1-beta.
|
|
44
|
+
"@eslint-react/ast": "1.28.1-beta.1",
|
|
45
|
+
"@eslint-react/eff": "1.28.1-beta.1",
|
|
46
|
+
"@eslint-react/shared": "1.28.1-beta.1",
|
|
47
|
+
"@eslint-react/jsx": "1.28.1-beta.1",
|
|
48
|
+
"@eslint-react/var": "1.28.1-beta.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"tsup": "^8.4.0",
|