eslint-plugin-react-web-api 5.24.0-beta.2 → 5.24.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.
Files changed (2) hide show
  1. package/dist/index.js +415 -89
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ var __exportAll = (all, no_symbols) => {
27
27
  //#endregion
28
28
  //#region package.json
29
29
  var name$1 = "eslint-plugin-react-web-api";
30
- var version = "5.24.0-beta.2";
30
+ var version = "5.24.1";
31
31
 
32
32
  //#endregion
33
33
  //#region src/utils/create-rule.ts
@@ -38,19 +38,6 @@ const createRule = ESLintUtils.RuleCreator(getDocsUrl);
38
38
 
39
39
  //#endregion
40
40
  //#region ../../.pkgs/eff/dist/index.js
41
- function or(a, b) {
42
- return (data) => a(data) || b(data);
43
- }
44
- /**
45
- * A function that checks if the passed parameter is a string and narrows its type accordingly.
46
- *
47
- * @param data - The variable to check.
48
- * @returns True if the passed input is a string, false otherwise.
49
- * @category guards
50
- */
51
- function isString(data) {
52
- return typeof data === "string";
53
- }
54
41
  /**
55
42
  * Applies a `pipe` method's variadic arguments to an initial value from left
56
43
  * to right.
@@ -83,7 +70,7 @@ function isString(data) {
83
70
  * (n) => n + 2,
84
71
  * (n) => n * 3
85
72
  * )
86
- * console.log(result) // 21
73
+ * result // => 21
87
74
  * ```
88
75
  *
89
76
  * @category combinators
@@ -140,16 +127,6 @@ const Class = (function() {
140
127
  return PipeableBase;
141
128
  })();
142
129
  /**
143
- * Provides small helpers for defining and reusing TypeScript functions.
144
- *
145
- * The main helpers are `pipe` and `flow` for left-to-right composition and
146
- * `dual` for APIs that support both direct and pipe-friendly call styles. The
147
- * module also contains small identity, constant, tuple, type-level, and
148
- * memoization helpers used across the library.
149
- *
150
- * @since 2.0.0
151
- */
152
- /**
153
130
  * Creates a function that can be called in data-first style or data-last
154
131
  * (`pipe`-friendly) style.
155
132
  *
@@ -174,8 +151,8 @@ const Class = (function() {
174
151
  * (self: number, that: number) => number
175
152
  * >(2, (self, that) => self + that)
176
153
  *
177
- * console.log(sum(2, 3)) // 5
178
- * console.log(pipe(2, sum(3))) // 5
154
+ * sum(2, 3) // => 5
155
+ * pipe(2, sum(3)) // => 5
179
156
  * ```
180
157
  *
181
158
  * **Example** (Defining overloads with call signatures)
@@ -188,8 +165,8 @@ const Class = (function() {
188
165
  * (self: number, that: number): number
189
166
  * } = Function.dual(2, (self: number, that: number): number => self + that)
190
167
  *
191
- * console.log(sum(2, 3)) // 5
192
- * console.log(pipe(2, sum(3))) // 5
168
+ * sum(2, 3) // => 5
169
+ * pipe(2, sum(3)) // => 5
193
170
  * ```
194
171
  *
195
172
  * **Example** (Selecting data-first or data-last style with a predicate)
@@ -205,8 +182,8 @@ const Class = (function() {
205
182
  * (self, that) => self + that
206
183
  * )
207
184
  *
208
- * console.log(sum(2, 3)) // 5
209
- * console.log(pipe(2, sum(3))) // 5
185
+ * sum(2, 3) // => 5
186
+ * pipe(2, sum(3)) // => 5
210
187
  * ```
211
188
  *
212
189
  * @category combinators
@@ -251,9 +228,8 @@ const dual = function(arity, body) {
251
228
  *
252
229
  * ```ts
253
230
  * import { identity } from "effect"
254
- * import * as assert from "node:assert"
255
231
  *
256
- * assert.deepStrictEqual(identity(5), 5)
232
+ * identity(5) // => 5
257
233
  * ```
258
234
  *
259
235
  * @category combinators
@@ -291,12 +267,11 @@ const cast = identity;
291
267
  *
292
268
  * ```ts
293
269
  * import { Function } from "effect"
294
- * import * as assert from "node:assert"
295
270
  *
296
271
  * const constNull = Function.constant(null)
297
272
  *
298
- * assert.deepStrictEqual(constNull(), null)
299
- * assert.deepStrictEqual(constNull(), null)
273
+ * constNull() // => null
274
+ * constNull() // => null
300
275
  * ```
301
276
  *
302
277
  * @category constructors
@@ -314,9 +289,8 @@ const constant = (value) => () => value;
314
289
  *
315
290
  * ```ts
316
291
  * import { Function } from "effect"
317
- * import * as assert from "node:assert"
318
292
  *
319
- * assert.deepStrictEqual(Function.constTrue(), true)
293
+ * Function.constTrue() // => true
320
294
  * ```
321
295
  *
322
296
  * @category constants
@@ -334,9 +308,8 @@ const constTrue = constant(true);
334
308
  *
335
309
  * ```ts
336
310
  * import { Function } from "effect"
337
- * import * as assert from "node:assert"
338
311
  *
339
- * assert.deepStrictEqual(Function.constFalse(), false)
312
+ * Function.constFalse() // => false
340
313
  * ```
341
314
  *
342
315
  * @category constants
@@ -354,9 +327,8 @@ const constFalse = constant(false);
354
327
  *
355
328
  * ```ts
356
329
  * import { Function } from "effect"
357
- * import * as assert from "node:assert"
358
330
  *
359
- * assert.deepStrictEqual(Function.constNull(), null)
331
+ * Function.constNull() // => null
360
332
  * ```
361
333
  *
362
334
  * @category constants
@@ -374,9 +346,8 @@ const constNull = constant(null);
374
346
  *
375
347
  * ```ts
376
348
  * import { Function } from "effect"
377
- * import * as assert from "node:assert"
378
349
  *
379
- * assert.deepStrictEqual(Function.constUndefined(), undefined)
350
+ * Function.constUndefined() // => undefined
380
351
  * ```
381
352
  *
382
353
  * @category constants
@@ -395,12 +366,11 @@ const constUndefined = constant(void 0);
395
366
  *
396
367
  * ```ts
397
368
  * import { Function } from "effect"
398
- * import * as assert from "node:assert"
399
369
  *
400
370
  * const increment = (n: number) => n + 1
401
371
  * const square = (n: number) => n * n
402
372
  *
403
- * assert.strictEqual(Function.compose(increment, square)(2), 9)
373
+ * Function.compose(increment, square)(2) // => 9
404
374
  * ```
405
375
  *
406
376
  * @see {@link flow} for composing a left-to-right sequence of functions
@@ -463,13 +433,347 @@ const absurd = (_) => {
463
433
  * name: hole<string>()
464
434
  * })
465
435
  *
466
- * console.log(typeof buildUser) // "function"
467
436
  * ```
468
437
  *
469
438
  * @category utility types
470
439
  * @since 2.0.0
471
440
  */
472
441
  const hole = cast(absurd);
442
+ /**
443
+ * Creates a predicate that returns `true` only if both predicates are `true`.
444
+ *
445
+ * **When to use**
446
+ *
447
+ * Use when you want to combine `Predicate`s with AND, accepting values that
448
+ * satisfy multiple conditions, including refinements that narrow to an
449
+ * intersection.
450
+ *
451
+ * **Details**
452
+ *
453
+ * Evaluation short-circuits on the first `false`. For refinements, the output
454
+ * type is an intersection.
455
+ *
456
+ * **Example** (Checking both conditions)
457
+ *
458
+ * ```ts
459
+ * import { Predicate } from "effect"
460
+ *
461
+ * const hasAAndB = Predicate.and(
462
+ * Predicate.hasProperty("a"),
463
+ * Predicate.hasProperty("b")
464
+ * )
465
+ *
466
+ * const input: unknown = JSON.parse(`{"a":1,"b":"ok"}`)
467
+ * if (hasAAndB(input)) {
468
+ * // input has both properties at this point
469
+ * const a = input.a
470
+ * const b = input.b
471
+ *
472
+ * const values = [a, b] // => [1, "ok"]
473
+ * }
474
+ * ```
475
+ *
476
+ * @see {@link or}
477
+ * @see {@link not}
478
+ * @category combinators
479
+ * @since 2.0.0
480
+ */
481
+ const and = dual(2, (a, b) => (data) => a(data) && b(data));
482
+ /**
483
+ * Creates a predicate that returns `true` if either predicate is `true`.
484
+ *
485
+ * **When to use**
486
+ *
487
+ * Use when you want to combine `Predicate`s with OR, accepting values that
488
+ * satisfy at least one condition, including refinements that narrow to a union.
489
+ *
490
+ * **Details**
491
+ *
492
+ * Evaluation short-circuits on the first `true`. For refinements, the output
493
+ * type is a union.
494
+ *
495
+ * **Example** (Checking either condition)
496
+ *
497
+ * ```ts
498
+ * import { Predicate } from "effect"
499
+ *
500
+ * const isStringOrNumber = Predicate.or(Predicate.isString, Predicate.isNumber)
501
+ *
502
+ * isStringOrNumber("a") // => true
503
+ * ```
504
+ *
505
+ * @see {@link and}
506
+ * @see {@link xor}
507
+ * @category combinators
508
+ * @since 2.0.0
509
+ */
510
+ const or = dual(2, (a, b) => (data) => a(data) || b(data));
511
+ /**
512
+ * Creates a predicate that returns `true` if exactly one predicate is `true`.
513
+ *
514
+ * **When to use**
515
+ *
516
+ * Use when you want to combine two `Predicate`s with exclusive-or semantics.
517
+ *
518
+ * **Details**
519
+ *
520
+ * Returns `true` when results differ.
521
+ *
522
+ * **Example** (Checking exclusive-or conditions)
523
+ *
524
+ * ```ts
525
+ * import { Predicate } from "effect"
526
+ *
527
+ * const isEven = (n: number) => n % 2 === 0
528
+ * const isPositive = (n: number) => n > 0
529
+ * const either = Predicate.xor(isEven, isPositive)
530
+ *
531
+ * either(-2) // => true
532
+ * ```
533
+ *
534
+ * @see {@link or}
535
+ * @see {@link and}
536
+ * @category combinators
537
+ * @since 2.0.0
538
+ */
539
+ const xor = dual(2, (a, b) => (data) => a(data) !== b(data));
540
+ /**
541
+ * Creates a predicate that returns `true` when both predicates agree.
542
+ *
543
+ * **When to use**
544
+ *
545
+ * Use when you want to check equivalence of two `Predicate`s.
546
+ *
547
+ * **Details**
548
+ *
549
+ * Returns `true` when both results are equal.
550
+ *
551
+ * **Example** (Defining equivalence)
552
+ *
553
+ * ```ts
554
+ * import { Predicate } from "effect"
555
+ *
556
+ * const isEven = (n: number) => n % 2 === 0
557
+ * const same = Predicate.eqv(isEven, isEven)
558
+ *
559
+ * same(3) // => true
560
+ * ```
561
+ *
562
+ * @see {@link xor}
563
+ * @category combinators
564
+ * @since 2.0.0
565
+ */
566
+ const eqv = dual(2, (a, b) => (data) => a(data) === b(data));
567
+ /**
568
+ * Creates a predicate representing logical implication: if `antecedent`, then `consequent`.
569
+ *
570
+ * **When to use**
571
+ *
572
+ * Use when you need to encode logical implication between `Predicate` rules,
573
+ * where one rule only applies when a precondition holds.
574
+ *
575
+ * **Details**
576
+ *
577
+ * Models constraints like "if A then B" and returns `true` when the antecedent
578
+ * is `false`.
579
+ *
580
+ * **Example** (Checking implication)
581
+ *
582
+ * ```ts
583
+ * import { Predicate } from "effect"
584
+ *
585
+ * const isAdult = (age: number) => age >= 18
586
+ * const canVote = (age: number) => age >= 18
587
+ * const implies = Predicate.implies(isAdult, canVote)
588
+ *
589
+ * implies(16) // => true
590
+ * ```
591
+ *
592
+ * @see {@link and}
593
+ * @see {@link or}
594
+ * @category combinators
595
+ * @since 2.0.0
596
+ */
597
+ const implies = dual(2, (antecedent, consequent) => (data) => !antecedent(data) || consequent(data));
598
+ /**
599
+ * Creates a predicate that returns `true` when neither predicate is `true`.
600
+ *
601
+ * **When to use**
602
+ *
603
+ * Use when you want to combine two `Predicate`s with logical NOR semantics.
604
+ *
605
+ * **Details**
606
+ *
607
+ * Returns the negation of `or`.
608
+ *
609
+ * **Example** (Checking NOR conditions)
610
+ *
611
+ * ```ts
612
+ * import { Predicate } from "effect"
613
+ *
614
+ * const neither = Predicate.nor(Predicate.isString, Predicate.isNumber)
615
+ *
616
+ * neither(true) // => true
617
+ * ```
618
+ *
619
+ * @see {@link or}
620
+ * @see {@link not}
621
+ * @category combinators
622
+ * @since 2.0.0
623
+ */
624
+ const nor = dual(2, (a, b) => (data) => !a(data) && !b(data));
625
+ /**
626
+ * Creates a predicate that returns `true` unless both predicates are `true`.
627
+ *
628
+ * **When to use**
629
+ *
630
+ * Use when you want to combine two `Predicate`s with logical NAND semantics.
631
+ *
632
+ * **Details**
633
+ *
634
+ * Returns the negation of `and`.
635
+ *
636
+ * **Example** (Checking NAND conditions)
637
+ *
638
+ * ```ts
639
+ * import { Predicate } from "effect"
640
+ *
641
+ * const notBoth = Predicate.nand(Predicate.isString, Predicate.isNumber)
642
+ *
643
+ * notBoth("a") // => true
644
+ * ```
645
+ *
646
+ * @see {@link and}
647
+ * @see {@link not}
648
+ * @category combinators
649
+ * @since 2.0.0
650
+ */
651
+ const nand = dual(2, (a, b) => (data) => !a(data) || !b(data));
652
+ /**
653
+ * Checks whether a value is a `string`.
654
+ *
655
+ * **When to use**
656
+ *
657
+ * Use when you need a `Predicate` guard to narrow an `unknown` value to a
658
+ * string.
659
+ *
660
+ * **Details**
661
+ *
662
+ * Uses `typeof input === "string"`.
663
+ *
664
+ * **Example** (Guarding strings)
665
+ *
666
+ * ```ts
667
+ * import { Predicate } from "effect"
668
+ *
669
+ * const data: unknown = "hi"
670
+ *
671
+ * if (Predicate.isString(data)) {
672
+ * data.toUpperCase() // => "HI"
673
+ * }
674
+ * ```
675
+ *
676
+ * @see {@link isNumber}
677
+ * @see {@link isBoolean}
678
+ * @see {@link Refinement}
679
+ * @category guards
680
+ * @since 2.0.0
681
+ */
682
+ function isString(input) {
683
+ return typeof input === "string";
684
+ }
685
+ /**
686
+ * Checks whether a value is a `function`.
687
+ *
688
+ * **When to use**
689
+ *
690
+ * Use when you need a `Predicate` guard to narrow an `unknown` value to a
691
+ * callable function.
692
+ *
693
+ * **Details**
694
+ *
695
+ * Uses `typeof input === "function"`.
696
+ *
697
+ * **Example** (Guarding functions)
698
+ *
699
+ * ```ts
700
+ * import { Predicate } from "effect"
701
+ *
702
+ * const data: unknown = () => 1
703
+ *
704
+ * if (Predicate.isFunction(data)) {
705
+ * data() // => 1
706
+ * }
707
+ * ```
708
+ *
709
+ * @see {@link isObjectKeyword}
710
+ * @category guards
711
+ * @since 2.0.0
712
+ */
713
+ function isFunction(input) {
714
+ return typeof input === "function";
715
+ }
716
+ /**
717
+ * Checks whether a value is an `object` in the JavaScript sense (objects, arrays, functions).
718
+ *
719
+ * **When to use**
720
+ *
721
+ * Use when you need a `Predicate` guard that accepts arrays and functions as
722
+ * well as objects.
723
+ *
724
+ * **Details**
725
+ *
726
+ * Returns `true` for arrays and functions, and `false` for `null`.
727
+ *
728
+ * **Example** (Checking object keywords)
729
+ *
730
+ * ```ts
731
+ * import { Predicate } from "effect"
732
+ *
733
+ * Predicate.isObjectKeyword(() => 1) // => true
734
+ * Predicate.isObjectKeyword(null) // => false
735
+ * ```
736
+ *
737
+ * @see {@link isObject}
738
+ * @see {@link isObjectOrArray}
739
+ * @category guards
740
+ * @since 4.0.0
741
+ */
742
+ function isObjectKeyword(input) {
743
+ return typeof input === "object" && input !== null || isFunction(input);
744
+ }
745
+ /**
746
+ * Checks whether a value has a given property key.
747
+ *
748
+ * **When to use**
749
+ *
750
+ * Use when you need a `Predicate` guard for property access on `unknown`
751
+ * values with a simple structural object check.
752
+ *
753
+ * **Details**
754
+ *
755
+ * Uses the `in` operator and `isObjectKeyword`. This does not check property
756
+ * value types.
757
+ *
758
+ * **Example** (Guarding object properties)
759
+ *
760
+ * ```ts
761
+ * import { Predicate } from "effect"
762
+ *
763
+ * const hasName = Predicate.hasProperty("name")
764
+ * const data: unknown = { name: "Ada" }
765
+ *
766
+ * if (hasName(data)) {
767
+ * data.name // => "Ada"
768
+ * }
769
+ * ```
770
+ *
771
+ * @see {@link isTagged}
772
+ * @see {@link isObjectKeyword}
773
+ * @category guards
774
+ * @since 2.0.0
775
+ */
776
+ const hasProperty = dual(2, (data, property) => isObjectKeyword(data) && property in data);
473
777
  function getOrInsertComputed(map, key, callback) {
474
778
  if (map.has(key)) return map.get(key);
475
779
  const value = callback(key);
@@ -477,56 +781,72 @@ function getOrInsertComputed(map, key, callback) {
477
781
  return value;
478
782
  }
479
783
  /**
480
- * Drops the longest prefix of elements from an array that satisfy the given predicate.
784
+ * Drops elements from the start while the predicate holds, returning the rest.
785
+ *
786
+ * **When to use**
481
787
  *
482
- * Supports both data-first and data-last (`pipe`-friendly) call styles.
788
+ * Use to remove a leading prefix of elements that satisfy a predicate.
483
789
  *
484
- * @param pred - The predicate to test each element with.
485
- * @returns A new array without the matching prefix.
486
- * @example
487
- * ```ts
488
- * import * as assert from "node:assert"
489
- * import { dropWhile, pipe } from "@local/eff"
790
+ * **Details**
791
+ *
792
+ * The predicate receives `(element, index)`.
793
+ *
794
+ * **Example** (Dropping while condition holds)
490
795
  *
491
- * // data-first
492
- * assert.deepStrictEqual(dropWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [3, 2, 1])
796
+ * ```ts
797
+ * import { Array } from "effect"
493
798
  *
494
- * // data-last
495
- * assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], dropWhile((n: number) => n < 3)), [3, 2, 1])
799
+ * Array.dropWhile([1, 2, 3, 4, 5], (x) => x < 4) // => [4, 5]
496
800
  * ```
497
- * @category array
801
+ *
802
+ * @see {@link takeWhile} — keep the matching prefix instead
803
+ * @see {@link drop} — drop a fixed count
804
+ *
805
+ * @category getters
806
+ * @since 2.0.0
498
807
  */
499
- const dropWhile = dual(2, (xs, pred) => {
500
- const len = xs.length;
808
+ const dropWhile = dual(2, (self, predicate) => {
809
+ const input = Array.isArray(self) ? self : Array.from(self);
810
+ const len = input.length;
501
811
  let idx = 0;
502
- while (idx < len && pred(xs[idx])) idx++;
503
- return xs.slice(idx);
812
+ while (idx < len && predicate(input[idx], idx)) idx++;
813
+ return input.slice(idx);
504
814
  });
505
815
  /**
506
- * Takes the longest prefix of elements from an array that satisfy the given predicate.
816
+ * Takes elements from the start while the predicate holds, stopping at the
817
+ * first element that fails.
507
818
  *
508
- * Supports both data-first and data-last (`pipe`-friendly) call styles.
819
+ * **When to use**
509
820
  *
510
- * @param pred - The predicate to test each element with.
511
- * @returns A new array containing only the matching prefix.
512
- * @example
513
- * ```ts
514
- * import * as assert from "node:assert"
515
- * import { pipe, takeWhile } from "@local/eff"
821
+ * Use to keep the leading elements of an iterable while each element satisfies
822
+ * a predicate, returning the retained prefix as an array.
823
+ *
824
+ * **Details**
825
+ *
826
+ * Supports refinements for type narrowing. The predicate receives
827
+ * `(element, index)`.
516
828
  *
517
- * // data-first
518
- * assert.deepStrictEqual(takeWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [1, 2])
829
+ * **Example** (Taking while condition holds)
830
+ *
831
+ * ```ts
832
+ * import { Array } from "effect"
519
833
  *
520
- * // data-last
521
- * assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], takeWhile((n: number) => n < 3)), [1, 2])
834
+ * Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4) // => [1, 3, 2]
522
835
  * ```
523
- * @category array
836
+ *
837
+ * @see {@link take} for keeping a fixed number of leading elements
838
+ * @see {@link dropWhile} for removing the matching prefix and keeping the rest
839
+ * @see {@link span} for splitting the matching prefix from the remaining elements
840
+ *
841
+ * @category getters
842
+ * @since 2.0.0
524
843
  */
525
- const takeWhile = dual(2, (xs, pred) => {
526
- const len = xs.length;
844
+ const takeWhile = dual(2, (self, predicate) => {
845
+ const input = Array.isArray(self) ? self : Array.from(self);
846
+ const len = input.length;
527
847
  let idx = 0;
528
- while (idx < len && pred(xs[idx])) idx++;
529
- return xs.slice(0, idx);
848
+ while (idx < len && predicate(input[idx], idx)) idx++;
849
+ return input.slice(0, idx);
530
850
  });
531
851
 
532
852
  //#endregion
@@ -584,6 +904,7 @@ function getOptions(context, node) {
584
904
  //#endregion
585
905
  //#region src/rules/no-leaked-event-listener/no-leaked-event-listener.ts
586
906
  const RULE_NAME$5 = "no-leaked-event-listener";
907
+ const isUseEffectCallback$5 = or(isUseEffectSetupCallback, isUseEffectCleanupCallback);
587
908
  function getCallKind$5(node) {
588
909
  const name = Extract.getCalleeName(node);
589
910
  if (name != null && isMatching(P.union("addEventListener", "removeEventListener"))(name)) return name;
@@ -691,7 +1012,7 @@ function create$5(context) {
691
1012
  }
692
1013
  return {
693
1014
  ["CallExpression"](node) {
694
- const fn = Traverse.findParent(node, (n) => isUseEffectSetupCallback(n) || isUseEffectCleanupCallback(n));
1015
+ const fn = Traverse.findParent(node, isUseEffectCallback$5);
695
1016
  if (fn == null) return;
696
1017
  const fKind = isUseEffectSetupCallback(fn) ? "setup" : "cleanup";
697
1018
  const setupFn = fKind === "setup" ? fn : Traverse.findParent(fn, Check.isFunction);
@@ -773,6 +1094,7 @@ function resolveToObjectExpression(context, node) {
773
1094
  //#endregion
774
1095
  //#region src/rules/no-leaked-fetch/no-leaked-fetch.ts
775
1096
  const RULE_NAME$4 = "no-leaked-fetch";
1097
+ const isUseEffectCallback$4 = or(isUseEffectSetupCallback, isUseEffectCleanupCallback);
776
1098
  function getCallKind$4(node) {
777
1099
  const name = Extract.getCalleeName(node);
778
1100
  if (name != null && isMatching(P.union("fetch", "abort"))(name)) return name;
@@ -861,7 +1183,7 @@ function create$4(context) {
861
1183
  node
862
1184
  });
863
1185
  }).with("abort", () => {
864
- const fn = Traverse.findParent(node, (n) => isUseEffectSetupCallback(n) || isUseEffectCleanupCallback(n));
1186
+ const fn = Traverse.findParent(node, isUseEffectCallback$4);
865
1187
  if (fn == null || !isUseEffectCleanupCallback(fn)) return;
866
1188
  const controller = getAbortController(node);
867
1189
  if (controller == null) return;
@@ -912,6 +1234,7 @@ function isFromObserver$1(context, node, name) {
912
1234
  //#endregion
913
1235
  //#region src/rules/no-leaked-intersection-observer/no-leaked-intersection-observer.ts
914
1236
  const RULE_NAME$3 = "no-leaked-intersection-observer";
1237
+ const isUseEffectCallback$3 = or(isUseEffectSetupCallback, isUseEffectCleanupCallback);
915
1238
  function getCallKind$3(context, node) {
916
1239
  const callee = Extract.unwrap(node.callee);
917
1240
  if (callee.type !== AST_NODE_TYPES.MemberExpression) return "other";
@@ -942,7 +1265,7 @@ function create$3(context) {
942
1265
  const dEntries = [];
943
1266
  return {
944
1267
  ["CallExpression"](node) {
945
- if (Traverse.findParent(node, (n) => isUseEffectSetupCallback(n) || isUseEffectCleanupCallback(n)) == null) return;
1268
+ if (Traverse.findParent(node, isUseEffectCallback$3) == null) return;
946
1269
  const callee = Extract.unwrap(node.callee);
947
1270
  if (callee.type !== AST_NODE_TYPES.MemberExpression) return;
948
1271
  const { object } = callee;
@@ -973,7 +1296,7 @@ function create$3(context) {
973
1296
  }).otherwise(() => null);
974
1297
  },
975
1298
  ["NewExpression"](node) {
976
- const fn = Traverse.findParent(node, (n) => Check.isFunction(n) && (isUseEffectSetupCallback(n) || isUseEffectCleanupCallback(n)));
1299
+ const fn = Traverse.findParent(node, and(Check.isFunction, isUseEffectCallback$3));
977
1300
  if (fn == null) return;
978
1301
  if (!isNewObserver$1(node, "IntersectionObserver")) return;
979
1302
  const id = resolveEnclosingAssignmentTarget(node);
@@ -1020,6 +1343,7 @@ function create$3(context) {
1020
1343
  //#endregion
1021
1344
  //#region src/rules/no-leaked-interval/no-leaked-interval.ts
1022
1345
  const RULE_NAME$2 = "no-leaked-interval";
1346
+ const isUseEffectCallback$2 = or(isUseEffectSetupCallback, isUseEffectCleanupCallback);
1023
1347
  function getCallKind$2(node) {
1024
1348
  const name = Extract.getCalleeName(node);
1025
1349
  if (name != null && isMatching(P.union("setInterval", "clearInterval"))(name)) return name;
@@ -1048,7 +1372,7 @@ function create$2(context) {
1048
1372
  }
1049
1373
  return {
1050
1374
  ["CallExpression"](node) {
1051
- if (Traverse.findParent(node, (n) => isUseEffectSetupCallback(n) || isUseEffectCleanupCallback(n)) == null) return;
1375
+ if (Traverse.findParent(node, isUseEffectCallback$2) == null) return;
1052
1376
  match(getCallKind$2(node)).with("setInterval", () => {
1053
1377
  const intervalIdNode = resolveEnclosingAssignmentTarget(node);
1054
1378
  if (intervalIdNode == null) {
@@ -1105,6 +1429,7 @@ function isFromObserver(context, node, name) {
1105
1429
  //#endregion
1106
1430
  //#region src/rules/no-leaked-resize-observer/no-leaked-resize-observer.ts
1107
1431
  const RULE_NAME$1 = "no-leaked-resize-observer";
1432
+ const isUseEffectCallback$1 = or(isUseEffectSetupCallback, isUseEffectCleanupCallback);
1108
1433
  function getCallKind$1(context, node) {
1109
1434
  const callee = Extract.unwrap(node.callee);
1110
1435
  if (callee.type !== AST_NODE_TYPES.MemberExpression) return "other";
@@ -1135,7 +1460,7 @@ function create$1(context) {
1135
1460
  const dEntries = [];
1136
1461
  return {
1137
1462
  ["CallExpression"](node) {
1138
- if (Traverse.findParent(node, (n) => isUseEffectSetupCallback(n) || isUseEffectCleanupCallback(n)) == null) return;
1463
+ if (Traverse.findParent(node, isUseEffectCallback$1) == null) return;
1139
1464
  const callee = Extract.unwrap(node.callee);
1140
1465
  if (callee.type !== AST_NODE_TYPES.MemberExpression) return;
1141
1466
  const { object } = callee;
@@ -1166,7 +1491,7 @@ function create$1(context) {
1166
1491
  }).otherwise(() => null);
1167
1492
  },
1168
1493
  ["NewExpression"](node) {
1169
- const fn = Traverse.findParent(node, (n) => Check.isFunction(n) && (isUseEffectSetupCallback(n) || isUseEffectCleanupCallback(n)));
1494
+ const fn = Traverse.findParent(node, and(Check.isFunction, isUseEffectCallback$1));
1170
1495
  if (fn == null) return;
1171
1496
  if (!isNewObserver(node, "ResizeObserver")) return;
1172
1497
  const id = resolveEnclosingAssignmentTarget(node);
@@ -1213,6 +1538,7 @@ function create$1(context) {
1213
1538
  //#endregion
1214
1539
  //#region src/rules/no-leaked-timeout/no-leaked-timeout.ts
1215
1540
  const RULE_NAME = "no-leaked-timeout";
1541
+ const isUseEffectCallback = or(isUseEffectSetupCallback, isUseEffectCleanupCallback);
1216
1542
  function getCallKind(node) {
1217
1543
  const name = Extract.getCalleeName(node);
1218
1544
  if (name != null && isMatching(P.union("setTimeout", "clearTimeout"))(name)) return name;
@@ -1241,7 +1567,7 @@ function create(context) {
1241
1567
  }
1242
1568
  return {
1243
1569
  ["CallExpression"](node) {
1244
- if (Traverse.findParent(node, (n) => isUseEffectSetupCallback(n) || isUseEffectCleanupCallback(n)) == null) return;
1570
+ if (Traverse.findParent(node, isUseEffectCallback) == null) return;
1245
1571
  match(getCallKind(node)).with("setTimeout", () => {
1246
1572
  const timeoutIdNode = resolveEnclosingAssignmentTarget(node);
1247
1573
  if (timeoutIdNode == null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-web-api",
3
- "version": "5.24.0-beta.2",
3
+ "version": "5.24.1",
4
4
  "description": "ESLint React's ESLint plugin for interacting with Web APIs",
5
5
  "keywords": [
6
6
  "react",
@@ -37,11 +37,11 @@
37
37
  "dist"
38
38
  ],
39
39
  "dependencies": {
40
- "@eslint-react/ast": "5.24.0-beta.2",
41
- "@eslint-react/core": "5.24.0-beta.2",
42
- "@eslint-react/eslint": "5.24.0-beta.2",
43
- "@eslint-react/shared": "5.24.0-beta.2",
44
- "@eslint-react/var": "5.24.0-beta.2",
40
+ "@eslint-react/ast": "5.24.1",
41
+ "@eslint-react/core": "5.24.1",
42
+ "@eslint-react/eslint": "5.24.1",
43
+ "@eslint-react/shared": "5.24.1",
44
+ "@eslint-react/var": "5.24.1",
45
45
  "@typescript-eslint/types": "^8.71.0",
46
46
  "@typescript-eslint/utils": "^8.71.0",
47
47
  "ts-pattern": "^5.9.0"
@@ -53,7 +53,7 @@
53
53
  "@types/react": "^19.3.0",
54
54
  "@types/react-dom": "^19.3.0",
55
55
  "dedent": "^1.7.2",
56
- "eslint": "^10.11.0",
56
+ "eslint": "^10.12.0",
57
57
  "tsdown": "^0.23.0",
58
58
  "typescript": "6.0.3"
59
59
  },