eslint-plugin-react-hooks-extra 1.19.0 → 1.20.0-beta.12

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
@@ -29,8 +29,8 @@ export default [
29
29
  },
30
30
  rules: {
31
31
  // react-hooks-extra recommended rules
32
- "react-hooks-extra/no-redundant-custom-hook": "warn",
33
32
  "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
33
+ "react-hooks-extra/no-redundant-custom-hook": "warn",
34
34
  "react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
35
35
  },
36
36
  },
@@ -39,10 +39,4 @@ export default [
39
39
 
40
40
  ## Rules
41
41
 
42
- | Rule | Description | 💼 | 💭 | |
43
- | :------------------------------------- | :------------------------------------------------------------------------ | :-: | :-: | :-: |
44
- | `no-direct-set-state-in-use-effect` | Disallow direct calls to the `set` function of `useState` in `useEffect`. | ✔️ | | |
45
- | `no-redundant-custom-hook` | Warns when custom Hooks that don't use other Hooks. | ✔️ | | |
46
- | `no-unnecessary-use-callback` | Disallow unnecessary usage of `useCallback`. | ✔️ | | |
47
- | `no-unnecessary-use-memo` | Disallow unnecessary usage of `useMemo`. | ✔️ | | |
48
- | `prefer-use-state-lazy-initialization` | Warns function calls made inside `useState` calls. | 🚀 | | |
42
+ <https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules>
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var VAR5__namespace = /*#__PURE__*/_interopNamespace(VAR5);
31
31
 
32
32
  // package.json
33
33
  var name = "eslint-plugin-react-hooks-extra";
34
- var version = "1.19.0";
34
+ var version = "1.20.0-beta.12";
35
35
  var createRule = shared.createRuleForPlugin("hooks-extra");
36
36
  function isFromHookCall(name2, context, settings, predicate = tools.F.constTrue) {
37
37
  const hookAlias = settings.additionalHooks?.[name2] ?? [];
@@ -110,11 +110,15 @@ function isVariableDeclaratorFromHookCall(node) {
110
110
 
111
111
  // src/rules/no-direct-set-state-in-use-effect.ts
112
112
  var RULE_NAME = "no-direct-set-state-in-use-effect";
113
+ var RULE_FEATURES = [
114
+ "CHK"
115
+ ];
113
116
  var no_direct_set_state_in_use_effect_default = createRule({
114
117
  meta: {
115
118
  type: "problem",
116
119
  docs: {
117
- description: "disallow direct calls to the 'set' function of 'useState' in 'useEffect'"
120
+ description: "disallow direct calls to the 'set' function of 'useState' in 'useEffect'",
121
+ [Symbol.for("rule_features")]: RULE_FEATURES
118
122
  },
119
123
  messages: {
120
124
  noDirectSetStateInUseEffect: "Do not call the 'set' function '{{name}}' of 'useState' directly in 'useEffect'."
@@ -287,11 +291,15 @@ var no_direct_set_state_in_use_effect_default = createRule({
287
291
  defaultOptions: []
288
292
  });
289
293
  var RULE_NAME2 = "no-direct-set-state-in-use-layout-effect";
294
+ var RULE_FEATURES2 = [
295
+ "CHK"
296
+ ];
290
297
  var no_direct_set_state_in_use_layout_effect_default = createRule({
291
298
  meta: {
292
299
  type: "problem",
293
300
  docs: {
294
- description: "disallow direct calls to the 'set' function of 'useState' in 'useLayoutEffect'"
301
+ description: "disallow direct calls to the 'set' function of 'useState' in 'useLayoutEffect'",
302
+ [Symbol.for("rule_features")]: RULE_FEATURES2
295
303
  },
296
304
  messages: {
297
305
  noDirectSetStateInUseLayoutEffect: "Do not call the 'set' function '{{name}}' of 'useState' directly in 'useLayoutEffect'."
@@ -468,11 +476,15 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
468
476
  defaultOptions: []
469
477
  });
470
478
  var RULE_NAME3 = "no-redundant-custom-hook";
479
+ var RULE_FEATURES3 = [
480
+ "CHK"
481
+ ];
471
482
  var no_redundant_custom_hook_default = createRule({
472
483
  meta: {
473
484
  type: "problem",
474
485
  docs: {
475
- description: "enforce custom hooks to use at least one other hook inside"
486
+ description: "enforce custom hooks to use at least one other hook inside",
487
+ [Symbol.for("rule_features")]: RULE_FEATURES3
476
488
  },
477
489
  messages: {
478
490
  noRedundantCustomHook: "A custom hook '{{name}}' should use at least one other hook."
@@ -503,11 +515,15 @@ var no_redundant_custom_hook_default = createRule({
503
515
  defaultOptions: []
504
516
  });
505
517
  var RULE_NAME4 = "no-unnecessary-use-callback";
518
+ var RULE_FEATURES4 = [
519
+ "CHK"
520
+ ];
506
521
  var no_unnecessary_use_callback_default = createRule({
507
522
  meta: {
508
523
  type: "problem",
509
524
  docs: {
510
- description: "disallow unnecessary usage of 'useCallback'"
525
+ description: "disallow unnecessary usage of 'useCallback'",
526
+ [Symbol.for("rule_features")]: RULE_FEATURES4
511
527
  },
512
528
  messages: {
513
529
  noUnnecessaryUseCallback: "An 'useCallback' with empty deps and no references to the component scope may be unnecessary."
@@ -582,11 +598,15 @@ var no_unnecessary_use_callback_default = createRule({
582
598
  defaultOptions: []
583
599
  });
584
600
  var RULE_NAME5 = "no-unnecessary-use-memo";
601
+ var RULE_FEATURES5 = [
602
+ "CHK"
603
+ ];
585
604
  var no_unnecessary_use_memo_default = createRule({
586
605
  meta: {
587
606
  type: "problem",
588
607
  docs: {
589
- description: "disallow unnecessary usage of 'useMemo'"
608
+ description: "disallow unnecessary usage of 'useMemo'",
609
+ [Symbol.for("rule_features")]: RULE_FEATURES5
590
610
  },
591
611
  messages: {
592
612
  noUnnecessaryUseMemo: "An 'useMemo' with empty deps and no references to the component scope may be unnecessary."
@@ -661,12 +681,16 @@ var no_unnecessary_use_memo_default = createRule({
661
681
  defaultOptions: []
662
682
  });
663
683
  var RULE_NAME6 = "prefer-use-state-lazy-initialization";
684
+ var RULE_FEATURES6 = [
685
+ "CHK"
686
+ ];
664
687
  var ALLOW_LIST = ["Boolean", "String", "Number"];
665
688
  var prefer_use_state_lazy_initialization_default = createRule({
666
689
  meta: {
667
690
  type: "problem",
668
691
  docs: {
669
- description: "disallow function calls in 'useState' that aren't wrapped in an initializer function"
692
+ description: "disallow function calls in 'useState' that aren't wrapped in an initializer function",
693
+ [Symbol.for("rule_features")]: RULE_FEATURES6
670
694
  },
671
695
  messages: {
672
696
  preferUseStateLazyInitialization: "To prevent re-computation, consider using lazy initial state for useState calls that involve function calls. Ex: 'useState(() => getValue())'."
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import { match, isMatching } from 'ts-pattern';
8
8
 
9
9
  // package.json
10
10
  var name = "eslint-plugin-react-hooks-extra";
11
- var version = "1.19.0";
11
+ var version = "1.20.0-beta.12";
12
12
  var createRule = createRuleForPlugin("hooks-extra");
13
13
  function isFromHookCall(name2, context, settings, predicate = F.constTrue) {
14
14
  const hookAlias = settings.additionalHooks?.[name2] ?? [];
@@ -87,11 +87,15 @@ function isVariableDeclaratorFromHookCall(node) {
87
87
 
88
88
  // src/rules/no-direct-set-state-in-use-effect.ts
89
89
  var RULE_NAME = "no-direct-set-state-in-use-effect";
90
+ var RULE_FEATURES = [
91
+ "CHK"
92
+ ];
90
93
  var no_direct_set_state_in_use_effect_default = createRule({
91
94
  meta: {
92
95
  type: "problem",
93
96
  docs: {
94
- description: "disallow direct calls to the 'set' function of 'useState' in 'useEffect'"
97
+ description: "disallow direct calls to the 'set' function of 'useState' in 'useEffect'",
98
+ [Symbol.for("rule_features")]: RULE_FEATURES
95
99
  },
96
100
  messages: {
97
101
  noDirectSetStateInUseEffect: "Do not call the 'set' function '{{name}}' of 'useState' directly in 'useEffect'."
@@ -264,11 +268,15 @@ var no_direct_set_state_in_use_effect_default = createRule({
264
268
  defaultOptions: []
265
269
  });
266
270
  var RULE_NAME2 = "no-direct-set-state-in-use-layout-effect";
271
+ var RULE_FEATURES2 = [
272
+ "CHK"
273
+ ];
267
274
  var no_direct_set_state_in_use_layout_effect_default = createRule({
268
275
  meta: {
269
276
  type: "problem",
270
277
  docs: {
271
- description: "disallow direct calls to the 'set' function of 'useState' in 'useLayoutEffect'"
278
+ description: "disallow direct calls to the 'set' function of 'useState' in 'useLayoutEffect'",
279
+ [Symbol.for("rule_features")]: RULE_FEATURES2
272
280
  },
273
281
  messages: {
274
282
  noDirectSetStateInUseLayoutEffect: "Do not call the 'set' function '{{name}}' of 'useState' directly in 'useLayoutEffect'."
@@ -445,11 +453,15 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
445
453
  defaultOptions: []
446
454
  });
447
455
  var RULE_NAME3 = "no-redundant-custom-hook";
456
+ var RULE_FEATURES3 = [
457
+ "CHK"
458
+ ];
448
459
  var no_redundant_custom_hook_default = createRule({
449
460
  meta: {
450
461
  type: "problem",
451
462
  docs: {
452
- description: "enforce custom hooks to use at least one other hook inside"
463
+ description: "enforce custom hooks to use at least one other hook inside",
464
+ [Symbol.for("rule_features")]: RULE_FEATURES3
453
465
  },
454
466
  messages: {
455
467
  noRedundantCustomHook: "A custom hook '{{name}}' should use at least one other hook."
@@ -480,11 +492,15 @@ var no_redundant_custom_hook_default = createRule({
480
492
  defaultOptions: []
481
493
  });
482
494
  var RULE_NAME4 = "no-unnecessary-use-callback";
495
+ var RULE_FEATURES4 = [
496
+ "CHK"
497
+ ];
483
498
  var no_unnecessary_use_callback_default = createRule({
484
499
  meta: {
485
500
  type: "problem",
486
501
  docs: {
487
- description: "disallow unnecessary usage of 'useCallback'"
502
+ description: "disallow unnecessary usage of 'useCallback'",
503
+ [Symbol.for("rule_features")]: RULE_FEATURES4
488
504
  },
489
505
  messages: {
490
506
  noUnnecessaryUseCallback: "An 'useCallback' with empty deps and no references to the component scope may be unnecessary."
@@ -559,11 +575,15 @@ var no_unnecessary_use_callback_default = createRule({
559
575
  defaultOptions: []
560
576
  });
561
577
  var RULE_NAME5 = "no-unnecessary-use-memo";
578
+ var RULE_FEATURES5 = [
579
+ "CHK"
580
+ ];
562
581
  var no_unnecessary_use_memo_default = createRule({
563
582
  meta: {
564
583
  type: "problem",
565
584
  docs: {
566
- description: "disallow unnecessary usage of 'useMemo'"
585
+ description: "disallow unnecessary usage of 'useMemo'",
586
+ [Symbol.for("rule_features")]: RULE_FEATURES5
567
587
  },
568
588
  messages: {
569
589
  noUnnecessaryUseMemo: "An 'useMemo' with empty deps and no references to the component scope may be unnecessary."
@@ -638,12 +658,16 @@ var no_unnecessary_use_memo_default = createRule({
638
658
  defaultOptions: []
639
659
  });
640
660
  var RULE_NAME6 = "prefer-use-state-lazy-initialization";
661
+ var RULE_FEATURES6 = [
662
+ "CHK"
663
+ ];
641
664
  var ALLOW_LIST = ["Boolean", "String", "Number"];
642
665
  var prefer_use_state_lazy_initialization_default = createRule({
643
666
  meta: {
644
667
  type: "problem",
645
668
  docs: {
646
- description: "disallow function calls in 'useState' that aren't wrapped in an initializer function"
669
+ description: "disallow function calls in 'useState' that aren't wrapped in an initializer function",
670
+ [Symbol.for("rule_features")]: RULE_FEATURES6
647
671
  },
648
672
  messages: {
649
673
  preferUseStateLazyInitialization: "To prevent re-computation, consider using lazy initial state for useState calls that involve function calls. Ex: 'useState(() => getValue())'."
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-hooks-extra",
3
- "version": "1.19.0",
3
+ "version": "1.20.0-beta.12",
4
4
  "description": "ESLint React's ESLint plugin for React Hooks related rules.",
5
5
  "keywords": [
6
+ "react",
7
+ "hooks",
8
+ "hooks-extra",
6
9
  "eslint",
10
+ "eslint-react",
7
11
  "eslint-plugin",
8
- "react",
9
- "hooks"
12
+ "eslint-plugin-react-hooks-extra"
10
13
  ],
11
14
  "homepage": "https://github.com/rel1cx/eslint-react",
12
15
  "bugs": {
@@ -45,20 +48,21 @@
45
48
  "@typescript-eslint/type-utils": "^8.18.0",
46
49
  "@typescript-eslint/types": "^8.18.0",
47
50
  "@typescript-eslint/utils": "^8.18.0",
48
- "ts-pattern": "^5.5.0",
49
- "@eslint-react/ast": "1.19.0",
50
- "@eslint-react/shared": "1.19.0",
51
- "@eslint-react/core": "1.19.0",
52
- "@eslint-react/tools": "1.19.0",
53
- "@eslint-react/types": "1.19.0",
54
- "@eslint-react/jsx": "1.19.0",
55
- "@eslint-react/var": "1.19.0"
51
+ "ts-pattern": "^5.6.0",
52
+ "@eslint-react/ast": "1.20.0-beta.12",
53
+ "@eslint-react/jsx": "1.20.0-beta.12",
54
+ "@eslint-react/shared": "1.20.0-beta.12",
55
+ "@eslint-react/tools": "1.20.0-beta.12",
56
+ "@eslint-react/core": "1.20.0-beta.12",
57
+ "@eslint-react/var": "1.20.0-beta.12",
58
+ "@eslint-react/types": "1.20.0-beta.12"
56
59
  },
57
60
  "devDependencies": {
58
61
  "@types/react": "^19.0.1",
59
62
  "@types/react-dom": "^19.0.2",
60
63
  "string-ts": "^2.2.0",
61
- "tsup": "^8.3.5"
64
+ "tsup": "^8.3.5",
65
+ "@workspace/configs": "0.0.0"
62
66
  },
63
67
  "peerDependencies": {
64
68
  "eslint": "^8.57.0 || ^9.0.0",