@eslint-react/jsx 0.6.1 → 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.
Files changed (4) hide show
  1. package/dist/index.cjs +1018 -914
  2. package/dist/index.js +1018 -914
  3. package/dist/index.mjs +1018 -914
  4. package/package.json +4 -5
package/dist/index.mjs CHANGED
@@ -4779,350 +4779,14 @@ function isNil(x){
4779
4779
  return x === undefined || x === null
4780
4780
  }
4781
4781
 
4782
- /**
4783
- * Tests if a value is a `string`.
4784
- *
4785
- * @param input - The value to test.
4786
- *
4787
- * @example
4788
- * import { isString } from "effect/Predicate"
4789
- *
4790
- * assert.deepStrictEqual(isString("a"), true)
4791
- *
4792
- * assert.deepStrictEqual(isString(1), false)
4793
- *
4794
- * @category guards
4795
- * @since 2.0.0
4796
- */ const isString$1 = (input)=>typeof input === "string";
4797
- 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)=>{
4798
- if (i$1(n)) {
4799
- const e = n[t$1](), { matched: r, selections: i } = e.match(o);
4800
- return r && i && Object.keys(i).forEach((t)=>c(t, i[t])), r;
4801
- }
4802
- if (r$1(n)) {
4803
- if (!r$1(o)) return !1;
4804
- if (Array.isArray(n)) {
4805
- if (!Array.isArray(o)) return !1;
4806
- let t = [], r = [], a = [];
4807
- for (const s of n.keys()){
4808
- const o = n[s];
4809
- i$1(o) && o[e$1] ? a.push(o) : a.length ? r.push(o) : t.push(o);
4810
- }
4811
- if (a.length) {
4812
- if (a.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
4813
- if (o.length < t.length + r.length) return !1;
4814
- 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);
4815
- 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));
4816
- }
4817
- return n.length === o.length && n.every((t, e)=>s$1(t, o[e], c));
4818
- }
4819
- return Object.keys(n).every((e)=>{
4820
- const r = n[e];
4821
- return (e in o || i$1(a = r) && "optional" === a[t$1]().matcherType) && s$1(r, o[e], c);
4822
- var a;
4823
- });
4824
- }
4825
- return Object.is(o, n);
4826
- }, o$1 = (e)=>{
4827
- var n, s, a;
4828
- 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) : [];
4829
- }, c$1 = (t, e)=>t.reduce((t, n)=>t.concat(e(n)), []);
4830
- function u$1(t) {
4831
- return Object.assign(t, {
4832
- optional: ()=>l$1(t),
4833
- and: (e)=>m$1(t, e),
4834
- or: (e)=>y$1(t, e),
4835
- select: (e)=>void 0 === e ? p$1(t) : p$1(e, t)
4836
- });
4837
- }
4838
- function l$1(e) {
4839
- return u$1({
4840
- [t$1]: ()=>({
4841
- match: (t)=>{
4842
- let n = {};
4843
- const r = (t, e)=>{
4844
- n[t] = e;
4845
- };
4846
- return void 0 === t ? (o$1(e).forEach((t)=>r(t, void 0)), {
4847
- matched: !0,
4848
- selections: n
4849
- }) : {
4850
- matched: s$1(e, t, r),
4851
- selections: n
4852
- };
4853
- },
4854
- getSelectionKeys: ()=>o$1(e),
4855
- matcherType: "optional"
4856
- })
4857
- });
4858
- }
4859
- function m$1(...e) {
4860
- return u$1({
4861
- [t$1]: ()=>({
4862
- match: (t)=>{
4863
- let n = {};
4864
- const r = (t, e)=>{
4865
- n[t] = e;
4866
- };
4867
- return {
4868
- matched: e.every((e)=>s$1(e, t, r)),
4869
- selections: n
4870
- };
4871
- },
4872
- getSelectionKeys: ()=>c$1(e, o$1),
4873
- matcherType: "and"
4874
- })
4875
- });
4876
- }
4877
- function y$1(...e) {
4878
- return u$1({
4879
- [t$1]: ()=>({
4880
- match: (t)=>{
4881
- let n = {};
4882
- const r = (t, e)=>{
4883
- n[t] = e;
4884
- };
4885
- return c$1(e, o$1).forEach((t)=>r(t, void 0)), {
4886
- matched: e.some((e)=>s$1(e, t, r)),
4887
- selections: n
4888
- };
4889
- },
4890
- getSelectionKeys: ()=>c$1(e, o$1),
4891
- matcherType: "or"
4892
- })
4893
- });
4894
- }
4895
- function d$1(e) {
4896
- return {
4897
- [t$1]: ()=>({
4898
- match: (t)=>({
4899
- matched: Boolean(e(t))
4900
- })
4901
- })
4902
- };
4903
- }
4904
- function p$1(...e) {
4905
- const r = "string" == typeof e[0] ? e[0] : void 0, i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
4906
- return u$1({
4907
- [t$1]: ()=>({
4908
- match: (t)=>{
4909
- let e = {
4910
- [null != r ? r : n$1]: t
4911
- };
4912
- return {
4913
- matched: void 0 === i || s$1(i, t, (t, n)=>{
4914
- e[t] = n;
4915
- }),
4916
- selections: e
4917
- };
4918
- },
4919
- getSelectionKeys: ()=>[
4920
- null != r ? r : n$1
4921
- ].concat(void 0 === i ? [] : o$1(i))
4922
- })
4923
- });
4924
- }
4925
- function v$1(t) {
4926
- return "number" == typeof t;
4927
- }
4928
- function b$1(t) {
4929
- return "string" == typeof t;
4930
- }
4931
- function w$1(t) {
4932
- return "bigint" == typeof t;
4933
- }
4934
- u$1(d$1(function(t) {
4935
- return !0;
4936
- }));
4937
- const j$1 = (t)=>Object.assign(u$1(t), {
4938
- startsWith: (e)=>{
4939
- return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.startsWith(n)))));
4940
- var n;
4941
- },
4942
- endsWith: (e)=>{
4943
- return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.endsWith(n)))));
4944
- var n;
4945
- },
4946
- minLength: (e)=>j$1(m$1(t, ((t)=>d$1((e)=>b$1(e) && e.length >= t))(e))),
4947
- maxLength: (e)=>j$1(m$1(t, ((t)=>d$1((e)=>b$1(e) && e.length <= t))(e))),
4948
- includes: (e)=>{
4949
- return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.includes(n)))));
4950
- var n;
4951
- },
4952
- regex: (e)=>{
4953
- return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && Boolean(t.match(n))))));
4954
- var n;
4955
- }
4956
- });
4957
- j$1(d$1(b$1));
4958
- const K$1 = (t)=>Object.assign(u$1(t), {
4959
- between: (e, n)=>K$1(m$1(t, ((t, e)=>d$1((n)=>v$1(n) && t <= n && e >= n))(e, n))),
4960
- lt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e < t))(e))),
4961
- gt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e > t))(e))),
4962
- lte: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e <= t))(e))),
4963
- gte: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e >= t))(e))),
4964
- int: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isInteger(t)))),
4965
- finite: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isFinite(t)))),
4966
- positive: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t > 0))),
4967
- negative: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t < 0)))
4968
- });
4969
- K$1(d$1(v$1));
4970
- const x$1 = (t)=>Object.assign(u$1(t), {
4971
- between: (e, n)=>x$1(m$1(t, ((t, e)=>d$1((n)=>w$1(n) && t <= n && e >= n))(e, n))),
4972
- lt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e < t))(e))),
4973
- gt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e > t))(e))),
4974
- lte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e <= t))(e))),
4975
- gte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e >= t))(e))),
4976
- positive: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t > 0))),
4977
- negative: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t < 0)))
4978
- });
4979
- x$1(d$1(w$1));
4980
- u$1(d$1(function(t) {
4981
- return "boolean" == typeof t;
4982
- }));
4983
- u$1(d$1(function(t) {
4984
- return "symbol" == typeof t;
4985
- }));
4986
- u$1(d$1(function(t) {
4987
- return null == t;
4988
- }));
4989
- const NodeType = AST_NODE_TYPES;
4990
- const is = ASTUtils.isNodeOfType;
4991
- const isOneOf = ASTUtils.isNodeOfTypes;
4992
- isOneOf([
4993
- NodeType.ArrowFunctionExpression,
4994
- NodeType.FunctionDeclaration,
4995
- NodeType.FunctionExpression
4996
- ]);
4997
- isOneOf([
4998
- NodeType.ArrowFunctionExpression,
4999
- NodeType.FunctionDeclaration,
5000
- NodeType.FunctionExpression,
5001
- NodeType.TSCallSignatureDeclaration,
5002
- NodeType.TSConstructSignatureDeclaration,
5003
- NodeType.TSDeclareFunction,
5004
- NodeType.TSEmptyBodyFunctionExpression,
5005
- NodeType.TSFunctionType,
5006
- NodeType.TSMethodSignature
5007
- ]);
5008
- isOneOf([
5009
- NodeType.ClassDeclaration,
5010
- NodeType.ClassExpression
5011
- ]);
5012
- isOneOf([
5013
- NodeType.DoWhileStatement,
5014
- NodeType.ForInStatement,
5015
- NodeType.ForOfStatement,
5016
- NodeType.ForStatement,
5017
- NodeType.WhileStatement
5018
- ]);
5019
- isOneOf([
5020
- NodeType.TSArrayType,
5021
- NodeType.TSTupleType
5022
- ]);
5023
- isOneOf([
5024
- NodeType.PropertyDefinition,
5025
- NodeType.TSIndexSignature,
5026
- NodeType.TSParameterProperty,
5027
- NodeType.TSPropertySignature
5028
- ]);
5029
- is(NodeType.JSXElement);
5030
- is(NodeType.JSXFragment);
5031
- isOneOf([
5032
- NodeType.JSXAttribute,
5033
- NodeType.JSXSpreadChild,
5034
- NodeType.JSXClosingElement,
5035
- NodeType.JSXClosingFragment,
5036
- NodeType.JSXElement,
5037
- NodeType.JSXEmptyExpression,
5038
- NodeType.JSXExpressionContainer,
5039
- NodeType.JSXFragment,
5040
- NodeType.JSXIdentifier,
5041
- NodeType.JSXMemberExpression,
5042
- NodeType.JSXNamespacedName,
5043
- NodeType.JSXOpeningElement,
5044
- NodeType.JSXOpeningFragment,
5045
- NodeType.JSXSpreadAttribute,
5046
- NodeType.JSXSpreadChild,
5047
- NodeType.JSXText
5048
- ]);
5049
- const isJSXTagNameExpression = isOneOf([
5050
- NodeType.JSXIdentifier,
5051
- NodeType.JSXMemberExpression,
5052
- NodeType.JSXNamespacedName
5053
- ]);
5054
- isOneOf([
5055
- NodeType.ArrayPattern,
5056
- NodeType.AssignmentPattern,
5057
- NodeType.ObjectPattern,
5058
- NodeType.RestElement
5059
- ]);
5060
- isOneOf([
5061
- NodeType.TSInterfaceDeclaration,
5062
- NodeType.TSTypeAliasDeclaration
5063
- ]);
5064
- isOneOf([
5065
- NodeType.ArrayExpression,
5066
- NodeType.ArrayPattern,
5067
- NodeType.ArrowFunctionExpression,
5068
- NodeType.CallExpression,
5069
- NodeType.ClassExpression,
5070
- NodeType.FunctionExpression,
5071
- NodeType.Identifier,
5072
- NodeType.JSXElement,
5073
- NodeType.JSXFragment,
5074
- NodeType.Literal,
5075
- NodeType.TemplateLiteral,
5076
- NodeType.MemberExpression,
5077
- NodeType.MetaProperty,
5078
- NodeType.ObjectExpression,
5079
- NodeType.ObjectPattern,
5080
- NodeType.SequenceExpression,
5081
- NodeType.Super,
5082
- NodeType.TaggedTemplateExpression,
5083
- NodeType.ThisExpression
5084
- ]);
5085
- isOneOf([
5086
- NodeType.ArrayExpression,
5087
- NodeType.ArrayPattern,
5088
- NodeType.ArrowFunctionExpression,
5089
- NodeType.CallExpression,
5090
- NodeType.ClassExpression,
5091
- NodeType.FunctionExpression,
5092
- NodeType.Identifier,
5093
- NodeType.JSXElement,
5094
- NodeType.JSXFragment,
5095
- NodeType.Literal,
5096
- NodeType.TemplateLiteral,
5097
- NodeType.MemberExpression,
5098
- NodeType.MetaProperty,
5099
- NodeType.ObjectExpression,
5100
- NodeType.ObjectPattern,
5101
- NodeType.SequenceExpression,
5102
- NodeType.Super,
5103
- NodeType.TaggedTemplateExpression,
5104
- NodeType.ThisExpression,
5105
- NodeType.TSAsExpression,
5106
- NodeType.TSNonNullExpression,
5107
- NodeType.TSTypeAssertion
5108
- ]);
5109
- const Construction = effectData_esm.taggedEnum();
5110
- Construction.None();
5111
- [
5112
- NodeType.JSXElement,
5113
- NodeType.ArrayExpression,
5114
- NodeType.ObjectExpression,
5115
- NodeType.FunctionExpression,
5116
- NodeType.ArrowFunctionExpression,
5117
- NodeType.ClassExpression,
5118
- NodeType.NewExpression,
5119
- NodeType.CallExpression
5120
- ];
5121
4782
  /**
5122
4783
  * @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
5123
- */ /**
4784
+ */
4785
+
4786
+ /**
5124
4787
  * @type {VisitorKeys}
5125
- */ const KEYS = {
4788
+ */
4789
+ const KEYS = {
5126
4790
  ArrayExpression: [
5127
4791
  "elements"
5128
4792
  ],
@@ -5419,187 +5083,232 @@ Construction.None();
5419
5083
  "argument"
5420
5084
  ]
5421
5085
  };
