eslint-plugin-react-jsx 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.
- package/dist/index.js +372 -71
- 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-jsx";
|
|
29
|
-
var version = "5.24.
|
|
29
|
+
var version = "5.24.1";
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region src/utils/create-rule.ts
|
|
@@ -246,9 +246,6 @@ function create$5(context) {
|
|
|
246
246
|
|
|
247
247
|
//#endregion
|
|
248
248
|
//#region ../../.pkgs/eff/dist/index.js
|
|
249
|
-
function not(predicate) {
|
|
250
|
-
return (data) => !predicate(data);
|
|
251
|
-
}
|
|
252
249
|
/**
|
|
253
250
|
* Applies a `pipe` method's variadic arguments to an initial value from left
|
|
254
251
|
* to right.
|
|
@@ -281,7 +278,7 @@ function not(predicate) {
|
|
|
281
278
|
* (n) => n + 2,
|
|
282
279
|
* (n) => n * 3
|
|
283
280
|
* )
|
|
284
|
-
*
|
|
281
|
+
* result // => 21
|
|
285
282
|
* ```
|
|
286
283
|
*
|
|
287
284
|
* @category combinators
|
|
@@ -338,16 +335,6 @@ const Class = (function() {
|
|
|
338
335
|
return PipeableBase;
|
|
339
336
|
})();
|
|
340
337
|
/**
|
|
341
|
-
* Provides small helpers for defining and reusing TypeScript functions.
|
|
342
|
-
*
|
|
343
|
-
* The main helpers are `pipe` and `flow` for left-to-right composition and
|
|
344
|
-
* `dual` for APIs that support both direct and pipe-friendly call styles. The
|
|
345
|
-
* module also contains small identity, constant, tuple, type-level, and
|
|
346
|
-
* memoization helpers used across the library.
|
|
347
|
-
*
|
|
348
|
-
* @since 2.0.0
|
|
349
|
-
*/
|
|
350
|
-
/**
|
|
351
338
|
* Creates a function that can be called in data-first style or data-last
|
|
352
339
|
* (`pipe`-friendly) style.
|
|
353
340
|
*
|
|
@@ -372,8 +359,8 @@ const Class = (function() {
|
|
|
372
359
|
* (self: number, that: number) => number
|
|
373
360
|
* >(2, (self, that) => self + that)
|
|
374
361
|
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
362
|
+
* sum(2, 3) // => 5
|
|
363
|
+
* pipe(2, sum(3)) // => 5
|
|
377
364
|
* ```
|
|
378
365
|
*
|
|
379
366
|
* **Example** (Defining overloads with call signatures)
|
|
@@ -386,8 +373,8 @@ const Class = (function() {
|
|
|
386
373
|
* (self: number, that: number): number
|
|
387
374
|
* } = Function.dual(2, (self: number, that: number): number => self + that)
|
|
388
375
|
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
376
|
+
* sum(2, 3) // => 5
|
|
377
|
+
* pipe(2, sum(3)) // => 5
|
|
391
378
|
* ```
|
|
392
379
|
*
|
|
393
380
|
* **Example** (Selecting data-first or data-last style with a predicate)
|
|
@@ -403,8 +390,8 @@ const Class = (function() {
|
|
|
403
390
|
* (self, that) => self + that
|
|
404
391
|
* )
|
|
405
392
|
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
393
|
+
* sum(2, 3) // => 5
|
|
394
|
+
* pipe(2, sum(3)) // => 5
|
|
408
395
|
* ```
|
|
409
396
|
*
|
|
410
397
|
* @category combinators
|
|
@@ -449,9 +436,8 @@ const dual = function(arity, body) {
|
|
|
449
436
|
*
|
|
450
437
|
* ```ts
|
|
451
438
|
* import { identity } from "effect"
|
|
452
|
-
* import * as assert from "node:assert"
|
|
453
439
|
*
|
|
454
|
-
*
|
|
440
|
+
* identity(5) // => 5
|
|
455
441
|
* ```
|
|
456
442
|
*
|
|
457
443
|
* @category combinators
|
|
@@ -489,12 +475,11 @@ const cast = identity;
|
|
|
489
475
|
*
|
|
490
476
|
* ```ts
|
|
491
477
|
* import { Function } from "effect"
|
|
492
|
-
* import * as assert from "node:assert"
|
|
493
478
|
*
|
|
494
479
|
* const constNull = Function.constant(null)
|
|
495
480
|
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
481
|
+
* constNull() // => null
|
|
482
|
+
* constNull() // => null
|
|
498
483
|
* ```
|
|
499
484
|
*
|
|
500
485
|
* @category constructors
|
|
@@ -512,9 +497,8 @@ const constant = (value) => () => value;
|
|
|
512
497
|
*
|
|
513
498
|
* ```ts
|
|
514
499
|
* import { Function } from "effect"
|
|
515
|
-
* import * as assert from "node:assert"
|
|
516
500
|
*
|
|
517
|
-
*
|
|
501
|
+
* Function.constTrue() // => true
|
|
518
502
|
* ```
|
|
519
503
|
*
|
|
520
504
|
* @category constants
|
|
@@ -532,9 +516,8 @@ const constTrue = constant(true);
|
|
|
532
516
|
*
|
|
533
517
|
* ```ts
|
|
534
518
|
* import { Function } from "effect"
|
|
535
|
-
* import * as assert from "node:assert"
|
|
536
519
|
*
|
|
537
|
-
*
|
|
520
|
+
* Function.constFalse() // => false
|
|
538
521
|
* ```
|
|
539
522
|
*
|
|
540
523
|
* @category constants
|
|
@@ -552,9 +535,8 @@ const constFalse = constant(false);
|
|
|
552
535
|
*
|
|
553
536
|
* ```ts
|
|
554
537
|
* import { Function } from "effect"
|
|
555
|
-
* import * as assert from "node:assert"
|
|
556
538
|
*
|
|
557
|
-
*
|
|
539
|
+
* Function.constNull() // => null
|
|
558
540
|
* ```
|
|
559
541
|
*
|
|
560
542
|
* @category constants
|
|
@@ -572,9 +554,8 @@ const constNull = constant(null);
|
|
|
572
554
|
*
|
|
573
555
|
* ```ts
|
|
574
556
|
* import { Function } from "effect"
|
|
575
|
-
* import * as assert from "node:assert"
|
|
576
557
|
*
|
|
577
|
-
*
|
|
558
|
+
* Function.constUndefined() // => undefined
|
|
578
559
|
* ```
|
|
579
560
|
*
|
|
580
561
|
* @category constants
|
|
@@ -593,12 +574,11 @@ const constUndefined = constant(void 0);
|
|
|
593
574
|
*
|
|
594
575
|
* ```ts
|
|
595
576
|
* import { Function } from "effect"
|
|
596
|
-
* import * as assert from "node:assert"
|
|
597
577
|
*
|
|
598
578
|
* const increment = (n: number) => n + 1
|
|
599
579
|
* const square = (n: number) => n * n
|
|
600
580
|
*
|
|
601
|
-
*
|
|
581
|
+
* Function.compose(increment, square)(2) // => 9
|
|
602
582
|
* ```
|
|
603
583
|
*
|
|
604
584
|
* @see {@link flow} for composing a left-to-right sequence of functions
|
|
@@ -661,64 +641,384 @@ const absurd = (_) => {
|
|
|
661
641
|
* name: hole<string>()
|
|
662
642
|
* })
|
|
663
643
|
*
|
|
664
|
-
* console.log(typeof buildUser) // "function"
|
|
665
644
|
* ```
|
|
666
645
|
*
|
|
667
646
|
* @category utility types
|
|
668
647
|
* @since 2.0.0
|
|
669
648
|
*/
|
|
670
649
|
const hole = cast(absurd);
|
|
650
|
+
function not(predicate) {
|
|
651
|
+
return (data) => !predicate(data);
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Creates a predicate that returns `true` only if both predicates are `true`.
|
|
655
|
+
*
|
|
656
|
+
* **When to use**
|
|
657
|
+
*
|
|
658
|
+
* Use when you want to combine `Predicate`s with AND, accepting values that
|
|
659
|
+
* satisfy multiple conditions, including refinements that narrow to an
|
|
660
|
+
* intersection.
|
|
661
|
+
*
|
|
662
|
+
* **Details**
|
|
663
|
+
*
|
|
664
|
+
* Evaluation short-circuits on the first `false`. For refinements, the output
|
|
665
|
+
* type is an intersection.
|
|
666
|
+
*
|
|
667
|
+
* **Example** (Checking both conditions)
|
|
668
|
+
*
|
|
669
|
+
* ```ts
|
|
670
|
+
* import { Predicate } from "effect"
|
|
671
|
+
*
|
|
672
|
+
* const hasAAndB = Predicate.and(
|
|
673
|
+
* Predicate.hasProperty("a"),
|
|
674
|
+
* Predicate.hasProperty("b")
|
|
675
|
+
* )
|
|
676
|
+
*
|
|
677
|
+
* const input: unknown = JSON.parse(`{"a":1,"b":"ok"}`)
|
|
678
|
+
* if (hasAAndB(input)) {
|
|
679
|
+
* // input has both properties at this point
|
|
680
|
+
* const a = input.a
|
|
681
|
+
* const b = input.b
|
|
682
|
+
*
|
|
683
|
+
* const values = [a, b] // => [1, "ok"]
|
|
684
|
+
* }
|
|
685
|
+
* ```
|
|
686
|
+
*
|
|
687
|
+
* @see {@link or}
|
|
688
|
+
* @see {@link not}
|
|
689
|
+
* @category combinators
|
|
690
|
+
* @since 2.0.0
|
|
691
|
+
*/
|
|
692
|
+
const and = dual(2, (a, b) => (data) => a(data) && b(data));
|
|
693
|
+
/**
|
|
694
|
+
* Creates a predicate that returns `true` if either predicate is `true`.
|
|
695
|
+
*
|
|
696
|
+
* **When to use**
|
|
697
|
+
*
|
|
698
|
+
* Use when you want to combine `Predicate`s with OR, accepting values that
|
|
699
|
+
* satisfy at least one condition, including refinements that narrow to a union.
|
|
700
|
+
*
|
|
701
|
+
* **Details**
|
|
702
|
+
*
|
|
703
|
+
* Evaluation short-circuits on the first `true`. For refinements, the output
|
|
704
|
+
* type is a union.
|
|
705
|
+
*
|
|
706
|
+
* **Example** (Checking either condition)
|
|
707
|
+
*
|
|
708
|
+
* ```ts
|
|
709
|
+
* import { Predicate } from "effect"
|
|
710
|
+
*
|
|
711
|
+
* const isStringOrNumber = Predicate.or(Predicate.isString, Predicate.isNumber)
|
|
712
|
+
*
|
|
713
|
+
* isStringOrNumber("a") // => true
|
|
714
|
+
* ```
|
|
715
|
+
*
|
|
716
|
+
* @see {@link and}
|
|
717
|
+
* @see {@link xor}
|
|
718
|
+
* @category combinators
|
|
719
|
+
* @since 2.0.0
|
|
720
|
+
*/
|
|
721
|
+
const or = dual(2, (a, b) => (data) => a(data) || b(data));
|
|
722
|
+
/**
|
|
723
|
+
* Creates a predicate that returns `true` if exactly one predicate is `true`.
|
|
724
|
+
*
|
|
725
|
+
* **When to use**
|
|
726
|
+
*
|
|
727
|
+
* Use when you want to combine two `Predicate`s with exclusive-or semantics.
|
|
728
|
+
*
|
|
729
|
+
* **Details**
|
|
730
|
+
*
|
|
731
|
+
* Returns `true` when results differ.
|
|
732
|
+
*
|
|
733
|
+
* **Example** (Checking exclusive-or conditions)
|
|
734
|
+
*
|
|
735
|
+
* ```ts
|
|
736
|
+
* import { Predicate } from "effect"
|
|
737
|
+
*
|
|
738
|
+
* const isEven = (n: number) => n % 2 === 0
|
|
739
|
+
* const isPositive = (n: number) => n > 0
|
|
740
|
+
* const either = Predicate.xor(isEven, isPositive)
|
|
741
|
+
*
|
|
742
|
+
* either(-2) // => true
|
|
743
|
+
* ```
|
|
744
|
+
*
|
|
745
|
+
* @see {@link or}
|
|
746
|
+
* @see {@link and}
|
|
747
|
+
* @category combinators
|
|
748
|
+
* @since 2.0.0
|
|
749
|
+
*/
|
|
750
|
+
const xor = dual(2, (a, b) => (data) => a(data) !== b(data));
|
|
751
|
+
/**
|
|
752
|
+
* Creates a predicate that returns `true` when both predicates agree.
|
|
753
|
+
*
|
|
754
|
+
* **When to use**
|
|
755
|
+
*
|
|
756
|
+
* Use when you want to check equivalence of two `Predicate`s.
|
|
757
|
+
*
|
|
758
|
+
* **Details**
|
|
759
|
+
*
|
|
760
|
+
* Returns `true` when both results are equal.
|
|
761
|
+
*
|
|
762
|
+
* **Example** (Defining equivalence)
|
|
763
|
+
*
|
|
764
|
+
* ```ts
|
|
765
|
+
* import { Predicate } from "effect"
|
|
766
|
+
*
|
|
767
|
+
* const isEven = (n: number) => n % 2 === 0
|
|
768
|
+
* const same = Predicate.eqv(isEven, isEven)
|
|
769
|
+
*
|
|
770
|
+
* same(3) // => true
|
|
771
|
+
* ```
|
|
772
|
+
*
|
|
773
|
+
* @see {@link xor}
|
|
774
|
+
* @category combinators
|
|
775
|
+
* @since 2.0.0
|
|
776
|
+
*/
|
|
777
|
+
const eqv = dual(2, (a, b) => (data) => a(data) === b(data));
|
|
778
|
+
/**
|
|
779
|
+
* Creates a predicate representing logical implication: if `antecedent`, then `consequent`.
|
|
780
|
+
*
|
|
781
|
+
* **When to use**
|
|
782
|
+
*
|
|
783
|
+
* Use when you need to encode logical implication between `Predicate` rules,
|
|
784
|
+
* where one rule only applies when a precondition holds.
|
|
785
|
+
*
|
|
786
|
+
* **Details**
|
|
787
|
+
*
|
|
788
|
+
* Models constraints like "if A then B" and returns `true` when the antecedent
|
|
789
|
+
* is `false`.
|
|
790
|
+
*
|
|
791
|
+
* **Example** (Checking implication)
|
|
792
|
+
*
|
|
793
|
+
* ```ts
|
|
794
|
+
* import { Predicate } from "effect"
|
|
795
|
+
*
|
|
796
|
+
* const isAdult = (age: number) => age >= 18
|
|
797
|
+
* const canVote = (age: number) => age >= 18
|
|
798
|
+
* const implies = Predicate.implies(isAdult, canVote)
|
|
799
|
+
*
|
|
800
|
+
* implies(16) // => true
|
|
801
|
+
* ```
|
|
802
|
+
*
|
|
803
|
+
* @see {@link and}
|
|
804
|
+
* @see {@link or}
|
|
805
|
+
* @category combinators
|
|
806
|
+
* @since 2.0.0
|
|
807
|
+
*/
|
|
808
|
+
const implies = dual(2, (antecedent, consequent) => (data) => !antecedent(data) || consequent(data));
|
|
809
|
+
/**
|
|
810
|
+
* Creates a predicate that returns `true` when neither predicate is `true`.
|
|
811
|
+
*
|
|
812
|
+
* **When to use**
|
|
813
|
+
*
|
|
814
|
+
* Use when you want to combine two `Predicate`s with logical NOR semantics.
|
|
815
|
+
*
|
|
816
|
+
* **Details**
|
|
817
|
+
*
|
|
818
|
+
* Returns the negation of `or`.
|
|
819
|
+
*
|
|
820
|
+
* **Example** (Checking NOR conditions)
|
|
821
|
+
*
|
|
822
|
+
* ```ts
|
|
823
|
+
* import { Predicate } from "effect"
|
|
824
|
+
*
|
|
825
|
+
* const neither = Predicate.nor(Predicate.isString, Predicate.isNumber)
|
|
826
|
+
*
|
|
827
|
+
* neither(true) // => true
|
|
828
|
+
* ```
|
|
829
|
+
*
|
|
830
|
+
* @see {@link or}
|
|
831
|
+
* @see {@link not}
|
|
832
|
+
* @category combinators
|
|
833
|
+
* @since 2.0.0
|
|
834
|
+
*/
|
|
835
|
+
const nor = dual(2, (a, b) => (data) => !a(data) && !b(data));
|
|
671
836
|
/**
|
|
672
|
-
*
|
|
837
|
+
* Creates a predicate that returns `true` unless both predicates are `true`.
|
|
838
|
+
*
|
|
839
|
+
* **When to use**
|
|
840
|
+
*
|
|
841
|
+
* Use when you want to combine two `Predicate`s with logical NAND semantics.
|
|
842
|
+
*
|
|
843
|
+
* **Details**
|
|
673
844
|
*
|
|
674
|
-
*
|
|
845
|
+
* Returns the negation of `and`.
|
|
846
|
+
*
|
|
847
|
+
* **Example** (Checking NAND conditions)
|
|
675
848
|
*
|
|
676
|
-
* @param pred - The predicate to test each element with.
|
|
677
|
-
* @returns A new array without the matching prefix.
|
|
678
|
-
* @example
|
|
679
849
|
* ```ts
|
|
680
|
-
* import
|
|
681
|
-
* import { dropWhile, pipe } from "@local/eff"
|
|
850
|
+
* import { Predicate } from "effect"
|
|
682
851
|
*
|
|
683
|
-
*
|
|
684
|
-
* assert.deepStrictEqual(dropWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [3, 2, 1])
|
|
852
|
+
* const notBoth = Predicate.nand(Predicate.isString, Predicate.isNumber)
|
|
685
853
|
*
|
|
686
|
-
* //
|
|
687
|
-
* assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], dropWhile((n: number) => n < 3)), [3, 2, 1])
|
|
854
|
+
* notBoth("a") // => true
|
|
688
855
|
* ```
|
|
689
|
-
*
|
|
856
|
+
*
|
|
857
|
+
* @see {@link and}
|
|
858
|
+
* @see {@link not}
|
|
859
|
+
* @category combinators
|
|
860
|
+
* @since 2.0.0
|
|
690
861
|
*/
|
|
691
|
-
const
|
|
692
|
-
|
|
862
|
+
const nand = dual(2, (a, b) => (data) => !a(data) || !b(data));
|
|
863
|
+
/**
|
|
864
|
+
* Checks whether a value is a `function`.
|
|
865
|
+
*
|
|
866
|
+
* **When to use**
|
|
867
|
+
*
|
|
868
|
+
* Use when you need a `Predicate` guard to narrow an `unknown` value to a
|
|
869
|
+
* callable function.
|
|
870
|
+
*
|
|
871
|
+
* **Details**
|
|
872
|
+
*
|
|
873
|
+
* Uses `typeof input === "function"`.
|
|
874
|
+
*
|
|
875
|
+
* **Example** (Guarding functions)
|
|
876
|
+
*
|
|
877
|
+
* ```ts
|
|
878
|
+
* import { Predicate } from "effect"
|
|
879
|
+
*
|
|
880
|
+
* const data: unknown = () => 1
|
|
881
|
+
*
|
|
882
|
+
* if (Predicate.isFunction(data)) {
|
|
883
|
+
* data() // => 1
|
|
884
|
+
* }
|
|
885
|
+
* ```
|
|
886
|
+
*
|
|
887
|
+
* @see {@link isObjectKeyword}
|
|
888
|
+
* @category guards
|
|
889
|
+
* @since 2.0.0
|
|
890
|
+
*/
|
|
891
|
+
function isFunction(input) {
|
|
892
|
+
return typeof input === "function";
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* Checks whether a value is an `object` in the JavaScript sense (objects, arrays, functions).
|
|
896
|
+
*
|
|
897
|
+
* **When to use**
|
|
898
|
+
*
|
|
899
|
+
* Use when you need a `Predicate` guard that accepts arrays and functions as
|
|
900
|
+
* well as objects.
|
|
901
|
+
*
|
|
902
|
+
* **Details**
|
|
903
|
+
*
|
|
904
|
+
* Returns `true` for arrays and functions, and `false` for `null`.
|
|
905
|
+
*
|
|
906
|
+
* **Example** (Checking object keywords)
|
|
907
|
+
*
|
|
908
|
+
* ```ts
|
|
909
|
+
* import { Predicate } from "effect"
|
|
910
|
+
*
|
|
911
|
+
* Predicate.isObjectKeyword(() => 1) // => true
|
|
912
|
+
* Predicate.isObjectKeyword(null) // => false
|
|
913
|
+
* ```
|
|
914
|
+
*
|
|
915
|
+
* @see {@link isObject}
|
|
916
|
+
* @see {@link isObjectOrArray}
|
|
917
|
+
* @category guards
|
|
918
|
+
* @since 4.0.0
|
|
919
|
+
*/
|
|
920
|
+
function isObjectKeyword(input) {
|
|
921
|
+
return typeof input === "object" && input !== null || isFunction(input);
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Checks whether a value has a given property key.
|
|
925
|
+
*
|
|
926
|
+
* **When to use**
|
|
927
|
+
*
|
|
928
|
+
* Use when you need a `Predicate` guard for property access on `unknown`
|
|
929
|
+
* values with a simple structural object check.
|
|
930
|
+
*
|
|
931
|
+
* **Details**
|
|
932
|
+
*
|
|
933
|
+
* Uses the `in` operator and `isObjectKeyword`. This does not check property
|
|
934
|
+
* value types.
|
|
935
|
+
*
|
|
936
|
+
* **Example** (Guarding object properties)
|
|
937
|
+
*
|
|
938
|
+
* ```ts
|
|
939
|
+
* import { Predicate } from "effect"
|
|
940
|
+
*
|
|
941
|
+
* const hasName = Predicate.hasProperty("name")
|
|
942
|
+
* const data: unknown = { name: "Ada" }
|
|
943
|
+
*
|
|
944
|
+
* if (hasName(data)) {
|
|
945
|
+
* data.name // => "Ada"
|
|
946
|
+
* }
|
|
947
|
+
* ```
|
|
948
|
+
*
|
|
949
|
+
* @see {@link isTagged}
|
|
950
|
+
* @see {@link isObjectKeyword}
|
|
951
|
+
* @category guards
|
|
952
|
+
* @since 2.0.0
|
|
953
|
+
*/
|
|
954
|
+
const hasProperty = dual(2, (data, property) => isObjectKeyword(data) && property in data);
|
|
955
|
+
/**
|
|
956
|
+
* Drops elements from the start while the predicate holds, returning the rest.
|
|
957
|
+
*
|
|
958
|
+
* **When to use**
|
|
959
|
+
*
|
|
960
|
+
* Use to remove a leading prefix of elements that satisfy a predicate.
|
|
961
|
+
*
|
|
962
|
+
* **Details**
|
|
963
|
+
*
|
|
964
|
+
* The predicate receives `(element, index)`.
|
|
965
|
+
*
|
|
966
|
+
* **Example** (Dropping while condition holds)
|
|
967
|
+
*
|
|
968
|
+
* ```ts
|
|
969
|
+
* import { Array } from "effect"
|
|
970
|
+
*
|
|
971
|
+
* Array.dropWhile([1, 2, 3, 4, 5], (x) => x < 4) // => [4, 5]
|
|
972
|
+
* ```
|
|
973
|
+
*
|
|
974
|
+
* @see {@link takeWhile} — keep the matching prefix instead
|
|
975
|
+
* @see {@link drop} — drop a fixed count
|
|
976
|
+
*
|
|
977
|
+
* @category getters
|
|
978
|
+
* @since 2.0.0
|
|
979
|
+
*/
|
|
980
|
+
const dropWhile = dual(2, (self, predicate) => {
|
|
981
|
+
const input = Array.isArray(self) ? self : Array.from(self);
|
|
982
|
+
const len = input.length;
|
|
693
983
|
let idx = 0;
|
|
694
|
-
while (idx < len &&
|
|
695
|
-
return
|
|
984
|
+
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
985
|
+
return input.slice(idx);
|
|
696
986
|
});
|
|
697
987
|
/**
|
|
698
|
-
* Takes
|
|
988
|
+
* Takes elements from the start while the predicate holds, stopping at the
|
|
989
|
+
* first element that fails.
|
|
990
|
+
*
|
|
991
|
+
* **When to use**
|
|
699
992
|
*
|
|
700
|
-
*
|
|
993
|
+
* Use to keep the leading elements of an iterable while each element satisfies
|
|
994
|
+
* a predicate, returning the retained prefix as an array.
|
|
701
995
|
*
|
|
702
|
-
*
|
|
703
|
-
* @returns A new array containing only the matching prefix.
|
|
704
|
-
* @example
|
|
705
|
-
* ```ts
|
|
706
|
-
* import * as assert from "node:assert"
|
|
707
|
-
* import { pipe, takeWhile } from "@local/eff"
|
|
996
|
+
* **Details**
|
|
708
997
|
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
998
|
+
* Supports refinements for type narrowing. The predicate receives
|
|
999
|
+
* `(element, index)`.
|
|
711
1000
|
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
1001
|
+
* **Example** (Taking while condition holds)
|
|
1002
|
+
*
|
|
1003
|
+
* ```ts
|
|
1004
|
+
* import { Array } from "effect"
|
|
1005
|
+
*
|
|
1006
|
+
* Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4) // => [1, 3, 2]
|
|
714
1007
|
* ```
|
|
715
|
-
*
|
|
1008
|
+
*
|
|
1009
|
+
* @see {@link take} for keeping a fixed number of leading elements
|
|
1010
|
+
* @see {@link dropWhile} for removing the matching prefix and keeping the rest
|
|
1011
|
+
* @see {@link span} for splitting the matching prefix from the remaining elements
|
|
1012
|
+
*
|
|
1013
|
+
* @category getters
|
|
1014
|
+
* @since 2.0.0
|
|
716
1015
|
*/
|
|
717
|
-
const takeWhile = dual(2, (
|
|
718
|
-
const
|
|
1016
|
+
const takeWhile = dual(2, (self, predicate) => {
|
|
1017
|
+
const input = Array.isArray(self) ? self : Array.from(self);
|
|
1018
|
+
const len = input.length;
|
|
719
1019
|
let idx = 0;
|
|
720
|
-
while (idx < len &&
|
|
721
|
-
return
|
|
1020
|
+
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
1021
|
+
return input.slice(0, idx);
|
|
722
1022
|
});
|
|
723
1023
|
|
|
724
1024
|
//#endregion
|
|
@@ -802,8 +1102,9 @@ function create$3(context) {
|
|
|
802
1102
|
* empty expression (ex: `{}` or a comment), or an empty string expression.
|
|
803
1103
|
* @param child The JSX child node to check.
|
|
804
1104
|
*/
|
|
1105
|
+
const isWhitespaceOrEmptyStringExpression = or(isWhitespaceText, isEmptyStringExpression);
|
|
805
1106
|
function isNonSubstantiveChild(child) {
|
|
806
|
-
if (
|
|
1107
|
+
if (isWhitespaceOrEmptyStringExpression(child)) return true;
|
|
807
1108
|
return child.type === AST_NODE_TYPES.JSXExpressionContainer && child.expression.type === AST_NODE_TYPES.JSXEmptyExpression;
|
|
808
1109
|
}
|
|
809
1110
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-jsx",
|
|
3
|
-
"version": "5.24.
|
|
3
|
+
"version": "5.24.1",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React Flavored JSX 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/core": "5.24.
|
|
42
|
-
"@eslint-react/eslint": "5.24.
|
|
43
|
-
"@eslint-react/jsx": "5.24.
|
|
44
|
-
"@eslint-react/shared": "5.24.
|
|
40
|
+
"@eslint-react/ast": "5.24.1",
|
|
41
|
+
"@eslint-react/core": "5.24.1",
|
|
42
|
+
"@eslint-react/eslint": "5.24.1",
|
|
43
|
+
"@eslint-react/jsx": "5.24.1",
|
|
44
|
+
"@eslint-react/shared": "5.24.1",
|
|
45
45
|
"@typescript-eslint/types": "^8.71.0",
|
|
46
46
|
"@typescript-eslint/utils": "^8.71.0"
|
|
47
47
|
},
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/react": "^19.3.0",
|
|
53
53
|
"@types/react-dom": "^19.3.0",
|
|
54
54
|
"dedent": "^1.7.2",
|
|
55
|
-
"eslint": "^10.
|
|
55
|
+
"eslint": "^10.12.0",
|
|
56
56
|
"tsdown": "^0.23.0",
|
|
57
57
|
"typescript": "6.0.3"
|
|
58
58
|
},
|