eslint-plugin-react-dom 5.24.0 → 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.
- package/dist/index.js +400 -77
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
26
26
|
//#endregion
|
|
27
27
|
//#region package.json
|
|
28
28
|
var name$2 = "eslint-plugin-react-dom";
|
|
29
|
-
var version = "5.24.
|
|
29
|
+
var version = "5.24.1";
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region src/utils/create-rule.ts
|
|
@@ -215,16 +215,6 @@ function buildFix$2(context, node) {
|
|
|
215
215
|
//#endregion
|
|
216
216
|
//#region ../../.pkgs/eff/dist/index.js
|
|
217
217
|
/**
|
|
218
|
-
* A function that checks if the passed parameter is a string and narrows its type accordingly.
|
|
219
|
-
*
|
|
220
|
-
* @param data - The variable to check.
|
|
221
|
-
* @returns True if the passed input is a string, false otherwise.
|
|
222
|
-
* @category guards
|
|
223
|
-
*/
|
|
224
|
-
function isString(data) {
|
|
225
|
-
return typeof data === "string";
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
218
|
* Applies a `pipe` method's variadic arguments to an initial value from left
|
|
229
219
|
* to right.
|
|
230
220
|
*
|
|
@@ -256,7 +246,7 @@ function isString(data) {
|
|
|
256
246
|
* (n) => n + 2,
|
|
257
247
|
* (n) => n * 3
|
|
258
248
|
* )
|
|
259
|
-
*
|
|
249
|
+
* result // => 21
|
|
260
250
|
* ```
|
|
261
251
|
*
|
|
262
252
|
* @category combinators
|
|
@@ -313,16 +303,6 @@ const Class = (function() {
|
|
|
313
303
|
return PipeableBase;
|
|
314
304
|
})();
|
|
315
305
|
/**
|
|
316
|
-
* Provides small helpers for defining and reusing TypeScript functions.
|
|
317
|
-
*
|
|
318
|
-
* The main helpers are `pipe` and `flow` for left-to-right composition and
|
|
319
|
-
* `dual` for APIs that support both direct and pipe-friendly call styles. The
|
|
320
|
-
* module also contains small identity, constant, tuple, type-level, and
|
|
321
|
-
* memoization helpers used across the library.
|
|
322
|
-
*
|
|
323
|
-
* @since 2.0.0
|
|
324
|
-
*/
|
|
325
|
-
/**
|
|
326
306
|
* Creates a function that can be called in data-first style or data-last
|
|
327
307
|
* (`pipe`-friendly) style.
|
|
328
308
|
*
|
|
@@ -347,8 +327,8 @@ const Class = (function() {
|
|
|
347
327
|
* (self: number, that: number) => number
|
|
348
328
|
* >(2, (self, that) => self + that)
|
|
349
329
|
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
330
|
+
* sum(2, 3) // => 5
|
|
331
|
+
* pipe(2, sum(3)) // => 5
|
|
352
332
|
* ```
|
|
353
333
|
*
|
|
354
334
|
* **Example** (Defining overloads with call signatures)
|
|
@@ -361,8 +341,8 @@ const Class = (function() {
|
|
|
361
341
|
* (self: number, that: number): number
|
|
362
342
|
* } = Function.dual(2, (self: number, that: number): number => self + that)
|
|
363
343
|
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
344
|
+
* sum(2, 3) // => 5
|
|
345
|
+
* pipe(2, sum(3)) // => 5
|
|
366
346
|
* ```
|
|
367
347
|
*
|
|
368
348
|
* **Example** (Selecting data-first or data-last style with a predicate)
|
|
@@ -378,8 +358,8 @@ const Class = (function() {
|
|
|
378
358
|
* (self, that) => self + that
|
|
379
359
|
* )
|
|
380
360
|
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
361
|
+
* sum(2, 3) // => 5
|
|
362
|
+
* pipe(2, sum(3)) // => 5
|
|
383
363
|
* ```
|
|
384
364
|
*
|
|
385
365
|
* @category combinators
|
|
@@ -424,9 +404,8 @@ const dual = function(arity, body) {
|
|
|
424
404
|
*
|
|
425
405
|
* ```ts
|
|
426
406
|
* import { identity } from "effect"
|
|
427
|
-
* import * as assert from "node:assert"
|
|
428
407
|
*
|
|
429
|
-
*
|
|
408
|
+
* identity(5) // => 5
|
|
430
409
|
* ```
|
|
431
410
|
*
|
|
432
411
|
* @category combinators
|
|
@@ -464,12 +443,11 @@ const cast = identity;
|
|
|
464
443
|
*
|
|
465
444
|
* ```ts
|
|
466
445
|
* import { Function } from "effect"
|
|
467
|
-
* import * as assert from "node:assert"
|
|
468
446
|
*
|
|
469
447
|
* const constNull = Function.constant(null)
|
|
470
448
|
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
449
|
+
* constNull() // => null
|
|
450
|
+
* constNull() // => null
|
|
473
451
|
* ```
|
|
474
452
|
*
|
|
475
453
|
* @category constructors
|
|
@@ -487,9 +465,8 @@ const constant = (value) => () => value;
|
|
|
487
465
|
*
|
|
488
466
|
* ```ts
|
|
489
467
|
* import { Function } from "effect"
|
|
490
|
-
* import * as assert from "node:assert"
|
|
491
468
|
*
|
|
492
|
-
*
|
|
469
|
+
* Function.constTrue() // => true
|
|
493
470
|
* ```
|
|
494
471
|
*
|
|
495
472
|
* @category constants
|
|
@@ -507,9 +484,8 @@ const constTrue = constant(true);
|
|
|
507
484
|
*
|
|
508
485
|
* ```ts
|
|
509
486
|
* import { Function } from "effect"
|
|
510
|
-
* import * as assert from "node:assert"
|
|
511
487
|
*
|
|
512
|
-
*
|
|
488
|
+
* Function.constFalse() // => false
|
|
513
489
|
* ```
|
|
514
490
|
*
|
|
515
491
|
* @category constants
|
|
@@ -527,9 +503,8 @@ const constFalse = constant(false);
|
|
|
527
503
|
*
|
|
528
504
|
* ```ts
|
|
529
505
|
* import { Function } from "effect"
|
|
530
|
-
* import * as assert from "node:assert"
|
|
531
506
|
*
|
|
532
|
-
*
|
|
507
|
+
* Function.constNull() // => null
|
|
533
508
|
* ```
|
|
534
509
|
*
|
|
535
510
|
* @category constants
|
|
@@ -547,9 +522,8 @@ const constNull = constant(null);
|
|
|
547
522
|
*
|
|
548
523
|
* ```ts
|
|
549
524
|
* import { Function } from "effect"
|
|
550
|
-
* import * as assert from "node:assert"
|
|
551
525
|
*
|
|
552
|
-
*
|
|
526
|
+
* Function.constUndefined() // => undefined
|
|
553
527
|
* ```
|
|
554
528
|
*
|
|
555
529
|
* @category constants
|
|
@@ -568,12 +542,11 @@ const constUndefined = constant(void 0);
|
|
|
568
542
|
*
|
|
569
543
|
* ```ts
|
|
570
544
|
* import { Function } from "effect"
|
|
571
|
-
* import * as assert from "node:assert"
|
|
572
545
|
*
|
|
573
546
|
* const increment = (n: number) => n + 1
|
|
574
547
|
* const square = (n: number) => n * n
|
|
575
548
|
*
|
|
576
|
-
*
|
|
549
|
+
* Function.compose(increment, square)(2) // => 9
|
|
577
550
|
* ```
|
|
578
551
|
*
|
|
579
552
|
* @see {@link flow} for composing a left-to-right sequence of functions
|
|
@@ -636,7 +609,6 @@ const absurd = (_) => {
|
|
|
636
609
|
* name: hole<string>()
|
|
637
610
|
* })
|
|
638
611
|
*
|
|
639
|
-
* console.log(typeof buildUser) // "function"
|
|
640
612
|
* ```
|
|
641
613
|
*
|
|
642
614
|
* @category utility types
|
|
@@ -644,56 +616,407 @@ const absurd = (_) => {
|
|
|
644
616
|
*/
|
|
645
617
|
const hole = cast(absurd);
|
|
646
618
|
/**
|
|
647
|
-
*
|
|
619
|
+
* Creates a predicate that returns `true` only if both predicates are `true`.
|
|
620
|
+
*
|
|
621
|
+
* **When to use**
|
|
622
|
+
*
|
|
623
|
+
* Use when you want to combine `Predicate`s with AND, accepting values that
|
|
624
|
+
* satisfy multiple conditions, including refinements that narrow to an
|
|
625
|
+
* intersection.
|
|
626
|
+
*
|
|
627
|
+
* **Details**
|
|
628
|
+
*
|
|
629
|
+
* Evaluation short-circuits on the first `false`. For refinements, the output
|
|
630
|
+
* type is an intersection.
|
|
631
|
+
*
|
|
632
|
+
* **Example** (Checking both conditions)
|
|
633
|
+
*
|
|
634
|
+
* ```ts
|
|
635
|
+
* import { Predicate } from "effect"
|
|
636
|
+
*
|
|
637
|
+
* const hasAAndB = Predicate.and(
|
|
638
|
+
* Predicate.hasProperty("a"),
|
|
639
|
+
* Predicate.hasProperty("b")
|
|
640
|
+
* )
|
|
641
|
+
*
|
|
642
|
+
* const input: unknown = JSON.parse(`{"a":1,"b":"ok"}`)
|
|
643
|
+
* if (hasAAndB(input)) {
|
|
644
|
+
* // input has both properties at this point
|
|
645
|
+
* const a = input.a
|
|
646
|
+
* const b = input.b
|
|
647
|
+
*
|
|
648
|
+
* const values = [a, b] // => [1, "ok"]
|
|
649
|
+
* }
|
|
650
|
+
* ```
|
|
651
|
+
*
|
|
652
|
+
* @see {@link or}
|
|
653
|
+
* @see {@link not}
|
|
654
|
+
* @category combinators
|
|
655
|
+
* @since 2.0.0
|
|
656
|
+
*/
|
|
657
|
+
const and = dual(2, (a, b) => (data) => a(data) && b(data));
|
|
658
|
+
/**
|
|
659
|
+
* Creates a predicate that returns `true` if either predicate is `true`.
|
|
660
|
+
*
|
|
661
|
+
* **When to use**
|
|
662
|
+
*
|
|
663
|
+
* Use when you want to combine `Predicate`s with OR, accepting values that
|
|
664
|
+
* satisfy at least one condition, including refinements that narrow to a union.
|
|
665
|
+
*
|
|
666
|
+
* **Details**
|
|
667
|
+
*
|
|
668
|
+
* Evaluation short-circuits on the first `true`. For refinements, the output
|
|
669
|
+
* type is a union.
|
|
670
|
+
*
|
|
671
|
+
* **Example** (Checking either condition)
|
|
672
|
+
*
|
|
673
|
+
* ```ts
|
|
674
|
+
* import { Predicate } from "effect"
|
|
675
|
+
*
|
|
676
|
+
* const isStringOrNumber = Predicate.or(Predicate.isString, Predicate.isNumber)
|
|
677
|
+
*
|
|
678
|
+
* isStringOrNumber("a") // => true
|
|
679
|
+
* ```
|
|
680
|
+
*
|
|
681
|
+
* @see {@link and}
|
|
682
|
+
* @see {@link xor}
|
|
683
|
+
* @category combinators
|
|
684
|
+
* @since 2.0.0
|
|
685
|
+
*/
|
|
686
|
+
const or = dual(2, (a, b) => (data) => a(data) || b(data));
|
|
687
|
+
/**
|
|
688
|
+
* Creates a predicate that returns `true` if exactly one predicate is `true`.
|
|
689
|
+
*
|
|
690
|
+
* **When to use**
|
|
691
|
+
*
|
|
692
|
+
* Use when you want to combine two `Predicate`s with exclusive-or semantics.
|
|
693
|
+
*
|
|
694
|
+
* **Details**
|
|
695
|
+
*
|
|
696
|
+
* Returns `true` when results differ.
|
|
697
|
+
*
|
|
698
|
+
* **Example** (Checking exclusive-or conditions)
|
|
699
|
+
*
|
|
700
|
+
* ```ts
|
|
701
|
+
* import { Predicate } from "effect"
|
|
702
|
+
*
|
|
703
|
+
* const isEven = (n: number) => n % 2 === 0
|
|
704
|
+
* const isPositive = (n: number) => n > 0
|
|
705
|
+
* const either = Predicate.xor(isEven, isPositive)
|
|
706
|
+
*
|
|
707
|
+
* either(-2) // => true
|
|
708
|
+
* ```
|
|
709
|
+
*
|
|
710
|
+
* @see {@link or}
|
|
711
|
+
* @see {@link and}
|
|
712
|
+
* @category combinators
|
|
713
|
+
* @since 2.0.0
|
|
714
|
+
*/
|
|
715
|
+
const xor = dual(2, (a, b) => (data) => a(data) !== b(data));
|
|
716
|
+
/**
|
|
717
|
+
* Creates a predicate that returns `true` when both predicates agree.
|
|
718
|
+
*
|
|
719
|
+
* **When to use**
|
|
720
|
+
*
|
|
721
|
+
* Use when you want to check equivalence of two `Predicate`s.
|
|
722
|
+
*
|
|
723
|
+
* **Details**
|
|
724
|
+
*
|
|
725
|
+
* Returns `true` when both results are equal.
|
|
726
|
+
*
|
|
727
|
+
* **Example** (Defining equivalence)
|
|
728
|
+
*
|
|
729
|
+
* ```ts
|
|
730
|
+
* import { Predicate } from "effect"
|
|
731
|
+
*
|
|
732
|
+
* const isEven = (n: number) => n % 2 === 0
|
|
733
|
+
* const same = Predicate.eqv(isEven, isEven)
|
|
734
|
+
*
|
|
735
|
+
* same(3) // => true
|
|
736
|
+
* ```
|
|
737
|
+
*
|
|
738
|
+
* @see {@link xor}
|
|
739
|
+
* @category combinators
|
|
740
|
+
* @since 2.0.0
|
|
741
|
+
*/
|
|
742
|
+
const eqv = dual(2, (a, b) => (data) => a(data) === b(data));
|
|
743
|
+
/**
|
|
744
|
+
* Creates a predicate representing logical implication: if `antecedent`, then `consequent`.
|
|
745
|
+
*
|
|
746
|
+
* **When to use**
|
|
747
|
+
*
|
|
748
|
+
* Use when you need to encode logical implication between `Predicate` rules,
|
|
749
|
+
* where one rule only applies when a precondition holds.
|
|
750
|
+
*
|
|
751
|
+
* **Details**
|
|
752
|
+
*
|
|
753
|
+
* Models constraints like "if A then B" and returns `true` when the antecedent
|
|
754
|
+
* is `false`.
|
|
755
|
+
*
|
|
756
|
+
* **Example** (Checking implication)
|
|
757
|
+
*
|
|
758
|
+
* ```ts
|
|
759
|
+
* import { Predicate } from "effect"
|
|
760
|
+
*
|
|
761
|
+
* const isAdult = (age: number) => age >= 18
|
|
762
|
+
* const canVote = (age: number) => age >= 18
|
|
763
|
+
* const implies = Predicate.implies(isAdult, canVote)
|
|
764
|
+
*
|
|
765
|
+
* implies(16) // => true
|
|
766
|
+
* ```
|
|
767
|
+
*
|
|
768
|
+
* @see {@link and}
|
|
769
|
+
* @see {@link or}
|
|
770
|
+
* @category combinators
|
|
771
|
+
* @since 2.0.0
|
|
772
|
+
*/
|
|
773
|
+
const implies = dual(2, (antecedent, consequent) => (data) => !antecedent(data) || consequent(data));
|
|
774
|
+
/**
|
|
775
|
+
* Creates a predicate that returns `true` when neither predicate is `true`.
|
|
648
776
|
*
|
|
649
|
-
*
|
|
777
|
+
* **When to use**
|
|
778
|
+
*
|
|
779
|
+
* Use when you want to combine two `Predicate`s with logical NOR semantics.
|
|
780
|
+
*
|
|
781
|
+
* **Details**
|
|
782
|
+
*
|
|
783
|
+
* Returns the negation of `or`.
|
|
784
|
+
*
|
|
785
|
+
* **Example** (Checking NOR conditions)
|
|
650
786
|
*
|
|
651
|
-
* @param pred - The predicate to test each element with.
|
|
652
|
-
* @returns A new array without the matching prefix.
|
|
653
|
-
* @example
|
|
654
787
|
* ```ts
|
|
655
|
-
* import
|
|
656
|
-
* import { dropWhile, pipe } from "@local/eff"
|
|
788
|
+
* import { Predicate } from "effect"
|
|
657
789
|
*
|
|
658
|
-
*
|
|
659
|
-
* assert.deepStrictEqual(dropWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [3, 2, 1])
|
|
790
|
+
* const neither = Predicate.nor(Predicate.isString, Predicate.isNumber)
|
|
660
791
|
*
|
|
661
|
-
* //
|
|
662
|
-
* assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], dropWhile((n: number) => n < 3)), [3, 2, 1])
|
|
792
|
+
* neither(true) // => true
|
|
663
793
|
* ```
|
|
664
|
-
*
|
|
794
|
+
*
|
|
795
|
+
* @see {@link or}
|
|
796
|
+
* @see {@link not}
|
|
797
|
+
* @category combinators
|
|
798
|
+
* @since 2.0.0
|
|
665
799
|
*/
|
|
666
|
-
const
|
|
667
|
-
|
|
800
|
+
const nor = dual(2, (a, b) => (data) => !a(data) && !b(data));
|
|
801
|
+
/**
|
|
802
|
+
* Creates a predicate that returns `true` unless both predicates are `true`.
|
|
803
|
+
*
|
|
804
|
+
* **When to use**
|
|
805
|
+
*
|
|
806
|
+
* Use when you want to combine two `Predicate`s with logical NAND semantics.
|
|
807
|
+
*
|
|
808
|
+
* **Details**
|
|
809
|
+
*
|
|
810
|
+
* Returns the negation of `and`.
|
|
811
|
+
*
|
|
812
|
+
* **Example** (Checking NAND conditions)
|
|
813
|
+
*
|
|
814
|
+
* ```ts
|
|
815
|
+
* import { Predicate } from "effect"
|
|
816
|
+
*
|
|
817
|
+
* const notBoth = Predicate.nand(Predicate.isString, Predicate.isNumber)
|
|
818
|
+
*
|
|
819
|
+
* notBoth("a") // => true
|
|
820
|
+
* ```
|
|
821
|
+
*
|
|
822
|
+
* @see {@link and}
|
|
823
|
+
* @see {@link not}
|
|
824
|
+
* @category combinators
|
|
825
|
+
* @since 2.0.0
|
|
826
|
+
*/
|
|
827
|
+
const nand = dual(2, (a, b) => (data) => !a(data) || !b(data));
|
|
828
|
+
/**
|
|
829
|
+
* Checks whether a value is a `string`.
|
|
830
|
+
*
|
|
831
|
+
* **When to use**
|
|
832
|
+
*
|
|
833
|
+
* Use when you need a `Predicate` guard to narrow an `unknown` value to a
|
|
834
|
+
* string.
|
|
835
|
+
*
|
|
836
|
+
* **Details**
|
|
837
|
+
*
|
|
838
|
+
* Uses `typeof input === "string"`.
|
|
839
|
+
*
|
|
840
|
+
* **Example** (Guarding strings)
|
|
841
|
+
*
|
|
842
|
+
* ```ts
|
|
843
|
+
* import { Predicate } from "effect"
|
|
844
|
+
*
|
|
845
|
+
* const data: unknown = "hi"
|
|
846
|
+
*
|
|
847
|
+
* if (Predicate.isString(data)) {
|
|
848
|
+
* data.toUpperCase() // => "HI"
|
|
849
|
+
* }
|
|
850
|
+
* ```
|
|
851
|
+
*
|
|
852
|
+
* @see {@link isNumber}
|
|
853
|
+
* @see {@link isBoolean}
|
|
854
|
+
* @see {@link Refinement}
|
|
855
|
+
* @category guards
|
|
856
|
+
* @since 2.0.0
|
|
857
|
+
*/
|
|
858
|
+
function isString(input) {
|
|
859
|
+
return typeof input === "string";
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Checks whether a value is a `function`.
|
|
863
|
+
*
|
|
864
|
+
* **When to use**
|
|
865
|
+
*
|
|
866
|
+
* Use when you need a `Predicate` guard to narrow an `unknown` value to a
|
|
867
|
+
* callable function.
|
|
868
|
+
*
|
|
869
|
+
* **Details**
|
|
870
|
+
*
|
|
871
|
+
* Uses `typeof input === "function"`.
|
|
872
|
+
*
|
|
873
|
+
* **Example** (Guarding functions)
|
|
874
|
+
*
|
|
875
|
+
* ```ts
|
|
876
|
+
* import { Predicate } from "effect"
|
|
877
|
+
*
|
|
878
|
+
* const data: unknown = () => 1
|
|
879
|
+
*
|
|
880
|
+
* if (Predicate.isFunction(data)) {
|
|
881
|
+
* data() // => 1
|
|
882
|
+
* }
|
|
883
|
+
* ```
|
|
884
|
+
*
|
|
885
|
+
* @see {@link isObjectKeyword}
|
|
886
|
+
* @category guards
|
|
887
|
+
* @since 2.0.0
|
|
888
|
+
*/
|
|
889
|
+
function isFunction(input) {
|
|
890
|
+
return typeof input === "function";
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Checks whether a value is an `object` in the JavaScript sense (objects, arrays, functions).
|
|
894
|
+
*
|
|
895
|
+
* **When to use**
|
|
896
|
+
*
|
|
897
|
+
* Use when you need a `Predicate` guard that accepts arrays and functions as
|
|
898
|
+
* well as objects.
|
|
899
|
+
*
|
|
900
|
+
* **Details**
|
|
901
|
+
*
|
|
902
|
+
* Returns `true` for arrays and functions, and `false` for `null`.
|
|
903
|
+
*
|
|
904
|
+
* **Example** (Checking object keywords)
|
|
905
|
+
*
|
|
906
|
+
* ```ts
|
|
907
|
+
* import { Predicate } from "effect"
|
|
908
|
+
*
|
|
909
|
+
* Predicate.isObjectKeyword(() => 1) // => true
|
|
910
|
+
* Predicate.isObjectKeyword(null) // => false
|
|
911
|
+
* ```
|
|
912
|
+
*
|
|
913
|
+
* @see {@link isObject}
|
|
914
|
+
* @see {@link isObjectOrArray}
|
|
915
|
+
* @category guards
|
|
916
|
+
* @since 4.0.0
|
|
917
|
+
*/
|
|
918
|
+
function isObjectKeyword(input) {
|
|
919
|
+
return typeof input === "object" && input !== null || isFunction(input);
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Checks whether a value has a given property key.
|
|
923
|
+
*
|
|
924
|
+
* **When to use**
|
|
925
|
+
*
|
|
926
|
+
* Use when you need a `Predicate` guard for property access on `unknown`
|
|
927
|
+
* values with a simple structural object check.
|
|
928
|
+
*
|
|
929
|
+
* **Details**
|
|
930
|
+
*
|
|
931
|
+
* Uses the `in` operator and `isObjectKeyword`. This does not check property
|
|
932
|
+
* value types.
|
|
933
|
+
*
|
|
934
|
+
* **Example** (Guarding object properties)
|
|
935
|
+
*
|
|
936
|
+
* ```ts
|
|
937
|
+
* import { Predicate } from "effect"
|
|
938
|
+
*
|
|
939
|
+
* const hasName = Predicate.hasProperty("name")
|
|
940
|
+
* const data: unknown = { name: "Ada" }
|
|
941
|
+
*
|
|
942
|
+
* if (hasName(data)) {
|
|
943
|
+
* data.name // => "Ada"
|
|
944
|
+
* }
|
|
945
|
+
* ```
|
|
946
|
+
*
|
|
947
|
+
* @see {@link isTagged}
|
|
948
|
+
* @see {@link isObjectKeyword}
|
|
949
|
+
* @category guards
|
|
950
|
+
* @since 2.0.0
|
|
951
|
+
*/
|
|
952
|
+
const hasProperty = dual(2, (data, property) => isObjectKeyword(data) && property in data);
|
|
953
|
+
/**
|
|
954
|
+
* Drops elements from the start while the predicate holds, returning the rest.
|
|
955
|
+
*
|
|
956
|
+
* **When to use**
|
|
957
|
+
*
|
|
958
|
+
* Use to remove a leading prefix of elements that satisfy a predicate.
|
|
959
|
+
*
|
|
960
|
+
* **Details**
|
|
961
|
+
*
|
|
962
|
+
* The predicate receives `(element, index)`.
|
|
963
|
+
*
|
|
964
|
+
* **Example** (Dropping while condition holds)
|
|
965
|
+
*
|
|
966
|
+
* ```ts
|
|
967
|
+
* import { Array } from "effect"
|
|
968
|
+
*
|
|
969
|
+
* Array.dropWhile([1, 2, 3, 4, 5], (x) => x < 4) // => [4, 5]
|
|
970
|
+
* ```
|
|
971
|
+
*
|
|
972
|
+
* @see {@link takeWhile} — keep the matching prefix instead
|
|
973
|
+
* @see {@link drop} — drop a fixed count
|
|
974
|
+
*
|
|
975
|
+
* @category getters
|
|
976
|
+
* @since 2.0.0
|
|
977
|
+
*/
|
|
978
|
+
const dropWhile = dual(2, (self, predicate) => {
|
|
979
|
+
const input = Array.isArray(self) ? self : Array.from(self);
|
|
980
|
+
const len = input.length;
|
|
668
981
|
let idx = 0;
|
|
669
|
-
while (idx < len &&
|
|
670
|
-
return
|
|
982
|
+
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
983
|
+
return input.slice(idx);
|
|
671
984
|
});
|
|
672
985
|
/**
|
|
673
|
-
* Takes
|
|
986
|
+
* Takes elements from the start while the predicate holds, stopping at the
|
|
987
|
+
* first element that fails.
|
|
674
988
|
*
|
|
675
|
-
*
|
|
989
|
+
* **When to use**
|
|
676
990
|
*
|
|
677
|
-
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
* import * as assert from "node:assert"
|
|
682
|
-
* import { pipe, takeWhile } from "@local/eff"
|
|
991
|
+
* Use to keep the leading elements of an iterable while each element satisfies
|
|
992
|
+
* a predicate, returning the retained prefix as an array.
|
|
993
|
+
*
|
|
994
|
+
* **Details**
|
|
683
995
|
*
|
|
684
|
-
*
|
|
685
|
-
*
|
|
996
|
+
* Supports refinements for type narrowing. The predicate receives
|
|
997
|
+
* `(element, index)`.
|
|
686
998
|
*
|
|
687
|
-
*
|
|
688
|
-
*
|
|
999
|
+
* **Example** (Taking while condition holds)
|
|
1000
|
+
*
|
|
1001
|
+
* ```ts
|
|
1002
|
+
* import { Array } from "effect"
|
|
1003
|
+
*
|
|
1004
|
+
* Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4) // => [1, 3, 2]
|
|
689
1005
|
* ```
|
|
690
|
-
*
|
|
1006
|
+
*
|
|
1007
|
+
* @see {@link take} for keeping a fixed number of leading elements
|
|
1008
|
+
* @see {@link dropWhile} for removing the matching prefix and keeping the rest
|
|
1009
|
+
* @see {@link span} for splitting the matching prefix from the remaining elements
|
|
1010
|
+
*
|
|
1011
|
+
* @category getters
|
|
1012
|
+
* @since 2.0.0
|
|
691
1013
|
*/
|
|
692
|
-
const takeWhile = dual(2, (
|
|
693
|
-
const
|
|
1014
|
+
const takeWhile = dual(2, (self, predicate) => {
|
|
1015
|
+
const input = Array.isArray(self) ? self : Array.from(self);
|
|
1016
|
+
const len = input.length;
|
|
694
1017
|
let idx = 0;
|
|
695
|
-
while (idx < len &&
|
|
696
|
-
return
|
|
1018
|
+
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
1019
|
+
return input.slice(0, idx);
|
|
697
1020
|
});
|
|
698
1021
|
|
|
699
1022
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-dom",
|
|
3
|
-
"version": "5.24.
|
|
3
|
+
"version": "5.24.1",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@eslint-react/ast": "5.24.
|
|
41
|
-
"@eslint-react/eslint": "5.24.
|
|
42
|
-
"@eslint-react/jsx": "5.24.
|
|
43
|
-
"@eslint-react/shared": "5.24.
|
|
44
|
-
"@eslint-react/var": "5.24.
|
|
40
|
+
"@eslint-react/ast": "5.24.1",
|
|
41
|
+
"@eslint-react/eslint": "5.24.1",
|
|
42
|
+
"@eslint-react/jsx": "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
|
"compare-versions": "^6.1.1",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@types/react": "^19.3.0",
|
|
55
55
|
"@types/react-dom": "^19.3.0",
|
|
56
56
|
"dedent": "^1.7.2",
|
|
57
|
-
"eslint": "^10.
|
|
57
|
+
"eslint": "^10.12.0",
|
|
58
58
|
"tsdown": "^0.23.0",
|
|
59
59
|
"typescript": "6.0.3"
|
|
60
60
|
},
|