eslint-plugin-react-web-api 5.16.1 → 5.17.0

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 +338 -34
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ var __exportAll = (all, no_symbols) => {
28
28
  //#endregion
29
29
  //#region package.json
30
30
  var name$1 = "eslint-plugin-react-web-api";
31
- var version = "5.16.1";
31
+ var version = "5.17.0";
32
32
 
33
33
  //#endregion
34
34
  //#region src/types/component-phase.ts
@@ -402,28 +402,124 @@ function or(a, b) {
402
402
  return (data) => a(data) || b(data);
403
403
  }
404
404
  /**
405
- * Creates a function that can be used in a data-last (aka `pipe`able) or
406
- * data-first style.
405
+ * Applies a `pipe` method's variadic arguments to an initial value from left
406
+ * to right.
407
407
  *
408
- * The first parameter to `dual` is either the arity of the uncurried function
409
- * or a predicate that determines if the function is being used in a data-first
410
- * or data-last style.
408
+ * **When to use**
411
409
  *
412
- * Using the arity is the most common use case, but there are some cases where
413
- * you may want to use a predicate. For example, if you have a function that
414
- * takes an optional argument, you can use a predicate to determine if the
415
- * function is being used in a data-first or data-last style.
410
+ * Use to implement a custom `.pipe(...)` method from JavaScript's `arguments`
411
+ * object.
416
412
  *
417
- * You can pass either the arity of the uncurried function or a predicate
418
- * which determines if the function is being used in a data-first or
419
- * data-last style.
413
+ * **Details**
420
414
  *
421
- * **Example** (Using arity to determine data-first or data-last style)
415
+ * This helper is intended for implementing `Pipeable.pipe` methods that
416
+ * receive JavaScript's `arguments` object. With no functions it returns the
417
+ * original value; otherwise it feeds each result into the next function.
418
+ *
419
+ * **Example** (Implementing a pipe method)
422
420
  *
423
421
  * ```ts
424
- * import { dual, pipe } from "effect/Function"
422
+ * import { Pipeable } from "effect"
423
+ *
424
+ * class NumberBox {
425
+ * constructor(readonly value: number) {}
426
+ *
427
+ * pipe(..._fns: ReadonlyArray<(value: number) => number>): number {
428
+ * return Pipeable.pipeArguments(this.value, arguments) as number
429
+ * }
430
+ * }
431
+ *
432
+ * const result = new NumberBox(5).pipe(
433
+ * (n) => n + 2,
434
+ * (n) => n * 3
435
+ * )
436
+ * console.log(result) // 21
437
+ * ```
438
+ *
439
+ * @category combinators
440
+ * @since 2.0.0
441
+ */
442
+ const pipeArguments = (self, args) => {
443
+ switch (args.length) {
444
+ case 0: return self;
445
+ case 1: return args[0](self);
446
+ case 2: return args[1](args[0](self));
447
+ case 3: return args[2](args[1](args[0](self)));
448
+ case 4: return args[3](args[2](args[1](args[0](self))));
449
+ case 5: return args[4](args[3](args[2](args[1](args[0](self)))));
450
+ case 6: return args[5](args[4](args[3](args[2](args[1](args[0](self))))));
451
+ case 7: return args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))));
452
+ case 8: return args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self))))))));
453
+ case 9: return args[8](args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))))));
454
+ default: {
455
+ let ret = self;
456
+ for (let i = 0, len = args.length; i < len; i++) ret = args[i](ret);
457
+ return ret;
458
+ }
459
+ }
460
+ };
461
+ /**
462
+ * Reusable prototype that implements `Pipeable.pipe`.
463
+ *
464
+ * **When to use**
465
+ *
466
+ * Use when classes or object prototypes can reuse this value when they need the
467
+ * standard pipe implementation backed by `pipeArguments`.
468
+ *
469
+ * @category prototypes
470
+ * @since 3.15.0
471
+ */
472
+ const Prototype = { pipe() {
473
+ return pipeArguments(this, arguments);
474
+ } };
475
+ /**
476
+ * Provides a base constructor whose instances implement the standard `Pipeable.pipe`
477
+ * method.
478
+ *
479
+ * **When to use**
425
480
  *
426
- * const sum = dual<
481
+ * Use when you need to define a class that supports Effect-style method
482
+ * chaining through `.pipe(...)`.
483
+ *
484
+ * @category constructors
485
+ * @since 3.15.0
486
+ */
487
+ const Class = (function() {
488
+ function PipeableBase() {}
489
+ PipeableBase.prototype = Prototype;
490
+ return PipeableBase;
491
+ })();
492
+ /**
493
+ * Provides small helpers for defining and reusing TypeScript functions.
494
+ *
495
+ * The main helpers are `pipe` and `flow` for left-to-right composition and
496
+ * `dual` for APIs that support both direct and pipe-friendly call styles. The
497
+ * module also contains small identity, constant, tuple, type-level, and
498
+ * memoization helpers used across the library.
499
+ *
500
+ * @since 2.0.0
501
+ */
502
+ /**
503
+ * Creates a function that can be called in data-first style or data-last
504
+ * (`pipe`-friendly) style.
505
+ *
506
+ * **When to use**
507
+ *
508
+ * Use to expose one implementation through both direct and `pipe`-friendly
509
+ * call styles.
510
+ *
511
+ * **Details**
512
+ *
513
+ * Pass either the arity of the uncurried function or a predicate that decides
514
+ * whether the current call is data-first. Arity is the common case. Use a
515
+ * predicate when optional arguments make arity ambiguous.
516
+ *
517
+ * **Example** (Selecting data-first or data-last style by arity)
518
+ *
519
+ * ```ts
520
+ * import { Function, pipe } from "effect"
521
+ *
522
+ * const sum = Function.dual<
427
523
  * (that: number) => (self: number) => number,
428
524
  * (self: number, that: number) => number
429
525
  * >(2, (self, that) => self + that)
@@ -432,26 +528,26 @@ function or(a, b) {
432
528
  * console.log(pipe(2, sum(3))) // 5
433
529
  * ```
434
530
  *
435
- * **Example** (Using call signatures to define the overloads)
531
+ * **Example** (Defining overloads with call signatures)
436
532
  *
437
533
  * ```ts
438
- * import { dual, pipe } from "effect/Function"
534
+ * import { Function, pipe } from "effect"
439
535
  *
440
536
  * const sum: {
441
537
  * (that: number): (self: number) => number
442
538
  * (self: number, that: number): number
443
- * } = dual(2, (self: number, that: number): number => self + that)
539
+ * } = Function.dual(2, (self: number, that: number): number => self + that)
444
540
  *
445
541
  * console.log(sum(2, 3)) // 5
446
542
  * console.log(pipe(2, sum(3))) // 5
447
543
  * ```
448
544
  *
449
- * **Example** (Using a predicate to determine data-first or data-last style)
545
+ * **Example** (Selecting data-first or data-last style with a predicate)
450
546
  *
451
547
  * ```ts
452
- * import { dual, pipe } from "effect/Function"
548
+ * import { Function, pipe } from "effect"
453
549
  *
454
- * const sum = dual<
550
+ * const sum = Function.dual<
455
551
  * (that: number) => (self: number) => number,
456
552
  * (self: number, that: number) => number
457
553
  * >(
@@ -463,9 +559,8 @@ function or(a, b) {
463
559
  * console.log(pipe(2, sum(3))) // 5
464
560
  * ```
465
561
  *
466
- * @param arity - The arity of the uncurried function or a predicate that determines if the function is being used in a data-first or data-last style.
467
- * @param body - The function to be curried.
468
- * @since 1.0.0
562
+ * @category combinators
563
+ * @since 2.0.0
469
564
  */
