@eslint-react/jsx 5.17.0 → 5.17.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.d.ts CHANGED
@@ -256,6 +256,25 @@ declare function hasChildren(element: TSESTreeJSXElementLike): boolean;
256
256
  */
257
257
  declare function hasEveryAttribute(context: RuleContext, element: TSESTree.JSXElement, names: string[]): boolean;
258
258
  //#endregion
259
+ //#region src/is-attribute.d.ts
260
+ /**
261
+ * Check whether a node is a `JSXAttribute` with the given name.
262
+ *
263
+ * Only plain identifier names are matched (ex: `className`); namespaced
264
+ * attributes (ex: `xml:space`) do not match.
265
+ *
266
+ * Supports both data-first and data-last (curried) call styles:
267
+ * - `isAttribute(node, "className")`
268
+ * - `isAttribute("className")(node)`.
269
+ * @param node The AST node to test.
270
+ * @param name The attribute name to match (ex: "className").
271
+ * @returns `true` when the node is a `JSXAttribute` named `name`.
272
+ */
273
+ declare const isAttribute: {
274
+ (name: string): (node: TSESTree.Node) => node is TSESTree.JSXAttribute;
275
+ (node: TSESTree.Node, name: string): node is TSESTree.JSXAttribute;
276
+ };
277
+ //#endregion
259
278
  //#region src/is-element.d.ts
260
279
  /**
261
280
  * A test that determines whether a JSX element matches.
@@ -393,4 +412,4 @@ declare const DEFAULT_JSX_DETECTION_HINT: JsxDetectionHint;
393
412
  */
394
413
  declare function resolveAttributeValue(context: RuleContext, attribute: TSESTreeJSXAttributeLike): JsxAttributeValue;
395
414
  //#endregion
396
- export { DEFAULT_JSX_DETECTION_HINT, ElementTest, JsxAttributeValue, JsxDetectionHint, collapseMultilineText, findAttribute, findParentAttribute, getAttributeName, getAttributeStaticValue, getAttributeValue, getChildren, getElementFullType, getElementSelfType, hasAnyAttribute, hasAttribute, hasChildren, hasEveryAttribute, isElement, isEmptyStringExpression, isFragmentElement, isHostElement, isWhitespace, isWhitespaceText, resolveAttributeValue };
415
+ export { DEFAULT_JSX_DETECTION_HINT, ElementTest, JsxAttributeValue, JsxDetectionHint, collapseMultilineText, findAttribute, findParentAttribute, getAttributeName, getAttributeStaticValue, getAttributeValue, getChildren, getElementFullType, getElementSelfType, hasAnyAttribute, hasAttribute, hasChildren, hasEveryAttribute, isAttribute, isElement, isEmptyStringExpression, isFragmentElement, isHostElement, isWhitespace, isWhitespaceText, resolveAttributeValue };
package/dist/index.js CHANGED
@@ -465,6 +465,499 @@ function hasEveryAttribute(context, element, names) {
465
465
  return names.every((name) => findAttribute(context, element, name) != null);
466
466
  }
467
467
 
