eslint-plugin-react-web-api 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 +1 -718
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region package.json
|
|
29
29
|
var name$1 = "eslint-plugin-react-web-api";
|
|
30
|
-
var version = "5.24.
|
|
30
|
+
var version = "5.24.2";
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/utils/create-rule.ts
|
|
@@ -38,44 +38,6 @@ const createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region ../../.pkgs/eff/dist/index.js
|
|
41
|
-
/**
|
|
42
|
-
* Applies a `pipe` method's variadic arguments to an initial value from left
|
|
43
|
-
* to right.
|
|
44
|
-
*
|
|
45
|
-
* **When to use**
|
|
46
|
-
*
|
|
47
|
-
* Use to implement a custom `.pipe(...)` method from JavaScript's `arguments`
|
|
48
|
-
* object.
|
|
49
|
-
*
|
|
50
|
-
* **Details**
|
|
51
|
-
*
|
|
52
|
-
* This helper is intended for implementing `Pipeable.pipe` methods that
|
|
53
|
-
* receive JavaScript's `arguments` object. With no functions it returns the
|
|
54
|
-
* original value; otherwise it feeds each result into the next function.
|
|
55
|
-
*
|
|
56
|
-
* **Example** (Implementing a pipe method)
|
|
57
|
-
*
|
|
58
|
-
* ```ts
|
|
59
|
-
* import { Pipeable } from "effect"
|
|
60
|
-
*
|
|
61
|
-
* class NumberBox {
|
|
62
|
-
* constructor(readonly value: number) {}
|
|
63
|
-
*
|
|
64
|
-
* pipe(..._fns: ReadonlyArray<(value: number) => number>): number {
|
|
65
|
-
* return Pipeable.pipeArguments(this.value, arguments) as number
|
|
66
|
-
* }
|
|
67
|
-
* }
|
|
68
|
-
*
|
|
69
|
-
* const result = new NumberBox(5).pipe(
|
|
70
|
-
* (n) => n + 2,
|
|
71
|
-
* (n) => n * 3
|
|
72
|
-
* )
|
|
73
|
-
* result // => 21
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* @category combinators
|
|
77
|
-
* @since 2.0.0
|
|
78
|
-
*/
|
|
79
41
|
const pipeArguments = (self, args) => {
|
|
80
42
|
switch (args.length) {
|
|
81
43
|
case 0: return self;
|
|
@@ -95,100 +57,14 @@ const pipeArguments = (self, args) => {
|
|
|
95
57
|
}
|
|
96
58
|
}
|
|
97
59
|
};
|
|
98
|
-
/**
|
|
99
|
-
* Reusable prototype that implements `Pipeable.pipe`.
|
|
100
|
-
*
|
|
101
|
-
* **When to use**
|
|
102
|
-
*
|
|
103
|
-
* Use when classes or object prototypes can reuse this value when they need the
|
|
104
|
-
* standard pipe implementation backed by `pipeArguments`.
|
|
105
|
-
*
|
|
106
|
-
* @category prototypes
|
|
107
|
-
* @since 3.15.0
|
|
108
|
-
*/
|
|
109
60
|
const Prototype = { pipe() {
|
|
110
61
|
return pipeArguments(this, arguments);
|
|
111
62
|
} };
|
|
112
|
-
/**
|
|
113
|
-
* Provides a base constructor whose instances implement the standard `Pipeable.pipe`
|
|
114
|
-
* method.
|
|
115
|
-
*
|
|
116
|
-
* **When to use**
|
|
117
|
-
*
|
|
118
|
-
* Use when you need to define a class that supports Effect-style method
|
|
119
|
-
* chaining through `.pipe(...)`.
|
|
120
|
-
*
|
|
121
|
-
* @category constructors
|
|
122
|
-
* @since 3.15.0
|
|
123
|
-
*/
|
|
124
63
|
const Class = (function() {
|
|
125
64
|
function PipeableBase() {}
|
|
126
65
|
PipeableBase.prototype = Prototype;
|
|
127
66
|
return PipeableBase;
|
|
128
67
|
})();
|
|
129
|
-
/**
|
|
130
|
-
* Creates a function that can be called in data-first style or data-last
|
|
131
|
-
* (`pipe`-friendly) style.
|
|
132
|
-
*
|
|
133
|
-
* **When to use**
|
|
134
|
-
*
|
|
135
|
-
* Use to expose one implementation through both direct and `pipe`-friendly
|
|
136
|
-
* call styles.
|
|
137
|
-
*
|
|
138
|
-
* **Details**
|
|
139
|
-
*
|
|
140
|
-
* Pass either the arity of the uncurried function or a predicate that decides
|
|
141
|
-
* whether the current call is data-first. Arity is the common case. Use a
|
|
142
|
-
* predicate when optional arguments make arity ambiguous.
|
|
143
|
-
*
|
|
144
|
-
* **Example** (Selecting data-first or data-last style by arity)
|
|
145
|
-
*
|
|
146
|
-
* ```ts
|
|
147
|
-
* import { Function, pipe } from "effect"
|
|
148
|
-
*
|
|
149
|
-
* const sum = Function.dual<
|
|
150
|
-
* (that: number) => (self: number) => number,
|
|
151
|
-
* (self: number, that: number) => number
|
|
152
|
-
* >(2, (self, that) => self + that)
|
|
153
|
-
*
|
|
154
|
-
* sum(2, 3) // => 5
|
|
155
|
-
* pipe(2, sum(3)) // => 5
|
|
156
|
-
* ```
|
|
157
|
-
*
|
|
158
|
-
* **Example** (Defining overloads with call signatures)
|
|
159
|
-
*
|
|
160
|
-
* ```ts
|
|
161
|
-
* import { Function, pipe } from "effect"
|
|
162
|
-
*
|
|
163
|
-
* const sum: {
|
|
164
|
-
* (that: number): (self: number) => number
|
|
165
|
-
* (self: number, that: number): number
|
|
166
|
-
* } = Function.dual(2, (self: number, that: number): number => self + that)
|
|
167
|
-
*
|
|
168
|
-
* sum(2, 3) // => 5
|
|
169
|
-
* pipe(2, sum(3)) // => 5
|
|
170
|
-
* ```
|
|
171
|
-
*
|
|
172
|
-
* **Example** (Selecting data-first or data-last style with a predicate)
|
|
173
|
-
*
|
|
174
|
-
* ```ts
|
|
175
|
-
* import { Function, pipe } from "effect"
|
|
176
|
-
*
|
|
177
|
-
* const sum = Function.dual<
|
|
178
|
-
* (that: number) => (self: number) => number,
|
|
179
|
-
* (self: number, that: number) => number
|
|
180
|
-
* >(
|
|
181
|
-
* (args) => args.length === 2,
|
|
182
|
-
* (self, that) => self + that
|
|
183
|
-
* )
|
|
184
|
-
*
|
|
185
|
-
* sum(2, 3) // => 5
|
|
186
|
-
* pipe(2, sum(3)) // => 5
|
|
187
|
-
* ```
|
|
188
|
-
*
|
|
189
|
-
* @category combinators
|
|
190
|
-
* @since 2.0.0
|
|
191
|
-
*/
|
|
192
68
|
const dual = function(arity, body) {
|
|
193
69
|
if (typeof arity === "function") return function() {
|
|
194
70
|
return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
|
|
@@ -217,562 +93,34 @@ const dual = function(arity, body) {
|
|
|
217
93
|
};
|
|
218
94
|
}
|
|
219
95
|
};
|
|
220
|
-
/**
|
|
221
|
-
* Returns its input argument unchanged.
|
|
222
|
-
*
|
|
223
|
-
* **When to use**
|
|
224
|
-
*
|
|
225
|
-
* Use to return a value unchanged where a function is required.
|
|
226
|
-
*
|
|
227
|
-
* **Example** (Returning the same value)
|
|
228
|
-
*
|
|
229
|
-
* ```ts
|
|
230
|
-
* import { identity } from "effect"
|
|
231
|
-
*
|
|
232
|
-
* identity(5) // => 5
|
|
233
|
-
* ```
|
|
234
|
-
*
|
|
235
|
-
* @category combinators
|
|
236
|
-
* @since 2.0.0
|
|
237
|
-
*/
|
|
238
96
|
const identity = (a) => a;
|
|
239
|
-
/**
|
|
240
|
-
* Returns the input value with a different static type.
|
|
241
|
-
*
|
|
242
|
-
* **When to use**
|
|
243
|
-
*
|
|
244
|
-
* Use when you need an explicit type-level cast and accept that the value is
|
|
245
|
-
* returned unchanged at runtime.
|
|
246
|
-
*
|
|
247
|
-
* **Gotchas**
|
|
248
|
-
*
|
|
249
|
-
* This is a type-level cast only; it performs no runtime validation or
|
|
250
|
-
* conversion.
|
|
251
|
-
*
|
|
252
|
-
* @see {@link satisfies} for checking assignability without changing the resulting type
|
|
253
|
-
*
|
|
254
|
-
* @category utility types
|
|
255
|
-
* @since 4.0.0
|
|
256
|
-
*/
|
|
257
97
|
const cast = identity;
|
|
258
|
-
/**
|
|
259
|
-
* Creates a zero-argument function that always returns the provided value.
|
|
260
|
-
*
|
|
261
|
-
* **When to use**
|
|
262
|
-
*
|
|
263
|
-
* Use when you need a thunk or callback that returns the same value on every
|
|
264
|
-
* invocation.
|
|
265
|
-
*
|
|
266
|
-
* **Example** (Creating a constant thunk)
|
|
267
|
-
*
|
|
268
|
-
* ```ts
|
|
269
|
-
* import { Function } from "effect"
|
|
270
|
-
*
|
|
271
|
-
* const constNull = Function.constant(null)
|
|
272
|
-
*
|
|
273
|
-
* constNull() // => null
|
|
274
|
-
* constNull() // => null
|
|
275
|
-
* ```
|
|
276
|
-
*
|
|
277
|
-
* @category constructors
|
|
278
|
-
* @since 2.0.0
|
|
279
|
-
*/
|
|
280
98
|
const constant = (value) => () => value;
|
|
281
|
-
/**
|
|
282
|
-
* Returns `true` when called.
|
|
283
|
-
*
|
|
284
|
-
* **When to use**
|
|
285
|
-
*
|
|
286
|
-
* Use when you need a thunk that returns `true` on every invocation.
|
|
287
|
-
*
|
|
288
|
-
* **Example** (Returning true from a thunk)
|
|
289
|
-
*
|
|
290
|
-
* ```ts
|
|
291
|
-
* import { Function } from "effect"
|
|
292
|
-
*
|
|
293
|
-
* Function.constTrue() // => true
|
|
294
|
-
* ```
|
|
295
|
-
*
|
|
296
|
-
* @category constants
|
|
297
|
-
* @since 2.0.0
|
|
298
|
-
*/
|
|
299
99
|
const constTrue = constant(true);
|
|
300
|
-
/**
|
|
301
|
-
* Returns `false` when called.
|
|
302
|
-
*
|
|
303
|
-
* **When to use**
|
|
304
|
-
*
|
|
305
|
-
* Use when you need a thunk that returns `false` on every invocation.
|
|
306
|
-
*
|
|
307
|
-
* **Example** (Returning false from a thunk)
|
|
308
|
-
*
|
|
309
|
-
* ```ts
|
|
310
|
-
* import { Function } from "effect"
|
|
311
|
-
*
|
|
312
|
-
* Function.constFalse() // => false
|
|
313
|
-
* ```
|
|
314
|
-
*
|
|
315
|
-
* @category constants
|
|
316
|
-
* @since 2.0.0
|
|
317
|
-
*/
|
|
318
100
|
const constFalse = constant(false);
|
|
319
|
-
/**
|
|
320
|
-
* Returns `null` when called.
|
|
321
|
-
*
|
|
322
|
-
* **When to use**
|
|
323
|
-
*
|
|
324
|
-
* Use when you need a thunk that returns `null` on every invocation.
|
|
325
|
-
*
|
|
326
|
-
* **Example** (Returning null from a thunk)
|
|
327
|
-
*
|
|
328
|
-
* ```ts
|
|
329
|
-
* import { Function } from "effect"
|
|
330
|
-
*
|
|
331
|
-
* Function.constNull() // => null
|
|
332
|
-
* ```
|
|
333
|
-
*
|
|
334
|
-
* @category constants
|
|
335
|
-
* @since 2.0.0
|
|
336
|
-
*/
|
|
337
101
|
const constNull = constant(null);
|
|
338
|
-
/**
|
|
339
|
-
* Returns `undefined` when called.
|
|
340
|
-
*
|
|
341
|
-
* **When to use**
|
|
342
|
-
*
|
|
343
|
-
* Use when you need a thunk that returns `undefined` on every invocation.
|
|
344
|
-
*
|
|
345
|
-
* **Example** (Returning undefined from a thunk)
|
|
346
|
-
*
|
|
347
|
-
* ```ts
|
|
348
|
-
* import { Function } from "effect"
|
|
349
|
-
*
|
|
350
|
-
* Function.constUndefined() // => undefined
|
|
351
|
-
* ```
|
|
352
|
-
*
|
|
353
|
-
* @category constants
|
|
354
|
-
* @since 2.0.0
|
|
355
|
-
*/
|
|
356
102
|
const constUndefined = constant(void 0);
|
|
357
|
-
/**
|
|
358
|
-
* 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`.
|
|
359
|
-
* The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
|
|
360
|
-
*
|
|
361
|
-
* **When to use**
|
|
362
|
-
*
|
|
363
|
-
* Use to compose exactly two unary functions into a reusable unary function.
|
|
364
|
-
*
|
|
365
|
-
* **Example** (Composing two functions)
|
|
366
|
-
*
|
|
367
|
-
* ```ts
|
|
368
|
-
* import { Function } from "effect"
|
|
369
|
-
*
|
|
370
|
-
* const increment = (n: number) => n + 1
|
|
371
|
-
* const square = (n: number) => n * n
|
|
372
|
-
*
|
|
373
|
-
* Function.compose(increment, square)(2) // => 9
|
|
374
|
-
* ```
|
|
375
|
-
*
|
|
376
|
-
* @see {@link flow} for composing a left-to-right sequence of functions
|
|
377
|
-
* @see {@link pipe} for applying a value through a left-to-right sequence immediately
|
|
378
|
-
*
|
|
379
|
-
* @category combinators
|
|
380
|
-
* @since 2.0.0
|
|
381
|
-
*/
|
|
382
103
|
const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
383
|
-
/**
|
|
384
|
-
* Marks an impossible branch by accepting a `never` value and returning any
|
|
385
|
-
* type.
|
|
386
|
-
*
|
|
387
|
-
* **When to use**
|
|
388
|
-
*
|
|
389
|
-
* Use when you need a return value in a branch that exhaustive checks prove
|
|
390
|
-
* cannot be reached.
|
|
391
|
-
*
|
|
392
|
-
* **Gotchas**
|
|
393
|
-
*
|
|
394
|
-
* Calling `absurd` throws, because a value of type `never` should be
|
|
395
|
-
* impossible at runtime.
|
|
396
|
-
*
|
|
397
|
-
* **Example** (Handling impossible values)
|
|
398
|
-
*
|
|
399
|
-
* ```ts
|
|
400
|
-
* import { absurd } from "effect"
|
|
401
|
-
*
|
|
402
|
-
* const handleNever = (value: never) => {
|
|
403
|
-
* return absurd(value) // This will throw an error if called
|
|
404
|
-
* }
|
|
405
|
-
* ```
|
|
406
|
-
*
|
|
407
|
-
* @category utility types
|
|
408
|
-
* @since 2.0.0
|
|
409
|
-
*/
|
|
410
104
|
const absurd = (_) => {
|
|
411
105
|
throw new Error("Called `absurd` function which should be uncallable");
|
|
412
106
|
};
|
|
413
|
-
/**
|
|
414
|
-
* Creates a compile-time placeholder for a value of any type.
|
|
415
|
-
*
|
|
416
|
-
* **When to use**
|
|
417
|
-
*
|
|
418
|
-
* Use as a temporary typed placeholder while developing incomplete code.
|
|
419
|
-
*
|
|
420
|
-
* **Gotchas**
|
|
421
|
-
*
|
|
422
|
-
* `hole` is intended for temporary development use. If the placeholder is
|
|
423
|
-
* evaluated at runtime, it throws.
|
|
424
|
-
*
|
|
425
|
-
* **Example** (Creating a development placeholder)
|
|
426
|
-
*
|
|
427
|
-
* ```ts
|
|
428
|
-
* import { hole } from "effect"
|
|
429
|
-
*
|
|
430
|
-
* // Intentionally not called: `hole` throws if the placeholder is evaluated.
|
|
431
|
-
* const buildUser = (id: number): { readonly id: number; readonly name: string } => ({
|
|
432
|
-
* id,
|
|
433
|
-
* name: hole<string>()
|
|
434
|
-
* })
|
|
435
|
-
*
|
|
436
|
-
* ```
|
|
437
|
-
*
|
|
438
|
-
* @category utility types
|
|
439
|
-
* @since 2.0.0
|
|
440
|
-
*/
|
|
441
107
|
const hole = cast(absurd);
|
|
442
|
-
/**
|
|
443
|
-
* Creates a predicate that returns `true` only if both predicates are `true`.
|
|
444
|
-
*
|
|
445
|
-
* **When to use**
|
|
446
|
-
*
|
|
447
|
-
* Use when you want to combine `Predicate`s with AND, accepting values that
|
|
448
|
-
* satisfy multiple conditions, including refinements that narrow to an
|
|
449
|
-
* intersection.
|
|
450
|
-
*
|
|
451
|
-
* **Details**
|
|
452
|
-
*
|
|
453
|
-
* Evaluation short-circuits on the first `false`. For refinements, the output
|
|
454
|
-
* type is an intersection.
|
|
455
|
-
*
|
|
456
|
-
* **Example** (Checking both conditions)
|
|
457
|
-
*
|
|
458
|
-
* ```ts
|
|
459
|
-
* import { Predicate } from "effect"
|
|
460
|
-
*
|
|
461
|
-
* const hasAAndB = Predicate.and(
|
|
462
|
-
* Predicate.hasProperty("a"),
|
|
463
|
-
* Predicate.hasProperty("b")
|
|
464
|
-
* )
|
|
465
|
-
*
|
|
466
|
-
* const input: unknown = JSON.parse(`{"a":1,"b":"ok"}`)
|
|
467
|
-
* if (hasAAndB(input)) {
|
|
468
|
-
* // input has both properties at this point
|
|
469
|
-
* const a = input.a
|
|
470
|
-
* const b = input.b
|
|
471
|
-
*
|
|
472
|
-
* const values = [a, b] // => [1, "ok"]
|
|
473
|
-
* }
|
|
474
|
-
* ```
|
|
475
|
-
*
|
|
476
|
-
* @see {@link or}
|
|
477
|
-
* @see {@link not}
|
|
478
|
-
* @category combinators
|
|
479
|
-
* @since 2.0.0
|
|
480
|
-
*/
|
|
481
108
|
const and = dual(2, (a, b) => (data) => a(data) && b(data));
|
|
482
|
-
/**
|
|
483
|
-
* Creates a predicate that returns `true` if either predicate is `true`.
|
|
484
|
-
*
|
|
485
|
-
* **When to use**
|
|
486
|
-
*
|
|
487
|
-
* Use when you want to combine `Predicate`s with OR, accepting values that
|
|
488
|
-
* satisfy at least one condition, including refinements that narrow to a union.
|
|
489
|
-
*
|
|
490
|
-
* **Details**
|
|
491
|
-
*
|
|
492
|
-
* Evaluation short-circuits on the first `true`. For refinements, the output
|
|
493
|
-
* type is a union.
|
|
494
|
-
*
|
|
495
|
-
* **Example** (Checking either condition)
|
|
496
|
-
*
|
|
497
|
-
* ```ts
|
|
498
|
-
* import { Predicate } from "effect"
|
|
499
|
-
*
|
|
500
|
-
* const isStringOrNumber = Predicate.or(Predicate.isString, Predicate.isNumber)
|
|
501
|
-
*
|
|
502
|
-
* isStringOrNumber("a") // => true
|
|
503
|
-
* ```
|
|
504
|
-
*
|
|
505
|
-
* @see {@link and}
|
|
506
|
-
* @see {@link xor}
|
|
507
|
-
* @category combinators
|
|
508
|
-
* @since 2.0.0
|
|
509
|
-
*/
|
|
510
109
|
const or = dual(2, (a, b) => (data) => a(data) || b(data));
|
|
511
|
-
/**
|
|
512
|
-
* Creates a predicate that returns `true` if exactly one predicate is `true`.
|
|
513
|
-
*
|
|
514
|
-
* **When to use**
|
|
515
|
-
*
|
|
516
|
-
* Use when you want to combine two `Predicate`s with exclusive-or semantics.
|
|
517
|
-
*
|
|
518
|
-
* **Details**
|
|
519
|
-
*
|
|
520
|
-
* Returns `true` when results differ.
|
|
521
|
-
*
|
|
522
|
-
* **Example** (Checking exclusive-or conditions)
|
|
523
|
-
*
|
|
524
|
-
* ```ts
|
|
525
|
-
* import { Predicate } from "effect"
|
|
526
|
-
*
|
|
527
|
-
* const isEven = (n: number) => n % 2 === 0
|
|
528
|
-
* const isPositive = (n: number) => n > 0
|
|
529
|
-
* const either = Predicate.xor(isEven, isPositive)
|
|
530
|
-
*
|
|
531
|
-
* either(-2) // => true
|
|
532
|
-
* ```
|
|
533
|
-
*
|
|
534
|
-
* @see {@link or}
|
|
535
|
-
* @see {@link and}
|
|
536
|
-
* @category combinators
|
|
537
|
-
* @since 2.0.0
|
|
538
|
-
*/
|
|
539
110
|
const xor = dual(2, (a, b) => (data) => a(data) !== b(data));
|
|
540
|
-
/**
|
|
541
|
-
* Creates a predicate that returns `true` when both predicates agree.
|
|
542
|
-
*
|
|
543
|
-
* **When to use**
|
|
544
|
-
*
|
|
545
|
-
* Use when you want to check equivalence of two `Predicate`s.
|
|
546
|
-
*
|
|
547
|
-
* **Details**
|
|
548
|
-
*
|
|
549
|
-
* Returns `true` when both results are equal.
|
|
550
|
-
*
|
|
551
|
-
* **Example** (Defining equivalence)
|
|
552
|
-
*
|
|
553
|
-
* ```ts
|
|
554
|
-
* import { Predicate } from "effect"
|
|
555
|
-
*
|
|
556
|
-
* const isEven = (n: number) => n % 2 === 0
|
|
557
|
-
* const same = Predicate.eqv(isEven, isEven)
|
|
558
|
-
*
|
|
559
|
-
* same(3) // => true
|
|
560
|
-
* ```
|
|
561
|
-
*
|
|
562
|
-
* @see {@link xor}
|
|
563
|
-
* @category combinators
|
|
564
|
-
* @since 2.0.0
|
|
565
|
-
*/
|
|
566
111
|
const eqv = dual(2, (a, b) => (data) => a(data) === b(data));
|
|
567
|
-
/**
|
|
568
|
-
* Creates a predicate representing logical implication: if `antecedent`, then `consequent`.
|
|
569
|
-
*
|
|
570
|
-
* **When to use**
|
|
571
|
-
*
|
|
572
|
-
* Use when you need to encode logical implication between `Predicate` rules,
|
|
573
|
-
* where one rule only applies when a precondition holds.
|
|
574
|
-
*
|
|
575
|
-
* **Details**
|
|
576
|
-
*
|
|
577
|
-
* Models constraints like "if A then B" and returns `true` when the antecedent
|
|
578
|
-
* is `false`.
|
|
579
|
-
*
|
|
580
|
-
* **Example** (Checking implication)
|
|
581
|
-
*
|
|
582
|
-
* ```ts
|
|
583
|
-
* import { Predicate } from "effect"
|
|
584
|
-
*
|
|
585
|
-
* const isAdult = (age: number) => age >= 18
|
|
586
|
-
* const canVote = (age: number) => age >= 18
|
|
587
|
-
* const implies = Predicate.implies(isAdult, canVote)
|
|
588
|
-
*
|
|
589
|
-
* implies(16) // => true
|
|
590
|
-
* ```
|
|
591
|
-
*
|
|
592
|
-
* @see {@link and}
|
|
593
|
-
* @see {@link or}
|
|
594
|
-
* @category combinators
|
|
595
|
-
* @since 2.0.0
|
|
596
|
-
*/
|
|
597
112
|
const implies = dual(2, (antecedent, consequent) => (data) => !antecedent(data) || consequent(data));
|
|
598
|
-
/**
|
|
599
|
-
* Creates a predicate that returns `true` when neither predicate is `true`.
|
|
600
|
-
*
|
|
601
|
-
* **When to use**
|
|
602
|
-
*
|
|
603
|
-
* Use when you want to combine two `Predicate`s with logical NOR semantics.
|
|
604
|
-
*
|
|
605
|
-
* **Details**
|
|
606
|
-
*
|
|
607
|
-
* Returns the negation of `or`.
|
|
608
|
-
*
|
|
609
|
-
* **Example** (Checking NOR conditions)
|
|
610
|
-
*
|
|
611
|
-
* ```ts
|
|
612
|
-
* import { Predicate } from "effect"
|
|
613
|
-
*
|
|
614
|
-
* const neither = Predicate.nor(Predicate.isString, Predicate.isNumber)
|
|
615
|
-
*
|
|
616
|
-
* neither(true) // => true
|
|
617
|
-
* ```
|
|
618
|
-
*
|
|
619
|
-
* @see {@link or}
|
|
620
|
-
* @see {@link not}
|
|
621
|
-
* @category combinators
|
|
622
|
-
* @since 2.0.0
|
|
623
|
-
*/
|
|
624
113
|
const nor = dual(2, (a, b) => (data) => !a(data) && !b(data));
|
|
625
|
-
/**
|
|
626
|
-
* Creates a predicate that returns `true` unless both predicates are `true`.
|
|
627
|
-
*
|
|
628
|
-
* **When to use**
|
|
629
|
-
*
|
|
630
|
-
* Use when you want to combine two `Predicate`s with logical NAND semantics.
|
|
631
|
-
*
|
|
632
|
-
* **Details**
|
|
633
|
-
*
|
|
634
|
-
* Returns the negation of `and`.
|
|
635
|
-
*
|
|
636
|
-
* **Example** (Checking NAND conditions)
|
|
637
|
-
*
|
|
638
|
-
* ```ts
|
|
639
|
-
* import { Predicate } from "effect"
|
|
640
|
-
*
|
|
641
|
-
* const notBoth = Predicate.nand(Predicate.isString, Predicate.isNumber)
|
|
642
|
-
*
|
|
643
|
-
* notBoth("a") // => true
|
|
644
|
-
* ```
|
|
645
|
-
*
|
|
646
|
-
* @see {@link and}
|
|
647
|
-
* @see {@link not}
|
|
648
|
-
* @category combinators
|
|
649
|
-
* @since 2.0.0
|
|
650
|
-
*/
|
|
651
114
|
const nand = dual(2, (a, b) => (data) => !a(data) || !b(data));
|
|
652
|
-
/**
|
|
653
|
-
* Checks whether a value is a `string`.
|
|
654
|
-
*
|
|
655
|
-
* **When to use**
|
|
656
|
-
*
|
|
657
|
-
* Use when you need a `Predicate` guard to narrow an `unknown` value to a
|
|
658
|
-
* string.
|
|
659
|
-
*
|
|
660
|
-
* **Details**
|
|
661
|
-
*
|
|
662
|
-
* Uses `typeof input === "string"`.
|
|
663
|
-
*
|
|
664
|
-
* **Example** (Guarding strings)
|
|
665
|
-
*
|
|
666
|
-
* ```ts
|
|
667
|
-
* import { Predicate } from "effect"
|
|
668
|
-
*
|
|
669
|
-
* const data: unknown = "hi"
|
|
670
|
-
*
|
|
671
|
-
* if (Predicate.isString(data)) {
|
|
672
|
-
* data.toUpperCase() // => "HI"
|
|
673
|
-
* }
|
|
674
|
-
* ```
|
|
675
|
-
*
|
|
676
|
-
* @see {@link isNumber}
|
|
677
|
-
* @see {@link isBoolean}
|
|
678
|
-
* @see {@link Refinement}
|
|
679
|
-
* @category guards
|
|
680
|
-
* @since 2.0.0
|
|
681
|
-
*/
|
|
682
115
|
function isString(input) {
|
|
683
116
|
return typeof input === "string";
|
|
684
117
|
}
|
|
685
|
-
/**
|
|
686
|
-
* Checks whether a value is a `function`.
|
|
687
|
-
*
|
|
688
|
-
* **When to use**
|
|
689
|
-
*
|
|
690
|
-
* Use when you need a `Predicate` guard to narrow an `unknown` value to a
|
|
691
|
-
* callable function.
|
|
692
|
-
*
|
|
693
|
-
* **Details**
|
|
694
|
-
*
|
|
695
|
-
* Uses `typeof input === "function"`.
|
|
696
|
-
*
|
|
697
|
-
* **Example** (Guarding functions)
|
|
698
|
-
*
|
|
699
|
-
* ```ts
|
|
700
|
-
* import { Predicate } from "effect"
|
|
701
|
-
*
|
|
702
|
-
* const data: unknown = () => 1
|
|
703
|
-
*
|
|
704
|
-
* if (Predicate.isFunction(data)) {
|
|
705
|
-
* data() // => 1
|
|
706
|
-
* }
|
|
707
|
-
* ```
|
|
708
|
-
*
|
|
709
|
-
* @see {@link isObjectKeyword}
|
|
710
|
-
* @category guards
|
|
711
|
-
* @since 2.0.0
|
|
712
|
-
*/
|
|
713
118
|
function isFunction(input) {
|
|
714
119
|
return typeof input === "function";
|
|
715
120
|
}
|
|
716
|
-
/**
|
|
717
|
-
* Checks whether a value is an `object` in the JavaScript sense (objects, arrays, functions).
|
|
718
|
-
*
|
|
719
|
-
* **When to use**
|
|
720
|
-
*
|
|
721
|
-
* Use when you need a `Predicate` guard that accepts arrays and functions as
|
|
722
|
-
* well as objects.
|
|
723
|
-
*
|
|
724
|
-
* **Details**
|
|
725
|
-
*
|
|
726
|
-
* Returns `true` for arrays and functions, and `false` for `null`.
|
|
727
|
-
*
|
|
728
|
-
* **Example** (Checking object keywords)
|
|
729
|
-
*
|
|
730
|
-
* ```ts
|
|
731
|
-
* import { Predicate } from "effect"
|
|
732
|
-
*
|
|
733
|
-
* Predicate.isObjectKeyword(() => 1) // => true
|
|
734
|
-
* Predicate.isObjectKeyword(null) // => false
|
|
735
|
-
* ```
|
|
736
|
-
*
|
|
737
|
-
* @see {@link isObject}
|
|
738
|
-
* @see {@link isObjectOrArray}
|
|
739
|
-
* @category guards
|
|
740
|
-
* @since 4.0.0
|
|
741
|
-
*/
|
|
742
121
|
function isObjectKeyword(input) {
|
|
743
122
|
return typeof input === "object" && input !== null || isFunction(input);
|
|
744
123
|
}
|
|
745
|
-
/**
|
|
746
|
-
* Checks whether a value has a given property key.
|
|
747
|
-
*
|
|
748
|
-
* **When to use**
|
|
749
|
-
*
|
|
750
|
-
* Use when you need a `Predicate` guard for property access on `unknown`
|
|
751
|
-
* values with a simple structural object check.
|
|
752
|
-
*
|
|
753
|
-
* **Details**
|
|
754
|
-
*
|
|
755
|
-
* Uses the `in` operator and `isObjectKeyword`. This does not check property
|
|
756
|
-
* value types.
|
|
757
|
-
*
|
|
758
|
-
* **Example** (Guarding object properties)
|
|
759
|
-
*
|
|
760
|
-
* ```ts
|
|
761
|
-
* import { Predicate } from "effect"
|
|
762
|
-
*
|
|
763
|
-
* const hasName = Predicate.hasProperty("name")
|
|
764
|
-
* const data: unknown = { name: "Ada" }
|
|
765
|
-
*
|
|
766
|
-
* if (hasName(data)) {
|
|
767
|
-
* data.name // => "Ada"
|
|
768
|
-
* }
|
|
769
|
-
* ```
|
|
770
|
-
*
|
|
771
|
-
* @see {@link isTagged}
|
|
772
|
-
* @see {@link isObjectKeyword}
|
|
773
|
-
* @category guards
|
|
774
|
-
* @since 2.0.0
|
|
775
|
-
*/
|
|
776
124
|
const hasProperty = dual(2, (data, property) => isObjectKeyword(data) && property in data);
|
|
777
125
|
function getOrInsertComputed(map, key, callback) {
|
|
778
126
|
if (map.has(key)) return map.get(key);
|
|
@@ -780,31 +128,6 @@ function getOrInsertComputed(map, key, callback) {
|
|
|
780
128
|
map.set(key, value);
|
|
781
129
|
return value;
|
|
782
130
|
}
|
|
783
|
-
/**
|
|
784
|
-
* Drops elements from the start while the predicate holds, returning the rest.
|
|
785
|
-
*
|
|
786
|
-
* **When to use**
|
|
787
|
-
*
|
|
788
|
-
* Use to remove a leading prefix of elements that satisfy a predicate.
|
|
789
|
-
*
|
|
790
|
-
* **Details**
|
|
791
|
-
*
|
|
792
|
-
* The predicate receives `(element, index)`.
|
|
793
|
-
*
|
|
794
|
-
* **Example** (Dropping while condition holds)
|
|
795
|
-
*
|
|
796
|
-
* ```ts
|
|
797
|
-
* import { Array } from "effect"
|
|
798
|
-
*
|
|
799
|
-
* Array.dropWhile([1, 2, 3, 4, 5], (x) => x < 4) // => [4, 5]
|
|
800
|
-
* ```
|
|
801
|
-
*
|
|
802
|
-
* @see {@link takeWhile} — keep the matching prefix instead
|
|
803
|
-
* @see {@link drop} — drop a fixed count
|
|
804
|
-
*
|
|
805
|
-
* @category getters
|
|
806
|
-
* @since 2.0.0
|
|
807
|
-
*/
|
|
808
131
|
const dropWhile = dual(2, (self, predicate) => {
|
|
809
132
|
const input = Array.isArray(self) ? self : Array.from(self);
|
|
810
133
|
const len = input.length;
|
|
@@ -812,35 +135,6 @@ const dropWhile = dual(2, (self, predicate) => {
|
|
|
812
135
|
while (idx < len && predicate(input[idx], idx)) idx++;
|
|
813
136
|
return input.slice(idx);
|
|
814
137
|
});
|
|
815
|
-
/**
|
|
816
|
-
* Takes elements from the start while the predicate holds, stopping at the
|
|
817
|
-
* first element that fails.
|
|
818
|
-
*
|
|
819
|
-
* **When to use**
|
|
820
|
-
*
|
|
821
|
-
* Use to keep the leading elements of an iterable while each element satisfies
|
|
822
|
-
* a predicate, returning the retained prefix as an array.
|
|
823
|
-
*
|
|
824
|
-
* **Details**
|
|
825
|
-
*
|
|
826
|
-
* Supports refinements for type narrowing. The predicate receives
|
|
827
|
-
* `(element, index)`.
|
|
828
|
-
*
|
|
829
|
-
* **Example** (Taking while condition holds)
|
|
830
|
-
*
|
|
831
|
-
* ```ts
|
|
832
|
-
* import { Array } from "effect"
|
|
833
|
-
*
|
|
834
|
-
* Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4) // => [1, 3, 2]
|
|
835
|
-
* ```
|
|
836
|
-
*
|
|
837
|
-
* @see {@link take} for keeping a fixed number of leading elements
|
|
838
|
-
* @see {@link dropWhile} for removing the matching prefix and keeping the rest
|
|
839
|
-
* @see {@link span} for splitting the matching prefix from the remaining elements
|
|
840
|
-
*
|
|
841
|
-
* @category getters
|
|
842
|
-
* @since 2.0.0
|
|
843
|
-
*/
|
|
844
138
|
const takeWhile = dual(2, (self, predicate) => {
|
|
845
139
|
const input = Array.isArray(self) ? self : Array.from(self);
|
|
846
140
|
const len = input.length;
|
|
@@ -910,17 +204,6 @@ function getCallKind$5(node) {
|
|
|
910
204
|
if (name != null && isMatching(P.union("addEventListener", "removeEventListener"))(name)) return name;
|
|
911
205
|
return "other";
|
|
912
206
|
}
|
|
913
|
-
/**
|
|
914
|
-
* Resolve the callee of a call inside an effect cleanup to the function it refers to.
|
|
915
|
-
* A bare call (`stop()`) resolves through the scope to the local function; a member call
|
|
916
|
-
* (`handlers.stop()`) only counts when the receiver resolves to a local object literal
|
|
917
|
-
* whose matching property is a function — an unresolvable member call says nothing about
|
|
918
|
-
* a same-named local function. Falls back to the callee name when a bare call cannot be
|
|
919
|
-
* resolved locally.
|
|
920
|
-
* @param context The ESLint rule context
|
|
921
|
-
* @param node The call expression to resolve
|
|
922
|
-
* @returns The resolved function or the callee name, or null when neither applies
|
|
923
|
-
*/
|
|
924
207
|
function resolveCleanupCallee(context, node) {
|
|
925
208
|
const callee = Extract.unwrap(node.callee);
|
|
926
209
|
switch (callee.type) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-web-api",
|
|
3
|
-
"version": "5.24.
|
|
3
|
+
"version": "5.24.2",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
|
|
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/shared": "5.24.
|
|
44
|
-
"@eslint-react/var": "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/shared": "5.24.2",
|
|
44
|
+
"@eslint-react/var": "5.24.2",
|
|
45
45
|
"@typescript-eslint/types": "^8.71.0",
|
|
46
46
|
"@typescript-eslint/utils": "^8.71.0",
|
|
47
47
|
"ts-pattern": "^5.9.0"
|