eslint-plugin-react-dom 5.24.0-beta.0 → 5.24.0-beta.2

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 +492 -9
  2. package/package.json +7 -6
package/dist/index.js CHANGED
@@ -6,7 +6,6 @@ import { Check, Extract } from "@eslint-react/ast";
6
6
  import { createImportLookup } from "@eslint-react/var";
7
7
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
8
8
  import { compare } from "compare-versions";
9
- import { P, isMatching } from "ts-pattern";
10
9
 
11
10
  //#region \0rolldown/runtime.js
12
11
  var __defProp = Object.defineProperty;
@@ -27,7 +26,7 @@ var __exportAll = (all, no_symbols) => {
27
26
  //#endregion
28
27
  //#region package.json
29
28
  var name$2 = "eslint-plugin-react-dom";
30
- var version = "5.24.0-beta.0";
29
+ var version = "5.24.0-beta.2";
31
30
 
32
31
  //#endregion
33
32
  //#region src/utils/create-rule.ts
@@ -213,6 +212,490 @@ function buildFix$2(context, node) {
213
212
  };
214
213
  }
215
214
 
215
+ //#endregion
216
+ //#region ../../.pkgs/eff/dist/index.js
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
+ * Applies a `pipe` method's variadic arguments to an initial value from left
229
+ * to right.
230
+ *
231
+ * **When to use**
232
+ *
233
+ * Use to implement a custom `.pipe(...)` method from JavaScript's `arguments`
234
+ * object.
235
+ *
236
+ * **Details**
237
+ *
238
+ * This helper is intended for implementing `Pipeable.pipe` methods that
239
+ * receive JavaScript's `arguments` object. With no functions it returns the
240
+ * original value; otherwise it feeds each result into the next function.
241
+ *
242
+ * **Example** (Implementing a pipe method)
243
+ *
244
+ * ```ts
245
+ * import { Pipeable } from "effect"
246
+ *
247
+ * class NumberBox {
248
+ * constructor(readonly value: number) {}
249
+ *
250
+ * pipe(..._fns: ReadonlyArray<(value: number) => number>): number {
251
+ * return Pipeable.pipeArguments(this.value, arguments) as number
252
+ * }
253
+ * }
254
+ *
255
+ * const result = new NumberBox(5).pipe(
256
+ * (n) => n + 2,
257
+ * (n) => n * 3
258
+ * )
259
+ * console.log(result) // 21
260
+ * ```
261
+ *
262
+ * @category combinators
263
+ * @since 2.0.0
264
+ */
265
+ const pipeArguments = (self, args) => {
266
+ switch (args.length) {
267
+ case 0: return self;
268
+ case 1: return args[0](self);
269
+ case 2: return args[1](args[0](self));
270
+ case 3: return args[2](args[1](args[0](self)));
271
+ case 4: return args[3](args[2](args[1](args[0](self))));
272
+ case 5: return args[4](args[3](args[2](args[1](args[0](self)))));
273
+ case 6: return args[5](args[4](args[3](args[2](args[1](args[0](self))))));
274
+ case 7: return args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))));
275
+ case 8: return args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self))))))));
276
+ case 9: return args[8](args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))))));
277
+ default: {
278
+ let ret = self;
279
+ for (let i = 0, len = args.length; i < len; i++) ret = args[i](ret);
280
+ return ret;
281
+ }
282
+ }
283
+ };
284
+ /**
285
+ * Reusable prototype that implements `Pipeable.pipe`.
286
+ *
287
+ * **When to use**
288
+ *
289
+ * Use when classes or object prototypes can reuse this value when they need the
290
+ * standard pipe implementation backed by `pipeArguments`.
291
+ *
292
+ * @category prototypes
293
+ * @since 3.15.0
294
+ */
295
+ const Prototype = { pipe() {
296
+ return pipeArguments(this, arguments);
297
+ } };
298
+ /**
299
+ * Provides a base constructor whose instances implement the standard `Pipeable.pipe`
300
+ * method.
301
+ *
302
+ * **When to use**
303
+ *
304
+ * Use when you need to define a class that supports Effect-style method
305
+ * chaining through `.pipe(...)`.
306
+ *
307
+ * @category constructors
308
+ * @since 3.15.0
309
+ */
310
+ const Class = (function() {
311
+ function PipeableBase() {}
312
+ PipeableBase.prototype = Prototype;
313
+ return PipeableBase;
314
+ })();
315
+ /**
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
+ * Creates a function that can be called in data-first style or data-last
327
+ * (`pipe`-friendly) style.
328
+ *
329
+ * **When to use**
330
+ *
331
+ * Use to expose one implementation through both direct and `pipe`-friendly
332
+ * call styles.
333
+ *
334
+ * **Details**
335
+ *
336
+ * Pass either the arity of the uncurried function or a predicate that decides
337
+ * whether the current call is data-first. Arity is the common case. Use a
338
+ * predicate when optional arguments make arity ambiguous.
339
+ *
340
+ * **Example** (Selecting data-first or data-last style by arity)
341
+ *
342
+ * ```ts
343
+ * import { Function, pipe } from "effect"
344
+ *
345
+ * const sum = Function.dual<
346
+ * (that: number) => (self: number) => number,
347
+ * (self: number, that: number) => number
348
+ * >(2, (self, that) => self + that)
349
+ *
350
+ * console.log(sum(2, 3)) // 5
351
+ * console.log(pipe(2, sum(3))) // 5
352
+ * ```
353
+ *
354
+ * **Example** (Defining overloads with call signatures)
355
+ *
356
+ * ```ts
357
+ * import { Function, pipe } from "effect"
358
+ *
359
+ * const sum: {
360
+ * (that: number): (self: number) => number
361
+ * (self: number, that: number): number
362
+ * } = Function.dual(2, (self: number, that: number): number => self + that)
363
+ *
364
+ * console.log(sum(2, 3)) // 5
365
+ * console.log(pipe(2, sum(3))) // 5
366
+ * ```
367
+ *
368
+ * **Example** (Selecting data-first or data-last style with a predicate)
369
+ *
370
+ * ```ts
371
+ * import { Function, pipe } from "effect"
372
+ *
373
+ * const sum = Function.dual<
374
+ * (that: number) => (self: number) => number,
375
+ * (self: number, that: number) => number
376
+ * >(
377
+ * (args) => args.length === 2,
378
+ * (self, that) => self + that
379
+ * )
380
+ *
381
+ * console.log(sum(2, 3)) // 5
382
+ * console.log(pipe(2, sum(3))) // 5
383
+ * ```
384
+ *
385
+ * @category combinators
386
+ * @since 2.0.0
387
+ */
388
+ const dual = function(arity, body) {
389
+ if (typeof arity === "function") return function() {
390
+ return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
391
+ };
392
+ switch (arity) {
393
+ case 0:
394
+ case 1: throw new RangeError(`Invalid arity ${arity}`);
395
+ case 2: return function(a, b) {
396
+ if (arguments.length >= 2) return body(a, b);
397
+ return function(self) {
398
+ return body(self, a);
399
+ };
400
+ };
401
+ case 3: return function(a, b, c) {
402
+ if (arguments.length >= 3) return body(a, b, c);
403
+ return function(self) {
404
+ return body(self, a, b);
405
+ };
406
+ };
407
+ default: return function() {
408
+ if (arguments.length >= arity) return body.apply(this, arguments);
409
+ const args = arguments;
410
+ return function(self) {
411
+ return body(self, ...args);
412
+ };
413
+ };
414
+ }
415
+ };
416
+ /**
417
+ * Returns its input argument unchanged.
418
+ *
419
+ * **When to use**
420
+ *
421
+ * Use to return a value unchanged where a function is required.
422
+ *
423
+ * **Example** (Returning the same value)
424
+ *
425
+ * ```ts
426
+ * import { identity } from "effect"
427
+ * import * as assert from "node:assert"
428
+ *
429
+ * assert.deepStrictEqual(identity(5), 5)
430
+ * ```
431
+ *
432
+ * @category combinators
433
+ * @since 2.0.0
434
+ */
435
+ const identity = (a) => a;
436
+ /**
437
+ * Returns the input value with a different static type.
438
+ *
439
+ * **When to use**
440
+ *
441
+ * Use when you need an explicit type-level cast and accept that the value is
442
+ * returned unchanged at runtime.
443
+ *
444
+ * **Gotchas**
445
+ *
446
+ * This is a type-level cast only; it performs no runtime validation or
447
+ * conversion.
448
+ *
449
+ * @see {@link satisfies} for checking assignability without changing the resulting type
450
+ *
451
+ * @category utility types
452
+ * @since 4.0.0
453
+ */
454
+ const cast = identity;
455
+ /**
456
+ * Creates a zero-argument function that always returns the provided value.
457
+ *
458
+ * **When to use**
459
+ *
460
+ * Use when you need a thunk or callback that returns the same value on every
461
+ * invocation.
462
+ *
463
+ * **Example** (Creating a constant thunk)
464
+ *
465
+ * ```ts
466
+ * import { Function } from "effect"
467
+ * import * as assert from "node:assert"
468
+ *
469
+ * const constNull = Function.constant(null)
470
+ *
471
+ * assert.deepStrictEqual(constNull(), null)
472
+ * assert.deepStrictEqual(constNull(), null)
473
+ * ```
474
+ *
475
+ * @category constructors
476
+ * @since 2.0.0
477
+ */
478
+ const constant = (value) => () => value;
479
+ /**
480
+ * Returns `true` when called.
481
+ *
482
+ * **When to use**
483
+ *
484
+ * Use when you need a thunk that returns `true` on every invocation.
485
+ *
486
+ * **Example** (Returning true from a thunk)
487
+ *
488
+ * ```ts
489
+ * import { Function } from "effect"
490
+ * import * as assert from "node:assert"
491
+ *
492
+ * assert.deepStrictEqual(Function.constTrue(), true)
493
+ * ```
494
+ *
495
+ * @category constants
496
+ * @since 2.0.0
497
+ */
498
+ const constTrue = constant(true);
499
+ /**
500
+ * Returns `false` when called.
501
+ *
502
+ * **When to use**
503
+ *
504
+ * Use when you need a thunk that returns `false` on every invocation.
505
+ *
506
+ * **Example** (Returning false from a thunk)
507
+ *
508
+ * ```ts
509
+ * import { Function } from "effect"
510
+ * import * as assert from "node:assert"
511
+ *
512
+ * assert.deepStrictEqual(Function.constFalse(), false)
513
+ * ```
514
+ *
515
+ * @category constants
516
+ * @since 2.0.0
517
+ */
518
+ const constFalse = constant(false);
519
+ /**
520
+ * Returns `null` when called.
521
+ *
522
+ * **When to use**
523
+ *
524
+ * Use when you need a thunk that returns `null` on every invocation.
525
+ *
526
+ * **Example** (Returning null from a thunk)
527
+ *
528
+ * ```ts
529
+ * import { Function } from "effect"
530
+ * import * as assert from "node:assert"
531
+ *
532
+ * assert.deepStrictEqual(Function.constNull(), null)
533
+ * ```
534
+ *
535
+ * @category constants
536
+ * @since 2.0.0
537
+ */
538
+ const constNull = constant(null);
539
+ /**
540
+ * Returns `undefined` when called.
541
+ *
542
+ * **When to use**
543
+ *
544
+ * Use when you need a thunk that returns `undefined` on every invocation.
545
+ *
546
+ * **Example** (Returning undefined from a thunk)
547
+ *
548
+ * ```ts
549
+ * import { Function } from "effect"
550
+ * import * as assert from "node:assert"
551
+ *
552
+ * assert.deepStrictEqual(Function.constUndefined(), undefined)
553
+ * ```
554
+ *
555
+ * @category constants
556
+ * @since 2.0.0
557
+ */
558
+ const constUndefined = constant(void 0);
559
+ /**
560
+ * 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`.
561
+ * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
562
+ *
563
+ * **When to use**
564
+ *
565
+ * Use to compose exactly two unary functions into a reusable unary function.
566
+ *
567
+ * **Example** (Composing two functions)
568
+ *
569
+ * ```ts
570
+ * import { Function } from "effect"
571
+ * import * as assert from "node:assert"
572
+ *
573
+ * const increment = (n: number) => n + 1
574
+ * const square = (n: number) => n * n
575
+ *
576
+ * assert.strictEqual(Function.compose(increment, square)(2), 9)
577
+ * ```
578
+ *
579
+ * @see {@link flow} for composing a left-to-right sequence of functions
580
+ * @see {@link pipe} for applying a value through a left-to-right sequence immediately
581
+ *
582
+ * @category combinators
583
+ * @since 2.0.0
584
+ */
585
+ const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
586
+ /**
587
+ * Marks an impossible branch by accepting a `never` value and returning any
588
+ * type.
589
+ *
590
+ * **When to use**
591
+ *
592
+ * Use when you need a return value in a branch that exhaustive checks prove
593
+ * cannot be reached.
594
+ *
595
+ * **Gotchas**
596
+ *
597
+ * Calling `absurd` throws, because a value of type `never` should be
598
+ * impossible at runtime.
599
+ *
600
+ * **Example** (Handling impossible values)
601
+ *
602
+ * ```ts
603
+ * import { absurd } from "effect"
604
+ *
605
+ * const handleNever = (value: never) => {
606
+ * return absurd(value) // This will throw an error if called
607
+ * }
608
+ * ```
609
+ *
610
+ * @category utility types
611
+ * @since 2.0.0
612
+ */
613
+ const absurd = (_) => {
614
+ throw new Error("Called `absurd` function which should be uncallable");
615
+ };
616
+ /**
617
+ * Creates a compile-time placeholder for a value of any type.
618
+ *
619
+ * **When to use**
620
+ *
621
+ * Use as a temporary typed placeholder while developing incomplete code.
622
+ *
623
+ * **Gotchas**
624
+ *
625
+ * `hole` is intended for temporary development use. If the placeholder is
626
+ * evaluated at runtime, it throws.
627
+ *
628
+ * **Example** (Creating a development placeholder)
629
+ *
630
+ * ```ts
631
+ * import { hole } from "effect"
632
+ *
633
+ * // Intentionally not called: `hole` throws if the placeholder is evaluated.
634
+ * const buildUser = (id: number): { readonly id: number; readonly name: string } => ({
635
+ * id,
636
+ * name: hole<string>()
637
+ * })
638
+ *
639
+ * console.log(typeof buildUser) // "function"
640
+ * ```
641
+ *
642
+ * @category utility types
643
+ * @since 2.0.0
644
+ */
645
+ const hole = cast(absurd);
646
+ /**
647
+ * Drops the longest prefix of elements from an array that satisfy the given predicate.
648
+ *
649
+ * Supports both data-first and data-last (`pipe`-friendly) call styles.
650
+ *
651
+ * @param pred - The predicate to test each element with.
652
+ * @returns A new array without the matching prefix.
653
+ * @example
654
+ * ```ts
655
+ * import * as assert from "node:assert"
656
+ * import { dropWhile, pipe } from "@local/eff"
657
+ *
658
+ * // data-first
659
+ * assert.deepStrictEqual(dropWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [3, 2, 1])
660
+ *
661
+ * // data-last
662
+ * assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], dropWhile((n: number) => n < 3)), [3, 2, 1])
663
+ * ```
664
+ * @category array
665
+ */
666
+ const dropWhile = dual(2, (xs, pred) => {
667
+ const len = xs.length;
668
+ let idx = 0;
669
+ while (idx < len && pred(xs[idx])) idx++;
670
+ return xs.slice(idx);
671
+ });
672
+ /**
673
+ * Takes the longest prefix of elements from an array that satisfy the given predicate.
674
+ *
675
+ * Supports both data-first and data-last (`pipe`-friendly) call styles.
676
+ *
677
+ * @param pred - The predicate to test each element with.
678
+ * @returns A new array containing only the matching prefix.
679
+ * @example
680
+ * ```ts
681
+ * import * as assert from "node:assert"
682
+ * import { pipe, takeWhile } from "@local/eff"
683
+ *
684
+ * // data-first
685
+ * assert.deepStrictEqual(takeWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [1, 2])
686
+ *
687
+ * // data-last
688
+ * assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], takeWhile((n: number) => n < 3)), [1, 2])
689
+ * ```
690
+ * @category array
691
+ */
692
+ const takeWhile = dual(2, (xs, pred) => {
693
+ const len = xs.length;
694
+ let idx = 0;
695
+ while (idx < len && pred(xs[idx])) idx++;
696
+ return xs.slice(0, idx);
697
+ });
698
+
216
699
  //#endregion
