@eslint-react/jsx 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -470,9 +470,10 @@ var effectFunction_esm = /*#__PURE__*/ Object.freeze({
470
470
  unsafeCoerce: unsafeCoerce,
471
471
  untupled: untupled
472
472
  });
473
+ const moduleVersion = "2.0.0-next.54";
473
474
  /**
474
475
  * @since 2.0.0
475
- */ const globalStoreId = /*#__PURE__*/ Symbol.for("effect/GlobalValue/globalStoreId");
476
+ */ const globalStoreId = /*#__PURE__*/ Symbol.for(`effect/GlobalValue/globalStoreId/${moduleVersion}`);
476
477
  if (!(globalStoreId in globalThis)) {
477
478
  globalThis[globalStoreId] = /*#__PURE__*/ new Map();
478
479
  }
@@ -516,7 +517,35 @@ const globalStore = globalThis[globalStoreId];
516
517
  *
517
518
  * @category guards
518
519
  * @since 2.0.0
519
- */ const isObject = (input)=>typeof input === "object" && input != null || isFunction(input);
520
+ */ const isObject = (input)=>typeof input === "object" && input !== null || isFunction(input);
521
+ /**
522
+ * Checks whether a value is an `object` containing a specified property key.
523
+ *
524
+ * @param property - The field to check within the object.
525
+ * @param self - The value to examine.
526
+ *
527
+ * @category guards
528
+ * @since 2.0.0
529
+ */ const hasProperty = /*#__PURE__*/ dual(2, (self, property)=>isObject(self) && property in self);
530
+ /**
531
+ * Tests if a value is an `object` with a property `_tag` that matches the given tag.
532
+ *
533
+ * @param input - The value to test.
534
+ * @param tag - The tag to test for.
535
+ *
536
+ * @example
537
+ * import { isTagged } from "effect/Predicate"
538
+ *
539
+ * assert.deepStrictEqual(isTagged(1, "a"), false)
540
+ * assert.deepStrictEqual(isTagged(null, "a"), false)
541
+ * assert.deepStrictEqual(isTagged({}, "a"), false)
542
+ * assert.deepStrictEqual(isTagged({ a: "a" }, "a"), false)
543
+ * assert.deepStrictEqual(isTagged({ _tag: "a" }, "a"), true)
544
+ * assert.deepStrictEqual(isTagged("a")({ _tag: "a" }), true)
545
+ *
546
+ * @category guards
547
+ * @since 2.0.0
548
+ */ const isTagged = /*#__PURE__*/ dual(2, (self, tag)=>hasProperty(self, "_tag") && self["_tag"] === tag);
520
549
  /**
521
550
  * A guard that succeeds when the input is `null` or `undefined`.
522
551
  *
@@ -895,7 +924,7 @@ function add64(out, aHi, aLo, bHi, bLo) {
895
924
  /**
896
925
  * @since 2.0.0
897
926
  * @category guards
898
- */ const isHash = (u)=>typeof u === "object" && u !== null && symbol$1 in u;
927
+ */ const isHash = (u)=>hasProperty(u, symbol$1);
899
928
  /**
900
929
  * @since 2.0.0
901
930
  * @category hashing
@@ -982,7 +1011,7 @@ function compareBoth(self, that) {
982
1011
  /**
983
1012
  * @since 2.0.0
984
1013
  * @category guards
985
- */ const isEqual = (u)=>typeof u === "object" && u !== null && symbol in u;
1014
+ */ const isEqual = (u)=>hasProperty(u, symbol);
986
1015
  /**
987
1016
  * @since 2.0.0
988
1017
  * @category instances
@@ -1018,7 +1047,7 @@ function compareBoth(self, that) {
1018
1047
  */ /**
1019
1048
  * @since 2.0.0
1020
1049
  */ const toJSON = (x)=>{
1021
- if (typeof x === "object" && x !== null && "toJSON" in x && typeof x["toJSON"] === "function" && x["toJSON"].length === 0) {
1050
+ if (hasProperty(x, "toJSON") && isFunction(x["toJSON"]) && x["toJSON"].length === 0) {
1022
1051
  return x.toJSON();
1023
1052
  } else if (Array.isArray(x)) {
1024
1053
  return x.map(toJSON);
@@ -1112,10 +1141,11 @@ function compareBoth(self, that) {
1112
1141
  /** @internal */ const StreamTypeId = /*#__PURE__*/ Symbol.for("effect/Stream");
1113
1142
  /** @internal */ const SinkTypeId = /*#__PURE__*/ Symbol.for("effect/Sink");
1114
1143
  /** @internal */ const ChannelTypeId = /*#__PURE__*/ Symbol.for("effect/Channel");
1115
- /** @internal */ const effectVariance$1 = {
1144
+ /** @internal */ const effectVariance = {
1116
1145
  _R: (_)=>_,
1117
1146
  _E: (_)=>_,
1118
- _A: (_)=>_
1147
+ _A: (_)=>_,
1148
+ _V: moduleVersion
1119
1149
  };
1120
1150
  /** @internal */ const sinkVariance = {
1121
1151
  _R: (_)=>_,
@@ -1134,8 +1164,8 @@ function compareBoth(self, that) {
1134
1164
  _OutDone: (_)=>_
1135
1165
  };
1136
1166
  /** @internal */ const EffectPrototype = {
1137
- [EffectTypeId$1]: effectVariance$1,
1138
- [StreamTypeId]: effectVariance$1,
1167
+ [EffectTypeId$1]: effectVariance,
1168
+ [StreamTypeId]: effectVariance,
1139
1169
  [SinkTypeId]: sinkVariance,
1140
1170
  [ChannelTypeId]: channelVariance,
1141
1171
  [symbol] (that) {
@@ -1204,7 +1234,7 @@ const NoneProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Common
1204
1234
  };
1205
1235
  }
1206
1236
  });
1207
- /** @internal */ const isOption$1 = (input)=>typeof input === "object" && input != null && TypeId$8 in input;
1237
+ /** @internal */ const isOption$1 = (input)=>hasProperty(input, TypeId$8);
1208
1238
  /** @internal */ const isNone$1 = (fa)=>fa._tag === "None";
1209
1239
  /** @internal */ const isSome$1 = (fa)=>fa._tag === "Some";
1210
1240
  /** @internal */ const none$1 = /*#__PURE__*/ Object.create(NoneProto);
@@ -1264,7 +1294,7 @@ const LeftProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Common
1264
1294
  };
1265
1295
  }
1266
1296
  });
1267
- /** @internal */ const isEither$1 = (input)=>typeof input === "object" && input != null && TypeId$7 in input;
1297
+ /** @internal */ const isEither$1 = (input)=>hasProperty(input, TypeId$7);
1268
1298
  /** @internal */ const isLeft$1 = (ma)=>ma._tag === "Left";
1269
1299
  /** @internal */ const isRight$1 = (ma)=>ma._tag === "Right";