470
565
  const dual = function(arity, body) {
471
566
  if (typeof arity === "function") return function() {
@@ -496,26 +591,235 @@ const dual = function(arity, body) {
496
591
  }
497
592
  };
498
593
  /**
594
+ * Returns its input argument unchanged.
595
+ *
596
+ * **When to use**
597
+ *
598
+ * Use to return a value unchanged where a function is required.
599
+ *
600
+ * **Example** (Returning the same value)
601
+ *
602
+ * ```ts
603
+ * import { identity } from "effect"
604
+ * import * as assert from "node:assert"
605
+ *
606
+ * assert.deepStrictEqual(identity(5), 5)
607
+ * ```
608
+ *
609
+ * @category combinators
610
+ * @since 2.0.0
611
+ */
612
+ const identity = (a) => a;
613
+ /**
614
+ * Returns the input value with a different static type.
615
+ *
616
+ * **When to use**
617
+ *
618
+ * Use when you need an explicit type-level cast and accept that the value is
619
+ * returned unchanged at runtime.
620
+ *
621
+ * **Gotchas**
622
+ *
623
+ * This is a type-level cast only; it performs no runtime validation or
624
+ * conversion.
625
+ *
626
+ * @see {@link satisfies} for checking assignability without changing the resulting type
627
+ *
628
+ * @category utility types
629
+ * @since 4.0.0
630
+ */
631
+ const cast = identity;
632
+ /**
633
+ * Creates a zero-argument function that always returns the provided value.
634
+ *
635
+ * **When to use**
636
+ *
637
+ * Use when you need a thunk or callback that returns the same value on every
638
+ * invocation.
639
+ *
640
+ * **Example** (Creating a constant thunk)
641
+ *
642
+ * ```ts
643
+ * import { Function } from "effect"
644
+ * import * as assert from "node:assert"
645
+ *
646
+ * const constNull = Function.constant(null)
647
+ *
648
+ * assert.deepStrictEqual(constNull(), null)
649
+ * assert.deepStrictEqual(constNull(), null)
650
+ * ```
651
+ *
652
+ * @category constructors
653
+ * @since 2.0.0
654
+ */
655
+ const constant = (value) => () => value;
656
+ /**
657
+ * Returns `true` when called.
658
+ *
659
+ * **When to use**
660
+ *
661
+ * Use when you need a thunk that returns `true` on every invocation.
662
+ *
663
+ * **Example** (Returning true from a thunk)
664
+ *
665
+ * ```ts
666
+ * import { Function } from "effect"
667
+ * import * as assert from "node:assert"
668
+ *
669
+ * assert.deepStrictEqual(Function.constTrue(), true)
670
+ * ```
671
+ *
672
+ * @category constants
673
+ * @since 2.0.0
674
+ */
675
+ const constTrue = constant(true);
676
+ /**
677
+ * Returns `false` when called.
678
+ *
679
+ * **When to use**
680
+ *
681
+ * Use when you need a thunk that returns `false` on every invocation.
682
+ *
683
+ * **Example** (Returning false from a thunk)
684
+ *
685
+ * ```ts
686
+ * import { Function } from "effect"
687
+ * import * as assert from "node:assert"
688
+ *
689
+ * assert.deepStrictEqual(Function.constFalse(), false)
690
+ * ```
691
+ *
692
+ * @category constants
693
+ * @since 2.0.0
694
+ */
695
+ const constFalse = constant(false);
696
+ /**
697
+ * Returns `null` when called.
698
+ *
699
+ * **When to use**
700
+ *
701
+ * Use when you need a thunk that returns `null` on every invocation.
702
+ *
703
+ * **Example** (Returning null from a thunk)
704
+ *
705
+ * ```ts
706
+ * import { Function } from "effect"
707
+ * import * as assert from "node:assert"
708
+ *
709
+ * assert.deepStrictEqual(Function.constNull(), null)
710
+ * ```
711
+ *
712
+ * @category constants
713
+ * @since 2.0.0
714
+ */
715
+ const constNull = constant(null);
716
+ /**
717
+ * Returns `undefined` when called.
718
+ *
719
+ * **When to use**
720
+ *
721
+ * Use when you need a thunk that returns `undefined` on every invocation.
722
+ *
723
+ * **Example** (Returning undefined from a thunk)
724
+ *
725
+ * ```ts
726
+ * import { Function } from "effect"
727
+ * import * as assert from "node:assert"
728
+ *
729
+ * assert.deepStrictEqual(Function.constUndefined(), undefined)
730
+ * ```
731
+ *
732
+ * @category constants
733
+ * @since 2.0.0
734
+ */
735
+ const constUndefined = constant(void 0);
736
+ /**
499
737
  * Composes two functions, `ab` and `bc` into a single function that takes in an argument `a` of type `A` and returns a result of type `C`.
500
738
  * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
501
739
  *
502
- * @param self - The first function to apply (or the composed function in data-last style).
503
- * @param bc - The second function to apply.
504
- * @returns A composed function that applies both functions in sequence.
505
- * @example
740
+ * **When to use**
741
+ *
742
+ * Use to compose exactly two unary functions into a reusable unary function.
743
+ *
744
+ * **Example** (Composing two functions)
745
+ *
506
746
  * ```ts
747
+ * import { Function } from "effect"
507
748
  * import * as assert from "node:assert"
508
- * import { compose } from "effect/Function"
509
749
  *
510
- * const increment = (n: number) => n + 1;
511
- * const square = (n: number) => n * n;
750
+ * const increment = (n: number) => n + 1
751
+ * const square = (n: number) => n * n
512
752
  *
513
- * assert.strictEqual(compose(increment, square)(2), 9);
753
+ * assert.strictEqual(Function.compose(increment, square)(2), 9)
514
754
  * ```
515
755
  *
516
- * @since 1.0.0
756
+ * @see {@link flow} for composing a left-to-right sequence of functions
757
+ * @see {@link pipe} for applying a value through a left-to-right sequence immediately
758
+ *
759
+ * @category combinators
760
+ * @since 2.0.0
517
761
  */
518
762
  const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
763
+ /**
764
+ * Marks an impossible branch by accepting a `never` value and returning any
765
+ * type.
766
+ *
767
+ * **When to use**
768
+ *
769
+ * Use when you need a return value in a branch that exhaustive checks prove
770
+ * cannot be reached.
771
+ *
772
+ * **Gotchas**
773
+ *
774
+ * Calling `absurd` throws, because a value of type `never` should be
775
+ * impossible at runtime.
776
+ *
777
+ * **Example** (Handling impossible values)
778
+ *
779
+ * ```ts
780
+ * import { absurd } from "effect"
781
+ *
782
+ * const handleNever = (value: never) => {
783
+ * return absurd(value) // This will throw an error if called
784
+ * }
785
+ * ```
786
+ *
787
+ * @category utility types
788
+ * @since 2.0.0
789
+ */
790
+ const absurd = (_) => {
791
+ throw new Error("Called `absurd` function which should be uncallable");
792
+ };
793
+ /**
794
+ * Creates a compile-time placeholder for a value of any type.
795
+ *
796
+ * **When to use**
797
+ *
798
+ * Use as a temporary typed placeholder while developing incomplete code.
799
+ *
800
+ * **Gotchas**
801
+ *
802
+ * `hole` is intended for temporary development use. If the placeholder is
803
+ * evaluated at runtime, it throws.
804
+ *
805
+ * **Example** (Creating a development placeholder)
806
+ *
807
+ * ```ts
808
+ * import { hole } from "effect"
809
+ *
810
+ * // Intentionally not called: `hole` throws if the placeholder is evaluated.
811
+ * const buildUser = (id: number): { readonly id: number; readonly name: string } => ({
812
+ * id,
813
+ * name: hole<string>()
814
+ * })
815
+ *
816
+ * console.log(typeof buildUser) // "function"
817
+ * ```
818
+ *
819
+ * @category utility types
820
+ * @since 2.0.0
821
+ */
822
+ const hole = cast(absurd);
519
823
 
520
824
  //#endregion
521
825
  //#region src/rules/no-leaked-intersection-observer/lib.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-web-api",
3
- "version": "5.16.1",
3
+ "version": "5.17.0",
4
4
  "description": "ESLint React's ESLint plugin for interacting with Web APIs",
5
5
  "keywords": [
6
6
  "react",
@@ -41,11 +41,11 @@
41
41
  "@typescript-eslint/utils": "^8.64.0",
42
42
  "birecord": "^0.1.2",
43
43
  "ts-pattern": "^5.9.0",
44
- "@eslint-react/ast": "5.16.1",
45
- "@eslint-react/core": "5.16.1",
46
- "@eslint-react/shared": "5.16.1",
47
- "@eslint-react/eslint": "5.16.1",
48
- "@eslint-react/var": "5.16.1"
44
+ "@eslint-react/ast": "5.17.0",
45
+ "@eslint-react/core": "5.17.0",
46
+ "@eslint-react/eslint": "5.17.0",
47
+ "@eslint-react/shared": "5.17.0",
48
+ "@eslint-react/var": "5.17.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/react": "^19.2.17",