eslint-plugin-react-hooks-extra 1.13.0 → 1.13.1-beta.2

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/README.md CHANGED
@@ -43,8 +43,8 @@ export default [
43
43
 
44
44
  | Rule | Description | 💼 | 💭 | |
45
45
  | :------------------------------------- | :------------------------------------------------------------------------ | :-: | :-: | :-: |
46
- | `no-direct-set-state-in-use-effect` | Disallow direct calls to the `set` function of `useState` in `useEffect`. | ✔️ | | |
46
+ | `no-direct-set-state-in-use-effect` | Disallow direct calls to the `set` function of `useState` in `useEffect`. | ✔️ | | 📐 |
47
47
  | `no-redundant-custom-hook` | Warns when custom Hooks that don't use other Hooks. | ✔️ | | |
48
- | `no-unnecessary-use-callback` | Disallow unnecessary usage of `useCallback`. | ✔️ | | |
49
- | `no-unnecessary-use-memo` | Disallow unnecessary usage of `useMemo`. | ✔️ | | |
48
+ | `no-unnecessary-use-callback` | Disallow unnecessary usage of `useCallback`. | ✔️ | | 📐 |
49
+ | `no-unnecessary-use-memo` | Disallow unnecessary usage of `useMemo`. | ✔️ | | 📐 |
50
50
  | `prefer-use-state-lazy-initialization` | Warns function calls made inside `useState` calls. | 🚀 | | |
package/dist/index.js CHANGED
@@ -1,24 +1,45 @@
1
1
  'use strict';
2
2
 
3
- var ast = require('@eslint-react/ast');
3
+ var AST2 = require('@eslint-react/ast');
4
4
  var core = require('@eslint-react/core');
5
5
  var shared = require('@eslint-react/shared');
6
6
  var tools = require('@eslint-react/tools');
7
- var _var = require('@eslint-react/var');
7
+ var VAR3 = require('@eslint-react/var');
8
8
  var types = require('@typescript-eslint/types');
9
9
  var tsPattern = require('ts-pattern');
10
10
  var astUtils = require('@typescript-eslint/utils/ast-utils');
11
11
 
12
+ function _interopNamespace(e) {
13
+ if (e && e.__esModule) return e;
14
+ var n = Object.create(null);
15
+ if (e) {
16
+ Object.keys(e).forEach(function (k) {
17
+ if (k !== 'default') {
18
+ var d = Object.getOwnPropertyDescriptor(e, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: function () { return e[k]; }
22
+ });
23
+ }
24
+ });
25
+ }
26
+ n.default = e;
27
+ return Object.freeze(n);
28
+ }
29
+
30
+ var AST2__namespace = /*#__PURE__*/_interopNamespace(AST2);
31
+ var VAR3__namespace = /*#__PURE__*/_interopNamespace(VAR3);
32
+
12
33
  // package.json
13
34
  var name = "eslint-plugin-react-hooks-extra";
14
- var version = "1.13.0";
35
+ var version = "1.13.1-beta.2";
15
36
  var createRule = shared.createRuleForPlugin("hooks-extra");