1270
1300
  /** @internal */ const left$1 = (left)=>{
@@ -2291,7 +2321,7 @@ const emptyArray = [];
2291
2321
  *
2292
2322
  * @category equivalence
2293
2323
  * @since 2.0.0
2294
- */ const getEquivalence$1 = (isEquivalent)=>make$7((self, that)=>toReadonlyArray$1(self).every((value, i)=>isEquivalent(value, unsafeGet(that, i))));
2324
+ */ const getEquivalence$1 = (isEquivalent)=>make$7((self, that)=>self.length === that.length && toReadonlyArray$1(self).every((value, i)=>isEquivalent(value, unsafeGet(that, i))));
2295
2325
  const _equivalence$1 = /*#__PURE__*/ getEquivalence$1(equals);
2296
2326
  const ChunkProto = {
2297
2327
  [TypeId$4]: {
@@ -2387,7 +2417,7 @@ const makeChunk = (backing)=>{
2387
2417
  *
2388
2418
  * @category constructors
2389
2419
  * @since 2.0.0
2390
- */ const isChunk = (u)=>isObject(u) && TypeId$4 in u;
2420
+ */ const isChunk = (u)=>hasProperty(u, TypeId$4);
2391
2421
  const _empty$4 = /*#__PURE__*/ makeChunk({
2392
2422
  _tag: "IEmpty"
2393
2423
  });
@@ -2715,7 +2745,7 @@ const copyToArray = (self, array, initial)=>{
2715
2745
  ...EffectPrototype,
2716
2746
  _tag: "Tag",
2717
2747
  _op: "Tag",
2718
- [STMTypeId]: effectVariance$1,
2748
+ [STMTypeId]: effectVariance,
2719
2749
  [TagTypeId]: {
2720
2750
  _S: (_)=>_,
2721
2751
  _I: (_)=>_
@@ -2803,7 +2833,7 @@ const tagRegistry = /*#__PURE__*/ globalValue("effect/Context/Tag/tagRegistry",
2803
2833
  context.unsafeMap = unsafeMap;
2804
2834
  return context;
2805
2835
  };
2806
- /** @internal */ const isContext = (u)=>typeof u === "object" && u !== null && TypeId$3 in u;
2836
+ /** @internal */ const isContext = (u)=>hasProperty(u, TypeId$3);
2807
2837
  const _empty$3 = /*#__PURE__*/ makeContext(/*#__PURE__*/ new Map());
2808
2838
  /** @internal */ const empty$7 = ()=>_empty$3;
2809
2839
  /** @internal */ const make$4 = (tag, service)=>makeContext(new Map([
@@ -3091,7 +3121,7 @@ const makeUpdateService = (tag, update)=>{
3091
3121
  }
3092
3122
  }
3093
3123
  /** @internal */ function isEmptyNode(a) {
3094
- return typeof a === "object" && a !== null && "_tag" in a && a._tag === "EmptyNode";
3124
+ return isTagged(a, "EmptyNode");
3095
3125
  }
3096
3126
  /** @internal */ function isLeafNode(node) {
3097
3127
  return isEmptyNode(node) || node._tag === "LeafNode" || node._tag === "CollisionNode";
@@ -3442,7 +3472,7 @@ const visitLazyChildren = (len, children, i, f, cont)=>{
3442
3472
  };
3443
3473
  const _empty$1 = /*#__PURE__*/ makeImpl$1(false, 0, /*#__PURE__*/ new EmptyNode(), 0);
3444
3474
  /** @internal */ const empty$4 = ()=>_empty$1;
3445
- /** @internal */ const isHashMap = (u)=>isObject(u) && HashMapTypeId in u;
3475
+ /** @internal */ const isHashMap = (u)=>hasProperty(u, HashMapTypeId);
3446
3476
  /** @internal */ const getHash = /*#__PURE__*/ dual(3, (self, key, hash)=>{
3447
3477
  let node = self._root;
3448
3478
  let shift = 0;
@@ -3576,7 +3606,7 @@ const _empty$1 = /*#__PURE__*/ makeImpl$1(false, 0, /*#__PURE__*/ new EmptyNode(
3576
3606
  set._keyMap = keyMap;
3577
3607
  return set;
3578
3608
  };
3579
- /** @internal */ const isHashSet = (u)=>isObject(u) && HashSetTypeId in u;
3609
+ /** @internal */ const isHashSet = (u)=>hasProperty(u, HashSetTypeId);
3580
3610
  const _empty = /*#__PURE__*/ makeImpl(/*#__PURE__*/ empty$4());
3581
3611
  /** @internal */ const empty$3 = ()=>_empty;
3582
3612
  /** @internal */ const size$2 = (self)=>size$3(self._keyMap);
@@ -3907,7 +3937,7 @@ var effectMutableRef_esm = /*#__PURE__*/ Object.freeze({
3907
3937
  // -----------------------------------------------------------------------------
3908
3938
  // Refinements
3909
3939
  // -----------------------------------------------------------------------------
3910
- /** @internal */ const isCause = (u)=>typeof u === "object" && u != null && CauseTypeId in u;
3940
+ /** @internal */ const isCause = (u)=>hasProperty(u, CauseTypeId);
3911
3941
  /** @internal */ const isInterruptedOnly = (self)=>reduceWithContext(undefined, IsInterruptedOnlyCauseReducer)(self);
3912
3942
  /** @internal */ const causeEquals = (left, right)=>{
3913
3943
  let leftStack = of$1(left);
@@ -4277,7 +4307,7 @@ class PrettyError {
4277
4307
  return `Error: ${u}`;
4278
4308
  }
4279
4309
  // 2)
4280
- if (typeof u === "object" && u != null && "toString" in u && typeof u["toString"] === "function" && u["toString"] !== Object.prototype.toString) {
4310
+ if (hasProperty(u, "toString") && isFunction(u["toString"]) && u["toString"] !== Object.prototype.toString) {
4281
4311
  return u["toString"]();
4282
4312
  }
4283
4313
  // 3)
@@ -4285,8 +4315,8 @@ class PrettyError {
4285
4315
  };
4286
4316
  const spanSymbol$1 = /*#__PURE__*/ Symbol.for("effect/SpanAnnotation");
4287
4317
  const defaultRenderError = (error)=>{
4288
- const span = typeof error === "object" && error !== null && spanSymbol$1 in error && error[spanSymbol$1];
4289
- if (typeof error === "object" && error !== null && error instanceof Error) {
4318
+ const span = hasProperty(error, spanSymbol$1) && error[spanSymbol$1];
4319
+ if (error instanceof Error) {
4290
4320
  return new PrettyError(prettyErrorMessage(error), error.stack?.split("\n").filter((_)=>_.match(/at (.*)/)).join("\n"), span);
4291
4321
  }
4292
4322
  return new PrettyError(prettyErrorMessage(error), void 0, span);
@@ -4386,11 +4416,6 @@ const defaultRenderError = (error)=>{
4386
4416
  return this.toJSON();
4387
4417
  }
4388
4418
  }
4389
- /** @internal */ const effectVariance = {
4390
- _R: (_)=>_,
4391
- _E: (_)=>_,
4392
- _A: (_)=>_
4393
- };
4394
4419
  /* @internal */ const withFiberRuntime = (withRuntime)=>{
4395
4420
  const effect = new EffectPrimitive(OP_WITH_RUNTIME);
4396
4421
  effect.i0 = withRuntime;
@@ -4418,7 +4443,7 @@ const originalSymbol = /*#__PURE__*/ Symbol.for("effect/OriginalAnnotation");
4418
4443
  }
4419
4444
  return obj;
4420
4445
  };
4421
- /* @internal */ const fail$1 = (error)=>typeof error === "object" && error !== null && !(spanSymbol in error) ? withFiberRuntime((fiber)=>failCause(fail$2(capture(error, currentSpanFromFiber(fiber))))) : failCause(fail$2(error));
4446
+ /* @internal */ const fail$1 = (error)=>isObject(error) && !(spanSymbol in error) ? withFiberRuntime((fiber)=>failCause(fail$2(capture(error, currentSpanFromFiber(fiber))))) : failCause(fail$2(error));
4422
4447
  /* @internal */ const failCause = (cause)=>{
4423
4448
  const effect = new EffectPrimitiveFailure(OP_FAILURE);
4424
4449
  effect.i0 = cause;
@@ -4464,14 +4489,14 @@ const originalSymbol = /*#__PURE__*/ Symbol.for("effect/OriginalAnnotation");
4464
4489
  *
4465
4490
  * @see https://github.com/oven-sh/bun/issues/3333
4466
4491
  */ /** @internal */ typeof process === "undefined" ? false : !!process?.isBun;
4467
- /**
4468
- * @since 2.0.0
4469
- * @category constructors
4470
- */ const fail = fail$1;
4471
4492
  /**
4472
4493
  * @since 2.0.0
4473
4494
  * @category prototypes
4474
4495
  */ const StructuralCommitPrototype = StructuralCommitPrototype$1;
4496
+ /**
4497
+ * @since 2.0.0
4498
+ * @category constructors
4499
+ */ const fail = fail$1;
4475
4500
  /**
4476
4501
  * @since 2.0.0
4477
4502
  */ /**
@@ -4756,350 +4781,14 @@ function isNil(x){
4756
4781
  return x === undefined || x === null
4757
4782
  }
4758
4783
 
4759
- /**
4760
- * Tests if a value is a `string`.
4761
- *
4762
- * @param input - The value to test.
4763
- *
4764
- * @example
4765
- * import { isString } from "effect/Predicate"
4766
- *
4767
- * assert.deepStrictEqual(isString("a"), true)
4768
- *
4769
- * assert.deepStrictEqual(isString(1), false)
4770
- *
4771
- * @category guards
4772
- * @since 2.0.0
4773
- */ const isString$1 = (input)=>typeof input === "string";
4774
- 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)=>{
4775
- if (i$1(n)) {
4776
- const e = n[t$1](), { matched: r, selections: i } = e.match(o);
4777
- return r && i && Object.keys(i).forEach((t)=>c(t, i[t])), r;
4778
- }
4779
- if (r$1(n)) {
4780
- if (!r$1(o)) return !1;
4781
- if (Array.isArray(n)) {
4782
- if (!Array.isArray(o)) return !1;
4783
- let t = [], r = [], a = [];
4784
- for (const s of n.keys()){
4785
- const o = n[s];
4786
- i$1(o) && o[e$1] ? a.push(o) : a.length ? r.push(o) : t.push(o);
4787
- }
4788
- if (a.length) {
4789
- if (a.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
4790
- if (o.length < t.length + r.length) return !1;
4791
- 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);
4792
- return t.every((t, n)=>s$1(t, e[n], c)) && r.every((t, e)=>s$1(t, n[e], c)) && (0 === a.length || s$1(a[0], i, c));
4793
- }
4794
- return n.length === o.length && n.every((t, e)=>s$1(t, o[e], c));
4795
- }
4796
- return Object.keys(n).every((e)=>{
4797
- const r = n[e];
4798
- return (e in o || i$1(a = r) && "optional" === a[t$1]().matcherType) && s$1(r, o[e], c);
4799
- var a;
4800
- });
4801
- }
4802
- return Object.is(o, n);
4803
- }, o$1 = (e)=>{
4804
- var n, s, a;
4805
- return r$1(e) ? i$1(e) ? null != (n = null == (s = (a = e[t$1]()).getSelectionKeys) ? void 0 : s.call(a)) ? n : [] : Array.isArray(e) ? c$1(e, o$1) : c$1(Object.values(e), o$1) : [];
4806
- }, c$1 = (t, e)=>t.reduce((t, n)=>t.concat(e(n)), []);
4807
- function u$1(t) {
4808
- return Object.assign(t, {
4809
- optional: ()=>l$1(t),
4810
- and: (e)=>m$1(t, e),
4811
- or: (e)=>y$1(t, e),
4812
- select: (e)=>void 0 === e ? p$1(t) : p$1(e, t)
4813
- });
4814
- }
4815
- function l$1(e) {
4816
- return u$1({
4817
- [t$1]: ()=>({
4818
- match: (t)=>{
4819
- let n = {};
4820
- const r = (t, e)=>{
4821
- n[t] = e;
4822
- };
4823
- return void 0 === t ? (o$1(e).forEach((t)=>r(t, void 0)), {
4824
- matched: !0,
4825
- selections: n
4826
- }) : {
4827
- matched: s$1(e, t, r),
4828
- selections: n
4829
- };
4830
- },
4831
- getSelectionKeys: ()=>o$1(e),
4832
- matcherType: "optional"
4833
- })
4834
- });
4835
- }
4836
- function m$1(...e) {
4837
- return u$1({
4838
- [t$1]: ()=>({
4839
- match: (t)=>{
4840
- let n = {};
4841
- const r = (t, e)=>{
4842
- n[t] = e;
4843
- };
4844
- return {
4845
- matched: e.every((e)=>s$1(e, t, r)),
4846
- selections: n
4847
- };
4848
- },
4849
- getSelectionKeys: ()=>c$1(e, o$1),
4850
- matcherType: "and"
4851
- })
4852
- });
4853
- }
4854
- function y$1(...e) {
4855
- return u$1({
4856
- [t$1]: ()=>({
4857
- match: (t)=>{
4858
- let n = {};
4859
- const r = (t, e)=>{
4860
- n[t] = e;
4861
- };
4862
- return c$1(e, o$1).forEach((t)=>r(t, void 0)), {
4863
- matched: e.some((e)=>s$1(e, t, r)),
4864
- selections: n
4865
- };
4866
- },
4867
- getSelectionKeys: ()=>c$1(e, o$1),
4868
- matcherType: "or"
4869
- })
4870
- });
4871
- }
4872
- function d$1(e) {
4873
- return {
4874
- [t$1]: ()=>({
4875
- match: (t)=>({
4876
- matched: Boolean(e(t))
4877
- })
4878
- })
4879
- };
4880
- }
4881
- function p$1(...e) {
4882
- const r = "string" == typeof e[0] ? e[0] : void 0, i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
4883
- return u$1({
4884
- [t$1]: ()=>({
4885
- match: (t)=>{
4886
- let e = {
4887
- [null != r ? r : n$1]: t
4888
- };
4889
- return {
4890
- matched: void 0 === i || s$1(i, t, (t, n)=>{
4891
- e[t] = n;
4892
- }),
4893
- selections: e
4894
- };
4895
- },
4896
- getSelectionKeys: ()=>[
4897
- null != r ? r : n$1
4898
- ].concat(void 0 === i ? [] : o$1(i))
4899
- })
4900
- });
4901
- }
4902
- function v$1(t) {
4903
- return "number" == typeof t;
4904
- }
4905
- function b$1(t) {
4906
- return "string" == typeof t;
4907
- }
4908
- function w$1(t) {
4909
- return "bigint" == typeof t;
4910
- }
4911
- u$1(d$1(function(t) {
4912
- return !0;
4913
- }));
4914
- const j$1 = (t)=>Object.assign(u$1(t), {
4915
- startsWith: (e)=>{
4916
- return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.startsWith(n)))));
4917
- var n;
4918
- },
4919
- endsWith: (e)=>{
4920
- return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.endsWith(n)))));
4921
- var n;
4922
- },
4923
- minLength: (e)=>j$1(m$1(t, ((t)=>d$1((e)=>b$1(e) && e.length >= t))(e))),
4924
- maxLength: (e)=>j$1(m$1(t, ((t)=>d$1((e)=>b$1(e) && e.length <= t))(e))),
4925
- includes: (e)=>{
4926
- return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.includes(n)))));
4927
- var n;
4928
- },
4929
- regex: (e)=>{
4930
- return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && Boolean(t.match(n))))));
4931
- var n;
4932
- }
4933
- });
4934
- j$1(d$1(b$1));
4935
- const K$1 = (t)=>Object.assign(u$1(t), {
4936
- between: (e, n)=>K$1(m$1(t, ((t, e)=>d$1((n)=>v$1(n) && t <= n && e >= n))(e, n))),
4937
- lt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e < t))(e))),
4938
- gt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e > t))(e))),
4939
- lte: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e <= t))(e))),
4940
- gte: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e >= t))(e))),
4941
- int: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isInteger(t)))),
4942
- finite: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isFinite(t)))),
4943
- positive: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t > 0))),
4944
- negative: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t < 0)))
4945
- });
4946
- K$1(d$1(v$1));
4947
- const x$1 = (t)=>Object.assign(u$1(t), {
4948
- between: (e, n)=>x$1(m$1(t, ((t, e)=>d$1((n)=>w$1(n) && t <= n && e >= n))(e, n))),
4949
- lt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e < t))(e))),
4950
- gt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e > t))(e))),
4951
- lte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e <= t))(e))),
4952
- gte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e >= t))(e))),
4953
- positive: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t > 0))),
4954
- negative: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t < 0)))
4955
- });
4956
- x$1(d$1(w$1));
4957
- u$1(d$1(function(t) {
4958
- return "boolean" == typeof t;
4959
- }));
4960
- u$1(d$1(function(t) {
4961
- return "symbol" == typeof t;
4962
- }));
4963
- u$1(d$1(function(t) {
4964
- return null == t;
4965
- }));
4966
- const NodeType = types.AST_NODE_TYPES;
4967
- const is = utils.ASTUtils.isNodeOfType;
4968
- const isOneOf = utils.ASTUtils.isNodeOfTypes;
4969
- isOneOf([
4970
- NodeType.ArrowFunctionExpression,
4971
- NodeType.FunctionDeclaration,
4972
- NodeType.FunctionExpression
4973
- ]);
4974
- isOneOf([
4975
- NodeType.ArrowFunctionExpression,
4976
- NodeType.FunctionDeclaration,
4977
- NodeType.FunctionExpression,
4978
- NodeType.TSCallSignatureDeclaration,
4979
- NodeType.TSConstructSignatureDeclaration,
4980
- NodeType.TSDeclareFunction,
4981
- NodeType.TSEmptyBodyFunctionExpression,
4982
- NodeType.TSFunctionType,
4983
- NodeType.TSMethodSignature
4984
- ]);
4985
- isOneOf([
4986
- NodeType.ClassDeclaration,
4987
- NodeType.ClassExpression
4988
- ]);
4989
- isOneOf([
4990
- NodeType.DoWhileStatement,
4991
- NodeType.ForInStatement,
4992
- NodeType.ForOfStatement,
4993
- NodeType.ForStatement,
4994
- NodeType.WhileStatement
4995
- ]);
4996
- isOneOf([
4997
- NodeType.TSArrayType,
4998
- NodeType.TSTupleType
4999
- ]);
5000
- isOneOf([
5001
- NodeType.PropertyDefinition,
5002
- NodeType.TSIndexSignature,
5003
- NodeType.TSParameterProperty,
5004
- NodeType.TSPropertySignature
5005
- ]);
5006
- is(NodeType.JSXElement);
5007
- is(NodeType.JSXFragment);
5008
- isOneOf([
5009
- NodeType.JSXAttribute,
5010
- NodeType.JSXSpreadChild,
5011
- NodeType.JSXClosingElement,
5012
- NodeType.JSXClosingFragment,
5013
- NodeType.JSXElement,
5014
- NodeType.JSXEmptyExpression,
5015
- NodeType.JSXExpressionContainer,
5016
- NodeType.JSXFragment,
5017
- NodeType.JSXIdentifier,
5018
- NodeType.JSXMemberExpression,
5019
- NodeType.JSXNamespacedName,
5020
- NodeType.JSXOpeningElement,
5021
- NodeType.JSXOpeningFragment,
5022
- NodeType.JSXSpreadAttribute,
5023
- NodeType.JSXSpreadChild,
5024
- NodeType.JSXText
5025
- ]);
5026
- const isJSXTagNameExpression = isOneOf([
5027
- NodeType.JSXIdentifier,
5028
- NodeType.JSXMemberExpression,
5029
- NodeType.JSXNamespacedName
5030
- ]);
5031
- isOneOf([
5032
- NodeType.ArrayPattern,
5033
- NodeType.AssignmentPattern,
5034
- NodeType.ObjectPattern,
5035
- NodeType.RestElement
5036
- ]);
5037
- isOneOf([
5038
- NodeType.TSInterfaceDeclaration,
5039
- NodeType.TSTypeAliasDeclaration
5040
- ]);
5041
- isOneOf([
5042
- NodeType.ArrayExpression,
5043
- NodeType.ArrayPattern,
5044
- NodeType.ArrowFunctionExpression,
5045
- NodeType.CallExpression,
5046
- NodeType.ClassExpression,
5047
- NodeType.FunctionExpression,
5048
- NodeType.Identifier,
5049
- NodeType.JSXElement,
5050
- NodeType.JSXFragment,
5051
- NodeType.Literal,
5052
- NodeType.TemplateLiteral,
5053
- NodeType.MemberExpression,
5054
- NodeType.MetaProperty,
5055
- NodeType.ObjectExpression,
5056
- NodeType.ObjectPattern,
5057
- NodeType.SequenceExpression,
5058
- NodeType.Super,
5059
- NodeType.TaggedTemplateExpression,
5060
- NodeType.ThisExpression
5061
- ]);
5062
- isOneOf([
5063
- NodeType.ArrayExpression,
5064
- NodeType.ArrayPattern,
5065
- NodeType.ArrowFunctionExpression,
5066
- NodeType.CallExpression,
5067
- NodeType.ClassExpression,
5068
- NodeType.FunctionExpression,
5069
- NodeType.Identifier,
5070
- NodeType.JSXElement,
5071
- NodeType.JSXFragment,
5072
- NodeType.Literal,
5073
- NodeType.TemplateLiteral,
5074
- NodeType.MemberExpression,
5075
- NodeType.MetaProperty,
5076
- NodeType.ObjectExpression,
5077
- NodeType.ObjectPattern,
5078
- NodeType.SequenceExpression,
5079
- NodeType.Super,
5080
- NodeType.TaggedTemplateExpression,
5081
- NodeType.ThisExpression,
5082
- NodeType.TSAsExpression,
5083
- NodeType.TSNonNullExpression,
5084
- NodeType.TSTypeAssertion
5085
- ]);
5086
- const Construction = effectData_esm.taggedEnum();
5087
- Construction.None();
5088
- [
5089
- NodeType.JSXElement,
5090
- NodeType.ArrayExpression,
5091
- NodeType.ObjectExpression,
5092
- NodeType.FunctionExpression,
5093
- NodeType.ArrowFunctionExpression,
5094
- NodeType.ClassExpression,
5095
- NodeType.NewExpression,
5096
- NodeType.CallExpression
5097
- ];
5098
4784
  /**
5099
4785
  * @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
5100
- */ /**
4786
+ */
4787
+
4788
+ /**
5101
4789
  * @type {VisitorKeys}
5102
- */ const KEYS = {
4790
+ */
4791
+ const KEYS = {
5103
4792
  ArrayExpression: [
5104
4793
  "elements"
5105
4794
  ],
@@ -5396,187 +5085,232 @@ Construction.None();
5396
5085
  "argument"
5397
5086
  ]
5398
5087
  };
5088
+
5399
5089
  // Types.
5400
5090
  const NODE_TYPES = Object.keys(KEYS);
5091
+
5401
5092
  // Freeze the keys.
