@eslint-react/core 2.12.4-next.1 → 2.12.4-next.3

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
@@ -544,7 +544,7 @@ type FindEnclosingComponentOrHookFilter = (n: TSESTree.Node, name: string | null
544
544
  * @param test Optional test function to customize component or hook identification
545
545
  * @returns The enclosing component or hook node, or `null` if none is ASAST.
546
546
  */
547
- declare function findEnclosingComponentOrHook(node: TSESTree.Node | unit, test?: FindEnclosingComponentOrHookFilter): TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression | undefined;
547
+ declare function findEnclosingComponentOrHook(node: TSESTree.Node | unit, test?: FindEnclosingComponentOrHookFilter): TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | undefined;
548
548
  //#endregion
549
549
  //#region src/hierarchy/is-inside-component-or-hook.d.ts
550
550
  /**
@@ -561,7 +561,7 @@ declare function isInsideComponentOrHook(node: TSESTree.Node | unit): boolean;
561
561
  */
562
562
  declare function isUseEffectSetupCallback(node: TSESTree.Node | unit): boolean;
563
563
  /**
564
- * Determine if a node is the cleanup function returned by a useEffect-like hook's setup function.
564
+ * Determine if a node is the cleanup function returned by a useEffect-like hook's setup function
565
565
  * @param node The AST node to check
566
566
  */
567
567
  declare function isUseEffectCleanupCallback(node: TSESTree.Node | unit): boolean;
@@ -742,7 +742,7 @@ declare function resolveJsxAttributeValue(context: RuleContext, attribute: ast.T
742
742
  readonly toStatic: () => string | number | bigint | boolean | RegExp | null;
743
743
  } | {
744
744
  readonly kind: "expression";
745
- readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
745
+ readonly node: TSESTree.Expression | TSESTree.JSXEmptyExpression;
746
746
  readonly toStatic: () => unknown;
747
747
  } | {
748
748
  readonly kind: "element";
@@ -750,7 +750,7 @@ declare function resolveJsxAttributeValue(context: RuleContext, attribute: ast.T
750
750
  readonly toStatic: () => undefined;
751
751
  } | {
752
752
  readonly kind: "spreadChild";
753
- readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
753
+ readonly node: TSESTree.Expression | TSESTree.JSXEmptyExpression;
754
754
  readonly toStatic: () => undefined;
755
755
  } | {
756
756
  readonly kind: "spreadProps";
@@ -901,7 +901,7 @@ declare function isInitializedFromRef(name: string, initialScope: Scope): boolea
901
901
  * Get the init expression of a ref variable
902
902
  * @param name The variable name
903
903
  * @param initialScope The initial scope
904
- * @returns The init expression node if the variable is derived from a ref, or null otherwise
904
+ * @returns The init expression node if the variable is derived from a ref, or undefined otherwise
905
905
  */
906
906
  declare function getRefInit(name: string, initialScope: Scope): TSESTree$1.Expression | unit;
907
907
  //#endregion
package/dist/index.js CHANGED
@@ -232,15 +232,15 @@ function isUseEffectSetupCallback(node) {
232
232
  return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.arguments.at(0) === node && isUseEffectLikeCall(node.parent);
233
233
  }
234
234
  /**
235
- * Determine if a node is the cleanup function returned by a useEffect-like hook's setup function.
235
+ * Determine if a node is the cleanup function returned by a useEffect-like hook's setup function
236
236
  * @param node The AST node to check
237
237
  */
238
238
  function isUseEffectCleanupCallback(node) {
239
239
  if (node == null) return false;
240
- const pReturn = ast.findParentNode(node, ast.is(AST_NODE_TYPES.ReturnStatement));
241
- const pFunction = ast.findParentNode(node, ast.isFunction);
242
- if (pFunction !== ast.findParentNode(pReturn, ast.isFunction)) return false;
243
- return isUseEffectSetupCallback(pFunction);
240
+ const returnStatement = ast.findParentNode(node, ast.is(AST_NODE_TYPES.ReturnStatement));
241
+ const enclosingFunction = ast.findParentNode(node, ast.isFunction);
242
+ if (enclosingFunction !== ast.findParentNode(returnStatement, ast.isFunction)) return false;
243
+ return isUseEffectSetupCallback(enclosingFunction);
244
244
  }
245
245
 
246
246
  //#endregion
@@ -1274,7 +1274,7 @@ function isInitializedFromRef(name, initialScope) {
1274
1274
  * Get the init expression of a ref variable
1275
1275
  * @param name The variable name
1276
1276
  * @param initialScope The initial scope
1277
- * @returns The init expression node if the variable is derived from a ref, or null otherwise
1277
+ * @returns The init expression node if the variable is derived from a ref, or undefined otherwise
1278
1278
  */
1279
1279
  function getRefInit(name, initialScope) {
1280
1280
  for (const { node } of findVariable(initialScope)(name)?.defs ?? []) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "2.12.4-next.1",
3
+ "version": "2.12.4-next.3",
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": {
@@ -30,14 +30,14 @@
30
30
  "./package.json"
31
31
  ],
32
32
  "dependencies": {
33
- "@typescript-eslint/scope-manager": "^8.54.0",
34
- "@typescript-eslint/types": "^8.54.0",
35
- "@typescript-eslint/utils": "^8.54.0",
33
+ "@typescript-eslint/scope-manager": "^8.55.0",
34
+ "@typescript-eslint/types": "^8.55.0",
35
+ "@typescript-eslint/utils": "^8.55.0",
36
36
  "ts-pattern": "^5.9.0",
37
- "@eslint-react/ast": "2.12.4-next.1",
38
- "@eslint-react/eff": "2.12.4-next.1",
39
- "@eslint-react/shared": "2.12.4-next.1",
40
- "@eslint-react/var": "2.12.4-next.1"
37
+ "@eslint-react/ast": "2.12.4-next.3",
38
+ "@eslint-react/shared": "2.12.4-next.3",
39
+ "@eslint-react/var": "2.12.4-next.3",
40
+ "@eslint-react/eff": "2.12.4-next.3"
41
41
  },
42
42
  "devDependencies": {
43
43
  "tsdown": "^0.20.3",