5086
+
5422
5087
  // Types.
5423
5088
  const NODE_TYPES = Object.keys(KEYS);
5089
+
5424
5090
  // Freeze the keys.
5425
- for (const type of NODE_TYPES){
5091
+ for (const type of NODE_TYPES) {
5426
5092
  Object.freeze(KEYS[type]);
5427
5093
  }
5428
5094
  Object.freeze(KEYS);
5095
+
5429
5096
  /**
5430
5097
  * @author Toru Nagashima <https://github.com/mysticatea>
5431
5098
  * See LICENSE file in root directory for full license.
5432
- */ /**
5099
+ */
5100
+
5101
+ /**
5433
5102
  * @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys
5434
- */ // List to ignore keys.
5103
+ */
5104
+
5105
+ // List to ignore keys.
5435
5106
  const KEY_BLACKLIST = new Set([
5436
5107
  "parent",
5437
5108
  "leadingComments",
5438
5109
  "trailingComments"
5439
5110
  ]);
5111
+
5440
5112
  /**
5441
5113
  * Check whether a given key should be used or not.
5442
5114
  * @param {string} key The key to check.
5443
5115
  * @returns {boolean} `true` if the key should be used.
5444
- */ function filterKey(key) {
5116
+ */
5117
+ function filterKey(key) {
5445
5118
  return !KEY_BLACKLIST.has(key) && key[0] !== "_";
5446
5119
  }
5120
+
5447
5121
  /**
5448
5122
  * Get visitor keys of a given node.
5449
5123
  * @param {object} node The AST node to get keys.
5450
5124
  * @returns {readonly string[]} Visitor keys of the node.
5451
- */ function getKeys(node) {
5125
+ */
5126
+ function getKeys(node) {
5452
5127
  return Object.keys(node).filter(filterKey);
5453
5128
  }
5129
+
5454
5130
  /**
5455
5131
  * Get the innermost scope which contains a given location.
5456
5132
  * @param {Scope} initialScope The initial scope to search.
5457
5133
  * @param {Node} node The location to search.
5458
5134
  * @returns {Scope} The innermost scope.
5459
- */ function getInnermostScope(initialScope, node) {
5135
+ */
5136
+ function getInnermostScope(initialScope, node) {
5460
5137
  const location = node.range[0];
5138
+
5461
5139
  let scope = initialScope;
5462
5140
  let found = false;
5463
5141
  do {
5464
5142
  found = false;
5465
- for (const childScope of scope.childScopes){
5143
+ for (const childScope of scope.childScopes) {
5466
5144
  const range = childScope.block.range;
5145
+
5467
5146
  if (range[0] <= location && location < range[1]) {
5468
5147
  scope = childScope;
5469
5148
  found = true;
5470
- break;
5149
+ break
5471
5150
  }
5472
5151
  }
5473
- }while (found)
5474
- return scope;
5152
+ } while (found)
5153
+
5154
+ return scope
5475
5155
  }
5156
+
5476
5157
  /**
5477
5158
  * Find the variable of a given name.
5478
5159
  * @param {Scope} initialScope The scope to start finding.
5479
5160
  * @param {string|Node} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node.
5480
5161
  * @returns {Variable|null} The found variable or null.
5481
- */ function findVariable(initialScope, nameOrNode) {
5162
+ */
5163
+ function findVariable(initialScope, nameOrNode) {
5482
5164
  let name = "";
5483
5165
  let scope = initialScope;
5166
+
5484
5167
  if (typeof nameOrNode === "string") {
5485
5168
  name = nameOrNode;
5486
5169
  } else {
5487
5170
  name = nameOrNode.name;
5488
5171
  scope = getInnermostScope(scope, nameOrNode);
5489
5172
  }
5490
- while(scope != null){
5173
+
5174
+ while (scope != null) {
5491
5175
  const variable = scope.set.get(name);
5492
5176
  if (variable != null) {
5493
- return variable;
5177
+ return variable
5494
5178
  }
5495
5179
  scope = scope.upper;
5496
5180
  }
5497
- return null;
5181
+
5182
+ return null
5498
5183
  }
5184
+
5499
5185
  /**
5500
5186
  * Negate the result of `this` calling.
5501
5187
  * @param {Token} token The token to check.
5502
5188
  * @returns {boolean} `true` if the result of `this(token)` is `false`.
5503
- */ function negate0(token) {
5189
+ */
5190
+ function negate0(token) {
5504
5191
  return !this(token) //eslint-disable-line no-invalid-this
5505
- ;
5506
5192
  }
5193
+
5507
5194
  /**
5508
5195
  * Creates the negate function of the given function.
5509
5196
  * @param {function(Token):boolean} f - The function to negate.
5510
5197
  * @returns {function(Token):boolean} Negated function.
5511
- */ function negate(f) {
5512
- return negate0.bind(f);
5198
+ */
5199
+ function negate(f) {
5200
+ return negate0.bind(f)
5513
5201
  }
5202
+
5514
5203
  /**
5515
5204
  * Checks if the given token is a PunctuatorToken with the given value
5516
5205
  * @param {Token} token - The token to check.
5517
5206
  * @param {string} value - The value to check.
5518
5207
  * @returns {boolean} `true` if the token is a PunctuatorToken with the given value.
5519
- */ function isPunctuatorTokenWithValue(token, value) {
5520
- return token.type === "Punctuator" && token.value === value;
5208
+ */
5209
+ function isPunctuatorTokenWithValue(token, value) {
5210
+ return token.type === "Punctuator" && token.value === value
5521
5211
  }
5212
+
5522
5213
  /**
5523
5214
  * Checks if the given token is an arrow token or not.
5524
5215
  * @param {Token} token - The token to check.
5525
5216
  * @returns {boolean} `true` if the token is an arrow token.
5526
- */ function isArrowToken(token) {
5527
- return isPunctuatorTokenWithValue(token, "=>");
5217
+ */
5218
+ function isArrowToken(token) {
5219
+ return isPunctuatorTokenWithValue(token, "=>")
5528
5220
  }
5221
+
5529
5222
  /**
5530
5223
  * Checks if the given token is a comma token or not.
5531
5224
  * @param {Token} token - The token to check.
5532
5225
  * @returns {boolean} `true` if the token is a comma token.
5533
- */ function isCommaToken(token) {
5534
- return isPunctuatorTokenWithValue(token, ",");
5226
+ */
5227
+ function isCommaToken(token) {
5228
+ return isPunctuatorTokenWithValue(token, ",")
5535
5229
  }
5230
+
5536
5231
  /**
5537
5232
  * Checks if the given token is a semicolon token or not.
5538
5233
  * @param {Token} token - The token to check.
5539
5234
  * @returns {boolean} `true` if the token is a semicolon token.
5540
- */ function isSemicolonToken(token) {
5541
- return isPunctuatorTokenWithValue(token, ";");
5235
+ */
5236
+ function isSemicolonToken(token) {
5237
+ return isPunctuatorTokenWithValue(token, ";")
5542
5238
  }
5239
+
5543
5240
  /**
5544
5241
  * Checks if the given token is a colon token or not.
5545
5242
  * @param {Token} token - The token to check.
5546
5243
  * @returns {boolean} `true` if the token is a colon token.
5547
- */ function isColonToken(token) {
5548
- return isPunctuatorTokenWithValue(token, ":");
5244
+ */
5245
+ function isColonToken(token) {
5246
+ return isPunctuatorTokenWithValue(token, ":")
5549
5247
  }
5248
+
5550
5249
  /**
5551
5250
  * Checks if the given token is an opening parenthesis token or not.
5552
5251
  * @param {Token} token - The token to check.
5553
5252
  * @returns {boolean} `true` if the token is an opening parenthesis token.
5554
- */ function isOpeningParenToken(token) {
5555
- return isPunctuatorTokenWithValue(token, "(");
5253
+ */
5254
+ function isOpeningParenToken(token) {
5255
+ return isPunctuatorTokenWithValue(token, "(")
5556
5256
  }
5257
+
5557
5258
  /**
5558
5259
  * Checks if the given token is a closing parenthesis token or not.
5559
5260
  * @param {Token} token - The token to check.
5560
5261
  * @returns {boolean} `true` if the token is a closing parenthesis token.
5561
- */ function isClosingParenToken(token) {
5562
- return isPunctuatorTokenWithValue(token, ")");
5262
+ */
5263
+ function isClosingParenToken(token) {
5264
+ return isPunctuatorTokenWithValue(token, ")")
5563
5265
  }
5266
+
5564
5267
  /**
5565
5268
  * Checks if the given token is an opening square bracket token or not.
5566
5269
  * @param {Token} token - The token to check.
5567
5270
  * @returns {boolean} `true` if the token is an opening square bracket token.
5568
- */ function isOpeningBracketToken(token) {
5569
- return isPunctuatorTokenWithValue(token, "[");
5271
+ */
5272
+ function isOpeningBracketToken(token) {
5273
+ return isPunctuatorTokenWithValue(token, "[")
5570
5274
  }
5275
+
5571
5276
  /**
5572
5277
  * Checks if the given token is a closing square bracket token or not.
5573
5278
  * @param {Token} token - The token to check.
5574
5279
  * @returns {boolean} `true` if the token is a closing square bracket token.
5575
- */ function isClosingBracketToken(token) {
5576
- return isPunctuatorTokenWithValue(token, "]");
5280
+ */
5281
+ function isClosingBracketToken(token) {
5282
+ return isPunctuatorTokenWithValue(token, "]")
5577
5283
  }
5284
+
5578
5285
  /**
5579
5286
  * Checks if the given token is an opening brace token or not.
5580
5287
  * @param {Token} token - The token to check.
5581
5288
  * @returns {boolean} `true` if the token is an opening brace token.
5582
- */ function isOpeningBraceToken(token) {
5583
- return isPunctuatorTokenWithValue(token, "{");
5289
+ */
5290
+ function isOpeningBraceToken(token) {
5291
+ return isPunctuatorTokenWithValue(token, "{")
5584
5292
  }
5293
+
5585
5294
  /**
5586
5295
  * Checks if the given token is a closing brace token or not.
5587
5296
  * @param {Token} token - The token to check.
5588
5297
  * @returns {boolean} `true` if the token is a closing brace token.
5589
- */ function isClosingBraceToken(token) {
5590
- return isPunctuatorTokenWithValue(token, "}");
5298
+ */
5299
+ function isClosingBraceToken(token) {
5300
+ return isPunctuatorTokenWithValue(token, "}")
5591
5301
  }
5302
+
5592
5303
  /**
5593
5304
  * Checks if the given token is a comment token or not.
5594
5305
  * @param {Token} token - The token to check.
5595
5306
  * @returns {boolean} `true` if the token is a comment token.
5596
- */ function isCommentToken(token) {
5597
- return [
5598
- "Block",
5599
- "Line",
5600
- "Shebang"
5601
- ].includes(token.type);
5307
+ */
5308
+ function isCommentToken(token) {
5309
+ return ["Block", "Line", "Shebang"].includes(token.type)
5602
5310
  }
5311
+
5603
5312
  negate(isArrowToken);
5604
5313
  negate(isCommaToken);
5605
5314
  negate(isSemicolonToken);
@@ -5611,163 +5320,180 @@ negate(isClosingBracketToken);
5611
5320
  negate(isOpeningBraceToken);
5612
5321
  negate(isClosingBraceToken);
5613
5322
  negate(isCommentToken);
5614
- /* globals globalThis, global, self, window */ const globalObject = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
5615
- const builtinNames = Object.freeze(new Set([
5616
- "Array",
5617
- "ArrayBuffer",
5618
- "BigInt",
5619
- "BigInt64Array",
5620
- "BigUint64Array",
5621
- "Boolean",
5622
- "DataView",
5623
- "Date",
5624
- "decodeURI",
5625
- "decodeURIComponent",
5626
- "encodeURI",
5627
- "encodeURIComponent",
5628
- "escape",
5629
- "Float32Array",
5630
- "Float64Array",
5631
- "Function",
5632
- "Infinity",
5633
- "Int16Array",
5634
- "Int32Array",
5635
- "Int8Array",
5636
- "isFinite",
5637
- "isNaN",
5638
- "isPrototypeOf",
5639
- "JSON",
5640
- "Map",
5641
- "Math",
5642
- "NaN",
5643
- "Number",
5644
- "Object",
5645
- "parseFloat",
5646
- "parseInt",
5647
- "Promise",
5648
- "Proxy",
5649
- "Reflect",
5650
- "RegExp",
5651
- "Set",
5652
- "String",
5653
- "Symbol",
5654
- "Uint16Array",
5655
- "Uint32Array",
5656
- "Uint8Array",
5657
- "Uint8ClampedArray",
5658
- "undefined",
5659
- "unescape",
5660
- "WeakMap",
5661
- "WeakSet"
5662
- ]));
5663
- const callAllowed = new Set([
5664
- Array.isArray,
5665
- Array.of,
5666
- Array.prototype.at,
5667
- Array.prototype.concat,
5668
- Array.prototype.entries,
5669
- Array.prototype.every,
5670
- Array.prototype.filter,
5671
- Array.prototype.find,
5672
- Array.prototype.findIndex,
5673
- Array.prototype.flat,
5674
- Array.prototype.includes,
5675
- Array.prototype.indexOf,
5676
- Array.prototype.join,
5677
- Array.prototype.keys,
5678
- Array.prototype.lastIndexOf,
5679
- Array.prototype.slice,
5680
- Array.prototype.some,
5681
- Array.prototype.toString,
5682
- Array.prototype.values,
5683
- typeof BigInt === "function" ? BigInt : undefined,
5684
- Boolean,
5685
- Date,
5686
- Date.parse,
5687
- decodeURI,
5688
- decodeURIComponent,
5689
- encodeURI,
5690
- encodeURIComponent,
5691
- escape,
5692
- isFinite,
5693
- isNaN,
5694
- isPrototypeOf,
5695
- Map,
5696
- Map.prototype.entries,
5697
- Map.prototype.get,
5698
- Map.prototype.has,
5699
- Map.prototype.keys,
5700
- Map.prototype.values,
5701
- ...Object.getOwnPropertyNames(Math).filter((k)=>k !== "random").map((k)=>Math[k]).filter((f)=>typeof f === "function"),
5702
- Number,
5703
- Number.isFinite,
5704
- Number.isNaN,
5705
- Number.parseFloat,
5706
- Number.parseInt,
5707
- Number.prototype.toExponential,
5708
- Number.prototype.toFixed,
5709
- Number.prototype.toPrecision,
5710
- Number.prototype.toString,
5711
- Object,
5712
- Object.entries,
5713
- Object.is,
5714
- Object.isExtensible,
5715
- Object.isFrozen,
5716
- Object.isSealed,
5717
- Object.keys,
5718
- Object.values,
5719
- parseFloat,
5720
- parseInt,
5721
- RegExp,
5722
- Set,
5723
- Set.prototype.entries,
5724
- Set.prototype.has,
5725
- Set.prototype.keys,
5726
- Set.prototype.values,
5727
- String,
5728
- String.fromCharCode,
5729
- String.fromCodePoint,
5730
- String.raw,
5731
- String.prototype.at,
5732
- String.prototype.charAt,
5733
- String.prototype.charCodeAt,
5734
- String.prototype.codePointAt,
5735
- String.prototype.concat,
5736
- String.prototype.endsWith,
5737
- String.prototype.includes,
5738
- String.prototype.indexOf,
5739
- String.prototype.lastIndexOf,
5740
- String.prototype.normalize,
5741
- String.prototype.padEnd,
5742
- String.prototype.padStart,
5743
- String.prototype.slice,
5744
- String.prototype.startsWith,
5745
- String.prototype.substr,
5746
- String.prototype.substring,
5747
- String.prototype.toLowerCase,
5748
- String.prototype.toString,
5749
- String.prototype.toUpperCase,
5750
- String.prototype.trim,
5751
- String.prototype.trimEnd,
5752
- String.prototype.trimLeft,
5753
- String.prototype.trimRight,
5754
- String.prototype.trimStart,
5755
- Symbol.for,
5756
- Symbol.keyFor,
5757
- unescape
5758
- ].filter((f)=>typeof f === "function"));
5323
+
5324
+ /* globals globalThis, global, self, window */
5325
+
5326
+ const globalObject =
5327
+ typeof globalThis !== "undefined"
5328
+ ? globalThis
5329
+ : typeof self !== "undefined"
5330
+ ? self
5331
+ : typeof window !== "undefined"
5332
+ ? window
5333
+ : typeof global !== "undefined"
5334
+ ? global
5335
+ : {};
5336
+
5337
+ const builtinNames = Object.freeze(
5338
+ new Set([
5339
+ "Array",
5340
+ "ArrayBuffer",
5341
+ "BigInt",
5342
+ "BigInt64Array",
5343
+ "BigUint64Array",
5344
+ "Boolean",
5345
+ "DataView",
5346
+ "Date",
5347
+ "decodeURI",
5348
+ "decodeURIComponent",
5349
+ "encodeURI",
5350
+ "encodeURIComponent",
5351
+ "escape",
5352
+ "Float32Array",
5353
+ "Float64Array",
5354
+ "Function",
5355
+ "Infinity",
5356
+ "Int16Array",
5357
+ "Int32Array",
5358
+ "Int8Array",
5359
+ "isFinite",
5360
+ "isNaN",
5361
+ "isPrototypeOf",
5362
+ "JSON",
5363
+ "Map",
5364
+ "Math",
5365
+ "NaN",
5366
+ "Number",
5367
+ "Object",
5368
+ "parseFloat",
5369
+ "parseInt",
5370
+ "Promise",
5371
+ "Proxy",
5372
+ "Reflect",
5373
+ "RegExp",
5374
+ "Set",
5375
+ "String",
5376
+ "Symbol",
5377
+ "Uint16Array",
5378
+ "Uint32Array",
5379
+ "Uint8Array",
5380
+ "Uint8ClampedArray",
5381
+ "undefined",
5382
+ "unescape",
5383
+ "WeakMap",
5384
+ "WeakSet",
5385
+ ]),
5386
+ );
5387
+ const callAllowed = new Set(
5388
+ [
5389
+ Array.isArray,
5390
+ Array.of,
5391
+ Array.prototype.at,
5392
+ Array.prototype.concat,
5393
+ Array.prototype.entries,
5394
+ Array.prototype.every,
5395
+ Array.prototype.filter,
5396
+ Array.prototype.find,
5397
+ Array.prototype.findIndex,
5398
+ Array.prototype.flat,
5399
+ Array.prototype.includes,
5400
+ Array.prototype.indexOf,
5401
+ Array.prototype.join,
5402
+ Array.prototype.keys,
5403
+ Array.prototype.lastIndexOf,
5404
+ Array.prototype.slice,
5405
+ Array.prototype.some,
5406
+ Array.prototype.toString,
5407
+ Array.prototype.values,
5408
+ typeof BigInt === "function" ? BigInt : undefined,
5409
+ Boolean,
5410
+ Date,
5411
+ Date.parse,
5412
+ decodeURI,
5413
+ decodeURIComponent,
5414
+ encodeURI,
5415
+ encodeURIComponent,
5416
+ escape,
5417
+ isFinite,
5418
+ isNaN,
5419
+ isPrototypeOf,
5420
+ Map,
5421
+ Map.prototype.entries,
5422
+ Map.prototype.get,
5423
+ Map.prototype.has,
5424
+ Map.prototype.keys,
5425
+ Map.prototype.values,
5426
+ ...Object.getOwnPropertyNames(Math)
5427
+ .filter((k) => k !== "random")
5428
+ .map((k) => Math[k])
5429
+ .filter((f) => typeof f === "function"),
5430
+ Number,
5431
+ Number.isFinite,
5432
+ Number.isNaN,
5433
+ Number.parseFloat,
5434
+ Number.parseInt,
5435
+ Number.prototype.toExponential,
5436
+ Number.prototype.toFixed,
5437
+ Number.prototype.toPrecision,
5438
+ Number.prototype.toString,
5439
+ Object,
5440
+ Object.entries,
5441
+ Object.is,
5442
+ Object.isExtensible,
5443
+ Object.isFrozen,
5444
+ Object.isSealed,
5445
+ Object.keys,
5446
+ Object.values,
5447
+ parseFloat,
5448
+ parseInt,
5449
+ RegExp,
5450
+ Set,
5451
+ Set.prototype.entries,
5452
+ Set.prototype.has,
5453
+ Set.prototype.keys,
5454
+ Set.prototype.values,
5455
+ String,
5456
+ String.fromCharCode,
5457
+ String.fromCodePoint,
5458
+ String.raw,
5459
+ String.prototype.at,
5460
+ String.prototype.charAt,
5461
+ String.prototype.charCodeAt,
5462
+ String.prototype.codePointAt,
5463
+ String.prototype.concat,
5464
+ String.prototype.endsWith,
5465
+ String.prototype.includes,
5466
+ String.prototype.indexOf,
5467
+ String.prototype.lastIndexOf,
5468
+ String.prototype.normalize,
5469
+ String.prototype.padEnd,
5470
+ String.prototype.padStart,
5471
+ String.prototype.slice,
5472
+ String.prototype.startsWith,
5473
+ String.prototype.substr,
5474
+ String.prototype.substring,
5475
+ String.prototype.toLowerCase,
5476
+ String.prototype.toString,
5477
+ String.prototype.toUpperCase,
5478
+ String.prototype.trim,
5479
+ String.prototype.trimEnd,
5480
+ String.prototype.trimLeft,
5481
+ String.prototype.trimRight,
5482
+ String.prototype.trimStart,
5483
+ Symbol.for,
5484
+ Symbol.keyFor,
5485
+ unescape,
5486
+ ].filter((f) => typeof f === "function"),
5487
+ );
5759
5488
  const callPassThrough = new Set([
5760
5489
  Object.freeze,
5761
5490
  Object.preventExtensions,
5762
- Object.seal
5491
+ Object.seal,
5763
5492
  ]);
5764
- /** @type {ReadonlyArray<readonly [Function, ReadonlySet<string>]>} */ const getterAllowed = [
5765
- [
5766
- Map,
5767
- new Set([
5768
- "size"
5769
- ])
5770
- ],
5493
+
5494
+ /** @type {ReadonlyArray<readonly [Function, ReadonlySet<string>]>} */
5495
+ const getterAllowed = [
5496
+ [Map, new Set(["size"])],
5771
5497
  [
5772
5498
  RegExp,
5773
5499
  new Set([
@@ -5779,218 +5505,190 @@ const callPassThrough = new Set([
5779
5505
  "multiline",
5780
5506
  "source",
5781
5507
  "sticky",
5782
- "unicode"
5783
- ])
5508
+ "unicode",
5509
+ ]),
5784
5510
  ],
5785
- [
5786
- Set,
5787
- new Set([
5788
- "size"
5789
- ])
5790
- ]
5511
+ [Set, new Set(["size"])],
5791
5512
  ];
5513
+
5792
5514
  /**
5793
5515
  * Get the property descriptor.
5794
5516
  * @param {object} object The object to get.
5795
5517
  * @param {string|number|symbol} name The property name to get.
5796
- */ function getPropertyDescriptor(object, name) {
5518
+ */
5519
+ function getPropertyDescriptor(object, name) {
5797
5520
  let x = object;
5798
- while((typeof x === "object" || typeof x === "function") && x !== null){
5521
+ while ((typeof x === "object" || typeof x === "function") && x !== null) {
5799
5522
  const d = Object.getOwnPropertyDescriptor(x, name);
5800
5523
  if (d) {
5801
- return d;
5524
+ return d
5802
5525
  }
5803
5526
  x = Object.getPrototypeOf(x);
5804
5527
  }
5805
- return null;
5528
+ return null
5806
5529
  }
5530
+
5807
5531
  /**
5808
5532
  * Check if a property is getter or not.
5809
5533
  * @param {object} object The object to check.
5810
5534
  * @param {string|number|symbol} name The property name to check.
5811
- */ function isGetter(object, name) {
5535
+ */
5536
+ function isGetter(object, name) {
5812
5537
  const d = getPropertyDescriptor(object, name);
5813
- return d != null && d.get != null;
5538
+ return d != null && d.get != null
5814
5539
  }
5540
+
5815
5541
  /**
5816
5542
  * Get the element values of a given node list.
5817
5543
  * @param {Node[]} nodeList The node list to get values.
5818
5544
  * @param {Scope|undefined} initialScope The initial scope to find variables.
5819
5545
  * @returns {any[]|null} The value list if all nodes are constant. Otherwise, null.
5820
- */ function getElementValues(nodeList, initialScope) {
5546
+ */
5547
+ function getElementValues(nodeList, initialScope) {
5821
5548
  const valueList = [];
5822
- for(let i = 0; i < nodeList.length; ++i){
5549
+
5550
+ for (let i = 0; i < nodeList.length; ++i) {
5823
5551
  const elementNode = nodeList[i];
5552
+
5824
5553
  if (elementNode == null) {
5825
5554
  valueList.length = i + 1;
5826
5555
  } else if (elementNode.type === "SpreadElement") {
5827
5556
  const argument = getStaticValueR(elementNode.argument, initialScope);
5828
5557
  if (argument == null) {
5829
- return null;
5558
+ return null
5830
5559
  }
5831
5560
  valueList.push(...argument.value);
5832
5561
  } else {
5833
5562
  const element = getStaticValueR(elementNode, initialScope);
5834
5563
  if (element == null) {
5835
- return null;
5564
+ return null
5836
5565
  }
5837
5566
  valueList.push(element.value);
5838
5567
  }
5839
5568
  }
5840
- return valueList;
5569
+
5570
+ return valueList
5841
5571
  }
5572
+
5842
5573
  /**
5843
5574
  * Returns whether the given variable is never written to after initialization.
5844
5575
  * @param {import("eslint").Scope.Variable} variable
5845
5576
  * @returns {boolean}
5846
- */ function isEffectivelyConst(variable) {
5577
+ */
5578
+ function isEffectivelyConst(variable) {
5847
5579
  const refs = variable.references;
5848
- const inits = refs.filter((r)=>r.init).length;
5849
- const reads = refs.filter((r)=>r.isReadOnly()).length;
5580
+
5581
+ const inits = refs.filter((r) => r.init).length;
5582
+ const reads = refs.filter((r) => r.isReadOnly()).length;
5850
5583
  if (inits === 1 && reads + inits === refs.length) {
5851
5584
  // there is only one init and all other references only read
5852
- return true;
5585
+ return true
5853
5586
  }
5854
- return false;
5587
+ return false
5855
5588
  }
5589
+
5856
5590
  const operations = Object.freeze({
5857
- ArrayExpression (node, initialScope) {
5591
+ ArrayExpression(node, initialScope) {
5858
5592
  const elements = getElementValues(node.elements, initialScope);
5859
- return elements != null ? {
5860
- value: elements
5861
- } : null;
5593
+ return elements != null ? { value: elements } : null
5862
5594
  },
5863
- AssignmentExpression (node, initialScope) {
5595
+
5596
+ AssignmentExpression(node, initialScope) {
5864
5597
  if (node.operator === "=") {
5865
- return getStaticValueR(node.right, initialScope);
5598
+ return getStaticValueR(node.right, initialScope)
5866
5599
  }
5867
- return null;
5600
+ return null
5868
5601
  },
5602
+
5869
5603
  //eslint-disable-next-line complexity
5870
- BinaryExpression (node, initialScope) {
5604
+ BinaryExpression(node, initialScope) {
5871
5605
  if (node.operator === "in" || node.operator === "instanceof") {
5872
5606
  // Not supported.
5873
- return null;
5607
+ return null
5874
5608
  }
5609
+
5875
5610
  const left = getStaticValueR(node.left, initialScope);
5876
5611
  const right = getStaticValueR(node.right, initialScope);
5877
5612
  if (left != null && right != null) {
5878
- switch(node.operator){
5613
+ switch (node.operator) {
5879
5614
  case "==":
5880
- return {
5881
- value: left.value == right.value
5882
- } //eslint-disable-line eqeqeq
5883
- ;
5615
+ return { value: left.value == right.value } //eslint-disable-line eqeqeq
5884
5616
  case "!=":
5885
- return {
5886
- value: left.value != right.value
5887
- } //eslint-disable-line eqeqeq
5888
- ;
5617
+ return { value: left.value != right.value } //eslint-disable-line eqeqeq
5889
5618
  case "===":
5890
- return {
5891
- value: left.value === right.value
5892
- };
5619
+ return { value: left.value === right.value }
5893
5620
  case "!==":
5894
- return {
5895
- value: left.value !== right.value
5896
- };
5621
+ return { value: left.value !== right.value }
5897
5622
  case "<":
5898
- return {
5899
- value: left.value < right.value
5900
- };
5623
+ return { value: left.value < right.value }
5901
5624
  case "<=":
5902
- return {
5903
- value: left.value <= right.value
5904
- };
5625
+ return { value: left.value <= right.value }
5905
5626
  case ">":
5906
- return {
5907
- value: left.value > right.value
5908
- };
5627
+ return { value: left.value > right.value }
5909
5628
  case ">=":
5910
- return {
5911
- value: left.value >= right.value
5912
- };
5629
+ return { value: left.value >= right.value }
5913
5630
  case "<<":
5914
- return {
5915
- value: left.value << right.value
5916
- };
5631
+ return { value: left.value << right.value }
5917
5632
  case ">>":
5918
- return {
5919
- value: left.value >> right.value
5920
- };
5633
+ return { value: left.value >> right.value }
5921
5634
  case ">>>":
5922
- return {
5923
- value: left.value >>> right.value
5924
- };
5635
+ return { value: left.value >>> right.value }
5925
5636
  case "+":
5926
- return {
5927
- value: left.value + right.value
5928
- };
5637
+ return { value: left.value + right.value }
5929
5638
  case "-":
5930
- return {
5931
- value: left.value - right.value
5932
- };
5639
+ return { value: left.value - right.value }
5933
5640
  case "*":
5934
- return {
5935
- value: left.value * right.value
5936
- };
5641
+ return { value: left.value * right.value }
5937
5642
  case "/":
5938
- return {
5939
- value: left.value / right.value
5940
- };
5643
+ return { value: left.value / right.value }
5941
5644
  case "%":
5942
- return {
5943
- value: left.value % right.value
5944
- };
5645
+ return { value: left.value % right.value }
5945
5646
  case "**":
5946
- return {
5947
- value: left.value ** right.value
5948
- };
5647
+ return { value: left.value ** right.value }
5949
5648
  case "|":
5950
- return {
5951
- value: left.value | right.value
5952
- };
5649
+ return { value: left.value | right.value }
5953
5650
  case "^":
5954
- return {
5955
- value: left.value ^ right.value
5956
- };
5651
+ return { value: left.value ^ right.value }
5957
5652
  case "&":
5958
- return {
5959
- value: left.value & right.value
5960
- };
5653
+ return { value: left.value & right.value }
5654
+
5655
+ // no default
5961
5656
  }
5962
5657
  }
5963
- return null;
5658
+
5659
+ return null
5964
5660
  },
5965
- CallExpression (node, initialScope) {
5661
+
5662
+ CallExpression(node, initialScope) {
5966
5663
  const calleeNode = node.callee;
5967
5664
  const args = getElementValues(node.arguments, initialScope);
5665
+
5968
5666
  if (args != null) {
5969
5667
  if (calleeNode.type === "MemberExpression") {
5970
5668
  if (calleeNode.property.type === "PrivateIdentifier") {
5971
- return null;
5669
+ return null
5972
5670
  }
5973
5671
  const object = getStaticValueR(calleeNode.object, initialScope);
5974
5672
  if (object != null) {
5975
- if (object.value == null && (object.optional || node.optional)) {
5976
- return {
5977
- value: undefined,
5978
- optional: true
5979
- };
5673
+ if (
5674
+ object.value == null &&
5675
+ (object.optional || node.optional)
5676
+ ) {
5677
+ return { value: undefined, optional: true }
5980
5678
  }
5981
- const property = getStaticPropertyNameValue(calleeNode, initialScope);
5679
+ const property = getStaticPropertyNameValue(
5680
+ calleeNode,
5681
+ initialScope,
5682
+ );
5683
+
5982
5684
  if (property != null) {
5983
5685
  const receiver = object.value;
5984
5686
  const methodName = property.value;
5985
5687
  if (callAllowed.has(receiver[methodName])) {
5986
- return {
5987
- value: receiver[methodName](...args)
5988
- };
5688
+ return { value: receiver[methodName](...args) }
5989
5689
  }
5990
5690
  if (callPassThrough.has(receiver[methodName])) {
5991
- return {
5992
- value: args[0]
5993
- };
5691
+ return { value: args[0] }
5994
5692
  }
5995
5693
  }
5996
5694
  }
@@ -5998,409 +5696,815 @@ const operations = Object.freeze({
5998
5696
  const callee = getStaticValueR(calleeNode, initialScope);
5999
5697
  if (callee != null) {
6000
5698
  if (callee.value == null && node.optional) {
6001
- return {
6002
- value: undefined,
6003
- optional: true
6004
- };
5699
+ return { value: undefined, optional: true }
6005
5700
  }
6006
5701
  const func = callee.value;
6007
5702
  if (callAllowed.has(func)) {
6008
- return {
6009
- value: func(...args)
6010
- };
5703
+ return { value: func(...args) }
6011
5704
  }
6012
5705
  if (callPassThrough.has(func)) {
6013
- return {
6014
- value: args[0]
6015
- };
5706
+ return { value: args[0] }
6016
5707
  }
6017
5708
  }
6018
5709
  }
6019
5710
  }
6020
- return null;
5711
+
5712
+ return null
6021
5713
  },
6022
- ConditionalExpression (node, initialScope) {
5714
+
5715
+ ConditionalExpression(node, initialScope) {
6023
5716
  const test = getStaticValueR(node.test, initialScope);
6024
5717
  if (test != null) {
6025
- return test.value ? getStaticValueR(node.consequent, initialScope) : getStaticValueR(node.alternate, initialScope);
5718
+ return test.value
5719
+ ? getStaticValueR(node.consequent, initialScope)
5720
+ : getStaticValueR(node.alternate, initialScope)
6026
5721
  }
6027
- return null;
5722
+ return null
6028
5723
  },
6029
- ExpressionStatement (node, initialScope) {
6030
- return getStaticValueR(node.expression, initialScope);
5724
+
5725
+ ExpressionStatement(node, initialScope) {
5726
+ return getStaticValueR(node.expression, initialScope)
6031
5727
  },
6032
- Identifier (node, initialScope) {
5728
+
5729
+ Identifier(node, initialScope) {
6033
5730
  if (initialScope != null) {
6034
5731
  const variable = findVariable(initialScope, node);
5732
+
6035
5733
  // Built-in globals.
6036
- if (variable != null && variable.defs.length === 0 && builtinNames.has(variable.name) && variable.name in globalObject) {
6037
- return {
6038
- value: globalObject[variable.name]
6039
- };
5734
+ if (
5735
+ variable != null &&
5736
+ variable.defs.length === 0 &&
5737
+ builtinNames.has(variable.name) &&
5738
+ variable.name in globalObject
5739
+ ) {
5740
+ return { value: globalObject[variable.name] }
6040
5741
  }
5742
+
6041
5743
  // Constants.
6042
5744
  if (variable != null && variable.defs.length === 1) {
6043
5745
  const def = variable.defs[0];
6044
- if (def.parent && def.type === "Variable" && (def.parent.kind === "const" || isEffectivelyConst(variable)) && // TODO(mysticatea): don't support destructuring here.
6045
- def.node.id.type === "Identifier") {
6046
- return getStaticValueR(def.node.init, initialScope);
5746
+ if (
5747
+ def.parent &&
5748
+ def.type === "Variable" &&
5749
+ (def.parent.kind === "const" ||
5750
+ isEffectivelyConst(variable)) &&
5751
+ // TODO(mysticatea): don't support destructuring here.
5752
+ def.node.id.type === "Identifier"
5753
+ ) {
5754
+ return getStaticValueR(def.node.init, initialScope)
6047
5755
  }
6048
5756
  }
6049
5757
  }
6050
- return null;
5758
+ return null
6051
5759
  },
6052
- Literal (node) {
5760
+
5761
+ Literal(node) {
6053
5762
  //istanbul ignore if : this is implementation-specific behavior.
6054
5763
  if ((node.regex != null || node.bigint != null) && node.value == null) {
6055
5764
  // It was a RegExp/BigInt literal, but Node.js didn't support it.
6056
- return null;
5765
+ return null
6057
5766
  }
6058
- return {
6059
- value: node.value
6060
- };
5767
+ return { value: node.value }
6061
5768
  },
6062
- LogicalExpression (node, initialScope) {
5769
+
5770
+ LogicalExpression(node, initialScope) {
6063
5771
  const left = getStaticValueR(node.left, initialScope);
6064
5772
  if (left != null) {
6065
- if (node.operator === "||" && Boolean(left.value) === true || node.operator === "&&" && Boolean(left.value) === false || node.operator === "??" && left.value != null) {
6066
- return left;
5773
+ if (
5774
+ (node.operator === "||" && Boolean(left.value) === true) ||
5775
+ (node.operator === "&&" && Boolean(left.value) === false) ||
5776
+ (node.operator === "??" && left.value != null)
5777
+ ) {
5778
+ return left
6067
5779
  }
5780
+
6068
5781
  const right = getStaticValueR(node.right, initialScope);
6069
5782
  if (right != null) {
6070
- return right;
5783
+ return right
6071
5784
  }
6072
5785
  }
6073
- return null;
5786
+
5787
+ return null
6074
5788
  },
6075
- MemberExpression (node, initialScope) {
5789
+
5790
+ MemberExpression(node, initialScope) {
6076
5791
  if (node.property.type === "PrivateIdentifier") {
6077
- return null;
5792
+ return null
6078
5793
  }
6079
5794
  const object = getStaticValueR(node.object, initialScope);
6080
5795
  if (object != null) {
6081
5796
  if (object.value == null && (object.optional || node.optional)) {
6082
- return {
6083
- value: undefined,
6084
- optional: true
6085
- };
5797
+ return { value: undefined, optional: true }
6086
5798
  }
6087
5799
  const property = getStaticPropertyNameValue(node, initialScope);
5800
+
6088
5801
  if (property != null) {
6089
5802
  if (!isGetter(object.value, property.value)) {
6090
- return {
6091
- value: object.value[property.value]
6092
- };
5803
+ return { value: object.value[property.value] }
6093
5804
  }
6094
- for (const [classFn, allowed] of getterAllowed){
6095
- if (object.value instanceof classFn && allowed.has(property.value)) {
6096
- return {
6097
- value: object.value[property.value]
6098
- };
5805
+
5806
+ for (const [classFn, allowed] of getterAllowed) {
5807
+ if (
5808
+ object.value instanceof classFn &&
5809
+ allowed.has(property.value)
5810
+ ) {
5811
+ return { value: object.value[property.value] }
6099
5812
  }
6100
5813
  }
6101
5814
  }
6102
5815
  }
6103
- return null;
5816
+ return null
6104
5817
  },
6105
- ChainExpression (node, initialScope) {
5818
+
5819
+ ChainExpression(node, initialScope) {
6106
5820
  const expression = getStaticValueR(node.expression, initialScope);
6107
5821
  if (expression != null) {
6108
- return {
6109
- value: expression.value
6110
- };
5822
+ return { value: expression.value }
6111
5823
  }
6112
- return null;
5824
+ return null
6113
5825
  },
6114
- NewExpression (node, initialScope) {
5826
+
5827
+ NewExpression(node, initialScope) {
6115
5828
  const callee = getStaticValueR(node.callee, initialScope);
6116
5829
  const args = getElementValues(node.arguments, initialScope);
5830
+
6117
5831
  if (callee != null && args != null) {
6118
5832
  const Func = callee.value;
6119
5833
  if (callAllowed.has(Func)) {
6120
- return {
6121
- value: new Func(...args)
6122
- };
5834
+ return { value: new Func(...args) }
6123
5835
  }
6124
5836
  }
6125
- return null;
5837
+
5838
+ return null
6126
5839
  },
6127
- ObjectExpression (node, initialScope) {
5840
+
5841
+ ObjectExpression(node, initialScope) {
6128
5842
  const object = {};
6129
- for (const propertyNode of node.properties){
5843
+
5844
+ for (const propertyNode of node.properties) {
6130
5845
  if (propertyNode.type === "Property") {
6131
5846
  if (propertyNode.kind !== "init") {
6132
- return null;
5847
+ return null
6133
5848
  }
6134
- const key = getStaticPropertyNameValue(propertyNode, initialScope);
5849
+ const key = getStaticPropertyNameValue(
5850
+ propertyNode,
5851
+ initialScope,
5852
+ );
6135
5853
  const value = getStaticValueR(propertyNode.value, initialScope);
6136
5854
  if (key == null || value == null) {
6137
- return null;
5855
+ return null
6138
5856
  }
6139
5857
  object[key.value] = value.value;
6140
- } else if (propertyNode.type === "SpreadElement" || propertyNode.type === "ExperimentalSpreadProperty") {
6141
- const argument = getStaticValueR(propertyNode.argument, initialScope);
5858
+ } else if (
5859
+ propertyNode.type === "SpreadElement" ||
5860
+ propertyNode.type === "ExperimentalSpreadProperty"
5861
+ ) {
5862
+ const argument = getStaticValueR(
5863
+ propertyNode.argument,
5864
+ initialScope,
5865
+ );
6142
5866
  if (argument == null) {
6143
- return null;
5867
+ return null
6144
5868
  }
6145
5869
  Object.assign(object, argument.value);
6146
5870
  } else {
6147
- return null;
5871
+ return null
6148
5872
  }
6149
5873
  }
6150
- return {
6151
- value: object
6152
- };
5874
+
5875
+ return { value: object }
6153
5876
  },
6154
- SequenceExpression (node, initialScope) {
5877
+
5878
+ SequenceExpression(node, initialScope) {
6155
5879
  const last = node.expressions[node.expressions.length - 1];
6156
- return getStaticValueR(last, initialScope);
5880
+ return getStaticValueR(last, initialScope)
6157
5881
  },
6158
- TaggedTemplateExpression (node, initialScope) {
5882
+
5883
+ TaggedTemplateExpression(node, initialScope) {
6159
5884
  const tag = getStaticValueR(node.tag, initialScope);
6160
- const expressions = getElementValues(node.quasi.expressions, initialScope);
5885
+ const expressions = getElementValues(
5886
+ node.quasi.expressions,
5887
+ initialScope,
5888
+ );
5889
+
6161
5890
  if (tag != null && expressions != null) {
6162
5891
  const func = tag.value;
6163
- const strings = node.quasi.quasis.map((q)=>q.value.cooked);
6164
- strings.raw = node.quasi.quasis.map((q)=>q.value.raw);
5892
+ const strings = node.quasi.quasis.map((q) => q.value.cooked);
5893
+ strings.raw = node.quasi.quasis.map((q) => q.value.raw);
5894
+
6165
5895
  if (func === String.raw) {
6166
- return {
6167
- value: func(strings, ...expressions)
6168
- };
5896
+ return { value: func(strings, ...expressions) }
6169
5897
  }
6170
5898
  }
6171
- return null;
5899
+
5900
+ return null
6172
5901
  },
6173
- TemplateLiteral (node, initialScope) {
5902
+
5903
+ TemplateLiteral(node, initialScope) {
6174
5904
  const expressions = getElementValues(node.expressions, initialScope);
6175
5905
  if (expressions != null) {
6176
5906
  let value = node.quasis[0].value.cooked;
6177
- for(let i = 0; i < expressions.length; ++i){
5907
+ for (let i = 0; i < expressions.length; ++i) {
6178
5908
  value += expressions[i];
6179
5909
  value += node.quasis[i + 1].value.cooked;
6180
5910
  }
6181
- return {
6182
- value
6183
- };
5911
+ return { value }
6184
5912
  }
6185
- return null;
5913
+ return null
6186
5914
  },
6187
- UnaryExpression (node, initialScope) {
5915
+
5916
+ UnaryExpression(node, initialScope) {
6188
5917
  if (node.operator === "delete") {
6189
5918
  // Not supported.
6190
- return null;
5919
+ return null
6191
5920
  }
6192
5921
  if (node.operator === "void") {
6193
- return {
6194
- value: undefined
6195
- };
5922
+ return { value: undefined }
6196
5923
  }
5924
+
6197
5925
  const arg = getStaticValueR(node.argument, initialScope);
6198
5926
  if (arg != null) {
6199
- switch(node.operator){
5927
+ switch (node.operator) {
6200
5928
  case "-":
6201
- return {
6202
- value: -arg.value
6203
- };
5929
+ return { value: -arg.value }
6204
5930
  case "+":
6205
- return {
6206
- value: +arg.value
6207
- } //eslint-disable-line no-implicit-coercion
6208
- ;
5931
+ return { value: +arg.value } //eslint-disable-line no-implicit-coercion
6209
5932
  case "!":
6210
- return {
6211
- value: !arg.value
6212
- };
5933
+ return { value: !arg.value }
6213
5934
  case "~":
6214
- return {
6215
- value: ~arg.value
6216
- };
5935
+ return { value: ~arg.value }
6217
5936
  case "typeof":
6218
- return {
6219
- value: typeof arg.value
6220
- };
5937
+ return { value: typeof arg.value }
5938
+
5939
+ // no default
6221
5940
  }
6222
5941
  }
6223
- return null;
6224
- }
5942
+
5943
+ return null
5944
+ },
6225
5945
  });
5946
+
6226
5947
  /**
6227
5948
  * Get the value of a given node if it's a static value.
6228
5949
  * @param {Node} node The node to get.
6229
5950
  * @param {Scope|undefined} initialScope The scope to start finding variable.
6230
5951
  * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`.
6231
- */ function getStaticValueR(node, initialScope) {
5952
+ */
5953
+ function getStaticValueR(node, initialScope) {
6232
5954
  if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
6233
- return operations[node.type](node, initialScope);
5955
+ return operations[node.type](node, initialScope)
6234
5956
  }
6235
- return null;
5957
+ return null
6236
5958
  }
5959
+
6237
5960
  /**
6238
5961
  * Get the static value of property name from a MemberExpression node or a Property node.
6239
5962
  * @param {Node} node The node to get.
6240
5963
  * @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.
6241
5964
  * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the property name of the node, or `null`.
6242
- */ function getStaticPropertyNameValue(node, initialScope) {
5965
+ */
5966
+ function getStaticPropertyNameValue(node, initialScope) {
6243
5967
  const nameNode = node.type === "Property" ? node.key : node.property;
5968
+
6244
5969
  if (node.computed) {
6245
- return getStaticValueR(nameNode, initialScope);
5970
+ return getStaticValueR(nameNode, initialScope)
6246
5971
  }
5972
+
6247
5973
  if (nameNode.type === "Identifier") {
6248
- return {
6249
- value: nameNode.name
6250
- };
5974
+ return { value: nameNode.name }
6251
5975
  }
5976
+
6252
5977
  if (nameNode.type === "Literal") {
6253
5978
  if (nameNode.bigint) {
6254
- return {
6255
- value: nameNode.bigint
6256
- };
5979
+ return { value: nameNode.bigint }
6257
5980
  }
6258
- return {
6259
- value: String(nameNode.value)
6260
- };
5981
+ return { value: String(nameNode.value) }
5982
+ }
5983
+
5984
+ return null
5985
+ }
5986
+
5987
+ /**
5988
+ * Get the value of a given node if it's a static value.
5989
+ * @param {Node} node The node to get.
5990
+ * @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.
5991
+ * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`.
5992
+ */
5993
+ function getStaticValue$1(node, initialScope = null) {
5994
+ try {
5995
+ return getStaticValueR(node, initialScope)
5996
+ } catch (_error) {
5997
+ return null
5998
+ }
5999
+ }
6000
+
6001
+ const typeConversionBinaryOps = Object.freeze(
6002
+ new Set([
6003
+ "==",
6004
+ "!=",
6005
+ "<",
6006
+ "<=",
6007
+ ">",
6008
+ ">=",
6009
+ "<<",
6010
+ ">>",
6011
+ ">>>",
6012
+ "+",
6013
+ "-",
6014
+ "*",
6015
+ "/",
6016
+ "%",
6017
+ "|",
6018
+ "^",
6019
+ "&",
6020
+ "in",
6021
+ ]),
6022
+ );
6023
+ const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"]));
6024
+
6025
+ /**
6026
+ * Check whether the given value is an ASTNode or not.
6027
+ * @param {any} x The value to check.
6028
+ * @returns {boolean} `true` if the value is an ASTNode.
6029
+ */
6030
+ function isNode(x) {
6031
+ return x !== null && typeof x === "object" && typeof x.type === "string"
6032
+ }
6033
+
6034
+ Object.freeze(
6035
+ Object.assign(Object.create(null), {
6036
+ $visit(node, options, visitorKeys) {
6037
+ const { type } = node;
6038
+
6039
+ if (typeof this[type] === "function") {
6040
+ return this[type](node, options, visitorKeys)
6041
+ }
6042
+
6043
+ return this.$visitChildren(node, options, visitorKeys)
6044
+ },
6045
+
6046
+ $visitChildren(node, options, visitorKeys) {
6047
+ const { type } = node;
6048
+
6049
+ for (const key of visitorKeys[type] || getKeys(node)) {
6050
+ const value = node[key];
6051
+
6052
+ if (Array.isArray(value)) {
6053
+ for (const element of value) {
6054
+ if (
6055
+ isNode(element) &&
6056
+ this.$visit(element, options, visitorKeys)
6057
+ ) {
6058
+ return true
6059
+ }
6060
+ }
6061
+ } else if (
6062
+ isNode(value) &&
6063
+ this.$visit(value, options, visitorKeys)
6064
+ ) {
6065
+ return true
6066
+ }
6067
+ }
6068
+
6069
+ return false
6070
+ },
6071
+
6072
+ ArrowFunctionExpression() {
6073
+ return false
6074
+ },
6075
+ AssignmentExpression() {
6076
+ return true
6077
+ },
6078
+ AwaitExpression() {
6079
+ return true
6080
+ },
6081
+ BinaryExpression(node, options, visitorKeys) {
6082
+ if (
6083
+ options.considerImplicitTypeConversion &&
6084
+ typeConversionBinaryOps.has(node.operator) &&
6085
+ (node.left.type !== "Literal" || node.right.type !== "Literal")
6086
+ ) {
6087
+ return true
6088
+ }
6089
+ return this.$visitChildren(node, options, visitorKeys)
6090
+ },
6091
+ CallExpression() {
6092
+ return true
6093
+ },
6094
+ FunctionExpression() {
6095
+ return false
6096
+ },
6097
+ ImportExpression() {
6098
+ return true
6099
+ },
6100
+ MemberExpression(node, options, visitorKeys) {
6101
+ if (options.considerGetters) {
6102
+ return true
6103
+ }
6104
+ if (
6105
+ options.considerImplicitTypeConversion &&
6106
+ node.computed &&
6107
+ node.property.type !== "Literal"
6108
+ ) {
6109
+ return true
6110
+ }
6111
+ return this.$visitChildren(node, options, visitorKeys)
6112
+ },
6113
+ MethodDefinition(node, options, visitorKeys) {
6114
+ if (
6115
+ options.considerImplicitTypeConversion &&
6116
+ node.computed &&
6117
+ node.key.type !== "Literal"
6118
+ ) {
6119
+ return true
6120
+ }
6121
+ return this.$visitChildren(node, options, visitorKeys)
6122
+ },
6123
+ NewExpression() {
6124
+ return true
6125
+ },
6126
+ Property(node, options, visitorKeys) {
6127
+ if (
6128
+ options.considerImplicitTypeConversion &&
6129
+ node.computed &&
6130
+ node.key.type !== "Literal"
6131
+ ) {
6132
+ return true
6133
+ }
6134
+ return this.$visitChildren(node, options, visitorKeys)
6135
+ },
6136
+ PropertyDefinition(node, options, visitorKeys) {
6137
+ if (
6138
+ options.considerImplicitTypeConversion &&
6139
+ node.computed &&
6140
+ node.key.type !== "Literal"
6141
+ ) {
6142
+ return true
6143
+ }
6144
+ return this.$visitChildren(node, options, visitorKeys)
6145
+ },
6146
+ UnaryExpression(node, options, visitorKeys) {
6147
+ if (node.operator === "delete") {
6148
+ return true
6149
+ }
6150
+ if (
6151
+ options.considerImplicitTypeConversion &&
6152
+ typeConversionUnaryOps.has(node.operator) &&
6153
+ node.argument.type !== "Literal"
6154
+ ) {
6155
+ return true
6156
+ }
6157
+ return this.$visitChildren(node, options, visitorKeys)
6158
+ },
6159
+ UpdateExpression() {
6160
+ return true
6161
+ },
6162
+ YieldExpression() {
6163
+ return true
6164
+ },
6165
+ }),
6166
+ );
6167
+ Function.call.bind(Object.hasOwnProperty);
6168
+
6169
+ /**
6170
+ * Tests if a value is a `string`.
6171
+ *
6172
+ * @param input - The value to test.
6173
+ *
6174
+ * @example
6175
+ * import { isString } from "effect/Predicate"
6176
+ *
6177
+ * assert.deepStrictEqual(isString("a"), true)
6178
+ *
6179
+ * assert.deepStrictEqual(isString(1), false)
6180
+ *
6181
+ * @category guards
6182
+ * @since 2.0.0
6183
+ */ const isString$1 = (input)=>typeof input === "string";
6184
+ 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)=>{
6185
+ if (i$1(n)) {
6186
+ const e = n[t$1](), { matched: r, selections: i } = e.match(o);
6187
+ return r && i && Object.keys(i).forEach((t)=>c(t, i[t])), r;
6188
+ }
6189
+ if (r$1(n)) {
6190
+ if (!r$1(o)) return !1;
6191
+ if (Array.isArray(n)) {
6192
+ if (!Array.isArray(o)) return !1;
6193
+ let t = [], r = [], a = [];
6194
+ for (const s of n.keys()){
6195
+ const o = n[s];
6196
+ i$1(o) && o[e$1] ? a.push(o) : a.length ? r.push(o) : t.push(o);
6197
+ }
6198
+ if (a.length) {
6199
+ if (a.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
6200
+ if (o.length < t.length + r.length) return !1;
6201
+ 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);
6202
+ 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));
6203
+ }
6204
+ return n.length === o.length && n.every((t, e)=>s$1(t, o[e], c));
6205
+ }
6206
+ return Object.keys(n).every((e)=>{
6207
+ const r = n[e];
6208
+ return (e in o || i$1(a = r) && "optional" === a[t$1]().matcherType) && s$1(r, o[e], c);
6209
+ var a;
6210
+ });
6261
6211
  }
6262
- return null;
6212
+ return Object.is(o, n);
6213
+ }, o$1 = (e)=>{
6214
+ var n, s, a;
6215
+ 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) : [];
6216
+ }, c$1 = (t, e)=>t.reduce((t, n)=>t.concat(e(n)), []);
6217
+ function u$1(t) {
6218
+ return Object.assign(t, {
6219
+ optional: ()=>l$1(t),
6220
+ and: (e)=>m$1(t, e),
6221
+ or: (e)=>y$1(t, e),
6222
+ select: (e)=>void 0 === e ? p$1(t) : p$1(e, t)
6223
+ });
6224
+ }
6225
+ function l$1(e) {
6226
+ return u$1({
6227
+ [t$1]: ()=>({
6228
+ match: (t)=>{
6229
+ let n = {};
6230
+ const r = (t, e)=>{
6231
+ n[t] = e;
6232
+ };
6233
+ return void 0 === t ? (o$1(e).forEach((t)=>r(t, void 0)), {
6234
+ matched: !0,
6235
+ selections: n
6236
+ }) : {
6237
+ matched: s$1(e, t, r),
6238
+ selections: n
6239
+ };
6240
+ },
6241
+ getSelectionKeys: ()=>o$1(e),
6242
+ matcherType: "optional"
6243
+ })
6244
+ });
6245
+ }
6246
+ function m$1(...e) {
6247
+ return u$1({
6248
+ [t$1]: ()=>({
6249
+ match: (t)=>{
6250
+ let n = {};
6251
+ const r = (t, e)=>{
6252
+ n[t] = e;
6253
+ };
6254
+ return {
6255
+ matched: e.every((e)=>s$1(e, t, r)),
6256
+ selections: n
6257
+ };
6258
+ },
6259
+ getSelectionKeys: ()=>c$1(e, o$1),
6260
+ matcherType: "and"
6261
+ })
6262
+ });
6263
+ }
6264
+ function y$1(...e) {
6265
+ return u$1({
6266
+ [t$1]: ()=>({
6267
+ match: (t)=>{
6268
+ let n = {};
6269
+ const r = (t, e)=>{
6270
+ n[t] = e;
6271
+ };
6272
+ return c$1(e, o$1).forEach((t)=>r(t, void 0)), {
6273
+ matched: e.some((e)=>s$1(e, t, r)),
6274
+ selections: n
6275
+ };
6276
+ },
6277
+ getSelectionKeys: ()=>c$1(e, o$1),
6278
+ matcherType: "or"
6279
+ })
6280
+ });
6281
+ }
6282
+ function d$1(e) {
6283
+ return {
6284
+ [t$1]: ()=>({
6285
+ match: (t)=>({
6286
+ matched: Boolean(e(t))
6287
+ })
6288
+ })
6289
+ };
6290
+ }
6291
+ function p$1(...e) {
6292
+ const r = "string" == typeof e[0] ? e[0] : void 0, i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
6293
+ return u$1({
6294
+ [t$1]: ()=>({
6295
+ match: (t)=>{
6296
+ let e = {
6297
+ [null != r ? r : n$1]: t
6298
+ };
6299
+ return {
6300
+ matched: void 0 === i || s$1(i, t, (t, n)=>{
6301
+ e[t] = n;
6302
+ }),
6303
+ selections: e
6304
+ };
6305
+ },
6306
+ getSelectionKeys: ()=>[
6307
+ null != r ? r : n$1
6308
+ ].concat(void 0 === i ? [] : o$1(i))
6309
+ })
6310
+ });
6263
6311
  }
6264
- /**
6265
- * Get the value of a given node if it's a static value.
6266
- * @param {Node} node The node to get.
6267
- * @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.
6268
- * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`.
6269
- */ function getStaticValue$1(node, initialScope = null) {
6270
- try {
6271
- return getStaticValueR(node, initialScope);
6272
- } catch (_error) {
6273
- return null;
6274
- }
6312
+ function v$1(t) {
6313
+ return "number" == typeof t;
6275
6314
  }
6276
- const typeConversionBinaryOps = Object.freeze(new Set([
6277
- "==",
6278
- "!=",
6279
- "<",
6280
- "<=",
6281
- ">",
6282
- ">=",
6283
- "<<",
6284
- ">>",
6285
- ">>>",
6286
- "+",
6287
- "-",
6288
- "*",
6289
- "/",
6290
- "%",
6291
- "|",
6292
- "^",
6293
- "&",
6294
- "in"
6295
- ]));
6296
- const typeConversionUnaryOps = Object.freeze(new Set([
6297
- "-",
6298
- "+",
6299
- "!",
6300
- "~"
6301
- ]));
6302
- /**
6303
- * Check whether the given value is an ASTNode or not.
6304
- * @param {any} x The value to check.
6305
- * @returns {boolean} `true` if the value is an ASTNode.
6306
- */ function isNode(x) {
6307
- return x !== null && typeof x === "object" && typeof x.type === "string";
6315
+ function b$1(t) {
6316
+ return "string" == typeof t;
6308
6317
  }
6309
- Object.freeze(Object.assign(Object.create(null), {
6310
- $visit (node, options, visitorKeys) {
6311
- const { type } = node;
6312
- if (typeof this[type] === "function") {
6313
- return this[type](node, options, visitorKeys);
6314
- }
6315
- return this.$visitChildren(node, options, visitorKeys);
6316
- },
6317
- $visitChildren (node, options, visitorKeys) {
6318
- const { type } = node;
6319
- for (const key of visitorKeys[type] || getKeys(node)){
6320
- const value = node[key];
6321
- if (Array.isArray(value)) {
6322
- for (const element of value){
6323
- if (isNode(element) && this.$visit(element, options, visitorKeys)) {
6324
- return true;
6325
- }
6326
- }
6327
- } else if (isNode(value) && this.$visit(value, options, visitorKeys)) {
6328
- return true;
6329
- }
6330
- }
6331
- return false;
6332
- },
6333
- ArrowFunctionExpression () {
6334
- return false;
6335
- },
6336
- AssignmentExpression () {
6337
- return true;
6338
- },
6339
- AwaitExpression () {
6340
- return true;
6341
- },
6342
- BinaryExpression (node, options, visitorKeys) {
6343
- if (options.considerImplicitTypeConversion && typeConversionBinaryOps.has(node.operator) && (node.left.type !== "Literal" || node.right.type !== "Literal")) {
6344
- return true;
6345
- }
6346
- return this.$visitChildren(node, options, visitorKeys);
6347
- },
6348
- CallExpression () {
6349
- return true;
6350
- },
6351
- FunctionExpression () {
6352
- return false;
6353
- },
6354
- ImportExpression () {
6355
- return true;
6356
- },
6357
- MemberExpression (node, options, visitorKeys) {
6358
- if (options.considerGetters) {
6359
- return true;
6360
- }
6361
- if (options.considerImplicitTypeConversion && node.computed && node.property.type !== "Literal") {
6362
- return true;
6363
- }
6364
- return this.$visitChildren(node, options, visitorKeys);
6365
- },
6366
- MethodDefinition (node, options, visitorKeys) {
6367
- if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
6368
- return true;
6369
- }
6370
- return this.$visitChildren(node, options, visitorKeys);
6371
- },
6372
- NewExpression () {
6373
- return true;
6374
- },
6375
- Property (node, options, visitorKeys) {
6376
- if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
6377
- return true;
6378
- }
6379
- return this.$visitChildren(node, options, visitorKeys);
6380
- },
6381
- PropertyDefinition (node, options, visitorKeys) {
6382
- if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
6383
- return true;
6384
- }
6385
- return this.$visitChildren(node, options, visitorKeys);
6386
- },
6387
- UnaryExpression (node, options, visitorKeys) {
6388
- if (node.operator === "delete") {
6389
- return true;
6390
- }
6391
- if (options.considerImplicitTypeConversion && typeConversionUnaryOps.has(node.operator) && node.argument.type !== "Literal") {
6392
- return true;
6318
+ function w$1(t) {
6319
+ return "bigint" == typeof t;
6320
+ }
6321
+ u$1(d$1(function(t) {
6322
+ return !0;
6323
+ }));
6324
+ const j$1 = (t)=>Object.assign(u$1(t), {
6325
+ startsWith: (e)=>{
6326
+ return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.startsWith(n)))));
6327
+ var n;
6328
+ },
6329
+ endsWith: (e)=>{
6330
+ return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.endsWith(n)))));
6331
+ var n;
6332
+ },
6333
+ minLength: (e)=>j$1(m$1(t, ((t)=>d$1((e)=>b$1(e) && e.length >= t))(e))),
6334
+ maxLength: (e)=>j$1(m$1(t, ((t)=>d$1((e)=>b$1(e) && e.length <= t))(e))),
6335
+ includes: (e)=>{
6336
+ return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.includes(n)))));
6337
+ var n;
6338
+ },
6339
+ regex: (e)=>{
6340
+ return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && Boolean(t.match(n))))));
6341
+ var n;
6393
6342
  }
6394
- return this.$visitChildren(node, options, visitorKeys);
6395
- },
6396
- UpdateExpression () {
6397
- return true;
6398
- },
6399
- YieldExpression () {
6400
- return true;
6401
- }
6343
+ });
6344
+ j$1(d$1(b$1));
6345
+ const K$1 = (t)=>Object.assign(u$1(t), {
6346
+ between: (e, n)=>K$1(m$1(t, ((t, e)=>d$1((n)=>v$1(n) && t <= n && e >= n))(e, n))),
6347
+ lt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e < t))(e))),
6348
+ gt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e > t))(e))),
6349
+ lte: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e <= t))(e))),
6350
+ gte: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e >= t))(e))),
6351
+ int: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isInteger(t)))),
6352
+ finite: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isFinite(t)))),
6353
+ positive: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t > 0))),
6354
+ negative: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t < 0)))
6355
+ });
6356
+ K$1(d$1(v$1));
6357
+ const x$1 = (t)=>Object.assign(u$1(t), {
6358
+ between: (e, n)=>x$1(m$1(t, ((t, e)=>d$1((n)=>w$1(n) && t <= n && e >= n))(e, n))),
6359
+ lt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e < t))(e))),
6360
+ gt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e > t))(e))),
6361
+ lte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e <= t))(e))),
6362
+ gte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e >= t))(e))),
6363
+ positive: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t > 0))),
6364
+ negative: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t < 0)))
6365
+ });
6366
+ x$1(d$1(w$1));
6367
+ u$1(d$1(function(t) {
6368
+ return "boolean" == typeof t;
6402
6369
  }));