16
37
  function isFromHookCall(name2, context, settings, predicate = tools.F.constTrue) {
17
38
  const hookAlias = settings.additionalHooks?.[name2] ?? [];
18
39
  return (topLevelId) => tools.F.pipe(
19
- _var.findVariable(topLevelId, context.sourceCode.getScope(topLevelId)),
20
- tools.O.flatMap(_var.getVariableNode(0)),
21
- tools.O.filter(ast.is(types.AST_NODE_TYPES.CallExpression)),
40
+ VAR3__namespace.findVariable(topLevelId, context.sourceCode.getScope(topLevelId)),
41
+ tools.O.flatMap(VAR3__namespace.getVariableNode(0)),
42
+ tools.O.filter(AST2__namespace.is(types.AST_NODE_TYPES.CallExpression)),
22
43
  tools.O.filter(core.isReactHookCallWithNameAlias(name2, context, hookAlias)),
23
44
  tools.O.exists((call) => predicate(topLevelId, call))
24
45
  );
@@ -52,7 +73,7 @@ function isSetFunctionCall(context, settings) {
52
73
  // const data = useState();
53
74
  // data.at(1)();
54
75
  case types.AST_NODE_TYPES.CallExpression: {
55
- const callee = node.callee.callee;
76
+ const { callee } = node.callee;
56
77
  if (callee.type !== types.AST_NODE_TYPES.MemberExpression) return false;
57
78
  if (!("name" in callee.object)) return false;
58
79
  const isAt = tsPattern.isMatching({
@@ -147,7 +168,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
147
168
  return tsPattern.match(node).when(isUseStateCall2, () => "useState").when(isUseEffectLikeCall, () => "useEffect").when(isSetStateCall, () => "setState").when(isThenCall, () => "then").otherwise(() => "other");
148
169
  }
149
170
  function getFunctionKind(node) {
150
- return tsPattern.match(node).when(isSetupFunction, () => "setup").when(ast.isFunctionOfImmediatelyInvoked, () => "immediate").otherwise(() => "other");
171
+ return tsPattern.match(node).when(isSetupFunction, () => "setup").when(AST2__namespace.isFunctionOfImmediatelyInvoked, () => "immediate").otherwise(() => "other");
151
172
  }
152
173
  return {
153
174
  ":function"(node) {
@@ -167,7 +188,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
167
188
  tsPattern.match(getCallKind(node)).with("setState", () => {
168
189
  if (!parentFn) return;
169
190
  if (parentFn !== effectFn && parentFnKind !== "immediate") {
170
- const maybeVd = ast.traverseUpGuard(node, isVariableDeclaratorFromHookCall);
191
+ const maybeVd = AST2__namespace.traverseUpGuard(node, isVariableDeclaratorFromHookCall);
171
192
  if (tools.O.isSome(maybeVd)) {
172
193
  const vd = maybeVd.value;
173
194
  const calls2 = indirectSetStateCallsInHooks.get(vd.init) ?? [];
@@ -185,8 +206,8 @@ var no_direct_set_state_in_use_effect_default = createRule({
185
206
  });
186
207
  }).with("useEffect", () => {
187
208
  const [firstArg] = node.arguments;
188
- if (ast.isFunction(firstArg)) return;
189
- const identifiers = ast.getNestedIdentifiers(node);
209
+ if (AST2__namespace.isFunction(firstArg)) return;
210
+ const identifiers = AST2__namespace.getNestedIdentifiers(node);
190
211
  setupFunctionIdentifiers.push(...identifiers);
191
212
  }).with("other", () => {
192
213
  const isInSetupFunction = effectFn === parentFn;
@@ -202,7 +223,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
202
223
  const [firstArg] = node.parent.arguments;
203
224
  if (node !== firstArg) break;
204
225
  if (isUseCallbackCall2(node.parent)) {
205
- const maybeVd = ast.traverseUpGuard(node.parent, isVariableDeclaratorFromHookCall);
226
+ const maybeVd = AST2__namespace.traverseUpGuard(node.parent, isVariableDeclaratorFromHookCall);
206
227
  if (tools.O.isNone(maybeVd)) break;
207
228
  const vd = maybeVd.value;
208
229
  const calls = indirectSetStateCallsAsArgs.get(vd.init) ?? [];
@@ -218,7 +239,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
218
239
  const parent = node.parent.parent;
219
240
  if (parent.type !== types.AST_NODE_TYPES.CallExpression) break;
220
241
  if (!isUseMemoCall2(parent)) break;
221
- const maybeVd = ast.traverseUpGuard(parent, isVariableDeclaratorFromHookCall);
242
+ const maybeVd = AST2__namespace.traverseUpGuard(parent, isVariableDeclaratorFromHookCall);
222
243
  if (tools.O.isNone(maybeVd)) break;
223
244
  const vd = maybeVd.value;
224
245
  const calls = indirectSetStateCallsAsArgs.get(vd.init) ?? [];
@@ -228,7 +249,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
228
249
  },
229
250
  "Program:exit"() {
230
251
  const getSetStateCalls = (id, initialScope) => {
231
- const node = tools.O.flatMap(_var.findVariable(id, initialScope), _var.getVariableNode(0)).pipe(tools.O.getOrNull);
252
+ const node = tools.O.flatMap(VAR3__namespace.findVariable(id, initialScope), VAR3__namespace.getVariableNode(0)).pipe(tools.O.getOrNull);
232
253
  switch (node?.type) {
233
254
  case types.AST_NODE_TYPES.FunctionDeclaration:
234
255
  case types.AST_NODE_TYPES.FunctionExpression:
@@ -257,7 +278,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
257
278
  messageId: "noDirectSetStateInUseEffect",
258
279
  node: setStateCall,
259
280
  data: {
260
- name: ast.toReadableNodeName(setStateCall, (n) => context.sourceCode.getText(n))
281
+ name: AST2__namespace.toReadableNodeName(setStateCall, (n) => context.sourceCode.getText(n))
261
282
  }
262
283
  });
263
284
  }
@@ -269,7 +290,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
269
290
  messageId: "noDirectSetStateInUseEffect",
270
291
  node: setStateCall,
271
292
  data: {
272
- name: ast.toReadableNodeName(setStateCall, (n) => context.sourceCode.getText(n))
293
+ name: AST2__namespace.toReadableNodeName(setStateCall, (n) => context.sourceCode.getText(n))
273
294
  }
274
295
  });
275
296
  }
@@ -299,7 +320,7 @@ var no_redundant_custom_hook_default = createRule({
299
320
  "Program:exit"(node) {
300
321
  const allHooks = ctx.getAllHooks(node);
301
322
  for (const { name: name2, node: node2, hookCalls } of allHooks.values()) {
302
- if (ast.isEmptyFunction(node2)) continue;
323
+ if (AST2__namespace.isEmptyFunction(node2)) continue;
303
324
  if (hookCalls.length > 0) continue;
304
325
  context.report({
305
326
  messageId: "noRedundantCustomHook",
@@ -339,7 +360,7 @@ var no_unnecessary_use_callback_default = createRule({
339
360
  }
340
361
  const scope = context.sourceCode.getScope(node);
341
362
  const component = scope.block;
342
- if (!ast.isFunction(component)) return;
363
+ if (!AST2__namespace.isFunction(component)) return;
343
364
  const [cb, deps] = node.arguments;
344
365
  if (!deps) {
345
366
  context.report({
@@ -351,9 +372,9 @@ var no_unnecessary_use_callback_default = createRule({
351
372
  const hasEmptyDeps = tools.F.pipe(
352
373
  tsPattern.match(deps).with({ type: types.AST_NODE_TYPES.ArrayExpression }, tools.O.some).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => {
353
374
  return tools.F.pipe(
354
- _var.findVariable(n.name, initialScope),
355
- tools.O.flatMap(_var.getVariableNode(0)),
356
- tools.O.filter(ast.is(types.AST_NODE_TYPES.ArrayExpression))
375
+ VAR3__namespace.findVariable(n.name, initialScope),
376
+ tools.O.flatMap(VAR3__namespace.getVariableNode(0)),
377
+ tools.O.filter(AST2__namespace.is(types.AST_NODE_TYPES.ArrayExpression))
357
378
  );
358
379
  }).otherwise(tools.O.none),
359
380
  tools.O.exists((x) => x.elements.length === 0)
@@ -374,9 +395,9 @@ var no_unnecessary_use_callback_default = createRule({
374
395
  return tools.O.some(n);
375
396
  }).with({ type: types.AST_NODE_TYPES.FunctionExpression }, tools.O.some).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => {
376
397
  return tools.F.pipe(
377
- _var.findVariable(n.name, initialScope),
378
- tools.O.flatMap(_var.getVariableNode(0)),
379
- tools.O.filter(ast.isFunction)
398
+ VAR3__namespace.findVariable(n.name, initialScope),
399
+ tools.O.flatMap(VAR3__namespace.getVariableNode(0)),
400
+ tools.O.filter(AST2__namespace.isFunction)
380
401
  );
381
402
  }).otherwise(tools.O.none),
382
403
  tools.O.map((n) => context.sourceCode.getScope(n)),
@@ -418,7 +439,7 @@ var no_unnecessary_use_memo_default = createRule({
418
439
  }
419
440
  const scope = context.sourceCode.getScope(node);
420
441
  const component = scope.block;
421
- if (!ast.isFunction(component)) return;
442
+ if (!AST2__namespace.isFunction(component)) return;
422
443
  const [cb, deps] = node.arguments;
423
444
  if (!deps) {
424
445
  context.report({
@@ -430,9 +451,9 @@ var no_unnecessary_use_memo_default = createRule({
430
451
  const hasEmptyDeps = tools.F.pipe(
431
452
  tsPattern.match(deps).with({ type: types.AST_NODE_TYPES.ArrayExpression }, tools.O.some).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => {
432
453
  return tools.F.pipe(
433
- _var.findVariable(n.name, initialScope),
434
- tools.O.flatMap(_var.getVariableNode(0)),
435
- tools.O.filter(ast.is(types.AST_NODE_TYPES.ArrayExpression))
454
+ VAR3__namespace.findVariable(n.name, initialScope),
455
+ tools.O.flatMap(VAR3__namespace.getVariableNode(0)),
456
+ tools.O.filter(AST2__namespace.is(types.AST_NODE_TYPES.ArrayExpression))
436
457
  );
437
458
  }).otherwise(tools.O.none),
438
459
  tools.O.exists((x) => x.elements.length === 0)
@@ -453,9 +474,9 @@ var no_unnecessary_use_memo_default = createRule({
453
474
  return tools.O.some(n);
454
475
  }).with({ type: types.AST_NODE_TYPES.FunctionExpression }, tools.O.some).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => {
455
476
  return tools.F.pipe(
456
- _var.findVariable(n.name, initialScope),
457
- tools.O.flatMap(_var.getVariableNode(0)),
458
- tools.O.filter(ast.isFunction)
477
+ VAR3__namespace.findVariable(n.name, initialScope),
478
+ tools.O.flatMap(VAR3__namespace.getVariableNode(0)),
479
+ tools.O.filter(AST2__namespace.isFunction)
459
480
  );
460
481
  }).otherwise(tools.O.none),
461
482
  tools.O.map((n) => context.sourceCode.getScope(n)),
@@ -495,7 +516,7 @@ var prefer_use_state_lazy_initialization_default = createRule({
495
516
  if (!core.isUseStateCall(node, context) && !alias.some(core.isReactHookCallWithNameLoose(node))) return;
496
517
  const [useStateInput] = node.arguments;
497
518
  if (!useStateInput) return;
498
- const nestedCallExpressions = ast.getNestedCallExpressions(useStateInput);
519
+ const nestedCallExpressions = AST2__namespace.getNestedCallExpressions(useStateInput);
499
520
  const hasFunctionCall = nestedCallExpressions.some((n) => {
500
521
  return "name" in n.callee && !ALLOW_LIST.includes(n.callee.name);
501
522
  });
package/dist/index.mjs CHANGED
@@ -1,22 +1,22 @@
1
- import { traverseUpGuard, isFunction, getNestedIdentifiers, toReadableNodeName, isEmptyFunction, is, getNestedCallExpressions, isFunctionOfImmediatelyInvoked } from '@eslint-react/ast';
1
+ import * as AST2 from '@eslint-react/ast';
2
2
  import { isReactHookCallWithNameAlias, useHookCollector, isReactHookCall, isUseCallbackCall, isReactHookCallWithNameLoose, isUseMemoCall, isUseStateCall, isReactHookName } from '@eslint-react/core';
3
3
  import { createRuleForPlugin, decodeSettings } from '@eslint-react/shared';
4
4
  import { MutRef, O, F } from '@eslint-react/tools';
5
- import { findVariable, getVariableNode } from '@eslint-react/var';
5
+ import * as VAR3 from '@eslint-react/var';
6
6
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
7
7
  import { match, isMatching } from 'ts-pattern';
8
8
  import { getStaticValue } from '@typescript-eslint/utils/ast-utils';
9
9
 
10
10
  // package.json
11
11
  var name = "eslint-plugin-react-hooks-extra";
12
- var version = "1.13.0";
12
+ var version = "1.13.1-beta.2";
13
13
  var createRule = createRuleForPlugin("hooks-extra");
14
14
  function isFromHookCall(name2, context, settings, predicate = F.constTrue) {
15
15
  const hookAlias = settings.additionalHooks?.[name2] ?? [];
16
16
  return (topLevelId) => F.pipe(
17
- findVariable(topLevelId, context.sourceCode.getScope(topLevelId)),
18
- O.flatMap(getVariableNode(0)),
19
- O.filter(is(AST_NODE_TYPES.CallExpression)),
17
+ VAR3.findVariable(topLevelId, context.sourceCode.getScope(topLevelId)),
18
+ O.flatMap(VAR3.getVariableNode(0)),
19
+ O.filter(AST2.is(AST_NODE_TYPES.CallExpression)),
20
20
  O.filter(isReactHookCallWithNameAlias(name2, context, hookAlias)),
21
21
  O.exists((call) => predicate(topLevelId, call))
22
22
  );
@@ -50,7 +50,7 @@ function isSetFunctionCall(context, settings) {
50
50
  // const data = useState();
51
51
  // data.at(1)();
52
52
  case AST_NODE_TYPES.CallExpression: {
53
- const callee = node.callee.callee;
53
+ const { callee } = node.callee;
54
54
  if (callee.type !== AST_NODE_TYPES.MemberExpression) return false;
55
55
  if (!("name" in callee.object)) return false;
56
56
  const isAt = isMatching({
@@ -145,7 +145,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
145
145
  return match(node).when(isUseStateCall2, () => "useState").when(isUseEffectLikeCall, () => "useEffect").when(isSetStateCall, () => "setState").when(isThenCall, () => "then").otherwise(() => "other");
146
146
  }
147
147
  function getFunctionKind(node) {
148
- return match(node).when(isSetupFunction, () => "setup").when(isFunctionOfImmediatelyInvoked, () => "immediate").otherwise(() => "other");
148
+ return match(node).when(isSetupFunction, () => "setup").when(AST2.isFunctionOfImmediatelyInvoked, () => "immediate").otherwise(() => "other");
149
149
  }
150
150
  return {
151
151
  ":function"(node) {
@@ -165,7 +165,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
165
165
  match(getCallKind(node)).with("setState", () => {
166
166
  if (!parentFn) return;
167
167
  if (parentFn !== effectFn && parentFnKind !== "immediate") {
168
- const maybeVd = traverseUpGuard(node, isVariableDeclaratorFromHookCall);
168
+ const maybeVd = AST2.traverseUpGuard(node, isVariableDeclaratorFromHookCall);
169
169
  if (O.isSome(maybeVd)) {
170
170
  const vd = maybeVd.value;
171
171
  const calls2 = indirectSetStateCallsInHooks.get(vd.init) ?? [];
@@ -183,8 +183,8 @@ var no_direct_set_state_in_use_effect_default = createRule({
183
183
  });
184
184
  }).with("useEffect", () => {
185
185
  const [firstArg] = node.arguments;
186
- if (isFunction(firstArg)) return;
187
- const identifiers = getNestedIdentifiers(node);
186
+ if (AST2.isFunction(firstArg)) return;
187
+ const identifiers = AST2.getNestedIdentifiers(node);
188
188
  setupFunctionIdentifiers.push(...identifiers);
189
189
  }).with("other", () => {
190
190
  const isInSetupFunction = effectFn === parentFn;
@@ -200,7 +200,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
200
200
  const [firstArg] = node.parent.arguments;
201
201
  if (node !== firstArg) break;
202
202
  if (isUseCallbackCall2(node.parent)) {
203
- const maybeVd = traverseUpGuard(node.parent, isVariableDeclaratorFromHookCall);
203
+ const maybeVd = AST2.traverseUpGuard(node.parent, isVariableDeclaratorFromHookCall);
204
204
  if (O.isNone(maybeVd)) break;
205
205
  const vd = maybeVd.value;
206
206
  const calls = indirectSetStateCallsAsArgs.get(vd.init) ?? [];
@@ -216,7 +216,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
216
216
  const parent = node.parent.parent;
217
217
  if (parent.type !== AST_NODE_TYPES.CallExpression) break;
218
218
  if (!isUseMemoCall2(parent)) break;
219
- const maybeVd = traverseUpGuard(parent, isVariableDeclaratorFromHookCall);
219
+ const maybeVd = AST2.traverseUpGuard(parent, isVariableDeclaratorFromHookCall);
220
220
  if (O.isNone(maybeVd)) break;
221
221
  const vd = maybeVd.value;
222
222
  const calls = indirectSetStateCallsAsArgs.get(vd.init) ?? [];
@@ -226,7 +226,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
226
226
  },
227
227
  "Program:exit"() {
228
228
  const getSetStateCalls = (id, initialScope) => {
229
- const node = O.flatMap(findVariable(id, initialScope), getVariableNode(0)).pipe(O.getOrNull);
229
+ const node = O.flatMap(VAR3.findVariable(id, initialScope), VAR3.getVariableNode(0)).pipe(O.getOrNull);
230
230
  switch (node?.type) {
231
231
  case AST_NODE_TYPES.FunctionDeclaration:
232
232
  case AST_NODE_TYPES.FunctionExpression:
@@ -255,7 +255,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
255
255
  messageId: "noDirectSetStateInUseEffect",
256
256
  node: setStateCall,
257
257
  data: {
258
- name: toReadableNodeName(setStateCall, (n) => context.sourceCode.getText(n))
258
+ name: AST2.toReadableNodeName(setStateCall, (n) => context.sourceCode.getText(n))
259
259
  }
260
260
  });
261
261
  }
@@ -267,7 +267,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
267
267
  messageId: "noDirectSetStateInUseEffect",
268
268
  node: setStateCall,
269
269
  data: {
270
- name: toReadableNodeName(setStateCall, (n) => context.sourceCode.getText(n))
270
+ name: AST2.toReadableNodeName(setStateCall, (n) => context.sourceCode.getText(n))
271
271
  }
272
272
  });
273
273
  }
@@ -297,7 +297,7 @@ var no_redundant_custom_hook_default = createRule({
297
297
  "Program:exit"(node) {
298
298
  const allHooks = ctx.getAllHooks(node);
299
299
  for (const { name: name2, node: node2, hookCalls } of allHooks.values()) {
300
- if (isEmptyFunction(node2)) continue;
300
+ if (AST2.isEmptyFunction(node2)) continue;
301
301
  if (hookCalls.length > 0) continue;
302
302
  context.report({
303
303
  messageId: "noRedundantCustomHook",
@@ -337,7 +337,7 @@ var no_unnecessary_use_callback_default = createRule({
337
337
  }
338
338
  const scope = context.sourceCode.getScope(node);
339
339
  const component = scope.block;
340
- if (!isFunction(component)) return;
340
+ if (!AST2.isFunction(component)) return;
341
341
  const [cb, deps] = node.arguments;
342
342
  if (!deps) {
343
343
  context.report({
@@ -349,9 +349,9 @@ var no_unnecessary_use_callback_default = createRule({
349
349
  const hasEmptyDeps = F.pipe(
350
350
  match(deps).with({ type: AST_NODE_TYPES.ArrayExpression }, O.some).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
351
351
  return F.pipe(
352
- findVariable(n.name, initialScope),
353
- O.flatMap(getVariableNode(0)),
354
- O.filter(is(AST_NODE_TYPES.ArrayExpression))
352
+ VAR3.findVariable(n.name, initialScope),
353
+ O.flatMap(VAR3.getVariableNode(0)),
354
+ O.filter(AST2.is(AST_NODE_TYPES.ArrayExpression))
355
355
  );
356
356
  }).otherwise(O.none),
357
357
  O.exists((x) => x.elements.length === 0)
@@ -372,9 +372,9 @@ var no_unnecessary_use_callback_default = createRule({
372
372
  return O.some(n);
373
373
  }).with({ type: AST_NODE_TYPES.FunctionExpression }, O.some).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
374
374
  return F.pipe(
375
- findVariable(n.name, initialScope),
376
- O.flatMap(getVariableNode(0)),
377
- O.filter(isFunction)
375
+ VAR3.findVariable(n.name, initialScope),
376
+ O.flatMap(VAR3.getVariableNode(0)),
377
+ O.filter(AST2.isFunction)
378
378
  );
379
379
  }).otherwise(O.none),
380
380
  O.map((n) => context.sourceCode.getScope(n)),
@@ -416,7 +416,7 @@ var no_unnecessary_use_memo_default = createRule({
416
416
  }
417
417
  const scope = context.sourceCode.getScope(node);
418
418
  const component = scope.block;
419
- if (!isFunction(component)) return;
419
+ if (!AST2.isFunction(component)) return;
420
420
  const [cb, deps] = node.arguments;
421
421
  if (!deps) {
422
422
  context.report({
@@ -428,9 +428,9 @@ var no_unnecessary_use_memo_default = createRule({
428
428
  const hasEmptyDeps = F.pipe(
429
429
  match(deps).with({ type: AST_NODE_TYPES.ArrayExpression }, O.some).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
430
430
  return F.pipe(
431
- findVariable(n.name, initialScope),
432
- O.flatMap(getVariableNode(0)),
433
- O.filter(is(AST_NODE_TYPES.ArrayExpression))
431
+ VAR3.findVariable(n.name, initialScope),
432
+ O.flatMap(VAR3.getVariableNode(0)),
433
+ O.filter(AST2.is(AST_NODE_TYPES.ArrayExpression))
434
434
  );
435
435
  }).otherwise(O.none),
436
436
  O.exists((x) => x.elements.length === 0)
@@ -451,9 +451,9 @@ var no_unnecessary_use_memo_default = createRule({
451
451
  return O.some(n);
452
452
  }).with({ type: AST_NODE_TYPES.FunctionExpression }, O.some).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
453
453
  return F.pipe(
454
- findVariable(n.name, initialScope),
455
- O.flatMap(getVariableNode(0)),
456
- O.filter(isFunction)
454
+ VAR3.findVariable(n.name, initialScope),
455
+ O.flatMap(VAR3.getVariableNode(0)),
456
+ O.filter(AST2.isFunction)
457
457
  );
458
458
  }).otherwise(O.none),
459
459
  O.map((n) => context.sourceCode.getScope(n)),
@@ -493,7 +493,7 @@ var prefer_use_state_lazy_initialization_default = createRule({
493
493
  if (!isUseStateCall(node, context) && !alias.some(isReactHookCallWithNameLoose(node))) return;
494
494
  const [useStateInput] = node.arguments;
495
495
  if (!useStateInput) return;
496
- const nestedCallExpressions = getNestedCallExpressions(useStateInput);
496
+ const nestedCallExpressions = AST2.getNestedCallExpressions(useStateInput);
497
497
  const hasFunctionCall = nestedCallExpressions.some((n) => {
498
498
  return "name" in n.callee && !ALLOW_LIST.includes(n.callee.name);
499
499
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-hooks-extra",
3
- "version": "1.13.0",
3
+ "version": "1.13.1-beta.2",
4
4
  "description": "ESLint React's ESLint plugin for React Hooks related rules.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -46,13 +46,13 @@
46
46
  "@typescript-eslint/types": "^8.4.0",
47
47
  "@typescript-eslint/utils": "^8.4.0",
48
48
  "ts-pattern": "^5.3.1",
49
- "@eslint-react/ast": "1.13.0",
50
- "@eslint-react/jsx": "1.13.0",
51
- "@eslint-react/core": "1.13.0",
52
- "@eslint-react/shared": "1.13.0",
53
- "@eslint-react/tools": "1.13.0",
54
- "@eslint-react/types": "1.13.0",
55
- "@eslint-react/var": "1.13.0"
49
+ "@eslint-react/ast": "1.13.1-beta.2",
50
+ "@eslint-react/core": "1.13.1-beta.2",
51
+ "@eslint-react/jsx": "1.13.1-beta.2",
52
+ "@eslint-react/shared": "1.13.1-beta.2",
53
+ "@eslint-react/tools": "1.13.1-beta.2",
54
+ "@eslint-react/types": "1.13.1-beta.2",
55
+ "@eslint-react/var": "1.13.1-beta.2"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/react": "^18.3.5",