@eslint-react/core 1.38.0-beta.9 → 1.38.0-next.10

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 CHANGED
@@ -20,9 +20,9 @@ declare const ERComponentHint: {
20
20
  */
21
21
  readonly SkipForwardRef: bigint;
22
22
  /**
23
- * Skip function component defined in map function callback
23
+ * Skip function component defined as array map argument
24
24
  */
25
- readonly SkipMapCallback: bigint;
25
+ readonly SkipArrayMapArgument: bigint;
26
26
  /**
27
27
  * Skip function component defined on object method
28
28
  */
package/dist/index.d.ts CHANGED
@@ -20,9 +20,9 @@ declare const ERComponentHint: {
20
20
  */
21
21
  readonly SkipForwardRef: bigint;
22
22
  /**
23
- * Skip function component defined in map function callback
23
+ * Skip function component defined as array map argument
24
24
  */
25
- readonly SkipMapCallback: bigint;
25
+ readonly SkipArrayMapArgument: bigint;
26
26
  /**
27
27
  * Skip function component defined on object method
28
28
  */
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var AST6 = require('@eslint-react/ast');
4
4
  var eff = require('@eslint-react/eff');
5
- var JSX3 = require('@eslint-react/jsx');
5
+ var JSX4 = require('@eslint-react/jsx');
6
6
  var shared = require('@eslint-react/shared');
7
7
  var types = require('@typescript-eslint/types');
8
8
  var VAR = require('@eslint-react/var');
@@ -31,7 +31,7 @@ function _interopNamespace(e) {
31
31
  }
32
32
 
33
33
  var AST6__namespace = /*#__PURE__*/_interopNamespace(AST6);
34
- var JSX3__namespace = /*#__PURE__*/_interopNamespace(JSX3);
34
+ var JSX4__namespace = /*#__PURE__*/_interopNamespace(JSX4);
35
35
  var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
36
36
  var birecord__default = /*#__PURE__*/_interopDefault(birecord);
37
37
 
@@ -819,7 +819,7 @@ var ERComponentHint = {
819
819
  /**
820
820
  * 1n << 0n - 1n << 63n are reserved for JSXValueHint
821
821
  */
822
- ...JSX3__namespace.JSXValueHint,
822
+ ...JSX4__namespace.JSXValueHint,
823
823
  /**
824
824
  * Skip function component created by React.memo
825
825
  */
@@ -829,9 +829,9 @@ var ERComponentHint = {
829
829
  */
830
830
  SkipForwardRef: 1n << 65n,
831
831
  /**
832
- * Skip function component defined in map function callback
832
+ * Skip function component defined as array map argument
833
833
  */
834
- SkipMapCallback: 1n << 66n,
834
+ SkipArrayMapArgument: 1n << 66n,
835
835
  /**
836
836
  * Skip function component defined on object method
837
837
  */
@@ -845,7 +845,7 @@ var ERComponentHint = {
845
845
  */
846
846
  SkipClassProperty: 1n << 69n
847
847
  };
848
- var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipEmptyArray | ERComponentHint.SkipMapCallback | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
848
+ var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipEmptyArray | ERComponentHint.SkipArrayMapArgument | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
849
849
 
850
850
  // src/component/component-flag.ts
851
851
  var ERComponentFlag = {
@@ -959,9 +959,6 @@ function hasValidHierarchy(context, node, hint) {
959
959
  if (isChildrenOfCreateElement(context, node) || isFunctionOfRenderMethod(node)) {
960
960
  return false;
961
961
  }
962
- if (hint & ERComponentHint.SkipMapCallback && AST6__namespace.isMapCallLoose(node.parent)) {
963
- return false;
964
- }
965
962
  if (hint & ERComponentHint.SkipObjectMethod && isFunctionOfObjectMethod(node.parent)) {
966
963
  return false;
967
964
  }
@@ -971,6 +968,9 @@ function hasValidHierarchy(context, node, hint) {
971
968
  if (hint & ERComponentHint.SkipClassProperty && isFunctionOfClassProperty(node.parent)) {
972
969
  return false;
973
970
  }
971
+ if (hint & ERComponentHint.SkipArrayMapArgument && AST6__namespace.isArrayMapCallLoose(node.parent)) {
972
+ return false;
973
+ }
974
974
  const boundaryNode = AST6__namespace.findParentNode(
975
975
  node,
976
976
  AST6__namespace.isOneOf([
@@ -1019,7 +1019,7 @@ function useComponentCollector(context, options = {}) {
1019
1019
  if (entry == null) return;
1020
1020
  if (!entry.isComponent) return functionEntries.pop();
1021
1021
  const shouldDrop = AST6__namespace.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
1022
- return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3__namespace.isJSXValue(r.argument, jsxCtx, hint);
1022
+ return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX4__namespace.isJSXValue(r.argument, jsxCtx, hint);
1023
1023
  });
1024
1024
  if (shouldDrop) {
1025
1025
  components.delete(entry.key);
@@ -1043,7 +1043,7 @@ function useComponentCollector(context, options = {}) {
1043
1043
  const entry = getCurrentEntry();
1044
1044
  if (entry == null) return;
1045
1045
  const { body } = entry.node;
1046
- const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3__namespace.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
1046
+ const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX4__namespace.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
1047
1047
  if (!isComponent) return;
1048
1048
  const initPath = AST6__namespace.getFunctionInitPath(entry.node);
1049
1049
  const id = getFunctionComponentIdentifier(context, entry.node);
@@ -1083,7 +1083,7 @@ function useComponentCollector(context, options = {}) {
1083
1083
  "ReturnStatement[type]"(node) {
1084
1084
  const entry = getCurrentEntry();
1085
1085
  if (entry == null) return;
1086
- const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3__namespace.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
1086
+ const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX4__namespace.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
1087
1087
  if (!isComponent) return;
1088
1088
  entry.isComponent = true;
1089
1089
  const initPath = AST6__namespace.getFunctionInitPath(entry.node);
@@ -1163,12 +1163,12 @@ function isRenderFunctionLoose(context, node) {
1163
1163
  if (AST6__namespace.getFunctionIdentifier(node)?.name.startsWith("render")) {
1164
1164
  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");
1165
1165
  }
1166
- return JSX3__namespace.isJSXValue(
1166
+ return JSX4__namespace.isJSXValue(
1167
1167
  body,
1168
1168
  {
1169
1169
  getScope: (node2) => context.sourceCode.getScope(node2)
1170
1170
  },
1171
- JSX3__namespace.JSXValueHint.SkipNullLiteral | JSX3__namespace.JSXValueHint.SkipUndefined | JSX3__namespace.JSXValueHint.StrictLogical | JSX3__namespace.JSXValueHint.StrictConditional
1171
+ JSX4__namespace.JSXValueHint.SkipNullLiteral | JSX4__namespace.JSXValueHint.SkipUndefined | JSX4__namespace.JSXValueHint.StrictLogical | JSX4__namespace.JSXValueHint.StrictConditional
1172
1172
  );
1173
1173
  }
1174
1174
  function isRenderPropLoose(context, node) {
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as AST6 from '@eslint-react/ast';
2
2
  import { flip, dual, constFalse, identity, _ } from '@eslint-react/eff';
3
- import * as JSX3 from '@eslint-react/jsx';
3
+ import * as JSX4 from '@eslint-react/jsx';
4
4
  import { DEFAULT_ESLINT_REACT_SETTINGS as DEFAULT_ESLINT_REACT_SETTINGS$1, unsafeDecodeSettings, getId } from '@eslint-react/shared';
5
5
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
6
6
  import * as VAR from '@eslint-react/var';
@@ -792,7 +792,7 @@ var ERComponentHint = {
792
792
  /**
793
793
  * 1n << 0n - 1n << 63n are reserved for JSXValueHint
794
794
  */
795
- ...JSX3.JSXValueHint,
795
+ ...JSX4.JSXValueHint,
796
796
  /**
797
797
  * Skip function component created by React.memo
798
798
  */
@@ -802,9 +802,9 @@ var ERComponentHint = {
802
802
  */
803
803
  SkipForwardRef: 1n << 65n,
804
804
  /**
805
- * Skip function component defined in map function callback
805
+ * Skip function component defined as array map argument
806
806
  */
807
- SkipMapCallback: 1n << 66n,
807
+ SkipArrayMapArgument: 1n << 66n,
808
808
  /**
809
809
  * Skip function component defined on object method
810
810
  */
@@ -818,7 +818,7 @@ var ERComponentHint = {
818
818
  */
819
819
  SkipClassProperty: 1n << 69n
820
820
  };
821
- var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipEmptyArray | ERComponentHint.SkipMapCallback | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
821
+ var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipEmptyArray | ERComponentHint.SkipArrayMapArgument | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
822
822
 
823
823
  // src/component/component-flag.ts
824
824
  var ERComponentFlag = {
@@ -932,9 +932,6 @@ function hasValidHierarchy(context, node, hint) {
932
932
  if (isChildrenOfCreateElement(context, node) || isFunctionOfRenderMethod(node)) {
933
933
  return false;
934
934
  }
935
- if (hint & ERComponentHint.SkipMapCallback && AST6.isMapCallLoose(node.parent)) {
936
- return false;
937
- }
938
935
  if (hint & ERComponentHint.SkipObjectMethod && isFunctionOfObjectMethod(node.parent)) {
939
936
  return false;
940
937
  }
@@ -944,6 +941,9 @@ function hasValidHierarchy(context, node, hint) {
944
941
  if (hint & ERComponentHint.SkipClassProperty && isFunctionOfClassProperty(node.parent)) {
945
942
  return false;
946
943
  }
944
+ if (hint & ERComponentHint.SkipArrayMapArgument && AST6.isArrayMapCallLoose(node.parent)) {
945
+ return false;
946
+ }
947
947
  const boundaryNode = AST6.findParentNode(
948
948
  node,
949
949
  AST6.isOneOf([
@@ -992,7 +992,7 @@ function useComponentCollector(context, options = {}) {
992
992
  if (entry == null) return;
993
993
  if (!entry.isComponent) return functionEntries.pop();
994
994
  const shouldDrop = AST6.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
995
- return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3.isJSXValue(r.argument, jsxCtx, hint);
995
+ return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX4.isJSXValue(r.argument, jsxCtx, hint);
996
996
  });
997
997
  if (shouldDrop) {
998
998
  components.delete(entry.key);
@@ -1016,7 +1016,7 @@ function useComponentCollector(context, options = {}) {
1016
1016
  const entry = getCurrentEntry();
1017
1017
  if (entry == null) return;
1018
1018
  const { body } = entry.node;
1019
- const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
1019
+ const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX4.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
1020
1020
  if (!isComponent) return;
1021
1021
  const initPath = AST6.getFunctionInitPath(entry.node);
1022
1022
  const id = getFunctionComponentIdentifier(context, entry.node);
@@ -1056,7 +1056,7 @@ function useComponentCollector(context, options = {}) {
1056
1056
  "ReturnStatement[type]"(node) {
1057
1057
  const entry = getCurrentEntry();
1058
1058
  if (entry == null) return;
1059
- const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX3.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
1059
+ const isComponent = hasNoneOrLooseComponentName(context, entry.node) && JSX4.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(context, entry.node, hint);
1060
1060
  if (!isComponent) return;
1061
1061
  entry.isComponent = true;
1062
1062
  const initPath = AST6.getFunctionInitPath(entry.node);
@@ -1136,12 +1136,12 @@ function isRenderFunctionLoose(context, node) {
1136
1136
  if (AST6.getFunctionIdentifier(node)?.name.startsWith("render")) {
1137
1137
  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");
1138
1138
  }
1139
- return JSX3.isJSXValue(
1139
+ return JSX4.isJSXValue(
1140
1140
  body,
1141
1141
  {
1142
1142
  getScope: (node2) => context.sourceCode.getScope(node2)
1143
1143
  },
1144
- JSX3.JSXValueHint.SkipNullLiteral | JSX3.JSXValueHint.SkipUndefined | JSX3.JSXValueHint.StrictLogical | JSX3.JSXValueHint.StrictConditional
1144
+ JSX4.JSXValueHint.SkipNullLiteral | JSX4.JSXValueHint.SkipUndefined | JSX4.JSXValueHint.StrictLogical | JSX4.JSXValueHint.StrictConditional
1145
1145
  );
1146
1146
  }
1147
1147
  function isRenderPropLoose(context, node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "1.38.0-beta.9",
3
+ "version": "1.38.0-next.10",
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,12 +41,12 @@
41
41
  "@typescript-eslint/utils": "^8.27.0",
42
42
  "birecord": "^0.1.1",
43
43
  "ts-pattern": "^5.6.2",
44
- "@eslint-react/ast": "1.38.0-beta.9",
45
- "@eslint-react/eff": "1.38.0-beta.9",
46
- "@eslint-react/jsx": "1.38.0-beta.9",
47
- "@eslint-react/kit": "1.38.0-beta.9",
48
- "@eslint-react/var": "1.38.0-beta.9",
49
- "@eslint-react/shared": "1.38.0-beta.9"
44
+ "@eslint-react/ast": "1.38.0-next.10",
45
+ "@eslint-react/eff": "1.38.0-next.10",
46
+ "@eslint-react/jsx": "1.38.0-next.10",
47
+ "@eslint-react/shared": "1.38.0-next.10",
48
+ "@eslint-react/var": "1.38.0-next.10",
49
+ "@eslint-react/kit": "1.38.0-next.10"
50
50
  },
51
51
  "devDependencies": {
52
52
  "tsup": "^8.4.0",