eslint-plugin-react-jsx 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.
Files changed (2) hide show
  1. package/dist/index.js +370 -73
  2. 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.0";
29
+ var version = "5.24.1";
30
30
 
31
31
  //#endregion
32
32
  //#region src/utils/create-rule.ts
@@ -246,12 +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
- function or(a, b) {
253
- return (data) => a(data) || b(data);
254
- }
255
249
  /**
256
250
  * Applies a `pipe` method's variadic arguments to an initial value from left
257
251
  * to right.
@@ -284,7 +278,7 @@ function or(a, b) {
284
278
  * (n) => n + 2,
285
279
  * (n) => n * 3
286
280
  * )
287
- * console.log(result) // 21
281
+ * result // => 21
288
282
  * ```
289
283
  *
290
284
  * @category combinators
@@ -341,16 +335,6 @@ const Class = (function() {
341
335
  return PipeableBase;
342
336
  })();
343
337
  /**
344
- * Provides small helpers for defining and reusing TypeScript functions.
345
- *
346
- * The main helpers are `pipe` and `flow` for left-to-right composition and
347
- * `dual` for APIs that support both direct and pipe-friendly call styles. The
348
- * module also contains small identity, constant, tuple, type-level, and
349
- * memoization helpers used across the library.
350
- *
351
- * @since 2.0.0
352
- */
353
- /**
354
338
  * Creates a function that can be called in data-first style or data-last
355
339
  * (`pipe`-friendly) style.
356
340
  *
@@ -375,8 +359,8 @@ const Class = (function() {
375
359
  * (self: number, that: number) => number
376
360
  * >(2, (self, that) => self + that)
377
361
  *
378
- * console.log(sum(2, 3)) // 5
379
- * console.log(pipe(2, sum(3))) // 5
362
+ * sum(2, 3) // => 5
363
+ * pipe(2, sum(3)) // => 5
380
364
  * ```
381
365
  *
382
366
  * **Example** (Defining overloads with call signatures)
@@ -389,8 +373,8 @@ const Class = (function() {
389
373
  * (self: number, that: number): number
390
374
  * } = Function.dual(2, (self: number, that: number): number => self + that)
391
375
  *
392
- * console.log(sum(2, 3)) // 5
393
- * console.log(pipe(2, sum(3))) // 5
376
+ * sum(2, 3) // => 5
377
+ * pipe(2, sum(3)) // => 5
394
378
  * ```
395
379
  *
396
380
  * **Example** (Selecting data-first or data-last style with a predicate)
@@ -406,8 +390,8 @@ const Class = (function() {
406
390
  * (self, that) => self + that
407
391
  * )
408
392
  *
409
- * console.log(sum(2, 3)) // 5
410
- * console.log(pipe(2, sum(3))) // 5
393
+ * sum(2, 3) // => 5
394
+ * pipe(2, sum(3)) // => 5
411
395
  * ```
412
396
  *
413
397
  * @category combinators
@@ -452,9 +436,8 @@ const dual = function(arity, body) {
452
436
  *
453
437
  * ```ts
454
438
  * import { identity } from "effect"
455
- * import * as assert from "node:assert"
456
439
  *
457
- * assert.deepStrictEqual(identity(5), 5)
440
+ * identity(5) // => 5
458
441
  * ```
459
442
  *
460
443
  * @category combinators
@@ -492,12 +475,11 @@ const cast = identity;
492
475
  *
493
476
  * ```ts
494
477
  * import { Function } from "effect"
495
- * import * as assert from "node:assert"
496
478
  *
497
479
  * const constNull = Function.constant(null)
498
480
  *
499
- * assert.deepStrictEqual(constNull(), null)
500
- * assert.deepStrictEqual(constNull(), null)
481
+ * constNull() // => null
482
+ * constNull() // => null
501
483
  * ```
502
484
  *
503
485
  * @category constructors
@@ -515,9 +497,8 @@ const constant = (value) => () => value;
515
497
  *
516
498
  * ```ts
517
499
  * import { Function } from "effect"
518
- * import * as assert from "node:assert"
519
500
  *
520
- * assert.deepStrictEqual(Function.constTrue(), true)
501
+ * Function.constTrue() // => true
521
502
  * ```
522
503
  *
523
504
  * @category constants
@@ -535,9 +516,8 @@ const constTrue = constant(true);
535
516
  *
536
517
  * ```ts
537
518
  * import { Function } from "effect"
538
- * import * as assert from "node:assert"
539
519
  *
540
- * assert.deepStrictEqual(Function.constFalse(), false)
520
+ * Function.constFalse() // => false
541
521
  * ```
542
522
  *
543
523
  * @category constants
@@ -555,9 +535,8 @@ const constFalse = constant(false);
555
535
  *
556
536
  * ```ts
557
537
  * import { Function } from "effect"
558
- * import * as assert from "node:assert"
559
538
  *
560
- * assert.deepStrictEqual(Function.constNull(), null)
539
+ * Function.constNull() // => null
561
540
  * ```
562
541
  *
563
542
  * @category constants
@@ -575,9 +554,8 @@ const constNull = constant(null);
575
554
  *
576
555
  * ```ts
577
556
  * import { Function } from "effect"
578
- * import * as assert from "node:assert"
579
557
  *
580
- * assert.deepStrictEqual(Function.constUndefined(), undefined)
558
+ * Function.constUndefined() // => undefined
581
559
  * ```
582
560
  *
583
561
  * @category constants
@@ -596,12 +574,11 @@ const constUndefined = constant(void 0);
596
574
  *
597
575
  * ```ts
598
576
  * import { Function } from "effect"
599
- * import * as assert from "node:assert"
600
577
  *
601
578
  * const increment = (n: number) => n + 1
602
579
  * const square = (n: number) => n * n
603
580
  *
604
- * assert.strictEqual(Function.compose(increment, square)(2), 9)
581
+ * Function.compose(increment, square)(2) // => 9
605
582
  * ```
606
583
  *
607
584
  * @see {@link flow} for composing a left-to-right sequence of functions
@@ -664,64 +641,384 @@ const absurd = (_) => {
664
641
  * name: hole<string>()
665
642
  * })
666
643
  *
667
- * console.log(typeof buildUser) // "function"
668
644
  * ```
669
645
  *
670
646
  * @category utility types
671
647
  * @since 2.0.0
672
648
  */
