@eslint-react/core 2.7.3-next.4 → 2.7.4-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
@@ -25,6 +25,14 @@ declare const ComponentDetectionHint: {
25
25
  * Skip function component defined on class property
26
26
  */
27
27
  readonly SkipClassProperty: bigint;
28
+ /**
29
+ * Skip function component defined in array pattern
30
+ */
31
+ readonly SkipArrayPattern: bigint;
32
+ /**
33
+ * Skip function component defined in array expression
34
+ */
35
+ readonly SkipArrayExpression: bigint;
28
36
  /**
29
37
  * Skip function component defined as array map callback
30
38
  */
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { IdGenerator, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_J
4
4
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
5
5
  import { findImportSource, findProperty, findVariable, getVariableDefinitionNode, isNodeValueEqual } from "@eslint-react/var";
6
6
  import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
7
- import { P, isMatching, match } from "ts-pattern";
7
+ import { P, match } from "ts-pattern";
8
8
  import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from "@typescript-eslint/utils";
9
9
  import birecord from "birecord";
10
10
 
@@ -687,12 +687,14 @@ const ComponentDetectionHint = {
687
687
  SkipObjectMethod: 1n << 64n,
688
688
  SkipClassMethod: 1n << 65n,
689
689
  SkipClassProperty: 1n << 66n,
690
- SkipArrayMapCallback: 1n << 67n
690
+ SkipArrayPattern: 1n << 67n,
691
+ SkipArrayExpression: 1n << 68n,
692
+ SkipArrayMapCallback: 1n << 69n
691
693
  };
692
694
  /**
693
695
  * Default component detection hint
694
696
  */
695
- const DEFAULT_COMPONENT_DETECTION_HINT = 0n | ComponentDetectionHint.SkipArrayMapCallback | ComponentDetectionHint.SkipBooleanLiteral | ComponentDetectionHint.SkipEmptyArray | ComponentDetectionHint.SkipNumberLiteral | ComponentDetectionHint.SkipStringLiteral | ComponentDetectionHint.SkipUndefined | ComponentDetectionHint.StrictArray | ComponentDetectionHint.StrictConditional | ComponentDetectionHint.StrictLogical;
697
+ const DEFAULT_COMPONENT_DETECTION_HINT = 0n | ComponentDetectionHint.SkipArrayExpression | ComponentDetectionHint.SkipArrayMapCallback | ComponentDetectionHint.SkipArrayPattern | ComponentDetectionHint.SkipBooleanLiteral | ComponentDetectionHint.SkipEmptyArray | ComponentDetectionHint.SkipNumberLiteral | ComponentDetectionHint.SkipStringLiteral | ComponentDetectionHint.SkipUndefined | ComponentDetectionHint.StrictArray | ComponentDetectionHint.StrictConditional | ComponentDetectionHint.StrictLogical;
696
698
 
697
699
  //#endregion
698
700
  //#region src/component/component-is.ts
@@ -748,27 +750,6 @@ function isRenderMethodLike(node) {
748
750
  //#endregion
749
751
  //#region src/component/component-definition.ts
750
752
  /**
751
- * Function patterns for matching specific AST structures
752
- * Used to identify where a function is defined (e.g., method, property)
753
- */
754
- const FUNCTION_PATTERNS = {
755
- CLASS_METHOD: {
756
- type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
757
- parent: AST_NODE_TYPES.MethodDefinition
758
- },
759
- CLASS_PROPERTY: {
760
- type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
761
- parent: AST_NODE_TYPES.Property
762
- },
763
- OBJECT_METHOD: {
764
- type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
765
- parent: {
766
- type: AST_NODE_TYPES.Property,
767
- parent: { type: AST_NODE_TYPES.ObjectExpression }
768
- }
769
- }
770
- };
771
- /**
772
753
  * Checks if the given node is a function within a render method of a class component.
773
754
  *
774
755
  * @param node The AST node to check
@@ -795,9 +776,11 @@ function isRenderMethodCallback(node) {
795
776
  */
796
777
  function shouldExcludeBasedOnHint(node, hint) {
797
778
  switch (true) {
798
- case hint & ComponentDetectionHint.SkipObjectMethod && isMatching(FUNCTION_PATTERNS.OBJECT_METHOD)(node): return true;
799
- case hint & ComponentDetectionHint.SkipClassMethod && isMatching(FUNCTION_PATTERNS.CLASS_METHOD)(node): return true;
800
- case hint & ComponentDetectionHint.SkipClassProperty && isMatching(FUNCTION_PATTERNS.CLASS_PROPERTY)(node): return true;
779
+ case hint & ComponentDetectionHint.SkipObjectMethod && AST.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && node.parent.type === AST_NODE_TYPES.Property && node.parent.parent.type === AST_NODE_TYPES.ObjectExpression: return true;
780
+ case hint & ComponentDetectionHint.SkipClassMethod && AST.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && node.parent.type === AST_NODE_TYPES.MethodDefinition: return true;
781
+ case hint & ComponentDetectionHint.SkipClassProperty && AST.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && node.parent.type === AST_NODE_TYPES.Property: return true;
782
+ case hint & ComponentDetectionHint.SkipArrayPattern && node.parent.type === AST_NODE_TYPES.ArrayPattern: return true;
783
+ case hint & ComponentDetectionHint.SkipArrayExpression && node.parent.type === AST_NODE_TYPES.ArrayExpression: return true;
801
784
  case hint & ComponentDetectionHint.SkipArrayMapCallback && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee.type === AST_NODE_TYPES.MemberExpression && node.parent.callee.property.type === AST_NODE_TYPES.Identifier && node.parent.callee.property.name === "map": return true;
802
785
  }
803
786
  return false;
@@ -827,8 +810,6 @@ function isComponentDefinition(context, node, hint) {
827
810
  if (isChildrenOfCreateElement(context, node) || isRenderMethodCallback(node)) return false;
828
811
  if (shouldExcludeBasedOnHint(node, hint)) return false;
829
812
  const significantParent = AST.findParentNode(node, AST.isOneOf([
830
- AST_NODE_TYPES.ArrayPattern,
831
- AST_NODE_TYPES.ArrayExpression,
832
813
  AST_NODE_TYPES.JSXExpressionContainer,
833
814
  AST_NODE_TYPES.ArrowFunctionExpression,
834
815
  AST_NODE_TYPES.FunctionExpression,
@@ -837,7 +818,6 @@ function isComponentDefinition(context, node, hint) {
837
818
  ]));
838
819
  if (significantParent == null) return true;
839
820
  if (significantParent.type === AST_NODE_TYPES.JSXExpressionContainer) return false;
840
- if (significantParent.type === AST_NODE_TYPES.ArrayPattern || significantParent.type === AST_NODE_TYPES.ArrayExpression) return false;
841
821
  return true;
842
822
  }
843
823
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "2.7.3-next.4",
3
+ "version": "2.7.4-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": {
@@ -35,10 +35,10 @@
35
35
  "@typescript-eslint/utils": "^8.53.1",
36
36
  "birecord": "^0.1.1",
37
37
  "ts-pattern": "^5.9.0",
38
- "@eslint-react/ast": "2.7.3-next.4",
39
- "@eslint-react/eff": "2.7.3-next.4",
40
- "@eslint-react/shared": "2.7.3-next.4",
41
- "@eslint-react/var": "2.7.3-next.4"
38
+ "@eslint-react/eff": "2.7.4-beta.0",
39
+ "@eslint-react/ast": "2.7.4-beta.0",
40
+ "@eslint-react/shared": "2.7.4-beta.0",
41
+ "@eslint-react/var": "2.7.4-beta.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsdown": "^0.20.0-beta.4",