eslint-plugin-react-jsx 5.24.0 → 5.24.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.
- package/dist/index.js +28 -464
- 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.2";
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region src/utils/create-rule.ts
|
|
@@ -37,13 +37,6 @@ const createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
|
37
37
|
|
|
38
38
|
//#endregion
|
|
39
39
|
//#region src/utils/remove-jsx-attribute.ts
|
|
40
|
-
/**
|
|
41
|
-
* Builds a fix that removes a JSX attribute along with the whitespace before it.
|
|
42
|
-
* @param context The rule context
|
|
43
|
-
* @param fixer The rule fixer
|
|
44
|
-
* @param attribute The `JSXAttribute` node to remove
|
|
45
|
-
* @returns A fix that removes the attribute and its preceding whitespace
|
|
46
|
-
*/
|
|
47
40
|
function removeJsxAttribute(context, fixer, attribute) {
|
|
48
41
|
let start = attribute.range[0];
|
|
49
42
|
while (start > 0 && /\s/.test(context.sourceCode.text[start - 1] ?? "")) start--;
|
|
@@ -171,12 +164,6 @@ function create$6(context) {
|
|
|
171
164
|
}
|
|
172
165
|
};
|
|
173
166
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Turns the value of a 'children' JSXAttribute into text usable as element content
|
|
176
|
-
* @param context The rule context
|
|
177
|
-
* @param attribute The 'children' JSXAttribute node
|
|
178
|
-
* @returns The text to insert as element content, or `null` when no usable value exists
|
|
179
|
-
*/
|
|
180
167
|
function getChildrenText(context, attribute) {
|
|
181
168
|
const { value } = attribute;
|
|
182
169
|
if (value?.type === AST_NODE_TYPES.Literal) return escapeJsxText(String(value.value));
|
|
@@ -186,22 +173,9 @@ function getChildrenText(context, attribute) {
|
|
|
186
173
|
}
|
|
187
174
|
return null;
|
|
188
175
|
}
|
|
189
|
-
/**
|
|
190
|
-
* Escapes characters that would be parsed as markup in JSX text
|
|
191
|
-
* @param text The raw string value
|
|
192
|
-
* @returns The escaped text safe for insertion as JSX content
|
|
193
|
-
*/
|
|
194
176
|
function escapeJsxText(text) {
|
|
195
177
|
return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("{", "{").replaceAll("}", "}");
|
|
196
178
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Builds the fix that moves the 'children' prop value into the element's content
|
|
199
|
-
* @param context The rule context object
|
|
200
|
-
* @param node The JSXElement node being reported
|
|
201
|
-
* @param prop The 'children' JSXAttribute to remove
|
|
202
|
-
* @param childrenText The text to insert as element content
|
|
203
|
-
* @returns A fixer function that applies the changes
|
|
204
|
-
*/
|
|
205
179
|
function buildFix$1(context, node, prop, childrenText) {
|
|
206
180
|
return (fixer) => {
|
|
207
181
|
const sourceCode = context.sourceCode;
|
|
@@ -246,50 +220,6 @@ function create$5(context) {
|
|
|
246
220
|
|
|
247
221
|
//#endregion
|
|
248
222
|
//#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
|
-
/**
|
|
256
|
-
* Applies a `pipe` method's variadic arguments to an initial value from left
|
|
257
|
-
* to right.
|
|
258
|
-
*
|
|
259
|
-
* **When to use**
|
|
260
|
-
*
|
|
261
|
-
* Use to implement a custom `.pipe(...)` method from JavaScript's `arguments`
|
|
262
|
-
* object.
|
|
263
|
-
*
|
|
264
|
-
* **Details**
|
|
265
|
-
*
|
|
266
|
-
* This helper is intended for implementing `Pipeable.pipe` methods that
|
|
267
|
-
* receive JavaScript's `arguments` object. With no functions it returns the
|
|
268
|
-
* original value; otherwise it feeds each result into the next function.
|
|
269
|
-
*
|
|
270
|
-
* **Example** (Implementing a pipe method)
|
|
271
|
-
*
|
|
272
|
-
* ```ts
|
|
273
|
-
* import { Pipeable } from "effect"
|
|
274
|
-
*
|
|
275
|
-
* class NumberBox {
|
|
276
|
-
* constructor(readonly value: number) {}
|
|
277
|
-
*
|
|
278
|
-
* pipe(..._fns: ReadonlyArray<(value: number) => number>): number {
|
|
279
|
-
* return Pipeable.pipeArguments(this.value, arguments) as number
|
|
280
|
-
* }
|
|
281
|
-
* }
|
|
282
|
-
*
|
|
283
|
-
* const result = new NumberBox(5).pipe(
|
|
284
|
-
* (n) => n + 2,
|
|
285
|
-
* (n) => n * 3
|
|
286
|
-
* )
|
|
287
|
-
* console.log(result) // 21
|
|
288
|
-
* ```
|
|
289
|
-
*
|
|
290
|
-
* @category combinators
|
|
291
|
-
* @since 2.0.0
|
|
292
|
-
*/
|
|
293
223
|
const pipeArguments = (self, args) => {
|
|
294
224
|
switch (args.length) {
|
|
295
225
|
case 0: return self;
|
|
@@ -309,110 +239,14 @@ const pipeArguments = (self, args) => {
|
|
|
309
239
|
}
|
|
310
240
|
}
|
|
311
241
|
};
|
|
312
|
-
/**
|
|
313
|
-
* Reusable prototype that implements `Pipeable.pipe`.
|
|
314
|
-
*
|
|
315
|
-
* **When to use**
|
|
316
|
-
*
|
|
317
|
-
* Use when classes or object prototypes can reuse this value when they need the
|
|
318
|
-
* standard pipe implementation backed by `pipeArguments`.
|
|
319
|
-
*
|
|
320
|
-
* @category prototypes
|
|
321
|
-
* @since 3.15.0
|
|
322
|
-
*/
|
|
323
242
|
const Prototype = { pipe() {
|
|
324
243
|
return pipeArguments(this, arguments);
|
|
325
244
|
} };
|
|
326
|
-
/**
|
|
327
|
-
* Provides a base constructor whose instances implement the standard `Pipeable.pipe`
|
|
328
|
-
* method.
|
|
329
|
-
*
|
|
330
|
-
* **When to use**
|
|
331
|
-
*
|
|
332
|
-
* Use when you need to define a class that supports Effect-style method
|
|
333
|
-
* chaining through `.pipe(...)`.
|
|
334
|
-
*
|
|
335
|
-
* @category constructors
|
|
336
|
-
* @since 3.15.0
|
|
337
|
-
*/
|
|
338
245
|
const Class = (function() {
|
|
339
246
|
function PipeableBase() {}
|
|
340
247
|
PipeableBase.prototype = Prototype;
|
|
341
248
|
return PipeableBase;
|
|
342
249
|
})();
|
|
343
|
-
/**
|
|
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
|
-
* Creates a function that can be called in data-first style or data-last
|
|
355
|
-
* (`pipe`-friendly) style.
|
|
356
|
-
*
|
|
357
|
-
* **When to use**
|
|
358
|
-
*
|
|
359
|
-
* Use to expose one implementation through both direct and `pipe`-friendly
|
|
360
|
-
* call styles.
|
|
361
|
-
*
|
|
362
|
-
* **Details**
|
|
363
|
-
*
|
|
364
|
-
* Pass either the arity of the uncurried function or a predicate that decides
|
|
365
|
-
* whether the current call is data-first. Arity is the common case. Use a
|
|
366
|
-
* predicate when optional arguments make arity ambiguous.
|
|
367
|
-
*
|
|
368
|
-
* **Example** (Selecting data-first or data-last style by arity)
|
|
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
|
-
* >(2, (self, that) => self + that)
|
|
377
|
-
*
|
|
378
|
-
* console.log(sum(2, 3)) // 5
|
|
379
|
-
* console.log(pipe(2, sum(3))) // 5
|
|
380
|
-
* ```
|
|
381
|
-
*
|
|
382
|
-
* **Example** (Defining overloads with call signatures)
|
|
383
|
-
*
|
|
384
|
-
* ```ts
|
|
385
|
-
* import { Function, pipe } from "effect"
|
|
386
|
-
*
|
|
387
|
-
* const sum: {
|
|
388
|
-
* (that: number): (self: number) => number
|
|
389
|
-
* (self: number, that: number): number
|
|
390
|
-
* } = Function.dual(2, (self: number, that: number): number => self + that)
|
|
391
|
-
*
|
|
392
|
-
* console.log(sum(2, 3)) // 5
|
|
393
|
-
* console.log(pipe(2, sum(3))) // 5
|
|
394
|
-
* ```
|
|
395
|
-
*
|
|
396
|
-
* **Example** (Selecting data-first or data-last style with a predicate)
|
|
397
|
-
*
|
|
398
|
-
* ```ts
|
|
399
|
-
* import { Function, pipe } from "effect"
|
|
400
|
-
*
|
|
401
|
-
* const sum = Function.dual<
|
|
402
|
-
* (that: number) => (self: number) => number,
|
|
403
|
-
* (self: number, that: number) => number
|
|
404
|
-
* >(
|
|
405
|
-
* (args) => args.length === 2,
|
|
406
|
-
* (self, that) => self + that
|
|
407
|
-
* )
|
|
408
|
-
*
|
|
409
|
-
* console.log(sum(2, 3)) // 5
|
|
410
|
-
* console.log(pipe(2, sum(3))) // 5
|
|
411
|
-
* ```
|
|
412
|
-
*
|
|
413
|
-
* @category combinators
|
|
414
|
-
* @since 2.0.0
|
|
415
|
-
*/
|
|
416
250
|
const dual = function(arity, body) {
|
|
417
251
|
if (typeof arity === "function") return function() {
|
|
418
252
|
return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
|
|
@@ -441,287 +275,48 @@ const dual = function(arity, body) {
|
|
|
441
275
|
};
|
|
442
276
|
}
|
|
443
277
|
};
|
|
444
|
-
/**
|
|
445
|
-
* Returns its input argument unchanged.
|
|
446
|
-
*
|
|
447
|
-
* **When to use**
|
|
448
|
-
*
|
|
449
|
-
* Use to return a value unchanged where a function is required.
|
|
450
|
-
*
|
|
451
|
-
* **Example** (Returning the same value)
|
|
452
|
-
*
|
|
453
|
-
* ```ts
|
|
454
|
-
* import { identity } from "effect"
|
|
455
|
-
* import * as assert from "node:assert"
|
|
456
|
-
*
|
|
457
|
-
* assert.deepStrictEqual(identity(5), 5)
|
|
458
|
-
* ```
|
|
459
|
-
*
|
|
460
|
-
* @category combinators
|
|
461
|
-
* @since 2.0.0
|
|
462
|
-
*/
|
|
463
278
|
const identity = (a) => a;
|
|
464
|
-
/**
|
|
465
|
-
* Returns the input value with a different static type.
|
|
466
|
-
*
|
|
467
|
-
* **When to use**
|
|
468
|
-
*
|
|
469
|
-
* Use when you need an explicit type-level cast and accept that the value is
|
|
470
|
-
* returned unchanged at runtime.
|
|
471
|
-
*
|
|
472
|
-
* **Gotchas**
|
|
473
|
-
*
|
|
474
|
-
* This is a type-level cast only; it performs no runtime validation or
|
|
475
|
-
* conversion.
|
|
476
|
-
*
|
|
477
|
-
* @see {@link satisfies} for checking assignability without changing the resulting type
|
|
478
|
-
*
|
|
479
|
-
* @category utility types
|
|
480
|
-
* @since 4.0.0
|
|
481
|
-
*/
|
|
482
279
|
const cast = identity;
|
|
483
|
-
/**
|
|
484
|
-
* Creates a zero-argument function that always returns the provided value.
|
|
485
|
-
*
|
|
486
|
-
* **When to use**
|
|
487
|
-
*
|
|
488
|
-
* Use when you need a thunk or callback that returns the same value on every
|
|
489
|
-
* invocation.
|
|
490
|
-
*
|
|
491
|
-
* **Example** (Creating a constant thunk)
|
|
492
|
-
*
|
|
493
|
-
* ```ts
|
|
494
|
-
* import { Function } from "effect"
|
|
495
|
-
* import * as assert from "node:assert"
|
|
496
|
-
*
|
|
497
|
-
* const constNull = Function.constant(null)
|
|
498
|
-
*
|
|
499
|
-
* assert.deepStrictEqual(constNull(), null)
|
|
500
|
-
* assert.deepStrictEqual(constNull(), null)
|
|
501
|
-
* ```
|
|
502
|
-
*
|
|
503
|
-
* @category constructors
|
|
504
|
-
* @since 2.0.0
|
|
505
|
-
*/
|
|
506
280
|
const constant = (value) => () => value;
|
|
507
|
-
/**
|
|
508
|
-
* Returns `true` when called.
|
|
509
|
-
*
|
|
510
|
-
* **When to use**
|
|
511
|
-
*
|
|
512
|
-
* Use when you need a thunk that returns `true` on every invocation.
|
|
513
|
-
*
|
|
514
|
-
* **Example** (Returning true from a thunk)
|
|
515
|
-
*
|
|
516
|
-
* ```ts
|
|
517
|
-
* import { Function } from "effect"
|
|
518
|
-
* import * as assert from "node:assert"
|
|
519
|
-
*
|
|
520
|
-
* assert.deepStrictEqual(Function.constTrue(), true)
|
|
521
|
-
* ```
|
|
522
|
-
*
|
|
523
|
-
* @category constants
|
|
524
|
-
* @since 2.0.0
|
|
525
|
-
*/
|
|
526
281
|
const constTrue = constant(true);
|
|
527
|
-
/**
|
|
528
|
-
* Returns `false` when called.
|
|
529
|
-
*
|
|
530
|
-
* **When to use**
|
|
531
|
-
*
|
|
532
|
-
* Use when you need a thunk that returns `false` on every invocation.
|
|
533
|
-
*
|
|
534
|
-
* **Example** (Returning false from a thunk)
|
|
535
|
-
*
|
|
536
|
-
* ```ts
|
|
537
|
-
* import { Function } from "effect"
|
|
538
|
-
* import * as assert from "node:assert"
|
|
539
|
-
*
|
|
540
|
-
* assert.deepStrictEqual(Function.constFalse(), false)
|
|
541
|
-
* ```
|
|
542
|
-
*
|
|
543
|
-
* @category constants
|
|
544
|
-
* @since 2.0.0
|
|
545
|
-
*/
|
|
546
282
|
const constFalse = constant(false);
|
|
547
|
-
/**
|
|
548
|
-
* Returns `null` when called.
|
|
549
|
-
*
|
|
550
|
-
* **When to use**
|
|
551
|
-
*
|
|
552
|
-
* Use when you need a thunk that returns `null` on every invocation.
|
|
553
|
-
*
|
|
554
|
-
* **Example** (Returning null from a thunk)
|
|
555
|
-
*
|
|
556
|
-
* ```ts
|
|
557
|
-
* import { Function } from "effect"
|
|
558
|
-
* import * as assert from "node:assert"
|
|
559
|
-
*
|
|
560
|
-
* assert.deepStrictEqual(Function.constNull(), null)
|
|
561
|
-
* ```
|
|
562
|
-
*
|
|
563
|
-
* @category constants
|
|
564
|
-
* @since 2.0.0
|
|
565
|
-
*/
|
|
566
283
|
const constNull = constant(null);
|
|
567
|
-
/**
|
|
568
|
-
* Returns `undefined` when called.
|
|
569
|
-
*
|
|
570
|
-
* **When to use**
|
|
571
|
-
*
|
|
572
|
-
* Use when you need a thunk that returns `undefined` on every invocation.
|
|
573
|
-
*
|
|
574
|
-
* **Example** (Returning undefined from a thunk)
|
|
575
|
-
*
|
|
576
|
-
* ```ts
|
|
577
|
-
* import { Function } from "effect"
|
|
578
|
-
* import * as assert from "node:assert"
|
|
579
|
-
*
|
|
580
|
-
* assert.deepStrictEqual(Function.constUndefined(), undefined)
|
|
581
|
-
* ```
|
|
582
|
-
*
|
|
583
|
-
* @category constants
|
|
584
|
-
* @since 2.0.0
|
|
585
|
-
*/
|
|
586
284
|
const constUndefined = constant(void 0);
|
|
587
|
-
/**
|
|
588
|
-
* 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`.
|
|
589
|
-
* The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
|
|
590
|
-
*
|
|
591
|
-
* **When to use**
|
|
592
|
-
*
|
|
593
|
-
* Use to compose exactly two unary functions into a reusable unary function.
|
|
594
|
-
*
|
|
595
|
-
* **Example** (Composing two functions)
|
|
596
|
-
*
|
|
597
|
-
* ```ts
|
|
598
|
-
* import { Function } from "effect"
|
|
599
|
-
* import * as assert from "node:assert"
|
|
600
|
-
*
|
|
601
|
-
* const increment = (n: number) => n + 1
|
|
602
|
-
* const square = (n: number) => n * n
|
|
603
|
-
*
|
|
604
|
-
* assert.strictEqual(Function.compose(increment, square)(2), 9)
|
|
605
|
-
* ```
|
|
606
|
-
*
|
|
607
|
-
* @see {@link flow} for composing a left-to-right sequence of functions
|
|
608
|
-
* @see {@link pipe} for applying a value through a left-to-right sequence immediately
|
|
609
|
-
*
|
|
610
|
-
* @category combinators
|
|
611
|
-
* @since 2.0.0
|
|
612
|
-
*/
|
|
613
285
|
const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
614
|
-
/**
|
|
615
|
-
* Marks an impossible branch by accepting a `never` value and returning any
|
|
616
|
-
* type.
|
|
617
|
-
*
|
|
618
|
-
* **When to use**
|
|
619
|
-
*
|
|
620
|
-
* Use when you need a return value in a branch that exhaustive checks prove
|
|
621
|
-
* cannot be reached.
|
|
622
|
-
*
|
|
623
|
-
* **Gotchas**
|
|
624
|
-
*
|
|
625
|
-
* Calling `absurd` throws, because a value of type `never` should be
|
|
626
|
-
* impossible at runtime.
|
|
627
|
-
*
|
|
628
|
-
* **Example** (Handling impossible values)
|
|
629
|
-
*
|
|
630
|
-
* ```ts
|
|
631
|
-
* import { absurd } from "effect"
|
|
632
|
-
*
|
|
633
|
-
* const handleNever = (value: never) => {
|
|
634
|
-
* return absurd(value) // This will throw an error if called
|
|
635
|
-
* }
|
|
636
|
-
* ```
|
|
637
|
-
*
|
|
638
|
-
* @category utility types
|
|
639
|
-
* @since 2.0.0
|
|
640
|
-
*/
|
|
641
286
|
const absurd = (_) => {
|
|
642
287
|
throw new Error("Called `absurd` function which should be uncallable");
|
|
643
288
|
};
|
|
644
|
-
/**
|
|
645
|
-
* Creates a compile-time placeholder for a value of any type.
|
|
646
|
-
*
|
|
647
|
-
* **When to use**
|
|
648
|
-
*
|
|
649
|
-
* Use as a temporary typed placeholder while developing incomplete code.
|
|
650
|
-
*
|
|
651
|
-
* **Gotchas**
|
|
652
|
-
*
|
|
653
|
-
* `hole` is intended for temporary development use. If the placeholder is
|
|
654
|
-
* evaluated at runtime, it throws.
|
|
655
|
-
*
|
|
656
|
-
* **Example** (Creating a development placeholder)
|
|
657
|
-
*
|
|
658
|
-
* ```ts
|
|
659
|
-
* import { hole } from "effect"
|
|
660
|
-
*
|
|
661
|
-
* // Intentionally not called: `hole` throws if the placeholder is evaluated.
|
|
662
|
-
* const buildUser = (id: number): { readonly id: number; readonly name: string } => ({
|
|
663
|
-
* id,
|
|
664
|
-
* name: hole<string>()
|
|
665
|
-
* })
|
|
666
|
-
*
|
|
667
|
-
* console.log(typeof buildUser) // "function"
|
|
668
|
-
* ```
|
|
669
|
-
*
|
|
670
|
-
* @category utility types
|
|
671
|
-
* @since 2.0.0
|
|
672
|
-
*/
|
|
673
289
|
const hole = cast(absurd);
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
const dropWhile = dual(2, (xs, pred) => {
|
|
695
|
-
const len = xs.length;
|
|
290
|
+
function not(predicate) {
|
|
291
|
+
return (data) => !predicate(data);
|
|
292
|
+
}
|
|
293
|
+
const and = dual(2, (a, b) => (data) => a(data) && b(data));
|
|
294
|
+
const or = dual(2, (a, b) => (data) => a(data) || b(data));
|
|
295
|
+
const xor = dual(2, (a, b) => (data) => a(data) !== b(data));
|
|
296
|
+
const eqv = dual(2, (a, b) => (data) => a(data) === b(data));
|
|
297
|
+
const implies = dual(2, (antecedent, consequent) => (data) => !antecedent(data) || consequent(data));
|
|
298
|
+
const nor = dual(2, (a, b) => (data) => !a(data) && !b(data));
|
|
299
|
+
const nand = dual(2, (a, b) => (data) => !a(data) || !b(data));
|
|
300
|
+
function isFunction(input) {
|
|
301
|
+
return typeof input === "function";
|
|
302
|
+
}
|
|
303
|
+
function isObjectKeyword(input) {
|
|
304
|
+
return typeof input === "object" && input !== null || isFunction(input);
|
|
305
|
+
}
|
|
306
|
+
const hasProperty = dual(2, (data, property) => isObjectKeyword(data) && property in data);
|
|
307
|
+
const dropWhile = dual(2, (self, predicate) => {
|
|
308
|
+
const input = Array.isArray(self) ? self : Array.from(self);
|
|
309
|
+
const len = input.length;
|
|
696
310
|
let idx = 0;
|
|
697
|
-
while (idx < len &&
|
|
698
|
-
return
|
|
311
|
+
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
312
|
+
return input.slice(idx);
|
|
699
313
|
});
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
* Supports both data-first and data-last (`pipe`-friendly) call styles.
|
|
704
|
-
*
|
|
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"
|
|
711
|
-
*
|
|
712
|
-
* // data-first
|
|
713
|
-
* assert.deepStrictEqual(takeWhile([1, 2, 3, 2, 1], (n: number) => n < 3), [1, 2])
|
|
714
|
-
*
|
|
715
|
-
* // data-last
|
|
716
|
-
* assert.deepStrictEqual(pipe([1, 2, 3, 2, 1], takeWhile((n: number) => n < 3)), [1, 2])
|
|
717
|
-
* ```
|
|
718
|
-
* @category array
|
|
719
|
-
*/
|
|
720
|
-
const takeWhile = dual(2, (xs, pred) => {
|
|
721
|
-
const len = xs.length;
|
|
314
|
+
const takeWhile = dual(2, (self, predicate) => {
|
|
315
|
+
const input = Array.isArray(self) ? self : Array.from(self);
|
|
316
|
+
const len = input.length;
|
|
722
317
|
let idx = 0;
|
|
723
|
-
while (idx < len &&
|
|
724
|
-
return
|
|
318
|
+
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
319
|
+
return input.slice(0, idx);
|
|
725
320
|
});
|
|
726
321
|
|
|
727
322
|
//#endregion
|
|
@@ -800,11 +395,6 @@ function create$3(context) {
|
|
|
800
395
|
JSXFragment: visit
|
|
801
396
|
};
|
|
802
397
|
}
|
|
803
|
-
/**
|
|
804
|
-
* Whether a JSX child carries no renderable content: padding whitespace, an
|
|
805
|
-
* empty expression (ex: `{}` or a comment), or an empty string expression.
|
|
806
|
-
* @param child The JSX child node to check.
|
|
807
|
-
*/
|
|
808
398
|
const isWhitespaceOrEmptyStringExpression = or(isWhitespaceText, isEmptyStringExpression);
|
|
809
399
|
function isNonSubstantiveChild(child) {
|
|
810
400
|
if (isWhitespaceOrEmptyStringExpression(child)) return true;
|
|
@@ -923,16 +513,6 @@ function create(context, [option]) {
|
|
|
923
513
|
}
|
|
924
514
|
};
|
|
925
515
|
}
|
|
926
|
-
/**
|
|
927
|
-
* Inspect a fragment node and report if it is useless.
|
|
928
|
-
*
|
|
929
|
-
* A fragment may be reported for **two independent reasons** on the same
|
|
930
|
-
* node (e.g. `<p><>foo</></p>` is both "placed inside a host component"
|
|
931
|
-
* and "contains less than two children").
|
|
932
|
-
* @param context The rule context.
|
|
933
|
-
* @param node The fragment node to inspect.
|
|
934
|
-
* @param options The resolved rule options.
|
|
935
|
-
*/
|
|
936
516
|
function visitFragment(context, node, options) {
|
|
937
517
|
const reasons = [];
|
|
938
518
|
if (isHostElement(node.parent)) reasons.push("placed inside a host component");
|
|
@@ -946,12 +526,6 @@ function visitFragment(context, node, options) {
|
|
|
946
526
|
node
|
|
947
527
|
});
|
|
948
528
|
}
|
|
949
|
-
/**
|
|
950
|
-
* Whether the fragment has too few meaningful children to justify its
|
|
951
|
-
* existence (the "contains less than two children" reason).
|
|
952
|
-
* @param node The fragment node to check.
|
|
953
|
-
* @param options The resolved rule options.
|
|
954
|
-
*/
|
|
955
529
|
function isContentUseless(node, options) {
|
|
956
530
|
const { allowEmptyFragment, allowExpressions } = options;
|
|
957
531
|
if (node.children.length === 0) return !allowEmptyFragment;
|
|
@@ -963,10 +537,6 @@ function isContentUseless(node, options) {
|
|
|
963
537
|
if (meaningful[0]?.type === AST_NODE_TYPES.JSXExpressionContainer) return !allowExpressions;
|
|
964
538
|
return true;
|
|
965
539
|
}
|
|
966
|
-
/**
|
|
967
|
-
* Whether it is safe to auto-fix the fragment by unwrapping it.
|
|
968
|
-
* @param node The fragment node to check.
|
|
969
|
-
*/
|
|
970
540
|
function isSafeToFix(node) {
|
|
971
541
|
if (node.type === AST_NODE_TYPES.JSXElement && node.openingElement.attributes.some((attr) => attr.type === AST_NODE_TYPES.JSXSpreadAttribute)) return false;
|
|
972
542
|
if (Check.isJSXElementOrFragment(node.parent)) return isHostElement(node.parent);
|
|
@@ -976,12 +546,6 @@ function isSafeToFix(node) {
|
|
|
976
546
|
return child.type === AST_NODE_TYPES.JSXText && isWhitespaceText(child);
|
|
977
547
|
});
|
|
978
548
|
}
|
|
979
|
-
/**
|
|
980
|
-
* Build an autofix that unwraps the fragment, replacing it with its
|
|
981
|
-
* meaningful children content. Returns `null` when the fix is unsafe.
|
|
982
|
-
* @param context The rule context.
|
|
983
|
-
* @param node The fragment node to fix.
|
|
984
|
-
*/
|
|
985
549
|
function buildFix(context, node) {
|
|
986
550
|
if (!isSafeToFix(node)) return null;
|
|
987
551
|
return (fixer) => {
|
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.2",
|
|
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.2",
|
|
41
|
+
"@eslint-react/core": "5.24.2",
|
|
42
|
+
"@eslint-react/eslint": "5.24.2",
|
|
43
|
+
"@eslint-react/jsx": "5.24.2",
|
|
44
|
+
"@eslint-react/shared": "5.24.2",
|
|
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
|
},
|