@eslint-react/core 5.5.6-beta.0 → 5.6.0-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.
Files changed (2) hide show
  1. package/dist/index.js +12 -5
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -365,7 +365,7 @@ function isRenderMethodCallback(node) {
365
365
  * @deprecated Class components are legacy. This function exists only to support legacy rules.
366
366
  */
367
367
  function isThisSetStateCall(node) {
368
- const { callee } = node;
368
+ const callee = Extract.unwrap(node.callee);
369
369
  return callee.type === AST_NODE_TYPES.MemberExpression && callee.object.type === AST_NODE_TYPES.ThisExpression && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
370
370
  }
371
371
  /**
@@ -505,7 +505,7 @@ function getFunctionInitPath(node) {
505
505
  function isFunctionHasCallInInitPath(callName, initPath) {
506
506
  return initPath.some((node) => {
507
507
  if (node.type !== AST_NODE_TYPES.CallExpression) return false;
508
- const { callee } = node;
508
+ const callee = Extract.unwrap(node.callee);
509
509
  if (callee.type === AST_NODE_TYPES.Identifier) return callee.name === callName;
510
510
  if (callee.type === AST_NODE_TYPES.MemberExpression && "name" in callee.property) return callee.property.name === callName;
511
511
  return false;
@@ -672,12 +672,19 @@ const DEFAULT_COMPONENT_DETECTION_HINT = 0n | FunctionComponentDetectionHint.DoN
672
672
  */
673
673
  function isFunctionComponentDefinition(context, node, hint) {
674
674
  if (!isFunctionWithLooseComponentName(context, node, true)) return false;
675
+ const isCreateElementArg = (() => {
676
+ let p = node.parent;
677
+ while (Check.isTypeExpression(p)) p = p.parent;
678
+ if (p.type !== AST_NODE_TYPES.CallExpression || !isCreateElementCall(context, p)) return false;
679
+ return p.arguments.slice(2).some((arg) => Extract.unwrap(arg) === node);
680
+ })();
675
681
  switch (true) {
676
- case node.parent.type === AST_NODE_TYPES.CallExpression && isCreateElementCall(context, node.parent) && node.parent.arguments.slice(2).some((arg) => arg === node): return false;
682
+ case isCreateElementArg: return false;
677
683
  case isRenderMethodCallback(node): return false;
678
684
  }
679
685
  let parent = node.parent;
680
686
  while (Check.isTypeExpression(parent)) parent = parent.parent;
687
+ const parentCallee = parent.type === AST_NODE_TYPES.CallExpression ? Extract.unwrap(parent.callee) : null;
681
688
  switch (true) {
682
689
  case isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.Property && parent.parent.type === AST_NODE_TYPES.ObjectExpression:
683
690
  if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsObjectMethod) return false;
@@ -694,10 +701,10 @@ function isFunctionComponentDefinition(context, node, hint) {
694
701
  case parent.type === AST_NODE_TYPES.ArrayExpression:
695
702
  if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayExpressionElement) return false;
696
703
  break;
697
- case parent.type === AST_NODE_TYPES.CallExpression && parent.callee.type === AST_NODE_TYPES.MemberExpression && parent.callee.property.type === AST_NODE_TYPES.Identifier && parent.callee.property.name === "map":
704
+ case parentCallee != null && parentCallee.type === AST_NODE_TYPES.MemberExpression && parentCallee.property.type === AST_NODE_TYPES.Identifier && parentCallee.property.name === "map":
698
705
  if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback) return false;
699
706
  break;
700
- case parent.type === AST_NODE_TYPES.CallExpression && parent.callee.type === AST_NODE_TYPES.MemberExpression && parent.callee.property.type === AST_NODE_TYPES.Identifier && parent.callee.property.name === "flatMap":
707
+ case parentCallee != null && parentCallee.type === AST_NODE_TYPES.MemberExpression && parentCallee.property.type === AST_NODE_TYPES.Identifier && parentCallee.property.name === "flatMap":
701
708
  if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayFlatMapCallback) return false;
702
709
  break;
703
710
  case parent.type === AST_NODE_TYPES.CallExpression && getFunctionId(node) == null && !isFunctionComponentWrapperCall(context, parent) && !isCreateElementCall(context, parent):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "5.5.6-beta.0",
3
+ "version": "5.6.0-beta.1",
4
4
  "description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -33,11 +33,11 @@
33
33
  "@typescript-eslint/types": "^8.59.1",
34
34
  "@typescript-eslint/utils": "^8.59.1",
35
35
  "ts-pattern": "^5.9.0",
36
- "@eslint-react/ast": "5.5.6-beta.0",
37
- "@eslint-react/eslint": "5.5.6-beta.0",
38
- "@eslint-react/jsx": "5.5.6-beta.0",
39
- "@eslint-react/shared": "5.5.6-beta.0",
40
- "@eslint-react/var": "5.5.6-beta.0"
36
+ "@eslint-react/eslint": "5.6.0-beta.1",
37
+ "@eslint-react/jsx": "5.6.0-beta.1",
38
+ "@eslint-react/ast": "5.6.0-beta.1",
39
+ "@eslint-react/shared": "5.6.0-beta.1",
40
+ "@eslint-react/var": "5.6.0-beta.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@typescript-eslint/parser": "^8.59.1",
@@ -46,8 +46,8 @@
46
46
  "tsdown": "^0.21.10",
47
47
  "typescript": "^6.0.3",
48
48
  "vitest": "^4.1.5",
49
- "@local/configs": "0.0.0",
50
- "@local/eff": "3.0.0-beta.72"
49
+ "@local/eff": "3.0.0-beta.72",
50
+ "@local/configs": "0.0.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "eslint": "^10.2.1",