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

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
@@ -92,6 +92,7 @@ type ComponentDetectionHint = bigint;
92
92
  * Hints for component collector
93
93
  */
94
94
  declare const ComponentDetectionHint: {
95
+ readonly DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback: bigint;
95
96
  readonly DoNotIncludeFunctionDefinedAsArrayFlatMapCallback: bigint;
96
97
  readonly DoNotIncludeFunctionDefinedAsArrayMapCallback: bigint;
97
98
  readonly DoNotIncludeFunctionDefinedInArrayExpression: bigint;
package/dist/index.js CHANGED
@@ -396,11 +396,11 @@ function isUseEffectLikeCall(node, additionalEffectHooks = { test: constFalse })
396
396
  function isUseStateLikeCall(node, additionalStateHooks = { test: constFalse }) {
397
397
  if (node == null) return false;
398
398
  if (node.type !== AST_NODE_TYPES.CallExpression) return false;
399
- return [/^use\w*State$/u, additionalStateHooks].some((regexp) => {
400
- if (node.callee.type === AST_NODE_TYPES.Identifier) return regexp.test(node.callee.name);
401
- if (node.callee.type === AST_NODE_TYPES.MemberExpression) return node.callee.property.type === AST_NODE_TYPES.Identifier && regexp.test(node.callee.property.name);
402
- return false;
403
- });
399
+ switch (true) {
400
+ case node.callee.type === AST_NODE_TYPES.Identifier: return node.callee.name === "useState" || additionalStateHooks.test(node.callee.name);
401
+ case node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier: return ast.getPropertyName(node.callee.property) === "useState" || additionalStateHooks.test(node.callee.property.name);
402
+ }
403
+ return false;
404
404
  }
405
405
  const isUseCall = flip(isHookCallWithName)("use");
406
406
  const isUseActionStateCall = flip(isHookCallWithName)("useActionState");
@@ -1181,6 +1181,7 @@ function isFunctionWithLooseComponentName(context, fn, allowNone = false) {
1181
1181
  */
1182
1182
  const ComponentDetectionHint = {
1183
1183
  ...JsxDetectionHint,
1184
+ DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback: 1n << 18n,
1184
1185
  DoNotIncludeFunctionDefinedAsArrayFlatMapCallback: 1n << 17n,
1185
1186
  DoNotIncludeFunctionDefinedAsArrayMapCallback: 1n << 16n,
1186
1187
  DoNotIncludeFunctionDefinedInArrayExpression: 1n << 15n,
@@ -1192,7 +1193,7 @@ const ComponentDetectionHint = {
1192
1193
  /**
1193
1194
  * Default component detection hint
1194
1195
  */
1195
- const DEFAULT_COMPONENT_DETECTION_HINT = 0n | ComponentDetectionHint.DoNotIncludeJsxWithBigIntValue | ComponentDetectionHint.DoNotIncludeJsxWithBooleanValue | ComponentDetectionHint.DoNotIncludeJsxWithNumberValue | ComponentDetectionHint.DoNotIncludeJsxWithStringValue | ComponentDetectionHint.DoNotIncludeJsxWithUndefinedValue | ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayFlatMapCallback | ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback | ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayExpression | ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayPattern | ComponentDetectionHint.RequireAllArrayElementsToBeJsx | ComponentDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx | ComponentDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx;
1196
+ const DEFAULT_COMPONENT_DETECTION_HINT = 0n | ComponentDetectionHint.DoNotIncludeJsxWithBigIntValue | ComponentDetectionHint.DoNotIncludeJsxWithBooleanValue | ComponentDetectionHint.DoNotIncludeJsxWithNumberValue | ComponentDetectionHint.DoNotIncludeJsxWithStringValue | ComponentDetectionHint.DoNotIncludeJsxWithUndefinedValue | ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback | ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayFlatMapCallback | ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback | ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayExpression | ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayPattern | ComponentDetectionHint.RequireAllArrayElementsToBeJsx | ComponentDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx | ComponentDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx;
1196
1197
  /**
1197
1198
  * Determine if a function node represents a valid React component definition
1198
1199
  *
@@ -1229,6 +1230,9 @@ function isComponentDefinition(context, node, hint) {
1229
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":
1230
1231
  if (hint & ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayFlatMapCallback) return false;
1231
1232
  break;
1233
+ case getFunctionComponentId(context, node) == null && node.parent.type === AST_NODE_TYPES.CallExpression && !isComponentWrapperCallLoose(context, node.parent) && !isCreateElementCall(context, node.parent):
1234
+ if (hint & ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback) return false;
1235
+ break;
1232
1236
  }
1233
1237
  const significantParent = ast.findParentNode(node, ast.isOneOf([
1234
1238
  AST_NODE_TYPES.JSXExpressionContainer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "3.0.0-next.80",
3
+ "version": "3.0.0-next.82",
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.80",
38
- "@eslint-react/shared": "3.0.0-next.80",
39
- "@eslint-react/var": "3.0.0-next.80"
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"
40
40
  },
41
41
  "devDependencies": {
42
42
  "tsdown": "^0.21.0",
43
- "@local/configs": "0.0.0",
44
- "@local/eff": "3.0.0-beta.72"
43
+ "@local/eff": "3.0.0-beta.72",
44
+ "@local/configs": "0.0.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "eslint": "^10.0.0",