@eslint-react/ast 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.
Files changed (2) hide show
  1. package/dist/index.js +0 -793
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -28,70 +28,41 @@ var check_exports = /* @__PURE__ */ __exportAll({
28
28
  isTypeAssertionExpression: () => isTypeAssertionExpression,
29
29
  isTypeExpression: () => isTypeExpression
30
30
  });
31
- /** Check if a node is of the given type. */
32
31
  const is = ASTUtils.isNodeOfType;
33
- /** Check if a node is one of the given types. */
34
32
  const isOneOf = ASTUtils.isNodeOfTypes;
35
- /**
36
- * Check if a node is a directive statement (ex: `"use client"`), optionally matching a specific directive name.
37
- * @param node The node to check.
38
- * @param name The directive name to match. When omitted, any directive matches.
39
- * @returns `true` if the node is a matching directive statement.
40
- */
41
33
  function isDirective(node, name) {
42
34
  return node.type === AST_NODE_TYPES.ExpressionStatement && (name == null || node.directive === name);
43
35
  }
44
- /**
45
- * Check if a node is an identifier, optionally matching a specific name.
46
- * @param node The node to check.
47
- * @param name The identifier name to match. When omitted, any identifier matches.
48
- * @returns `true` if the node is a matching identifier.
49
- */
50
36
  function isIdentifier(node, name) {
51
37
  return node.type === AST_NODE_TYPES.Identifier && (name == null || node.name === name);
52
38
  }
53
- /** Check if a node is a call expression. */
54
39
  const isCallExpression = is(AST_NODE_TYPES.CallExpression);
55
- /** Check if a node is a member expression. */
56
40
  const isMemberExpression = is(AST_NODE_TYPES.MemberExpression);
57
- /** Check if a node is an object expression. */
58
41
  const isObjectExpression = is(AST_NODE_TYPES.ObjectExpression);
59
- /** Check if a node is a return statement. */
60
42
  const isReturnStatement = is(AST_NODE_TYPES.ReturnStatement);
61
- /** Check if a node is a class declaration or class expression. */
62
43
  const isClass = isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]);
63
- /** Check if a node is a function declaration, function expression, or arrow function expression. */
64
44
  const isFunction$1 = isOneOf([
65
45
  AST_NODE_TYPES.ArrowFunctionExpression,
66
46
  AST_NODE_TYPES.FunctionDeclaration,
67
47
  AST_NODE_TYPES.FunctionExpression
68
48
  ]);
69
- /** Check if a node is a property-like node (property definition, index signature, parameter property, or property signature). */
70
49
  const isProperty = isOneOf([
71
50
  AST_NODE_TYPES.PropertyDefinition,
72
51
  AST_NODE_TYPES.TSIndexSignature,
73
52
  AST_NODE_TYPES.TSParameterProperty,
74
53
  AST_NODE_TYPES.TSPropertySignature
75
54
  ]);
76
- /** Check if a node is a property or method definition. */
77
55
  const isPropertyOrMethod = isOneOf([AST_NODE_TYPES.PropertyDefinition, AST_NODE_TYPES.MethodDefinition]);
78
- /** Check if a node is a JSX element. */
79
56
  const isJSXElement = is(AST_NODE_TYPES.JSXElement);
80
- /** Check if a node is a JSX expression container. */
81
57
  const isJSXExpressionContainer = is(AST_NODE_TYPES.JSXExpressionContainer);
82
- /** Check if a node is a JSX spread attribute. */
83
58
  const isJSXSpreadAttribute = is(AST_NODE_TYPES.JSXSpreadAttribute);
84
- /** Check if a node is a JSX fragment. */
85
59
  const isJSXFragment = is(AST_NODE_TYPES.JSXFragment);
86
- /** Check if a node is a JSX element or JSX fragment. */
87
60
  const isJSXElementOrFragment = isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment]);
88
- /** Check if a node can appear as a JSX tag name. */
89
61
  const isJSXTagNameExpression = isOneOf([
90
62
  AST_NODE_TYPES.JSXIdentifier,
91
63
  AST_NODE_TYPES.JSXMemberExpression,
92
64
  AST_NODE_TYPES.JSXNamespacedName
93
65
  ]);