217
700
  //#region src/utils/create-jsx-element-resolver.ts
218
701
  /**
@@ -246,7 +729,7 @@ resolve(node) {
246
729
  const nameNode = node.openingElement.name;
247
730
  if (nameNode.type === AST_NODE_TYPES.JSXIdentifier && nameNode.name.charAt(0) === nameNode.name.charAt(0).toLowerCase()) return result;
248
731
  const polyPropValue = getAttributeStaticValue(context, node, polymorphicPropName);
249
- if (typeof polyPropValue === "string") return {
732
+ if (isString(polyPropValue)) return {
250
733
  ...result,
251
734
  domElementType: polyPropValue.toLowerCase()
252
735
  };
@@ -337,7 +820,7 @@ function create$9(context) {
337
820
  return;
338
821
  }
339
822
  const sandboxValue = resolveAttributeValue(context, sandboxProp, "sandbox");
340
- if (isMatching(P.string, sandboxValue.toStatic())) return;
823
+ if (isString(sandboxValue.toStatic())) return;
341
824
  context.report({
342
825
  messageId: "missing-sandbox-attribute",
343
826
  node: sandboxValue.node ?? sandboxProp,
@@ -474,7 +957,7 @@ function create$6(context) {
474
957
  return { JSXAttribute(node) {
475
958
  if (node.name.type !== AST_NODE_TYPES.JSXIdentifier || node.value == null) return;
476
959
  const value = resolveAttributeValue(context, node).toStatic();
477
- if (isMatching(P.string, value) && RE_JAVASCRIPT_PROTOCOL.test(value)) context.report({
960
+ if (isString(value) && RE_JAVASCRIPT_PROTOCOL.test(value)) context.report({
478
961
  messageId: "default",
479
962
  node: node.value
480
963
  });
@@ -501,7 +984,7 @@ function create$5(context) {
501
984
  const styleProp = findAttribute(context, node, "style");
502
985
  if (styleProp == null) return;
503
986
  const styleValue = resolveAttributeValue(context, styleProp);
504
- if (!isMatching(P.string, styleValue.toStatic())) return;
987
+ if (!isString(styleValue.toStatic())) return;
505
988
  context.report({
506
989
  messageId: "default",
507
990
  node: styleValue.node ?? styleProp
@@ -1720,7 +2203,7 @@ function create$3(context) {
1720
2203
  if (sandboxProp == null) return;
1721
2204
  const sandboxValue = resolveAttributeValue(context, sandboxProp, "sandbox");
1722
2205
  const value = sandboxValue.toStatic();
1723
- if (!isMatching(P.string, value) || !UNSAFE_SANDBOX_VALUES.every((a) => value.includes(a))) return;
2206
+ if (!isString(value) || !UNSAFE_SANDBOX_VALUES.every((a) => value.includes(a))) return;
1724
2207
  context.report({
1725
2208
  messageId: "default",
1726
2209
  node: sandboxValue.node ?? sandboxProp
@@ -1737,7 +2220,7 @@ function create$3(context) {
1737
2220
  * @returns Whether the value represents an external link
1738
2221
  */
