@eslint-react/core 5.11.2 → 5.12.0-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.d.ts CHANGED
@@ -288,7 +288,7 @@ type FunctionSemanticNode = ClientFunctionSemanticNode | ServerFunctionSemanticN
288
288
  * @param node - The function node to analyze.
289
289
  * @returns The identifier node if found, `null` otherwise.
290
290
  */
291
- declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.PrivateIdentifier | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldNoStarExpression | TSESTree.YieldStarExpression | null;
291
+ declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.TemplateLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldNoStarExpression | TSESTree.YieldStarExpression | TSESTree.PrivateIdentifier | null;
292
292
  /**
293
293
  * Identifies the initialization path of a function node in the AST.
294
294
  *
@@ -451,9 +451,9 @@ declare const FunctionComponentDetectionHint: {
451
451
  readonly DoNotIncludeFunctionDefinedAsObjectMethod: bigint;
452
452
  readonly DoNotIncludeFunctionDefinedAsArrayExpressionElement: bigint;
453
453
  readonly DoNotIncludeFunctionDefinedAsArrayPatternElement: bigint;
454
- readonly DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback: bigint;
455
454
  readonly DoNotIncludeFunctionDefinedAsArrayFlatMapCallback: bigint;
456
455
  readonly DoNotIncludeFunctionDefinedAsArrayMapCallback: bigint;
456
+ readonly DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback: bigint;
457
457
  readonly None: 0n;
458
458
  readonly DoNotIncludeJsxWithNullValue: bigint;
459
459
  readonly DoNotIncludeJsxWithNumberValue: bigint;
package/dist/index.js CHANGED
@@ -577,9 +577,11 @@ function getFunctionComponentId(context, node) {
577
577
  if (functionId != null) return functionId;
578
578
  let parent = node.parent;
579
579
  while (Check.isTypeExpression(parent)) parent = parent.parent;
580
- if (parent.type === AST_NODE_TYPES.CallExpression && isFunctionComponentWrapperCall(context, parent) && parent.parent.type === AST_NODE_TYPES.VariableDeclarator) return parent.parent.id;
581
- if (parent.type === AST_NODE_TYPES.CallExpression && isFunctionComponentWrapperCall(context, parent) && parent.parent.type === AST_NODE_TYPES.CallExpression && isFunctionComponentWrapperCall(context, parent.parent) && parent.parent.parent.type === AST_NODE_TYPES.VariableDeclarator) return parent.parent.parent.id;
582
- return null;
580
+ switch (true) {
581
+ case parent.type === AST_NODE_TYPES.CallExpression && isFunctionComponentWrapperCall(context, parent) && parent.parent.type === AST_NODE_TYPES.VariableDeclarator: return parent.parent.id;
582
+ case parent.type === AST_NODE_TYPES.CallExpression && isFunctionComponentWrapperCall(context, parent) && parent.parent.type === AST_NODE_TYPES.CallExpression && isFunctionComponentWrapperCall(context, parent.parent) && parent.parent.parent.type === AST_NODE_TYPES.VariableDeclarator: return parent.parent.parent.id;
583
+ default: return null;
584
+ }
583
585
  }
584
586
  /**
585
587
  * Check if a string matches the strict component name pattern
@@ -619,9 +621,9 @@ const FunctionComponentDetectionHint = {
619
621
  DoNotIncludeFunctionDefinedAsObjectMethod: 1n << 13n,
620
622
  DoNotIncludeFunctionDefinedAsArrayExpressionElement: 1n << 14n,
621
623
  DoNotIncludeFunctionDefinedAsArrayPatternElement: 1n << 15n,
622
- DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback: 1n << 18n,
623
624
  DoNotIncludeFunctionDefinedAsArrayFlatMapCallback: 1n << 16n,
624
- DoNotIncludeFunctionDefinedAsArrayMapCallback: 1n << 17n
625
+ DoNotIncludeFunctionDefinedAsArrayMapCallback: 1n << 17n,
626
+ DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback: 1n << 18n
625
627
  };
626
628
  /**
627
629
  * Default component detection hint
@@ -657,7 +659,7 @@ function isFunctionComponentDefinition(context, node, hint) {
657
659
  case Check.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.MethodDefinition:
658
660
  if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsClassMethod) return false;
659
661
  break;
660
- case Check.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.Property:
662
+ case Check.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.PropertyDefinition:
661
663
  if (hint & FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsClassProperty) return false;
662
664
  break;
663
665
  case parent.type === AST_NODE_TYPES.ArrayPattern:
@@ -841,8 +843,7 @@ function isUseEffectCleanupCallback(node) {
841
843
  * ```
842
844
  */
843
845
  function isJsxLike(context, node, hint = DEFAULT_JSX_DETECTION_HINT) {
844
- const visited = /* @__PURE__ */ new Set();
845
- return visit(node);
846
+ const seen = /* @__PURE__ */ new Set();
846
847
  function visit(node) {
847
848
  if (node == null) return false;
848
849
  if (Check.isJSX(node)) return true;
@@ -877,12 +878,13 @@ function isJsxLike(context, node, hint = DEFAULT_JSX_DETECTION_HINT) {
877
878
  }
878
879
  case AST_NODE_TYPES.Identifier:
879
880
  if (node.name === "undefined") return !(hint & JsxDetectionHint.DoNotIncludeJsxWithUndefinedValue);
880
- if (visited.has(node)) return false;
881
- visited.add(node);
881
+ if (seen.has(node)) return false;
882
+ seen.add(node);
882
883
  return visit(resolve(context, node));
883
884
  }
884
885
  return false;
885
886
  }
887
+ return visit(node);
886
888
  }
887
889
 
888
890
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "5.11.2",
3
+ "version": "5.12.0-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": {
@@ -33,11 +33,11 @@
33
33
  "@typescript-eslint/types": "^8.62.1",
34
34
  "@typescript-eslint/utils": "^8.62.1",
35
35
  "ts-pattern": "^5.9.0",
36
- "@eslint-react/ast": "5.11.2",
37
- "@eslint-react/eslint": "5.11.2",
38
- "@eslint-react/jsx": "5.11.2",
39
- "@eslint-react/var": "5.11.2",
40
- "@eslint-react/shared": "5.11.2"
36
+ "@eslint-react/ast": "5.12.0-beta.0",
37
+ "@eslint-react/eslint": "5.12.0-beta.0",
38
+ "@eslint-react/jsx": "5.12.0-beta.0",
39
+ "@eslint-react/var": "5.12.0-beta.0",
40
+ "@eslint-react/shared": "5.12.0-beta.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@typescript-eslint/parser": "^8.62.1",
@@ -46,8 +46,8 @@
46
46
  "tsdown": "^0.22.3",
47
47
  "typescript": "6.0.3",
48
48
  "vitest": "^4.1.9",
49
- "@local/eff": "0.0.0",
50
- "@local/configs": "0.0.0"
49
+ "@local/configs": "0.0.0",
50
+ "@local/eff": "0.0.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "eslint": "*",