5402
- for (const type of NODE_TYPES){
5093
+ for (const type of NODE_TYPES) {
5403
5094
  Object.freeze(KEYS[type]);
5404
5095
  }
5405
5096
  Object.freeze(KEYS);
5097
+
5406
5098
  /**
5407
5099
  * @author Toru Nagashima <https://github.com/mysticatea>
5408
5100
  * See LICENSE file in root directory for full license.
5409
- */ /**
5101
+ */
5102
+
5103
+ /**
5410
5104
  * @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys
5411
- */ // List to ignore keys.
5105
+ */
5106
+
5107
+ // List to ignore keys.
5412
5108
  const KEY_BLACKLIST = new Set([
5413
5109
  "parent",
5414
5110
  "leadingComments",
5415
5111
  "trailingComments"
5416
5112
  ]);
5113
+
5417
5114
  /**
5418
5115
  * Check whether a given key should be used or not.
5419
5116
  * @param {string} key The key to check.
5420
5117
  * @returns {boolean} `true` if the key should be used.
5421
- */ function filterKey(key) {
5118
+ */
5119
+ function filterKey(key) {
5422
5120
  return !KEY_BLACKLIST.has(key) && key[0] !== "_";
5423
5121
  }
5122
+
5424
5123
  /**
5425
5124
  * Get visitor keys of a given node.
5426
5125
  * @param {object} node The AST node to get keys.
5427
5126
  * @returns {readonly string[]} Visitor keys of the node.
5428
- */ function getKeys(node) {
5127
+ */
5128
+ function getKeys(node) {
5429
5129
  return Object.keys(node).filter(filterKey);
5430
5130
  }
5131
+
5431
5132
  /**
5432
5133
  * Get the innermost scope which contains a given location.
5433
5134
  * @param {Scope} initialScope The initial scope to search.
5434
5135
  * @param {Node} node The location to search.
5435
5136
  * @returns {Scope} The innermost scope.
5436
- */ function getInnermostScope(initialScope, node) {
5137
+ */
5138
+ function getInnermostScope(initialScope, node) {
5437
5139
  const location = node.range[0];
5140
+
5438
5141
  let scope = initialScope;
5439
5142
  let found = false;
5440
5143
  do {
5441
5144
  found = false;
5442
- for (const childScope of scope.childScopes){
5145
+ for (const childScope of scope.childScopes) {
5443
5146
  const range = childScope.block.range;
5147
+
5444
5148
  if (range[0] <= location && location < range[1]) {
5445
5149
  scope = childScope;
5446
5150
  found = true;
5447
- break;
5151
+ break
5448
5152
  }
5449
5153
  }
5450
- }while (found)
5451
- return scope;
5154
+ } while (found)
5155
+
5156
+ return scope
5452
5157
  }
5158
+
5453
5159
  /**
5454
5160
  * Find the variable of a given name.
5455
5161
  * @param {Scope} initialScope The scope to start finding.
5456
5162
  * @param {string|Node} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node.
5457
5163
  * @returns {Variable|null} The found variable or null.
5458
- */ function findVariable(initialScope, nameOrNode) {
5164
+ */
5165
+ function findVariable(initialScope, nameOrNode) {
5459
5166
  let name = "";
5460
5167
  let scope = initialScope;
5168
+
5461
5169
  if (typeof nameOrNode === "string") {
5462
5170
  name = nameOrNode;
5463
5171
  } else {
5464
5172
  name = nameOrNode.name;
5465
5173
  scope = getInnermostScope(scope, nameOrNode);
5466
5174
  }
5467
- while(scope != null){
5175
+
5176
+ while (scope != null) {
5468
5177
  const variable = scope.set.get(name);
5469
5178
  if (variable != null) {
5470
- return variable;
5179
+ return variable
5471
5180
  }
5472
5181
  scope = scope.upper;
5473
5182
  }
5474
- return null;
5183
+
5184
+ return null
5475
5185
  }
5186
+
5476
5187
  /**
5477
5188
  * Negate the result of `this` calling.
5478
5189
  * @param {Token} token The token to check.
5479
5190
  * @returns {boolean} `true` if the result of `this(token)` is `false`.
5480
- */ function negate0(token) {
5191
+ */
5192
+ function negate0(token) {
5481
5193
  return !this(token) //eslint-disable-line no-invalid-this
5482
- ;
5483
5194
  }
5195
+
5484
5196
  /**
5485
5197
  * Creates the negate function of the given function.
5486
5198
  * @param {function(Token):boolean} f - The function to negate.
5487
5199
  * @returns {function(Token):boolean} Negated function.
5488
- */ function negate(f) {
5489
- return negate0.bind(f);
5200
+ */
5201
+ function negate(f) {
5202
+ return negate0.bind(f)
5490
5203
  }
5204
+
5491
5205
  /**
5492
5206
  * Checks if the given token is a PunctuatorToken with the given value
5493
5207
  * @param {Token} token - The token to check.
5494
5208
  * @param {string} value - The value to check.
5495
5209
  * @returns {boolean} `true` if the token is a PunctuatorToken with the given value.
5496
- */ function isPunctuatorTokenWithValue(token, value) {
5497
- return token.type === "Punctuator" && token.value === value;
5210
+ */
5211
+ function isPunctuatorTokenWithValue(token, value) {
5212
+ return token.type === "Punctuator" && token.value === value
5498
5213
  }
5214
+
5499
5215
  /**
5500
5216
  * Checks if the given token is an arrow token or not.
5501
5217
  * @param {Token} token - The token to check.
5502
5218
  * @returns {boolean} `true` if the token is an arrow token.
5503
- */ function isArrowToken(token) {
5504
- return isPunctuatorTokenWithValue(token, "=>");
5219
+ */
5220
+ function isArrowToken(token) {
5221
+ return isPunctuatorTokenWithValue(token, "=>")
5505
5222
  }
5223
+
5506
5224
  /**
5507
5225
  * Checks if the given token is a comma token or not.
5508
5226
  * @param {Token} token - The token to check.
5509
5227
  * @returns {boolean} `true` if the token is a comma token.
5510
- */ function isCommaToken(token) {
5511
- return isPunctuatorTokenWithValue(token, ",");
5228
+ */
5229
+ function isCommaToken(token) {
5230
+ return isPunctuatorTokenWithValue(token, ",")
5512
5231
  }
5232
+
5513
5233
  /**
5514
5234
  * Checks if the given token is a semicolon token or not.
5515
5235
  * @param {Token} token - The token to check.
5516
5236
  * @returns {boolean} `true` if the token is a semicolon token.
5517
- */ function isSemicolonToken(token) {
5518
- return isPunctuatorTokenWithValue(token, ";");
5237
+ */
5238
+ function isSemicolonToken(token) {
5239
+ return isPunctuatorTokenWithValue(token, ";")
5519
5240
  }
5241
+
5520
5242
  /**
5521
5243
  * Checks if the given token is a colon token or not.
5522
5244
  * @param {Token} token - The token to check.
5523
5245
  * @returns {boolean} `true` if the token is a colon token.
5524
- */ function isColonToken(token) {
5525
- return isPunctuatorTokenWithValue(token, ":");
5246
+ */
5247
+ function isColonToken(token) {
5248
+ return isPunctuatorTokenWithValue(token, ":")
5526
5249
  }
5250
+
5527
5251
  /**
5528
5252
  * Checks if the given token is an opening parenthesis token or not.
5529
5253
  * @param {Token} token - The token to check.
5530
5254
  * @returns {boolean} `true` if the token is an opening parenthesis token.
5531
- */ function isOpeningParenToken(token) {
5532
- return isPunctuatorTokenWithValue(token, "(");
5255
+ */
5256
+ function isOpeningParenToken(token) {
5257
+ return isPunctuatorTokenWithValue(token, "(")
5533
5258
  }
5259
+
5534
5260
  /**
5535
5261
  * Checks if the given token is a closing parenthesis token or not.
5536
5262
  * @param {Token} token - The token to check.
5537
5263
  * @returns {boolean} `true` if the token is a closing parenthesis token.
5538
- */ function isClosingParenToken(token) {
5539
- return isPunctuatorTokenWithValue(token, ")");
5264
+ */
5265
+ function isClosingParenToken(token) {
5266
+ return isPunctuatorTokenWithValue(token, ")")
5540
5267
  }
5268
+
5541
5269
  /**
5542
5270
  * Checks if the given token is an opening square bracket token or not.
5543
5271
  * @param {Token} token - The token to check.
5544
5272
  * @returns {boolean} `true` if the token is an opening square bracket token.
5545
- */ function isOpeningBracketToken(token) {
5546
- return isPunctuatorTokenWithValue(token, "[");
5273
+ */
5274
+ function isOpeningBracketToken(token) {
5275
+ return isPunctuatorTokenWithValue(token, "[")
5547
5276
  }
5277
+
5548
5278
  /**
5549
5279
  * Checks if the given token is a closing square bracket token or not.
5550
5280
  * @param {Token} token - The token to check.
5551
5281
  * @returns {boolean} `true` if the token is a closing square bracket token.
5552
- */ function isClosingBracketToken(token) {
5553
- return isPunctuatorTokenWithValue(token, "]");
5282
+ */
5283
+ function isClosingBracketToken(token) {
5284
+ return isPunctuatorTokenWithValue(token, "]")
5554
5285
  }
5286
+
5555
5287
  /**
5556
5288
  * Checks if the given token is an opening brace token or not.
5557
5289
  * @param {Token} token - The token to check.
5558
5290
  * @returns {boolean} `true` if the token is an opening brace token.
5559
- */ function isOpeningBraceToken(token) {
5560
- return isPunctuatorTokenWithValue(token, "{");
5291
+ */
5292
+ function isOpeningBraceToken(token) {
5293
+ return isPunctuatorTokenWithValue(token, "{")
5561
5294
  }
5295
+
5562
5296
  /**
5563
5297
  * Checks if the given token is a closing brace token or not.
5564
5298
  * @param {Token} token - The token to check.
5565
5299
  * @returns {boolean} `true` if the token is a closing brace token.
5566
- */ function isClosingBraceToken(token) {
5567
- return isPunctuatorTokenWithValue(token, "}");
5300
+ */
5301
+ function isClosingBraceToken(token) {
5302
+ return isPunctuatorTokenWithValue(token, "}")
5568
5303
  }
5304
+
5569
5305
  /**
5570
5306
  * Checks if the given token is a comment token or not.
5571
5307
  * @param {Token} token - The token to check.
5572
5308
  * @returns {boolean} `true` if the token is a comment token.
5573
- */ function isCommentToken(token) {
5574
- return [
5575
- "Block",
5576
- "Line",
5577
- "Shebang"
5578
- ].includes(token.type);
5309
+ */
5310
+ function isCommentToken(token) {
5311
+ return ["Block", "Line", "Shebang"].includes(token.type)
5579
5312
  }
5313
+
5580
5314
  negate(isArrowToken);
5581
5315
  negate(isCommaToken);
5582
5316
  negate(isSemicolonToken);
@@ -5588,163 +5322,180 @@ negate(isClosingBracketToken);
5588
5322
  negate(isOpeningBraceToken);
5589
5323
  negate(isClosingBraceToken);
5590
5324
  negate(isCommentToken);
5591
- /* globals globalThis, global, self, window */ const globalObject = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
5592
- const builtinNames = Object.freeze(new Set([
5593
- "Array",
5594
- "ArrayBuffer",
5595
- "BigInt",
5596
- "BigInt64Array",
5597
- "BigUint64Array",
5598
- "Boolean",
5599
- "DataView",
5600
- "Date",
5601
- "decodeURI",
5602
- "decodeURIComponent",
5603
- "encodeURI",
5604
- "encodeURIComponent",
5605
- "escape",
5606
- "Float32Array",
5607
- "Float64Array",
5608
- "Function",
5609
- "Infinity",
5610
- "Int16Array",
5611
- "Int32Array",
5612
- "Int8Array",
5613
- "isFinite",
5614
- "isNaN",
5615
- "isPrototypeOf",
5616
- "JSON",
5617
- "Map",
5618
- "Math",
5619
- "NaN",
5620
- "Number",
5621
- "Object",
5622
- "parseFloat",
5623
- "parseInt",
5624
- "Promise",
5625
- "Proxy",
5626
- "Reflect",
5627
- "RegExp",
5628
- "Set",
5629
- "String",
5630
- "Symbol",
5631
- "Uint16Array",
5632
- "Uint32Array",
5633
- "Uint8Array",
5634
- "Uint8ClampedArray",
5635
- "undefined",
5636
- "unescape",
5637
- "WeakMap",
5638
- "WeakSet"
5639
- ]));
5640
- const callAllowed = new Set([
5641
- Array.isArray,
5642
- Array.of,
5643
- Array.prototype.at,
5644
- Array.prototype.concat,
5645
- Array.prototype.entries,
5646
- Array.prototype.every,
5647
- Array.prototype.filter,
5648
- Array.prototype.find,
5649
- Array.prototype.findIndex,
5650
- Array.prototype.flat,
5651
- Array.prototype.includes,
5652
- Array.prototype.indexOf,
5653
- Array.prototype.join,
5654
- Array.prototype.keys,
5655
- Array.prototype.lastIndexOf,
5656
- Array.prototype.slice,
5657
- Array.prototype.some,
5658
- Array.prototype.toString,
5659
- Array.prototype.values,
5660
- typeof BigInt === "function" ? BigInt : undefined,
5661
- Boolean,
5662
- Date,
5663
- Date.parse,
5664
- decodeURI,
5665
- decodeURIComponent,
5666
- encodeURI,
5667
- encodeURIComponent,
5668
- escape,
5669
- isFinite,
5670
- isNaN,
5671
- isPrototypeOf,
5672
- Map,
5673
- Map.prototype.entries,
5674
- Map.prototype.get,
5675
- Map.prototype.has,
5676
- Map.prototype.keys,
5677
- Map.prototype.values,
5678
- ...Object.getOwnPropertyNames(Math).filter((k)=>k !== "random").map((k)=>Math[k]).filter((f)=>typeof f === "function"),
5679
- Number,
5680
- Number.isFinite,
5681
- Number.isNaN,
5682
- Number.parseFloat,
5683
- Number.parseInt,
5684
- Number.prototype.toExponential,
5685
- Number.prototype.toFixed,
5686
- Number.prototype.toPrecision,
5687
- Number.prototype.toString,
5688
- Object,
5689
- Object.entries,
5690
- Object.is,
5691
- Object.isExtensible,
5692
- Object.isFrozen,
5693
- Object.isSealed,
5694
- Object.keys,
5695
- Object.values,
5696
- parseFloat,
5697
- parseInt,
5698
- RegExp,
5699
- Set,
5700
- Set.prototype.entries,
5701
- Set.prototype.has,
5702
- Set.prototype.keys,
5703
- Set.prototype.values,
5704
- String,
5705
- String.fromCharCode,
5706
- String.fromCodePoint,
5707
- String.raw,
5708
- String.prototype.at,
5709
- String.prototype.charAt,
5710
- String.prototype.charCodeAt,
5711
- String.prototype.codePointAt,
5712
- String.prototype.concat,
5713
- String.prototype.endsWith,
5714
- String.prototype.includes,
5715
- String.prototype.indexOf,
5716
- String.prototype.lastIndexOf,
5717
- String.prototype.normalize,
5718
- String.prototype.padEnd,
5719
- String.prototype.padStart,
5720
- String.prototype.slice,
5721
- String.prototype.startsWith,
5722
- String.prototype.substr,
5723
- String.prototype.substring,
5724
- String.prototype.toLowerCase,
5725
- String.prototype.toString,
5726
- String.prototype.toUpperCase,
5727
- String.prototype.trim,
5728
- String.prototype.trimEnd,
5729
- String.prototype.trimLeft,
5730
- String.prototype.trimRight,
5731
- String.prototype.trimStart,
5732
- Symbol.for,
5733
- Symbol.keyFor,
5734
- unescape
5735
- ].filter((f)=>typeof f === "function"));
5325
+
5326
+ /* globals globalThis, global, self, window */
5327
+
5328
+ const globalObject =
5329
+ typeof globalThis !== "undefined"
5330
+ ? globalThis
5331
+ : typeof self !== "undefined"
5332
+ ? self
5333
+ : typeof window !== "undefined"
5334
+ ? window
5335
+ : typeof global !== "undefined"
5336
+ ? global
5337
+ : {};
5338
+
5339
+ const builtinNames = Object.freeze(
5340
+ new Set([
5341
+ "Array",
5342
+ "ArrayBuffer",
5343
+ "BigInt",
5344
+ "BigInt64Array",
5345
+ "BigUint64Array",
5346
+ "Boolean",
5347
+ "DataView",
5348
+ "Date",
5349
+ "decodeURI",
5350
+ "decodeURIComponent",
5351
+ "encodeURI",
5352
+ "encodeURIComponent",
5353
+ "escape",
5354
+ "Float32Array",
5355
+ "Float64Array",
5356
+ "Function",
5357
+ "Infinity",
5358
+ "Int16Array",
5359
+ "Int32Array",
5360
+ "Int8Array",
5361
+ "isFinite",
5362
+ "isNaN",
5363
+ "isPrototypeOf",
5364
+ "JSON",
5365
+ "Map",
5366
+ "Math",
5367
+ "NaN",
5368
+ "Number",
5369
+ "Object",
5370
+ "parseFloat",
5371
+ "parseInt",
5372
+ "Promise",
5373
+ "Proxy",
5374
+ "Reflect",
5375
+ "RegExp",
5376
+ "Set",
5377
+ "String",
5378
+ "Symbol",
5379
+ "Uint16Array",
5380
+ "Uint32Array",
5381
+ "Uint8Array",
5382
+ "Uint8ClampedArray",
5383
+ "undefined",
5384
+ "unescape",
5385
+ "WeakMap",
5386
+ "WeakSet",
5387
+ ]),
5388
+ );
5389
+ const callAllowed = new Set(
5390
+ [
5391
+ Array.isArray,
5392
+ Array.of,
5393
+ Array.prototype.at,
5394
+ Array.prototype.concat,
5395
+ Array.prototype.entries,
5396
+ Array.prototype.every,
5397
+ Array.prototype.filter,
5398
+ Array.prototype.find,
5399
+ Array.prototype.findIndex,
5400
+ Array.prototype.flat,
5401
+ Array.prototype.includes,
5402
+ Array.prototype.indexOf,
5403
+ Array.prototype.join,
5404
+ Array.prototype.keys,
5405
+ Array.prototype.lastIndexOf,
5406
+ Array.prototype.slice,
5407
+ Array.prototype.some,
5408
+ Array.prototype.toString,
5409
+ Array.prototype.values,
5410
+ typeof BigInt === "function" ? BigInt : undefined,
5411
+ Boolean,
5412
+ Date,
5413
+ Date.parse,
5414
+ decodeURI,
5415
+ decodeURIComponent,
5416
+ encodeURI,
5417
+ encodeURIComponent,
5418
+ escape,
5419
+ isFinite,
5420
+ isNaN,
5421
+ isPrototypeOf,
5422
+ Map,
5423
+ Map.prototype.entries,
5424
+ Map.prototype.get,
5425
+ Map.prototype.has,
5426
+ Map.prototype.keys,
5427
+ Map.prototype.values,
5428
+ ...Object.getOwnPropertyNames(Math)
5429
+ .filter((k) => k !== "random")
5430
+ .map((k) => Math[k])
5431
+ .filter((f) => typeof f === "function"),
5432
+ Number,
5433
+ Number.isFinite,
5434
+ Number.isNaN,
5435
+ Number.parseFloat,
5436
+ Number.parseInt,
5437
+ Number.prototype.toExponential,
5438
+ Number.prototype.toFixed,
5439
+ Number.prototype.toPrecision,
5440
+ Number.prototype.toString,
5441
+ Object,
5442
+ Object.entries,
5443
+ Object.is,
5444
+ Object.isExtensible,
5445
+ Object.isFrozen,
5446
+ Object.isSealed,
5447
+ Object.keys,
5448
+ Object.values,
5449
+ parseFloat,
5450
+ parseInt,
5451
+ RegExp,
5452
+ Set,
5453
+ Set.prototype.entries,
5454
+ Set.prototype.has,
5455
+ Set.prototype.keys,
5456
+ Set.prototype.values,
5457
+ String,
5458
+ String.fromCharCode,
5459
+ String.fromCodePoint,
5460
+ String.raw,
5461
+ String.prototype.at,
5462
+ String.prototype.charAt,
5463
+ String.prototype.charCodeAt,
5464
+ String.prototype.codePointAt,
5465
+ String.prototype.concat,
5466
+ String.prototype.endsWith,
5467
+ String.prototype.includes,
5468
+ String.prototype.indexOf,
5469
+ String.prototype.lastIndexOf,
5470
+ String.prototype.normalize,
5471
+ String.prototype.padEnd,
5472
+ String.prototype.padStart,
5473
+ String.prototype.slice,
5474
+ String.prototype.startsWith,
5475
+ String.prototype.substr,
5476
+ String.prototype.substring,
5477
+ String.prototype.toLowerCase,
5478
+ String.prototype.toString,
5479
+ String.prototype.toUpperCase,
5480
+ String.prototype.trim,
5481
+ String.prototype.trimEnd,
5482
+ String.prototype.trimLeft,
5483
+ String.prototype.trimRight,
5484
+ String.prototype.trimStart,
5485
+ Symbol.for,
5486
+ Symbol.keyFor,
5487
+ unescape,
5488
+ ].filter((f) => typeof f === "function"),
5489
+ );
5736
5490
  const callPassThrough = new Set([
5737
5491
  Object.freeze,
5738
5492
  Object.preventExtensions,
5739
- Object.seal
5493
+ Object.seal,
5740
5494
  ]);
5741
- /** @type {ReadonlyArray<readonly [Function, ReadonlySet<string>]>} */ const getterAllowed = [
5742
- [
5743
- Map,
5744
- new Set([
5745
- "size"
5746
- ])
5747
- ],
5495
+
5496
+ /** @type {ReadonlyArray<readonly [Function, ReadonlySet<string>]>} */
5497
+ const getterAllowed = [
5498
+ [Map, new Set(["size"])],
5748
5499
  [
5749
5500
  RegExp,
5750
5501
  new Set([
@@ -5756,218 +5507,190 @@ const callPassThrough = new Set([
5756
5507
  "multiline",
5757
5508
  "source",
5758
5509
  "sticky",
5759
- "unicode"
5760
- ])
5510
+ "unicode",
5511
+ ]),
5761
5512
  ],
5762
- [
5763
- Set,
5764
- new Set([
5765
- "size"
5766
- ])
5767
- ]
5513
+ [Set, new Set(["size"])],
5768
5514
  ];
5515
+
5769
5516
  /**
5770
5517
  * Get the property descriptor.
5771
5518
  * @param {object} object The object to get.
5772
5519
  * @param {string|number|symbol} name The property name to get.
5773
- */ function getPropertyDescriptor(object, name) {
5520
+ */
5521
+ function getPropertyDescriptor(object, name) {
5774
5522
  let x = object;
5775
- while((typeof x === "object" || typeof x === "function") && x !== null){
5523
+ while ((typeof x === "object" || typeof x === "function") && x !== null) {
5776
5524
  const d = Object.getOwnPropertyDescriptor(x, name);
5777
5525
  if (d) {
5778
- return d;
5526
+ return d
5779
5527
  }
5780
5528
  x = Object.getPrototypeOf(x);
5781
5529
  }
5782
- return null;
5530
+ return null
5783
5531
  }
5532
+
5784
5533
  /**
5785
5534
  * Check if a property is getter or not.
5786
5535
  * @param {object} object The object to check.
5787
5536
  * @param {string|number|symbol} name The property name to check.
5788
- */ function isGetter(object, name) {
5537
+ */
5538
+ function isGetter(object, name) {
5789
5539
  const d = getPropertyDescriptor(object, name);
5790
- return d != null && d.get != null;
5540
+ return d != null && d.get != null
5791
5541
  }
5542
+
5792
5543
  /**
5793
5544
  * Get the element values of a given node list.
5794
5545
  * @param {Node[]} nodeList The node list to get values.
5795
5546
  * @param {Scope|undefined} initialScope The initial scope to find variables.
5796
5547
  * @returns {any[]|null} The value list if all nodes are constant. Otherwise, null.
5797
- */ function getElementValues(nodeList, initialScope) {
5548
+ */
5549
+ function getElementValues(nodeList, initialScope) {
5798
5550
  const valueList = [];
5799
- for(let i = 0; i < nodeList.length; ++i){
5551
+
5552
+ for (let i = 0; i < nodeList.length; ++i) {
5800
5553
  const elementNode = nodeList[i];
5554
+
5801
5555
  if (elementNode == null) {
5802
5556
  valueList.length = i + 1;
5803
5557
  } else if (elementNode.type === "SpreadElement") {
5804
5558
  const argument = getStaticValueR(elementNode.argument, initialScope);
5805
5559
  if (argument == null) {
5806
- return null;
5560
+ return null
5807
5561
  }
5808
5562
  valueList.push(...argument.value);
5809
5563
  } else {
5810
5564
  const element = getStaticValueR(elementNode, initialScope);
5811
5565
  if (element == null) {
5812
- return null;
5566
+ return null
5813
5567
  }
5814
5568
  valueList.push(element.value);
5815
5569
  }
5816
5570
  }
5817
- return valueList;
5571
+
5572
+ return valueList
5818
5573
  }
5574
+
5819
5575
  /**
5820
5576
  * Returns whether the given variable is never written to after initialization.
5821
5577
  * @param {import("eslint").Scope.Variable} variable
5822
5578
  * @returns {boolean}
5823
- */ function isEffectivelyConst(variable) {
5579
+ */
5580
+ function isEffectivelyConst(variable) {
5824
5581
  const refs = variable.references;
5825
- const inits = refs.filter((r)=>r.init).length;
5826
- const reads = refs.filter((r)=>r.isReadOnly()).length;
5582
+
5583
+ const inits = refs.filter((r) => r.init).length;
5584
+ const reads = refs.filter((r) => r.isReadOnly()).length;
5827
5585
  if (inits === 1 && reads + inits === refs.length) {
5828
5586
  // there is only one init and all other references only read
5829
- return true;
5587
+ return true
5830
5588
  }
5831
- return false;
5589
+ return false
5832
5590
  }
5591
+
5833
5592
  const operations = Object.freeze({
5834
- ArrayExpression (node, initialScope) {
5593
+ ArrayExpression(node, initialScope) {
5835
5594
  const elements = getElementValues(node.elements, initialScope);
5836
- return elements != null ? {
5837
- value: elements
5838
- } : null;
5595
+ return elements != null ? { value: elements } : null
5839
5596
  },
5840
- AssignmentExpression (node, initialScope) {
5597
+
5598
+ AssignmentExpression(node, initialScope) {
5841
5599
  if (node.operator === "=") {
5842
- return getStaticValueR(node.right, initialScope);
5600
+ return getStaticValueR(node.right, initialScope)
5843
5601
  }
5844
- return null;
5602
+ return null
5845
5603
  },
5604
+
5846
5605
  //eslint-disable-next-line complexity
5847
- BinaryExpression (node, initialScope) {
5606
+ BinaryExpression(node, initialScope) {
5848
5607
  if (node.operator === "in" || node.operator === "instanceof") {
5849
5608
  // Not supported.
5850
- return null;
5609
+ return null
5851
5610
  }
5611
+
5852
5612
  const left = getStaticValueR(node.left, initialScope);
5853
5613
  const right = getStaticValueR(node.right, initialScope);
5854
5614
  if (left != null && right != null) {
5855
- switch(node.operator){
5615
+ switch (node.operator) {
5856
5616
  case "==":
5857
- return {
5858
- value: left.value == right.value
5859
- } //eslint-disable-line eqeqeq
5860
- ;
5617
+ return { value: left.value == right.value } //eslint-disable-line eqeqeq
5861
5618
  case "!=":
5862
- return {
5863
- value: left.value != right.value
5864
- } //eslint-disable-line eqeqeq
5865
- ;
5619
+ return { value: left.value != right.value } //eslint-disable-line eqeqeq
5866
5620
  case "===":
5867
- return {
5868
- value: left.value === right.value
5869
- };
5621
+ return { value: left.value === right.value }
5870
5622
  case "!==":
5871
- return {
5872
- value: left.value !== right.value
5873
- };
5623
+ return { value: left.value !== right.value }
5874
5624
  case "<":
5875
- return {
5876
- value: left.value < right.value
5877
- };
5625
+ return { value: left.value < right.value }
5878
5626
  case "<=":
5879
- return {
5880
- value: left.value <= right.value
5881
- };
5627
+ return { value: left.value <= right.value }
5882
5628
  case ">":
5883
- return {
5884
- value: left.value > right.value
5885
- };
5629
+ return { value: left.value > right.value }
5886
5630
  case ">=":
5887
- return {
5888
- value: left.value >= right.value
5889
- };
5631
+ return { value: left.value >= right.value }
5890
5632
  case "<<":
5891
- return {
5892
- value: left.value << right.value
5893
- };
5633
+ return { value: left.value << right.value }
5894
5634
  case ">>":
5895
- return {
5896
- value: left.value >> right.value
5897
- };
5635
+ return { value: left.value >> right.value }
5898
5636
  case ">>>":
5899
- return {
5900
- value: left.value >>> right.value
5901
- };
5637
+ return { value: left.value >>> right.value }
5902
5638
  case "+":
5903
- return {
5904
- value: left.value + right.value
5905
- };
5639
+ return { value: left.value + right.value }
5906
5640
  case "-":
5907
- return {
5908
- value: left.value - right.value
5909
- };
5641
+ return { value: left.value - right.value }
5910
5642
  case "*":
5911
- return {
5912
- value: left.value * right.value
5913
- };
5643
+ return { value: left.value * right.value }
5914
5644
  case "/":
5915
- return {
5916
- value: left.value / right.value
5917
- };
5645
+ return { value: left.value / right.value }
5918
5646
  case "%":
5919
- return {
5920
- value: left.value % right.value
5921
- };
5647
+ return { value: left.value % right.value }
5922
5648
  case "**":
5923
- return {
5924
- value: left.value ** right.value
5925
- };
5649
+ return { value: left.value ** right.value }
5926
5650
  case "|":
5927
- return {
5928
- value: left.value | right.value
5929
- };
5651
+ return { value: left.value | right.value }
5930
5652
  case "^":
5931
- return {
5932
- value: left.value ^ right.value
5933
- };
5653
+ return { value: left.value ^ right.value }
5934
5654
  case "&":
5935
- return {
5936
- value: left.value & right.value
5937
- };
5655
+ return { value: left.value & right.value }
5656
+
5657
+ // no default
5938
5658
  }
5939
5659
  }
5940
- return null;
5660
+
5661
+ return null
5941
5662
  },
5942
- CallExpression (node, initialScope) {
5663
+
5664
+ CallExpression(node, initialScope) {
5943
5665
  const calleeNode = node.callee;
5944
5666
  const args = getElementValues(node.arguments, initialScope);
5667
+
5945
5668
  if (args != null) {
5946
5669
  if (calleeNode.type === "MemberExpression") {
5947
5670
  if (calleeNode.property.type === "PrivateIdentifier") {
5948
- return null;
5671
+ return null
5949
5672
  }
5950
5673
  const object = getStaticValueR(calleeNode.object, initialScope);
5951
5674
  if (object != null) {
5952
- if (object.value == null && (object.optional || node.optional)) {
5953
- return {
5954
- value: undefined,
5955
- optional: true
5956
- };
5675
+ if (
5676
+ object.value == null &&
5677
+ (object.optional || node.optional)
5678
+ ) {
5679
+ return { value: undefined, optional: true }
5957
5680
  }
5958
- const property = getStaticPropertyNameValue(calleeNode, initialScope);
5681
+ const property = getStaticPropertyNameValue(
5682
+ calleeNode,
5683
+ initialScope,
5684
+ );
5685
+
5959
5686
  if (property != null) {
5960
5687
  const receiver = object.value;
5961
5688
  const methodName = property.value;
5962
5689
  if (callAllowed.has(receiver[methodName])) {
5963
- return {
5964
- value: receiver[methodName](...args)
5965
- };
5690
+ return { value: receiver[methodName](...args) }
5966
5691
  }
5967
5692
  if (callPassThrough.has(receiver[methodName])) {
5968
- return {
5969
- value: args[0]
5970
- };
5693
+ return { value: args[0] }
5971
5694
  }
5972
5695
  }
5973
5696
  }
@@ -5975,409 +5698,815 @@ const operations = Object.freeze({
5975
5698
  const callee = getStaticValueR(calleeNode, initialScope);
5976
5699
  if (callee != null) {
5977
5700
  if (callee.value == null && node.optional) {
5978
- return {
5979
- value: undefined,
5980
- optional: true
5981
- };
5701
+ return { value: undefined, optional: true }
5982
5702
  }
5983
5703
  const func = callee.value;
5984
5704
  if (callAllowed.has(func)) {
5985
- return {
5986
- value: func(...args)
5987
- };
5705
+ return { value: func(...args) }
5988
5706
  }
5989
5707
  if (callPassThrough.has(func)) {
5990
- return {
5991
- value: args[0]
5992
- };
5708
+ return { value: args[0] }
5993
5709
  }
5994
5710
  }
5995
5711
  }
5996
5712
  }
5997
- return null;
5713
+
5714
+ return null
5998
5715
  },
5999
- ConditionalExpression (node, initialScope) {
5716
+
5717
+ ConditionalExpression(node, initialScope) {
6000
5718
  const test = getStaticValueR(node.test, initialScope);
6001
5719
  if (test != null) {
6002
- return test.value ? getStaticValueR(node.consequent, initialScope) : getStaticValueR(node.alternate, initialScope);
5720
+ return test.value
5721
+ ? getStaticValueR(node.consequent, initialScope)
5722
+ : getStaticValueR(node.alternate, initialScope)
6003
5723
  }
6004
- return null;
5724
+ return null
6005
5725
  },
6006
- ExpressionStatement (node, initialScope) {
6007
- return getStaticValueR(node.expression, initialScope);
5726
+
5727
+ ExpressionStatement(node, initialScope) {
5728
+ return getStaticValueR(node.expression, initialScope)
6008
5729
  },
6009
- Identifier (node, initialScope) {
5730
+
5731
+ Identifier(node, initialScope) {
6010
5732
  if (initialScope != null) {
6011
5733
  const variable = findVariable(initialScope, node);
5734
+
6012
5735
  // Built-in globals.
6013
- if (variable != null && variable.defs.length === 0 && builtinNames.has(variable.name) && variable.name in globalObject) {
6014
- return {
6015
- value: globalObject[variable.name]
6016
- };
5736
+ if (
5737
+ variable != null &&
5738
+ variable.defs.length === 0 &&
5739
+ builtinNames.has(variable.name) &&
5740
+ variable.name in globalObject
5741
+ ) {
5742
+ return { value: globalObject[variable.name] }
6017
5743
  }
5744
+
6018
5745
  // Constants.
6019
5746
  if (variable != null && variable.defs.length === 1) {
6020
5747
  const def = variable.defs[0];
6021
- if (def.parent && def.type === "Variable" && (def.parent.kind === "const" || isEffectivelyConst(variable)) && // TODO(mysticatea): don't support destructuring here.
6022
- def.node.id.type === "Identifier") {
6023
- return getStaticValueR(def.node.init, initialScope);
5748
+ if (
5749
+ def.parent &&
5750
+ def.type === "Variable" &&
5751
+ (def.parent.kind === "const" ||
5752
+ isEffectivelyConst(variable)) &&
5753
+ // TODO(mysticatea): don't support destructuring here.
5754
+ def.node.id.type === "Identifier"
5755
+ ) {
5756
+ return getStaticValueR(def.node.init, initialScope)
6024
5757
  }
6025
5758
  }
6026
5759
  }
6027
- return null;
5760
+ return null
6028
5761
  },
6029
- Literal (node) {
5762
+
5763
+ Literal(node) {
6030
5764
  //istanbul ignore if : this is implementation-specific behavior.
6031
5765
  if ((node.regex != null || node.bigint != null) && node.value == null) {
6032
5766
  // It was a RegExp/BigInt literal, but Node.js didn't support it.
6033
- return null;
5767
+ return null
6034
5768
  }
6035
- return {
6036
- value: node.value
6037
- };
5769
+ return { value: node.value }
6038
5770
  },
6039
- LogicalExpression (node, initialScope) {
5771
+
5772
+ LogicalExpression(node, initialScope) {
6040
5773
  const left = getStaticValueR(node.left, initialScope);
6041
5774
  if (left != null) {
6042
- if (node.operator === "||" && Boolean(left.value) === true || node.operator === "&&" && Boolean(left.value) === false || node.operator === "??" && left.value != null) {
6043
- return left;
5775
+ if (
5776
+ (node.operator === "||" && Boolean(left.value) === true) ||
5777
+ (node.operator === "&&" && Boolean(left.value) === false) ||
5778
+ (node.operator === "??" && left.value != null)
5779
+ ) {
5780
+ return left
6044
5781
  }
5782
+
6045
5783
  const right = getStaticValueR(node.right, initialScope);
6046
5784
  if (right != null) {
6047
- return right;
5785
+ return right
6048
5786
  }
6049
5787
  }
6050
- return null;
5788
+
5789
+ return null
6051
5790
  },
6052
- MemberExpression (node, initialScope) {
5791
+
5792
+ MemberExpression(node, initialScope) {
6053
5793
  if (node.property.type === "PrivateIdentifier") {
6054
- return null;
5794
+ return null
6055
5795
  }
6056
5796
  const object = getStaticValueR(node.object, initialScope);
6057
5797
  if (object != null) {
6058
5798
  if (object.value == null && (object.optional || node.optional)) {
6059
- return {
6060
- value: undefined,
6061
- optional: true
6062
- };
5799
+ return { value: undefined, optional: true }
6063
5800
  }
6064
5801
  const property = getStaticPropertyNameValue(node, initialScope);
5802
+
6065
5803
  if (property != null) {
6066
5804
  if (!isGetter(object.value, property.value)) {
6067
- return {
6068
- value: object.value[property.value]
6069
- };
5805
+ return { value: object.value[property.value] }
6070
5806
  }
6071
- for (const [classFn, allowed] of getterAllowed){
6072
- if (object.value instanceof classFn && allowed.has(property.value)) {
6073
- return {
6074
- value: object.value[property.value]
6075
- };
5807
+
5808
+ for (const [classFn, allowed] of getterAllowed) {
5809
+ if (
5810
+ object.value instanceof classFn &&
5811
+ allowed.has(property.value)
5812
+ ) {
5813
+ return { value: object.value[property.value] }
6076
5814
  }
6077
5815
  }
6078
5816
  }
6079
5817
  }
6080
- return null;
5818
+ return null
6081
5819
  },
6082
- ChainExpression (node, initialScope) {
5820
+
5821
+ ChainExpression(node, initialScope) {
6083
5822
  const expression = getStaticValueR(node.expression, initialScope);
6084
5823
  if (expression != null) {
6085
- return {
6086
- value: expression.value
6087
- };
5824
+ return { value: expression.value }
6088
5825
  }
6089
- return null;
5826
+ return null
6090
5827
  },
6091
- NewExpression (node, initialScope) {
5828
+
5829
+ NewExpression(node, initialScope) {
6092
5830
  const callee = getStaticValueR(node.callee, initialScope);
6093
5831
  const args = getElementValues(node.arguments, initialScope);
5832
+
6094
5833
  if (callee != null && args != null) {
6095
5834
  const Func = callee.value;
6096
5835
  if (callAllowed.has(Func)) {
6097
- return {
6098
- value: new Func(...args)
6099
- };
5836
+ return { value: new Func(...args) }
6100
5837
  }
6101
5838
  }
6102
- return null;
5839
+
5840
+ return null
6103
5841
  },
6104
- ObjectExpression (node, initialScope) {
5842
+
5843
+ ObjectExpression(node, initialScope) {
6105
5844
  const object = {};
6106
- for (const propertyNode of node.properties){
5845
+
5846
+ for (const propertyNode of node.properties) {
6107
5847
  if (propertyNode.type === "Property") {
6108
5848
  if (propertyNode.kind !== "init") {
6109
- return null;
5849
+ return null
6110
5850
  }
6111
- const key = getStaticPropertyNameValue(propertyNode, initialScope);
5851
+ const key = getStaticPropertyNameValue(
5852
+ propertyNode,
5853
+ initialScope,
5854
+ );
6112
5855
  const value = getStaticValueR(propertyNode.value, initialScope);
6113
5856
  if (key == null || value == null) {
6114
- return null;
5857
+ return null
6115
5858
  }
6116
5859
  object[key.value] = value.value;
6117
- } else if (propertyNode.type === "SpreadElement" || propertyNode.type === "ExperimentalSpreadProperty") {
6118
- const argument = getStaticValueR(propertyNode.argument, initialScope);
5860
+ } else if (
5861
+ propertyNode.type === "SpreadElement" ||
5862
+ propertyNode.type === "ExperimentalSpreadProperty"
5863
+ ) {
5864
+ const argument = getStaticValueR(
5865
+ propertyNode.argument,
5866
+ initialScope,
5867
+ );
6119
5868
  if (argument == null) {
6120
- return null;
5869
+ return null
6121
5870
  }
6122
5871
  Object.assign(object, argument.value);
6123
5872
  } else {
6124
- return null;
5873
+ return null
6125
5874
  }
6126
5875
  }
6127
- return {
6128
- value: object
6129
- };
5876
+
5877
+ return { value: object }
6130
5878
  },
6131
- SequenceExpression (node, initialScope) {
5879
+
5880
+ SequenceExpression(node, initialScope) {
6132
5881
  const last = node.expressions[node.expressions.length - 1];
6133
- return getStaticValueR(last, initialScope);
5882
+ return getStaticValueR(last, initialScope)
6134
5883
  },
6135
- TaggedTemplateExpression (node, initialScope) {
5884
+
5885
+ TaggedTemplateExpression(node, initialScope) {
6136
5886
  const tag = getStaticValueR(node.tag, initialScope);
6137
- const expressions = getElementValues(node.quasi.expressions, initialScope);
5887
+ const expressions = getElementValues(
5888
+ node.quasi.expressions,
5889
+ initialScope,
5890
+ );
5891
+
6138
5892
  if (tag != null && expressions != null) {
6139
5893
  const func = tag.value;
6140
- const strings = node.quasi.quasis.map((q)=>q.value.cooked);
6141
- strings.raw = node.quasi.quasis.map((q)=>q.value.raw);
5894
+ const strings = node.quasi.quasis.map((q) => q.value.cooked);
5895
+ strings.raw = node.quasi.quasis.map((q) => q.value.raw);
5896
+
6142
5897
  if (func === String.raw) {
6143
- return {
6144
- value: func(strings, ...expressions)
6145
- };
5898
+ return { value: func(strings, ...expressions) }
6146
5899
  }
6147
5900
  }
6148
- return null;
5901
+
5902
+ return null
6149
5903
  },
6150
- TemplateLiteral (node, initialScope) {
5904
+
5905
+ TemplateLiteral(node, initialScope) {
6151
5906
  const expressions = getElementValues(node.expressions, initialScope);
6152
5907
  if (expressions != null) {
6153
5908
  let value = node.quasis[0].value.cooked;
6154
- for(let i = 0; i < expressions.length; ++i){
5909
+ for (let i = 0; i < expressions.length; ++i) {
6155
5910
  value += expressions[i];
6156
5911
  value += node.quasis[i + 1].value.cooked;
6157
5912
  }
6158
- return {
6159
- value
6160
- };
5913
+ return { value }
6161
5914
  }
6162
- return null;
5915
+ return null
6163
5916
  },
6164
- UnaryExpression (node, initialScope) {
5917
+
5918
+ UnaryExpression(node, initialScope) {
6165
5919
  if (node.operator === "delete") {
6166
5920
  // Not supported.
6167
- return null;
5921
+ return null
6168
5922
  }
6169
5923
  if (node.operator === "void") {
6170
- return {
6171
- value: undefined
6172
- };
5924
+ return { value: undefined }
6173
5925
  }
5926
+
6174
5927
  const arg = getStaticValueR(node.argument, initialScope);
6175
5928
  if (arg != null) {
6176
- switch(node.operator){
5929
+ switch (node.operator) {
6177
5930
  case "-":
6178
- return {
6179
- value: -arg.value
6180
- };
5931
+ return { value: -arg.value }
6181
5932
  case "+":
6182
- return {
6183
- value: +arg.value
6184
- } //eslint-disable-line no-implicit-coercion
6185
- ;
5933
+ return { value: +arg.value } //eslint-disable-line no-implicit-coercion
6186
5934
  case "!":
6187
- return {
6188
- value: !arg.value
6189
- };
5935
+ return { value: !arg.value }
6190
5936
  case "~":
6191
- return {
6192
- value: ~arg.value
6193
- };
5937
+ return { value: ~arg.value }
6194
5938
  case "typeof":
6195
- return {
6196
- value: typeof arg.value
6197
- };
5939
+ return { value: typeof arg.value }
5940
+
5941
+ // no default
6198
5942
  }
6199
5943
  }
6200
- return null;
6201
- }
5944
+
5945
+ return null
5946
+ },
6202
5947
  });
5948
+
6203
5949
  /**
6204
5950
  * Get the value of a given node if it's a static value.
6205
5951
  * @param {Node} node The node to get.
6206
5952
  * @param {Scope|undefined} initialScope The scope to start finding variable.
6207
5953
  * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`.
6208
- */ function getStaticValueR(node, initialScope) {
5954
+ */
5955
+ function getStaticValueR(node, initialScope) {
6209
5956
  if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
6210
- return operations[node.type](node, initialScope);
5957
+ return operations[node.type](node, initialScope)
6211
5958
  }
6212
- return null;
5959
+ return null
6213
5960
  }
5961
+
6214
5962
  /**
6215
5963
  * Get the static value of property name from a MemberExpression node or a Property node.
6216
5964
  * @param {Node} node The node to get.
6217
5965
  * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
6218
5966
  * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the property name of the node, or `null`.
6219
- */ function getStaticPropertyNameValue(node, initialScope) {
5967
+ */
5968
+ function getStaticPropertyNameValue(node, initialScope) {
6220
5969
  const nameNode = node.type === "Property" ? node.key : node.property;
5970
+
6221
5971
  if (node.computed) {
6222
- return getStaticValueR(nameNode, initialScope);
5972
+ return getStaticValueR(nameNode, initialScope)
6223
5973
  }
5974
+
6224
5975
  if (nameNode.type === "Identifier") {
6225
- return {
6226
- value: nameNode.name
6227
- };
5976
+ return { value: nameNode.name }
6228
5977
  }
5978
+
6229
5979
  if (nameNode.type === "Literal") {
6230
5980
  if (nameNode.bigint) {
6231
- return {
6232
- value: nameNode.bigint
6233
- };
5981
+ return { value: nameNode.bigint }
6234
5982
  }
6235
- return {
6236
- value: String(nameNode.value)
6237
- };
5983
+ return { value: String(nameNode.value) }
6238
5984
  }
6239
- return null;
5985
+
5986
+ return null
6240
5987
  }
5988
+
6241
5989
  /**
6242
5990
  * Get the value of a given node if it's a static value.
6243
5991
  * @param {Node} node The node to get.
6244
5992
  * @param {Scope} [initialScope] The scope to start finding variable. Optional. If this scope was given, this tries to resolve identifier references which are in the given node as much as possible.
6245
5993
  * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`.
6246
- */ function getStaticValue$1(node, initialScope = null) {
5994
+ */
5995
+ function getStaticValue$1(node, initialScope = null) {
6247
5996
  try {
6248
- return getStaticValueR(node, initialScope);
5997
+ return getStaticValueR(node, initialScope)
6249
5998
  } catch (_error) {
6250
- return null;
5999
+ return null
6251
6000
  }
6252
6001
  }
6253
- const typeConversionBinaryOps = Object.freeze(new Set([
6254
- "==",
6255
- "!=",
6256
- "<",
6257
- "<=",
6258
- ">",
6259
- ">=",
6260
- "<<",
6261
- ">>",
6262
- ">>>",
6263
- "+",
6264
- "-",
6265
- "*",
6266
- "/",
6267
- "%",
6268
- "|",
6269
- "^",
6270
- "&",
6271
- "in"
6272
- ]));
6273
- const typeConversionUnaryOps = Object.freeze(new Set([
6274
- "-",
6275
- "+",
6276
- "!",
6277
- "~"
6278
- ]));
6002
+
6003
+ const typeConversionBinaryOps = Object.freeze(
6004
+ new Set([
6005
+ "==",
6006
+ "!=",
6007
+ "<",
6008
+ "<=",
6009
+ ">",
6010
+ ">=",
6011
+ "<<",
6012
+ ">>",
6013
+ ">>>",
6014
+ "+",
6015
+ "-",
6016
+ "*",
6017
+ "/",
6018
+ "%",
6019
+ "|",
6020
+ "^",
6021
+ "&",
6022
+ "in",
6023
+ ]),
6024
+ );
6025
+ const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"]));
6026
+
6279
6027
  /**
6280
6028
  * Check whether the given value is an ASTNode or not.
6281
6029
  * @param {any} x The value to check.
6282
6030
  * @returns {boolean} `true` if the value is an ASTNode.
6283
- */ function isNode(x) {
6284
- return x !== null && typeof x === "object" && typeof x.type === "string";
6031
+ */
6032
+ function isNode(x) {
6033
+ return x !== null && typeof x === "object" && typeof x.type === "string"
6285
6034
  }
6286
- Object.freeze(Object.assign(Object.create(null), {
6287
- $visit (node, options, visitorKeys) {
6288
- const { type } = node;
6289
- if (typeof this[type] === "function") {
6290
- return this[type](node, options, visitorKeys);
6291
- }
6292
- return this.$visitChildren(node, options, visitorKeys);
6293
- },
6294
- $visitChildren (node, options, visitorKeys) {
6295
- const { type } = node;
6296
- for (const key of visitorKeys[type] || getKeys(node)){
6297
- const value = node[key];
6298
- if (Array.isArray(value)) {
6299
- for (const element of value){
6300
- if (isNode(element) && this.$visit(element, options, visitorKeys)) {
6301
- return true;
6035
+
6036
+ Object.freeze(
6037
+ Object.assign(Object.create(null), {
6038
+ $visit(node, options, visitorKeys) {
6039
+ const { type } = node;
6040
+
6041
+ if (typeof this[type] === "function") {
6042
+ return this[type](node, options, visitorKeys)
6043
+ }
6044
+
6045
+ return this.$visitChildren(node, options, visitorKeys)
6046
+ },
6047
+
6048
+ $visitChildren(node, options, visitorKeys) {
6049
+ const { type } = node;
6050
+
6051
+ for (const key of visitorKeys[type] || getKeys(node)) {
6052
+ const value = node[key];
6053
+
6054
+ if (Array.isArray(value)) {
6055
+ for (const element of value) {
6056
+ if (
6057
+ isNode(element) &&
6058
+ this.$visit(element, options, visitorKeys)
6059
+ ) {
6060
+ return true
6061
+ }
6302
6062
  }
6063
+ } else if (
6064
+ isNode(value) &&
6065
+ this.$visit(value, options, visitorKeys)
6066
+ ) {
6067
+ return true
6303
6068
  }
6304
- } else if (isNode(value) && this.$visit(value, options, visitorKeys)) {
6305
- return true;
6306
6069
  }
6070
+
6071
+ return false
6072
+ },
6073
+
6074
+ ArrowFunctionExpression() {
6075
+ return false
6076
+ },
6077
+ AssignmentExpression() {
6078
+ return true
6079
+ },
6080
+ AwaitExpression() {
6081
+ return true
6082
+ },
6083
+ BinaryExpression(node, options, visitorKeys) {
6084
+ if (
6085
+ options.considerImplicitTypeConversion &&
6086
+ typeConversionBinaryOps.has(node.operator) &&
6087
+ (node.left.type !== "Literal" || node.right.type !== "Literal")
6088
+ ) {
6089
+ return true
6090
+ }
6091
+ return this.$visitChildren(node, options, visitorKeys)
6092
+ },
6093
+ CallExpression() {
6094
+ return true
6095
+ },
6096
+ FunctionExpression() {
6097
+ return false
6098
+ },
6099
+ ImportExpression() {
6100
+ return true
6101
+ },
6102
+ MemberExpression(node, options, visitorKeys) {
6103
+ if (options.considerGetters) {
6104
+ return true
6105
+ }
6106
+ if (
6107
+ options.considerImplicitTypeConversion &&
6108
+ node.computed &&
6109
+ node.property.type !== "Literal"
6110
+ ) {
6111
+ return true
6112
+ }
6113
+ return this.$visitChildren(node, options, visitorKeys)
6114
+ },
6115
+ MethodDefinition(node, options, visitorKeys) {
6116
+ if (
6117
+ options.considerImplicitTypeConversion &&
6118
+ node.computed &&
6119
+ node.key.type !== "Literal"
6120
+ ) {
6121
+ return true
6122
+ }
6123
+ return this.$visitChildren(node, options, visitorKeys)
6124
+ },
6125
+ NewExpression() {
6126
+ return true
6127
+ },
6128
+ Property(node, options, visitorKeys) {
6129
+ if (
6130
+ options.considerImplicitTypeConversion &&
6131
+ node.computed &&
6132
+ node.key.type !== "Literal"
6133
+ ) {
6134
+ return true
6135
+ }
6136
+ return this.$visitChildren(node, options, visitorKeys)
6137
+ },
6138
+ PropertyDefinition(node, options, visitorKeys) {
6139
+ if (
6140
+ options.considerImplicitTypeConversion &&
6141
+ node.computed &&
6142
+ node.key.type !== "Literal"
6143
+ ) {
6144
+ return true
6145
+ }
6146
+ return this.$visitChildren(node, options, visitorKeys)
6147
+ },
6148
+ UnaryExpression(node, options, visitorKeys) {
6149
+ if (node.operator === "delete") {
6150
+ return true
6151
+ }
6152
+ if (
6153
+ options.considerImplicitTypeConversion &&
6154
+ typeConversionUnaryOps.has(node.operator) &&
6155
+ node.argument.type !== "Literal"
6156
+ ) {
6157
+ return true
6158
+ }
6159
+ return this.$visitChildren(node, options, visitorKeys)
6160
+ },
6161
+ UpdateExpression() {
6162
+ return true
6163
+ },
6164
+ YieldExpression() {
6165
+ return true
6166
+ },
6167
+ }),
6168
+ );
6169
+ Function.call.bind(Object.hasOwnProperty);
6170
+
6171
+ /**
6172
+ * Tests if a value is a `string`.
6173
+ *
6174
+ * @param input - The value to test.
6175
+ *
6176
+ * @example
6177
+ * import { isString } from "effect/Predicate"
6178
+ *
6179
+ * assert.deepStrictEqual(isString("a"), true)
6180
+ *
6181
+ * assert.deepStrictEqual(isString(1), false)
6182
+ *
6183
+ * @category guards
6184
+ * @since 2.0.0
6185
+ */ const isString$1 = (input)=>typeof input === "string";
6186
+ 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)=>{
6187
+ if (i$1(n)) {
6188
+ const e = n[t$1](), { matched: r, selections: i } = e.match(o);
6189
+ return r && i && Object.keys(i).forEach((t)=>c(t, i[t])), r;
6190
+ }
6191
+ if (r$1(n)) {
6192
+ if (!r$1(o)) return !1;
6193
+ if (Array.isArray(n)) {
6194
+ if (!Array.isArray(o)) return !1;
6195
+ let t = [], r = [], a = [];
6196
+ for (const s of n.keys()){
6197
+ const o = n[s];
6198
+ i$1(o) && o[e$1] ? a.push(o) : a.length ? r.push(o) : t.push(o);
6199
+ }
6200
+ if (a.length) {
6201
+ if (a.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
6202
+ if (o.length < t.length + r.length) return !1;
6203
+ 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);
6204
+ return t.every((t, n)=>s$1(t, e[n], c)) && r.every((t, e)=>s$1(t, n[e], c)) && (0 === a.length || s$1(a[0], i, c));
6205
+ }
6206
+ return n.length === o.length && n.every((t, e)=>s$1(t, o[e], c));
6307
6207
  }
6308
- return false;
6309
- },
6310
- ArrowFunctionExpression () {
6311
- return false;
6312
- },
6313
- AssignmentExpression () {
6314
- return true;
6315
- },
6316
- AwaitExpression () {
6317
- return true;
6318
- },
6319
- BinaryExpression (node, options, visitorKeys) {
6320
- if (options.considerImplicitTypeConversion && typeConversionBinaryOps.has(node.operator) && (node.left.type !== "Literal" || node.right.type !== "Literal")) {
6321
- return true;
6322
- }
6323
- return this.$visitChildren(node, options, visitorKeys);
6324
- },
6325
- CallExpression () {
6326
- return true;
6327
- },
6328
- FunctionExpression () {
6329
- return false;
6330
- },
6331
- ImportExpression () {
6332
- return true;
6333
- },
6334
- MemberExpression (node, options, visitorKeys) {
6335
- if (options.considerGetters) {
6336
- return true;
6337
- }
6338
- if (options.considerImplicitTypeConversion && node.computed && node.property.type !== "Literal") {
6339
- return true;
6340
- }
6341
- return this.$visitChildren(node, options, visitorKeys);
6342
- },
6343
- MethodDefinition (node, options, visitorKeys) {
6344
- if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
6345
- return true;
6346
- }
6347
- return this.$visitChildren(node, options, visitorKeys);
6348
- },
6349
- NewExpression () {
6350
- return true;
6351
- },
6352
- Property (node, options, visitorKeys) {
6353
- if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
6354
- return true;
6355
- }
6356
- return this.$visitChildren(node, options, visitorKeys);
6357
- },
6358
- PropertyDefinition (node, options, visitorKeys) {
6359
- if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
6360
- return true;
6361
- }
6362
- return this.$visitChildren(node, options, visitorKeys);
6363
- },
6364
- UnaryExpression (node, options, visitorKeys) {
6365
- if (node.operator === "delete") {
6366
- return true;
6367
- }
6368
- if (options.considerImplicitTypeConversion && typeConversionUnaryOps.has(node.operator) && node.argument.type !== "Literal") {
6369
- return true;
6370
- }
6371
- return this.$visitChildren(node, options, visitorKeys);
6372
- },
6373
- UpdateExpression () {
6374
- return true;
6375
- },
6376
- YieldExpression () {
6377
- return true;
6208
+ return Object.keys(n).every((e)=>{
6209
+ const r = n[e];
6210
+ return (e in o || i$1(a = r) && "optional" === a[t$1]().matcherType) && s$1(r, o[e], c);
6211
+ var a;
6212
+ });
6378
6213
  }
6214
+ return Object.is(o, n);
6215
+ }, o$1 = (e)=>{
6216
+ var n, s, a;
6217
+ return r$1(e) ? i$1(e) ? null != (n = null == (s = (a = e[t$1]()).getSelectionKeys) ? void 0 : s.call(a)) ? n : [] : Array.isArray(e) ? c$1(e, o$1) : c$1(Object.values(e), o$1) : [];
6218
+ }, c$1 = (t, e)=>t.reduce((t, n)=>t.concat(e(n)), []);
6219
+ function u$1(t) {
6220
+ return Object.assign(t, {
6221
+ optional: ()=>l$1(t),
6222
+ and: (e)=>m$1(t, e),
6223
+ or: (e)=>y$1(t, e),
6224
+ select: (e)=>void 0 === e ? p$1(t) : p$1(e, t)
6225
+ });
6226
+ }
6227
+ function l$1(e) {
6228
+ return u$1({
6229
+ [t$1]: ()=>({
6230
+ match: (t)=>{
6231
+ let n = {};
6232
+ const r = (t, e)=>{
6233
+ n[t] = e;
6234
+ };
6235
+ return void 0 === t ? (o$1(e).forEach((t)=>r(t, void 0)), {
6236
+ matched: !0,
6237
+ selections: n
6238
+ }) : {
6239
+ matched: s$1(e, t, r),
6240
+ selections: n
6241
+ };
6242
+ },
6243
+ getSelectionKeys: ()=>o$1(e),
6244
+ matcherType: "optional"
6245
+ })
6246
+ });
6247
+ }
6248
+ function m$1(...e) {
6249
+ return u$1({
6250
+ [t$1]: ()=>({
6251
+ match: (t)=>{
6252
+ let n = {};
6253
+ const r = (t, e)=>{
6254
+ n[t] = e;
6255
+ };
6256
+ return {
6257
+ matched: e.every((e)=>s$1(e, t, r)),
6258
+ selections: n
6259
+ };
6260
+ },
6261
+ getSelectionKeys: ()=>c$1(e, o$1),
6262
+ matcherType: "and"
6263
+ })
6264
+ });
6265
+ }
6266
+ function y$1(...e) {
6267
+ return u$1({
6268
+ [t$1]: ()=>({
6269
+ match: (t)=>{
6270
+ let n = {};
6271
+ const r = (t, e)=>{
6272
+ n[t] = e;
6273
+ };
6274
+ return c$1(e, o$1).forEach((t)=>r(t, void 0)), {
6275
+ matched: e.some((e)=>s$1(e, t, r)),
6276
+ selections: n
6277
+ };
6278
+ },
6279
+ getSelectionKeys: ()=>c$1(e, o$1),
6280
+ matcherType: "or"
6281
+ })
6282
+ });
6283
+ }
6284
+ function d$1(e) {
6285
+ return {
6286
+ [t$1]: ()=>({
6287
+ match: (t)=>({
6288
+ matched: Boolean(e(t))
6289
+ })
6290
+ })
6291
+ };
6292
+ }
6293
+ function p$1(...e) {
6294
+ const r = "string" == typeof e[0] ? e[0] : void 0, i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
6295
+ return u$1({
6296
+ [t$1]: ()=>({
6297
+ match: (t)=>{
6298
+ let e = {
6299
+ [null != r ? r : n$1]: t
6300
+ };
6301
+ return {
6302
+ matched: void 0 === i || s$1(i, t, (t, n)=>{
6303
+ e[t] = n;
6304
+ }),
6305
+ selections: e
6306
+ };
6307
+ },
6308
+ getSelectionKeys: ()=>[
6309
+ null != r ? r : n$1
6310
+ ].concat(void 0 === i ? [] : o$1(i))
6311
+ })
6312
+ });
6313
+ }
6314
+ function v$1(t) {
6315
+ return "number" == typeof t;
6316
+ }
6317
+ function b$1(t) {
6318
+ return "string" == typeof t;
6319
+ }
6320
+ function w$1(t) {
6321
+ return "bigint" == typeof t;
6322
+ }
6323
+ u$1(d$1(function(t) {
6324
+ return !0;
6379
6325
  }));
6380
- Function.call.bind(Object.hasOwnProperty);
6326
+ const j$1 = (t)=>Object.assign(u$1(t), {
6327
+ startsWith: (e)=>{
6328
+ return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.startsWith(n)))));
6329
+ var n;
6330
+ },
6331
+ endsWith: (e)=>{
6332
+ return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.endsWith(n)))));
6333
+ var n;
6334
+ },
6335
+ minLength: (e)=>j$1(m$1(t, ((t)=>d$1((e)=>b$1(e) && e.length >= t))(e))),
6336
+ maxLength: (e)=>j$1(m$1(t, ((t)=>d$1((e)=>b$1(e) && e.length <= t))(e))),
6337
+ includes: (e)=>{
6338
+ return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.includes(n)))));
6339
+ var n;
6340
+ },
6341
+ regex: (e)=>{
6342
+ return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && Boolean(t.match(n))))));
6343
+ var n;
6344
+ }
6345
+ });
6346
+ j$1(d$1(b$1));
6347
+ const K$1 = (t)=>Object.assign(u$1(t), {
6348
+ between: (e, n)=>K$1(m$1(t, ((t, e)=>d$1((n)=>v$1(n) && t <= n && e >= n))(e, n))),
6349
+ lt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e < t))(e))),
6350
+ gt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e > t))(e))),
6351
+ lte: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e <= t))(e))),
6352
+ gte: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e >= t))(e))),
6353
+ int: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isInteger(t)))),
6354
+ finite: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isFinite(t)))),
6355
+ positive: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t > 0))),
6356
+ negative: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t < 0)))
6357
+ });
6358
+ K$1(d$1(v$1));
6359
+ const x$1 = (t)=>Object.assign(u$1(t), {
6360
+ between: (e, n)=>x$1(m$1(t, ((t, e)=>d$1((n)=>w$1(n) && t <= n && e >= n))(e, n))),
6361
+ lt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e < t))(e))),
6362
+ gt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e > t))(e))),
6363
+ lte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e <= t))(e))),
6364
+ gte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e >= t))(e))),
6365
+ positive: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t > 0))),
6366
+ negative: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t < 0)))
6367
+ });
6368
+ x$1(d$1(w$1));
6369
+ u$1(d$1(function(t) {
6370
+ return "boolean" == typeof t;
6371
+ }));
6372
+ u$1(d$1(function(t) {
6373
+ return "symbol" == typeof t;
6374
+ }));
6375
+ u$1(d$1(function(t) {
6376
+ return null == t;
6377
+ }));
6378
+ const NodeType = types.AST_NODE_TYPES;
6379
+ const is = utils.ASTUtils.isNodeOfType;
6380
+ const isOneOf = utils.ASTUtils.isNodeOfTypes;
6381
+ isOneOf([
6382
+ NodeType.ArrowFunctionExpression,
6383
+ NodeType.FunctionDeclaration,
6384
+ NodeType.FunctionExpression
6385
+ ]);
6386
+ isOneOf([
6387
+ NodeType.ArrowFunctionExpression,
6388
+ NodeType.FunctionDeclaration,
6389
+ NodeType.FunctionExpression,
6390
+ NodeType.TSCallSignatureDeclaration,
6391
+ NodeType.TSConstructSignatureDeclaration,
6392
+ NodeType.TSDeclareFunction,
6393
+ NodeType.TSEmptyBodyFunctionExpression,
6394
+ NodeType.TSFunctionType,
6395
+ NodeType.TSMethodSignature
6396
+ ]);
6397
+ isOneOf([
6398
+ NodeType.ClassDeclaration,
6399
+ NodeType.ClassExpression
6400
+ ]);
6401
+ isOneOf([
6402
+ NodeType.DoWhileStatement,
6403
+ NodeType.ForInStatement,
6404
+ NodeType.ForOfStatement,
6405
+ NodeType.ForStatement,
6406
+ NodeType.WhileStatement
6407
+ ]);
6408
+ isOneOf([
6409
+ NodeType.TSArrayType,
6410
+ NodeType.TSTupleType
6411
+ ]);
6412
+ isOneOf([
6413
+ NodeType.PropertyDefinition,
6414
+ NodeType.TSIndexSignature,
6415
+ NodeType.TSParameterProperty,
6416
+ NodeType.TSPropertySignature
6417
+ ]);
6418
+ is(NodeType.JSXElement);
6419
+ is(NodeType.JSXFragment);
6420
+ isOneOf([
6421
+ NodeType.JSXAttribute,
6422
+ NodeType.JSXSpreadChild,
6423
+ NodeType.JSXClosingElement,
6424
+ NodeType.JSXClosingFragment,
6425
+ NodeType.JSXElement,
6426
+ NodeType.JSXEmptyExpression,
6427
+ NodeType.JSXExpressionContainer,
6428
+ NodeType.JSXFragment,
6429
+ NodeType.JSXIdentifier,
6430
+ NodeType.JSXMemberExpression,
6431
+ NodeType.JSXNamespacedName,
6432
+ NodeType.JSXOpeningElement,
6433
+ NodeType.JSXOpeningFragment,
6434
+ NodeType.JSXSpreadAttribute,
6435
+ NodeType.JSXSpreadChild,
6436
+ NodeType.JSXText
6437
+ ]);
6438
+ const isJSXTagNameExpression = isOneOf([
6439
+ NodeType.JSXIdentifier,
6440
+ NodeType.JSXMemberExpression,
6441
+ NodeType.JSXNamespacedName
6442
+ ]);
6443
+ isOneOf([
6444
+ NodeType.ArrayPattern,
6445
+ NodeType.AssignmentPattern,
6446
+ NodeType.ObjectPattern,
6447
+ NodeType.RestElement
6448
+ ]);
6449
+ isOneOf([
6450
+ NodeType.TSInterfaceDeclaration,
6451
+ NodeType.TSTypeAliasDeclaration
6452
+ ]);
6453
+ isOneOf([
6454
+ NodeType.ArrayExpression,
6455
+ NodeType.ArrayPattern,
6456
+ NodeType.ArrowFunctionExpression,
6457
+ NodeType.CallExpression,
6458
+ NodeType.ClassExpression,
6459
+ NodeType.FunctionExpression,
6460
+ NodeType.Identifier,
6461
+ NodeType.JSXElement,
6462
+ NodeType.JSXFragment,
6463
+ NodeType.Literal,
6464
+ NodeType.TemplateLiteral,
6465
+ NodeType.MemberExpression,
6466
+ NodeType.MetaProperty,
6467
+ NodeType.ObjectExpression,
6468
+ NodeType.ObjectPattern,
6469
+ NodeType.SequenceExpression,
6470
+ NodeType.Super,
6471
+ NodeType.TaggedTemplateExpression,
6472
+ NodeType.ThisExpression
6473
+ ]);
6474
+ isOneOf([
6475
+ NodeType.ArrayExpression,
6476
+ NodeType.ArrayPattern,
6477
+ NodeType.ArrowFunctionExpression,
6478
+ NodeType.CallExpression,
6479
+ NodeType.ClassExpression,
6480
+ NodeType.FunctionExpression,
6481
+ NodeType.Identifier,
6482
+ NodeType.JSXElement,
6483
+ NodeType.JSXFragment,
6484
+ NodeType.Literal,
6485
+ NodeType.TemplateLiteral,
6486
+ NodeType.MemberExpression,
6487
+ NodeType.MetaProperty,
6488
+ NodeType.ObjectExpression,
6489
+ NodeType.ObjectPattern,
6490
+ NodeType.SequenceExpression,
6491
+ NodeType.Super,
6492
+ NodeType.TaggedTemplateExpression,
6493
+ NodeType.ThisExpression,
6494
+ NodeType.TSAsExpression,
6495
+ NodeType.TSNonNullExpression,
6496
+ NodeType.TSTypeAssertion
6497
+ ]);
6498
+ const Construction = effectData_esm.taggedEnum();
6499
+ Construction.None();
6500
+ [
6501
+ NodeType.JSXElement,
6502
+ NodeType.ArrayExpression,
6503
+ NodeType.ObjectExpression,
6504
+ NodeType.FunctionExpression,
6505
+ NodeType.ArrowFunctionExpression,
6506
+ NodeType.ClassExpression,
6507
+ NodeType.NewExpression,
6508
+ NodeType.CallExpression
6509
+ ];
6381
6510
  /**
6382
6511
  * Get the value of a given node if it can decide the value statically.
6383
6512
  * If the 2nd parameter `initialScope` was given, this function tries to resolve identifier references which are in the
@@ -6498,13 +6627,24 @@ function isStringLiteral(node) {
6498
6627
  */ function findVariableByNameUpToGlobal(name, startScope) {
6499
6628
  return effectFunction_esm.pipe(getVariablesUpToGlobal(startScope), findVariableByName(name));
6500
6629
  }
