@eslint-react/shared 5.24.1 → 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 +0 -820
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4,44 +4,6 @@ import { P, match } from "ts-pattern";
|
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
5
|
|
|
6
6
|
//#region ../../.pkgs/eff/dist/index.js
|
|
7
|
-
/**
|
|
8
|
-
* Applies a `pipe` method's variadic arguments to an initial value from left
|
|
9
|
-
* to right.
|
|
10
|
-
*
|
|
11
|
-
* **When to use**
|
|
12
|
-
*
|
|
13
|
-
* Use to implement a custom `.pipe(...)` method from JavaScript's `arguments`
|
|
14
|
-
* object.
|
|
15
|
-
*
|
|
16
|
-
* **Details**
|
|
17
|
-
*
|
|
18
|
-
* This helper is intended for implementing `Pipeable.pipe` methods that
|
|
19
|
-
* receive JavaScript's `arguments` object. With no functions it returns the
|
|
20
|
-
* original value; otherwise it feeds each result into the next function.
|
|
21
|
-
*
|
|
22
|
-
* **Example** (Implementing a pipe method)
|
|
23
|
-
*
|
|
24
|
-
* ```ts
|
|
25
|
-
* import { Pipeable } from "effect"
|
|
26
|
-
*
|
|
27
|
-
* class NumberBox {
|
|
28
|
-
* constructor(readonly value: number) {}
|
|
29
|
-
*
|
|
30
|
-
* pipe(..._fns: ReadonlyArray<(value: number) => number>): number {
|
|
31
|
-
* return Pipeable.pipeArguments(this.value, arguments) as number
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* const result = new NumberBox(5).pipe(
|
|
36
|
-
* (n) => n + 2,
|
|
37
|
-
* (n) => n * 3
|
|
38
|
-
* )
|
|
39
|
-
* result // => 21
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @category combinators
|
|
43
|
-
* @since 2.0.0
|
|
44
|
-
*/
|
|
45
7
|
const pipeArguments = (self, args) => {
|
|
46
8
|
switch (args.length) {
|
|
47
9
|
case 0: return self;
|
|
@@ -61,100 +23,14 @@ const pipeArguments = (self, args) => {
|
|
|
61
23
|
}
|
|
62
24
|
}
|
|
63
25
|
};
|
|
64
|
-
/**
|
|
65
|
-
* Reusable prototype that implements `Pipeable.pipe`.
|
|
66
|
-
*
|
|
67
|
-
* **When to use**
|
|
68
|
-
*
|
|
69
|
-
* Use when classes or object prototypes can reuse this value when they need the
|
|
70
|
-
* standard pipe implementation backed by `pipeArguments`.
|
|
71
|
-
*
|
|
72
|
-
* @category prototypes
|
|
73
|
-
* @since 3.15.0
|
|
74
|
-
*/
|
|
75
26
|
const Prototype = { pipe() {
|
|
76
27
|
return pipeArguments(this, arguments);
|
|
77
28
|
} };
|
|
78
|
-
/**
|
|
79
|
-
* Provides a base constructor whose instances implement the standard `Pipeable.pipe`
|
|
80
|
-
* method.
|
|
81
|
-
*
|
|
82
|
-
* **When to use**
|
|
83
|
-
*
|
|
84
|
-
* Use when you need to define a class that supports Effect-style method
|
|
85
|
-
* chaining through `.pipe(...)`.
|
|
86
|
-
*
|
|
87
|
-
* @category constructors
|
|
88
|
-
* @since 3.15.0
|
|
89
|
-
*/
|
|
90
29
|
const Class = (function() {
|
|
91
30
|
function PipeableBase() {}
|
|
92
31
|
PipeableBase.prototype = Prototype;
|
|
93
32
|
return PipeableBase;
|
|
94
33
|
})();
|
|
95
|
-
/**
|
|
96
|
-
* Creates a function that can be called in data-first style or data-last
|
|
97
|
-
* (`pipe`-friendly) style.
|
|
98
|
-
*
|
|
99
|
-
* **When to use**
|
|
100
|
-
*
|
|
101
|
-
* Use to expose one implementation through both direct and `pipe`-friendly
|
|
102
|
-
* call styles.
|
|
103
|
-
*
|
|
104
|
-
* **Details**
|
|
105
|
-
*
|
|
106
|
-
* Pass either the arity of the uncurried function or a predicate that decides
|
|
107
|
-
* whether the current call is data-first. Arity is the common case. Use a
|
|
108
|
-
* predicate when optional arguments make arity ambiguous.
|
|
109
|
-
*
|
|
110
|
-
* **Example** (Selecting data-first or data-last style by arity)
|
|
111
|
-
*
|
|
112
|
-
* ```ts
|
|
113
|
-
* import { Function, pipe } from "effect"
|
|
114
|
-
*
|
|
115
|
-
* const sum = Function.dual<
|
|
116
|
-
* (that: number) => (self: number) => number,
|
|
117
|
-
* (self: number, that: number) => number
|
|
118
|
-
* >(2, (self, that) => self + that)
|
|
119
|
-
*
|
|
120
|
-
* sum(2, 3) // => 5
|
|
121
|
-
* pipe(2, sum(3)) // => 5
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* **Example** (Defining overloads with call signatures)
|
|
125
|
-
*
|
|
126
|
-
* ```ts
|
|
127
|
-
* import { Function, pipe } from "effect"
|
|
128
|
-
*
|
|
129
|
-
* const sum: {
|
|
130
|
-
* (that: number): (self: number) => number
|
|
131
|
-
* (self: number, that: number): number
|
|
132
|
-
* } = Function.dual(2, (self: number, that: number): number => self + that)
|
|
133
|
-
*
|
|
134
|
-
* sum(2, 3) // => 5
|
|
135
|
-
* pipe(2, sum(3)) // => 5
|
|
136
|
-
* ```
|
|
137
|
-
*
|
|
138
|
-
* **Example** (Selecting data-first or data-last style with a predicate)
|
|
139
|
-
*
|
|
140
|
-
* ```ts
|
|
141
|
-
* import { Function, pipe } from "effect"
|
|
142
|
-
*
|
|
143
|
-
* const sum = Function.dual<
|
|
144
|
-
* (that: number) => (self: number) => number,
|
|
145
|
-
* (self: number, that: number) => number
|
|
146
|
-
* >(
|
|
147
|
-
* (args) => args.length === 2,
|
|
148
|
-
* (self, that) => self + that
|
|
149
|
-
* )
|
|
150
|
-
*
|
|
151
|
-
* sum(2, 3) // => 5
|
|
152
|
-
* pipe(2, sum(3)) // => 5
|
|
153
|
-
* ```
|
|
154
|
-
*
|
|
155
|
-
* @category combinators
|
|
156
|
-
* @since 2.0.0
|
|
157
|
-
*/
|
|
158
34
|
const dual = function(arity, body) {
|
|
159
35
|
if (typeof arity === "function") return function() {
|
|
160
36
|
return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
|
|
@@ -183,253 +59,18 @@ const dual = function(arity, body) {
|
|
|
183
59
|
};
|
|
184
60
|
}
|
|
185
61
|
};
|
|
186
|
-
/**
|
|
187
|
-
* Returns its input argument unchanged.
|
|
188
|
-
*
|
|
189
|
-
* **When to use**
|
|
190
|
-
*
|
|
191
|
-
* Use to return a value unchanged where a function is required.
|
|
192
|
-
*
|
|
193
|
-
* **Example** (Returning the same value)
|
|
194
|
-
*
|
|
195
|
-
* ```ts
|
|
196
|
-
* import { identity } from "effect"
|
|
197
|
-
*
|
|
198
|
-
* identity(5) // => 5
|
|
199
|
-
* ```
|
|
200
|
-
*
|
|
201
|
-
* @category combinators
|
|
202
|
-
* @since 2.0.0
|
|
203
|
-
*/
|
|
204
62
|
const identity = (a) => a;
|
|
205
|
-
/**
|
|
206
|
-
* Returns the input value with a different static type.
|
|
207
|
-
*
|
|
208
|
-
* **When to use**
|
|
209
|
-
*
|
|
210
|
-
* Use when you need an explicit type-level cast and accept that the value is
|
|
211
|
-
* returned unchanged at runtime.
|
|
212
|
-
*
|
|
213
|
-
* **Gotchas**
|
|
214
|
-
*
|
|
215
|
-
* This is a type-level cast only; it performs no runtime validation or
|
|
216
|
-
* conversion.
|
|
217
|
-
*
|
|
218
|
-
* @see {@link satisfies} for checking assignability without changing the resulting type
|
|
219
|
-
*
|
|
220
|
-
* @category utility types
|
|
221
|
-
* @since 4.0.0
|
|
222
|
-
*/
|
|
223
63
|
const cast = identity;
|
|
224
|
-
/**
|
|
225
|
-
* Creates a zero-argument function that always returns the provided value.
|
|
226
|
-
*
|
|
227
|
-
* **When to use**
|
|
228
|
-
*
|
|
229
|
-
* Use when you need a thunk or callback that returns the same value on every
|
|
230
|
-
* invocation.
|
|
231
|
-
*
|
|
232
|
-
* **Example** (Creating a constant thunk)
|
|
233
|
-
*
|
|
234
|
-
* ```ts
|
|
235
|
-
* import { Function } from "effect"
|
|
236
|
-
*
|
|
237
|
-
* const constNull = Function.constant(null)
|
|
238
|
-
*
|
|
239
|
-
* constNull() // => null
|
|
240
|
-
* constNull() // => null
|
|
241
|
-
* ```
|
|
242
|
-
*
|
|
243
|
-
* @category constructors
|
|
244
|
-
* @since 2.0.0
|
|
245
|
-
*/
|
|
246
64
|
const constant = (value) => () => value;
|
|
247
|
-
/**
|
|
248
|
-
* Returns `true` when called.
|
|
249
|
-
*
|
|
250
|
-
* **When to use**
|
|
251
|
-
*
|
|
252
|
-
* Use when you need a thunk that returns `true` on every invocation.
|
|
253
|
-
*
|
|
254
|
-
* **Example** (Returning true from a thunk)
|
|
255
|
-
*
|
|
256
|
-
* ```ts
|
|
257
|
-
* import { Function } from "effect"
|
|
258
|
-
*
|
|
259
|
-
* Function.constTrue() // => true
|
|
260
|
-
* ```
|
|
261
|
-
*
|
|
262
|
-
* @category constants
|
|
263
|
-
* @since 2.0.0
|
|
264
|
-
*/
|
|
265
65
|
const constTrue = constant(true);
|
|
266
|
-
/**
|
|
267
|
-
* Returns `false` when called.
|
|
268
|
-
*
|
|
269
|
-
* **When to use**
|
|
270
|
-
*
|
|
271
|
-
* Use when you need a thunk that returns `false` on every invocation.
|
|
272
|
-
*
|
|
273
|
-
* **Example** (Returning false from a thunk)
|
|
274
|
-
*
|
|
275
|
-
* ```ts
|
|
276
|
-
* import { Function } from "effect"
|
|
277
|
-
*
|
|
278
|
-
* Function.constFalse() // => false
|
|
279
|
-
* ```
|
|
280
|
-
*
|
|
281
|
-
* @category constants
|
|
282
|
-
* @since 2.0.0
|
|
283
|
-
*/
|
|
284
66
|
const constFalse = constant(false);
|
|
285
|
-
/**
|
|
286
|
-
* Returns `null` when called.
|
|
287
|
-
*
|
|
288
|
-
* **When to use**
|
|
289
|
-
*
|
|
290
|
-
* Use when you need a thunk that returns `null` on every invocation.
|
|
291
|
-
*
|
|
292
|
-
* **Example** (Returning null from a thunk)
|
|
293
|
-
*
|
|
294
|
-
* ```ts
|
|
295
|
-
* import { Function } from "effect"
|
|
296
|
-
*
|
|
297
|
-
* Function.constNull() // => null
|
|
298
|
-
* ```
|
|
299
|
-
*
|
|
300
|
-
* @category constants
|
|
301
|
-
* @since 2.0.0
|
|
302
|
-
*/
|
|
303
67
|
const constNull = constant(null);
|
|
304
|
-
/**
|
|
305
|
-
* Returns `undefined` when called.
|
|
306
|
-
*
|
|
307
|
-
* **When to use**
|
|
308
|
-
*
|
|
309
|
-
* Use when you need a thunk that returns `undefined` on every invocation.
|
|
310
|
-
*
|
|
311
|
-
* **Example** (Returning undefined from a thunk)
|
|
312
|
-
*
|
|
313
|
-
* ```ts
|
|
314
|
-
* import { Function } from "effect"
|
|
315
|
-
*
|
|
316
|
-
* Function.constUndefined() // => undefined
|
|
317
|
-
* ```
|
|
318
|
-
*
|
|
319
|
-
* @category constants
|
|
320
|
-
* @since 2.0.0
|
|
321
|
-
*/
|
|
322
68
|
const constUndefined = constant(void 0);
|
|
323
|
-
/**
|
|
324
|
-
* 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`.
|
|
325
|
-
* The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
|
|
326
|
-
*
|
|
327
|
-
* **When to use**
|
|
328
|
-
*
|
|
329
|
-
* Use to compose exactly two unary functions into a reusable unary function.
|
|
330
|
-
*
|
|
331
|
-
* **Example** (Composing two functions)
|
|
332
|
-
*
|
|
333
|
-
* ```ts
|
|
334
|
-
* import { Function } from "effect"
|
|
335
|
-
*
|
|
336
|
-
* const increment = (n: number) => n + 1
|
|
337
|
-
* const square = (n: number) => n * n
|
|
338
|
-
*
|
|
339
|
-
* Function.compose(increment, square)(2) // => 9
|
|
340
|
-
* ```
|
|
341
|
-
*
|
|
342
|
-
* @see {@link flow} for composing a left-to-right sequence of functions
|
|
343
|
-
* @see {@link pipe} for applying a value through a left-to-right sequence immediately
|
|
344
|
-
*
|
|
345
|
-
* @category combinators
|
|
346
|
-
* @since 2.0.0
|
|
347
|
-
*/
|
|
348
69
|
const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
349
|
-
/**
|
|
350
|
-
* Marks an impossible branch by accepting a `never` value and returning any
|
|
351
|
-
* type.
|
|
352
|
-
*
|
|
353
|
-
* **When to use**
|
|
354
|
-
*
|
|
355
|
-
* Use when you need a return value in a branch that exhaustive checks prove
|
|
356
|
-
* cannot be reached.
|
|
357
|
-
*
|
|
358
|
-
* **Gotchas**
|
|
359
|
-
*
|
|
360
|
-
* Calling `absurd` throws, because a value of type `never` should be
|
|
361
|
-
* impossible at runtime.
|
|
362
|
-
*
|
|
363
|
-
* **Example** (Handling impossible values)
|
|
364
|
-
*
|
|
365
|
-
* ```ts
|
|
366
|
-
* import { absurd } from "effect"
|
|
367
|
-
*
|
|
368
|
-
* const handleNever = (value: never) => {
|
|
369
|
-
* return absurd(value) // This will throw an error if called
|
|
370
|
-
* }
|
|
371
|
-
* ```
|
|
372
|
-
*
|
|
373
|
-
* @category utility types
|
|
374
|
-
* @since 2.0.0
|
|
375
|
-
*/
|
|
376
70
|
const absurd = (_) => {
|
|
377
71
|
throw new Error("Called `absurd` function which should be uncallable");
|
|
378
72
|
};
|
|
379
|
-
/**
|
|
380
|
-
* Creates a compile-time placeholder for a value of any type.
|
|
381
|
-
*
|
|
382
|
-
* **When to use**
|
|
383
|
-
*
|
|
384
|
-
* Use as a temporary typed placeholder while developing incomplete code.
|
|
385
|
-
*
|
|
386
|
-
* **Gotchas**
|
|
387
|
-
*
|
|
388
|
-
* `hole` is intended for temporary development use. If the placeholder is
|
|
389
|
-
* evaluated at runtime, it throws.
|
|
390
|
-
*
|
|
391
|
-
* **Example** (Creating a development placeholder)
|
|
392
|
-
*
|
|
393
|
-
* ```ts
|
|
394
|
-
* import { hole } from "effect"
|
|
395
|
-
*
|
|
396
|
-
* // Intentionally not called: `hole` throws if the placeholder is evaluated.
|
|
397
|
-
* const buildUser = (id: number): { readonly id: number; readonly name: string } => ({
|
|
398
|
-
* id,
|
|
399
|
-
* name: hole<string>()
|
|
400
|
-
* })
|
|
401
|
-
*
|
|
402
|
-
* ```
|
|
403
|
-
*
|
|
404
|
-
* @category utility types
|
|
405
|
-
* @since 2.0.0
|
|
406
|
-
*/
|
|
407
73
|
const hole = cast(absurd);
|
|
408
|
-
/**
|
|
409
|
-
* Creates a memoized function whose input is an object, caching results by
|
|
410
|
-
* object identity.
|
|
411
|
-
*
|
|
412
|
-
* **When to use**
|
|
413
|
-
*
|
|
414
|
-
* Use to reuse the result of a synchronous computation whose output is stable
|
|
415
|
-
* for a given object reference.
|
|
416
|
-
*
|
|
417
|
-
* **Details**
|
|
418
|
-
*
|
|
419
|
-
* Each memoized wrapper owns a private `WeakMap` keyed by object identity.
|
|
420
|
-
*
|
|
421
|
-
* **Gotchas**
|
|
422
|
-
*
|
|
423
|
-
* `undefined` is reserved to represent a cache miss and is therefore not
|
|
424
|
-
* supported as a return value.
|
|
425
|
-
*
|
|
426
|
-
* Structurally equal objects do not share cache entries. If the same object is
|
|
427
|
-
* mutated after its first call, later calls still return the cached result for
|
|
428
|
-
* that reference.
|
|
429
|
-
*
|
|
430
|
-
* @category caching
|
|
431
|
-
* @since 4.0.0
|
|
432
|
-
*/
|
|
433
74
|
function memoize(f) {
|
|
434
75
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
435
76
|
return (a) => {
|
|
@@ -440,333 +81,20 @@ function memoize(f) {
|
|
|
440
81
|
return result;
|
|
441
82
|
};
|
|
442
83
|
}
|
|
443
|
-
/**
|
|
444
|
-
* Creates a predicate that returns `true` only if both predicates are `true`.
|
|
445
|
-
*
|
|
446
|
-
* **When to use**
|
|
447
|
-
*
|
|
448
|
-
* Use when you want to combine `Predicate`s with AND, accepting values that
|
|
449
|
-
* satisfy multiple conditions, including refinements that narrow to an
|
|
450
|
-
* intersection.
|
|
451
|
-
*
|
|
452
|
-
* **Details**
|
|
453
|
-
*
|
|
454
|
-
* Evaluation short-circuits on the first `false`. For refinements, the output
|
|
455
|
-
* type is an intersection.
|
|
456
|
-
*
|
|
457
|
-
* **Example** (Checking both conditions)
|
|
458
|
-
*
|
|
459
|
-
* ```ts
|
|
460
|
-
* import { Predicate } from "effect"
|
|
461
|
-
*
|
|
462
|
-
* const hasAAndB = Predicate.and(
|
|
463
|
-
* Predicate.hasProperty("a"),
|
|
464
|
-
* Predicate.hasProperty("b")
|
|
465
|
-
* )
|
|
466
|
-
*
|
|
467
|
-
* const input: unknown = JSON.parse(`{"a":1,"b":"ok"}`)
|
|
468
|
-
* if (hasAAndB(input)) {
|
|
469
|
-
* // input has both properties at this point
|
|
470
|
-
* const a = input.a
|
|
471
|
-
* const b = input.b
|
|
472
|
-
*
|
|
473
|
-
* const values = [a, b] // => [1, "ok"]
|
|
474
|
-
* }
|
|
475
|
-
* ```
|
|
476
|
-
*
|
|
477
|
-
* @see {@link or}
|
|
478
|
-
* @see {@link not}
|
|
479
|
-
* @category combinators
|
|
480
|
-
* @since 2.0.0
|
|
481
|
-
*/
|
|
482
84
|
const and = dual(2, (a, b) => (data) => a(data) && b(data));
|
|
483
|
-
/**
|
|
484
|
-
* Creates a predicate that returns `true` if either predicate is `true`.
|
|
485
|
-
*
|
|
486
|
-
* **When to use**
|
|
487
|
-
*
|
|
488
|
-
* Use when you want to combine `Predicate`s with OR, accepting values that
|
|
489
|
-
* satisfy at least one condition, including refinements that narrow to a union.
|
|
490
|
-
*
|
|
491
|
-
* **Details**
|
|
492
|
-
*
|
|
493
|
-
* Evaluation short-circuits on the first `true`. For refinements, the output
|
|
494
|
-
* type is a union.
|
|
495
|
-
*
|
|
496
|
-
* **Example** (Checking either condition)
|
|
497
|
-
*
|
|
498
|
-
* ```ts
|
|
499
|
-
* import { Predicate } from "effect"
|
|
500
|
-
*
|
|
501
|
-
* const isStringOrNumber = Predicate.or(Predicate.isString, Predicate.isNumber)
|
|
502
|
-
*
|
|
503
|
-
* isStringOrNumber("a") // => true
|
|
504
|
-
* ```
|
|
505
|
-
*
|
|
506
|
-
* @see {@link and}
|
|
507
|
-
* @see {@link xor}
|
|
508
|
-
* @category combinators
|
|
509
|
-
* @since 2.0.0
|
|
510
|
-
*/
|
|
511
85
|
const or = dual(2, (a, b) => (data) => a(data) || b(data));
|
|
512
|
-
/**
|
|
513
|
-
* Creates a predicate that returns `true` if exactly one predicate is `true`.
|
|
514
|
-
*
|
|
515
|
-
* **When to use**
|
|
516
|
-
*
|
|
517
|
-
* Use when you want to combine two `Predicate`s with exclusive-or semantics.
|
|
518
|
-
*
|
|
519
|
-
* **Details**
|
|
520
|
-
*
|
|
521
|
-
* Returns `true` when results differ.
|
|
522
|
-
*
|
|
523
|
-
* **Example** (Checking exclusive-or conditions)
|
|
524
|
-
*
|
|
525
|
-
* ```ts
|
|
526
|
-
* import { Predicate } from "effect"
|
|
527
|
-
*
|
|
528
|
-
* const isEven = (n: number) => n % 2 === 0
|
|
529
|
-
* const isPositive = (n: number) => n > 0
|
|
530
|
-
* const either = Predicate.xor(isEven, isPositive)
|
|
531
|
-
*
|
|
532
|
-
* either(-2) // => true
|
|
533
|
-
* ```
|
|
534
|
-
*
|
|
535
|
-
* @see {@link or}
|
|
536
|
-
* @see {@link and}
|
|
537
|
-
* @category combinators
|
|
538
|
-
* @since 2.0.0
|
|
539
|
-
*/
|
|
540
86
|
const xor = dual(2, (a, b) => (data) => a(data) !== b(data));
|
|
541
|
-
/**
|
|
542
|
-
* Creates a predicate that returns `true` when both predicates agree.
|
|
543
|
-
*
|
|
544
|
-
* **When to use**
|
|
545
|
-
*
|
|
546
|
-
* Use when you want to check equivalence of two `Predicate`s.
|
|
547
|
-
*
|
|
548
|
-
* **Details**
|
|
549
|
-
*
|
|
550
|
-
* Returns `true` when both results are equal.
|
|
551
|
-
*
|
|
552
|
-
* **Example** (Defining equivalence)
|
|
553
|
-
*
|
|
554
|
-
* ```ts
|
|
555
|
-
* import { Predicate } from "effect"
|
|
556
|
-
*
|
|
557
|
-
* const isEven = (n: number) => n % 2 === 0
|
|
558
|
-
* const same = Predicate.eqv(isEven, isEven)
|
|
559
|
-
*
|
|
560
|
-
* same(3) // => true
|
|
561
|
-
* ```
|
|
562
|
-
*
|
|
563
|
-
* @see {@link xor}
|
|
564
|
-
* @category combinators
|
|
565
|
-
* @since 2.0.0
|
|
566
|
-
*/
|
|
567
87
|
const eqv = dual(2, (a, b) => (data) => a(data) === b(data));
|
|
568
|
-
/**
|
|
569
|
-
* Creates a predicate representing logical implication: if `antecedent`, then `consequent`.
|
|
570
|
-
*
|
|
571
|
-
* **When to use**
|
|
572
|
-
*
|
|
573
|
-
* Use when you need to encode logical implication between `Predicate` rules,
|
|
574
|
-
* where one rule only applies when a precondition holds.
|
|
575
|
-
*
|
|
576
|
-
* **Details**
|
|
577
|
-
*
|
|
578
|
-
* Models constraints like "if A then B" and returns `true` when the antecedent
|
|
579
|
-
* is `false`.
|
|
580
|
-
*
|
|
581
|
-
* **Example** (Checking implication)
|
|
582
|
-
*
|
|
583
|
-
* ```ts
|
|
584
|
-
* import { Predicate } from "effect"
|
|
585
|
-
*
|
|
586
|
-
* const isAdult = (age: number) => age >= 18
|
|
587
|
-
* const canVote = (age: number) => age >= 18
|
|
588
|
-
* const implies = Predicate.implies(isAdult, canVote)
|
|
589
|
-
*
|
|
590
|
-
* implies(16) // => true
|
|
591
|
-
* ```
|
|
592
|
-
*
|
|
593
|
-
* @see {@link and}
|
|
594
|
-
* @see {@link or}
|
|
595
|
-
* @category combinators
|
|
596
|
-
* @since 2.0.0
|
|
597
|
-
*/
|
|
598
88
|
const implies = dual(2, (antecedent, consequent) => (data) => !antecedent(data) || consequent(data));
|
|
599
|
-
/**
|
|
600
|
-
* Creates a predicate that returns `true` when neither predicate is `true`.
|
|
601
|
-
*
|
|
602
|
-
* **When to use**
|
|
603
|
-
*
|
|
604
|
-
* Use when you want to combine two `Predicate`s with logical NOR semantics.
|
|
605
|
-
*
|
|
606
|
-
* **Details**
|
|
607
|
-
*
|
|
608
|
-
* Returns the negation of `or`.
|
|
609
|
-
*
|
|
610
|
-
* **Example** (Checking NOR conditions)
|
|
611
|
-
*
|
|
612
|
-
* ```ts
|
|
613
|
-
* import { Predicate } from "effect"
|
|
614
|
-
*
|
|
615
|
-
* const neither = Predicate.nor(Predicate.isString, Predicate.isNumber)
|
|
616
|
-
*
|
|
617
|
-
* neither(true) // => true
|
|
618
|
-
* ```
|
|
619
|
-
*
|
|
620
|
-
* @see {@link or}
|
|
621
|
-
* @see {@link not}
|
|
622
|
-
* @category combinators
|
|
623
|
-
* @since 2.0.0
|
|
624
|
-
*/
|
|
625
89
|
const nor = dual(2, (a, b) => (data) => !a(data) && !b(data));
|
|
626
|
-
/**
|
|
627
|
-
* Creates a predicate that returns `true` unless both predicates are `true`.
|
|
628
|
-
*
|
|
629
|
-
* **When to use**
|
|
630
|
-
*
|
|
631
|
-
* Use when you want to combine two `Predicate`s with logical NAND semantics.
|
|
632
|
-
*
|
|
633
|
-
* **Details**
|
|
634
|
-
*
|
|
635
|
-
* Returns the negation of `and`.
|
|
636
|
-
*
|
|
637
|
-
* **Example** (Checking NAND conditions)
|
|
638
|
-
*
|
|
639
|
-
* ```ts
|
|
640
|
-
* import { Predicate } from "effect"
|
|
641
|
-
*
|
|
642
|
-
* const notBoth = Predicate.nand(Predicate.isString, Predicate.isNumber)
|
|
643
|
-
*
|
|
644
|
-
* notBoth("a") // => true
|
|
645
|
-
* ```
|
|
646
|
-
*
|
|
647
|
-
* @see {@link and}
|
|
648
|
-
* @see {@link not}
|
|
649
|
-
* @category combinators
|
|
650
|
-
* @since 2.0.0
|
|
651
|
-
*/
|
|
652
90
|
const nand = dual(2, (a, b) => (data) => !a(data) || !b(data));
|
|
653
|
-
/**
|
|
654
|
-
* Checks whether a value is a `function`.
|
|
655
|
-
*
|
|
656
|
-
* **When to use**
|
|
657
|
-
*
|
|
658
|
-
* Use when you need a `Predicate` guard to narrow an `unknown` value to a
|
|
659
|
-
* callable function.
|
|
660
|
-
*
|
|
661
|
-
* **Details**
|
|
662
|
-
*
|
|
663
|
-
* Uses `typeof input === "function"`.
|
|
664
|
-
*
|
|
665
|
-
* **Example** (Guarding functions)
|
|
666
|
-
*
|
|
667
|
-
* ```ts
|
|
668
|
-
* import { Predicate } from "effect"
|
|
669
|
-
*
|
|
670
|
-
* const data: unknown = () => 1
|
|
671
|
-
*
|
|
672
|
-
* if (Predicate.isFunction(data)) {
|
|
673
|
-
* data() // => 1
|
|
674
|
-
* }
|
|
675
|
-
* ```
|
|
676
|
-
*
|
|
677
|
-
* @see {@link isObjectKeyword}
|
|
678
|
-
* @category guards
|
|
679
|
-
* @since 2.0.0
|
|
680
|
-
*/
|
|
681
91
|
function isFunction(input) {
|
|
682
92
|
return typeof input === "function";
|
|
683
93
|
}
|
|
684
|
-
/**
|
|
685
|
-
* Checks whether a value is an `object` in the JavaScript sense (objects, arrays, functions).
|
|
686
|
-
*
|
|
687
|
-
* **When to use**
|
|
688
|
-
*
|
|
689
|
-
* Use when you need a `Predicate` guard that accepts arrays and functions as
|
|
690
|
-
* well as objects.
|
|
691
|
-
*
|
|
692
|
-
* **Details**
|
|
693
|
-
*
|
|
694
|
-
* Returns `true` for arrays and functions, and `false` for `null`.
|
|
695
|
-
*
|
|
696
|
-
* **Example** (Checking object keywords)
|
|
697
|
-
*
|
|
698
|
-
* ```ts
|
|
699
|
-
* import { Predicate } from "effect"
|
|
700
|
-
*
|
|
701
|
-
* Predicate.isObjectKeyword(() => 1) // => true
|
|
702
|
-
* Predicate.isObjectKeyword(null) // => false
|
|
703
|
-
* ```
|
|
704
|
-
*
|
|
705
|
-
* @see {@link isObject}
|
|
706
|
-
* @see {@link isObjectOrArray}
|
|
707
|
-
* @category guards
|
|
708
|
-
* @since 4.0.0
|
|
709
|
-
*/
|
|
710
94
|
function isObjectKeyword(input) {
|
|
711
95
|
return typeof input === "object" && input !== null || isFunction(input);
|
|
712
96
|
}
|
|
713
|
-
/**
|
|
714
|
-
* Checks whether a value has a given property key.
|
|
715
|
-
*
|
|
716
|
-
* **When to use**
|
|
717
|
-
*
|
|
718
|
-
* Use when you need a `Predicate` guard for property access on `unknown`
|
|
719
|
-
* values with a simple structural object check.
|
|
720
|
-
*
|
|
721
|
-
* **Details**
|
|
722
|
-
*
|
|
723
|
-
* Uses the `in` operator and `isObjectKeyword`. This does not check property
|
|
724
|
-
* value types.
|
|
725
|
-
*
|
|
726
|
-
* **Example** (Guarding object properties)
|
|
727
|
-
*
|
|
728
|
-
* ```ts
|
|
729
|
-
* import { Predicate } from "effect"
|
|
730
|
-
*
|
|
731
|
-
* const hasName = Predicate.hasProperty("name")
|
|
732
|
-
* const data: unknown = { name: "Ada" }
|
|
733
|
-
*
|
|
734
|
-
* if (hasName(data)) {
|
|
735
|
-
* data.name // => "Ada"
|
|
736
|
-
* }
|
|
737
|
-
* ```
|
|
738
|
-
*
|
|
739
|
-
* @see {@link isTagged}
|
|
740
|
-
* @see {@link isObjectKeyword}
|
|
741
|
-
* @category guards
|
|
742
|
-
* @since 2.0.0
|
|
743
|
-
*/
|
|
744
97
|
const hasProperty = dual(2, (data, property) => isObjectKeyword(data) && property in data);
|
|
745
|
-
/**
|
|
746
|
-
* Drops elements from the start while the predicate holds, returning the rest.
|
|
747
|
-
*
|
|
748
|
-
* **When to use**
|
|
749
|
-
*
|
|
750
|
-
* Use to remove a leading prefix of elements that satisfy a predicate.
|
|
751
|
-
*
|
|
752
|
-
* **Details**
|
|
753
|
-
*
|
|
754
|
-
* The predicate receives `(element, index)`.
|
|
755
|
-
*
|
|
756
|
-
* **Example** (Dropping while condition holds)
|
|
757
|
-
*
|
|
758
|
-
* ```ts
|
|
759
|
-
* import { Array } from "effect"
|
|
760
|
-
*
|
|
761
|
-
* Array.dropWhile([1, 2, 3, 4, 5], (x) => x < 4) // => [4, 5]
|
|
762
|
-
* ```
|
|
763
|
-
*
|
|
764
|
-
* @see {@link takeWhile} — keep the matching prefix instead
|
|
765
|
-
* @see {@link drop} — drop a fixed count
|
|
766
|
-
*
|
|
767
|
-
* @category getters
|
|
768
|
-
* @since 2.0.0
|
|
769
|
-
*/
|
|
770
98
|
const dropWhile = dual(2, (self, predicate) => {
|
|
771
99
|
const input = Array.isArray(self) ? self : Array.from(self);
|
|
772
100
|
const len = input.length;
|
|
@@ -774,35 +102,6 @@ const dropWhile = dual(2, (self, predicate) => {
|
|
|
774
102
|
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
775
103
|
return input.slice(idx);
|
|
776
104
|
});
|
|
777
|
-
/**
|
|
778
|
-
* Takes elements from the start while the predicate holds, stopping at the
|
|
779
|
-
* first element that fails.
|
|
780
|
-
*
|
|
781
|
-
* **When to use**
|
|
782
|
-
*
|
|
783
|
-
* Use to keep the leading elements of an iterable while each element satisfies
|
|
784
|
-
* a predicate, returning the retained prefix as an array.
|
|
785
|
-
*
|
|
786
|
-
* **Details**
|
|
787
|
-
*
|
|
788
|
-
* Supports refinements for type narrowing. The predicate receives
|
|
789
|
-
* `(element, index)`.
|
|
790
|
-
*
|
|
791
|
-
* **Example** (Taking while condition holds)
|
|
792
|
-
*
|
|
793
|
-
* ```ts
|
|
794
|
-
* import { Array } from "effect"
|
|
795
|
-
*
|
|
796
|
-
* Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4) // => [1, 3, 2]
|
|
797
|
-
* ```
|
|
798
|
-
*
|
|
799
|
-
* @see {@link take} for keeping a fixed number of leading elements
|
|
800
|
-
* @see {@link dropWhile} for removing the matching prefix and keeping the rest
|
|
801
|
-
* @see {@link span} for splitting the matching prefix from the remaining elements
|
|
802
|
-
*
|
|
803
|
-
* @category getters
|
|
804
|
-
* @since 2.0.0
|
|
805
|
-
*/
|
|
806
105
|
const takeWhile = dual(2, (self, predicate) => {
|
|
807
106
|
const input = Array.isArray(self) ? self : Array.from(self);
|
|
808
107
|
const len = input.length;
|
|
@@ -813,175 +112,71 @@ const takeWhile = dual(2, (self, predicate) => {
|
|
|
813
112
|
|
|
814
113
|
//#endregion
|
|
815
114
|
//#region src/regexp.ts
|
|
816
|
-
/** Regular expression for matching an HTML tag name. */
|
|
817
115
|
const RE_HTML_TAG = /^[a-z][^-]*$/u;
|
|
818
|
-
/** Regular expression for matching a TypeScript file extension. */
|
|
819
116
|
const RE_TS_EXT = /^[cm]?tsx?$/u;
|
|
820
|
-
/** Regular expression for matching a JavaScript file extension. */
|
|
821
117
|
const RE_JS_EXT = /^[cm]?jsx?$/u;
|
|
822
|
-
/** Regular expression for matching a PascalCase string. */
|
|
823
118
|
const RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
|
|
824
|
-
/** Regular expression for matching a camelCase string. */
|
|
825
119
|
const RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
|
|
826
|
-
/** Regular expression for matching a kebab-case string. */
|
|
827
120
|
const RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
|
|
828
|
-
/** Regular expression for matching a snake_case string. */
|
|
829
121
|
const RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
|
|
830
|
-
/** Regular expression for matching a CONSTANT_CASE string. */
|
|
831
122
|
const RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
|
|
832
|
-
/**
|
|
833
|
-
* Regular expression for matching the `javascript:` protocol.
|
|
834
|
-
* @see https://github.com/facebook/react/blob/6db7f4209e6f32ebde298a0b7451710dd6aa3e19/packages/react-dom-bindings/src/shared/sanitizeURL.js#L22
|
|
835
|
-
*/
|
|
836
123
|
const RE_JAVASCRIPT_PROTOCOL = /^[\u0000-\u001F ]*j[\t\n\r]*a[\t\n\r]*v[\t\n\r]*a[\t\n\r]*s[\t\n\r]*c[\t\n\r]*r[\t\n\r]*i[\t\n\r]*p[\t\n\r]*t[\t\n\r]*:/iu;
|
|
837
|
-
/** Regular expression for matching a valid JavaScript identifier. */
|
|
838
124
|
const RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
|
|
839
|
-
/** Regular expression for matching a RegExp string. */
|
|
840
125
|
const RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
|
|
841
|
-
/** Regular expression for matching a `@jsx` annotation comment. */
|
|
842
126
|
const RE_ANNOTATION_JSX = /@jsx\s+(\S+)/u;
|
|
843
|
-
/** Regular expression for matching a `@jsxFrag` annotation comment. */
|
|
844
127
|
const RE_ANNOTATION_JSX_FRAG = /@jsxFrag\s+(\S+)/u;
|
|
845
|
-
/** Regular expression for matching a `@jsxRuntime` annotation comment. */
|
|
846
128
|
const RE_ANNOTATION_JSX_RUNTIME = /@jsxRuntime\s+(\S+)/u;
|
|
847
|
-
/** Regular expression for matching a `@jsxImportSource` annotation comment. */
|
|
848
129
|
const RE_ANNOTATION_JSX_IMPORT_SOURCE = /@jsxImportSource\s+(\S+)/u;
|
|
849
|
-
/** Regular expression for matching a React component name. */
|
|
850
130
|
const RE_COMPONENT_NAME = /^[A-Z]/u;
|
|
851
|
-
/** Regular expression for matching a React component name (loose). */
|
|
852
131
|
const RE_COMPONENT_NAME_LOOSE = /^_?[A-Z]/u;
|
|
853
|
-
/** Regular expression for matching a React Hook name. */
|
|
854
132
|
const RE_HOOK_NAME = /^use/u;
|
|
855
|
-
/**
|
|
856
|
-
* Convert a string to a `RegExpLike` object.
|
|
857
|
-
*
|
|
858
|
-
* Normal strings (ex: `"foo"`) are converted to `/^foo$/`.
|
|
859
|
-
* RegExp strings (ex: `"/^foo/i"`) are converted to `/^foo/i`.
|
|
860
|
-
* @param string The string to convert.
|
|
861
|
-
* @returns The converted `RegExpLike` object.
|
|
862
|
-
* @see https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/utils/regexp.ts
|
|
863
|
-
*/
|
|
864
133
|
function toRegExp(string) {
|
|
865
134
|
if (string == null) return { test: constFalse };
|
|
866
135
|
const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
|
|
867
136
|
if (pattern != null) return new RegExp(pattern, flags);
|
|
868
137
|
return { test: (s) => s === string };
|
|
869
138
|
}
|
|
870
|
-
/**
|
|
871
|
-
* Check if the string is a RegExp string.
|
|
872
|
-
* @param string The string to check.
|
|
873
|
-
* @returns `true` if the string is a RegExp string.
|
|
874
|
-
*/
|
|
875
139
|
function isRegExp(string) {
|
|
876
140
|
return RE_REGEXP_STR.test(string);
|
|
877
141
|
}
|
|
878
142
|
|
|
879
143
|
//#endregion
|
|
880
144
|
//#region src/settings.ts
|
|
881
|
-
/**
|
|
882
|
-
* The zod schema for the ESLint React settings.
|
|
883
|
-
* @internal
|
|
884
|
-
*/
|
|
885
145
|
const ESLintReactSettingsSchema = z.object({
|
|
886
|
-
/**
|
|
887
|
-
* The source where React is imported from.
|
|
888
|
-
* Allows specifying a custom import location for React.
|
|
889
|
-
* @default "react"
|
|
890
|
-
* @example "@pika/react"
|
|
891
|
-
*/
|
|
892
146
|
importSource: z.optional(z.string()),
|
|
893
|
-
/**
|
|
894
|
-
* The React Compiler compilationMode that the project is using.
|
|
895
|
-
* Used to inform the rule about how components and hooks will be picked up by the compiler.
|
|
896
|
-
* @example "infer"
|
|
897
|
-
*/
|
|
898
147
|
compilationMode: z.optional(z.enum([
|
|
899
148
|
"infer",
|
|
900
149
|
"annotation",
|
|
901
150
|
"syntax",
|
|
902
151
|
"all"
|
|
903
152
|
])),
|
|
904
|
-
/**
|
|
905
|
-
* The prop name used for polymorphic components.
|
|
906
|
-
* Used to determine the component's type.
|
|
907
|
-
* @example "as"
|
|
908
|
-
*/
|
|
909
153
|
polymorphicPropName: z.optional(z.string()),
|
|
910
|
-
/**
|
|
911
|
-
* React version to use.
|
|
912
|
-
* "detect" means auto-detect React version from project dependencies.
|
|
913
|
-
* @example "18.3.1"
|
|
914
|
-
* @default "detect"
|
|
915
|
-
*/
|
|
916
154
|
version: z.optional(z.string()),
|
|
917
|
-
/**
|
|
918
|
-
* Regex pattern matching custom hooks that should be treated as ref hooks.
|
|
919
|
-
* @example "useMyRef|useCustomRef"
|
|
920
|
-
*/
|
|
921
155
|
additionalRefHooks: z.optional(z.string()),
|
|
922
|
-
/**
|
|
923
|
-
* Regex pattern matching custom hooks that should be treated as state hooks.
|
|
924
|
-
* @example "useMyState|useCustomState"
|
|
925
|
-
*/
|
|
926
156
|
additionalStateHooks: z.optional(z.string()),
|
|
927
|
-
/**
|
|
928
|
-
* Regex pattern matching custom hooks that should be treated as effect hooks.
|
|
929
|
-
* @example "useMyEffect|useCustomEffect"
|
|
930
|
-
*/
|
|
931
157
|
additionalEffectHooks: z.optional(z.string())
|
|
932
158
|
});
|
|
933
|
-
/**
|
|
934
|
-
* The zod schema for the ESLint settings.
|
|
935
|
-
* @internal
|
|
936
|
-
*/
|
|
937
159
|
const ESLintSettingsSchema = z.optional(z.object({ "react-x": z.optional(z.unknown()) }));
|
|
938
|
-
/** The default ESLint React settings. */
|
|
939
160
|
const DEFAULT_ESLINT_REACT_SETTINGS = {
|
|
940
161
|
version: "detect",
|
|
941
162
|
importSource: "react",
|
|
942
163
|
polymorphicPropName: "as"
|
|
943
164
|
};
|
|
944
|
-
/** The default ESLint settings. */
|
|
945
165
|
const DEFAULT_ESLINT_SETTINGS = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
|
|
946
|
-
/**
|
|
947
|
-
* Check if the value is valid ESLint settings.
|
|
948
|
-
* @param settings The value to check.
|
|
949
|
-
* @returns `true` if the value is valid ESLint settings.
|
|
950
|
-
*/
|
|
951
166
|
function isESLintSettings(settings) {
|
|
952
167
|
return ESLintSettingsSchema.safeParse(settings).success;
|
|
953
168
|
}
|
|
954
|
-
/**
|
|
955
|
-
* Check if the value is valid ESLint React settings.
|
|
956
|
-
* @param settings The value to check.
|
|
957
|
-
* @returns `true` if the value is valid ESLint React settings.
|
|
958
|
-
*/
|
|
959
169
|
function isESLintReactSettings(settings) {
|
|
960
170
|
return ESLintReactSettingsSchema.safeParse(settings).success;
|
|
961
171
|
}
|
|
962
|
-
/**
|
|
963
|
-
* Decode the ESLint settings, falling back to the defaults when invalid.
|
|
964
|
-
* @param settings The value to decode.
|
|
965
|
-
* @returns The decoded ESLint settings.
|
|
966
|
-
*/
|
|
967
172
|
const decodeESLintSettings = (settings) => {
|
|
968
173
|
if (isESLintSettings(settings)) return settings;
|
|
969
174
|
return DEFAULT_ESLINT_SETTINGS;
|
|
970
175
|
};
|
|
971
|
-
/**
|
|
972
|
-
* Decode the ESLint React settings, falling back to the defaults when invalid.
|
|
973
|
-
* @param settings The value to decode.
|
|
974
|
-
* @returns The decoded ESLint React settings.
|
|
975
|
-
*/
|
|
976
176
|
const decodeSettings = (settings) => {
|
|
977
177
|
if (isESLintReactSettings(settings)) return settings;
|
|
978
178
|
return DEFAULT_ESLINT_REACT_SETTINGS;
|
|
979
179
|
};
|
|
980
|
-
/**
|
|
981
|
-
* Normalize the ESLint React settings to the form used by rules.
|
|
982
|
-
* @param settings The ESLint React settings to normalize.
|
|
983
|
-
* @returns The normalized ESLint React settings.
|
|
984
|
-
*/
|
|
985
180
|
const normalizeSettings = ({ importSource = "react", compilationMode, polymorphicPropName = "as", version, additionalRefHooks, additionalStateHooks, additionalEffectHooks, ...rest }) => {
|
|
986
181
|
return {
|
|
987
182
|
...rest,
|
|
@@ -994,11 +189,6 @@ const normalizeSettings = ({ importSource = "react", compilationMode, polymorphi
|
|
|
994
189
|
additionalEffectHooks: toRegExp(additionalEffectHooks)
|
|
995
190
|
};
|
|
996
191
|
};
|
|
997
|
-
/**
|
|
998
|
-
* Get the React version from the project's dependencies.
|
|
999
|
-
* @param fallback The fallback version to return if React is not found.
|
|
1000
|
-
* @returns The detected React version or the fallback version.
|
|
1001
|
-
*/
|
|
1002
192
|
function getReactVersion(fallback) {
|
|
1003
193
|
try {
|
|
1004
194
|
return match(module.createRequire(process.cwd() + path.sep)("react")).with({ version: P.select(P.string) }, identity).otherwise(() => fallback);
|
|
@@ -1006,17 +196,7 @@ function getReactVersion(fallback) {
|
|
|
1006
196
|
return fallback;
|
|
1007
197
|
}
|
|
1008
198
|
}
|
|
1009
|
-
/**
|
|
1010
|
-
* Get the normalized ESLint React settings, memoized by the input settings object.
|
|
1011
|
-
* @param settings The ESLint React settings to decode and normalize.
|
|
1012
|
-
* @returns The normalized ESLint React settings.
|
|
1013
|
-
*/
|
|
1014
199
|
const getNormalizedSettings = memoize((settings) => normalizeSettings(decodeSettings(settings)));
|
|
1015
|
-
/**
|
|
1016
|
-
* Get the normalized ESLint React settings from the rule context.
|
|
1017
|
-
* @param context The rule context.
|
|
1018
|
-
* @returns The normalized ESLint React settings.
|
|
1019
|
-
*/
|
|
1020
200
|
function getSettingsFromContext(context) {
|
|
1021
201
|
const settings = context.settings["react-x"];
|
|
1022
202
|
return getNormalizedSettings(isObjectKeyword(settings) ? settings : DEFAULT_ESLINT_REACT_SETTINGS);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/shared",
|
|
3
|
-
"version": "5.24.
|
|
3
|
+
"version": "5.24.2",
|
|
4
4
|
"description": "ESLint React's Shared constants and functions.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@eslint-react/eslint": "5.24.
|
|
32
|
+
"@eslint-react/eslint": "5.24.2",
|
|
33
33
|
"@typescript-eslint/utils": "^8.71.0",
|
|
34
34
|
"ts-pattern": "^5.9.0",
|
|
35
35
|
"zod": "^3.25.0 || ^4.0.0"
|