468
+ //#endregion
469
+ //#region ../../.pkgs/eff/dist/index.js
470
+ /**
471
+ * Applies a `pipe` method's variadic arguments to an initial value from left
472
+ * to right.
473
+ *
474
+ * **When to use**
475
+ *
476
+ * Use to implement a custom `.pipe(...)` method from JavaScript's `arguments`
477
+ * object.
478
+ *
479
+ * **Details**
480
+ *
481
+ * This helper is intended for implementing `Pipeable.pipe` methods that
482
+ * receive JavaScript's `arguments` object. With no functions it returns the
483
+ * original value; otherwise it feeds each result into the next function.
484
+ *
485
+ * **Example** (Implementing a pipe method)
486
+ *
487
+ * ```ts
488
+ * import { Pipeable } from "effect"
489
+ *
490
+ * class NumberBox {
491
+ * constructor(readonly value: number) {}
492
+ *
493
+ * pipe(..._fns: ReadonlyArray<(value: number) => number>): number {
494
+ * return Pipeable.pipeArguments(this.value, arguments) as number
495
+ * }
496
+ * }
497
+ *
498
+ * const result = new NumberBox(5).pipe(
499
+ * (n) => n + 2,
500
+ * (n) => n * 3
501
+ * )
502
+ * console.log(result) // 21
503
+ * ```
504
+ *
505
+ * @category combinators
506
+ * @since 2.0.0
507
+ */
508
+ const pipeArguments = (self, args) => {
509
+ switch (args.length) {
510
+ case 0: return self;
511
+ case 1: return args[0](self);
512
+ case 2: return args[1](args[0](self));
513
+ case 3: return args[2](args[1](args[0](self)));
514
+ case 4: return args[3](args[2](args[1](args[0](self))));
515
+ case 5: return args[4](args[3](args[2](args[1](args[0](self)))));
516
+ case 6: return args[5](args[4](args[3](args[2](args[1](args[0](self))))));
517
+ case 7: return args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))));
518
+ case 8: return args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self))))))));
519
+ case 9: return args[8](args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))))));
520
+ default: {
521
+ let ret = self;
522
+ for (let i = 0, len = args.length; i < len; i++) ret = args[i](ret);
523
+ return ret;
524
+ }
525
+ }
526
+ };
527
+ /**
528
+ * Reusable prototype that implements `Pipeable.pipe`.
529
+ *
530
+ * **When to use**
531
+ *
532
+ * Use when classes or object prototypes can reuse this value when they need the
533
+ * standard pipe implementation backed by `pipeArguments`.
534
+ *
535
+ * @category prototypes
536
+ * @since 3.15.0
537
+ */
538
+ const Prototype = { pipe() {
539
+ return pipeArguments(this, arguments);
540
+ } };
541
+ /**
542
+ * Provides a base constructor whose instances implement the standard `Pipeable.pipe`
543
+ * method.
544
+ *
545
+ * **When to use**
546
+ *
547
+ * Use when you need to define a class that supports Effect-style method
548
+ * chaining through `.pipe(...)`.
549
+ *
550
+ * @category constructors
551
+ * @since 3.15.0
552
+ */
553
+ const Class = (function() {
554
+ function PipeableBase() {}
555
+ PipeableBase.prototype = Prototype;
556
+ return PipeableBase;
557
+ })();
558
+ /**
559
+ * Provides small helpers for defining and reusing TypeScript functions.
560
+ *
561
+ * The main helpers are `pipe` and `flow` for left-to-right composition and
562
+ * `dual` for APIs that support both direct and pipe-friendly call styles. The
563
+ * module also contains small identity, constant, tuple, type-level, and
564
+ * memoization helpers used across the library.
565
+ *
566
+ * @since 2.0.0
567
+ */
568
+ /**
569
+ * Creates a function that can be called in data-first style or data-last
570
+ * (`pipe`-friendly) style.
571
+ *
572
+ * **When to use**
573
+ *
574
+ * Use to expose one implementation through both direct and `pipe`-friendly
575
+ * call styles.
576
+ *
577
+ * **Details**
578
+ *
579
+ * Pass either the arity of the uncurried function or a predicate that decides
580
+ * whether the current call is data-first. Arity is the common case. Use a
581
+ * predicate when optional arguments make arity ambiguous.
582
+ *
583
+ * **Example** (Selecting data-first or data-last style by arity)
584
+ *
585
+ * ```ts
586
+ * import { Function, pipe } from "effect"
587
+ *
588
+ * const sum = Function.dual<
589
+ * (that: number) => (self: number) => number,
590
+ * (self: number, that: number) => number
591
+ * >(2, (self, that) => self + that)
592
+ *
593
+ * console.log(sum(2, 3)) // 5
594
+ * console.log(pipe(2, sum(3))) // 5
595
+ * ```
596
+ *
597
+ * **Example** (Defining overloads with call signatures)
598
+ *
599
+ * ```ts
600
+ * import { Function, pipe } from "effect"
601
+ *
602
+ * const sum: {
603
+ * (that: number): (self: number) => number
604
+ * (self: number, that: number): number
605
+ * } = Function.dual(2, (self: number, that: number): number => self + that)
606
+ *
607
+ * console.log(sum(2, 3)) // 5
608
+ * console.log(pipe(2, sum(3))) // 5
609
+ * ```
610
+ *
611
+ * **Example** (Selecting data-first or data-last style with a predicate)
612
+ *
613
+ * ```ts
614
+ * import { Function, pipe } from "effect"
615
+ *
616
+ * const sum = Function.dual<
617
+ * (that: number) => (self: number) => number,
618
+ * (self: number, that: number) => number
619
+ * >(
620
+ * (args) => args.length === 2,
621
+ * (self, that) => self + that
622
+ * )
623
+ *
624
+ * console.log(sum(2, 3)) // 5
625
+ * console.log(pipe(2, sum(3))) // 5
626
+ * ```
627
+ *
628
+ * @category combinators
629
+ * @since 2.0.0
630
+ */
631
+ const dual = function(arity, body) {
632
+ if (typeof arity === "function") return function() {
633
+ return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
634
+ };
635
+ switch (arity) {
636
+ case 0:
637
+ case 1: throw new RangeError(`Invalid arity ${arity}`);
638
+ case 2: return function(a, b) {
639
+ if (arguments.length >= 2) return body(a, b);
640
+ return function(self) {
641
+ return body(self, a);
642
+ };
643
+ };
644
+ case 3: return function(a, b, c) {
645
+ if (arguments.length >= 3) return body(a, b, c);
646
+ return function(self) {
647
+ return body(self, a, b);
648
+ };
649
+ };
650
+ default: return function() {
651
+ if (arguments.length >= arity) return body.apply(this, arguments);
652
+ const args = arguments;
653
+ return function(self) {
654
+ return body(self, ...args);
655
+ };
656
+ };
657
+ }
658
+ };
659
+ /**
660
+ * Returns its input argument unchanged.
661
+ *
662
+ * **When to use**
663
+ *
664
+ * Use to return a value unchanged where a function is required.
665
+ *
666
+ * **Example** (Returning the same value)
667
+ *
668
+ * ```ts
669
+ * import { identity } from "effect"
670
+ * import * as assert from "node:assert"
671
+ *
672
+ * assert.deepStrictEqual(identity(5), 5)
673
+ * ```
674
+ *
675
+ * @category combinators
676
+ * @since 2.0.0
677
+ */
678
+ const identity = (a) => a;
679
+ /**
680
+ * Returns the input value with a different static type.
681
+ *
682
+ * **When to use**
683
+ *
684
+ * Use when you need an explicit type-level cast and accept that the value is
685
+ * returned unchanged at runtime.
686
+ *
687
+ * **Gotchas**
688
+ *
689
+ * This is a type-level cast only; it performs no runtime validation or
690
+ * conversion.
691
+ *
692
+ * @see {@link satisfies} for checking assignability without changing the resulting type
693
+ *
694
+ * @category utility types
695
+ * @since 4.0.0
696
+ */
697
+ const cast = identity;
698
+ /**
699
+ * Creates a zero-argument function that always returns the provided value.
700
+ *
701
+ * **When to use**
702
+ *
703
+ * Use when you need a thunk or callback that returns the same value on every
704
+ * invocation.
705
+ *
706
+ * **Example** (Creating a constant thunk)
707
+ *
708
+ * ```ts
709
+ * import { Function } from "effect"
710
+ * import * as assert from "node:assert"
711
+ *
712
+ * const constNull = Function.constant(null)
713
+ *
714
+ * assert.deepStrictEqual(constNull(), null)
715
+ * assert.deepStrictEqual(constNull(), null)
716
+ * ```
717
+ *
718
+ * @category constructors
719
+ * @since 2.0.0
720
+ */
721
+ const constant = (value) => () => value;
722
+ /**
723
+ * Returns `true` when called.
724
+ *
725
+ * **When to use**
726
+ *
727
+ * Use when you need a thunk that returns `true` on every invocation.
728
+ *
729
+ * **Example** (Returning true from a thunk)
730
+ *
731
+ * ```ts
732
+ * import { Function } from "effect"
733
+ * import * as assert from "node:assert"
734
+ *
735
+ * assert.deepStrictEqual(Function.constTrue(), true)
736
+ * ```
737
+ *
738
+ * @category constants
739
+ * @since 2.0.0
740
+ */
741
+ const constTrue = constant(true);
742
+ /**
743
+ * Returns `false` when called.
744
+ *
745
+ * **When to use**
746
+ *
747
+ * Use when you need a thunk that returns `false` on every invocation.
748
+ *
749
+ * **Example** (Returning false from a thunk)
750
+ *
751
+ * ```ts
752
+ * import { Function } from "effect"
753
+ * import * as assert from "node:assert"
754
+ *
755
+ * assert.deepStrictEqual(Function.constFalse(), false)
756
+ * ```
757
+ *
758
+ * @category constants
759
+ * @since 2.0.0
760
+ */
761
+ const constFalse = constant(false);
762
+ /**
763
+ * Returns `null` when called.
764
+ *
765
+ * **When to use**
766
+ *
767
+ * Use when you need a thunk that returns `null` on every invocation.
768
+ *
769
+ * **Example** (Returning null from a thunk)
770
+ *
771
+ * ```ts
772
+ * import { Function } from "effect"
773
+ * import * as assert from "node:assert"
774
+ *
775
+ * assert.deepStrictEqual(Function.constNull(), null)
776
+ * ```
777
+ *
778
+ * @category constants
779
+ * @since 2.0.0
780
+ */
781
+ const constNull = constant(null);
782
+ /**
783
+ * Returns `undefined` when called.
784
+ *
785
+ * **When to use**
786
+ *
787
+ * Use when you need a thunk that returns `undefined` on every invocation.
788
+ *
789
+ * **Example** (Returning undefined from a thunk)
790
+ *
791
+ * ```ts
792
+ * import { Function } from "effect"
793
+ * import * as assert from "node:assert"
794
+ *
795
+ * assert.deepStrictEqual(Function.constUndefined(), undefined)
796
+ * ```
797
+ *
798
+ * @category constants
799
+ * @since 2.0.0
800
+ */
801
+ const constUndefined = constant(void 0);
802
+ /**
803
+ * 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`.
804
+ * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
805
+ *
806
+ * **When to use**
807
+ *
808
+ * Use to compose exactly two unary functions into a reusable unary function.
809
+ *
810
+ * **Example** (Composing two functions)
811
+ *
812
+ * ```ts
813
+ * import { Function } from "effect"
814
+ * import * as assert from "node:assert"
815
+ *
816
+ * const increment = (n: number) => n + 1
817
+ * const square = (n: number) => n * n
818
+ *
819
+ * assert.strictEqual(Function.compose(increment, square)(2), 9)
820
+ * ```
821
+ *
822
+ * @see {@link flow} for composing a left-to-right sequence of functions
823
+ * @see {@link pipe} for applying a value through a left-to-right sequence immediately
824
+ *
825
+ * @category combinators
826
+ * @since 2.0.0
827
+ */
828
+ const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
829
+ /**
830
+ * Marks an impossible branch by accepting a `never` value and returning any
831
+ * type.
832
+ *
833
+ * **When to use**
834
+ *
835
+ * Use when you need a return value in a branch that exhaustive checks prove
836
+ * cannot be reached.
837
+ *
838
+ * **Gotchas**
839
+ *
840
+ * Calling `absurd` throws, because a value of type `never` should be
841
+ * impossible at runtime.
842
+ *
843
+ * **Example** (Handling impossible values)
844
+ *
845
+ * ```ts
846
+ * import { absurd } from "effect"
847
+ *
848
+ * const handleNever = (value: never) => {
849
+ * return absurd(value) // This will throw an error if called
850
+ * }
851
+ * ```
852
+ *
853
+ * @category utility types
854
+ * @since 2.0.0
855
+ */
856
+ const absurd = (_) => {
857
+ throw new Error("Called `absurd` function which should be uncallable");
858
+ };
859
+ /**
860
+ * Creates a compile-time placeholder for a value of any type.
861
+ *
862
+ * **When to use**
863
+ *
864
+ * Use as a temporary typed placeholder while developing incomplete code.
865
+ *
866
+ * **Gotchas**
867
+ *
868
+ * `hole` is intended for temporary development use. If the placeholder is
869
+ * evaluated at runtime, it throws.
870
+ *
871
+ * **Example** (Creating a development placeholder)
872
+ *
873
+ * ```ts
874
+ * import { hole } from "effect"
875
+ *
876
+ * // Intentionally not called: `hole` throws if the placeholder is evaluated.
877
+ * const buildUser = (id: number): { readonly id: number; readonly name: string } => ({
878
+ * id,
879
+ * name: hole<string>()
880
+ * })
881
+ *
882
+ * console.log(typeof buildUser) // "function"
883
+ * ```
884
+ *
885
+ * @category utility types
886
+ * @since 2.0.0
887
+ */
888
+ const hole = cast(absurd);
889
+ /**
890
+ * Drops the longest prefix of elements from an array that satisfy the given predicate.
891
+ *
892
+ * Supports both data-first and data-last (`pipe`-friendly) call styles.
893
+ *
894
+ * @param pred - The predicate to test each element with.
895
+ * @returns A new array without the matching prefix.
896
+ * @example
897
+ * ```ts
898
+ * import * as assert from "node:assert"
899
+ * import { dropWhile, pipe } from "@local/eff"
900
+ *
901
+ * // data-first
902
+ * assert.deepStrictEqual(dropWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [3, 2, 1])
903
+ *
904
+ * // data-last
905
+ * assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], dropWhile((n: number) => n < 3)), [3, 2, 1])
906
+ * ```
907
+ * @category array
908
+ */
909
+ const dropWhile = dual(2, (xs, pred) => {
910
+ const len = xs.length;
911
+ let idx = 0;
912
+ while (idx < len && pred(xs[idx])) idx++;
913
+ return xs.slice(idx);
914
+ });
915
+ /**
916
+ * Takes the longest prefix of elements from an array that satisfy the given predicate.
917
+ *
918
+ * Supports both data-first and data-last (`pipe`-friendly) call styles.
919
+ *
920
+ * @param pred - The predicate to test each element with.
921
+ * @returns A new array containing only the matching prefix.
922
+ * @example
923
+ * ```ts
924
+ * import * as assert from "node:assert"
925
+ * import { pipe, takeWhile } from "@local/eff"
926
+ *
927
+ * // data-first
928
+ * assert.deepStrictEqual(takeWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [1, 2])
929
+ *
930
+ * // data-last
931
+ * assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], takeWhile((n: number) => n < 3)), [1, 2])
932
+ * ```
933
+ * @category array
934
+ */
935
+ const takeWhile = dual(2, (xs, pred) => {
936
+ const len = xs.length;
937
+ let idx = 0;
938
+ while (idx < len && pred(xs[idx])) idx++;
939
+ return xs.slice(0, idx);
940
+ });
941
+
942
+ //#endregion
943
+ //#region src/is-attribute.ts
944
+ /**
945
+ * Check whether a node is a `JSXAttribute` with the given name.
946
+ *
947
+ * Only plain identifier names are matched (ex: `className`); namespaced
948
+ * attributes (ex: `xml:space`) do not match.
949
+ *
950
+ * Supports both data-first and data-last (curried) call styles:
951
+ * - `isAttribute(node, "className")`
952
+ * - `isAttribute("className")(node)`.
953
+ * @param node The AST node to test.
954
+ * @param name The attribute name to match (ex: "className").
955
+ * @returns `true` when the node is a `JSXAttribute` named `name`.
956
+ */
957
+ const isAttribute = dual(2, (node, name) => {
958
+ return node.type === AST_NODE_TYPES.JSXAttribute && node.name.type === AST_NODE_TYPES.JSXIdentifier && node.name.name === name;
959
+ });
960
+
468
961
  //#endregion
