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