673
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));
674
751
  /**
675
- * Drops the longest prefix of elements from an array that satisfy the given predicate.
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**
676
759
  *
677
- * Supports both data-first and data-last (`pipe`-friendly) call styles.
760
+ * Returns `true` when both results are equal.
761
+ *
762
+ * **Example** (Defining equivalence)
678
763
  *
679
- * @param pred - The predicate to test each element with.
680
- * @returns A new array without the matching prefix.
681
- * @example
682
764
  * ```ts
683
- * import * as assert from "node:assert"
684
- * import { dropWhile, pipe } from "@local/eff"
765
+ * import { Predicate } from "effect"
685
766
  *
686
- * // data-first
687
- * assert.deepStrictEqual(dropWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [3, 2, 1])
767
+ * const isEven = (n: number) => n % 2 === 0
768
+ * const same = Predicate.eqv(isEven, isEven)
688
769
  *
689
- * // data-last
690
- * assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], dropWhile((n: number) => n < 3)), [3, 2, 1])
770
+ * same(3) // => true
691
771
  * ```
692
- * @category array
772
+ *
773
+ * @see {@link xor}
774
+ * @category combinators
775
+ * @since 2.0.0
693
776
  */
694
- const dropWhile = dual(2, (xs, pred) => {
695
- const len = xs.length;
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));
836
+ /**
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**
844
+ *
845
+ * Returns the negation of `and`.
846
+ *
847
+ * **Example** (Checking NAND conditions)
848
+ *
849
+ * ```ts
850
+ * import { Predicate } from "effect"
851
+ *
852
+ * const notBoth = Predicate.nand(Predicate.isString, Predicate.isNumber)
853
+ *
854
+ * notBoth("a") // => true
855
+ * ```
856
+ *
857
+ * @see {@link and}
858
+ * @see {@link not}
859
+ * @category combinators
860
+ * @since 2.0.0
861
+ */
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;
696
983
  let idx = 0;
697
- while (idx < len && pred(xs[idx])) idx++;
698
- return xs.slice(idx);
984
+ while (idx < len && predicate(input[idx], idx)) idx++;
985
+ return input.slice(idx);
699
986
  });
700
987
  /**
701
- * Takes the longest prefix of elements from an array that satisfy the given predicate.
988
+ * Takes elements from the start while the predicate holds, stopping at the
989
+ * first element that fails.
990
+ *
991
+ * **When to use**
702
992
  *
703
- * Supports both data-first and data-last (`pipe`-friendly) call styles.
993
+ * Use to keep the leading elements of an iterable while each element satisfies
994
+ * a predicate, returning the retained prefix as an array.
704
995
  *
705
- * @param pred - The predicate to test each element with.
706
- * @returns A new array containing only the matching prefix.
707
- * @example
708
- * ```ts
709
- * import * as assert from "node:assert"
710
- * import { pipe, takeWhile } from "@local/eff"
996
+ * **Details**
711
997
  *
712
- * // data-first
713
- * assert.deepStrictEqual(takeWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [1, 2])
998
+ * Supports refinements for type narrowing. The predicate receives
999
+ * `(element, index)`.
714
1000
  *
715
- * // data-last
716
- * assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], takeWhile((n: number) => n < 3)), [1, 2])
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]
717
1007
  * ```
718
- * @category array
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
719
1015
  */
720
- const takeWhile = dual(2, (xs, pred) => {
721
- const len = xs.length;
1016
+ const takeWhile = dual(2, (self, predicate) => {
1017
+ const input = Array.isArray(self) ? self : Array.from(self);
1018
+ const len = input.length;
722
1019
  let idx = 0;
723
- while (idx < len && pred(xs[idx])) idx++;
724
- return xs.slice(0, idx);
1020
+ while (idx < len && predicate(input[idx], idx)) idx++;
1021
+ return input.slice(0, idx);
725
1022
  });
726
1023
 
727
1024
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-jsx",
3
- "version": "5.24.0",
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.0",
41
- "@eslint-react/core": "5.24.0",
42
- "@eslint-react/eslint": "5.24.0",
43
- "@eslint-react/jsx": "5.24.0",
44
- "@eslint-react/shared": "5.24.0",
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.11.0",
55
+ "eslint": "^10.12.0",
56
56
  "tsdown": "^0.23.0",
57
57
  "typescript": "6.0.3"
58
58
  },