@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.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var AST7 = require('@eslint-react/ast');
|
|
4
4
|
var eff = require('@eslint-react/eff');
|
|
5
5
|
var JSX3 = require('@eslint-react/jsx');
|
|
6
6
|
var shared = require('@eslint-react/shared');
|
|
@@ -29,7 +29,7 @@ function _interopNamespace(e) {
|
|
|
29
29
|
return Object.freeze(n);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var AST7__namespace = /*#__PURE__*/_interopNamespace(AST7);
|
|
33
33
|
var JSX3__namespace = /*#__PURE__*/_interopNamespace(JSX3);
|
|
34
34
|
var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
|
|
35
35
|
var birecord__default = /*#__PURE__*/_interopDefault(birecord);
|
|
@@ -508,6 +508,17 @@ var ESLintReactSettingsSchema = object({
|
|
|
508
508
|
var DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
509
509
|
...parse(ESLintReactSettingsSchema, {}),
|
|
510
510
|
importSource: "react"};
|
|
511
|
+
var DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
|
|
512
|
+
"AssignmentExpression",
|
|
513
|
+
"[type]",
|
|
514
|
+
"[operator='=']",
|
|
515
|
+
"[left.type='MemberExpression']",
|
|
516
|
+
"[left.property.name='displayName']"
|
|
517
|
+
].join("");
|
|
518
|
+
function isDisplayNameAssignment(node) {
|
|
519
|
+
if (node == null) return false;
|
|
520
|
+
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";
|
|
521
|
+
}
|
|
511
522
|
function getRequireExpressionArguments(node) {
|
|
512
523
|
return tsPattern.match(node).with({ type: types.AST_NODE_TYPES.CallExpression, arguments: tsPattern.P.select(), callee: { type: types.AST_NODE_TYPES.Identifier, name: "require" } }, eff.identity).with({ type: types.AST_NODE_TYPES.MemberExpression, object: tsPattern.P.select() }, getRequireExpressionArguments).otherwise(() => eff._);
|
|
513
524
|
}
|
|
@@ -526,7 +537,7 @@ function isInitializedFromReact(name, importSource, initialScope) {
|
|
|
526
537
|
}
|
|
527
538
|
const args = getRequireExpressionArguments(init);
|
|
528
539
|
const arg0 = args?.[0];
|
|
529
|
-
if (arg0 == null || !
|
|
540
|
+
if (arg0 == null || !AST7__namespace.isKindOfLiteral(arg0, "string")) {
|
|
530
541
|
return false;
|
|
531
542
|
}
|
|
532
543
|
return arg0.value === importSource || arg0.value.startsWith(`${importSource}/`);
|
|
@@ -557,82 +568,69 @@ function isFromReactStrict(node, name, importSource, initialScope) {
|
|
|
557
568
|
}
|
|
558
569
|
}
|
|
559
570
|
function isFromReact(name) {
|
|
560
|
-
return (context, node) => {
|
|
571
|
+
return eff.dual(2, (context, node) => {
|
|
572
|
+
if (node == null) return false;
|
|
561
573
|
const { importSource = defaultImportSource, skipImportCheck = true } = shared.unsafeDecodeSettings(context.settings);
|
|
562
574
|
if (skipImportCheck) return isFromReactLoose(node, name);
|
|
563
575
|
return isFromReactStrict(node, name, importSource, context.sourceCode.getScope(node));
|
|
564
|
-
};
|
|
576
|
+
});
|
|
565
577
|
}
|
|
566
|
-
function
|
|
567
|
-
return (context, node) => {
|
|
578
|
+
function isFromReactObject(objectName, propertyName) {
|
|
579
|
+
return eff.dual(2, (context, node) => {
|
|
580
|
+
if (node?.type !== types.AST_NODE_TYPES.MemberExpression) return false;
|
|
568
581
|
const { importSource = defaultImportSource, skipImportCheck = true } = shared.unsafeDecodeSettings(context.settings);
|
|
569
582
|
const { object: object2, property } = node;
|
|
570
|
-
if (skipImportCheck) return isFromReactLoose(object2,
|
|
583
|
+
if (skipImportCheck) return isFromReactLoose(object2, objectName) && isFromReactLoose(property, propertyName);
|
|
571
584
|
return isFromReactStrict(
|
|
572
585
|
object2,
|
|
573
|
-
|
|
586
|
+
objectName,
|
|
574
587
|
importSource,
|
|
575
588
|
context.sourceCode.getScope(object2)
|
|
576
|
-
) &&
|
|
577
|
-
};
|
|
589
|
+
) && isFromReactLoose(property, propertyName);
|
|
590
|
+
});
|
|
578
591
|
}
|
|
579
|
-
|
|
580
|
-
// src/utils/is-call-from-react.ts
|
|
581
592
|
function isCallFromReact(name) {
|
|
582
593
|
return eff.dual(2, (context, node) => {
|
|
583
594
|
if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
|
|
584
|
-
if (!AST8__namespace.isOneOf([types.AST_NODE_TYPES.Identifier, types.AST_NODE_TYPES.MemberExpression])(node.callee)) return false;
|
|
585
595
|
return isFromReact(name)(context, node.callee);
|
|
586
596
|
});
|
|
587
597
|
}
|
|
588
|
-
function
|
|
598
|
+
function isCallFromReactObject(objectName, propertyName) {
|
|
589
599
|
return eff.dual(2, (context, node) => {
|
|
590
600
|
if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
|
|
591
|
-
|
|
592
|
-
return isFromReactMember(pragmaMemberName, name)(context, node.callee);
|
|
601
|
+
return isFromReactObject(objectName, propertyName)(context, node.callee);
|
|
593
602
|
});
|
|
594
603
|
}
|
|
595
|
-
var DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
|
|
596
|
-
"AssignmentExpression",
|
|
597
|
-
"[type]",
|
|
598
|
-
"[operator='=']",
|
|
599
|
-
"[left.type='MemberExpression']",
|
|
600
|
-
"[left.property.name='displayName']"
|
|
601
|
-
].join("");
|
|
602
|
-
function isDisplayNameAssignment(node) {
|
|
603
|
-
if (node == null) return false;
|
|
604
|
-
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";
|
|
605
|
-
}
|
|
606
604
|
|
|
607
605
|
// src/utils/is-react-api.ts
|
|
608
|
-
function
|
|
609
|
-
return
|
|
610
|
-
}
|
|
611
|
-
function
|
|
612
|
-
return
|
|
613
|
-
}
|
|
614
|
-
var isChildrenCount =
|
|
615
|
-
var isChildrenForEach =
|
|
616
|
-
var isChildrenMap =
|
|
617
|
-
var isChildrenOnly =
|
|
618
|
-
var isChildrenToArray =
|
|
619
|
-
var isCloneElement =
|
|
620
|
-
var isCreateContext =
|
|
621
|
-
var isCreateElement =
|
|
622
|
-
var isCreateRef =
|
|
623
|
-
var isForwardRef =
|
|
624
|
-
var isMemo =
|
|
625
|
-
var isChildrenCountCall =
|
|
626
|
-
var isChildrenForEachCall =
|
|
627
|
-
var isChildrenMapCall =
|
|
628
|
-
var isChildrenOnlyCall =
|
|
629
|
-
var isChildrenToArrayCall =
|
|
630
|
-
var isCloneElementCall =
|
|
631
|
-
var isCreateContextCall =
|
|
632
|
-
var isCreateElementCall =
|
|
633
|
-
var isCreateRefCall =
|
|
634
|
-
var isForwardRefCall =
|
|
635
|
-
var isMemoCall =
|
|
606
|
+
function isReactAPI(arg0, arg1) {
|
|
607
|
+
return arg1 == null ? isFromReact(arg0) : isFromReactObject(arg0, arg1);
|
|
608
|
+
}
|
|
609
|
+
function isReactAPICall(arg0, arg1) {
|
|
610
|
+
return arg1 == null ? isCallFromReact(arg0) : isCallFromReactObject(arg0, arg1);
|
|
611
|
+
}
|
|
612
|
+
var isChildrenCount = isReactAPI("Children", "count");
|
|
613
|
+
var isChildrenForEach = isReactAPI("Children", "forEach");
|
|
614
|
+
var isChildrenMap = isReactAPI("Children", "map");
|
|
615
|
+
var isChildrenOnly = isReactAPI("Children", "only");
|
|
616
|
+
var isChildrenToArray = isReactAPI("Children", "toArray");
|
|
617
|
+
var isCloneElement = isReactAPI("cloneElement");
|
|
618
|
+
var isCreateContext = isReactAPI("createContext");
|
|
619
|
+
var isCreateElement = isReactAPI("createElement");
|
|
620
|
+
var isCreateRef = isReactAPI("createRef");
|
|
621
|
+
var isForwardRef = isReactAPI("forwardRef");
|
|
622
|
+
var isMemo = isReactAPI("memo");
|
|
623
|
+
var isChildrenCountCall = isReactAPICall("Children", "count");
|
|
624
|
+
var isChildrenForEachCall = isReactAPICall("Children", "forEach");
|
|
625
|
+
var isChildrenMapCall = isReactAPICall("Children", "map");
|
|
626
|
+
var isChildrenOnlyCall = isReactAPICall("Children", "only");
|
|
627
|
+
var isChildrenToArrayCall = isReactAPICall("Children", "toArray");
|
|
628
|
+
var isCloneElementCall = isReactAPICall("cloneElement");
|
|
629
|
+
var isCreateContextCall = isReactAPICall("createContext");
|
|
630
|
+
var isCreateElementCall = isReactAPICall("createElement");
|
|
631
|
+
var isCreateRefCall = isReactAPICall("createRef");
|
|
632
|
+
var isForwardRefCall = isReactAPICall("forwardRef");
|
|
633
|
+
var isMemoCall = isReactAPICall("memo");
|
|
636
634
|
|
|
637
635
|
// src/hook/hook-name.ts
|
|
638
636
|
var RE_HOOK_NAME = /^use[A-Z\d]/u;
|
|
@@ -643,7 +641,7 @@ function isReactHookName(name) {
|
|
|
643
641
|
// src/hook/is.ts
|
|
644
642
|
function isReactHook(node) {
|
|
645
643
|
if (node == null) return eff._;
|
|
646
|
-
const id =
|
|
644
|
+
const id = AST7__namespace.getFunctionIdentifier(node);
|
|
647
645
|
return id?.name != null && isReactHookName(id.name);
|
|
648
646
|
}
|
|
649
647
|
function isReactHookCall(node) {
|
|
@@ -739,13 +737,13 @@ var isUseTransitionCall = eff.flip(isReactHookCallWithName)("useTransition");
|
|
|
739
737
|
|
|
740
738
|
// src/hook/hierarchy.ts
|
|
741
739
|
function isInsideReactHook(node) {
|
|
742
|
-
return isReactHook(
|
|
740
|
+
return isReactHook(AST7__namespace.findParentNode(node, AST7__namespace.isFunction));
|
|
743
741
|
}
|
|
744
742
|
function useHookCollector() {
|
|
745
743
|
const hooks = /* @__PURE__ */ new Map();
|
|
746
744
|
const functionEntries = [];
|
|
747
745
|
const onFunctionEnter = (node) => {
|
|
748
|
-
const id =
|
|
746
|
+
const id = AST7__namespace.getFunctionIdentifier(node);
|
|
749
747
|
const key = shared.getId();
|
|
750
748
|
const name = id?.name;
|
|
751
749
|
if (name != null && isReactHookName(name)) {
|
|
@@ -841,7 +839,7 @@ function isComponentWrapperCall(context, node) {
|
|
|
841
839
|
return isMemoCall(context, node) || isForwardRefCall(context, node) || isReactHookCallWithNameLoose(node)("useCallback");
|
|
842
840
|
}
|
|
843
841
|
function getFunctionComponentIdentifier(context, node) {
|
|
844
|
-
const functionId =
|
|
842
|
+
const functionId = AST7__namespace.getFunctionIdentifier(node);
|
|
845
843
|
if (functionId != null) {
|
|
846
844
|
return functionId;
|
|
847
845
|
}
|
|
@@ -869,9 +867,9 @@ function hasNoneOrValidComponentName(context, node) {
|
|
|
869
867
|
return name != null && isComponentName(name);
|
|
870
868
|
}
|
|
871
869
|
function isInsideCreateElementProps(context, node) {
|
|
872
|
-
const call =
|
|
870
|
+
const call = AST7__namespace.findParentNode(node, isCreateElementCall(context));
|
|
873
871
|
if (call == null) return false;
|
|
874
|
-
const prop =
|
|
872
|
+
const prop = AST7__namespace.findParentNode(node, AST7__namespace.is(types.AST_NODE_TYPES.ObjectExpression));
|
|
875
873
|
if (prop == null) return false;
|
|
876
874
|
return prop === call.arguments[1];
|
|
877
875
|
}
|
|
@@ -908,28 +906,28 @@ function isPureComponent(node) {
|
|
|
908
906
|
|
|
909
907
|
// src/component/component-lifecycle.ts
|
|
910
908
|
function isComponentDidMount(node) {
|
|
911
|
-
return
|
|
909
|
+
return AST7__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
|
|
912
910
|
}
|
|
913
911
|
function isComponentWillUnmount(node) {
|
|
914
|
-
return
|
|
912
|
+
return AST7__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
|
|
915
913
|
}
|
|
916
914
|
function isComponentDidCatch(node) {
|
|
917
|
-
return
|
|
915
|
+
return AST7__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
|
|
918
916
|
}
|
|
919
917
|
function isGetDerivedStateFromError(node) {
|
|
920
|
-
return
|
|
918
|
+
return AST7__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
|
|
921
919
|
}
|
|
922
920
|
function isGetDerivedStateFromProps(node) {
|
|
923
|
-
return
|
|
921
|
+
return AST7__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
|
|
924
922
|
}
|
|
925
923
|
function isFunctionOfComponentDidMount(node) {
|
|
926
|
-
return
|
|
924
|
+
return AST7__namespace.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
|
|
927
925
|
}
|
|
928
926
|
function isFunctionOfComponentWillUnmount(node) {
|
|
929
|
-
return
|
|
927
|
+
return AST7__namespace.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
|
|
930
928
|
}
|
|
931
929
|
function isRenderMethodLike(node) {
|
|
932
|
-
return
|
|
930
|
+
return AST7__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration;
|
|
933
931
|
}
|
|
934
932
|
function isFunctionOfRenderMethod(node) {
|
|
935
933
|
if (!isRenderMethodLike(node.parent)) {
|
|
@@ -938,7 +936,7 @@ function isFunctionOfRenderMethod(node) {
|
|
|
938
936
|
return isClassComponent(node.parent.parent.parent);
|
|
939
937
|
}
|
|
940
938
|
function isInsideRenderMethod(node) {
|
|
941
|
-
return
|
|
939
|
+
return AST7__namespace.findParentNode(node, (node2) => isRenderMethodLike(node2) && isClassComponent(node2.parent.parent)) != null;
|
|
942
940
|
}
|
|
943
941
|
|
|
944
942
|
// src/component/hierarchy.ts
|
|
@@ -946,7 +944,7 @@ function hasValidHierarchy(context, node, hint) {
|
|
|
946
944
|
if (isChildrenOfCreateElement(context, node) || isFunctionOfRenderMethod(node)) {
|
|
947
945
|
return false;
|
|
948
946
|
}
|
|
949
|
-
if (hint & ERComponentHint.SkipMapCallback &&
|
|
947
|
+
if (hint & ERComponentHint.SkipMapCallback && AST7__namespace.isMapCallLoose(node.parent)) {
|
|
950
948
|
return false;
|
|
951
949
|
}
|
|
952
950
|
if (hint & ERComponentHint.SkipObjectMethod && isFunctionOfObjectMethod(node.parent)) {
|
|
@@ -958,9 +956,9 @@ function hasValidHierarchy(context, node, hint) {
|
|
|
958
956
|
if (hint & ERComponentHint.SkipClassProperty && isFunctionOfClassProperty(node.parent)) {
|
|
959
957
|
return false;
|
|
960
958
|
}
|
|
961
|
-
const boundaryNode =
|
|
959
|
+
const boundaryNode = AST7__namespace.findParentNode(
|
|
962
960
|
node,
|
|
963
|
-
|
|
961
|
+
AST7__namespace.isOneOf([
|
|
964
962
|
types.AST_NODE_TYPES.JSXExpressionContainer,
|
|
965
963
|
types.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
966
964
|
types.AST_NODE_TYPES.FunctionExpression,
|
|
@@ -995,7 +993,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
995
993
|
const entry = functionEntries.at(-1);
|
|
996
994
|
if (entry == null) return;
|
|
997
995
|
if (!entry.isComponent) return functionEntries.pop();
|
|
998
|
-
const shouldDrop =
|
|
996
|
+
const shouldDrop = AST7__namespace.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
|
|
999
997
|
return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3__namespace.isJSXValue(r.argument, jsxCtx, hint);
|
|
1000
998
|
});
|
|
1001
999
|
if (shouldDrop) {
|
|
@@ -1022,7 +1020,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
1022
1020
|
const { body } = entry.node;
|
|
1023
1021
|
const isComponent = hasNoneOrValidComponentName(context, entry.node) && JSX3__namespace.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
|
|
1024
1022
|
if (!isComponent) return;
|
|
1025
|
-
const initPath =
|
|
1023
|
+
const initPath = AST7__namespace.getFunctionInitPath(entry.node);
|
|
1026
1024
|
const id = getFunctionComponentIdentifier(context, entry.node);
|
|
1027
1025
|
const name = getComponentNameFromIdentifier(id);
|
|
1028
1026
|
const key = shared.getId();
|
|
@@ -1063,7 +1061,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
1063
1061
|
const isComponent = hasNoneOrValidComponentName(context, entry.node) && JSX3__namespace.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
|
|
1064
1062
|
if (!isComponent) return;
|
|
1065
1063
|
entry.isComponent = true;
|
|
1066
|
-
const initPath =
|
|
1064
|
+
const initPath = AST7__namespace.getFunctionInitPath(entry.node);
|
|
1067
1065
|
const id = getFunctionComponentIdentifier(context, entry.node);
|
|
1068
1066
|
const name = getComponentNameFromIdentifier(id);
|
|
1069
1067
|
components.set(entry.key, {
|
|
@@ -1084,10 +1082,10 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
|
|
|
1084
1082
|
}
|
|
1085
1083
|
function getComponentFlag(initPath) {
|
|
1086
1084
|
let flag = ERComponentFlag.None;
|
|
1087
|
-
if (initPath != null &&
|
|
1085
|
+
if (initPath != null && AST7__namespace.hasCallInFunctionInitPath("memo", initPath)) {
|
|
1088
1086
|
flag |= ERComponentFlag.Memo;
|
|
1089
1087
|
}
|
|
1090
|
-
if (initPath != null &&
|
|
1088
|
+
if (initPath != null && AST7__namespace.hasCallInFunctionInitPath("forwardRef", initPath)) {
|
|
1091
1089
|
flag |= ERComponentFlag.ForwardRef;
|
|
1092
1090
|
}
|
|
1093
1091
|
return flag;
|
|
@@ -1104,7 +1102,7 @@ function useComponentCollectorLegacy() {
|
|
|
1104
1102
|
if (!isClassComponent(node)) {
|
|
1105
1103
|
return;
|
|
1106
1104
|
}
|
|
1107
|
-
const id =
|
|
1105
|
+
const id = AST7__namespace.getClassIdentifier(node);
|
|
1108
1106
|
const key = shared.getId();
|
|
1109
1107
|
const flag = isPureComponent(node) ? ERComponentFlag.PureComponent : ERComponentFlag.None;
|
|
1110
1108
|
components.set(
|
|
@@ -1137,7 +1135,7 @@ var ERPhaseRelevance = birecord__default.default({
|
|
|
1137
1135
|
var isInversePhase = eff.dual(2, (a, b) => ERPhaseRelevance.get(a) === b);
|
|
1138
1136
|
function isRenderFunctionLoose(context, node) {
|
|
1139
1137
|
const { body, parent } = node;
|
|
1140
|
-
if (
|
|
1138
|
+
if (AST7__namespace.getFunctionIdentifier(node)?.name.startsWith("render")) {
|
|
1141
1139
|
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");
|
|
1142
1140
|
}
|
|
1143
1141
|
return JSX3__namespace.isJSXValue(
|
|
@@ -1152,7 +1150,7 @@ function isRenderPropLoose(context, node) {
|
|
|
1152
1150
|
if (node.name.type !== types.AST_NODE_TYPES.JSXIdentifier) {
|
|
1153
1151
|
return false;
|
|
1154
1152
|
}
|
|
1155
|
-
return node.name.name.startsWith("render") && node.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer &&
|
|
1153
|
+
return node.name.name.startsWith("render") && node.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && AST7__namespace.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression);
|
|
1156
1154
|
}
|
|
1157
1155
|
function isDirectValueOfRenderPropertyLoose(node) {
|
|
1158
1156
|
const matching = (node2) => {
|
|
@@ -1164,7 +1162,7 @@ function isDeclaredInRenderPropLoose(node) {
|
|
|
1164
1162
|
if (isDirectValueOfRenderPropertyLoose(node)) {
|
|
1165
1163
|
return true;
|
|
1166
1164
|
}
|
|
1167
|
-
const parent =
|
|
1165
|
+
const parent = AST7__namespace.findParentNode(node, AST7__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer))?.parent;
|
|
1168
1166
|
if (parent?.type !== types.AST_NODE_TYPES.JSXAttribute) {
|
|
1169
1167
|
return false;
|
|
1170
1168
|
}
|
|
@@ -1172,16 +1170,16 @@ function isDeclaredInRenderPropLoose(node) {
|
|
|
1172
1170
|
}
|
|
1173
1171
|
function isThisSetState(node) {
|
|
1174
1172
|
const { callee } = node;
|
|
1175
|
-
return callee.type === types.AST_NODE_TYPES.MemberExpression &&
|
|
1173
|
+
return callee.type === types.AST_NODE_TYPES.MemberExpression && AST7__namespace.isThisExpression(callee.object) && callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === "setState";
|
|
1176
1174
|
}
|
|
1177
1175
|
function isFunctionOfUseEffectSetup(node) {
|
|
1178
1176
|
if (node == null) return eff._;
|
|
1179
1177
|
return node.parent?.type === types.AST_NODE_TYPES.CallExpression && node.parent.callee !== node && node.parent.callee.type === types.AST_NODE_TYPES.Identifier && node.parent.arguments.at(0) === node && isUseEffectCallLoose(node.parent);
|
|
1180
1178
|
}
|
|
1181
1179
|
function isFunctionOfUseEffectCleanup(node) {
|
|
1182
|
-
const nearReturn =
|
|
1183
|
-
const nearFunction =
|
|
1184
|
-
const nearFunctionOfReturn =
|
|
1180
|
+
const nearReturn = AST7__namespace.findParentNode(node, AST7__namespace.is(types.AST_NODE_TYPES.ReturnStatement));
|
|
1181
|
+
const nearFunction = AST7__namespace.findParentNode(node, AST7__namespace.isFunction);
|
|
1182
|
+
const nearFunctionOfReturn = AST7__namespace.findParentNode(nearReturn, AST7__namespace.isFunction);
|
|
1185
1183
|
return nearFunction === nearFunctionOfReturn && isFunctionOfUseEffectSetup(nearFunction);
|
|
1186
1184
|
}
|
|
1187
1185
|
|
|
@@ -1197,7 +1195,7 @@ exports.getFunctionComponentIdentifier = getFunctionComponentIdentifier;
|
|
|
1197
1195
|
exports.hasNoneOrValidComponentName = hasNoneOrValidComponentName;
|
|
1198
1196
|
exports.hasValidHierarchy = hasValidHierarchy;
|
|
1199
1197
|
exports.isCallFromReact = isCallFromReact;
|
|
1200
|
-
exports.
|
|
1198
|
+
exports.isCallFromReactObject = isCallFromReactObject;
|
|
1201
1199
|
exports.isChildrenCount = isChildrenCount;
|
|
1202
1200
|
exports.isChildrenCountCall = isChildrenCountCall;
|
|
1203
1201
|
exports.isChildrenForEach = isChildrenForEach;
|
|
@@ -1229,7 +1227,7 @@ exports.isForwardRef = isForwardRef;
|
|
|
1229
1227
|
exports.isForwardRefCall = isForwardRefCall;
|
|
1230
1228
|
exports.isFromReact = isFromReact;
|
|
1231
1229
|
exports.isFromReactLoose = isFromReactLoose;
|
|
1232
|
-
exports.
|
|
1230
|
+
exports.isFromReactObject = isFromReactObject;
|
|
1233
1231
|
exports.isFromReactStrict = isFromReactStrict;
|
|
1234
1232
|
exports.isFunctionOfComponentDidMount = isFunctionOfComponentDidMount;
|
|
1235
1233
|
exports.isFunctionOfComponentWillUnmount = isFunctionOfComponentWillUnmount;
|
|
@@ -1246,8 +1244,8 @@ exports.isInversePhase = isInversePhase;
|
|
|
1246
1244
|
exports.isMemo = isMemo;
|
|
1247
1245
|
exports.isMemoCall = isMemoCall;
|
|
1248
1246
|
exports.isPureComponent = isPureComponent;
|
|
1249
|
-
exports.
|
|
1250
|
-
exports.
|
|
1247
|
+
exports.isReactAPI = isReactAPI;
|
|
1248
|
+
exports.isReactAPICall = isReactAPICall;
|
|
1251
1249
|
exports.isReactHook = isReactHook;
|
|
1252
1250
|
exports.isReactHookCall = isReactHookCall;
|
|
1253
1251
|
exports.isReactHookCallWithName = isReactHookCallWithName;
|