6403
- Function.call.bind(Object.hasOwnProperty);
6370
+ u$1(d$1(function(t) {
6371
+ return "symbol" == typeof t;
6372
+ }));
6373
+ u$1(d$1(function(t) {
6374
+ return null == t;
6375
+ }));
6376
+ const NodeType = AST_NODE_TYPES;
6377
+ const is = ASTUtils.isNodeOfType;
6378
+ const isOneOf = ASTUtils.isNodeOfTypes;
6379
+ isOneOf([
6380
+ NodeType.ArrowFunctionExpression,
6381
+ NodeType.FunctionDeclaration,
6382
+ NodeType.FunctionExpression
6383
+ ]);
6384
+ isOneOf([
6385
+ NodeType.ArrowFunctionExpression,
6386
+ NodeType.FunctionDeclaration,
6387
+ NodeType.FunctionExpression,
6388
+ NodeType.TSCallSignatureDeclaration,
6389
+ NodeType.TSConstructSignatureDeclaration,
6390
+ NodeType.TSDeclareFunction,
6391
+ NodeType.TSEmptyBodyFunctionExpression,
6392
+ NodeType.TSFunctionType,
6393
+ NodeType.TSMethodSignature
6394
+ ]);
6395
+ isOneOf([
6396
+ NodeType.ClassDeclaration,
6397
+ NodeType.ClassExpression
6398
+ ]);
6399
+ isOneOf([
6400
+ NodeType.DoWhileStatement,
6401
+ NodeType.ForInStatement,
6402
+ NodeType.ForOfStatement,
6403
+ NodeType.ForStatement,
6404
+ NodeType.WhileStatement
6405
+ ]);
6406
+ isOneOf([
6407
+ NodeType.TSArrayType,
6408
+ NodeType.TSTupleType
6409
+ ]);
6410
+ isOneOf([
6411
+ NodeType.PropertyDefinition,
6412
+ NodeType.TSIndexSignature,
6413
+ NodeType.TSParameterProperty,
6414
+ NodeType.TSPropertySignature
6415
+ ]);
6416
+ is(NodeType.JSXElement);
6417
+ is(NodeType.JSXFragment);
6418
+ isOneOf([
6419
+ NodeType.JSXAttribute,
6420
+ NodeType.JSXSpreadChild,
6421
+ NodeType.JSXClosingElement,
6422
+ NodeType.JSXClosingFragment,
6423
+ NodeType.JSXElement,
6424
+ NodeType.JSXEmptyExpression,
6425
+ NodeType.JSXExpressionContainer,
6426
+ NodeType.JSXFragment,
6427
+ NodeType.JSXIdentifier,
6428
+ NodeType.JSXMemberExpression,
6429
+ NodeType.JSXNamespacedName,
6430
+ NodeType.JSXOpeningElement,
6431
+ NodeType.JSXOpeningFragment,
6432
+ NodeType.JSXSpreadAttribute,
6433
+ NodeType.JSXSpreadChild,
6434
+ NodeType.JSXText
6435
+ ]);
6436
+ const isJSXTagNameExpression = isOneOf([
6437
+ NodeType.JSXIdentifier,
6438
+ NodeType.JSXMemberExpression,
6439
+ NodeType.JSXNamespacedName
6440
+ ]);
6441
+ isOneOf([
6442
+ NodeType.ArrayPattern,
6443
+ NodeType.AssignmentPattern,
6444
+ NodeType.ObjectPattern,
6445
+ NodeType.RestElement
6446
+ ]);
6447
+ isOneOf([
6448
+ NodeType.TSInterfaceDeclaration,
6449
+ NodeType.TSTypeAliasDeclaration
6450
+ ]);
6451
+ isOneOf([
6452
+ NodeType.ArrayExpression,
6453
+ NodeType.ArrayPattern,
6454
+ NodeType.ArrowFunctionExpression,
6455
+ NodeType.CallExpression,
6456
+ NodeType.ClassExpression,
6457
+ NodeType.FunctionExpression,
6458
+ NodeType.Identifier,
6459
+ NodeType.JSXElement,
6460
+ NodeType.JSXFragment,
6461
+ NodeType.Literal,
6462
+ NodeType.TemplateLiteral,
6463
+ NodeType.MemberExpression,
6464
+ NodeType.MetaProperty,
6465
+ NodeType.ObjectExpression,
6466
+ NodeType.ObjectPattern,
6467
+ NodeType.SequenceExpression,
6468
+ NodeType.Super,
6469
+ NodeType.TaggedTemplateExpression,
6470
+ NodeType.ThisExpression
6471
+ ]);
6472
+ isOneOf([
6473
+ NodeType.ArrayExpression,
6474
+ NodeType.ArrayPattern,
6475
+ NodeType.ArrowFunctionExpression,
6476
+ NodeType.CallExpression,
6477
+ NodeType.ClassExpression,
6478
+ NodeType.FunctionExpression,
6479
+ NodeType.Identifier,
6480
+ NodeType.JSXElement,
6481
+ NodeType.JSXFragment,
6482
+ NodeType.Literal,
6483
+ NodeType.TemplateLiteral,
6484
+ NodeType.MemberExpression,
6485
+ NodeType.MetaProperty,
6486
+ NodeType.ObjectExpression,
6487
+ NodeType.ObjectPattern,
6488
+ NodeType.SequenceExpression,
6489
+ NodeType.Super,
6490
+ NodeType.TaggedTemplateExpression,
6491
+ NodeType.ThisExpression,
6492
+ NodeType.TSAsExpression,
6493
+ NodeType.TSNonNullExpression,
6494
+ NodeType.TSTypeAssertion
6495
+ ]);
6496
+ const Construction = effectData_esm.taggedEnum();
6497
+ Construction.None();
6498
+ [
6499
+ NodeType.JSXElement,
6500
+ NodeType.ArrayExpression,
6501
+ NodeType.ObjectExpression,
6502
+ NodeType.FunctionExpression,
6503
+ NodeType.ArrowFunctionExpression,
6504
+ NodeType.ClassExpression,
6505
+ NodeType.NewExpression,
6506
+ NodeType.CallExpression
6507
+ ];
6404
6508
  /**
6405
6509
  * Get the value of a given node if it can decide the value statically.
6406
6510
  * If the 2nd parameter `initialScope` was given, this function tries to resolve identifier references which are in the