1739
2222
  function isExternalLinkLike(value) {
1740
- if (typeof value !== "string") return false;
2223
+ if (!isString(value)) return false;
1741
2224
  return value.startsWith("https://") || /^(?:\w+:|\/\/)/u.test(value);
1742
2225
  }
1743
2226
  /**
@@ -1747,7 +2230,7 @@ function isExternalLinkLike(value) {
1747
2230
  * @returns Whether the rel value is considered secure
1748
2231
  */
1749
2232
  function isSafeRel(value) {
1750
- if (typeof value !== "string") return false;
2233
+ if (!isString(value)) return false;
1751
2234
  return value === "noreferrer" || /\bnoreferrer\b/u.test(value);
1752
2235
  }
1753
2236
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-dom",
3
- "version": "5.24.0-beta.0",
3
+ "version": "5.24.0-beta.2",
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.0-beta.0",
41
- "@eslint-react/eslint": "5.24.0-beta.0",
42
- "@eslint-react/jsx": "5.24.0-beta.0",
43
- "@eslint-react/shared": "5.24.0-beta.0",
44
- "@eslint-react/var": "5.24.0-beta.0",
40
+ "@eslint-react/ast": "5.24.0-beta.2",
41
+ "@eslint-react/eslint": "5.24.0-beta.2",
42
+ "@eslint-react/jsx": "5.24.0-beta.2",
43
+ "@eslint-react/shared": "5.24.0-beta.2",
44
+ "@eslint-react/var": "5.24.0-beta.2",
45
45
  "@typescript-eslint/types": "^8.71.0",
46
46
  "@typescript-eslint/utils": "^8.71.0",
47
47
  "compare-versions": "^6.1.1",
@@ -49,6 +49,7 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@local/configs": "0.0.0",
52
+ "@local/eff": "0.0.0",
52
53
  "@local/testkit": "0.0.0",
53
54
  "@types/react": "^19.3.0",
54
55
  "@types/react-dom": "^19.3.0",