6630
+ /**
6631
+ * Get the first definition of a variable
6632
+ * @param variable The variable to get the definition from
6633
+ */ function getVariableDefinitionFirst(variable) {
6634
+ return effectOption_esm.fromNullable(variable.defs[0]);
6635
+ }
6501
6636
  /**
6502
6637
  * Get the init node of the nth definition of a variable
6503
- * @param at The index of the definition to get, negative numbers are counted from the end, -1 is the last definition
6504
- */ function getVariableNthDefNodeInit(at) {
6505
- return (variable)=>{
6506
- return effectFunction_esm.pipe(effectOption_esm.some(variable), effectOption_esm.flatMapNullable((v)=>v.defs.at(at)), effectOption_esm.flatMapNullable((d)=>d.node), effectOption_esm.flatMapNullable((n)=>"init" in n ? n.init : null));
6507
- };
6638
+ * @param variable
6639
+ * @param getDefinition A function that returns the nth definition of a variable
6640
+ */ function getVariableInit(variable, getDefinition) {
6641
+ return effectFunction_esm.pipe(effectOption_esm.some(variable), effectOption_esm.flatMap(getDefinition), effectOption_esm.flatMapNullable((d)=>d.node), effectOption_esm.flatMapNullable((n)=>"init" in n ? n.init : null));
6642
+ }
6643
+ /**
6644
+ * Get the init node of the first definition of a variable
6645
+ * @param variable
6646
+ */ function getVariableInitFirst(variable) {
6647
+ return getVariableInit(variable, getVariableDefinitionFirst);
6508
6648
  }
6509
6649
 
6510
6650
  /**
@@ -6563,7 +6703,7 @@ const getPragmaFromContext = memo((context)=>{
6563
6703
  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")));
6564
6704
  });
6565
6705
 
6566
- 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}}
6706
+ 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 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"})})}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}u(d(function(t){return !0}));const 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;}});j(d(b));const 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)))});K(d(v));const 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)))});x(d(w));u(d(function(t){return "boolean"==typeof t}));u(d(function(t){return "symbol"==typeof t}));u(d(function(t){return null==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}}
6567
6707
 
6568
6708
  function isPropertyOfPragma(name, context, pragma = getPragmaFromContext(context)) {
6569
6709
  const isMatch = a({
@@ -6931,190 +7071,175 @@ function isFragmentWithSingleExpression(node) {
6931
7071
  return children.length === 1 && children[0]?.type === NodeType.JSXExpressionContainer;
6932
7072
  }
6933
7073
 
6934
- const defaultJSXValueCheckOptions = {
6935
- ignoreNull: false,
6936
- strict: false
7074
+ /* eslint-disable perfectionist/sort-objects */ const JSXValueCheckHint = {
7075
+ None: 0n,
7076
+ IgnoreNull: 1n << 0n,
7077
+ IgnoreCreateElement: 1n << 1n,
7078
+ StrictLogical: 1n << 2n,
7079
+ StrictConditional: 1n << 3n
6937
7080
  };
6938
- /**
7081
+ /* eslint-enable perfectionist/sort-objects */ /**
6939
7082
  * Check if a node is a JSX value
6940
7083
  * @param node The AST node to check
6941
7084
  * @param context The rule context
6942
- * @param options The `JSXValueCheckOptions` to use
7085
+ * @param hint The `JSXValueCheckHint` to use
6943
7086
  * @returns boolean
6944
- */ function isJSXValue(node, context, options = defaultJSXValueCheckOptions) {
7087
+ */ function isJSXValue(node, context, hint = JSXValueCheckHint.None) {
6945
7088
  if (!node) {
6946
7089
  return false;
6947
7090
  }
6948
- // TODO: implement strict mode
6949
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
6950
- const { ignoreNull = false, strict = false } = options;
6951
- return N(node.type).with(NodeType.JSXElement, effectFunction_esm.constTrue).with(NodeType.JSXFragment, effectFunction_esm.constTrue).with(NodeType.Literal, ()=>{
6952
- if (!("value" in node) || ignoreNull) {
7091
+ return N(node).with({
7092
+ type: NodeType.JSXElement
7093
+ }, effectFunction_esm.constTrue).with({
7094
+ type: NodeType.JSXFragment
7095
+ }, effectFunction_esm.constTrue).with({
7096
+ type: NodeType.Literal
7097
+ }, (node)=>{
7098
+ if (!("value" in node) || hint & JSXValueCheckHint.IgnoreNull) {
6953
7099
  return false;
6954
7100
  }
6955
7101
  return node.value === null;
6956
- }).with(NodeType.ConditionalExpression, ()=>{
7102
+ }).with({
7103
+ type: NodeType.ConditionalExpression
7104
+ }, (node)=>{
6957
7105
  if (!("consequent" in node)) {
6958
7106
  return false;
6959
7107
  }
6960
- const leftHasJSX = N(node.consequent).with(_.array(), (n)=>n.some((n)=>isJSXValue(n, context, options))).with(_.any, (n)=>isJSXValue(n, context, options)).exhaustive();
6961
- if (leftHasJSX) {
6962
- return true;
7108
+ function leftHasJSX(node) {
7109
+ if (!("consequent" in node)) {
7110
+ return false;
7111
+ }
7112
+ if (Array.isArray(node.consequent)) {
7113
+ return node.consequent.some((n)=>isJSXValue(n, context, hint));
7114
+ }
7115
+ return isJSXValue(node.consequent, context, hint);
7116
+ }
7117
+ function rightHasJSX(node) {
7118
+ return "alternate" in node && isJSXValue(node.alternate, context, hint);
6963
7119
  }
6964
- return "alternate" in node && isJSXValue(node.alternate, context, options);
6965
- }).with(NodeType.LogicalExpression, ()=>{
7120
+ if (hint & JSXValueCheckHint.StrictConditional) {
7121
+ return leftHasJSX(node) && rightHasJSX(node);
7122
+ }
7123
+ return leftHasJSX(node) || rightHasJSX(node);
7124
+ }).with({
7125
+ type: NodeType.LogicalExpression
7126
+ }, (node)=>{
6966
7127
  if (!("left" in node)) {
6967
7128
  return false;
6968
7129
  }
6969
- return isJSXValue(node.left, context, options) || isJSXValue(node.right, context, options);
6970
- }).with(NodeType.SequenceExpression, ()=>{
7130
+ return isJSXValue(node.left, context, hint) || isJSXValue(node.right, context, hint);
7131
+ }).with({
7132
+ type: NodeType.SequenceExpression
7133
+ }, (node)=>{
6971
7134
  if (!("expressions" in node)) {
6972
7135
  return false;
6973
7136
  }
6974
7137
  const exp = node.expressions.at(-1);
6975
- return isJSXValue(exp, context, options);
6976
- }).with(NodeType.CallExpression, ()=>isCreateElementCall(node, context)).with(NodeType.Identifier, ()=>{
7138
+ return isJSXValue(exp, context, hint);
7139
+ }).with({
7140
+ type: NodeType.CallExpression
7141
+ }, (node)=>{
7142
+ if (hint & JSXValueCheckHint.IgnoreCreateElement) {
7143
+ return false;
7144
+ }
7145
+ return isCreateElementCall(node, context);
7146
+ }).with({
7147
+ type: NodeType.Identifier
7148
+ }, (node)=>{
6977
7149
  if (!("name" in node)) {
6978
7150
  return false;
6979
7151
  }
6980
7152
  if (isJSXTagNameExpression(node)) {
6981
7153
  return true;
6982
7154
  }
6983
- if (!isString(node.name) && node.name.type !== NodeType.Identifier) {
6984
- return isJSXTagNameExpression(node.name);
6985
- }
6986
- const name = N(node.name).with(_.string, effectFunction_esm.identity).with({
6987
- type: NodeType.Identifier
6988
- }, (n)=>n.name).exhaustive();
6989
- const variable = findVariableByNameUpToGlobal(name, context.getScope());
6990
- return effectFunction_esm.pipe(variable, effectOption_esm.flatMap(getVariableNthDefNodeInit(0)), effectOption_esm.map(isOneOf([
7155
+ const variable = findVariableByNameUpToGlobal(node.name, context.getScope());
7156
+ return effectFunction_esm.pipe(variable, effectOption_esm.flatMap(getVariableInitFirst), effectOption_esm.filter(isOneOf([
6991
7157
  NodeType.JSXElement,
6992
7158
  NodeType.JSXFragment
6993
- ])), effectOption_esm.getOrElse(effectFunction_esm.constFalse));
6994
- }).otherwise(effectFunction_esm.constFalse);
7159
+ ])), effectOption_esm.isSome);
7160
+ }).with({
7161
+ type: NodeType.JSXMemberExpression
7162
+ }, effectFunction_esm.constTrue).with({
7163
+ type: NodeType.JSXNamespacedName
7164
+ }, effectFunction_esm.constTrue).otherwise(effectFunction_esm.constFalse);
6995
7165
  }
6996
7166
 
6997
7167
  /**
6998
7168
  * Check if function is returning JSX
6999
7169
  * @param node The return statement node to check
7000
7170
  * @param context The rule context
7001
- * @param options The JSX value check options
7171
+ * @param hint The `JSXValueCheckHint` to use
7002
7172
  * @returns boolean
7003
- */ function isFunctionReturningJSXValue(node, context, options) {
7173
+ */ function isFunctionReturningJSXValue(node, context, hint = JSXValueCheckHint.None) {
7004
7174
  if (node.body.type !== NodeType.BlockStatement) {
7005
- return isJSXValue(node.body, context, options);
7175
+ return isJSXValue(node.body, context, hint);
7006
7176
  }
7007
7177
  const statements = getNestedReturnStatements(node.body);
7008
- return statements.some((statement)=>isJSXValue(statement.argument, context, options));
7178
+ return statements.some((statement)=>isJSXValue(statement.argument, context, hint));
7009
7179
  }
7010
7180
 
7011
- /**
7012
- * Check if the given prop name is present in the given attributes
7013
- * @param attributes The attributes to search in
7014
- * @param propName The prop name to search for
7015
- * @param context The rule context
7016
- * @returns `true` if the given prop name is present in the given properties
7017
- */ function hasProp(attributes, propName, context) {
7018
- return effectOption_esm.isSome(findPropInAttributes(attributes, context)(propName));
7019
- }
7020
- /**
7021
- * Check if any of the given prop names are present in the given attributes
7022
- * @param attributes The attributes to search in
7023
- * @param propNames The prop names to search for
7024
- * @param context The rule context
7025
- * @returns `true` if any of the given prop names are present in the given attributes
7026
- */ function hasAnyProp(attributes, propNames, context) {
7027
- return propNames.some((propName)=>hasProp(attributes, propName, context));
7028
- }
7029
- /**
7030
- * Check if all of the given prop names are present in the given attributes
7031
- * @param attributes The attributes to search in
7032
- * @param propNames The prop names to search for
7033
- * @param context The rule context
7034
- * @returns `true` if all of the given prop names are present in the given attributes
7035
- */ function hasEveryProp(attributes, propNames, context) {
7036
- return propNames.every((propName)=>hasProp(attributes, propName, context));
7037
- }
7038
- /**
7039
- * Get the name of a JSX attribute
7040
- * @param node The JSX attribute node
7041
- * @returns string
7042
- */ function getPropName(node) {
7043
- return N(node.name).when(is(NodeType.JSXIdentifier), (n)=>n.name).when(is(NodeType.JSXNamespacedName), (n)=>n.name.name).exhaustive();
7044
- }
7045
- /**
7046
- * Get the name of a JSX attribute with namespace
7047
- * @param node The JSX attribute node
7048
- * @returns string
7049
- */ function getPropNameWithNamespace(node) {
7050
- return N(node.name).when(is(NodeType.JSXIdentifier), (n)=>n.name).when(is(NodeType.JSXNamespacedName), (n)=>`${n.namespace.name}:${n.name.name}`).exhaustive();
7051
- }
7052
- /**
7053
- * Traverses up prop node
7054
- * @param node The AST node to start traversing from
7055
- * @param predicate The predicate to check each node
7056
- * @returns prop node if found
7057
- */ function traverseUpProp(node, predicate = effectFunction_esm.constTrue) {
7058
- const matcher = (node)=>{
7059
- return node.type === NodeType.JSXAttribute && predicate(node);
7060
- };
7061
- return effectOption_esm.fromNullable(traverseUpGuard(node, matcher));
7062
- }
7063
- /**
7064
- * Checks if the node is inside a prop's value
7065
- * @param node The AST node to check
7066
- * @returns `true` if the node is inside a prop's value
7067
- */ function isInsidePropValue(node) {
7068
- if (isStringLiteral(node)) {
7069
- return node.parent.type === NodeType.JSXAttribute;
7070
- }
7071
- return effectOption_esm.isSome(traverseUpProp(node, (n)=>n.value?.type === NodeType.JSXExpressionContainer));
7072
- }
7073
7181
  /**
7074
7182
  * @param properties The properties to search in
7075
7183
  * @param context The rule context
7076
7184
  * @param seenProps The properties that have already been seen
7077
7185
  * @returns A function that searches for a property in the given properties
7078
7186
  */ function findPropInProperties(properties, context, seenProps = []) {
7187
+ const startScope = context.getScope();
7079
7188
  /**
7080
7189
  * Search for a property in the given properties
7081
7190
  * @param propName The name of the property to search for
7082
7191
  * @returns The property if found
7083
7192
  */ return (propName)=>{
7084
7193
  return effectOption_esm.fromNullable(properties.find((prop)=>{
7085
- if (prop.type === NodeType.Property) {
7194
+ return N(prop).when(is(NodeType.Property), (prop)=>{
7086
7195
  return "name" in prop.key && prop.key.name === propName;
7087
- }
7088
- if (prop.type === NodeType.SpreadElement) {
7089
- if (!("argument" in prop && "name" in prop.argument)) {
7090
- return false;
7091
- }
7092
- const { name } = prop.argument;
7093
- const maybeFirstDefNodeInit = effectFunction_esm.pipe(findVariableByNameUpToGlobal(name, context.getScope()), effectOption_esm.flatMap(getVariableNthDefNodeInit(0)));
7094
- if (effectOption_esm.isNone(maybeFirstDefNodeInit)) {
7095
- return false;
7096
- }
7097
- const firstDefNodeInit = maybeFirstDefNodeInit.value;
7098
- if (firstDefNodeInit.type !== NodeType.ObjectExpression) {
7099
- return false;
7100
- }
7101
- if (seenProps.includes(name)) {
7102
- return false;
7103
- }
7104
- return effectOption_esm.isSome(findPropInProperties(firstDefNodeInit.properties, context, [
7105
- ...seenProps,
7106
- name
7107
- ])(propName));
7108
- }
7109
- return false;
7196
+ }).when(is(NodeType.SpreadElement), (prop)=>{
7197
+ return N(prop.argument).when(is(NodeType.Identifier), (argument)=>{
7198
+ const { name } = argument;
7199
+ const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInitFirst);
7200
+ if (effectOption_esm.isNone(maybeInit)) {
7201
+ return false;
7202
+ }
7203
+ const init = maybeInit.value;
7204
+ if (init.type !== NodeType.ObjectExpression) {
7205
+ return false;
7206
+ }
7207
+ if (seenProps.includes(name)) {
7208
+ return false;
7209
+ }
7210
+ return effectOption_esm.isSome(findPropInProperties(init.properties, context, [
7211
+ ...seenProps,
7212
+ name
7213
+ ])(propName));
7214
+ }).when(is(NodeType.ObjectExpression), (argument)=>{
7215
+ return effectOption_esm.isSome(findPropInProperties(argument.properties, context, seenProps)(propName));
7216
+ }).when(is(NodeType.MemberExpression), ()=>{
7217
+ // Not implemented
7218
+ }).when(is(NodeType.CallExpression), ()=>{
7219
+ // Not implemented
7220
+ }).otherwise(effectFunction_esm.constFalse);
7221
+ }).when(is(NodeType.RestElement), ()=>{
7222
+ // Not implemented
7223
+ return false;
7224
+ }).otherwise(effectFunction_esm.constFalse);
7110
7225
  }));
7111
7226
  };
7112
7227
  }
7228
+
7229
+ /**
7230
+ * Get the name of a JSX attribute with namespace
7231
+ * @param node The JSX attribute node
7232
+ * @returns string
7233
+ */ function getPropName(node) {
7234
+ return N(node.name).when(is(NodeType.JSXIdentifier), (n)=>n.name).when(is(NodeType.JSXNamespacedName), (n)=>`${n.namespace.name}:${n.name.name}`).exhaustive();
7235
+ }
7236
+
7113
7237
  /**
7114
7238
  * @param attributes The attributes to search in
7115
7239
  * @param context The rule context
7116
7240
  * @returns A function that searches for a property in the given attributes
7117
7241
  */ function findPropInAttributes(attributes, context) {
7242
+ const startScope = context.getScope();
7118
7243
  /**
7119
7244
  * Search for a property in the given attributes
7120
7245
  * @param propName The name of the property to search for
@@ -7122,22 +7247,36 @@ const defaultJSXValueCheckOptions = {
7122
7247
  */ return (propName)=>{
7123
7248
  return effectOption_esm.fromNullable(attributes.find((attr)=>{
7124
7249
  return N(attr).when(is(NodeType.JSXAttribute), (attr)=>getPropName(attr) === propName).when(is(NodeType.JSXSpreadAttribute), (attr)=>{
7125
- if (!("argument" in attr && "name" in attr.argument)) {
7126
- return false;
7127
- }
7128
- const { name } = attr.argument;
7129
- const maybeFirstDefNodeInit = effectFunction_esm.pipe(findVariableByNameUpToGlobal(name, context.getScope()), effectOption_esm.flatMap(getVariableNthDefNodeInit(0)));
7130
- if (effectOption_esm.isNone(maybeFirstDefNodeInit)) {
7250
+ return N(attr.argument).with({
7251
+ type: NodeType.Identifier
7252
+ }, (argument)=>{
7253
+ const { name } = argument;
7254
+ const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInitFirst);
7255
+ if (effectOption_esm.isNone(maybeInit)) {
7256
+ return false;
7257
+ }
7258
+ const init = maybeInit.value;
7259
+ if (!("properties" in init)) {
7260
+ return false;
7261
+ }
7262
+ return effectOption_esm.isSome(findPropInProperties(init.properties, context)(propName));
7263
+ }).when(is(NodeType.ObjectExpression), (argument)=>{
7264
+ return effectOption_esm.isSome(findPropInProperties(argument.properties, context)(propName));
7265
+ }).when(is(NodeType.MemberExpression), ()=>{
7266
+ // Not implemented
7131
7267
  return false;
7132
- }
7133
- if (!("properties" in maybeFirstDefNodeInit.value)) {
7268
+ }).when(is(NodeType.CallExpression), ()=>{
7269
+ // Not implemented
7134
7270
  return false;
7135
- }
7136
- return effectOption_esm.isSome(findPropInProperties(maybeFirstDefNodeInit.value.properties, context)(propName));
7271
+ }).otherwise(effectFunction_esm.constFalse);
7137
7272
  }).otherwise(effectFunction_esm.constFalse);
7138
7273
  }));
7139
7274
  };
7140
7275
  }
7276
+
7277
+ function getProp(props, propName, context) {
7278
+ return findPropInAttributes(props, context)(propName);
7279
+ }
7141
7280
  /**
7142
7281
  * Gets and resolves the static value of a JSX attribute
7143
7282
  * @param attribute The JSX attribute to get the value of
@@ -7162,14 +7301,65 @@ const defaultJSXValueCheckOptions = {
7162
7301
  return effectOption_esm.some(getStaticValue(argument, scope));
7163
7302
  }
7164
7303
 
7165
- exports.defaultJSXValueCheckOptions = defaultJSXValueCheckOptions;
7304
+ /**
7305
+ * Check if the given prop name is present in the given attributes
7306
+ * @param attributes The attributes to search in
7307
+ * @param propName The prop name to search for
7308
+ * @param context The rule context
7309
+ * @returns `true` if the given prop name is present in the given properties
7310
+ */ function hasProp(attributes, propName, context) {
7311
+ return effectOption_esm.isSome(findPropInAttributes(attributes, context)(propName));
7312
+ }
7313
+ /**
7314
+ * Check if any of the given prop names are present in the given attributes
7315
+ * @param attributes The attributes to search in
7316
+ * @param propNames The prop names to search for
7317
+ * @param context The rule context
7318
+ * @returns `true` if any of the given prop names are present in the given attributes
7319
+ */ function hasAnyProp(attributes, propNames, context) {
7320
+ return propNames.some((propName)=>hasProp(attributes, propName, context));
7321
+ }
7322
+ /**
7323
+ * Check if all of the given prop names are present in the given attributes
7324
+ * @param attributes The attributes to search in
7325
+ * @param propNames The prop names to search for
7326
+ * @param context The rule context
7327
+ * @returns `true` if all of the given prop names are present in the given attributes
7328
+ */ function hasEveryProp(attributes, propNames, context) {
7329
+ return propNames.every((propName)=>hasProp(attributes, propName, context));
7330
+ }
7331
+
7332
+ /**
7333
+ * Traverses up prop node
7334
+ * @param node The AST node to start traversing from
7335
+ * @param predicate The predicate to check each node
7336
+ * @returns prop node if found
7337
+ */ function traverseUpProp(node, predicate = effectFunction_esm.constTrue) {
7338
+ const matcher = (node)=>{
7339
+ return node.type === NodeType.JSXAttribute && predicate(node);
7340
+ };
7341
+ return effectOption_esm.fromNullable(traverseUpGuard(node, matcher));
7342
+ }
7343
+
7344
+ /**
7345
+ * Checks if the node is inside a prop's value
7346
+ * @param node The AST node to check
7347
+ * @returns `true` if the node is inside a prop's value
7348
+ */ function isInsidePropValue(node) {
7349
+ if (isStringLiteral(node)) {
7350
+ return node.parent.type === NodeType.JSXAttribute;
7351
+ }
7352
+ return effectOption_esm.isSome(traverseUpProp(node, (n)=>n.value?.type === NodeType.JSXExpressionContainer));
7353
+ }
7354
+
7355
+ exports.JSXValueCheckHint = JSXValueCheckHint;
7166
7356
  exports.elementType = elementType;
7167
7357
  exports.findPropInAttributes = findPropInAttributes;
7168
7358
  exports.findPropInProperties = findPropInProperties;
7169
7359
  exports.getFragmentFromContext = getFragmentFromContext;
7170
7360
  exports.getPragmaFromContext = getPragmaFromContext;
7361
+ exports.getProp = getProp;
7171
7362
  exports.getPropName = getPropName;
7172
- exports.getPropNameWithNamespace = getPropNameWithNamespace;
7173
7363
  exports.getPropValue = getPropValue;
7174
7364
  exports.hasAnyProp = hasAnyProp;
7175
7365
  exports.hasChildren = hasChildren;