94
- /** Check if a node is any JSX-related node. */
95
66
  const isJSX = isOneOf([
96
67
  AST_NODE_TYPES.JSXAttribute,
97
68
  AST_NODE_TYPES.JSXClosingElement,
@@ -109,7 +80,6 @@ const isJSX = isOneOf([
109
80
  AST_NODE_TYPES.JSXSpreadChild,
110
81
  AST_NODE_TYPES.JSXText
111
82
  ]);
112
- /** Check if a node is a TypeScript type expression (assertion, non-null, satisfies, or instantiation). */
113
83
  const isTypeExpression = isOneOf([
114
84
  AST_NODE_TYPES.TSAsExpression,
115
85
  AST_NODE_TYPES.TSTypeAssertion,
@@ -117,14 +87,12 @@ const isTypeExpression = isOneOf([
117
87
  AST_NODE_TYPES.TSSatisfiesExpression,
118
88
  AST_NODE_TYPES.TSInstantiationExpression
119
89
  ]);
120
- /** Check if a node is a TypeScript type assertion-like expression (as, assertion, non-null, or satisfies). */
121
90
  const isTypeAssertionExpression = isOneOf([
122
91
  AST_NODE_TYPES.TSAsExpression,
123
92
  AST_NODE_TYPES.TSTypeAssertion,
124
93
  AST_NODE_TYPES.TSNonNullExpression,
125
94
  AST_NODE_TYPES.TSSatisfiesExpression
126
95
  ]);
127
- /** Check if a node is an expression node. */
128
96
  const isExpression = isOneOf([
129
97
  AST_NODE_TYPES.ArrayExpression,
130
98
  AST_NODE_TYPES.ArrayPattern,
@@ -162,7 +130,6 @@ const isExpression = isOneOf([
162
130
  AST_NODE_TYPES.UpdateExpression,
163
131
  AST_NODE_TYPES.YieldExpression
164
132
  ]);
165
- /** Check if a node is a conditional expression or a control flow statement. */
166
133
  const isConditional = isOneOf([
167
134
  AST_NODE_TYPES.DoWhileStatement,
168
135
  AST_NODE_TYPES.ForInStatement,
@@ -177,44 +144,6 @@ const isConditional = isOneOf([
177
144
 
178
145
  //#endregion
179
146
  //#region ../../.pkgs/eff/dist/index.js
180
- /**
181
- * Applies a `pipe` method's variadic arguments to an initial value from left
182
- * to right.
183
- *
184
- * **When to use**
185
- *
186
- * Use to implement a custom `.pipe(...)` method from JavaScript's `arguments`
187
- * object.
188
- *
189
- * **Details**
190
- *
191
- * This helper is intended for implementing `Pipeable.pipe` methods that
192
- * receive JavaScript's `arguments` object. With no functions it returns the
193
- * original value; otherwise it feeds each result into the next function.
194
- *
195
- * **Example** (Implementing a pipe method)
196
- *
197
- * ```ts
198
- * import { Pipeable } from "effect"
199
- *
200
- * class NumberBox {
201
- * constructor(readonly value: number) {}
202
- *
203
- * pipe(..._fns: ReadonlyArray<(value: number) => number>): number {
204
- * return Pipeable.pipeArguments(this.value, arguments) as number
205
- * }
206
- * }
207
- *
208
- * const result = new NumberBox(5).pipe(
209
- * (n) => n + 2,
210
- * (n) => n * 3
211
- * )
212
- * result // => 21
213
- * ```
214
- *
215
- * @category combinators
216
- * @since 2.0.0
217
- */
218
147
  const pipeArguments = (self, args) => {
219
148
  switch (args.length) {
220
149
  case 0: return self;
@@ -234,100 +163,14 @@ const pipeArguments = (self, args) => {
234
163
  }
235
164
  }
236
165
  };
237
- /**
238
- * Reusable prototype that implements `Pipeable.pipe`.
239
- *
240
- * **When to use**
241
- *
242
- * Use when classes or object prototypes can reuse this value when they need the
243
- * standard pipe implementation backed by `pipeArguments`.
244
- *
245
- * @category prototypes
246
- * @since 3.15.0
247
- */
248
166
  const Prototype = { pipe() {
249
167
  return pipeArguments(this, arguments);
250
168
  } };
251
- /**
252
- * Provides a base constructor whose instances implement the standard `Pipeable.pipe`
253
- * method.
254
- *
255
- * **When to use**
256
- *
257
- * Use when you need to define a class that supports Effect-style method
258
- * chaining through `.pipe(...)`.
259
- *
260
- * @category constructors
261
- * @since 3.15.0
262
- */
263
169
  const Class = (function() {
264
170
  function PipeableBase() {}
265
171
  PipeableBase.prototype = Prototype;
266
172
  return PipeableBase;
267
173
  })();
268
- /**
269
- * Creates a function that can be called in data-first style or data-last
270
- * (`pipe`-friendly) style.
271
- *
272
- * **When to use**
273
- *
274
- * Use to expose one implementation through both direct and `pipe`-friendly
275
- * call styles.
276
- *
277
- * **Details**
278
- *
279
- * Pass either the arity of the uncurried function or a predicate that decides
280
- * whether the current call is data-first. Arity is the common case. Use a
281
- * predicate when optional arguments make arity ambiguous.
282
- *
283
- * **Example** (Selecting data-first or data-last style by arity)
284
- *
285
- * ```ts
286
- * import { Function, pipe } from "effect"
287
- *
288
- * const sum = Function.dual<
289
- * (that: number) => (self: number) => number,
290
- * (self: number, that: number) => number
291
- * >(2, (self, that) => self + that)
292
- *
293
- * sum(2, 3) // => 5
294
- * pipe(2, sum(3)) // => 5
295
- * ```
296
- *
297
- * **Example** (Defining overloads with call signatures)
298
- *
299
- * ```ts
300
- * import { Function, pipe } from "effect"
301
- *
302
- * const sum: {
303
- * (that: number): (self: number) => number
304
- * (self: number, that: number): number
305
- * } = Function.dual(2, (self: number, that: number): number => self + that)
306
- *
307
- * sum(2, 3) // => 5
308
- * pipe(2, sum(3)) // => 5
309
- * ```
310
- *
311
- * **Example** (Selecting data-first or data-last style with a predicate)
312
- *
313
- * ```ts
314
- * import { Function, pipe } from "effect"
315
- *
316
- * const sum = Function.dual<
317
- * (that: number) => (self: number) => number,
318
- * (self: number, that: number) => number
319
- * >(
320
- * (args) => args.length === 2,
321
- * (self, that) => self + that
322
- * )
323
- *
324
- * sum(2, 3) // => 5
325
- * pipe(2, sum(3)) // => 5
326
- * ```
327
- *
328
- * @category combinators
329
- * @since 2.0.0
330
- */
331
174
  const dual = function(arity, body) {
332
175
  if (typeof arity === "function") return function() {
333
176
  return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
@@ -356,588 +199,35 @@ const dual = function(arity, body) {
356
199
  };
357
200
  }
358
201
  };
359
- /**
360
- * Returns its input argument unchanged.
361
- *
362
- * **When to use**
363
- *
364
- * Use to return a value unchanged where a function is required.
365
- *
366
- * **Example** (Returning the same value)
367
- *
368
- * ```ts
369
- * import { identity } from "effect"
370
- *
371
- * identity(5) // => 5
372
- * ```
373
- *
374
- * @category combinators
375
- * @since 2.0.0
376
- */
377
202
  const identity = (a) => a;
378
- /**
379
- * Returns the input value with a different static type.
380
- *
381
- * **When to use**
382
- *
383
- * Use when you need an explicit type-level cast and accept that the value is
384
- * returned unchanged at runtime.
385
- *
386
- * **Gotchas**
387
- *
388
- * This is a type-level cast only; it performs no runtime validation or
389
- * conversion.
390
- *
391
- * @see {@link satisfies} for checking assignability without changing the resulting type
392
- *
393
- * @category utility types
394
- * @since 4.0.0
395
- */
396
203
  const cast = identity;
397
- /**
398
- * Creates a zero-argument function that always returns the provided value.
399
- *
400
- * **When to use**
401
- *
402
- * Use when you need a thunk or callback that returns the same value on every
403
- * invocation.
404
- *
405
- * **Example** (Creating a constant thunk)
406
- *
407
- * ```ts
408
- * import { Function } from "effect"
409
- *
410
- * const constNull = Function.constant(null)
411
- *
412
- * constNull() // => null
413
- * constNull() // => null
414
- * ```
415
- *
416
- * @category constructors
417
- * @since 2.0.0
418
- */
419
204
  const constant = (value) => () => value;
420
- /**
421
- * Returns `true` when called.
422
- *
423
- * **When to use**
424
- *
425
- * Use when you need a thunk that returns `true` on every invocation.
426
- *
427
- * **Example** (Returning true from a thunk)
428
- *
429
- * ```ts
430
- * import { Function } from "effect"
431
- *
432
- * Function.constTrue() // => true
433
- * ```
434
- *
435
- * @category constants
436
- * @since 2.0.0
437
- */
438
205
  const constTrue = constant(true);
439
- /**
440
- * Returns `false` when called.
441
- *
442
- * **When to use**
443
- *
444
- * Use when you need a thunk that returns `false` on every invocation.
445
- *
446
- * **Example** (Returning false from a thunk)
447
- *
448
- * ```ts
449
- * import { Function } from "effect"
450
- *
451
- * Function.constFalse() // => false
452
- * ```
453
- *
454
- * @category constants
455
- * @since 2.0.0
456
- */
457
206
  const constFalse = constant(false);
458
- /**
459
- * Returns `null` when called.
460
- *
461
- * **When to use**
462
- *
463
- * Use when you need a thunk that returns `null` on every invocation.
464
- *
465
- * **Example** (Returning null from a thunk)
466
- *
467
- * ```ts
468
- * import { Function } from "effect"
469
- *
470
- * Function.constNull() // => null
471
- * ```
472
- *
473
- * @category constants
474
- * @since 2.0.0
475
- */
476
207
  const constNull = constant(null);
477
- /**
478
- * Returns `undefined` when called.
479
- *
480
- * **When to use**
481
- *
482
- * Use when you need a thunk that returns `undefined` on every invocation.
483
- *
484
- * **Example** (Returning undefined from a thunk)
485
- *
486
- * ```ts
487
- * import { Function } from "effect"
488
- *
489
- * Function.constUndefined() // => undefined
490
- * ```
491
- *
492
- * @category constants
493
- * @since 2.0.0
494
- */
495
208
  const constUndefined = constant(void 0);
496
- /**
497
- * 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`.
498
- * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
499
- *
500
- * **When to use**
501
- *
502
- * Use to compose exactly two unary functions into a reusable unary function.
503
- *
504
- * **Example** (Composing two functions)
505
- *
506
- * ```ts
507
- * import { Function } from "effect"
508
- *
509
- * const increment = (n: number) => n + 1
510
- * const square = (n: number) => n * n
511
- *
512
- * Function.compose(increment, square)(2) // => 9
513
- * ```
514
- *
515
- * @see {@link flow} for composing a left-to-right sequence of functions
516
- * @see {@link pipe} for applying a value through a left-to-right sequence immediately
517
- *
518
- * @category combinators
519
- * @since 2.0.0
520
- */
521
209
  const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
522
- /**
523
- * Marks an impossible branch by accepting a `never` value and returning any
524
- * type.
525
- *
526
- * **When to use**
527
- *
528
- * Use when you need a return value in a branch that exhaustive checks prove
529
- * cannot be reached.
530
- *
531
- * **Gotchas**
532
- *
533
- * Calling `absurd` throws, because a value of type `never` should be
534
- * impossible at runtime.
535
- *
536
- * **Example** (Handling impossible values)
537
- *
538
- * ```ts
539
- * import { absurd } from "effect"
540
- *
541
- * const handleNever = (value: never) => {
542
- * return absurd(value) // This will throw an error if called
543
- * }
544
- * ```
545
- *
546
- * @category utility types
547
- * @since 2.0.0
548
- */
549
210
  const absurd = (_) => {
550
211
  throw new Error("Called `absurd` function which should be uncallable");
551
212
  };
552
- /**
553
- * Creates a compile-time placeholder for a value of any type.
554
- *
555
- * **When to use**
556
- *
557
- * Use as a temporary typed placeholder while developing incomplete code.
558
- *
559
- * **Gotchas**
560
- *
561
- * `hole` is intended for temporary development use. If the placeholder is
562
- * evaluated at runtime, it throws.
563
- *
564
- * **Example** (Creating a development placeholder)
565
- *
566
- * ```ts
567
- * import { hole } from "effect"
568
- *
569
- * // Intentionally not called: `hole` throws if the placeholder is evaluated.
570
- * const buildUser = (id: number): { readonly id: number; readonly name: string } => ({
571
- * id,
572
- * name: hole<string>()
573
- * })
574
- *
575
- * ```
576
- *
577
- * @category utility types
578
- * @since 2.0.0
579
- */
580
213
  const hole = cast(absurd);
581
- /**
582
- * Creates a predicate that returns `true` only if both predicates are `true`.
583
- *
584
- * **When to use**
585
- *
586
- * Use when you want to combine `Predicate`s with AND, accepting values that
587
- * satisfy multiple conditions, including refinements that narrow to an
588
- * intersection.
589
- *
590
- * **Details**
591
- *
592
- * Evaluation short-circuits on the first `false`. For refinements, the output
593
- * type is an intersection.
594
- *
595
- * **Example** (Checking both conditions)
596
- *
597
- * ```ts
598
- * import { Predicate } from "effect"
599
- *
600
- * const hasAAndB = Predicate.and(
601
- * Predicate.hasProperty("a"),
602
- * Predicate.hasProperty("b")
603
- * )
604
- *
605
- * const input: unknown = JSON.parse(`{"a":1,"b":"ok"}`)
606
- * if (hasAAndB(input)) {
607
- * // input has both properties at this point
608
- * const a = input.a
609
- * const b = input.b
610
- *
611
- * const values = [a, b] // => [1, "ok"]
612
- * }
613
- * ```
614
- *
615
- * @see {@link or}
616
- * @see {@link not}
617
- * @category combinators
618
- * @since 2.0.0
619
- */
620
214
  const and = dual(2, (a, b) => (data) => a(data) && b(data));
621
- /**
622
- * Creates a predicate that returns `true` if either predicate is `true`.
623
- *
624
- * **When to use**
625
- *
626
- * Use when you want to combine `Predicate`s with OR, accepting values that
627
- * satisfy at least one condition, including refinements that narrow to a union.
628
- *
629
- * **Details**
630
- *
631
- * Evaluation short-circuits on the first `true`. For refinements, the output
632
- * type is a union.
633
- *
634
- * **Example** (Checking either condition)
635
- *
636
- * ```ts
637
- * import { Predicate } from "effect"
638
- *
639
- * const isStringOrNumber = Predicate.or(Predicate.isString, Predicate.isNumber)
640
- *
641
- * isStringOrNumber("a") // => true
642
- * ```
643
- *
644
- * @see {@link and}
645
- * @see {@link xor}
646
- * @category combinators
647
- * @since 2.0.0
648
- */
649
215
  const or = dual(2, (a, b) => (data) => a(data) || b(data));
650
- /**
651
- * Creates a predicate that returns `true` if exactly one predicate is `true`.
652
- *
653
- * **When to use**
654
- *
655
- * Use when you want to combine two `Predicate`s with exclusive-or semantics.
656
- *
657
- * **Details**
658
- *
659
- * Returns `true` when results differ.
660
- *
661
- * **Example** (Checking exclusive-or conditions)
662
- *
663
- * ```ts
664
- * import { Predicate } from "effect"
665
- *
666
- * const isEven = (n: number) => n % 2 === 0
667
- * const isPositive = (n: number) => n > 0
668
- * const either = Predicate.xor(isEven, isPositive)
669
- *
670
- * either(-2) // => true
671
- * ```
672
- *
673
- * @see {@link or}
674
- * @see {@link and}
675
- * @category combinators
676
- * @since 2.0.0
677
- */
678
216
  const xor = dual(2, (a, b) => (data) => a(data) !== b(data));
679
- /**
680
- * Creates a predicate that returns `true` when both predicates agree.
681
- *
682
- * **When to use**
683
- *
684
- * Use when you want to check equivalence of two `Predicate`s.
685
- *
686
- * **Details**
687
- *
688
- * Returns `true` when both results are equal.
689
- *
690
- * **Example** (Defining equivalence)
691
- *
692
- * ```ts
693
- * import { Predicate } from "effect"
694
- *
695
- * const isEven = (n: number) => n % 2 === 0
696
- * const same = Predicate.eqv(isEven, isEven)
697
- *
698
- * same(3) // => true
699
- * ```
700
- *
701
- * @see {@link xor}
702
- * @category combinators
703
- * @since 2.0.0
704
- */
705
217
  const eqv = dual(2, (a, b) => (data) => a(data) === b(data));
706
- /**
707
- * Creates a predicate representing logical implication: if `antecedent`, then `consequent`.
708
- *
709
- * **When to use**
710
- *
711
- * Use when you need to encode logical implication between `Predicate` rules,
712
- * where one rule only applies when a precondition holds.
713
- *
714
- * **Details**
715
- *
716
- * Models constraints like "if A then B" and returns `true` when the antecedent
717
- * is `false`.
718
- *
719
- * **Example** (Checking implication)
720
- *
721
- * ```ts
722
- * import { Predicate } from "effect"
723
- *
724
- * const isAdult = (age: number) => age >= 18
725
- * const canVote = (age: number) => age >= 18
726
- * const implies = Predicate.implies(isAdult, canVote)
727
- *
728
- * implies(16) // => true
729
- * ```
730
- *
731
- * @see {@link and}
732
- * @see {@link or}
733
- * @category combinators
734
- * @since 2.0.0
735
- */
736
218
  const implies = dual(2, (antecedent, consequent) => (data) => !antecedent(data) || consequent(data));
737
- /**
738
- * Creates a predicate that returns `true` when neither predicate is `true`.
739
- *
740
- * **When to use**
741
- *
742
- * Use when you want to combine two `Predicate`s with logical NOR semantics.
743
- *
744
- * **Details**
745
- *
746
- * Returns the negation of `or`.
747
- *
748
- * **Example** (Checking NOR conditions)
749
- *
750
- * ```ts
751
- * import { Predicate } from "effect"
752
- *
753
- * const neither = Predicate.nor(Predicate.isString, Predicate.isNumber)
754
- *
755
- * neither(true) // => true
756
- * ```
757
- *
758
- * @see {@link or}
759
- * @see {@link not}
760
- * @category combinators
761
- * @since 2.0.0
762
- */
763
219
  const nor = dual(2, (a, b) => (data) => !a(data) && !b(data));
764
- /**
765
- * Creates a predicate that returns `true` unless both predicates are `true`.
766
- *
767
- * **When to use**
768
- *
769
- * Use when you want to combine two `Predicate`s with logical NAND semantics.
770
- *
771
- * **Details**
772
- *
773
- * Returns the negation of `and`.
774
- *
775
- * **Example** (Checking NAND conditions)
776
- *
777
- * ```ts
778
- * import { Predicate } from "effect"
779
- *
780
- * const notBoth = Predicate.nand(Predicate.isString, Predicate.isNumber)
781
- *
782
- * notBoth("a") // => true
783
- * ```
784
- *
785
- * @see {@link and}
786
- * @see {@link not}
787
- * @category combinators
788
- * @since 2.0.0
789
- */
790
220
  const nand = dual(2, (a, b) => (data) => !a(data) || !b(data));
791
- /**
792
- * Checks whether a value is a `string`.
793
- *
794
- * **When to use**
795
- *
796
- * Use when you need a `Predicate` guard to narrow an `unknown` value to a
797
- * string.
798
- *
799
- * **Details**
800
- *
801
- * Uses `typeof input === "string"`.
802
- *
803
- * **Example** (Guarding strings)
804
- *
805
- * ```ts
806
- * import { Predicate } from "effect"
807
- *
808
- * const data: unknown = "hi"
809
- *
810
- * if (Predicate.isString(data)) {
811
- * data.toUpperCase() // => "HI"
812
- * }
813
- * ```
814
- *
815
- * @see {@link isNumber}
816
- * @see {@link isBoolean}
817
- * @see {@link Refinement}
818
- * @category guards
819
- * @since 2.0.0
820
- */
821
221
  function isString(input) {
822
222
  return typeof input === "string";
823
223
  }
824
- /**
825
- * Checks whether a value is a `function`.
826
- *
827
- * **When to use**
828
- *
829
- * Use when you need a `Predicate` guard to narrow an `unknown` value to a
830
- * callable function.
831
- *
832
- * **Details**
833
- *
834
- * Uses `typeof input === "function"`.
835
- *
836
- * **Example** (Guarding functions)
837
- *
838
- * ```ts
839
- * import { Predicate } from "effect"
840
- *
841
- * const data: unknown = () => 1
842
- *
843
- * if (Predicate.isFunction(data)) {
844
- * data() // => 1
845
- * }
846
- * ```
847
- *
848
- * @see {@link isObjectKeyword}
849
- * @category guards
850
- * @since 2.0.0
851
- */
852
224
  function isFunction(input) {
853
225
  return typeof input === "function";
854
226
  }
855
- /**
856
- * Checks whether a value is an `object` in the JavaScript sense (objects, arrays, functions).
857
- *
858
- * **When to use**
859
- *
860
- * Use when you need a `Predicate` guard that accepts arrays and functions as
861
- * well as objects.
862
- *
863
- * **Details**
864
- *
865
- * Returns `true` for arrays and functions, and `false` for `null`.
866
- *
867
- * **Example** (Checking object keywords)
868
- *
869
- * ```ts
870
- * import { Predicate } from "effect"
871
- *
872
- * Predicate.isObjectKeyword(() => 1) // => true
873
- * Predicate.isObjectKeyword(null) // => false
874
- * ```
875
- *
876
- * @see {@link isObject}
877
- * @see {@link isObjectOrArray}
878
- * @category guards
879
- * @since 4.0.0
880
- */
881
227
  function isObjectKeyword(input) {
882
228
  return typeof input === "object" && input !== null || isFunction(input);
883
229
  }
884
- /**
885
- * Checks whether a value has a given property key.
886
- *
887
- * **When to use**
888
- *
889
- * Use when you need a `Predicate` guard for property access on `unknown`
890
- * values with a simple structural object check.
891
- *
892
- * **Details**
893
- *
894
- * Uses the `in` operator and `isObjectKeyword`. This does not check property
895
- * value types.
896
- *
897
- * **Example** (Guarding object properties)
898
- *
899
- * ```ts
900
- * import { Predicate } from "effect"
901
- *
902
- * const hasName = Predicate.hasProperty("name")
903
- * const data: unknown = { name: "Ada" }
904
- *
905
- * if (hasName(data)) {
906
- * data.name // => "Ada"
907
- * }
908
- * ```
909
- *
910
- * @see {@link isTagged}
911
- * @see {@link isObjectKeyword}
912
- * @category guards
913
- * @since 2.0.0
914
- */
915
230
  const hasProperty = dual(2, (data, property) => isObjectKeyword(data) && property in data);
916
- /**
917
- * Drops elements from the start while the predicate holds, returning the rest.
918
- *
919
- * **When to use**
920
- *
921
- * Use to remove a leading prefix of elements that satisfy a predicate.
922
- *
923
- * **Details**
924
- *
925
- * The predicate receives `(element, index)`.
926
- *
927
- * **Example** (Dropping while condition holds)
928
- *
929
- * ```ts
930
- * import { Array } from "effect"
931
- *
932
- * Array.dropWhile([1, 2, 3, 4, 5], (x) => x < 4) // => [4, 5]
933
- * ```
934
- *
935
- * @see {@link takeWhile} — keep the matching prefix instead
936
- * @see {@link drop} — drop a fixed count
937
- *
938
- * @category getters
939
- * @since 2.0.0
940
- */
941
231
  const dropWhile = dual(2, (self, predicate) => {
942
232
  const input = Array.isArray(self) ? self : Array.from(self);
943
233
  const len = input.length;
@@ -945,35 +235,6 @@ const dropWhile = dual(2, (self, predicate) => {
945
235
  while (idx < len && predicate(input[idx], idx)) idx++;
946
236
  return input.slice(idx);
947
237
  });
948
- /**
949
- * Takes elements from the start while the predicate holds, stopping at the
950
- * first element that fails.
951
- *
952
- * **When to use**
953
- *
954
- * Use to keep the leading elements of an iterable while each element satisfies
955
- * a predicate, returning the retained prefix as an array.
956
- *
957
- * **Details**
958
- *
959
- * Supports refinements for type narrowing. The predicate receives
960
- * `(element, index)`.
961
- *
962
- * **Example** (Taking while condition holds)
963
- *
964
- * ```ts
965
- * import { Array } from "effect"
966
- *
967
- * Array.takeWhile([1, 3, 2, 4, 1, 2], (x) => x < 4) // => [1, 3, 2]
968
- * ```
969
- *
970
- * @see {@link take} for keeping a fixed number of leading elements
971
- * @see {@link dropWhile} for removing the matching prefix and keeping the rest
972
- * @see {@link span} for splitting the matching prefix from the remaining elements
973
- *
974
- * @category getters
975
- * @since 2.0.0
976
- */
977
238
  const takeWhile = dual(2, (self, predicate) => {
978
239
  const input = Array.isArray(self) ? self : Array.from(self);
979
240
  const len = input.length;
@@ -993,21 +254,10 @@ var extract_exports = /* @__PURE__ */ __exportAll({
993
254
  getPropertyName: () => getPropertyName,
994
255
  unwrap: () => unwrap
995
256
  });
996
- /**
997
- * Recursively unwrap TypeScript type expressions and chain expressions to get the underlying expression.
998
- * @param node The node to unwrap.
999
- * @returns The innermost non-type-expression node.
1000
- */
1001
257
  function unwrap(node) {
1002
258
  if (isTypeExpression(node) || node.type === AST_NODE_TYPES.ChainExpression) return unwrap(node.expression);
1003
259
  return node;
1004
260
  }
1005
- /**
1006
- * Find a property by name in a list of object literal properties, recursing into spread object expressions.
1007
- * @param properties The object literal properties to search.
1008
- * @param name The property name to look for.
1009
- * @returns The matching `Property` node, or `null` when not found.
1010
- */
1011
261
  function findProperty(properties, name) {
1012
262
  for (const property of properties) {
1013
263
  if (property.type === AST_NODE_TYPES.Property && getPropertyName(property) === name) return property;
@@ -1018,23 +268,12 @@ function findProperty(properties, name) {
1018
268
  }
1019
269
  return null;
1020
270
  }
1021
- /**
1022
- * Get the name of the callee of a call expression.
1023
- * @param node The call expression to inspect.
1024
- * @returns The callee name (ex: `"useState"`), or `null` when it cannot be statically determined.
1025
- */
1026
271
  function getCalleeName(node) {
1027
272
  const callee = unwrap(node.callee);
1028
273
  if (isIdentifier(callee)) return callee.name;
1029
274
  if (callee.type === AST_NODE_TYPES.MemberExpression && !callee.computed && isIdentifier(callee.property)) return callee.property.name;
1030
275
  return null;
1031
276
  }
1032
- /**
1033
- * Get the member chain of an expression (ex: `[a, b, c]` for `a.b.c`), starting from the base object.
1034
- * Type expressions and chain expressions are unwrapped along the way.
1035
- * @param node The expression to inspect.
1036
- * @returns The base node followed by each member property in access order.
1037
- */
1038
277
  function getMemberChain(node) {
1039
278
  const members = [];
1040
279
  let current = unwrap(node);
@@ -1046,14 +285,6 @@ function getMemberChain(node) {
1046
285
  members.unshift(current);
1047
286
  return members;
1048
287
  }
1049
- /**
1050
- * Collect every write target of an assignment or loop target, expanding
1051
- * destructuring patterns such as `[local, globalValue] = source` or
1052
- * `({ a: obj.x } = source)`. Defaults (`{ a = source }`) are not targets;
1053
- * their left side is.
1054
- * @param node The assignment left side or for-in/of loop target to inspect.
1055
- * @returns The identifier and member expression targets being written.
1056
- */
1057
288
  function getAssignmentTargets(node) {
1058
289
  const target = unwrap(node);
1059
290
  switch (target.type) {
@@ -1069,12 +300,6 @@ function getAssignmentTargets(node) {
1069
300
  default: return [];
1070
301
  }
1071
302
  }
1072
- /**
1073
- * Get the static name of an object property's key.
1074
- * @param property The property to inspect.
1075
- * @param effort `"min"` only matches plain identifiers; `"max"` also resolves string literals and simple template literals.
1076
- * @returns The property name, or `null` when it cannot be statically determined.
1077
- */
1078
303
  function getPropertyName(property, effort = "min") {
1079
304
  const key = unwrap(property.key);
1080
305
  if (isIdentifier(key) && !property.computed) return key.name;
@@ -1083,12 +308,6 @@ function getPropertyName(property, effort = "min") {
1083
308
  if (key.type === AST_NODE_TYPES.TemplateLiteral && key.expressions.length === 0) return key.quasis[0]?.value.cooked ?? key.quasis[0]?.value.raw ?? null;
1084
309
  return null;
1085
310
  }
1086
- /**
1087
- * Get the fully qualified name of a node (ex: `React.useState`), falling back to source text when needed.
1088
- * @param node The node to inspect.
1089
- * @param getText A function returning the source text of a node.
1090
- * @returns The fully qualified name.
1091
- */
1092
311
  function getFullyQualifiedName(node, getText) {
1093
312
  const expr = unwrap(node);
1094
313
  switch (expr.type) {
@@ -1109,13 +328,6 @@ function getFullyQualifiedName(node, getText) {
1109
328
  //#endregion
1110
329
  //#region src/compare.ts
1111
330
  var compare_exports = /* @__PURE__ */ __exportAll({ isEqual: () => isEqual });
1112
- /**
1113
- * Check if two nodes are structurally equal.
1114
- * @param a The first node to compare.
1115
- * @param b The second node to compare.
1116
- * @returns `true` if the nodes are equal.
1117
- * @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
1118
- */
1119
331
  const isEqual = dual(2, (a, b) => {
1120
332
  a = isTypeExpression(a) ? unwrap(a) : a;
1121
333
  b = isTypeExpression(b) ? unwrap(b) : b;
@@ -1182,11 +394,6 @@ function findParent(node, test, stop) {
1182
394
  }
1183
395
  return null;
1184
396
  }
1185
- /**
1186
- * Find the nearest `TryStatement` whose `try` block (not `catch`/`finally`) encloses the given node.
1187
- * @param node The node to check.
1188
- * @returns The enclosing `TryStatement`, or `null` when none is found.
1189
- */
1190
397
  function findEnclosingTryBlock(node) {
1191
398
  const parent = node.parent;
1192
399
  if (parent == null || parent.type === AST_NODE_TYPES.Program) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "5.24.1",
3
+ "version": "5.24.2",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {