@eslint-react/core 3.0.0-next.82 → 3.0.0-next.83

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 +16 -11
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1109,7 +1109,8 @@ function isComponentWrapperCallLoose(context, node) {
1109
1109
  */
1110
1110
  function isComponentWrapperCallback(context, node) {
1111
1111
  if (!ast.isFunction(node)) return false;
1112
- const parent = node.parent;
1112
+ let parent = node.parent;
1113
+ while (ast.isTypeExpression(parent)) parent = parent.parent;
1113
1114
  if (parent.type !== AST_NODE_TYPES.CallExpression) return false;
1114
1115
  return isComponentWrapperCall(context, parent);
1115
1116
  }
@@ -1121,7 +1122,8 @@ function isComponentWrapperCallback(context, node) {
1121
1122
  */
1122
1123
  function isComponentWrapperCallbackLoose(context, node) {
1123
1124
  if (!ast.isFunction(node)) return false;
1124
- const parent = node.parent;
1125
+ let parent = node.parent;
1126
+ while (ast.isTypeExpression(parent)) parent = parent.parent;
1125
1127
  if (parent.type !== AST_NODE_TYPES.CallExpression) return false;
1126
1128
  return isComponentWrapperCallLoose(context, parent);
1127
1129
  }
@@ -1137,7 +1139,8 @@ function isComponentWrapperCallbackLoose(context, node) {
1137
1139
  function getFunctionComponentId(context, node) {
1138
1140
  const functionId = ast.getFunctionId(node);
1139
1141
  if (functionId != null) return functionId;
1140
- const { parent } = node;
1142
+ let parent = node.parent;
1143
+ while (ast.isTypeExpression(parent)) parent = parent.parent;
1141
1144
  if (parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent) && parent.parent.type === AST_NODE_TYPES.VariableDeclarator) return parent.parent.id;
1142
1145
  if (parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent) && parent.parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent.parent) && parent.parent.parent.type === AST_NODE_TYPES.VariableDeclarator) return parent.parent.parent.id;
1143
1146
  return null;
@@ -1208,29 +1211,31 @@ function isComponentDefinition(context, node, hint) {
1208
1211
  case node.parent.type === AST_NODE_TYPES.CallExpression && isCreateElementCall(context, node.parent) && node.parent.arguments.slice(2).some((arg) => arg === node): return false;
1209
1212
  case isRenderMethodCallback(node): return false;
1210
1213
  }
1214
+ let parent = node.parent;
1215
+ while (ast.isTypeExpression(parent)) parent = parent.parent;
1211
1216
  switch (true) {
1212
- case 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:
1217
+ case ast.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.Property && parent.parent.type === AST_NODE_TYPES.ObjectExpression:
1213
1218
  if (hint & ComponentDetectionHint.DoNotIncludeFunctionDefinedOnObjectMethod) return false;
1214
1219
  break;
1215
- case ast.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && node.parent.type === AST_NODE_TYPES.MethodDefinition:
1220
+ case ast.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.MethodDefinition:
1216
1221
  if (hint & ComponentDetectionHint.DoNotIncludeFunctionDefinedOnClassMethod) return false;
1217
1222
  break;
1218
- case ast.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && node.parent.type === AST_NODE_TYPES.Property:
1223
+ case ast.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(node) && parent.type === AST_NODE_TYPES.Property:
1219
1224
  if (hint & ComponentDetectionHint.DoNotIncludeFunctionDefinedOnClassProperty) return false;
1220
1225
  break;
1221
- case node.parent.type === AST_NODE_TYPES.ArrayPattern:
1226
+ case parent.type === AST_NODE_TYPES.ArrayPattern:
1222
1227
  if (hint & ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayPattern) return false;
1223
1228
  break;
1224
- case node.parent.type === AST_NODE_TYPES.ArrayExpression:
1229
+ case parent.type === AST_NODE_TYPES.ArrayExpression:
1225
1230
  if (hint & ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayExpression) return false;
1226
1231
  break;
1227
- case 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":
1232
+ 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":
1228
1233
  if (hint & ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback) return false;
1229
1234
  break;
1230
- case 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 === "flatMap":
1235
+ 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":
1231
1236
  if (hint & ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayFlatMapCallback) return false;
1232
1237
  break;
1233
- case getFunctionComponentId(context, node) == null && node.parent.type === AST_NODE_TYPES.CallExpression && !isComponentWrapperCallLoose(context, node.parent) && !isCreateElementCall(context, node.parent):
1238
+ case parent.type === AST_NODE_TYPES.CallExpression && ast.getFunctionId(node) == null && !isComponentWrapperCallLoose(context, parent) && !isCreateElementCall(context, parent):
1234
1239
  if (hint & ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback) return false;
1235
1240
  break;
1236
1241
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "3.0.0-next.82",
3
+ "version": "3.0.0-next.83",
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": {
@@ -34,14 +34,14 @@
34
34
  "@typescript-eslint/types": "canary",
35
35
  "@typescript-eslint/utils": "canary",
36
36
  "ts-pattern": "^5.9.0",
37
- "@eslint-react/ast": "3.0.0-next.82",
38
- "@eslint-react/shared": "3.0.0-next.82",
39
- "@eslint-react/var": "3.0.0-next.82"
37
+ "@eslint-react/shared": "3.0.0-next.83",
38
+ "@eslint-react/ast": "3.0.0-next.83",
39
+ "@eslint-react/var": "3.0.0-next.83"
40
40
  },
41
41
  "devDependencies": {
42
42
  "tsdown": "^0.21.0",
43
- "@local/eff": "3.0.0-beta.72",
44
- "@local/configs": "0.0.0"
43
+ "@local/configs": "0.0.0",
44
+ "@local/eff": "3.0.0-beta.72"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "eslint": "^10.0.0",