@eslint-react/jsx 0.5.7 → 0.5.8

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.cjs CHANGED
@@ -1287,7 +1287,6 @@ const LeftProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Common
1287
1287
  };
1288
1288
  /** @internal */ const getLeft$2 = (self)=>isRight$1(self) ? none$1 : some$4(self.left);
1289
1289
  /** @internal */ const getRight$2 = (self)=>isLeft$1(self) ? none$1 : some$4(self.right);
1290
- /** @internal */ const fromOption$1 = /*#__PURE__*/ dual(2, (self, onNone)=>isNone$1(self) ? left$1(onNone()) : right$1(self.value));
1291
1290
  /**
1292
1291
  * @since 2.0.0
1293
1292
  */ /**
@@ -2227,15 +2226,6 @@ var effectOption_esm = /*#__PURE__*/ Object.freeze({
2227
2226
  zipRight: zipRight,
2228
2227
  zipWith: zipWith$3
2229
2228
  });
2230
- /**
2231
- * @since 2.0.0
2232
- */ /**
2233
- * @category models
2234
- * @since 2.0.0
2235
- */ /**
2236
- * @category symbols
2237
- * @since 2.0.0
2238
- */ const TypeId$5 = TypeId$7;
2239
2229
  /**
2240
2230
  * @category symbols
2241
2231
  * @since 2.0.0
@@ -2268,366 +2258,6 @@ var effectOption_esm = /*#__PURE__*/ Object.freeze({
2268
2258
  * @category constructors
2269
2259
  * @since 2.0.0
2270
2260
  */ const left = left$1;
2271
- /**
2272
- * Takes a lazy default and a nullable value, if the value is not nully (`null` or `undefined`), turn it into a `Right`, if the value is nully use
2273
- * the provided default as a `Left`.
2274
- *
2275
- * @example
2276
- * import * as Either from 'effect/Either'
2277
- *
2278
- * assert.deepStrictEqual(Either.fromNullable(1, () => 'fallback'), Either.right(1))
2279
- * assert.deepStrictEqual(Either.fromNullable(null, () => 'fallback'), Either.left('fallback'))
2280
- *
2281
- * @category constructors
2282
- * @since 2.0.0
2283
- */ const fromNullable = /*#__PURE__*/ dual(2, (self, onNullable)=>self == null ? left(onNullable(self)) : right(self));
2284
- /**
2285
- * @example
2286
- * import * as Either from 'effect/Either'
2287
- * import * as Option from 'effect/Option'
2288
- *
2289
- * assert.deepStrictEqual(Either.fromOption(Option.some(1), () => 'error'), Either.right(1))
2290
- * assert.deepStrictEqual(Either.fromOption(Option.none(), () => 'error'), Either.left('error'))
2291
- *
2292
- * @category constructors
2293
- * @since 2.0.0
2294
- */ const fromOption = fromOption$1;
2295
- const try_ = (evaluate)=>{
2296
- if (isFunction(evaluate)) {
2297
- try {
2298
- return right(evaluate());
2299
- } catch (e) {
2300
- return left(e);
2301
- }
2302
- } else {
2303
- try {
2304
- return right(evaluate.try());
2305
- } catch (e) {
2306
- return left(evaluate.catch(e));
2307
- }
2308
- }
2309
- };
2310
- /**
2311
- * Tests if a value is a `Either`.
2312
- *
2313
- * @param input - The value to test.
2314
- *
2315
- * @example
2316
- * import { isEither, left, right } from 'effect/Either'
2317
- *
2318
- * assert.deepStrictEqual(isEither(right(1)), true)
2319
- * assert.deepStrictEqual(isEither(left("a")), true)
2320
- * assert.deepStrictEqual(isEither({ right: 1 }), false)
2321
- *
2322
- * @category guards
2323
- * @since 2.0.0
2324
- */ const isEither = isEither$1;
2325
- /**
2326
- * Determine if a `Either` is a `Left`.
2327
- *
2328
- * @param self - The `Either` to check.
2329
- *
2330
- * @example
2331
- * import { isLeft, left, right } from 'effect/Either'
2332
- *
2333
- * assert.deepStrictEqual(isLeft(right(1)), false)
2334
- * assert.deepStrictEqual(isLeft(left("a")), true)
2335
- *
2336
- * @category guards
2337
- * @since 2.0.0
2338
- */ const isLeft = isLeft$1;
2339
- /**
2340
- * Determine if a `Either` is a `Right`.
2341
- *
2342
- * @param self - The `Either` to check.
2343
- *
2344
- * @example
2345
- * import { isRight, left, right } from 'effect/Either'
2346
- *
2347
- * assert.deepStrictEqual(isRight(right(1)), true)
2348
- * assert.deepStrictEqual(isRight(left("a")), false)
2349
- *
2350
- * @category guards
2351
- * @since 2.0.0
2352
- */ const isRight = isRight$1;
2353
- /**
2354
- * Converts a `Either` to an `Option` discarding the `Left`.
2355
- *
2356
- * Alias of {@link toOption}.
2357
- *
2358
- * @example
2359
- * import * as O from 'effect/Option'
2360
- * import * as E from 'effect/Either'
2361
- *
2362
- * assert.deepStrictEqual(E.getRight(E.right('ok')), O.some('ok'))
2363
- * assert.deepStrictEqual(E.getRight(E.left('err')), O.none())
2364
- *
2365
- * @category getters
2366
- * @since 2.0.0
2367
- */ const getRight = getRight$2;
2368
- /**
2369
- * Converts a `Either` to an `Option` discarding the value.
2370
- *
2371
- * @example
2372
- * import * as O from 'effect/Option'
2373
- * import * as E from 'effect/Either'
2374
- *
2375
- * assert.deepStrictEqual(E.getLeft(E.right('ok')), O.none())
2376
- * assert.deepStrictEqual(E.getLeft(E.left('err')), O.some('err'))
2377
- *
2378
- * @category getters
2379
- * @since 2.0.0
2380
- */ const getLeft = getLeft$2;
2381
- /**
2382
- * @category equivalence
2383
- * @since 2.0.0
2384
- */ const getEquivalence$4 = (EE, EA)=>make$7((x, y)=>x === y || (isLeft(x) ? isLeft(y) && EE(x.left, y.left) : isRight(y) && EA(x.right, y.right)));
2385
- /**
2386
- * @category mapping
2387
- * @since 2.0.0
2388
- */ const mapBoth = /*#__PURE__*/ dual(2, (self, { onLeft, onRight })=>isLeft(self) ? left(onLeft(self.left)) : right(onRight(self.right)));
2389
- /**
2390
- * Maps the `Left` side of an `Either` value to a new `Either` value.
2391
- *
2392
- * @param self - The input `Either` value to map.
2393
- * @param f - A transformation function to apply to the `Left` value of the input `Either`.
2394
- *
2395
- * @category mapping
2396
- * @since 2.0.0
2397
- */ const mapLeft = /*#__PURE__*/ dual(2, (self, f)=>isLeft(self) ? left(f(self.left)) : right(self.right));
2398
- /**
2399
- * Maps the `Right` side of an `Either` value to a new `Either` value.
2400
- *
2401
- * @param self - An `Either` to map
2402
- * @param f - The function to map over the value of the `Either`
2403
- *
2404
- * @category mapping
2405
- * @since 2.0.0
2406
- */ const map$4 = /*#__PURE__*/ dual(2, (self, f)=>isRight(self) ? right(f(self.right)) : left(self.left));
2407
- /**
2408
- * Takes two functions and an `Either` value, if the value is a `Left` the inner value is applied to the `onLeft function,
2409
- * if the value is a `Right` the inner value is applied to the `onRight` function.
2410
- *
2411
- * @example
2412
- * import * as E from 'effect/Either'
2413
- * import { pipe } from 'effect/Function'
2414
- *
2415
- * const onLeft = (strings: ReadonlyArray<string>): string => `strings: ${strings.join(', ')}`
2416
- *
2417
- * const onRight = (value: number): string => `Ok: ${value}`
2418
- *
2419
- * assert.deepStrictEqual(pipe(E.right(1), E.match({ onLeft, onRight })), 'Ok: 1')
2420
- * assert.deepStrictEqual(
2421
- * pipe(E.left(['string 1', 'string 2']), E.match({ onLeft, onRight })),
2422
- * 'strings: string 1, string 2'
2423
- * )
2424
- *
2425
- * @category pattern matching
2426
- * @since 2.0.0
2427
- */ const match = /*#__PURE__*/ dual(2, (self, { onLeft, onRight })=>isLeft(self) ? onLeft(self.left) : onRight(self.right));
2428
- /**
2429
- * @category getters
2430
- * @since 2.0.0
2431
- */ const merge = /*#__PURE__*/ match({
2432
- onLeft: identity$1,
2433
- onRight: identity$1
2434
- });
2435
- /**
2436
- * Returns the wrapped value if it's a `Right` or a default value if is a `Left`.
2437
- *
2438
- * @example
2439
- * import * as Either from 'effect/Either'
2440
- *
2441
- * assert.deepStrictEqual(Either.getOrElse(Either.right(1), (error) => error + "!"), 1)
2442
- * assert.deepStrictEqual(Either.getOrElse(Either.left("not a number"), (error) => error + "!"), "not a number!")
2443
- *
2444
- * @category getters
2445
- * @since 2.0.0
2446
- */ const getOrElse = /*#__PURE__*/ dual(2, (self, onLeft)=>isLeft(self) ? onLeft(self.left) : self.right);
2447
- /**
2448
- * @example
2449
- * import * as Either from 'effect/Either'
2450
- *
2451
- * assert.deepStrictEqual(Either.getOrNull(Either.right(1)), 1)
2452
- * assert.deepStrictEqual(Either.getOrNull(Either.left("a")), null)
2453
- *
2454
- * @category getters
2455
- * @since 2.0.0
2456
- */ const getOrNull = /*#__PURE__*/ getOrElse(constNull);
2457
- /**
2458
- * @example
2459
- * import * as Either from 'effect/Either'
2460
- *
2461
- * assert.deepStrictEqual(Either.getOrUndefined(Either.right(1)), 1)
2462
- * assert.deepStrictEqual(Either.getOrUndefined(Either.left("a")), undefined)
2463
- *
2464
- * @category getters
2465
- * @since 2.0.0
2466
- */ const getOrUndefined = /*#__PURE__*/ getOrElse(constUndefined);
2467
- /**
2468
- * Extracts the value of an `Either` or throws if the `Either` is `Left`.
2469
- *
2470
- * If a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.
2471
- *
2472
- * @param self - The `Either` to extract the value from.
2473
- * @param onLeft - A function that will be called if the `Either` is `Left`. It returns the error to be thrown.
2474
- *
2475
- * @example
2476
- * import * as E from "effect/Either"
2477
- *
2478
- * assert.deepStrictEqual(
2479
- * E.getOrThrowWith(E.right(1), () => new Error('Unexpected Left')),
2480
- * 1
2481
- * )
2482
- * assert.throws(() => E.getOrThrowWith(E.left("error"), () => new Error('Unexpected Left')))
2483
- *
2484
- * @category getters
2485
- * @since 2.0.0
2486
- */ const getOrThrowWith = /*#__PURE__*/ dual(2, (self, onLeft)=>{
2487
- if (isRight(self)) {
2488
- return self.right;
2489
- }
2490
- throw onLeft(self.left);
2491
- });
2492
- /**
2493
- * Extracts the value of an `Either` or throws if the `Either` is `Left`.
2494
- *
2495
- * The thrown error is a default error. To configure the error thrown, see {@link getOrThrowWith}.
2496
- *
2497
- * @param self - The `Either` to extract the value from.
2498
- * @throws `Error("getOrThrow called on a Left")`
2499
- *
2500
- * @example
2501
- * import * as E from "effect/Either"
2502
- *
2503
- * assert.deepStrictEqual(E.getOrThrow(E.right(1)), 1)
2504
- * assert.throws(() => E.getOrThrow(E.left("error")))
2505
- *
2506
- * @category getters
2507
- * @since 2.0.0
2508
- */ const getOrThrow = /*#__PURE__*/ getOrThrowWith(()=>new Error("getOrThrow called on a Left"));
2509
- /**
2510
- * Returns `self` if it is a `Right` or `that` otherwise.
2511
- *
2512
- * @param self - The input `Either` value to check and potentially return.
2513
- * @param that - A function that takes the error value from `self` (if it's a `Left`) and returns a new `Either` value.
2514
- *
2515
- * @category error handling
2516
- * @since 2.0.0
2517
- */ const orElse = /*#__PURE__*/ dual(2, (self, that)=>isLeft(self) ? that(self.left) : right(self.right));
2518
- /**
2519
- * @category combining
2520
- * @since 2.0.0
2521
- */ const flatMap$2 = /*#__PURE__*/ dual(2, (self, f)=>isLeft(self) ? left(self.left) : f(self.right));
2522
- /**
2523
- * @since 2.0.0
2524
- * @category combining
2525
- */ const zipWith$2 = /*#__PURE__*/ dual(3, (self, that, f)=>flatMap$2(self, (a)=>map$4(that, (b)=>f(a, b))));
2526
- /**
2527
- * @category combining
2528
- * @since 2.0.0
2529
- */ const ap = /*#__PURE__*/ dual(2, (self, that)=>zipWith$2(self, that, (f, a)=>f(a)));
2530
- /**
2531
- * Takes a structure of `Option`s and returns an `Option` of values with the same structure.
2532
- *
2533
- * - If a tuple is supplied, then the returned `Option` will contain a tuple with the same length.
2534
- * - If a struct is supplied, then the returned `Option` will contain a struct with the same keys.
2535
- * - If an iterable is supplied, then the returned `Option` will contain an array.
2536
- *
2537
- * @param fields - the struct of `Option`s to be sequenced.
2538
- *
2539
- * @example
2540
- * import * as Either from "effect/Either"
2541
- *
2542
- * assert.deepStrictEqual(Either.all([Either.right(1), Either.right(2)]), Either.right([1, 2]))
2543
- * assert.deepStrictEqual(Either.all({ a: Either.right(1), b: Either.right("hello") }), Either.right({ a: 1, b: "hello" }))
2544
- * assert.deepStrictEqual(Either.all({ a: Either.right(1), b: Either.left("error") }), Either.left("error"))
2545
- *
2546
- * @category combining
2547
- * @since 2.0.0
2548
- */ // @ts-expect-error
2549
- const all = (input)=>{
2550
- if (Symbol.iterator in input) {
2551
- const out = [];
2552
- for (const e of input){
2553
- if (isLeft(e)) {
2554
- return e;
2555
- }
2556
- out.push(e.right);
2557
- }
2558
- return right(out);
2559
- }
2560
- const out = {};
2561
- for (const key of Object.keys(input)){
2562
- const e = input[key];
2563
- if (isLeft(e)) {
2564
- return e;
2565
- }
2566
- out[key] = e.right;
2567
- }
2568
- return right(out);
2569
- };
2570
- /**
2571
- * @since 2.0.0
2572
- */ const reverse$3 = (self)=>isLeft(self) ? right(self.left) : left(self.right);
2573
- const adapter = /*#__PURE__*/ adapter$2();
2574
- /**
2575
- * @category generators
2576
- * @since 2.0.0
2577
- */ const gen = (f)=>{
2578
- const iterator = f(adapter);
2579
- let state = iterator.next();
2580
- if (state.done) {
2581
- return right(state.value);
2582
- } else {
2583
- let current = state.value.value;
2584
- if (isLeft(current)) {
2585
- return current;
2586
- }
2587
- while(!state.done){
2588
- state = iterator.next(current.right);
2589
- if (!state.done) {
2590
- current = state.value.value;
2591
- if (isLeft(current)) {
2592
- return current;
2593
- }
2594
- }
2595
- }
2596
- return right(state.value);
2597
- }
2598
- };
2599
- var effectEither_esm = /*#__PURE__*/ Object.freeze({
2600
- __proto__: null,
2601
- TypeId: TypeId$5,
2602
- all: all,
2603
- ap: ap,
2604
- flatMap: flatMap$2,
2605
- fromNullable: fromNullable,
2606
- fromOption: fromOption,
2607
- gen: gen,
2608
- getEquivalence: getEquivalence$4,
2609
- getLeft: getLeft,
2610
- getOrElse: getOrElse,
2611
- getOrNull: getOrNull,
2612
- getOrThrow: getOrThrow,
2613
- getOrThrowWith: getOrThrowWith,
2614
- getOrUndefined: getOrUndefined,
2615
- getRight: getRight,
2616
- isEither: isEither,
2617
- isLeft: isLeft,
2618
- isRight: isRight,
2619
- left: left,
2620
- map: map$4,
2621
- mapBoth: mapBoth,
2622
- mapLeft: mapLeft,
2623
- match: match,
2624
- merge: merge,
2625
- orElse: orElse,
2626
- reverse: reverse$3,
2627
- right: right,
2628
- try: try_,
2629
- zipWith: zipWith$2
2630
- });
2631
2261
  /**
2632
2262
  * @category conversions
2633
2263
  * @since 2.0.0
@@ -5130,28 +4760,41 @@ var effectData_esm = /*#__PURE__*/ Object.freeze({
5130
4760
  unsafeStruct: unsafeStruct
5131
4761
  });
5132
4762
 
4763
+ /**
4764
+ * Tests if a value is a `string`.
4765
+ *
4766
+ * @param input - The value to test.
4767
+ *
4768
+ * @example
4769
+ * import { isString } from "effect/Predicate"
4770
+ *
4771
+ * assert.deepStrictEqual(isString("a"), true)
4772
+ *
4773
+ * assert.deepStrictEqual(isString(1), false)
4774
+ *
4775
+ * @category guards
4776
+ * @since 2.0.0
4777
+ */
4778
+ const isString$1 = input => typeof input === "string";
4779
+
5133
4780
  const RE_JSX_ANNOTATION_REGEX = /@jsx\s+(\S+)/u;
5134
4781
  // Does not check for reserved keywords or unicode characters
5135
4782
  const RE_JS_IDENTIFIER_REGEX = /^[$A-Z_a-z][\w$]*$/u;
5136
4783
  function getFragmentFromContext(context) {
5137
4784
  // eslint-disable-next-line prefer-destructuring
5138
4785
  const settings = context.settings;
5139
- const pragma = settings.react?.fragment ?? "Fragment";
5140
- if (!RE_JS_IDENTIFIER_REGEX.test(pragma)) {
5141
- return effectEither_esm.left(new Error(`Fragment pragma ${pragma} is not a valid identifier`));
4786
+ const fragment = settings.react?.fragment;
4787
+ if (isString$1(fragment) && RE_JS_IDENTIFIER_REGEX.test(fragment)) {
4788
+ return fragment;
5142
4789
  }
5143
- return effectEither_esm.right(pragma);
4790
+ return "Fragment";
5144
4791
  }
5145
4792
  const getPragmaFromContext = memo((context)=>{
5146
4793
  // eslint-disable-next-line prefer-destructuring
5147
4794
  const settings = context.settings;
5148
4795
  const sourceCode = context.getSourceCode();
5149
4796
  const pragmaNode = sourceCode.getAllComments().find((node)=>RE_JSX_ANNOTATION_REGEX.test(node.value));
5150
- const pragma = settings.react?.pragma ?? effectFunction_esm.pipe(effectOption_esm.fromNullable(pragmaNode), effectOption_esm.map((node)=>RE_JSX_ANNOTATION_REGEX.exec(node.value)), effectOption_esm.flatMap((matches)=>effectOption_esm.fromNullable(matches?.[1]?.split(".")[0])), effectOption_esm.getOrElse(()=>"React"));
5151
- if (!RE_JS_IDENTIFIER_REGEX.test(pragma)) {
5152
- return effectEither_esm.left(new Error(`React pragma ${pragma} is not a valid identifier`));
5153
- }
5154
- return effectEither_esm.right(pragma);
4797
+ return effectFunction_esm.pipe(effectOption_esm.orElse(effectOption_esm.fromNullable(settings.react?.pragma), ()=>effectFunction_esm.pipe(effectOption_esm.fromNullable(pragmaNode), effectOption_esm.map(({ value })=>RE_JSX_ANNOTATION_REGEX.exec(value)), effectOption_esm.flatMapNullable((matches)=>matches?.[1]?.split(".")[0]))), effectOption_esm.flatMap(effectOption_esm.liftPredicate((x)=>RE_JS_IDENTIFIER_REGEX.test(x))), effectOption_esm.getOrElse(effectFunction_esm.constant("React")));
5155
4798
  });
5156
4799
 
5157
4800
  function isNil(x){
@@ -5172,7 +4815,7 @@ function isNil(x){
5172
4815
  *
5173
4816
  * @category guards
5174
4817
  * @since 2.0.0
5175
- */ const isString$1 = (input)=>typeof input === "string";
4818
+ */ const isString = (input)=>typeof input === "string";
5176
4819
  const t$1 = Symbol.for("@ts-pattern/matcher"), e$1 = Symbol.for("@ts-pattern/isVariadic"), n$1 = "@ts-pattern/anonymous-select-key", r$1 = (t)=>Boolean(t && "object" == typeof t), i$1 = (e)=>e && !!e[t$1], s$1 = (n, o, c)=>{
5177
4820
  if (i$1(n)) {
5178
4821
  const e = n[t$1](), { matched: r, selections: i } = e.match(o);
@@ -5440,6 +5083,51 @@ isOneOf([
5440
5083
  NodeType.TSInterfaceDeclaration,
5441
5084
  NodeType.TSTypeAliasDeclaration
5442
5085
  ]);
5086
+ isOneOf([
5087
+ NodeType.ArrayExpression,
5088
+ NodeType.ArrayPattern,
5089
+ NodeType.ArrowFunctionExpression,
5090
+ NodeType.CallExpression,
5091
+ NodeType.ClassExpression,
5092
+ NodeType.FunctionExpression,
5093
+ NodeType.Identifier,
5094
+ NodeType.JSXElement,
5095
+ NodeType.JSXFragment,
5096
+ NodeType.Literal,
5097
+ NodeType.TemplateLiteral,
5098
+ NodeType.MemberExpression,
5099
+ NodeType.MetaProperty,
5100
+ NodeType.ObjectExpression,
5101
+ NodeType.ObjectPattern,
5102
+ NodeType.SequenceExpression,
5103
+ NodeType.Super,
5104
+ NodeType.TaggedTemplateExpression,
5105
+ NodeType.ThisExpression
5106
+ ]);
5107
+ isOneOf([
5108
+ NodeType.ArrayExpression,
5109
+ NodeType.ArrayPattern,
5110
+ NodeType.ArrowFunctionExpression,
5111
+ NodeType.CallExpression,
5112
+ NodeType.ClassExpression,
5113
+ NodeType.FunctionExpression,
5114
+ NodeType.Identifier,
5115
+ NodeType.JSXElement,
5116
+ NodeType.JSXFragment,
5117
+ NodeType.Literal,
5118
+ NodeType.TemplateLiteral,
5119
+ NodeType.MemberExpression,
5120
+ NodeType.MetaProperty,
5121
+ NodeType.ObjectExpression,
5122
+ NodeType.ObjectPattern,
5123
+ NodeType.SequenceExpression,
5124
+ NodeType.Super,
5125
+ NodeType.TaggedTemplateExpression,
5126
+ NodeType.ThisExpression,
5127
+ NodeType.TSAsExpression,
5128
+ NodeType.TSNonNullExpression,
5129
+ NodeType.TSTypeAssertion
5130
+ ]);
5443
5131
  const Construction = effectData_esm.taggedEnum();
5444
5132
  Construction.None();
5445
5133
  [
@@ -6792,7 +6480,7 @@ Function.call.bind(Object.hasOwnProperty);
6792
6480
  return returnStatements;
6793
6481
  }
6794
6482
  function isStringLiteral(node) {
6795
- return node?.type === NodeType.Literal && isString$1(node.value);
6483
+ return node?.type === NodeType.Literal && isString(node.value);
6796
6484
  }
6797
6485
  /**
6798
6486
  * Check if a node is multiline
@@ -6866,14 +6554,24 @@ function isStringLiteral(node) {
6866
6554
 
6867
6555
  const t=Symbol.for("@ts-pattern/matcher"),e=Symbol.for("@ts-pattern/isVariadic"),n="@ts-pattern/anonymous-select-key",r=t=>Boolean(t&&"object"==typeof t),i=e=>e&&!!e[t],s=(n,o,c)=>{if(i(n)){const e=n[t](),{matched:r,selections:i}=e.match(o);return r&&i&&Object.keys(i).forEach(t=>c(t,i[t])),r}if(r(n)){if(!r(o))return !1;if(Array.isArray(n)){if(!Array.isArray(o))return !1;let t=[],r=[],a=[];for(const s of n.keys()){const o=n[s];i(o)&&o[e]?a.push(o):a.length?r.push(o):t.push(o);}if(a.length){if(a.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(o.length<t.length+r.length)return !1;const e=o.slice(0,t.length),n=0===r.length?[]:o.slice(-r.length),i=o.slice(t.length,0===r.length?Infinity:-r.length);return t.every((t,n)=>s(t,e[n],c))&&r.every((t,e)=>s(t,n[e],c))&&(0===a.length||s(a[0],i,c))}return n.length===o.length&&n.every((t,e)=>s(t,o[e],c))}return Object.keys(n).every(e=>{const r=n[e];return (e in o||i(a=r)&&"optional"===a[t]().matcherType)&&s(r,o[e],c);var a;})}return Object.is(o,n)},o=e=>{var n,s,a;return r(e)?i(e)?null!=(n=null==(s=(a=e[t]()).getSelectionKeys)?void 0:s.call(a))?n:[]:Array.isArray(e)?c(e,o):c(Object.values(e),o):[]},c=(t,e)=>t.reduce((t,n)=>t.concat(e(n)),[]);function a(...t){if(1===t.length){const[e]=t;return t=>s(e,t,()=>{})}if(2===t.length){const[e,n]=t;return s(e,n,()=>{})}throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`)}function u(t){return Object.assign(t,{optional:()=>l(t),and:e=>m(t,e),or:e=>y(t,e),select:e=>void 0===e?p(t):p(e,t)})}function h(t){return Object.assign((t=>Object.assign(t,{*[Symbol.iterator](){yield Object.assign(t,{[e]:!0});}}))(t),{optional:()=>h(l(t)),select:e=>h(void 0===e?p(t):p(e,t))})}function l(e){return u({[t]:()=>({match:t=>{let n={};const r=(t,e)=>{n[t]=e;};return void 0===t?(o(e).forEach(t=>r(t,void 0)),{matched:!0,selections:n}):{matched:s(e,t,r),selections:n}},getSelectionKeys:()=>o(e),matcherType:"optional"})})}const f=(t,e)=>{for(const n of t)if(!e(n))return !1;return !0},g=(t,e)=>{for(const[n,r]of t.entries())if(!e(r,n))return !1;return !0};function m(...e){return u({[t]:()=>({match:t=>{let n={};const r=(t,e)=>{n[t]=e;};return {matched:e.every(e=>s(e,t,r)),selections:n}},getSelectionKeys:()=>c(e,o),matcherType:"and"})})}function y(...e){return u({[t]:()=>({match:t=>{let n={};const r=(t,e)=>{n[t]=e;};return c(e,o).forEach(t=>r(t,void 0)),{matched:e.some(e=>s(e,t,r)),selections:n}},getSelectionKeys:()=>c(e,o),matcherType:"or"})})}function d(e){return {[t]:()=>({match:t=>({matched:Boolean(e(t))})})}}function p(...e){const r="string"==typeof e[0]?e[0]:void 0,i=2===e.length?e[1]:"string"==typeof e[0]?void 0:e[0];return u({[t]:()=>({match:t=>{let e={[null!=r?r:n]:t};return {matched:void 0===i||s(i,t,(t,n)=>{e[t]=n;}),selections:e}},getSelectionKeys:()=>[null!=r?r:n].concat(void 0===i?[]:o(i))})})}function v(t){return "number"==typeof t}function b(t){return "string"==typeof t}function w(t){return "bigint"==typeof t}const S=u(d(function(t){return !0})),O=S,j=t=>Object.assign(u(t),{startsWith:e=>{return j(m(t,(n=e,d(t=>b(t)&&t.startsWith(n)))));var n;},endsWith:e=>{return j(m(t,(n=e,d(t=>b(t)&&t.endsWith(n)))));var n;},minLength:e=>j(m(t,(t=>d(e=>b(e)&&e.length>=t))(e))),maxLength:e=>j(m(t,(t=>d(e=>b(e)&&e.length<=t))(e))),includes:e=>{return j(m(t,(n=e,d(t=>b(t)&&t.includes(n)))));var n;},regex:e=>{return j(m(t,(n=e,d(t=>b(t)&&Boolean(t.match(n))))));var n;}}),E=j(d(b)),K=t=>Object.assign(u(t),{between:(e,n)=>K(m(t,((t,e)=>d(n=>v(n)&&t<=n&&e>=n))(e,n))),lt:e=>K(m(t,(t=>d(e=>v(e)&&e<t))(e))),gt:e=>K(m(t,(t=>d(e=>v(e)&&e>t))(e))),lte:e=>K(m(t,(t=>d(e=>v(e)&&e<=t))(e))),gte:e=>K(m(t,(t=>d(e=>v(e)&&e>=t))(e))),int:()=>K(m(t,d(t=>v(t)&&Number.isInteger(t)))),finite:()=>K(m(t,d(t=>v(t)&&Number.isFinite(t)))),positive:()=>K(m(t,d(t=>v(t)&&t>0))),negative:()=>K(m(t,d(t=>v(t)&&t<0)))}),A=K(d(v)),x=t=>Object.assign(u(t),{between:(e,n)=>x(m(t,((t,e)=>d(n=>w(n)&&t<=n&&e>=n))(e,n))),lt:e=>x(m(t,(t=>d(e=>w(e)&&e<t))(e))),gt:e=>x(m(t,(t=>d(e=>w(e)&&e>t))(e))),lte:e=>x(m(t,(t=>d(e=>w(e)&&e<=t))(e))),gte:e=>x(m(t,(t=>d(e=>w(e)&&e>=t))(e))),positive:()=>x(m(t,d(t=>w(t)&&t>0))),negative:()=>x(m(t,d(t=>w(t)&&t<0)))}),P=x(d(w)),T=u(d(function(t){return "boolean"==typeof t})),k=u(d(function(t){return "symbol"==typeof t})),B=u(d(function(t){return null==t}));var _={__proto__:null,matcher:t,optional:l,array:function(...e){return h({[t]:()=>({match:t=>{if(!Array.isArray(t))return {matched:!1};if(0===e.length)return {matched:!0};const n=e[0];let r={};if(0===t.length)return o(n).forEach(t=>{r[t]=[];}),{matched:!0,selections:r};const i=(t,e)=>{r[t]=(r[t]||[]).concat([e]);};return {matched:t.every(t=>s(n,t,i)),selections:r}},getSelectionKeys:()=>0===e.length?[]:o(e[0])})})},set:function(...e){return u({[t]:()=>({match:t=>{if(!(t instanceof Set))return {matched:!1};let n={};if(0===t.size)return {matched:!0,selections:n};if(0===e.length)return {matched:!0};const r=(t,e)=>{n[t]=(n[t]||[]).concat([e]);},i=e[0];return {matched:f(t,t=>s(i,t,r)),selections:n}},getSelectionKeys:()=>0===e.length?[]:o(e[0])})})},map:function(...e){return u({[t]:()=>({match:t=>{if(!(t instanceof Map))return {matched:!1};let n={};if(0===t.size)return {matched:!0,selections:n};const r=(t,e)=>{n[t]=(n[t]||[]).concat([e]);};if(0===e.length)return {matched:!0};var i;if(1===e.length)throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${null==(i=e[0])?void 0:i.toString()}`);const[o,c]=e;return {matched:g(t,(t,e)=>{const n=s(o,e,r),i=s(c,t,r);return n&&i}),selections:n}},getSelectionKeys:()=>0===e.length?[]:[...o(e[0]),...o(e[1])]})})},intersection:m,union:y,not:function(e){return u({[t]:()=>({match:t=>({matched:!s(e,t,()=>{})}),getSelectionKeys:()=>[],matcherType:"not"})})},when:d,select:p,any:S,_:O,string:E,number:A,bigint:P,boolean:T,symbol:k,nullish:B,instanceOf:function(t){return u(d(function(t){return e=>e instanceof t}(t)))},shape:function(t){return u(d(a(t)))}};const W={matched:!1,value:void 0};function N(t){return new $(t,W)}class ${constructor(t,e){this.input=void 0,this.state=void 0,this.input=t,this.state=e;}with(...t){if(this.state.matched)return this;const e=t[t.length-1],r=[t[0]];let i;3===t.length&&"function"==typeof t[1]?(r.push(t[0]),i=t[1]):t.length>2&&r.push(...t.slice(1,t.length-1));let o=!1,c={};const a=(t,e)=>{o=!0,c[t]=e;},u=!r.some(t=>s(t,this.input,a))||i&&!Boolean(i(this.input))?W:{matched:!0,value:e(o?n in c?c[n]:c:this.input,this.input)};return new $(this.input,u)}when(t,e){if(this.state.matched)return this;const n=Boolean(t(this.input));return new $(this.input,n?{matched:!0,value:e(this.input,this.input)}:W)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){return this.run()}run(){if(this.state.matched)return this.state.value;let t;try{t=JSON.stringify(this.input);}catch(e){t=this.input;}throw new Error(`Pattern matching error: no pattern matches value ${t}`)}returnType(){return this}}
6868
6556
 
6869
- function isDestructuredFromPragma(variableName, context) {
6870
- const maybePragma = getPragmaFromContext(context);
6557
+ function isPropertyOfPragma(name, context, pragma = getPragmaFromContext(context)) {
6558
+ const isMatch = a({
6559
+ type: NodeType.MemberExpression,
6560
+ object: {
6561
+ type: NodeType.Identifier,
6562
+ name: pragma
6563
+ },
6564
+ property: {
6565
+ name
6566
+ }
6567
+ });
6568
+ return isMatch;
6569
+ }
6570
+
6571
+ function isInitializedFromPragma(variableName, context, pragma = getPragmaFromContext(context)) {
6871
6572
  const variables = getVariablesUpToGlobal(context.getScope());
6872
- if (effectEither_esm.isLeft(maybePragma)) {
6873
- return false;
6874
- }
6875
- const pragma = maybePragma.right;
6876
- const maybeLatestDef = effectFunction_esm.pipe(findVariableByName(variableName)(variables), effectOption_esm.flatMapNullable((variable)=>variable.defs.at(-1)));
6573
+ const maybeVariable = findVariableByName(variableName)(variables);
6574
+ const maybeLatestDef = effectOption_esm.flatMapNullable(maybeVariable, (variable)=>variable.defs.at(-1));
6877
6575
  if (effectOption_esm.isNone(maybeLatestDef)) {
6878
6576
  return false;
6879
6577
  }
@@ -6929,32 +6627,24 @@ function isDestructuredFromPragma(variableName, context) {
6929
6627
  }
6930
6628
  }, parent);
6931
6629
  }
6932
-
6933
6630
  /**
6934
6631
  * Checks if the given node is a call expression to the given function or method of the pragma
6935
6632
  * @param name The name of the function or method to check
6936
6633
  * @returns A predicate that checks if the given node is a call expression to the given function or method
6937
- */ const isCallFromPragma = (name)=>(node, context)=>{
6634
+ */ function isCallFromPragma(name) {
6635
+ return (node, context)=>{
6938
6636
  if (node.type !== NodeType.CallExpression || !("callee" in node)) {
6939
6637
  return false;
6940
6638
  }
6941
- const maybePragma = getPragmaFromContext(context);
6942
- if (effectEither_esm.isLeft(maybePragma)) {
6943
- return false;
6639
+ if (node.callee.type === NodeType.MemberExpression) {
6640
+ return isPropertyOfPragma(name, context)(node.callee);
6944
6641
  }
6945
- const pragma = maybePragma.right;
6946
- return N(node.callee).with({
6947
- type: NodeType.MemberExpression,
6948
- object: {
6949
- name: pragma
6950
- },
6951
- property: {
6952
- name
6953
- }
6954
- }, effectFunction_esm.constTrue).with({
6955
- name
6956
- }, ({ name })=>isDestructuredFromPragma(name, context)).otherwise(effectFunction_esm.constFalse);
6642
+ if ("name" in node.callee && node.callee.name === name) {
6643
+ return isInitializedFromPragma(name, context);
6644
+ }
6645
+ return false;
6957
6646
  };
6647
+ }
6958
6648
 
6959
6649
  /**
6960
6650
  * Checks if the given node is a call expression to `createElement`
@@ -7132,23 +6822,6 @@ const hdlWheel = [
7132
6822
  ...hdlWheel
7133
6823
  ];
7134
6824
 
7135
- /**
7136
- * Tests if a value is a `string`.
7137
- *
7138
- * @param input - The value to test.
7139
- *
7140
- * @example
7141
- * import { isString } from "effect/Predicate"
7142
- *
7143
- * assert.deepStrictEqual(isString("a"), true)
7144
- *
7145
- * assert.deepStrictEqual(isString(1), false)
7146
- *
7147
- * @category guards
7148
- * @since 2.0.0
7149
- */
7150
- const isString = input => typeof input === "string";
7151
-
7152
6825
  const defaultJSXValueCheckOptions = {
7153
6826
  ignoreNull: false,
7154
6827
  strict: false
@@ -7198,7 +6871,7 @@ const defaultJSXValueCheckOptions = {
7198
6871
  if (isJSXTagNameExpression(node)) {
7199
6872
  return true;
7200
6873
  }
7201
- if (!isString(node.name) && node.name.type !== NodeType.Identifier) {
6874
+ if (!isString$1(node.name) && node.name.type !== NodeType.Identifier) {
7202
6875
  return isJSXTagNameExpression(node.name);
7203
6876
  }
7204
6877
  const name = N(node.name).with(_.string, effectFunction_esm.identity).with({
@@ -7356,22 +7029,28 @@ const defaultJSXValueCheckOptions = {
7356
7029
  }));
7357
7030
  };
7358
7031
  }
7359
- function getPropValue(attribute, context) {
7032
+ /**
7033
+ * Gets and resolves the static value of a JSX attribute
7034
+ * @param attribute The JSX attribute to get the value of
7035
+ * @param context The rule context
7036
+ * @returns The static value of the given JSX attribute
7037
+ */ function getPropValue(attribute, context) {
7038
+ const scope = context.getScope();
7360
7039
  if (attribute.type === NodeType.JSXAttribute && "value" in attribute) {
7361
7040
  const { value } = attribute;
7362
7041
  if (value === null) {
7363
7042
  return effectOption_esm.none();
7364
7043
  }
7365
7044
  if (value.type === NodeType.Literal) {
7366
- return effectOption_esm.some(getStaticValue(value, context.getScope()));
7045
+ return effectOption_esm.some(getStaticValue(value, scope));
7367
7046
  }
7368
7047
  if (value.type === NodeType.JSXExpressionContainer) {
7369
- return effectOption_esm.some(getStaticValue(value.expression, context.getScope()));
7048
+ return effectOption_esm.some(getStaticValue(value.expression, scope));
7370
7049
  }
7371
7050
  return effectOption_esm.none();
7372
7051
  }
7373
7052
  const { argument } = attribute;
7374
- return effectOption_esm.some(getStaticValue(argument, context.getScope()));
7053
+ return effectOption_esm.some(getStaticValue(argument, scope));
7375
7054
  }
7376
7055
 
7377
7056
  /**
@@ -7387,7 +7066,7 @@ function getPropValue(attribute, context) {
7387
7066
  * @param node The AST node to check
7388
7067
  * @returns boolean `true` if the node is whitespace
7389
7068
  */ function isWhiteSpace(node) {
7390
- return isString(node.value) && node.value.trim() === "";
7069
+ return isString$1(node.value) && node.value.trim() === "";
7391
7070
  }
7392
7071
  /**
7393
7072
  * Check if a Literal or JSXText node is a line break
@@ -7428,12 +7107,13 @@ exports.isCallFromPragma = isCallFromPragma;
7428
7107
  exports.isChildrenOfCreateElement = isChildrenOfCreateElement;
7429
7108
  exports.isCloneElementCall = isCloneElementCall;
7430
7109
  exports.isCreateElementCall = isCreateElementCall;
7431
- exports.isDestructuredFromPragma = isDestructuredFromPragma;
7432
7110
  exports.isFunctionReturningJSXValue = isFunctionReturningJSXValue;
7111
+ exports.isInitializedFromPragma = isInitializedFromPragma;
7433
7112
  exports.isInsideCreateElementProps = isInsideCreateElementProps;
7434
7113
  exports.isInsidePropValue = isInsidePropValue;
7435
7114
  exports.isJSXValue = isJSXValue;
7436
7115
  exports.isLineBreak = isLineBreak;
7437
7116
  exports.isLiteral = isLiteral;
7117
+ exports.isPropertyOfPragma = isPropertyOfPragma;
7438
7118
  exports.isWhiteSpace = isWhiteSpace;
7439
7119
  exports.traverseUpProp = traverseUpProp;