469
962
  //#region src/is-element.ts
470
963
  /**
@@ -563,4 +1056,4 @@ const JsxDetectionHint = {
563
1056
  const DEFAULT_JSX_DETECTION_HINT = 0n | JsxDetectionHint.DoNotIncludeJsxWithNumberValue | JsxDetectionHint.DoNotIncludeJsxWithBigIntValue | JsxDetectionHint.DoNotIncludeJsxWithBooleanValue | JsxDetectionHint.DoNotIncludeJsxWithStringValue | JsxDetectionHint.DoNotIncludeJsxWithUndefinedValue;
564
1057
 
565
1058
  //#endregion
566
- export { DEFAULT_JSX_DETECTION_HINT, JsxDetectionHint, collapseMultilineText, findAttribute, findParentAttribute, getAttributeName, getAttributeStaticValue, getAttributeValue, getChildren, getElementFullType, getElementSelfType, hasAnyAttribute, hasAttribute, hasChildren, hasEveryAttribute, isElement, isEmptyStringExpression, isFragmentElement, isHostElement, isWhitespace, isWhitespaceText, resolveAttributeValue };
1059
+ export { DEFAULT_JSX_DETECTION_HINT, JsxDetectionHint, collapseMultilineText, findAttribute, findParentAttribute, getAttributeName, getAttributeStaticValue, getAttributeValue, getChildren, getElementFullType, getElementSelfType, hasAnyAttribute, hasAttribute, hasChildren, hasEveryAttribute, isAttribute, isElement, isEmptyStringExpression, isFragmentElement, isHostElement, isWhitespace, isWhitespaceText, resolveAttributeValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/jsx",
3
- "version": "5.17.0",
3
+ "version": "5.17.1",
4
4
  "description": "ESLint React's TSESTree JSX utility module for static analysis of JSX patterns.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -32,17 +32,17 @@
32
32
  "@typescript-eslint/types": "^8.64.0",
33
33
  "@typescript-eslint/utils": "^8.64.0",
34
34
  "ts-pattern": "^5.9.0",
35
- "@eslint-react/ast": "5.17.0",
36
- "@eslint-react/eslint": "5.17.0",
37
- "@eslint-react/shared": "5.17.0",
38
- "@eslint-react/var": "5.17.0"
35
+ "@eslint-react/ast": "5.17.1",
36
+ "@eslint-react/shared": "5.17.1",
37
+ "@eslint-react/var": "5.17.1",
38
+ "@eslint-react/eslint": "5.17.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "eslint": "^10.7.0",
42
- "tsdown": "^0.22.7",
42
+ "tsdown": "^0.22.8",
43
43
  "typescript": "6.0.3",
44
- "@local/eff": "0.0.0",
45
- "@local/configs": "0.0.0"
44
+ "@local/configs": "0.0.0",
45
+ "@local/eff": "0.0.0"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "eslint": "*",