@eslint-react/core 1.47.5-next.0 → 1.48.2-beta.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.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import * as AST8 from '@eslint-react/ast';
1
+ import * as AST9 from '@eslint-react/ast';
2
2
  import { flip, dual, constFalse, identity, constTrue, _ } from '@eslint-react/eff';
3
3
  import { RegExp as RegExp$1, Selector } from '@eslint-react/kit';
4
- import { DEFAULT_ESLINT_REACT_SETTINGS as DEFAULT_ESLINT_REACT_SETTINGS$1, unsafeDecodeSettings, getId } from '@eslint-react/shared';
4
+ import { coerceSettings, getId } from '@eslint-react/shared';
5
5
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
6
6
  import * as VAR3 from '@eslint-react/var';
7
7
  import { isMatching, P, match } from 'ts-pattern';
@@ -401,6 +401,10 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
401
401
  return payload;
402
402
  };
403
403
  });
404
+ var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
405
+ $ZodType.init(inst, def);
406
+ inst._zod.parse = (payload) => payload;
407
+ });
404
408
  function handleArrayResult(result, final, index) {
405
409
  if (result.issues.length) {
406
410
  final.issues.push(...prefixIssues(index, result.issues));
@@ -662,6 +666,12 @@ function _boolean(Class, params) {
662
666
  ...normalizeParams(params)
663
667
  });
664
668
  }
669
+ function _unknown(Class, params) {
670
+ return new Class({
671
+ type: "unknown",
672
+ ...normalizeParams(params)
673
+ });
674
+ }
665
675
 
666
676
  // ../../node_modules/.pnpm/@zod+mini@4.0.0-beta.0/node_modules/@zod/mini/dist/esm/parse.js
667
677
  var parse2 = /* @__PURE__ */ _parse.bind({ Error: $ZodError });
