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