eslint-plugin-react-hooks-extra 1.5.26 → 1.5.27-beta.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.js CHANGED
@@ -9,7 +9,7 @@ var astUtils = require('@typescript-eslint/utils/ast-utils');
9
9
 
10
10
  // package.json
11
11
  var name = "eslint-plugin-react-hooks-extra";
12
- var version = "1.5.26";
12
+ var version = "1.5.27-beta.1";
13
13
  var createRule = shared.createRuleForPlugin("hooks-extra");
14
14
 
15
15
  // src/rules/ensure-custom-hooks-using-other-hooks.ts
@@ -403,9 +403,10 @@ var no_direct_set_state_in_use_effect_default = createRule({
403
403
  return {
404
404
  CallExpression(node) {
405
405
  const effectFunction = ast.traverseUp(node, isEffectFunction);
406
- if (tools.O.isNone(effectFunction)) return;
407
- const scope = context.sourceCode.getScope(node);
408
- if (scope.block !== effectFunction.value) return;
406
+ const parentFunction = ast.traverseUp(node, ast.isFunction);
407
+ if (tools.O.isNone(effectFunction) || tools.O.isNone(parentFunction)) return;
408
+ if (parentFunction.value !== effectFunction.value) return;
409
+ const callScope = context.sourceCode.getScope(node);
409
410
  const name2 = $(node.callee).with({ type: ast.NodeType.Identifier }, (n2) => tools.O.some(n2.name)).with({ type: ast.NodeType.MemberExpression }, (n2) => {
410
411
  if (!("name" in n2.object)) return tools.O.none();
411
412
  const initialScope = context.sourceCode.getScope(n2);
@@ -435,7 +436,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
435
436
  }).otherwise(tools.O.none);
436
437
  tools.F.pipe(
437
438
  name2,
438
- tools.O.flatMap(_var.findVariable(scope)),
439
+ tools.O.flatMap(_var.findVariable(callScope)),
439
440
  tools.O.flatMap(_var.getVariableInit(0)),
440
441
  tools.O.filter(ast.is(ast.NodeType.CallExpression)),
441
442
  tools.O.filter((name3) => isUseStateCallWithAlias(name3, context)),
@@ -481,9 +482,10 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
481
482
  return {
482
483
  CallExpression(node) {
483
484
  const effectFunction = ast.traverseUp(node, isEffectFunction);
484
- if (tools.O.isNone(effectFunction)) return;
485
- const scope = context.sourceCode.getScope(node);
486
- if (scope.block !== effectFunction.value) return;
485
+ const parentFunction = ast.traverseUp(node, ast.isFunction);
486
+ if (tools.O.isNone(effectFunction) || tools.O.isNone(parentFunction)) return;
487
+ if (parentFunction.value !== effectFunction.value) return;
488
+ const callScope = context.sourceCode.getScope(node);
487
489
  const name2 = $(node.callee).with({ type: ast.NodeType.Identifier }, (n2) => tools.O.some(n2.name)).with({ type: ast.NodeType.MemberExpression }, (n2) => {
488
490
  if (!("name" in n2.object)) return tools.O.none();
489
491
  const initialScope = context.sourceCode.getScope(n2);
@@ -513,7 +515,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
513
515
  }).otherwise(tools.O.none);
514
516
  tools.F.pipe(
515
517
  name2,
516
- tools.O.flatMap(_var.findVariable(scope)),
518
+ tools.O.flatMap(_var.findVariable(callScope)),
517
519
  tools.O.flatMap(_var.getVariableInit(0)),
518
520
  tools.O.filter(ast.is(ast.NodeType.CallExpression)),
519
521
  tools.O.filter((name3) => isUseStateCallWithAlias(name3, context)),
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { getStaticValue } from '@typescript-eslint/utils/ast-utils';
7
7
 
8
8
  // package.json
9
9
  var name = "eslint-plugin-react-hooks-extra";
10
- var version = "1.5.26";
10
+ var version = "1.5.27-beta.1";
11
11
  var createRule = createRuleForPlugin("hooks-extra");
12
12
 
13
13
  // src/rules/ensure-custom-hooks-using-other-hooks.ts
@@ -401,9 +401,10 @@ var no_direct_set_state_in_use_effect_default = createRule({
401
401
  return {
402
402
  CallExpression(node) {
403
403
  const effectFunction = traverseUp(node, isEffectFunction);
404
- if (O.isNone(effectFunction)) return;
405
- const scope = context.sourceCode.getScope(node);
406
- if (scope.block !== effectFunction.value) return;
404
+ const parentFunction = traverseUp(node, isFunction);
405
+ if (O.isNone(effectFunction) || O.isNone(parentFunction)) return;
406
+ if (parentFunction.value !== effectFunction.value) return;
407
+ const callScope = context.sourceCode.getScope(node);
407
408
  const name2 = $(node.callee).with({ type: NodeType.Identifier }, (n2) => O.some(n2.name)).with({ type: NodeType.MemberExpression }, (n2) => {
408
409
  if (!("name" in n2.object)) return O.none();
409
410
  const initialScope = context.sourceCode.getScope(n2);
@@ -433,7 +434,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
433
434
  }).otherwise(O.none);
434
435
  F.pipe(
435
436
  name2,
436
- O.flatMap(findVariable(scope)),
437
+ O.flatMap(findVariable(callScope)),
437
438
  O.flatMap(getVariableInit(0)),
438
439
  O.filter(is(NodeType.CallExpression)),
439
440
  O.filter((name3) => isUseStateCallWithAlias(name3, context)),
@@ -479,9 +480,10 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
479
480
  return {
480
481
  CallExpression(node) {
481
482
  const effectFunction = traverseUp(node, isEffectFunction);
482
- if (O.isNone(effectFunction)) return;
483
- const scope = context.sourceCode.getScope(node);
484
- if (scope.block !== effectFunction.value) return;
483
+ const parentFunction = traverseUp(node, isFunction);
484
+ if (O.isNone(effectFunction) || O.isNone(parentFunction)) return;
485
+ if (parentFunction.value !== effectFunction.value) return;
486
+ const callScope = context.sourceCode.getScope(node);
485
487
  const name2 = $(node.callee).with({ type: NodeType.Identifier }, (n2) => O.some(n2.name)).with({ type: NodeType.MemberExpression }, (n2) => {
486
488
  if (!("name" in n2.object)) return O.none();
487
489
  const initialScope = context.sourceCode.getScope(n2);
@@ -511,7 +513,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
511
513
  }).otherwise(O.none);
512
514
  F.pipe(
513
515
  name2,
514
- O.flatMap(findVariable(scope)),
516
+ O.flatMap(findVariable(callScope)),
515
517
  O.flatMap(getVariableInit(0)),
516
518
  O.filter(is(NodeType.CallExpression)),
517
519
  O.filter((name3) => isUseStateCallWithAlias(name3, context)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-hooks-extra",
3
- "version": "1.5.26",
3
+ "version": "1.5.27-beta.1",
4
4
  "description": "ESLint React's ESLint plugin for React Hooks related rules.",
5
5
  "homepage": "https://github.com/rel1cx/eslint-react",
6
6
  "bugs": {
@@ -39,13 +39,13 @@
39
39
  "@typescript-eslint/type-utils": "^7.16.0",
40
40
  "@typescript-eslint/types": "^7.16.0",
41
41
  "@typescript-eslint/utils": "^7.16.0",
42
- "@eslint-react/ast": "1.5.26",
43
- "@eslint-react/core": "1.5.26",
44
- "@eslint-react/jsx": "1.5.26",
45
- "@eslint-react/tools": "1.5.26",
46
- "@eslint-react/shared": "1.5.26",
47
- "@eslint-react/types": "1.5.26",
48
- "@eslint-react/var": "1.5.26"
42
+ "@eslint-react/core": "1.5.27-beta.1",
43
+ "@eslint-react/ast": "1.5.27-beta.1",
44
+ "@eslint-react/shared": "1.5.27-beta.1",
45
+ "@eslint-react/types": "1.5.27-beta.1",
46
+ "@eslint-react/var": "1.5.27-beta.1",
47
+ "@eslint-react/jsx": "1.5.27-beta.1",
48
+ "@eslint-react/tools": "1.5.27-beta.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "string-ts": "2.2.0",