@@ -711,6 +721,13 @@ var ZodMiniBoolean = /* @__PURE__ */ $constructor("ZodMiniBoolean", (inst, def)
711
721
  function boolean2(params) {
712
722
  return _boolean(ZodMiniBoolean, params);
713
723
  }
724
+ var ZodMiniUnknown = /* @__PURE__ */ $constructor("ZodMiniUnknown", (inst, def) => {
725
+ $ZodUnknown.init(inst, def);
726
+ ZodMiniType.init(inst, def);
727
+ });
728
+ function unknown(params) {
729
+ return _unknown(ZodMiniUnknown, params);
730
+ }
714
731
  var ZodMiniArray = /* @__PURE__ */ $constructor("ZodMiniArray", (inst, def) => {
715
732
  $ZodArray.init(inst, def);
716
733
  ZodMiniType.init(inst, def);
@@ -828,7 +845,7 @@ var CustomHooksSchema = object({
828
845
  useSyncExternalStore: optional(array(string2())),
829
846
  useTransition: optional(array(string2()))
830
847
  });
831
- var ESLintReactSettingsSchema = object({
848
+ object({
832
849
  /**
833
850
  * The source where React is imported from.
834
851
  * @description This allows to specify a custom import location for React when not using the official distribution.
@@ -856,13 +873,14 @@ var ESLintReactSettingsSchema = object({
856
873
  */
857
874
  polymorphicPropName: optional(string2()),
858
875
  /**
876
+ * @default `true`
859
877
  * @internal
860
878
  */
861
879
  strict: optional(boolean2()),
862
880
  /**
863
881
  * Check both the shape and the import to determine if an API is from React.
864
- * @description This can prevent false positives when using a irrelevant third-party library that has similar APIs to React.
865
882
  * @default `true`
883
+ * @internal
866
884
  */
867
885
  skipImportCheck: optional(boolean2()),
868
886
  /**
@@ -887,14 +905,11 @@ var ESLintReactSettingsSchema = object({
887
905
  });
888
906
  optional(
889
907
  object({
890
- "react-x": optional(ESLintReactSettingsSchema),
891
- /** @deprecated Use `react-x` instead */
892
- reactOptions: optional(ESLintReactSettingsSchema)
908
+ "react-x": optional(unknown())
893
909
  }),
894
910
  {}
895
911
  );
896
912
  var DEFAULT_ESLINT_REACT_SETTINGS = {
897
- ...parse2(ESLintReactSettingsSchema, {}),
898
913
  importSource: "react"};
899
914
  function getInstanceId(node, prev) {
900
915
  switch (true) {
@@ -928,90 +943,44 @@ function isInitializedFromReact(name, importSource, initialScope) {
928
943
  }
929
944
  const args = getRequireExpressionArguments(init);
930
945
  const arg0 = args?.[0];
931
- if (arg0 == null || !AST8.isLiteral(arg0, "string")) {
946
+ if (arg0 == null || !AST9.isLiteral(arg0, "string")) {
932
947
  return false;
933
948
  }
934
949
  return arg0.value === importSource || arg0.value.startsWith(`${importSource}/`);
935
950
  }
936
951
  return parent?.type === AST_NODE_TYPES.ImportDeclaration && parent.source.value === importSource;
937
952
  }
938
-
939
- // src/utils/is-from-react.ts
940
- var defaultImportSource = DEFAULT_ESLINT_REACT_SETTINGS$1.importSource;
941
- function isFromReactLoose(node, name) {
942
- switch (node?.type) {
943
- case AST_NODE_TYPES.Identifier:
944
- return node.name === name;
945
- case AST_NODE_TYPES.MemberExpression:
946
- return node.object.type === AST_NODE_TYPES.Identifier && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === name;
947
- default:
948
- return false;
949
- }
950
- }
951
- function isFromReactStrict(node, name, importSource, initialScope) {
952
- switch (node?.type) {
953
- case AST_NODE_TYPES.Identifier:
954
- return node.name === name && isInitializedFromReact(name, importSource, initialScope);
955
- case AST_NODE_TYPES.MemberExpression:
956
- 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);
957
- default:
958
- return false;
959
- }
960
- }
961
- function isFromReact(name) {
962
- return dual(2, (context, node) => {
963
- if (node == null) return false;
964
- const { importSource = defaultImportSource, skipImportCheck = true } = unsafeDecodeSettings(context.settings);
965
- if (skipImportCheck) return isFromReactLoose(node, name);
966
- return isFromReactStrict(node, name, importSource, context.sourceCode.getScope(node));
967
- });
968
- }
969
- function isFromReactObject(objectName, propertyName) {
970
- return dual(2, (context, node) => {
971
- if (node?.type !== AST_NODE_TYPES.MemberExpression) return false;
972
- const { importSource = defaultImportSource, skipImportCheck = true } = unsafeDecodeSettings(context.settings);
973
- const { object: object2, property } = node;
974
- if (skipImportCheck) return isFromReactLoose(object2, objectName) && isFromReactLoose(property, propertyName);
975
- return isFromReactStrict(
976
- object2,
977
- objectName,
978
- importSource,
979
- context.sourceCode.getScope(object2)
980
- ) && isFromReactLoose(property, propertyName);
981
- });
982
- }
983
- function isCallFromReact(name) {
984
- return dual(2, (context, node) => {
985
- if (node.type !== AST_NODE_TYPES.CallExpression) return false;
986
- return isFromReact(name)(context, node.callee);
987
- });
988
- }
989
- function isCallFromReactObject(objectName, propertyName) {
990
- return dual(2, (context, node) => {
991
- if (node.type !== AST_NODE_TYPES.CallExpression) return false;
992
- return isFromReactObject(objectName, propertyName)(context, node.callee);
993
- });
994
- }
995
953
  function isInstanceIdEqual(context, a, b) {
996
- return AST8.isNodeEqual(a, b) || VAR3.isNodeValueEqual(a, b, [
954
+ return AST9.isNodeEqual(a, b) || VAR3.isNodeValueEqual(a, b, [
997
955
  context.sourceCode.getScope(a),
998
956
  context.sourceCode.getScope(b)
999
957
  ]);
1000
958
  }
1001
-
1002
- // src/utils/is-react-api.ts
1003
- function isReactAPI(arg0, arg1) {
1004
- return arg1 == null ? isFromReact(arg0) : isFromReactObject(arg0, arg1);
959
+ function isReactAPI(api) {
960
+ const func = (context, node) => {
961
+ if (node == null) return false;
962
+ const getText = (n) => context.sourceCode.getText(n);
963
+ const name = AST9.toString(node, getText);
964
+ if (name === api) return true;
965
+ if (name.substring(name.indexOf(".") + 1) === api) return true;
966
+ return false;
967
+ };
968
+ return dual(2, func);
1005
969
  }
1006
- function isReactAPICall(arg0, arg1) {
1007
- return arg1 == null ? isCallFromReact(arg0) : isCallFromReactObject(arg0, arg1);
970
+ function isReactAPICall(api) {
971
+ const func = (context, node) => {
972
+ if (node == null) return false;
973
+ if (node.type !== AST_NODE_TYPES.CallExpression) return false;
974
+ return isReactAPI(api)(context, node.callee);
975
+ };
976
+ return dual(2, func);
1008
977
  }
1009
978
  var isCaptureOwnerStack = isReactAPI("captureOwnerStack");
1010
- var isChildrenCount = isReactAPI("Children", "count");
1011
- var isChildrenForEach = isReactAPI("Children", "forEach");
1012
- var isChildrenMap = isReactAPI("Children", "map");
1013
- var isChildrenOnly = isReactAPI("Children", "only");
1014
- var isChildrenToArray = isReactAPI("Children", "toArray");
979
+ var isChildrenCount = isReactAPI("Children.count");
980
+ var isChildrenForEach = isReactAPI("Children.forEach");
981
+ var isChildrenMap = isReactAPI("Children.map");
982
+ var isChildrenOnly = isReactAPI("Children.only");
983
+ var isChildrenToArray = isReactAPI("Children.toArray");
1015
984
  var isCloneElement = isReactAPI("cloneElement");
1016
985
  var isCreateContext = isReactAPI("createContext");
1017
986
  var isCreateElement = isReactAPI("createElement");
@@ -1020,11 +989,11 @@ var isForwardRef = isReactAPI("forwardRef");
1020
989
  var isMemo = isReactAPI("memo");
1021
990
  var isLazy = isReactAPI("lazy");
1022
991
  var isCaptureOwnerStackCall = isReactAPICall("captureOwnerStack");
1023
- var isChildrenCountCall = isReactAPICall("Children", "count");
1024
- var isChildrenForEachCall = isReactAPICall("Children", "forEach");
1025
- var isChildrenMapCall = isReactAPICall("Children", "map");
1026
- var isChildrenOnlyCall = isReactAPICall("Children", "only");
1027
- var isChildrenToArrayCall = isReactAPICall("Children", "toArray");
992
+ var isChildrenCountCall = isReactAPICall("Children.count");
993
+ var isChildrenForEachCall = isReactAPICall("Children.forEach");
994
+ var isChildrenMapCall = isReactAPICall("Children.map");
995
+ var isChildrenOnlyCall = isReactAPICall("Children.only");
996
+ var isChildrenToArrayCall = isReactAPICall("Children.toArray");
1028
997
  var isCloneElementCall = isReactAPICall("cloneElement");
1029
998
  var isCreateContextCall = isReactAPICall("createContext");
1030
999
  var isCreateElementCall = isReactAPICall("createElement");
@@ -1041,7 +1010,7 @@ function isReactHookName(name) {
1041
1010
  // src/hook/hook-is.ts
1042
1011
  function isReactHook(node) {
1043
1012
  if (node == null) return false;
1044
- const id = AST8.getFunctionIdentifier(node);
1013
+ const id = AST9.getFunctionIdentifier(node);
1045
1014
  return id?.name != null && isReactHookName(id.name);
1046
1015
  }
1047
1016
  function isReactHookCall(node) {
@@ -1062,7 +1031,7 @@ function isReactHookCallWithName(context, node) {
1062
1031
  const {
1063
1032
  importSource = DEFAULT_ESLINT_REACT_SETTINGS.importSource,
1064
1033
  skipImportCheck = true
1065
- } = unsafeDecodeSettings(context.settings);
1034
+ } = coerceSettings(context.settings);
1066
1035
  const initialScope = context.sourceCode.getScope(node);
1067
1036
  return (name) => {
1068
1037
  switch (true) {
@@ -1092,7 +1061,7 @@ function isReactHookCallWithNameAlias(context, name, alias = []) {
1092
1061
  const {
1093
1062
  importSource = DEFAULT_ESLINT_REACT_SETTINGS.importSource,
1094
1063
  skipImportCheck = true
1095
- } = unsafeDecodeSettings(context.settings);
1064
+ } = coerceSettings(context.settings);
1096
1065
  return (node) => {
1097
1066
  const initialScope = context.sourceCode.getScope(node);
1098
1067
  switch (true) {
@@ -1144,7 +1113,7 @@ function useHookCollector() {
1144
1113
  const hooks = /* @__PURE__ */ new Map();
1145
1114
  const functionEntries = [];
1146
1115
  const onFunctionEnter = (node) => {
1147
- const id = AST8.getFunctionIdentifier(node);
1116
+ const id = AST9.getFunctionIdentifier(node);
1148
1117
  const key = getId();
1149
1118
  const name = id?.name;
1150
1119
  if (name != null && isReactHookName(name)) {
@@ -1198,9 +1167,9 @@ function isFunctionOfUseEffectSetup(node) {
1198
1167
  }
1199
1168
  function isFunctionOfUseEffectCleanup(node) {
1200
1169
  if (node == null) return false;
1201
- const pReturn = AST8.findParentNode(node, AST8.is(AST_NODE_TYPES.ReturnStatement));
1202
- const pFaunction = AST8.findParentNode(node, AST8.isFunction);
1203
- const pFunctionOfReturn = AST8.findParentNode(pReturn, AST8.isFunction);
1170
+ const pReturn = AST9.findParentNode(node, AST9.is(AST_NODE_TYPES.ReturnStatement));
1171
+ const pFaunction = AST9.findParentNode(node, AST9.isFunction);
1172
+ const pFunctionOfReturn = AST9.findParentNode(pReturn, AST9.isFunction);
1204
1173
  if (pFaunction !== pFunctionOfReturn) return false;
1205
1174
  return isFunctionOfUseEffectSetup(pFaunction);
1206
1175
  }
@@ -1317,7 +1286,7 @@ function isJsxText(node) {
1317
1286
  }
1318
1287
  function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
1319
1288
  if (node == null) return false;
1320
- if (AST8.isJSX(node)) return true;
1289
+ if (AST9.isJSX(node)) return true;
1321
1290
  switch (node.type) {
1322
1291
  case AST_NODE_TYPES.Literal: {
1323
1292
  switch (typeof node.value) {
@@ -1391,7 +1360,7 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
1391
1360
  if (name === "undefined") {
1392
1361
  return !(hint & JSXDetectionHint.SkipUndefined);
1393
1362
  }
1394
- if (AST8.isJSXTagNameExpression(node)) {
1363
+ if (AST9.isJSXTagNameExpression(node)) {
1395
1364
  return true;
1396
1365
  }
1397
1366
  const variable = VAR3.findVariable(name, code.getScope(node));
@@ -1422,7 +1391,7 @@ function findParentAttribute(node, test = constTrue) {
1422
1391
  const guard = (node2) => {
1423
1392
  return node2.type === AST_NODE_TYPES.JSXAttribute && test(node2);
1424
1393
  };
1425
- return AST8.findParentNode(node, guard);
1394
+ return AST9.findParentNode(node, guard);
1426
1395
  }
1427
1396
  function isHostElement(context, node) {
1428
1397
  return node.type === AST_NODE_TYPES.JSXElement && node.openingElement.name.type === AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.openingElement.name.name);
@@ -1494,58 +1463,58 @@ function isPureComponent(node) {
1494
1463
  return false;
1495
1464
  }
1496
1465
  function isComponentDidCatch(node) {
1497
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
1466
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
1498
1467
  }
1499
1468
  function isComponentDidMount(node) {
1500
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
1469
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
1501
1470
  }
1502
1471
  function isComponentDidUpdate(node) {
1503
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
1472
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
1504
1473
  }
1505
1474
  function isComponentWillMount(node) {
1506
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillMount";
1475
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillMount";
1507
1476
  }
1508
1477
  function isComponentWillReceiveProps(node) {
1509
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillReceiveProps";
1478
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillReceiveProps";
1510
1479
  }
1511
1480
  function isComponentWillUnmount(node) {
1512
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
1481
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
1513
1482
  }
1514
1483
  function isComponentWillUpdate(node) {
1515
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
1484
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
1516
1485
  }
1517
1486
  function isGetChildContext(node) {
1518
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getChildContext";
1487
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getChildContext";
1519
1488
  }
1520
1489
  function isGetDefaultProps(node) {
1521
- return AST8.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDefaultProps";
1490
+ return AST9.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDefaultProps";
1522
1491
  }
1523
1492
  function isGetInitialState(node) {
1524
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getInitialState";
1493
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getInitialState";
1525
1494
  }
1526
1495
  function isGetSnapshotBeforeUpdate(node) {
1527
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getSnapshotBeforeUpdate";
1496
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getSnapshotBeforeUpdate";
1528
1497
  }
1529
1498
  function isShouldComponentUpdate(node) {
1530
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
1499
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
1531
1500
  }
1532
1501
  function isUnsafeComponentWillMount(node) {
1533
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
1502
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
1534
1503
  }
1535
1504
  function isUnsafeComponentWillReceiveProps(node) {
1536
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
1505
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
1537
1506
  }
1538
1507
  function isUnsafeComponentWillUpdate(node) {
1539
- return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
1508
+ return AST9.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
1540
1509
  }
1541
1510
  function isGetDerivedStateFromProps(node) {
1542
- return AST8.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
1511
+ return AST9.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
1543
1512
  }
1544
1513
  function isGetDerivedStateFromError(node) {
1545
- return AST8.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
1514
+ return AST9.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
1546
1515
  }
1547
1516
  function isRenderLike(node) {
1548
- return AST8.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
1517
+ return AST9.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
1549
1518
  }
1550
1519
  function isFunctionOfRender(node) {
1551
1520
  if (!isRenderLike(node.parent)) {
@@ -1554,7 +1523,7 @@ function isFunctionOfRender(node) {
1554
1523
  return isClassComponent(node.parent.parent.parent);
1555
1524
  }
1556
1525
  function isRenderMethodLike(node) {
1557
- return AST8.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name.startsWith("render") && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
1526
+ return AST9.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name.startsWith("render") && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
1558
1527
  }
1559
1528
 
1560
1529
  // src/component/component-hierarchy.ts
@@ -1565,13 +1534,13 @@ function isChildrenOfCreateElement(context, node) {
1565
1534
  return parent.arguments.slice(2).some((arg) => arg === node);
1566
1535
  }
1567
1536
  function isInsideRenderMethod(node) {
1568
- return AST8.findParentNode(node, (n) => isRenderLike(n) && isClassComponent(n.parent.parent)) != null;
1537
+ return AST9.findParentNode(node, (n) => isRenderLike(n) && isClassComponent(n.parent.parent)) != null;
1569
1538
  }
1570
1539
  function isFunctionOfComponentDidMount(node) {
1571
- return AST8.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
1540
+ return AST9.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
1572
1541
  }
1573
1542
  function isFunctionOfComponentWillUnmount(node) {
1574
- return AST8.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
1543
+ return AST9.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
1575
1544
  }
1576
1545
  function isFunctionOfRenderMethod(node) {
1577
1546
  if (!isRenderMethodLike(node.parent)) {
@@ -1611,12 +1580,12 @@ function isValidComponentDefinition(context, node, hint) {
1611
1580
  if (hint & ComponentDetectionHint.SkipClassProperty && isFunctionOfClassProperty(node.parent)) {
1612
1581
  return false;
1613
1582
  }
1614
- if (hint & ComponentDetectionHint.SkipArrayMapArgument && AST8.isArrayMapCall(node.parent)) {
1583
+ if (hint & ComponentDetectionHint.SkipArrayMapArgument && AST9.isArrayMapCall(node.parent)) {
1615
1584
  return false;
1616
1585
  }
1617
- const significantParent = AST8.findParentNode(
1586
+ const significantParent = AST9.findParentNode(
1618
1587
  node,
1619
- AST8.isOneOf([
1588
+ AST9.isOneOf([
1620
1589
  AST_NODE_TYPES.JSXExpressionContainer,
1621
1590
  AST_NODE_TYPES.ArrowFunctionExpression,
1622
1591
  AST_NODE_TYPES.FunctionExpression,
@@ -1637,7 +1606,7 @@ function isComponentWrapperCallLoose(context, node) {
1637
1606
 
1638
1607
  // src/component/component-id.ts
1639
1608
  function getFunctionComponentId(context, node) {
1640
- const functionId = AST8.getFunctionIdentifier(node);
1609
+ const functionId = AST9.getFunctionIdentifier(node);
1641
1610
  if (functionId != null) {
1642
1611
  return functionId;
1643
1612
  }
@@ -1664,10 +1633,10 @@ var ComponentFlag = {
1664
1633
  // src/component/component-init-path.ts
1665
1634
  function getComponentFlagFromInitPath(initPath) {
1666
1635
  let flag = ComponentFlag.None;
1667
- if (initPath != null && AST8.hasCallInFunctionInitPath("memo", initPath)) {
1636
+ if (initPath != null && AST9.hasCallInFunctionInitPath("memo", initPath)) {
1668
1637
  flag |= ComponentFlag.Memo;
1669
1638
  }
1670
- if (initPath != null && AST8.hasCallInFunctionInitPath("forwardRef", initPath)) {
1639
+ if (initPath != null && AST9.hasCallInFunctionInitPath("forwardRef", initPath)) {
1671
1640
  flag |= ComponentFlag.ForwardRef;
1672
1641
  }
1673
1642
  return flag;
@@ -1707,7 +1676,7 @@ function useComponentCollector(context, options = {}) {
1707
1676
  const entry = functionEntries.at(-1);
1708
1677
  if (entry == null) return;
1709
1678
  if (!entry.isComponent) return functionEntries.pop();
1710
- const shouldDrop = AST8.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
1679
+ const shouldDrop = AST9.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
1711
1680
  return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !isJsxLike(context.sourceCode, r.argument, hint);
1712
1681
  });
1713
1682
  if (shouldDrop) {
@@ -1734,7 +1703,7 @@ function useComponentCollector(context, options = {}) {
1734
1703
  const { body } = entry.node;
1735
1704
  const isComponent = hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, body, hint) && isValidComponentDefinition(context, entry.node, hint);
1736
1705
  if (!isComponent) return;
1737
- const initPath = AST8.getFunctionInitPath(entry.node);
1706
+ const initPath = AST9.getFunctionInitPath(entry.node);
1738
1707
  const id = getFunctionComponentId(context, entry.node);
1739
1708
  const name = getComponentNameFromId(id);
1740
1709
  const key = getId();
@@ -1775,7 +1744,7 @@ function useComponentCollector(context, options = {}) {
1775
1744
  const isComponent = hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, node.argument, hint) && isValidComponentDefinition(context, entry.node, hint);
1776
1745
  if (!isComponent) return;
1777
1746
  entry.isComponent = true;
1778
- const initPath = AST8.getFunctionInitPath(entry.node);
1747
+ const initPath = AST9.getFunctionInitPath(entry.node);
1779
1748
  const id = getFunctionComponentId(context, entry.node);
1780
1749
  const name = getComponentNameFromId(id);
1781
1750
  components.set(entry.key, {
@@ -1806,7 +1775,7 @@ function useComponentCollectorLegacy() {
1806
1775
  if (!isClassComponent(node)) {
1807
1776
  return;
1808
1777
  }
1809
- const id = AST8.getClassIdentifier(node);
1778
+ const id = AST9.getClassIdentifier(node);
1810
1779
  const key = getId();
1811
1780
  const flag = isPureComponent(node) ? ComponentFlag.PureComponent : ComponentFlag.None;
1812
1781
  components.set(
@@ -1839,7 +1808,7 @@ var ComponentPhaseRelevance = birecord({
1839
1808
  var isInversePhase = dual(2, (a, b) => ComponentPhaseRelevance.get(a) === b);
1840
1809
  function isRenderFunctionLoose(context, node) {
1841
1810
  const { body, parent } = node;
1842
- if (AST8.getFunctionIdentifier(node)?.name.startsWith("render")) {
1811
+ if (AST9.getFunctionIdentifier(node)?.name.startsWith("render")) {
1843
1812
  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");
1844
1813
  }
1845
1814
  return isJsxLike(
@@ -1852,7 +1821,7 @@ function isRenderPropLoose(context, node) {
1852
1821
  if (node.name.type !== AST_NODE_TYPES.JSXIdentifier) {
1853
1822
  return false;
1854
1823
  }
1855
- return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && AST8.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression);
1824
+ return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && AST9.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression);
1856
1825
  }
1857
1826
  function isDirectValueOfRenderPropertyLoose(node) {
1858
1827
  const matching = (node2) => {
@@ -1864,7 +1833,7 @@ function isDeclaredInRenderPropLoose(node) {
1864
1833
  if (isDirectValueOfRenderPropertyLoose(node)) {
1865
1834
  return true;
1866
1835
  }
1867
- const parent = AST8.findParentNode(node, AST8.is(AST_NODE_TYPES.JSXExpressionContainer))?.parent;
1836
+ const parent = AST9.findParentNode(node, AST9.is(AST_NODE_TYPES.JSXExpressionContainer))?.parent;
1868
1837
  if (parent?.type !== AST_NODE_TYPES.JSXAttribute) {
1869
1838
  return false;
1870
1839
  }
@@ -1872,11 +1841,11 @@ function isDeclaredInRenderPropLoose(node) {
1872
1841
  }
1873
1842
  function isThisSetState(node) {
1874
1843
  const { callee } = node;
1875
- return callee.type === AST_NODE_TYPES.MemberExpression && AST8.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
1844
+ return callee.type === AST_NODE_TYPES.MemberExpression && AST9.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
1876
1845
  }
1877
1846
  function isAssignmentToThisState(node) {
1878
1847
  const { left } = node;
1879
- return left.type === AST_NODE_TYPES.MemberExpression && AST8.isThisExpression(left.object) && AST8.getPropertyName(left.property) === "state";
1848
+ return left.type === AST_NODE_TYPES.MemberExpression && AST9.isThisExpression(left.object) && AST9.getPropertyName(left.property) === "state";
1880
1849
  }
1881
1850
 
1882
- export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getComponentFlagFromInitPath, getComponentNameFromId, getElementType, getFunctionComponentId, getInstanceId, hasAnyAttribute, hasAttribute, hasEveryAttribute, hasNoneOrLooseComponentName, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRender, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHostElement, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isJsxLike, isJsxText, isKeyedElement, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
1851
+ export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getComponentFlagFromInitPath, getComponentNameFromId, getElementType, getFunctionComponentId, getInstanceId, hasAnyAttribute, hasAttribute, hasEveryAttribute, hasNoneOrLooseComponentName, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRender, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHostElement, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isJsxLike, isJsxText, isKeyedElement, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "1.47.5-next.0",
3
+ "version": "1.48.2-beta.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,11 +41,11 @@
41
41
  "@typescript-eslint/utils": "^8.30.1",
42
42
  "birecord": "^0.1.1",
43
43
  "ts-pattern": "^5.7.0",
44
- "@eslint-react/ast": "1.47.5-next.0",
45
- "@eslint-react/eff": "1.47.5-next.0",
46
- "@eslint-react/kit": "1.47.5-next.0",
47
- "@eslint-react/var": "1.47.5-next.0",
48
- "@eslint-react/shared": "1.47.5-next.0"
44
+ "@eslint-react/ast": "1.48.2-beta.0",
45
+ "@eslint-react/eff": "1.48.2-beta.0",
46
+ "@eslint-react/shared": "1.48.2-beta.0",
47
+ "@eslint-react/var": "1.48.2-beta.0",
48
+ "@eslint-react/kit": "1.48.2-beta.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "tsup": "^8.4.0",