@eslint-react/core 5.26.8 → 5.27.1

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
@@ -494,9 +494,8 @@ export type FunctionDisplayNameAssignment = TSESTree.AssignmentExpression & {
494
494
  };
495
495
  };
496
496
  operator: "=";
497
- right: TSESTree.Literal;
498
497
  };
499
- /** The esquery selector matching `displayName` assignment expressions with a statically determinable property name and a literal right side. */
498
+ /** The esquery selector matching `displayName` assignment expressions with a statically determinable property name. */
500
499
  export declare const SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT: string;
501
500
  //#endregion
502
501
  //#region src/hook.d.ts
package/dist/index.js CHANGED
@@ -167,6 +167,9 @@ const absurd = (_) => {
167
167
  throw new Error("Called `absurd` function which should be uncallable");
168
168
  };
169
169
  cast(absurd);
170
+ function not(predicate) {
171
+ return (data) => !predicate(data);
172
+ }
170
173
  dual(2, (a, b) => (data) => a(data) && b(data));
171
174
  dual(2, (a, b) => (data) => a(data) || b(data));
172
175
  dual(2, (a, b) => (data) => a(data) !== b(data));
@@ -430,7 +433,6 @@ const SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT = [
430
433
  "AssignmentExpression",
431
434
  "[operator='=']",
432
435
  "[left.type='MemberExpression']",
433
- "[right.type='Literal']",
434
436
  ":matches(",
435
437
  "[left.computed=false][left.property.name='displayName']",
436
438
  ", ",
@@ -657,20 +659,20 @@ function isUseEffectLikeCall(node, additionalEffectHooks = { test: constFalse })
657
659
  function isUseEffectSetupCallback(node) {
658
660
  if (node == null) return false;
659
661
  const expr = Extract.unwrap(node);
660
- let parent = expr.parent;
661
- while (parent != null && (Check.isTypeExpression(parent) || parent.type === AST_NODE_TYPES.ChainExpression)) parent = parent.parent;
662
- if (parent?.type !== AST_NODE_TYPES.CallExpression) return false;
663
- const firstArgument = parent.arguments.at(0);
664
- return firstArgument != null && Extract.unwrap(firstArgument) === expr && isUseEffectLikeCall(parent);
662
+ const call = Traverse.findParent(expr, not(Check.isTypeOrChainExpression));
663
+ if (call?.type !== AST_NODE_TYPES.CallExpression) return false;
664
+ const [arg0] = call.arguments;
665
+ if (arg0 == null) return false;
666
+ return Extract.unwrap(arg0) === expr && isUseEffectLikeCall(call);
665
667
  }
666
668
  function isUseEffectCleanupCallback(node) {
667
669
  if (node == null) return false;
668
670
  const expr = Extract.unwrap(node);
669
- const returnStatement = Traverse.findParent(expr, Check.isReturnStatement);
670
- const enclosingFunction = Traverse.findParent(expr, Check.isFunction);
671
- if (returnStatement == null) return Check.isFunction(expr) && enclosingFunction?.type === AST_NODE_TYPES.ArrowFunctionExpression && Extract.unwrap(enclosingFunction.body) === expr && isUseEffectSetupCallback(enclosingFunction);
672
- if (enclosingFunction !== Traverse.findParent(returnStatement, Check.isFunction)) return false;
673
- return returnStatement.argument != null && Extract.unwrap(returnStatement.argument) === expr && isUseEffectSetupCallback(enclosingFunction);
671
+ const func = Traverse.findParent(expr, Check.isFunction);
672
+ if (func == null || !isUseEffectSetupCallback(func)) return false;
673
+ const stat = Traverse.findParent(expr, Check.isReturnStatement, Check.isFunction);
674
+ if (stat != null) return stat.argument != null && Extract.unwrap(stat.argument) === expr;
675
+ return Check.isFunction(expr) && func.type === AST_NODE_TYPES.ArrowFunctionExpression && Extract.unwrap(func.body) === expr;
674
676
  }
675
677
  //#endregion
676
678
  //#region src/function-component-collector.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "5.26.8",
3
+ "version": "5.27.1",
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": {
@@ -29,10 +29,10 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@eslint-react/ast": "5.26.8",
33
- "@eslint-react/eslint": "5.26.8",
34
- "@eslint-react/shared": "5.26.8",
35
- "@eslint-react/var": "5.26.8",
32
+ "@eslint-react/ast": "5.27.1",
33
+ "@eslint-react/eslint": "5.27.1",
34
+ "@eslint-react/shared": "5.27.1",
35
+ "@eslint-react/var": "5.27.1",
36
36
  "@typescript-eslint/types": "^8.71.2",
37
37
  "@typescript-eslint/utils": "^8.71.2",
38
38
  "ts-pattern": "^5.9.2"