@dcf-micro/eslint-config 5.0.0

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 (46) hide show
  1. package/dist/chunks/eslint-plugin-prettier.mjs +1716 -0
  2. package/dist/chunks/index.mjs +1341 -0
  3. package/dist/chunks/index10.mjs +39595 -0
  4. package/dist/chunks/index11.mjs +24 -0
  5. package/dist/chunks/index12.mjs +75273 -0
  6. package/dist/chunks/index13.mjs +55129 -0
  7. package/dist/chunks/index14.mjs +24 -0
  8. package/dist/chunks/index15.mjs +1441 -0
  9. package/dist/chunks/index2.mjs +31864 -0
  10. package/dist/chunks/index3.mjs +8154 -0
  11. package/dist/chunks/index4.mjs +24 -0
  12. package/dist/chunks/index5.mjs +44093 -0
  13. package/dist/chunks/index6.mjs +10371 -0
  14. package/dist/chunks/index7.mjs +21890 -0
  15. package/dist/chunks/index8.mjs +14424 -0
  16. package/dist/chunks/index9.mjs +194 -0
  17. package/dist/chunks/jiti.mjs +320 -0
  18. package/dist/index.d.mts +3897 -0
  19. package/dist/index.d.ts +3897 -0
  20. package/dist/index.mjs +4 -0
  21. package/dist/shared/eslint-config.BDBLGvXj.mjs +5282 -0
  22. package/dist/shared/eslint-config.BEdqg1el.mjs +12256 -0
  23. package/dist/shared/eslint-config.BKmXKm8B.mjs +5533 -0
  24. package/dist/shared/eslint-config.BjUMgISS.mjs +9012 -0
  25. package/dist/shared/eslint-config.Bk-3rH6Y.mjs +1355 -0
  26. package/dist/shared/eslint-config.BytuZ0Ec.mjs +20 -0
  27. package/dist/shared/eslint-config.C1V0I4Np.mjs +16900 -0
  28. package/dist/shared/eslint-config.CGxZQKHV.mjs +2091 -0
  29. package/dist/shared/eslint-config.COweQ1RR.mjs +5 -0
  30. package/dist/shared/eslint-config.CSnk9Q4w.mjs +9339 -0
  31. package/dist/shared/eslint-config.CWvTq0mr.mjs +2914 -0
  32. package/dist/shared/eslint-config.Ca4PTK8E.mjs +646 -0
  33. package/dist/shared/eslint-config.CmPTszkJ.mjs +3583 -0
  34. package/dist/shared/eslint-config.CqEANaNA.mjs +139622 -0
  35. package/dist/shared/eslint-config.CsePEcYJ.mjs +71 -0
  36. package/dist/shared/eslint-config.Cw6mETSZ.mjs +2580 -0
  37. package/dist/shared/eslint-config.DTVnsecK.mjs +1751 -0
  38. package/dist/shared/eslint-config.DWoU09EE.mjs +6958 -0
  39. package/dist/shared/eslint-config.DZvqTQUU.mjs +3818 -0
  40. package/dist/shared/eslint-config.Dhg7lT0g.mjs +1807 -0
  41. package/dist/shared/eslint-config.Du5y5qmf.mjs +200673 -0
  42. package/dist/shared/eslint-config.FKVuBSa4.mjs +394 -0
  43. package/dist/shared/eslint-config.I8d-HnmI.mjs +2654 -0
  44. package/dist/shared/eslint-config.YntqsQY1.mjs +40 -0
  45. package/dist/shared/eslint-config.uGTBNMD0.mjs +687 -0
  46. package/package.json +56 -0
@@ -0,0 +1,3818 @@
1
+ import { c as commonjsGlobal } from './eslint-config.BDBLGvXj.mjs';
2
+ import { r as requireEslintVisitorKeys } from './eslint-config.FKVuBSa4.mjs';
3
+ import { r as requireDist$1, a as requireDist$2 } from './eslint-config.CSnk9Q4w.mjs';
4
+ import { r as requireUnsupportedApi } from './eslint-config.YntqsQY1.mjs';
5
+ import { r as requireApi } from './eslint-config.DTVnsecK.mjs';
6
+
7
+ var dist = {};
8
+
9
+ var astUtils = {};
10
+
11
+ var eslintUtils$2 = {};
12
+
13
+ var astUtilities = {};
14
+
15
+ var eslintUtils$1 = {};
16
+
17
+ var hasRequiredEslintUtils$2;
18
+
19
+ function requireEslintUtils$2 () {
20
+ if (hasRequiredEslintUtils$2) return eslintUtils$1;
21
+ hasRequiredEslintUtils$2 = 1;
22
+ (function (exports) {
23
+
24
+ Object.defineProperty(exports, '__esModule', { value: true });
25
+
26
+ var eslintVisitorKeys = requireEslintVisitorKeys();
27
+
28
+ /** @typedef {import("eslint").Scope.Scope} Scope */
29
+ /** @typedef {import("estree").Node} Node */
30
+
31
+ /**
32
+ * Get the innermost scope which contains a given location.
33
+ * @param {Scope} initialScope The initial scope to search.
34
+ * @param {Node} node The location to search.
35
+ * @returns {Scope} The innermost scope.
36
+ */
37
+ function getInnermostScope(initialScope, node) {
38
+ const location = /** @type {[number, number]} */ (node.range)[0];
39
+
40
+ let scope = initialScope;
41
+ let found = false;
42
+ do {
43
+ found = false;
44
+ for (const childScope of scope.childScopes) {
45
+ const range = /** @type {[number, number]} */ (
46
+ childScope.block.range
47
+ );
48
+
49
+ if (range[0] <= location && location < range[1]) {
50
+ scope = childScope;
51
+ found = true;
52
+ break
53
+ }
54
+ }
55
+ } while (found)
56
+
57
+ return scope
58
+ }
59
+
60
+ /** @typedef {import("eslint").Scope.Scope} Scope */
61
+ /** @typedef {import("eslint").Scope.Variable} Variable */
62
+ /** @typedef {import("estree").Identifier} Identifier */
63
+
64
+ /**
65
+ * Find the variable of a given name.
66
+ * @param {Scope} initialScope The scope to start finding.
67
+ * @param {string|Identifier} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node.
68
+ * @returns {Variable|null} The found variable or null.
69
+ */
70
+ function findVariable(initialScope, nameOrNode) {
71
+ let name = "";
72
+ /** @type {Scope|null} */
73
+ let scope = initialScope;
74
+
75
+ if (typeof nameOrNode === "string") {
76
+ name = nameOrNode;
77
+ } else {
78
+ name = nameOrNode.name;
79
+ scope = getInnermostScope(scope, nameOrNode);
80
+ }
81
+
82
+ while (scope != null) {
83
+ const variable = scope.set.get(name);
84
+ if (variable != null) {
85
+ return variable
86
+ }
87
+ scope = scope.upper;
88
+ }
89
+
90
+ return null
91
+ }
92
+
93
+ /** @typedef {import("eslint").AST.Token} Token */
94
+ /** @typedef {import("estree").Comment} Comment */
95
+ /** @typedef {import("./types.mjs").ArrowToken} ArrowToken */
96
+ /** @typedef {import("./types.mjs").CommaToken} CommaToken */
97
+ /** @typedef {import("./types.mjs").SemicolonToken} SemicolonToken */
98
+ /** @typedef {import("./types.mjs").ColonToken} ColonToken */
99
+ /** @typedef {import("./types.mjs").OpeningParenToken} OpeningParenToken */
100
+ /** @typedef {import("./types.mjs").ClosingParenToken} ClosingParenToken */
101
+ /** @typedef {import("./types.mjs").OpeningBracketToken} OpeningBracketToken */
102
+ /** @typedef {import("./types.mjs").ClosingBracketToken} ClosingBracketToken */
103
+ /** @typedef {import("./types.mjs").OpeningBraceToken} OpeningBraceToken */
104
+ /** @typedef {import("./types.mjs").ClosingBraceToken} ClosingBraceToken */
105
+ /**
106
+ * @template {string} Value
107
+ * @typedef {import("./types.mjs").PunctuatorToken<Value>} PunctuatorToken
108
+ */
109
+
110
+ /** @typedef {Comment | Token} CommentOrToken */
111
+
112
+ /**
113
+ * Creates the negate function of the given function.
114
+ * @param {function(CommentOrToken):boolean} f - The function to negate.
115
+ * @returns {function(CommentOrToken):boolean} Negated function.
116
+ */
117
+ function negate(f) {
118
+ return (token) => !f(token)
119
+ }
120
+
121
+ /**
122
+ * Checks if the given token is a PunctuatorToken with the given value
123
+ * @template {string} Value
124
+ * @param {CommentOrToken} token - The token to check.
125
+ * @param {Value} value - The value to check.
126
+ * @returns {token is PunctuatorToken<Value>} `true` if the token is a PunctuatorToken with the given value.
127
+ */
128
+ function isPunctuatorTokenWithValue(token, value) {
129
+ return token.type === "Punctuator" && token.value === value
130
+ }
131
+
132
+ /**
133
+ * Checks if the given token is an arrow token or not.
134
+ * @param {CommentOrToken} token - The token to check.
135
+ * @returns {token is ArrowToken} `true` if the token is an arrow token.
136
+ */
137
+ function isArrowToken(token) {
138
+ return isPunctuatorTokenWithValue(token, "=>")
139
+ }
140
+
141
+ /**
142
+ * Checks if the given token is a comma token or not.
143
+ * @param {CommentOrToken} token - The token to check.
144
+ * @returns {token is CommaToken} `true` if the token is a comma token.
145
+ */
146
+ function isCommaToken(token) {
147
+ return isPunctuatorTokenWithValue(token, ",")
148
+ }
149
+
150
+ /**
151
+ * Checks if the given token is a semicolon token or not.
152
+ * @param {CommentOrToken} token - The token to check.
153
+ * @returns {token is SemicolonToken} `true` if the token is a semicolon token.
154
+ */
155
+ function isSemicolonToken(token) {
156
+ return isPunctuatorTokenWithValue(token, ";")
157
+ }
158
+
159
+ /**
160
+ * Checks if the given token is a colon token or not.
161
+ * @param {CommentOrToken} token - The token to check.
162
+ * @returns {token is ColonToken} `true` if the token is a colon token.
163
+ */
164
+ function isColonToken(token) {
165
+ return isPunctuatorTokenWithValue(token, ":")
166
+ }
167
+
168
+ /**
169
+ * Checks if the given token is an opening parenthesis token or not.
170
+ * @param {CommentOrToken} token - The token to check.
171
+ * @returns {token is OpeningParenToken} `true` if the token is an opening parenthesis token.
172
+ */
173
+ function isOpeningParenToken(token) {
174
+ return isPunctuatorTokenWithValue(token, "(")
175
+ }
176
+
177
+ /**
178
+ * Checks if the given token is a closing parenthesis token or not.
179
+ * @param {CommentOrToken} token - The token to check.
180
+ * @returns {token is ClosingParenToken} `true` if the token is a closing parenthesis token.
181
+ */
182
+ function isClosingParenToken(token) {
183
+ return isPunctuatorTokenWithValue(token, ")")
184
+ }
185
+
186
+ /**
187
+ * Checks if the given token is an opening square bracket token or not.
188
+ * @param {CommentOrToken} token - The token to check.
189
+ * @returns {token is OpeningBracketToken} `true` if the token is an opening square bracket token.
190
+ */
191
+ function isOpeningBracketToken(token) {
192
+ return isPunctuatorTokenWithValue(token, "[")
193
+ }
194
+
195
+ /**
196
+ * Checks if the given token is a closing square bracket token or not.
197
+ * @param {CommentOrToken} token - The token to check.
198
+ * @returns {token is ClosingBracketToken} `true` if the token is a closing square bracket token.
199
+ */
200
+ function isClosingBracketToken(token) {
201
+ return isPunctuatorTokenWithValue(token, "]")
202
+ }
203
+
204
+ /**
205
+ * Checks if the given token is an opening brace token or not.
206
+ * @param {CommentOrToken} token - The token to check.
207
+ * @returns {token is OpeningBraceToken} `true` if the token is an opening brace token.
208
+ */
209
+ function isOpeningBraceToken(token) {
210
+ return isPunctuatorTokenWithValue(token, "{")
211
+ }
212
+
213
+ /**
214
+ * Checks if the given token is a closing brace token or not.
215
+ * @param {CommentOrToken} token - The token to check.
216
+ * @returns {token is ClosingBraceToken} `true` if the token is a closing brace token.
217
+ */
218
+ function isClosingBraceToken(token) {
219
+ return isPunctuatorTokenWithValue(token, "}")
220
+ }
221
+
222
+ /**
223
+ * Checks if the given token is a comment token or not.
224
+ * @param {CommentOrToken} token - The token to check.
225
+ * @returns {token is Comment} `true` if the token is a comment token.
226
+ */
227
+ function isCommentToken(token) {
228
+ return ["Block", "Line", "Shebang"].includes(token.type)
229
+ }
230
+
231
+ const isNotArrowToken = negate(isArrowToken);
232
+ const isNotCommaToken = negate(isCommaToken);
233
+ const isNotSemicolonToken = negate(isSemicolonToken);
234
+ const isNotColonToken = negate(isColonToken);
235
+ const isNotOpeningParenToken = negate(isOpeningParenToken);
236
+ const isNotClosingParenToken = negate(isClosingParenToken);
237
+ const isNotOpeningBracketToken = negate(isOpeningBracketToken);
238
+ const isNotClosingBracketToken = negate(isClosingBracketToken);
239
+ const isNotOpeningBraceToken = negate(isOpeningBraceToken);
240
+ const isNotClosingBraceToken = negate(isClosingBraceToken);
241
+ const isNotCommentToken = negate(isCommentToken);
242
+
243
+ /** @typedef {import("eslint").Rule.Node} RuleNode */
244
+ /** @typedef {import("eslint").SourceCode} SourceCode */
245
+ /** @typedef {import("eslint").AST.Token} Token */
246
+ /** @typedef {import("estree").Function} FunctionNode */
247
+ /** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
248
+ /** @typedef {import("estree").FunctionExpression} FunctionExpression */
249
+ /** @typedef {import("estree").SourceLocation} SourceLocation */
250
+ /** @typedef {import("estree").Position} Position */
251
+
252
+ /**
253
+ * Get the `(` token of the given function node.
254
+ * @param {FunctionExpression | FunctionDeclaration} node - The function node to get.
255
+ * @param {SourceCode} sourceCode - The source code object to get tokens.
256
+ * @returns {Token} `(` token.
257
+ */
258
+ function getOpeningParenOfParams(node, sourceCode) {
259
+ return node.id
260
+ ? /** @type {Token} */ (
261
+ sourceCode.getTokenAfter(node.id, isOpeningParenToken)
262
+ )
263
+ : /** @type {Token} */ (
264
+ sourceCode.getFirstToken(node, isOpeningParenToken)
265
+ )
266
+ }
267
+
268
+ /**
269
+ * Get the location of the given function node for reporting.
270
+ * @param {FunctionNode} node - The function node to get.
271
+ * @param {SourceCode} sourceCode - The source code object to get tokens.
272
+ * @returns {SourceLocation|null} The location of the function node for reporting.
273
+ */
274
+ function getFunctionHeadLocation(node, sourceCode) {
275
+ const parent = /** @type {RuleNode} */ (node).parent;
276
+
277
+ /** @type {Position|null} */
278
+ let start = null;
279
+ /** @type {Position|null} */
280
+ let end = null;
281
+
282
+ if (node.type === "ArrowFunctionExpression") {
283
+ const arrowToken = /** @type {Token} */ (
284
+ sourceCode.getTokenBefore(node.body, isArrowToken)
285
+ );
286
+
287
+ start = arrowToken.loc.start;
288
+ end = arrowToken.loc.end;
289
+ } else if (
290
+ parent.type === "Property" ||
291
+ parent.type === "MethodDefinition" ||
292
+ parent.type === "PropertyDefinition"
293
+ ) {
294
+ start = /** @type {SourceLocation} */ (parent.loc).start;
295
+ end = getOpeningParenOfParams(node, sourceCode).loc.start;
296
+ } else {
297
+ start = /** @type {SourceLocation} */ (node.loc).start;
298
+ end = getOpeningParenOfParams(node, sourceCode).loc.start;
299
+ }
300
+
301
+ return {
302
+ start: { ...start },
303
+ end: { ...end },
304
+ }
305
+ }
306
+
307
+ /* globals globalThis, global, self, window */
308
+ /** @typedef {import("./types.mjs").StaticValue} StaticValue */
309
+ /** @typedef {import("eslint").Scope.Scope} Scope */
310
+ /** @typedef {import("estree").Node} Node */
311
+ /** @typedef {import("@typescript-eslint/types").TSESTree.Node} TSESTreeNode */
312
+ /** @typedef {import("@typescript-eslint/types").TSESTree.AST_NODE_TYPES} TSESTreeNodeTypes */
313
+ /** @typedef {import("@typescript-eslint/types").TSESTree.MemberExpression} MemberExpression */
314
+ /** @typedef {import("@typescript-eslint/types").TSESTree.Property} Property */
315
+ /** @typedef {import("@typescript-eslint/types").TSESTree.RegExpLiteral} RegExpLiteral */
316
+ /** @typedef {import("@typescript-eslint/types").TSESTree.BigIntLiteral} BigIntLiteral */
317
+ /** @typedef {import("@typescript-eslint/types").TSESTree.Literal} Literal */
318
+
319
+ const globalObject =
320
+ typeof globalThis !== "undefined"
321
+ ? globalThis
322
+ : // @ts-ignore
323
+ typeof self !== "undefined"
324
+ ? // @ts-ignore
325
+ self
326
+ : // @ts-ignore
327
+ typeof window !== "undefined"
328
+ ? // @ts-ignore
329
+ window
330
+ : typeof commonjsGlobal !== "undefined"
331
+ ? commonjsGlobal
332
+ : {};
333
+
334
+ const builtinNames = Object.freeze(
335
+ new Set([
336
+ "Array",
337
+ "ArrayBuffer",
338
+ "BigInt",
339
+ "BigInt64Array",
340
+ "BigUint64Array",
341
+ "Boolean",
342
+ "DataView",
343
+ "Date",
344
+ "decodeURI",
345
+ "decodeURIComponent",
346
+ "encodeURI",
347
+ "encodeURIComponent",
348
+ "escape",
349
+ "Float32Array",
350
+ "Float64Array",
351
+ "Function",
352
+ "Infinity",
353
+ "Int16Array",
354
+ "Int32Array",
355
+ "Int8Array",
356
+ "isFinite",
357
+ "isNaN",
358
+ "isPrototypeOf",
359
+ "JSON",
360
+ "Map",
361
+ "Math",
362
+ "NaN",
363
+ "Number",
364
+ "Object",
365
+ "parseFloat",
366
+ "parseInt",
367
+ "Promise",
368
+ "Proxy",
369
+ "Reflect",
370
+ "RegExp",
371
+ "Set",
372
+ "String",
373
+ "Symbol",
374
+ "Uint16Array",
375
+ "Uint32Array",
376
+ "Uint8Array",
377
+ "Uint8ClampedArray",
378
+ "undefined",
379
+ "unescape",
380
+ "WeakMap",
381
+ "WeakSet",
382
+ ]),
383
+ );
384
+ const callAllowed = new Set(
385
+ [
386
+ Array.isArray,
387
+ Array.of,
388
+ Array.prototype.at,
389
+ Array.prototype.concat,
390
+ Array.prototype.entries,
391
+ Array.prototype.every,
392
+ Array.prototype.filter,
393
+ Array.prototype.find,
394
+ Array.prototype.findIndex,
395
+ Array.prototype.flat,
396
+ Array.prototype.includes,
397
+ Array.prototype.indexOf,
398
+ Array.prototype.join,
399
+ Array.prototype.keys,
400
+ Array.prototype.lastIndexOf,
401
+ Array.prototype.slice,
402
+ Array.prototype.some,
403
+ Array.prototype.toString,
404
+ Array.prototype.values,
405
+ typeof BigInt === "function" ? BigInt : undefined,
406
+ Boolean,
407
+ Date,
408
+ Date.parse,
409
+ decodeURI,
410
+ decodeURIComponent,
411
+ encodeURI,
412
+ encodeURIComponent,
413
+ escape,
414
+ isFinite,
415
+ isNaN,
416
+ // @ts-ignore
417
+ isPrototypeOf,
418
+ Map,
419
+ Map.prototype.entries,
420
+ Map.prototype.get,
421
+ Map.prototype.has,
422
+ Map.prototype.keys,
423
+ Map.prototype.values,
424
+ .../** @type {(keyof typeof Math)[]} */ (
425
+ Object.getOwnPropertyNames(Math)
426
+ )
427
+ .filter((k) => k !== "random")
428
+ .map((k) => Math[k])
429
+ .filter((f) => typeof f === "function"),
430
+ Number,
431
+ Number.isFinite,
432
+ Number.isNaN,
433
+ Number.parseFloat,
434
+ Number.parseInt,
435
+ Number.prototype.toExponential,
436
+ Number.prototype.toFixed,
437
+ Number.prototype.toPrecision,
438
+ Number.prototype.toString,
439
+ Object,
440
+ Object.entries,
441
+ Object.is,
442
+ Object.isExtensible,
443
+ Object.isFrozen,
444
+ Object.isSealed,
445
+ Object.keys,
446
+ Object.values,
447
+ parseFloat,
448
+ parseInt,
449
+ RegExp,
450
+ Set,
451
+ Set.prototype.entries,
452
+ Set.prototype.has,
453
+ Set.prototype.keys,
454
+ Set.prototype.values,
455
+ String,
456
+ String.fromCharCode,
457
+ String.fromCodePoint,
458
+ String.raw,
459
+ String.prototype.at,
460
+ String.prototype.charAt,
461
+ String.prototype.charCodeAt,
462
+ String.prototype.codePointAt,
463
+ String.prototype.concat,
464
+ String.prototype.endsWith,
465
+ String.prototype.includes,
466
+ String.prototype.indexOf,
467
+ String.prototype.lastIndexOf,
468
+ String.prototype.normalize,
469
+ String.prototype.padEnd,
470
+ String.prototype.padStart,
471
+ String.prototype.slice,
472
+ String.prototype.startsWith,
473
+ String.prototype.substr,
474
+ String.prototype.substring,
475
+ String.prototype.toLowerCase,
476
+ String.prototype.toString,
477
+ String.prototype.toUpperCase,
478
+ String.prototype.trim,
479
+ String.prototype.trimEnd,
480
+ String.prototype.trimLeft,
481
+ String.prototype.trimRight,
482
+ String.prototype.trimStart,
483
+ Symbol.for,
484
+ Symbol.keyFor,
485
+ unescape,
486
+ ].filter((f) => typeof f === "function"),
487
+ );
488
+ const callPassThrough = new Set([
489
+ Object.freeze,
490
+ Object.preventExtensions,
491
+ Object.seal,
492
+ ]);
493
+
494
+ /** @type {ReadonlyArray<readonly [Function, ReadonlySet<string>]>} */
495
+ const getterAllowed = [
496
+ [Map, new Set(["size"])],
497
+ [
498
+ RegExp,
499
+ new Set([
500
+ "dotAll",
501
+ "flags",
502
+ "global",
503
+ "hasIndices",
504
+ "ignoreCase",
505
+ "multiline",
506
+ "source",
507
+ "sticky",
508
+ "unicode",
509
+ ]),
510
+ ],
511
+ [Set, new Set(["size"])],
512
+ ];
513
+
514
+ /**
515
+ * Get the property descriptor.
516
+ * @param {object} object The object to get.
517
+ * @param {string|number|symbol} name The property name to get.
518
+ */
519
+ function getPropertyDescriptor(object, name) {
520
+ let x = object;
521
+ while ((typeof x === "object" || typeof x === "function") && x !== null) {
522
+ const d = Object.getOwnPropertyDescriptor(x, name);
523
+ if (d) {
524
+ return d
525
+ }
526
+ x = Object.getPrototypeOf(x);
527
+ }
528
+ return null
529
+ }
530
+
531
+ /**
532
+ * Check if a property is getter or not.
533
+ * @param {object} object The object to check.
534
+ * @param {string|number|symbol} name The property name to check.
535
+ */
536
+ function isGetter(object, name) {
537
+ const d = getPropertyDescriptor(object, name);
538
+ return d != null && d.get != null
539
+ }
540
+
541
+ /**
542
+ * Get the element values of a given node list.
543
+ * @param {(Node|TSESTreeNode|null)[]} nodeList The node list to get values.
544
+ * @param {Scope|undefined|null} initialScope The initial scope to find variables.
545
+ * @returns {any[]|null} The value list if all nodes are constant. Otherwise, null.
546
+ */
547
+ function getElementValues(nodeList, initialScope) {
548
+ const valueList = [];
549
+
550
+ for (let i = 0; i < nodeList.length; ++i) {
551
+ const elementNode = nodeList[i];
552
+
553
+ if (elementNode == null) {
554
+ valueList.length = i + 1;
555
+ } else if (elementNode.type === "SpreadElement") {
556
+ const argument = getStaticValueR(elementNode.argument, initialScope);
557
+ if (argument == null) {
558
+ return null
559
+ }
560
+ valueList.push(.../** @type {Iterable<any>} */ (argument.value));
561
+ } else {
562
+ const element = getStaticValueR(elementNode, initialScope);
563
+ if (element == null) {
564
+ return null
565
+ }
566
+ valueList.push(element.value);
567
+ }
568
+ }
569
+
570
+ return valueList
571
+ }
572
+
573
+ /**
574
+ * Returns whether the given variable is never written to after initialization.
575
+ * @param {import("eslint").Scope.Variable} variable
576
+ * @returns {boolean}
577
+ */
578
+ function isEffectivelyConst(variable) {
579
+ const refs = variable.references;
580
+
581
+ const inits = refs.filter((r) => r.init).length;
582
+ const reads = refs.filter((r) => r.isReadOnly()).length;
583
+ if (inits === 1 && reads + inits === refs.length) {
584
+ // there is only one init and all other references only read
585
+ return true
586
+ }
587
+ return false
588
+ }
589
+
590
+ /**
591
+ * @template {TSESTreeNodeTypes} T
592
+ * @callback VisitorCallback
593
+ * @param {TSESTreeNode & { type: T }} node
594
+ * @param {Scope|undefined|null} initialScope
595
+ * @returns {StaticValue | null}
596
+ */
597
+ /**
598
+ * @typedef { { [K in TSESTreeNodeTypes]?: VisitorCallback<K> } } Operations
599
+ */
600
+ /**
601
+ * @type {Operations}
602
+ */
603
+ const operations = Object.freeze({
604
+ ArrayExpression(node, initialScope) {
605
+ const elements = getElementValues(node.elements, initialScope);
606
+ return elements != null ? { value: elements } : null
607
+ },
608
+
609
+ AssignmentExpression(node, initialScope) {
610
+ if (node.operator === "=") {
611
+ return getStaticValueR(node.right, initialScope)
612
+ }
613
+ return null
614
+ },
615
+
616
+ //eslint-disable-next-line complexity
617
+ BinaryExpression(node, initialScope) {
618
+ if (node.operator === "in" || node.operator === "instanceof") {
619
+ // Not supported.
620
+ return null
621
+ }
622
+
623
+ const left = getStaticValueR(node.left, initialScope);
624
+ const right = getStaticValueR(node.right, initialScope);
625
+ if (left != null && right != null) {
626
+ switch (node.operator) {
627
+ case "==":
628
+ return { value: left.value == right.value } //eslint-disable-line eqeqeq
629
+ case "!=":
630
+ return { value: left.value != right.value } //eslint-disable-line eqeqeq
631
+ case "===":
632
+ return { value: left.value === right.value }
633
+ case "!==":
634
+ return { value: left.value !== right.value }
635
+ case "<":
636
+ return {
637
+ value:
638
+ /** @type {any} */ (left.value) <
639
+ /** @type {any} */ (right.value),
640
+ }
641
+ case "<=":
642
+ return {
643
+ value:
644
+ /** @type {any} */ (left.value) <=
645
+ /** @type {any} */ (right.value),
646
+ }
647
+ case ">":
648
+ return {
649
+ value:
650
+ /** @type {any} */ (left.value) >
651
+ /** @type {any} */ (right.value),
652
+ }
653
+ case ">=":
654
+ return {
655
+ value:
656
+ /** @type {any} */ (left.value) >=
657
+ /** @type {any} */ (right.value),
658
+ }
659
+ case "<<":
660
+ return {
661
+ value:
662
+ /** @type {any} */ (left.value) <<
663
+ /** @type {any} */ (right.value),
664
+ }
665
+ case ">>":
666
+ return {
667
+ value:
668
+ /** @type {any} */ (left.value) >>
669
+ /** @type {any} */ (right.value),
670
+ }
671
+ case ">>>":
672
+ return {
673
+ value:
674
+ /** @type {any} */ (left.value) >>>
675
+ /** @type {any} */ (right.value),
676
+ }
677
+ case "+":
678
+ return {
679
+ value:
680
+ /** @type {any} */ (left.value) +
681
+ /** @type {any} */ (right.value),
682
+ }
683
+ case "-":
684
+ return {
685
+ value:
686
+ /** @type {any} */ (left.value) -
687
+ /** @type {any} */ (right.value),
688
+ }
689
+ case "*":
690
+ return {
691
+ value:
692
+ /** @type {any} */ (left.value) *
693
+ /** @type {any} */ (right.value),
694
+ }
695
+ case "/":
696
+ return {
697
+ value:
698
+ /** @type {any} */ (left.value) /
699
+ /** @type {any} */ (right.value),
700
+ }
701
+ case "%":
702
+ return {
703
+ value:
704
+ /** @type {any} */ (left.value) %
705
+ /** @type {any} */ (right.value),
706
+ }
707
+ case "**":
708
+ return {
709
+ value:
710
+ /** @type {any} */ (left.value) **
711
+ /** @type {any} */ (right.value),
712
+ }
713
+ case "|":
714
+ return {
715
+ value:
716
+ /** @type {any} */ (left.value) |
717
+ /** @type {any} */ (right.value),
718
+ }
719
+ case "^":
720
+ return {
721
+ value:
722
+ /** @type {any} */ (left.value) ^
723
+ /** @type {any} */ (right.value),
724
+ }
725
+ case "&":
726
+ return {
727
+ value:
728
+ /** @type {any} */ (left.value) &
729
+ /** @type {any} */ (right.value),
730
+ }
731
+
732
+ // no default
733
+ }
734
+ }
735
+
736
+ return null
737
+ },
738
+
739
+ CallExpression(node, initialScope) {
740
+ const calleeNode = node.callee;
741
+ const args = getElementValues(node.arguments, initialScope);
742
+
743
+ if (args != null) {
744
+ if (calleeNode.type === "MemberExpression") {
745
+ if (calleeNode.property.type === "PrivateIdentifier") {
746
+ return null
747
+ }
748
+ const object = getStaticValueR(calleeNode.object, initialScope);
749
+ if (object != null) {
750
+ if (
751
+ object.value == null &&
752
+ (object.optional || node.optional)
753
+ ) {
754
+ return { value: undefined, optional: true }
755
+ }
756
+ const property = getStaticPropertyNameValue(
757
+ calleeNode,
758
+ initialScope,
759
+ );
760
+
761
+ if (property != null) {
762
+ const receiver =
763
+ /** @type {Record<PropertyKey, (...args: any[]) => any>} */ (
764
+ object.value
765
+ );
766
+ const methodName = /** @type {PropertyKey} */ (
767
+ property.value
768
+ );
769
+ if (callAllowed.has(receiver[methodName])) {
770
+ return {
771
+ value: receiver[methodName](...args),
772
+ }
773
+ }
774
+ if (callPassThrough.has(receiver[methodName])) {
775
+ return { value: args[0] }
776
+ }
777
+ }
778
+ }
779
+ } else {
780
+ const callee = getStaticValueR(calleeNode, initialScope);
781
+ if (callee != null) {
782
+ if (callee.value == null && node.optional) {
783
+ return { value: undefined, optional: true }
784
+ }
785
+ const func = /** @type {(...args: any[]) => any} */ (
786
+ callee.value
787
+ );
788
+ if (callAllowed.has(func)) {
789
+ return { value: func(...args) }
790
+ }
791
+ if (callPassThrough.has(func)) {
792
+ return { value: args[0] }
793
+ }
794
+ }
795
+ }
796
+ }
797
+
798
+ return null
799
+ },
800
+
801
+ ConditionalExpression(node, initialScope) {
802
+ const test = getStaticValueR(node.test, initialScope);
803
+ if (test != null) {
804
+ return test.value
805
+ ? getStaticValueR(node.consequent, initialScope)
806
+ : getStaticValueR(node.alternate, initialScope)
807
+ }
808
+ return null
809
+ },
810
+
811
+ ExpressionStatement(node, initialScope) {
812
+ return getStaticValueR(node.expression, initialScope)
813
+ },
814
+
815
+ Identifier(node, initialScope) {
816
+ if (initialScope != null) {
817
+ const variable = findVariable(initialScope, node);
818
+
819
+ // Built-in globals.
820
+ if (
821
+ variable != null &&
822
+ variable.defs.length === 0 &&
823
+ builtinNames.has(variable.name) &&
824
+ variable.name in globalObject
825
+ ) {
826
+ return { value: globalObject[variable.name] }
827
+ }
828
+
829
+ // Constants.
830
+ if (variable != null && variable.defs.length === 1) {
831
+ const def = variable.defs[0];
832
+ if (
833
+ def.parent &&
834
+ def.type === "Variable" &&
835
+ (def.parent.kind === "const" ||
836
+ isEffectivelyConst(variable)) &&
837
+ // TODO(mysticatea): don't support destructuring here.
838
+ def.node.id.type === "Identifier"
839
+ ) {
840
+ return getStaticValueR(def.node.init, initialScope)
841
+ }
842
+ }
843
+ }
844
+ return null
845
+ },
846
+
847
+ Literal(node) {
848
+ const literal =
849
+ /** @type {Partial<Literal> & Partial<RegExpLiteral> & Partial<BigIntLiteral>} */ (
850
+ node
851
+ );
852
+ //istanbul ignore if : this is implementation-specific behavior.
853
+ if (
854
+ (literal.regex != null || literal.bigint != null) &&
855
+ literal.value == null
856
+ ) {
857
+ // It was a RegExp/BigInt literal, but Node.js didn't support it.
858
+ return null
859
+ }
860
+ return { value: literal.value }
861
+ },
862
+
863
+ LogicalExpression(node, initialScope) {
864
+ const left = getStaticValueR(node.left, initialScope);
865
+ if (left != null) {
866
+ if (
867
+ (node.operator === "||" && Boolean(left.value) === true) ||
868
+ (node.operator === "&&" && Boolean(left.value) === false) ||
869
+ (node.operator === "??" && left.value != null)
870
+ ) {
871
+ return left
872
+ }
873
+
874
+ const right = getStaticValueR(node.right, initialScope);
875
+ if (right != null) {
876
+ return right
877
+ }
878
+ }
879
+
880
+ return null
881
+ },
882
+
883
+ MemberExpression(node, initialScope) {
884
+ if (node.property.type === "PrivateIdentifier") {
885
+ return null
886
+ }
887
+ const object = getStaticValueR(node.object, initialScope);
888
+ if (object != null) {
889
+ if (object.value == null && (object.optional || node.optional)) {
890
+ return { value: undefined, optional: true }
891
+ }
892
+ const property = getStaticPropertyNameValue(node, initialScope);
893
+
894
+ if (property != null) {
895
+ if (
896
+ !isGetter(
897
+ /** @type {object} */ (object.value),
898
+ /** @type {PropertyKey} */ (property.value),
899
+ )
900
+ ) {
901
+ return {
902
+ value: /** @type {Record<PropertyKey, unknown>} */ (
903
+ object.value
904
+ )[/** @type {PropertyKey} */ (property.value)],
905
+ }
906
+ }
907
+
908
+ for (const [classFn, allowed] of getterAllowed) {
909
+ if (
910
+ object.value instanceof classFn &&
911
+ allowed.has(/** @type {string} */ (property.value))
912
+ ) {
913
+ return {
914
+ value: /** @type {Record<PropertyKey, unknown>} */ (
915
+ object.value
916
+ )[/** @type {PropertyKey} */ (property.value)],
917
+ }
918
+ }
919
+ }
920
+ }
921
+ }
922
+ return null
923
+ },
924
+
925
+ ChainExpression(node, initialScope) {
926
+ const expression = getStaticValueR(node.expression, initialScope);
927
+ if (expression != null) {
928
+ return { value: expression.value }
929
+ }
930
+ return null
931
+ },
932
+
933
+ NewExpression(node, initialScope) {
934
+ const callee = getStaticValueR(node.callee, initialScope);
935
+ const args = getElementValues(node.arguments, initialScope);
936
+
937
+ if (callee != null && args != null) {
938
+ const Func = /** @type {new (...args: any[]) => any} */ (
939
+ callee.value
940
+ );
941
+ if (callAllowed.has(Func)) {
942
+ return { value: new Func(...args) }
943
+ }
944
+ }
945
+
946
+ return null
947
+ },
948
+
949
+ ObjectExpression(node, initialScope) {
950
+ /** @type {Record<PropertyKey, unknown>} */
951
+ const object = {};
952
+
953
+ for (const propertyNode of node.properties) {
954
+ if (propertyNode.type === "Property") {
955
+ if (propertyNode.kind !== "init") {
956
+ return null
957
+ }
958
+ const key = getStaticPropertyNameValue(
959
+ propertyNode,
960
+ initialScope,
961
+ );
962
+ const value = getStaticValueR(propertyNode.value, initialScope);
963
+ if (key == null || value == null) {
964
+ return null
965
+ }
966
+ object[/** @type {PropertyKey} */ (key.value)] = value.value;
967
+ } else if (
968
+ propertyNode.type === "SpreadElement" ||
969
+ // @ts-expect-error -- Backward compatibility
970
+ propertyNode.type === "ExperimentalSpreadProperty"
971
+ ) {
972
+ const argument = getStaticValueR(
973
+ propertyNode.argument,
974
+ initialScope,
975
+ );
976
+ if (argument == null) {
977
+ return null
978
+ }
979
+ Object.assign(object, argument.value);
980
+ } else {
981
+ return null
982
+ }
983
+ }
984
+
985
+ return { value: object }
986
+ },
987
+
988
+ SequenceExpression(node, initialScope) {
989
+ const last = node.expressions[node.expressions.length - 1];
990
+ return getStaticValueR(last, initialScope)
991
+ },
992
+
993
+ TaggedTemplateExpression(node, initialScope) {
994
+ const tag = getStaticValueR(node.tag, initialScope);
995
+ const expressions = getElementValues(
996
+ node.quasi.expressions,
997
+ initialScope,
998
+ );
999
+
1000
+ if (tag != null && expressions != null) {
1001
+ const func = /** @type {(...args: any[]) => any} */ (tag.value);
1002
+ /** @type {any[] & { raw?: string[] }} */
1003
+ const strings = node.quasi.quasis.map((q) => q.value.cooked);
1004
+ strings.raw = node.quasi.quasis.map((q) => q.value.raw);
1005
+
1006
+ if (func === String.raw) {
1007
+ return { value: func(strings, ...expressions) }
1008
+ }
1009
+ }
1010
+
1011
+ return null
1012
+ },
1013
+
1014
+ TemplateLiteral(node, initialScope) {
1015
+ const expressions = getElementValues(node.expressions, initialScope);
1016
+ if (expressions != null) {
1017
+ let value = node.quasis[0].value.cooked;
1018
+ for (let i = 0; i < expressions.length; ++i) {
1019
+ value += expressions[i];
1020
+ value += /** @type {string} */ (node.quasis[i + 1].value.cooked);
1021
+ }
1022
+ return { value }
1023
+ }
1024
+ return null
1025
+ },
1026
+
1027
+ UnaryExpression(node, initialScope) {
1028
+ if (node.operator === "delete") {
1029
+ // Not supported.
1030
+ return null
1031
+ }
1032
+ if (node.operator === "void") {
1033
+ return { value: undefined }
1034
+ }
1035
+
1036
+ const arg = getStaticValueR(node.argument, initialScope);
1037
+ if (arg != null) {
1038
+ switch (node.operator) {
1039
+ case "-":
1040
+ return { value: -(/** @type {any} */ (arg.value)) }
1041
+ case "+":
1042
+ return { value: +(/** @type {any} */ (arg.value)) } //eslint-disable-line no-implicit-coercion
1043
+ case "!":
1044
+ return { value: !arg.value }
1045
+ case "~":
1046
+ return { value: ~(/** @type {any} */ (arg.value)) }
1047
+ case "typeof":
1048
+ return { value: typeof arg.value }
1049
+
1050
+ // no default
1051
+ }
1052
+ }
1053
+
1054
+ return null
1055
+ },
1056
+ TSAsExpression(node, initialScope) {
1057
+ return getStaticValueR(node.expression, initialScope)
1058
+ },
1059
+ TSSatisfiesExpression(node, initialScope) {
1060
+ return getStaticValueR(node.expression, initialScope)
1061
+ },
1062
+ TSTypeAssertion(node, initialScope) {
1063
+ return getStaticValueR(node.expression, initialScope)
1064
+ },
1065
+ TSNonNullExpression(node, initialScope) {
1066
+ return getStaticValueR(node.expression, initialScope)
1067
+ },
1068
+ TSInstantiationExpression(node, initialScope) {
1069
+ return getStaticValueR(node.expression, initialScope)
1070
+ },
1071
+ });
1072
+
1073
+ /**
1074
+ * Get the value of a given node if it's a static value.
1075
+ * @param {Node|TSESTreeNode|null|undefined} node The node to get.
1076
+ * @param {Scope|undefined|null} initialScope The scope to start finding variable.
1077
+ * @returns {StaticValue|null} The static value of the node, or `null`.
1078
+ */
1079
+ function getStaticValueR(node, initialScope) {
1080
+ if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
1081
+ return /** @type {VisitorCallback<any>} */ (operations[node.type])(
1082
+ /** @type {TSESTreeNode} */ (node),
1083
+ initialScope,
1084
+ )
1085
+ }
1086
+ return null
1087
+ }
1088
+
1089
+ /**
1090
+ * Get the static value of property name from a MemberExpression node or a Property node.
1091
+ * @param {MemberExpression|Property} node The node to get.
1092
+ * @param {Scope|null} [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.
1093
+ * @returns {StaticValue|null} The static value of the property name of the node, or `null`.
1094
+ */
1095
+ function getStaticPropertyNameValue(node, initialScope) {
1096
+ const nameNode = node.type === "Property" ? node.key : node.property;
1097
+
1098
+ if (node.computed) {
1099
+ return getStaticValueR(nameNode, initialScope)
1100
+ }
1101
+
1102
+ if (nameNode.type === "Identifier") {
1103
+ return { value: nameNode.name }
1104
+ }
1105
+
1106
+ if (nameNode.type === "Literal") {
1107
+ if (/** @type {Partial<BigIntLiteral>} */ (nameNode).bigint) {
1108
+ return { value: /** @type {BigIntLiteral} */ (nameNode).bigint }
1109
+ }
1110
+ return { value: String(nameNode.value) }
1111
+ }
1112
+
1113
+ return null
1114
+ }
1115
+
1116
+ /**
1117
+ * Get the value of a given node if it's a static value.
1118
+ * @param {Node} node The node to get.
1119
+ * @param {Scope|null} [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.
1120
+ * @returns {StaticValue | null} The static value of the node, or `null`.
1121
+ */
1122
+ function getStaticValue(node, initialScope = null) {
1123
+ try {
1124
+ return getStaticValueR(node, initialScope)
1125
+ } catch (_error) {
1126
+ return null
1127
+ }
1128
+ }
1129
+
1130
+ /** @typedef {import("eslint").Scope.Scope} Scope */
1131
+ /** @typedef {import("estree").Node} Node */
1132
+ /** @typedef {import("estree").RegExpLiteral} RegExpLiteral */
1133
+ /** @typedef {import("estree").BigIntLiteral} BigIntLiteral */
1134
+ /** @typedef {import("estree").SimpleLiteral} SimpleLiteral */
1135
+
1136
+ /**
1137
+ * Get the value of a given node if it's a literal or a template literal.
1138
+ * @param {Node} node The node to get.
1139
+ * @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If the node is an Identifier node and this scope was given, this checks the variable of the identifier, and returns the value of it if the variable is a constant.
1140
+ * @returns {string|null} The value of the node, or `null`.
1141
+ */
1142
+ function getStringIfConstant(node, initialScope = null) {
1143
+ // Handle the literals that the platform doesn't support natively.
1144
+ if (node && node.type === "Literal" && node.value === null) {
1145
+ const literal =
1146
+ /** @type {Partial<SimpleLiteral> & Partial<RegExpLiteral> & Partial<BigIntLiteral>} */ (
1147
+ node
1148
+ );
1149
+ if (literal.regex) {
1150
+ return `/${literal.regex.pattern}/${literal.regex.flags}`
1151
+ }
1152
+ if (literal.bigint) {
1153
+ return literal.bigint
1154
+ }
1155
+ }
1156
+
1157
+ const evaluated = getStaticValue(node, initialScope);
1158
+
1159
+ if (evaluated) {
1160
+ // `String(Symbol.prototype)` throws error
1161
+ try {
1162
+ return String(evaluated.value)
1163
+ } catch {
1164
+ // No op
1165
+ }
1166
+ }
1167
+
1168
+ return null
1169
+ }
1170
+
1171
+ /** @typedef {import("eslint").Scope.Scope} Scope */
1172
+ /** @typedef {import("estree").MemberExpression} MemberExpression */
1173
+ /** @typedef {import("estree").MethodDefinition} MethodDefinition */
1174
+ /** @typedef {import("estree").Property} Property */
1175
+ /** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
1176
+ /** @typedef {import("estree").Identifier} Identifier */
1177
+
1178
+ /**
1179
+ * Get the property name from a MemberExpression node or a Property node.
1180
+ * @param {MemberExpression | MethodDefinition | Property | PropertyDefinition} node The node to get.
1181
+ * @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.
1182
+ * @returns {string|null|undefined} The property name of the node.
1183
+ */
1184
+ function getPropertyName(node, initialScope) {
1185
+ switch (node.type) {
1186
+ case "MemberExpression":
1187
+ if (node.computed) {
1188
+ return getStringIfConstant(node.property, initialScope)
1189
+ }
1190
+ if (node.property.type === "PrivateIdentifier") {
1191
+ return null
1192
+ }
1193
+ return /** @type {Partial<Identifier>} */ (node.property).name
1194
+
1195
+ case "Property":
1196
+ case "MethodDefinition":
1197
+ case "PropertyDefinition":
1198
+ if (node.computed) {
1199
+ return getStringIfConstant(node.key, initialScope)
1200
+ }
1201
+ if (node.key.type === "Literal") {
1202
+ return String(node.key.value)
1203
+ }
1204
+ if (node.key.type === "PrivateIdentifier") {
1205
+ return null
1206
+ }
1207
+ return /** @type {Partial<Identifier>} */ (node.key).name
1208
+ }
1209
+
1210
+ return null
1211
+ }
1212
+
1213
+ /** @typedef {import("eslint").Rule.Node} RuleNode */
1214
+ /** @typedef {import("eslint").SourceCode} SourceCode */
1215
+ /** @typedef {import("estree").Function} FunctionNode */
1216
+ /** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
1217
+ /** @typedef {import("estree").FunctionExpression} FunctionExpression */
1218
+ /** @typedef {import("estree").Identifier} Identifier */
1219
+
1220
+ /**
1221
+ * Get the name and kind of the given function node.
1222
+ * @param {FunctionNode} node - The function node to get.
1223
+ * @param {SourceCode} [sourceCode] The source code object to get the code of computed property keys.
1224
+ * @returns {string} The name and kind of the function node.
1225
+ */
1226
+ // eslint-disable-next-line complexity
1227
+ function getFunctionNameWithKind(node, sourceCode) {
1228
+ const parent = /** @type {RuleNode} */ (node).parent;
1229
+ const tokens = [];
1230
+ const isObjectMethod = parent.type === "Property" && parent.value === node;
1231
+ const isClassMethod =
1232
+ parent.type === "MethodDefinition" && parent.value === node;
1233
+ const isClassFieldMethod =
1234
+ parent.type === "PropertyDefinition" && parent.value === node;
1235
+
1236
+ // Modifiers.
1237
+ if (isClassMethod || isClassFieldMethod) {
1238
+ if (parent.static) {
1239
+ tokens.push("static");
1240
+ }
1241
+ if (parent.key.type === "PrivateIdentifier") {
1242
+ tokens.push("private");
1243
+ }
1244
+ }
1245
+ if (node.async) {
1246
+ tokens.push("async");
1247
+ }
1248
+ if (node.generator) {
1249
+ tokens.push("generator");
1250
+ }
1251
+
1252
+ // Kinds.
1253
+ if (isObjectMethod || isClassMethod) {
1254
+ if (parent.kind === "constructor") {
1255
+ return "constructor"
1256
+ }
1257
+ if (parent.kind === "get") {
1258
+ tokens.push("getter");
1259
+ } else if (parent.kind === "set") {
1260
+ tokens.push("setter");
1261
+ } else {
1262
+ tokens.push("method");
1263
+ }
1264
+ } else if (isClassFieldMethod) {
1265
+ tokens.push("method");
1266
+ } else {
1267
+ if (node.type === "ArrowFunctionExpression") {
1268
+ tokens.push("arrow");
1269
+ }
1270
+ tokens.push("function");
1271
+ }
1272
+
1273
+ // Names.
1274
+ if (isObjectMethod || isClassMethod || isClassFieldMethod) {
1275
+ if (parent.key.type === "PrivateIdentifier") {
1276
+ tokens.push(`#${parent.key.name}`);
1277
+ } else {
1278
+ const name = getPropertyName(parent);
1279
+ if (name) {
1280
+ tokens.push(`'${name}'`);
1281
+ } else if (sourceCode) {
1282
+ const keyText = sourceCode.getText(parent.key);
1283
+ if (!keyText.includes("\n")) {
1284
+ tokens.push(`[${keyText}]`);
1285
+ }
1286
+ }
1287
+ }
1288
+ } else if (hasId(node)) {
1289
+ tokens.push(`'${node.id.name}'`);
1290
+ } else if (
1291
+ parent.type === "VariableDeclarator" &&
1292
+ parent.id &&
1293
+ parent.id.type === "Identifier"
1294
+ ) {
1295
+ tokens.push(`'${parent.id.name}'`);
1296
+ } else if (
1297
+ (parent.type === "AssignmentExpression" ||
1298
+ parent.type === "AssignmentPattern") &&
1299
+ parent.left &&
1300
+ parent.left.type === "Identifier"
1301
+ ) {
1302
+ tokens.push(`'${parent.left.name}'`);
1303
+ } else if (
1304
+ parent.type === "ExportDefaultDeclaration" &&
1305
+ parent.declaration === node
1306
+ ) {
1307
+ tokens.push("'default'");
1308
+ }
1309
+
1310
+ return tokens.join(" ")
1311
+ }
1312
+
1313
+ /**
1314
+ * @param {FunctionNode} node
1315
+ * @returns {node is FunctionDeclaration | FunctionExpression & { id: Identifier }}
1316
+ */
1317
+ function hasId(node) {
1318
+ return Boolean(
1319
+ /** @type {Partial<FunctionDeclaration | FunctionExpression>} */ (node)
1320
+ .id,
1321
+ )
1322
+ }
1323
+
1324
+ /** @typedef {import("estree").Node} Node */
1325
+ /** @typedef {import("eslint").SourceCode} SourceCode */
1326
+ /** @typedef {import("./types.mjs").HasSideEffectOptions} HasSideEffectOptions */
1327
+ /** @typedef {import("estree").BinaryExpression} BinaryExpression */
1328
+ /** @typedef {import("estree").MemberExpression} MemberExpression */
1329
+ /** @typedef {import("estree").MethodDefinition} MethodDefinition */
1330
+ /** @typedef {import("estree").Property} Property */
1331
+ /** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
1332
+ /** @typedef {import("estree").UnaryExpression} UnaryExpression */
1333
+
1334
+ const typeConversionBinaryOps = Object.freeze(
1335
+ new Set([
1336
+ "==",
1337
+ "!=",
1338
+ "<",
1339
+ "<=",
1340
+ ">",
1341
+ ">=",
1342
+ "<<",
1343
+ ">>",
1344
+ ">>>",
1345
+ "+",
1346
+ "-",
1347
+ "*",
1348
+ "/",
1349
+ "%",
1350
+ "|",
1351
+ "^",
1352
+ "&",
1353
+ "in",
1354
+ ]),
1355
+ );
1356
+ const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"]));
1357
+
1358
+ /**
1359
+ * Check whether the given value is an ASTNode or not.
1360
+ * @param {any} x The value to check.
1361
+ * @returns {x is Node} `true` if the value is an ASTNode.
1362
+ */
1363
+ function isNode(x) {
1364
+ return x !== null && typeof x === "object" && typeof x.type === "string"
1365
+ }
1366
+
1367
+ const visitor = Object.freeze(
1368
+ Object.assign(Object.create(null), {
1369
+ /**
1370
+ * @param {Node} node
1371
+ * @param {HasSideEffectOptions} options
1372
+ * @param {Record<string, string[]>} visitorKeys
1373
+ */
1374
+ $visit(node, options, visitorKeys) {
1375
+ const { type } = node;
1376
+
1377
+ if (typeof (/** @type {any} */ (this)[type]) === "function") {
1378
+ return /** @type {any} */ (this)[type](
1379
+ node,
1380
+ options,
1381
+ visitorKeys,
1382
+ )
1383
+ }
1384
+
1385
+ return this.$visitChildren(node, options, visitorKeys)
1386
+ },
1387
+
1388
+ /**
1389
+ * @param {Node} node
1390
+ * @param {HasSideEffectOptions} options
1391
+ * @param {Record<string, string[]>} visitorKeys
1392
+ */
1393
+ $visitChildren(node, options, visitorKeys) {
1394
+ const { type } = node;
1395
+
1396
+ for (const key of /** @type {(keyof Node)[]} */ (
1397
+ visitorKeys[type] || eslintVisitorKeys.getKeys(node)
1398
+ )) {
1399
+ const value = node[key];
1400
+
1401
+ if (Array.isArray(value)) {
1402
+ for (const element of value) {
1403
+ if (
1404
+ isNode(element) &&
1405
+ this.$visit(element, options, visitorKeys)
1406
+ ) {
1407
+ return true
1408
+ }
1409
+ }
1410
+ } else if (
1411
+ isNode(value) &&
1412
+ this.$visit(value, options, visitorKeys)
1413
+ ) {
1414
+ return true
1415
+ }
1416
+ }
1417
+
1418
+ return false
1419
+ },
1420
+
1421
+ ArrowFunctionExpression() {
1422
+ return false
1423
+ },
1424
+ AssignmentExpression() {
1425
+ return true
1426
+ },
1427
+ AwaitExpression() {
1428
+ return true
1429
+ },
1430
+ /**
1431
+ * @param {BinaryExpression} node
1432
+ * @param {HasSideEffectOptions} options
1433
+ * @param {Record<string, string[]>} visitorKeys
1434
+ */
1435
+ BinaryExpression(node, options, visitorKeys) {
1436
+ if (
1437
+ options.considerImplicitTypeConversion &&
1438
+ typeConversionBinaryOps.has(node.operator) &&
1439
+ (node.left.type !== "Literal" || node.right.type !== "Literal")
1440
+ ) {
1441
+ return true
1442
+ }
1443
+ return this.$visitChildren(node, options, visitorKeys)
1444
+ },
1445
+ CallExpression() {
1446
+ return true
1447
+ },
1448
+ FunctionExpression() {
1449
+ return false
1450
+ },
1451
+ ImportExpression() {
1452
+ return true
1453
+ },
1454
+ /**
1455
+ * @param {MemberExpression} node
1456
+ * @param {HasSideEffectOptions} options
1457
+ * @param {Record<string, string[]>} visitorKeys
1458
+ */
1459
+ MemberExpression(node, options, visitorKeys) {
1460
+ if (options.considerGetters) {
1461
+ return true
1462
+ }
1463
+ if (
1464
+ options.considerImplicitTypeConversion &&
1465
+ node.computed &&
1466
+ node.property.type !== "Literal"
1467
+ ) {
1468
+ return true
1469
+ }
1470
+ return this.$visitChildren(node, options, visitorKeys)
1471
+ },
1472
+ /**
1473
+ * @param {MethodDefinition} node
1474
+ * @param {HasSideEffectOptions} options
1475
+ * @param {Record<string, string[]>} visitorKeys
1476
+ */
1477
+ MethodDefinition(node, options, visitorKeys) {
1478
+ if (
1479
+ options.considerImplicitTypeConversion &&
1480
+ node.computed &&
1481
+ node.key.type !== "Literal"
1482
+ ) {
1483
+ return true
1484
+ }
1485
+ return this.$visitChildren(node, options, visitorKeys)
1486
+ },
1487
+ NewExpression() {
1488
+ return true
1489
+ },
1490
+ /**
1491
+ * @param {Property} node
1492
+ * @param {HasSideEffectOptions} options
1493
+ * @param {Record<string, string[]>} visitorKeys
1494
+ */
1495
+ Property(node, options, visitorKeys) {
1496
+ if (
1497
+ options.considerImplicitTypeConversion &&
1498
+ node.computed &&
1499
+ node.key.type !== "Literal"
1500
+ ) {
1501
+ return true
1502
+ }
1503
+ return this.$visitChildren(node, options, visitorKeys)
1504
+ },
1505
+ /**
1506
+ * @param {PropertyDefinition} node
1507
+ * @param {HasSideEffectOptions} options
1508
+ * @param {Record<string, string[]>} visitorKeys
1509
+ */
1510
+ PropertyDefinition(node, options, visitorKeys) {
1511
+ if (
1512
+ options.considerImplicitTypeConversion &&
1513
+ node.computed &&
1514
+ node.key.type !== "Literal"
1515
+ ) {
1516
+ return true
1517
+ }
1518
+ return this.$visitChildren(node, options, visitorKeys)
1519
+ },
1520
+ /**
1521
+ * @param {UnaryExpression} node
1522
+ * @param {HasSideEffectOptions} options
1523
+ * @param {Record<string, string[]>} visitorKeys
1524
+ */
1525
+ UnaryExpression(node, options, visitorKeys) {
1526
+ if (node.operator === "delete") {
1527
+ return true
1528
+ }
1529
+ if (
1530
+ options.considerImplicitTypeConversion &&
1531
+ typeConversionUnaryOps.has(node.operator) &&
1532
+ node.argument.type !== "Literal"
1533
+ ) {
1534
+ return true
1535
+ }
1536
+ return this.$visitChildren(node, options, visitorKeys)
1537
+ },
1538
+ UpdateExpression() {
1539
+ return true
1540
+ },
1541
+ YieldExpression() {
1542
+ return true
1543
+ },
1544
+ }),
1545
+ );
1546
+
1547
+ /**
1548
+ * Check whether a given node has any side effect or not.
1549
+ * @param {Node} node The node to get.
1550
+ * @param {SourceCode} sourceCode The source code object.
1551
+ * @param {HasSideEffectOptions} [options] The option object.
1552
+ * @returns {boolean} `true` if the node has a certain side effect.
1553
+ */
1554
+ function hasSideEffect(node, sourceCode, options = {}) {
1555
+ const { considerGetters = false, considerImplicitTypeConversion = false } =
1556
+ options;
1557
+ return visitor.$visit(
1558
+ node,
1559
+ { considerGetters, considerImplicitTypeConversion },
1560
+ sourceCode.visitorKeys || eslintVisitorKeys.KEYS,
1561
+ )
1562
+ }
1563
+
1564
+ /** @typedef {import("estree").Node} Node */
1565
+ /** @typedef {import("eslint").SourceCode} SourceCode */
1566
+ /** @typedef {import("eslint").AST.Token} Token */
1567
+ /** @typedef {import("eslint").Rule.Node} RuleNode */
1568
+
1569
+ /**
1570
+ * Get the left parenthesis of the parent node syntax if it exists.
1571
+ * E.g., `if (a) {}` then the `(`.
1572
+ * @param {Node} node The AST node to check.
1573
+ * @param {SourceCode} sourceCode The source code object to get tokens.
1574
+ * @returns {Token|null} The left parenthesis of the parent node syntax
1575
+ */
1576
+ function getParentSyntaxParen(node, sourceCode) {
1577
+ const parent = /** @type {RuleNode} */ (node).parent;
1578
+
1579
+ switch (parent.type) {
1580
+ case "CallExpression":
1581
+ case "NewExpression":
1582
+ if (parent.arguments.length === 1 && parent.arguments[0] === node) {
1583
+ return sourceCode.getTokenAfter(
1584
+ parent.callee,
1585
+ isOpeningParenToken,
1586
+ )
1587
+ }
1588
+ return null
1589
+
1590
+ case "DoWhileStatement":
1591
+ if (parent.test === node) {
1592
+ return sourceCode.getTokenAfter(
1593
+ parent.body,
1594
+ isOpeningParenToken,
1595
+ )
1596
+ }
1597
+ return null
1598
+
1599
+ case "IfStatement":
1600
+ case "WhileStatement":
1601
+ if (parent.test === node) {
1602
+ return sourceCode.getFirstToken(parent, 1)
1603
+ }
1604
+ return null
1605
+
1606
+ case "ImportExpression":
1607
+ if (parent.source === node) {
1608
+ return sourceCode.getFirstToken(parent, 1)
1609
+ }
1610
+ return null
1611
+
1612
+ case "SwitchStatement":
1613
+ if (parent.discriminant === node) {
1614
+ return sourceCode.getFirstToken(parent, 1)
1615
+ }
1616
+ return null
1617
+
1618
+ case "WithStatement":
1619
+ if (parent.object === node) {
1620
+ return sourceCode.getFirstToken(parent, 1)
1621
+ }
1622
+ return null
1623
+
1624
+ default:
1625
+ return null
1626
+ }
1627
+ }
1628
+
1629
+ /**
1630
+ * Check whether a given node is parenthesized or not.
1631
+ * @param {number} times The number of parantheses.
1632
+ * @param {Node} node The AST node to check.
1633
+ * @param {SourceCode} sourceCode The source code object to get tokens.
1634
+ * @returns {boolean} `true` if the node is parenthesized the given times.
1635
+ */
1636
+ /**
1637
+ * Check whether a given node is parenthesized or not.
1638
+ * @param {Node} node The AST node to check.
1639
+ * @param {SourceCode} sourceCode The source code object to get tokens.
1640
+ * @returns {boolean} `true` if the node is parenthesized.
1641
+ */
1642
+ /**
1643
+ * Check whether a given node is parenthesized or not.
1644
+ * @param {Node|number} timesOrNode The first parameter.
1645
+ * @param {Node|SourceCode} nodeOrSourceCode The second parameter.
1646
+ * @param {SourceCode} [optionalSourceCode] The third parameter.
1647
+ * @returns {boolean} `true` if the node is parenthesized.
1648
+ */
1649
+ function isParenthesized(
1650
+ timesOrNode,
1651
+ nodeOrSourceCode,
1652
+ optionalSourceCode,
1653
+ ) {
1654
+ /** @type {number} */
1655
+ let times,
1656
+ /** @type {RuleNode} */
1657
+ node,
1658
+ /** @type {SourceCode} */
1659
+ sourceCode,
1660
+ maybeLeftParen,
1661
+ maybeRightParen;
1662
+ if (typeof timesOrNode === "number") {
1663
+ times = timesOrNode | 0;
1664
+ node = /** @type {RuleNode} */ (nodeOrSourceCode);
1665
+ sourceCode = /** @type {SourceCode} */ (optionalSourceCode);
1666
+ if (!(times >= 1)) {
1667
+ throw new TypeError("'times' should be a positive integer.")
1668
+ }
1669
+ } else {
1670
+ times = 1;
1671
+ node = /** @type {RuleNode} */ (timesOrNode);
1672
+ sourceCode = /** @type {SourceCode} */ (nodeOrSourceCode);
1673
+ }
1674
+
1675
+ if (
1676
+ node == null ||
1677
+ // `Program` can't be parenthesized
1678
+ node.parent == null ||
1679
+ // `CatchClause.param` can't be parenthesized, example `try {} catch (error) {}`
1680
+ (node.parent.type === "CatchClause" && node.parent.param === node)
1681
+ ) {
1682
+ return false
1683
+ }
1684
+
1685
+ maybeLeftParen = maybeRightParen = node;
1686
+ do {
1687
+ maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen);
1688
+ maybeRightParen = sourceCode.getTokenAfter(maybeRightParen);
1689
+ } while (
1690
+ maybeLeftParen != null &&
1691
+ maybeRightParen != null &&
1692
+ isOpeningParenToken(maybeLeftParen) &&
1693
+ isClosingParenToken(maybeRightParen) &&
1694
+ // Avoid false positive such as `if (a) {}`
1695
+ maybeLeftParen !== getParentSyntaxParen(node, sourceCode) &&
1696
+ --times > 0
1697
+ )
1698
+
1699
+ return times === 0
1700
+ }
1701
+
1702
+ /**
1703
+ * @author Toru Nagashima <https://github.com/mysticatea>
1704
+ * See LICENSE file in root directory for full license.
1705
+ */
1706
+
1707
+ const placeholder = /\$(?:[$&`']|[1-9][0-9]?)/gu;
1708
+
1709
+ /** @type {WeakMap<PatternMatcher, {pattern:RegExp,escaped:boolean}>} */
1710
+ const internal = new WeakMap();
1711
+
1712
+ /**
1713
+ * Check whether a given character is escaped or not.
1714
+ * @param {string} str The string to check.
1715
+ * @param {number} index The location of the character to check.
1716
+ * @returns {boolean} `true` if the character is escaped.
1717
+ */
1718
+ function isEscaped(str, index) {
1719
+ let escaped = false;
1720
+ for (let i = index - 1; i >= 0 && str.charCodeAt(i) === 0x5c; --i) {
1721
+ escaped = !escaped;
1722
+ }
1723
+ return escaped
1724
+ }
1725
+
1726
+ /**
1727
+ * Replace a given string by a given matcher.
1728
+ * @param {PatternMatcher} matcher The pattern matcher.
1729
+ * @param {string} str The string to be replaced.
1730
+ * @param {string} replacement The new substring to replace each matched part.
1731
+ * @returns {string} The replaced string.
1732
+ */
1733
+ function replaceS(matcher, str, replacement) {
1734
+ const chunks = [];
1735
+ let index = 0;
1736
+
1737
+ /**
1738
+ * @param {string} key The placeholder.
1739
+ * @param {RegExpExecArray} match The matched information.
1740
+ * @returns {string} The replaced string.
1741
+ */
1742
+ function replacer(key, match) {
1743
+ switch (key) {
1744
+ case "$$":
1745
+ return "$"
1746
+ case "$&":
1747
+ return match[0]
1748
+ case "$`":
1749
+ return str.slice(0, match.index)
1750
+ case "$'":
1751
+ return str.slice(match.index + match[0].length)
1752
+ default: {
1753
+ const i = key.slice(1);
1754
+ if (i in match) {
1755
+ return match[/** @type {any} */ (i)]
1756
+ }
1757
+ return key
1758
+ }
1759
+ }
1760
+ }
1761
+
1762
+ for (const match of matcher.execAll(str)) {
1763
+ chunks.push(str.slice(index, match.index));
1764
+ chunks.push(
1765
+ replacement.replace(placeholder, (key) => replacer(key, match)),
1766
+ );
1767
+ index = match.index + match[0].length;
1768
+ }
1769
+ chunks.push(str.slice(index));
1770
+
1771
+ return chunks.join("")
1772
+ }
1773
+
1774
+ /**
1775
+ * Replace a given string by a given matcher.
1776
+ * @param {PatternMatcher} matcher The pattern matcher.
1777
+ * @param {string} str The string to be replaced.
1778
+ * @param {(substring: string, ...args: any[]) => string} replace The function to replace each matched part.
1779
+ * @returns {string} The replaced string.
1780
+ */
1781
+ function replaceF(matcher, str, replace) {
1782
+ const chunks = [];
1783
+ let index = 0;
1784
+
1785
+ for (const match of matcher.execAll(str)) {
1786
+ chunks.push(str.slice(index, match.index));
1787
+ chunks.push(
1788
+ String(
1789
+ replace(
1790
+ .../** @type {[string, ...string[]]} */ (
1791
+ /** @type {string[]} */ (match)
1792
+ ),
1793
+ match.index,
1794
+ match.input,
1795
+ ),
1796
+ ),
1797
+ );
1798
+ index = match.index + match[0].length;
1799
+ }
1800
+ chunks.push(str.slice(index));
1801
+
1802
+ return chunks.join("")
1803
+ }
1804
+
1805
+ /**
1806
+ * The class to find patterns as considering escape sequences.
1807
+ */
1808
+ class PatternMatcher {
1809
+ /**
1810
+ * Initialize this matcher.
1811
+ * @param {RegExp} pattern The pattern to match.
1812
+ * @param {{escaped?:boolean}} [options] The options.
1813
+ */
1814
+ constructor(pattern, options = {}) {
1815
+ const { escaped = false } = options;
1816
+ if (!(pattern instanceof RegExp)) {
1817
+ throw new TypeError("'pattern' should be a RegExp instance.")
1818
+ }
1819
+ if (!pattern.flags.includes("g")) {
1820
+ throw new Error("'pattern' should contains 'g' flag.")
1821
+ }
1822
+
1823
+ internal.set(this, {
1824
+ pattern: new RegExp(pattern.source, pattern.flags),
1825
+ escaped: Boolean(escaped),
1826
+ });
1827
+ }
1828
+
1829
+ /**
1830
+ * Find the pattern in a given string.
1831
+ * @param {string} str The string to find.
1832
+ * @returns {IterableIterator<RegExpExecArray>} The iterator which iterate the matched information.
1833
+ */
1834
+ *execAll(str) {
1835
+ const { pattern, escaped } =
1836
+ /** @type {{pattern:RegExp,escaped:boolean}} */ (internal.get(this));
1837
+ let match = null;
1838
+ let lastIndex = 0;
1839
+
1840
+ pattern.lastIndex = 0;
1841
+ while ((match = pattern.exec(str)) != null) {
1842
+ if (escaped || !isEscaped(str, match.index)) {
1843
+ lastIndex = pattern.lastIndex;
1844
+ yield match;
1845
+ pattern.lastIndex = lastIndex;
1846
+ }
1847
+ }
1848
+ }
1849
+
1850
+ /**
1851
+ * Check whether the pattern is found in a given string.
1852
+ * @param {string} str The string to check.
1853
+ * @returns {boolean} `true` if the pattern was found in the string.
1854
+ */
1855
+ test(str) {
1856
+ const it = this.execAll(str);
1857
+ const ret = it.next();
1858
+ return !ret.done
1859
+ }
1860
+
1861
+ /**
1862
+ * Replace a given string.
1863
+ * @param {string} str The string to be replaced.
1864
+ * @param {(string|((...strs:string[])=>string))} replacer The string or function to replace. This is the same as the 2nd argument of `String.prototype.replace`.
1865
+ * @returns {string} The replaced string.
1866
+ */
1867
+ [Symbol.replace](str, replacer) {
1868
+ return typeof replacer === "function"
1869
+ ? replaceF(this, String(str), replacer)
1870
+ : replaceS(this, String(str), String(replacer))
1871
+ }
1872
+ }
1873
+
1874
+ /** @typedef {import("eslint").Scope.Scope} Scope */
1875
+ /** @typedef {import("eslint").Scope.Variable} Variable */
1876
+ /** @typedef {import("eslint").Rule.Node} RuleNode */
1877
+ /** @typedef {import("estree").Node} Node */
1878
+ /** @typedef {import("estree").Expression} Expression */
1879
+ /** @typedef {import("estree").Pattern} Pattern */
1880
+ /** @typedef {import("estree").Identifier} Identifier */
1881
+ /** @typedef {import("estree").SimpleCallExpression} CallExpression */
1882
+ /** @typedef {import("estree").Program} Program */
1883
+ /** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
1884
+ /** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
1885
+ /** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclaration */
1886
+ /** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
1887
+ /** @typedef {import("estree").ImportSpecifier} ImportSpecifier */
1888
+ /** @typedef {import("estree").ImportDefaultSpecifier} ImportDefaultSpecifier */
1889
+ /** @typedef {import("estree").ImportNamespaceSpecifier} ImportNamespaceSpecifier */
1890
+ /** @typedef {import("estree").ExportSpecifier} ExportSpecifier */
1891
+ /** @typedef {import("estree").Property} Property */
1892
+ /** @typedef {import("estree").AssignmentProperty} AssignmentProperty */
1893
+ /** @typedef {import("estree").Literal} Literal */
1894
+ /** @typedef {import("@typescript-eslint/types").TSESTree.Node} TSESTreeNode */
1895
+ /** @typedef {import("./types.mjs").ReferenceTrackerOptions} ReferenceTrackerOptions */
1896
+ /**
1897
+ * @template T
1898
+ * @typedef {import("./types.mjs").TraceMap<T>} TraceMap
1899
+ */
1900
+ /**
1901
+ * @template T
1902
+ * @typedef {import("./types.mjs").TraceMapObject<T>} TraceMapObject
1903
+ */
1904
+ /**
1905
+ * @template T
1906
+ * @typedef {import("./types.mjs").TrackedReferences<T>} TrackedReferences
1907
+ */
1908
+
1909
+ const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u;
1910
+
1911
+ /**
1912
+ * Check whether a given node is an import node or not.
1913
+ * @param {Node} node
1914
+ * @returns {node is ImportDeclaration|ExportAllDeclaration|ExportNamedDeclaration&{source: Literal}} `true` if the node is an import node.
1915
+ */
1916
+ function isHasSource(node) {
1917
+ return (
1918
+ IMPORT_TYPE.test(node.type) &&
1919
+ /** @type {ImportDeclaration|ExportAllDeclaration|ExportNamedDeclaration} */ (
1920
+ node
1921
+ ).source != null
1922
+ )
1923
+ }
1924
+ const has =
1925
+ /** @type {<T>(traceMap: TraceMap<unknown>, v: T) => v is (string extends T ? string : T)} */ (
1926
+ Function.call.bind(Object.hasOwnProperty)
1927
+ );
1928
+
1929
+ const READ = Symbol("read");
1930
+ const CALL = Symbol("call");
1931
+ const CONSTRUCT = Symbol("construct");
1932
+ const ESM = Symbol("esm");
1933
+
1934
+ const requireCall = { require: { [CALL]: true } };
1935
+
1936
+ /**
1937
+ * Check whether a given variable is modified or not.
1938
+ * @param {Variable|undefined} variable The variable to check.
1939
+ * @returns {boolean} `true` if the variable is modified.
1940
+ */
1941
+ function isModifiedGlobal(variable) {
1942
+ return (
1943
+ variable == null ||
1944
+ variable.defs.length !== 0 ||
1945
+ variable.references.some((r) => r.isWrite())
1946
+ )
1947
+ }
1948
+
1949
+ /**
1950
+ * Check if the value of a given node is passed through to the parent syntax as-is.
1951
+ * For example, `a` and `b` in (`a || b` and `c ? a : b`) are passed through.
1952
+ * @param {Node} node A node to check.
1953
+ * @returns {node is RuleNode & {parent: Expression}} `true` if the node is passed through.
1954
+ */
1955
+ function isPassThrough(node) {
1956
+ const parent = /** @type {TSESTreeNode} */ (node).parent;
1957
+
1958
+ if (parent) {
1959
+ switch (parent.type) {
1960
+ case "ConditionalExpression":
1961
+ return parent.consequent === node || parent.alternate === node
1962
+ case "LogicalExpression":
1963
+ return true
1964
+ case "SequenceExpression":
1965
+ return (
1966
+ parent.expressions[parent.expressions.length - 1] === node
1967
+ )
1968
+ case "ChainExpression":
1969
+ return true
1970
+ case "TSAsExpression":
1971
+ case "TSSatisfiesExpression":
1972
+ case "TSTypeAssertion":
1973
+ case "TSNonNullExpression":
1974
+ case "TSInstantiationExpression":
1975
+ return true
1976
+
1977
+ default:
1978
+ return false
1979
+ }
1980
+ }
1981
+ return false
1982
+ }
1983
+
1984
+ /**
1985
+ * The reference tracker.
1986
+ */
1987
+ class ReferenceTracker {
1988
+ /**
1989
+ * Initialize this tracker.
1990
+ * @param {Scope} globalScope The global scope.
1991
+ * @param {object} [options] The options.
1992
+ * @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules.
1993
+ * @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object.
1994
+ */
1995
+ constructor(globalScope, options = {}) {
1996
+ const {
1997
+ mode = "strict",
1998
+ globalObjectNames = ["global", "globalThis", "self", "window"],
1999
+ } = options;
2000
+ /** @private @type {Variable[]} */
2001
+ this.variableStack = [];
2002
+ /** @private */
2003
+ this.globalScope = globalScope;
2004
+ /** @private */
2005
+ this.mode = mode;
2006
+ /** @private */
2007
+ this.globalObjectNames = globalObjectNames.slice(0);
2008
+ }
2009
+
2010
+ /**
2011
+ * Iterate the references of global variables.
2012
+ * @template T
2013
+ * @param {TraceMap<T>} traceMap The trace map.
2014
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2015
+ */
2016
+ *iterateGlobalReferences(traceMap) {
2017
+ for (const key of Object.keys(traceMap)) {
2018
+ const nextTraceMap = traceMap[key];
2019
+ const path = [key];
2020
+ const variable = this.globalScope.set.get(key);
2021
+
2022
+ if (isModifiedGlobal(variable)) {
2023
+ continue
2024
+ }
2025
+
2026
+ yield* this._iterateVariableReferences(
2027
+ /** @type {Variable} */ (variable),
2028
+ path,
2029
+ nextTraceMap,
2030
+ true,
2031
+ );
2032
+ }
2033
+
2034
+ for (const key of this.globalObjectNames) {
2035
+ /** @type {string[]} */
2036
+ const path = [];
2037
+ const variable = this.globalScope.set.get(key);
2038
+
2039
+ if (isModifiedGlobal(variable)) {
2040
+ continue
2041
+ }
2042
+
2043
+ yield* this._iterateVariableReferences(
2044
+ /** @type {Variable} */ (variable),
2045
+ path,
2046
+ traceMap,
2047
+ false,
2048
+ );
2049
+ }
2050
+ }
2051
+
2052
+ /**
2053
+ * Iterate the references of CommonJS modules.
2054
+ * @template T
2055
+ * @param {TraceMap<T>} traceMap The trace map.
2056
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2057
+ */
2058
+ *iterateCjsReferences(traceMap) {
2059
+ for (const { node } of this.iterateGlobalReferences(requireCall)) {
2060
+ const key = getStringIfConstant(
2061
+ /** @type {CallExpression} */ (node).arguments[0],
2062
+ );
2063
+ if (key == null || !has(traceMap, key)) {
2064
+ continue
2065
+ }
2066
+
2067
+ const nextTraceMap = traceMap[key];
2068
+ const path = [key];
2069
+
2070
+ if (nextTraceMap[READ]) {
2071
+ yield {
2072
+ node,
2073
+ path,
2074
+ type: READ,
2075
+ info: nextTraceMap[READ],
2076
+ };
2077
+ }
2078
+ yield* this._iteratePropertyReferences(
2079
+ /** @type {CallExpression} */ (node),
2080
+ path,
2081
+ nextTraceMap,
2082
+ );
2083
+ }
2084
+ }
2085
+
2086
+ /**
2087
+ * Iterate the references of ES modules.
2088
+ * @template T
2089
+ * @param {TraceMap<T>} traceMap The trace map.
2090
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2091
+ */
2092
+ *iterateEsmReferences(traceMap) {
2093
+ const programNode = /** @type {Program} */ (this.globalScope.block);
2094
+
2095
+ for (const node of programNode.body) {
2096
+ if (!isHasSource(node)) {
2097
+ continue
2098
+ }
2099
+ const moduleId = /** @type {string} */ (node.source.value);
2100
+
2101
+ if (!has(traceMap, moduleId)) {
2102
+ continue
2103
+ }
2104
+ const nextTraceMap = traceMap[moduleId];
2105
+ const path = [moduleId];
2106
+
2107
+ if (nextTraceMap[READ]) {
2108
+ yield {
2109
+ // eslint-disable-next-line object-shorthand -- apply type
2110
+ node: /** @type {RuleNode} */ (node),
2111
+ path,
2112
+ type: READ,
2113
+ info: nextTraceMap[READ],
2114
+ };
2115
+ }
2116
+
2117
+ if (node.type === "ExportAllDeclaration") {
2118
+ for (const key of Object.keys(nextTraceMap)) {
2119
+ const exportTraceMap = nextTraceMap[key];
2120
+ if (exportTraceMap[READ]) {
2121
+ yield {
2122
+ // eslint-disable-next-line object-shorthand -- apply type
2123
+ node: /** @type {RuleNode} */ (node),
2124
+ path: path.concat(key),
2125
+ type: READ,
2126
+ info: exportTraceMap[READ],
2127
+ };
2128
+ }
2129
+ }
2130
+ } else {
2131
+ for (const specifier of node.specifiers) {
2132
+ const esm = has(nextTraceMap, ESM);
2133
+ const it = this._iterateImportReferences(
2134
+ specifier,
2135
+ path,
2136
+ esm
2137
+ ? nextTraceMap
2138
+ : this.mode === "legacy"
2139
+ ? { default: nextTraceMap, ...nextTraceMap }
2140
+ : { default: nextTraceMap },
2141
+ );
2142
+
2143
+ if (esm) {
2144
+ yield* it;
2145
+ } else {
2146
+ for (const report of it) {
2147
+ report.path = report.path.filter(exceptDefault);
2148
+ if (
2149
+ report.path.length >= 2 ||
2150
+ report.type !== READ
2151
+ ) {
2152
+ yield report;
2153
+ }
2154
+ }
2155
+ }
2156
+ }
2157
+ }
2158
+ }
2159
+ }
2160
+
2161
+ /**
2162
+ * Iterate the property references for a given expression AST node.
2163
+ * @template T
2164
+ * @param {Expression} node The expression AST node to iterate property references.
2165
+ * @param {TraceMap<T>} traceMap The trace map.
2166
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate property references.
2167
+ */
2168
+ *iteratePropertyReferences(node, traceMap) {
2169
+ yield* this._iteratePropertyReferences(node, [], traceMap);
2170
+ }
2171
+
2172
+ /**
2173
+ * Iterate the references for a given variable.
2174
+ * @private
2175
+ * @template T
2176
+ * @param {Variable} variable The variable to iterate that references.
2177
+ * @param {string[]} path The current path.
2178
+ * @param {TraceMapObject<T>} traceMap The trace map.
2179
+ * @param {boolean} shouldReport = The flag to report those references.
2180
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2181
+ */
2182
+ *_iterateVariableReferences(variable, path, traceMap, shouldReport) {
2183
+ if (this.variableStack.includes(variable)) {
2184
+ return
2185
+ }
2186
+ this.variableStack.push(variable);
2187
+ try {
2188
+ for (const reference of variable.references) {
2189
+ if (!reference.isRead()) {
2190
+ continue
2191
+ }
2192
+ const node = /** @type {RuleNode & Identifier} */ (
2193
+ reference.identifier
2194
+ );
2195
+
2196
+ if (shouldReport && traceMap[READ]) {
2197
+ yield { node, path, type: READ, info: traceMap[READ] };
2198
+ }
2199
+ yield* this._iteratePropertyReferences(node, path, traceMap);
2200
+ }
2201
+ } finally {
2202
+ this.variableStack.pop();
2203
+ }
2204
+ }
2205
+
2206
+ /**
2207
+ * Iterate the references for a given AST node.
2208
+ * @private
2209
+ * @template T
2210
+ * @param {Expression} rootNode The AST node to iterate references.
2211
+ * @param {string[]} path The current path.
2212
+ * @param {TraceMapObject<T>} traceMap The trace map.
2213
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2214
+ */
2215
+ //eslint-disable-next-line complexity
2216
+ *_iteratePropertyReferences(rootNode, path, traceMap) {
2217
+ let node = rootNode;
2218
+ while (isPassThrough(node)) {
2219
+ node = node.parent;
2220
+ }
2221
+
2222
+ const parent = /** @type {RuleNode} */ (node).parent;
2223
+ if (parent.type === "MemberExpression") {
2224
+ if (parent.object === node) {
2225
+ const key = getPropertyName(parent);
2226
+ if (key == null || !has(traceMap, key)) {
2227
+ return
2228
+ }
2229
+
2230
+ path = path.concat(key); //eslint-disable-line no-param-reassign
2231
+ const nextTraceMap = traceMap[key];
2232
+ if (nextTraceMap[READ]) {
2233
+ yield {
2234
+ node: parent,
2235
+ path,
2236
+ type: READ,
2237
+ info: nextTraceMap[READ],
2238
+ };
2239
+ }
2240
+ yield* this._iteratePropertyReferences(
2241
+ parent,
2242
+ path,
2243
+ nextTraceMap,
2244
+ );
2245
+ }
2246
+ return
2247
+ }
2248
+ if (parent.type === "CallExpression") {
2249
+ if (parent.callee === node && traceMap[CALL]) {
2250
+ yield { node: parent, path, type: CALL, info: traceMap[CALL] };
2251
+ }
2252
+ return
2253
+ }
2254
+ if (parent.type === "NewExpression") {
2255
+ if (parent.callee === node && traceMap[CONSTRUCT]) {
2256
+ yield {
2257
+ node: parent,
2258
+ path,
2259
+ type: CONSTRUCT,
2260
+ info: traceMap[CONSTRUCT],
2261
+ };
2262
+ }
2263
+ return
2264
+ }
2265
+ if (parent.type === "AssignmentExpression") {
2266
+ if (parent.right === node) {
2267
+ yield* this._iterateLhsReferences(parent.left, path, traceMap);
2268
+ yield* this._iteratePropertyReferences(parent, path, traceMap);
2269
+ }
2270
+ return
2271
+ }
2272
+ if (parent.type === "AssignmentPattern") {
2273
+ if (parent.right === node) {
2274
+ yield* this._iterateLhsReferences(parent.left, path, traceMap);
2275
+ }
2276
+ return
2277
+ }
2278
+ if (parent.type === "VariableDeclarator") {
2279
+ if (parent.init === node) {
2280
+ yield* this._iterateLhsReferences(parent.id, path, traceMap);
2281
+ }
2282
+ }
2283
+ }
2284
+
2285
+ /**
2286
+ * Iterate the references for a given Pattern node.
2287
+ * @private
2288
+ * @template T
2289
+ * @param {Pattern} patternNode The Pattern node to iterate references.
2290
+ * @param {string[]} path The current path.
2291
+ * @param {TraceMapObject<T>} traceMap The trace map.
2292
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2293
+ */
2294
+ *_iterateLhsReferences(patternNode, path, traceMap) {
2295
+ if (patternNode.type === "Identifier") {
2296
+ const variable = findVariable(this.globalScope, patternNode);
2297
+ if (variable != null) {
2298
+ yield* this._iterateVariableReferences(
2299
+ variable,
2300
+ path,
2301
+ traceMap,
2302
+ false,
2303
+ );
2304
+ }
2305
+ return
2306
+ }
2307
+ if (patternNode.type === "ObjectPattern") {
2308
+ for (const property of patternNode.properties) {
2309
+ const key = getPropertyName(
2310
+ /** @type {AssignmentProperty} */ (property),
2311
+ );
2312
+
2313
+ if (key == null || !has(traceMap, key)) {
2314
+ continue
2315
+ }
2316
+
2317
+ const nextPath = path.concat(key);
2318
+ const nextTraceMap = traceMap[key];
2319
+ if (nextTraceMap[READ]) {
2320
+ yield {
2321
+ node: /** @type {RuleNode} */ (property),
2322
+ path: nextPath,
2323
+ type: READ,
2324
+ info: nextTraceMap[READ],
2325
+ };
2326
+ }
2327
+ yield* this._iterateLhsReferences(
2328
+ /** @type {AssignmentProperty} */ (property).value,
2329
+ nextPath,
2330
+ nextTraceMap,
2331
+ );
2332
+ }
2333
+ return
2334
+ }
2335
+ if (patternNode.type === "AssignmentPattern") {
2336
+ yield* this._iterateLhsReferences(patternNode.left, path, traceMap);
2337
+ }
2338
+ }
2339
+
2340
+ /**
2341
+ * Iterate the references for a given ModuleSpecifier node.
2342
+ * @private
2343
+ * @template T
2344
+ * @param {ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier} specifierNode The ModuleSpecifier node to iterate references.
2345
+ * @param {string[]} path The current path.
2346
+ * @param {TraceMapObject<T>} traceMap The trace map.
2347
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2348
+ */
2349
+ *_iterateImportReferences(specifierNode, path, traceMap) {
2350
+ const type = specifierNode.type;
2351
+
2352
+ if (type === "ImportSpecifier" || type === "ImportDefaultSpecifier") {
2353
+ const key =
2354
+ type === "ImportDefaultSpecifier"
2355
+ ? "default"
2356
+ : specifierNode.imported.type === "Identifier"
2357
+ ? specifierNode.imported.name
2358
+ : specifierNode.imported.value;
2359
+ if (!has(traceMap, key)) {
2360
+ return
2361
+ }
2362
+
2363
+ path = path.concat(key); //eslint-disable-line no-param-reassign
2364
+ const nextTraceMap = traceMap[key];
2365
+ if (nextTraceMap[READ]) {
2366
+ yield {
2367
+ node: /** @type {RuleNode} */ (specifierNode),
2368
+ path,
2369
+ type: READ,
2370
+ info: nextTraceMap[READ],
2371
+ };
2372
+ }
2373
+ yield* this._iterateVariableReferences(
2374
+ /** @type {Variable} */ (
2375
+ findVariable(this.globalScope, specifierNode.local)
2376
+ ),
2377
+ path,
2378
+ nextTraceMap,
2379
+ false,
2380
+ );
2381
+
2382
+ return
2383
+ }
2384
+
2385
+ if (type === "ImportNamespaceSpecifier") {
2386
+ yield* this._iterateVariableReferences(
2387
+ /** @type {Variable} */ (
2388
+ findVariable(this.globalScope, specifierNode.local)
2389
+ ),
2390
+ path,
2391
+ traceMap,
2392
+ false,
2393
+ );
2394
+ return
2395
+ }
2396
+
2397
+ if (type === "ExportSpecifier") {
2398
+ const key =
2399
+ specifierNode.local.type === "Identifier"
2400
+ ? specifierNode.local.name
2401
+ : specifierNode.local.value;
2402
+ if (!has(traceMap, key)) {
2403
+ return
2404
+ }
2405
+
2406
+ path = path.concat(key); //eslint-disable-line no-param-reassign
2407
+ const nextTraceMap = traceMap[key];
2408
+ if (nextTraceMap[READ]) {
2409
+ yield {
2410
+ node: /** @type {RuleNode} */ (specifierNode),
2411
+ path,
2412
+ type: READ,
2413
+ info: nextTraceMap[READ],
2414
+ };
2415
+ }
2416
+ }
2417
+ }
2418
+ }
2419
+
2420
+ ReferenceTracker.READ = READ;
2421
+ ReferenceTracker.CALL = CALL;
2422
+ ReferenceTracker.CONSTRUCT = CONSTRUCT;
2423
+ ReferenceTracker.ESM = ESM;
2424
+
2425
+ /**
2426
+ * This is a predicate function for Array#filter.
2427
+ * @param {string} name A name part.
2428
+ * @param {number} index The index of the name.
2429
+ * @returns {boolean} `false` if it's default.
2430
+ */
2431
+ function exceptDefault(name, index) {
2432
+ return !(index === 1 && name === "default")
2433
+ }
2434
+
2435
+ /** @typedef {import("./types.mjs").StaticValue} StaticValue */
2436
+
2437
+ var index = {
2438
+ CALL,
2439
+ CONSTRUCT,
2440
+ ESM,
2441
+ findVariable,
2442
+ getFunctionHeadLocation,
2443
+ getFunctionNameWithKind,
2444
+ getInnermostScope,
2445
+ getPropertyName,
2446
+ getStaticValue,
2447
+ getStringIfConstant,
2448
+ hasSideEffect,
2449
+ isArrowToken,
2450
+ isClosingBraceToken,
2451
+ isClosingBracketToken,
2452
+ isClosingParenToken,
2453
+ isColonToken,
2454
+ isCommaToken,
2455
+ isCommentToken,
2456
+ isNotArrowToken,
2457
+ isNotClosingBraceToken,
2458
+ isNotClosingBracketToken,
2459
+ isNotClosingParenToken,
2460
+ isNotColonToken,
2461
+ isNotCommaToken,
2462
+ isNotCommentToken,
2463
+ isNotOpeningBraceToken,
2464
+ isNotOpeningBracketToken,
2465
+ isNotOpeningParenToken,
2466
+ isNotSemicolonToken,
2467
+ isOpeningBraceToken,
2468
+ isOpeningBracketToken,
2469
+ isOpeningParenToken,
2470
+ isParenthesized,
2471
+ isSemicolonToken,
2472
+ PatternMatcher,
2473
+ READ,
2474
+ ReferenceTracker,
2475
+ };
2476
+
2477
+ exports.CALL = CALL;
2478
+ exports.CONSTRUCT = CONSTRUCT;
2479
+ exports.ESM = ESM;
2480
+ exports.PatternMatcher = PatternMatcher;
2481
+ exports.READ = READ;
2482
+ exports.ReferenceTracker = ReferenceTracker;
2483
+ exports["default"] = index;
2484
+ exports.findVariable = findVariable;
2485
+ exports.getFunctionHeadLocation = getFunctionHeadLocation;
2486
+ exports.getFunctionNameWithKind = getFunctionNameWithKind;
2487
+ exports.getInnermostScope = getInnermostScope;
2488
+ exports.getPropertyName = getPropertyName;
2489
+ exports.getStaticValue = getStaticValue;
2490
+ exports.getStringIfConstant = getStringIfConstant;
2491
+ exports.hasSideEffect = hasSideEffect;
2492
+ exports.isArrowToken = isArrowToken;
2493
+ exports.isClosingBraceToken = isClosingBraceToken;
2494
+ exports.isClosingBracketToken = isClosingBracketToken;
2495
+ exports.isClosingParenToken = isClosingParenToken;
2496
+ exports.isColonToken = isColonToken;
2497
+ exports.isCommaToken = isCommaToken;
2498
+ exports.isCommentToken = isCommentToken;
2499
+ exports.isNotArrowToken = isNotArrowToken;
2500
+ exports.isNotClosingBraceToken = isNotClosingBraceToken;
2501
+ exports.isNotClosingBracketToken = isNotClosingBracketToken;
2502
+ exports.isNotClosingParenToken = isNotClosingParenToken;
2503
+ exports.isNotColonToken = isNotColonToken;
2504
+ exports.isNotCommaToken = isNotCommaToken;
2505
+ exports.isNotCommentToken = isNotCommentToken;
2506
+ exports.isNotOpeningBraceToken = isNotOpeningBraceToken;
2507
+ exports.isNotOpeningBracketToken = isNotOpeningBracketToken;
2508
+ exports.isNotOpeningParenToken = isNotOpeningParenToken;
2509
+ exports.isNotSemicolonToken = isNotSemicolonToken;
2510
+ exports.isOpeningBraceToken = isOpeningBraceToken;
2511
+ exports.isOpeningBracketToken = isOpeningBracketToken;
2512
+ exports.isOpeningParenToken = isOpeningParenToken;
2513
+ exports.isParenthesized = isParenthesized;
2514
+ exports.isSemicolonToken = isSemicolonToken;
2515
+
2516
+ } (eslintUtils$1));
2517
+ return eslintUtils$1;
2518
+ }
2519
+
2520
+ var hasRequiredAstUtilities;
2521
+
2522
+ function requireAstUtilities () {
2523
+ if (hasRequiredAstUtilities) return astUtilities;
2524
+ hasRequiredAstUtilities = 1;
2525
+ var __createBinding = (astUtilities && astUtilities.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2526
+ if (k2 === undefined) k2 = k;
2527
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2528
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2529
+ desc = { enumerable: true, get: function() { return m[k]; } };
2530
+ }
2531
+ Object.defineProperty(o, k2, desc);
2532
+ }) : (function(o, m, k, k2) {
2533
+ if (k2 === undefined) k2 = k;
2534
+ o[k2] = m[k];
2535
+ }));
2536
+ var __setModuleDefault = (astUtilities && astUtilities.__setModuleDefault) || (Object.create ? (function(o, v) {
2537
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
2538
+ }) : function(o, v) {
2539
+ o["default"] = v;
2540
+ });
2541
+ var __importStar = (astUtilities && astUtilities.__importStar) || (function () {
2542
+ var ownKeys = function(o) {
2543
+ ownKeys = Object.getOwnPropertyNames || function (o) {
2544
+ var ar = [];
2545
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
2546
+ return ar;
2547
+ };
2548
+ return ownKeys(o);
2549
+ };
2550
+ return function (mod) {
2551
+ if (mod && mod.__esModule) return mod;
2552
+ var result = {};
2553
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
2554
+ __setModuleDefault(result, mod);
2555
+ return result;
2556
+ };
2557
+ })();
2558
+ Object.defineProperty(astUtilities, "__esModule", { value: true });
2559
+ astUtilities.isParenthesized = astUtilities.hasSideEffect = astUtilities.getStringIfConstant = astUtilities.getStaticValue = astUtilities.getPropertyName = astUtilities.getFunctionNameWithKind = astUtilities.getFunctionHeadLocation = void 0;
2560
+ const eslintUtils = __importStar(/*@__PURE__*/ requireEslintUtils$2());
2561
+ /**
2562
+ * Get the proper location of a given function node to report.
2563
+ *
2564
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getfunctionheadlocation}
2565
+ */
2566
+ astUtilities.getFunctionHeadLocation = eslintUtils.getFunctionHeadLocation;
2567
+ /**
2568
+ * Get the name and kind of a given function node.
2569
+ *
2570
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getfunctionnamewithkind}
2571
+ */
2572
+ astUtilities.getFunctionNameWithKind = eslintUtils.getFunctionNameWithKind;
2573
+ /**
2574
+ * Get the property name of a given property node.
2575
+ * If the node is a computed property, this tries to compute the property name by the getStringIfConstant function.
2576
+ *
2577
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getpropertyname}
2578
+ * @returns The property name of the node. If the property name is not constant then it returns `null`.
2579
+ */
2580
+ astUtilities.getPropertyName = eslintUtils.getPropertyName;
2581
+ /**
2582
+ * Get the value of a given node if it can decide the value statically.
2583
+ * If the 2nd parameter `initialScope` was given, this function tries to resolve identifier references which are in the
2584
+ * given node as much as possible. In the resolving way, it does on the assumption that built-in global objects have
2585
+ * not been modified.
2586
+ * For example, it considers `Symbol.iterator`, `Symbol.for('k')`, ` String.raw``hello`` `, and `Object.freeze({a: 1}).a` as static, but `Symbol('k')` is not static.
2587
+ *
2588
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getstaticvalue}
2589
+ * @returns The `{ value: any }` shaped object. The `value` property is the static value. If it couldn't compute the
2590
+ * static value of the node, it returns `null`.
2591
+ */
2592
+ astUtilities.getStaticValue = eslintUtils.getStaticValue;
2593
+ /**
2594
+ * Get the string value of a given node.
2595
+ * This function is a tiny wrapper of the getStaticValue function.
2596
+ *
2597
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getstringifconstant}
2598
+ */
2599
+ astUtilities.getStringIfConstant = eslintUtils.getStringIfConstant;
2600
+ /**
2601
+ * Check whether a given node has any side effect or not.
2602
+ * The side effect means that it may modify a certain variable or object member. This function considers the node which
2603
+ * contains the following types as the node which has side effects:
2604
+ * - `AssignmentExpression`
2605
+ * - `AwaitExpression`
2606
+ * - `CallExpression`
2607
+ * - `ImportExpression`
2608
+ * - `NewExpression`
2609
+ * - `UnaryExpression([operator = "delete"])`
2610
+ * - `UpdateExpression`
2611
+ * - `YieldExpression`
2612
+ * - When `options.considerGetters` is `true`:
2613
+ * - `MemberExpression`
2614
+ * - When `options.considerImplicitTypeConversion` is `true`:
2615
+ * - `BinaryExpression([operator = "==" | "!=" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "in"])`
2616
+ * - `MemberExpression([computed = true])`
2617
+ * - `MethodDefinition([computed = true])`
2618
+ * - `Property([computed = true])`
2619
+ * - `UnaryExpression([operator = "-" | "+" | "!" | "~"])`
2620
+ *
2621
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#hassideeffect}
2622
+ */
2623
+ astUtilities.hasSideEffect = eslintUtils.hasSideEffect;
2624
+ astUtilities.isParenthesized = eslintUtils.isParenthesized;
2625
+ return astUtilities;
2626
+ }
2627
+
2628
+ var PatternMatcher = {};
2629
+
2630
+ var hasRequiredPatternMatcher;
2631
+
2632
+ function requirePatternMatcher () {
2633
+ if (hasRequiredPatternMatcher) return PatternMatcher;
2634
+ hasRequiredPatternMatcher = 1;
2635
+ var __createBinding = (PatternMatcher && PatternMatcher.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2636
+ if (k2 === undefined) k2 = k;
2637
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2638
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2639
+ desc = { enumerable: true, get: function() { return m[k]; } };
2640
+ }
2641
+ Object.defineProperty(o, k2, desc);
2642
+ }) : (function(o, m, k, k2) {
2643
+ if (k2 === undefined) k2 = k;
2644
+ o[k2] = m[k];
2645
+ }));
2646
+ var __setModuleDefault = (PatternMatcher && PatternMatcher.__setModuleDefault) || (Object.create ? (function(o, v) {
2647
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
2648
+ }) : function(o, v) {
2649
+ o["default"] = v;
2650
+ });
2651
+ var __importStar = (PatternMatcher && PatternMatcher.__importStar) || (function () {
2652
+ var ownKeys = function(o) {
2653
+ ownKeys = Object.getOwnPropertyNames || function (o) {
2654
+ var ar = [];
2655
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
2656
+ return ar;
2657
+ };
2658
+ return ownKeys(o);
2659
+ };
2660
+ return function (mod) {
2661
+ if (mod && mod.__esModule) return mod;
2662
+ var result = {};
2663
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
2664
+ __setModuleDefault(result, mod);
2665
+ return result;
2666
+ };
2667
+ })();
2668
+ Object.defineProperty(PatternMatcher, "__esModule", { value: true });
2669
+ PatternMatcher.PatternMatcher = void 0;
2670
+ const eslintUtils = __importStar(/*@__PURE__*/ requireEslintUtils$2());
2671
+ /**
2672
+ * The class to find a pattern in strings as handling escape sequences.
2673
+ * It ignores the found pattern if it's escaped with `\`.
2674
+ *
2675
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#patternmatcher-class}
2676
+ */
2677
+ PatternMatcher.PatternMatcher = eslintUtils.PatternMatcher;
2678
+ return PatternMatcher;
2679
+ }
2680
+
2681
+ var predicates$1 = {};
2682
+
2683
+ var hasRequiredPredicates$1;
2684
+
2685
+ function requirePredicates$1 () {
2686
+ if (hasRequiredPredicates$1) return predicates$1;
2687
+ hasRequiredPredicates$1 = 1;
2688
+ var __createBinding = (predicates$1 && predicates$1.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2689
+ if (k2 === undefined) k2 = k;
2690
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2691
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2692
+ desc = { enumerable: true, get: function() { return m[k]; } };
2693
+ }
2694
+ Object.defineProperty(o, k2, desc);
2695
+ }) : (function(o, m, k, k2) {
2696
+ if (k2 === undefined) k2 = k;
2697
+ o[k2] = m[k];
2698
+ }));
2699
+ var __setModuleDefault = (predicates$1 && predicates$1.__setModuleDefault) || (Object.create ? (function(o, v) {
2700
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
2701
+ }) : function(o, v) {
2702
+ o["default"] = v;
2703
+ });
2704
+ var __importStar = (predicates$1 && predicates$1.__importStar) || (function () {
2705
+ var ownKeys = function(o) {
2706
+ ownKeys = Object.getOwnPropertyNames || function (o) {
2707
+ var ar = [];
2708
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
2709
+ return ar;
2710
+ };
2711
+ return ownKeys(o);
2712
+ };
2713
+ return function (mod) {
2714
+ if (mod && mod.__esModule) return mod;
2715
+ var result = {};
2716
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
2717
+ __setModuleDefault(result, mod);
2718
+ return result;
2719
+ };
2720
+ })();
2721
+ Object.defineProperty(predicates$1, "__esModule", { value: true });
2722
+ predicates$1.isNotSemicolonToken = predicates$1.isSemicolonToken = predicates$1.isNotOpeningParenToken = predicates$1.isOpeningParenToken = predicates$1.isNotOpeningBracketToken = predicates$1.isOpeningBracketToken = predicates$1.isNotOpeningBraceToken = predicates$1.isOpeningBraceToken = predicates$1.isNotCommentToken = predicates$1.isCommentToken = predicates$1.isNotCommaToken = predicates$1.isCommaToken = predicates$1.isNotColonToken = predicates$1.isColonToken = predicates$1.isNotClosingParenToken = predicates$1.isClosingParenToken = predicates$1.isNotClosingBracketToken = predicates$1.isClosingBracketToken = predicates$1.isNotClosingBraceToken = predicates$1.isClosingBraceToken = predicates$1.isNotArrowToken = predicates$1.isArrowToken = void 0;
2723
+ const eslintUtils = __importStar(/*@__PURE__*/ requireEslintUtils$2());
2724
+ predicates$1.isArrowToken = eslintUtils.isArrowToken;
2725
+ predicates$1.isNotArrowToken = eslintUtils.isNotArrowToken;
2726
+ predicates$1.isClosingBraceToken = eslintUtils.isClosingBraceToken;
2727
+ predicates$1.isNotClosingBraceToken = eslintUtils.isNotClosingBraceToken;
2728
+ predicates$1.isClosingBracketToken = eslintUtils.isClosingBracketToken;
2729
+ predicates$1.isNotClosingBracketToken = eslintUtils.isNotClosingBracketToken;
2730
+ predicates$1.isClosingParenToken = eslintUtils.isClosingParenToken;
2731
+ predicates$1.isNotClosingParenToken = eslintUtils.isNotClosingParenToken;
2732
+ predicates$1.isColonToken = eslintUtils.isColonToken;
2733
+ predicates$1.isNotColonToken = eslintUtils.isNotColonToken;
2734
+ predicates$1.isCommaToken = eslintUtils.isCommaToken;
2735
+ predicates$1.isNotCommaToken = eslintUtils.isNotCommaToken;
2736
+ predicates$1.isCommentToken = eslintUtils.isCommentToken;
2737
+ predicates$1.isNotCommentToken = eslintUtils.isNotCommentToken;
2738
+ predicates$1.isOpeningBraceToken = eslintUtils.isOpeningBraceToken;
2739
+ predicates$1.isNotOpeningBraceToken = eslintUtils.isNotOpeningBraceToken;
2740
+ predicates$1.isOpeningBracketToken = eslintUtils.isOpeningBracketToken;
2741
+ predicates$1.isNotOpeningBracketToken = eslintUtils.isNotOpeningBracketToken;
2742
+ predicates$1.isOpeningParenToken = eslintUtils.isOpeningParenToken;
2743
+ predicates$1.isNotOpeningParenToken = eslintUtils.isNotOpeningParenToken;
2744
+ predicates$1.isSemicolonToken = eslintUtils.isSemicolonToken;
2745
+ predicates$1.isNotSemicolonToken = eslintUtils.isNotSemicolonToken;
2746
+ return predicates$1;
2747
+ }
2748
+
2749
+ var ReferenceTracker = {};
2750
+
2751
+ var hasRequiredReferenceTracker;
2752
+
2753
+ function requireReferenceTracker () {
2754
+ if (hasRequiredReferenceTracker) return ReferenceTracker;
2755
+ hasRequiredReferenceTracker = 1;
2756
+ var __createBinding = (ReferenceTracker && ReferenceTracker.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2757
+ if (k2 === undefined) k2 = k;
2758
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2759
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2760
+ desc = { enumerable: true, get: function() { return m[k]; } };
2761
+ }
2762
+ Object.defineProperty(o, k2, desc);
2763
+ }) : (function(o, m, k, k2) {
2764
+ if (k2 === undefined) k2 = k;
2765
+ o[k2] = m[k];
2766
+ }));
2767
+ var __setModuleDefault = (ReferenceTracker && ReferenceTracker.__setModuleDefault) || (Object.create ? (function(o, v) {
2768
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
2769
+ }) : function(o, v) {
2770
+ o["default"] = v;
2771
+ });
2772
+ var __importStar = (ReferenceTracker && ReferenceTracker.__importStar) || (function () {
2773
+ var ownKeys = function(o) {
2774
+ ownKeys = Object.getOwnPropertyNames || function (o) {
2775
+ var ar = [];
2776
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
2777
+ return ar;
2778
+ };
2779
+ return ownKeys(o);
2780
+ };
2781
+ return function (mod) {
2782
+ if (mod && mod.__esModule) return mod;
2783
+ var result = {};
2784
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
2785
+ __setModuleDefault(result, mod);
2786
+ return result;
2787
+ };
2788
+ })();
2789
+ Object.defineProperty(ReferenceTracker, "__esModule", { value: true });
2790
+ ReferenceTracker.ReferenceTracker = void 0;
2791
+ /* eslint-disable @typescript-eslint/no-namespace */
2792
+ const eslintUtils = __importStar(/*@__PURE__*/ requireEslintUtils$2());
2793
+ eslintUtils.ReferenceTracker.READ;
2794
+ eslintUtils.ReferenceTracker.CALL;
2795
+ eslintUtils.ReferenceTracker.CONSTRUCT;
2796
+ eslintUtils.ReferenceTracker.ESM;
2797
+ /**
2798
+ * The tracker for references. This provides reference tracking for global variables, CommonJS modules, and ES modules.
2799
+ *
2800
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#referencetracker-class}
2801
+ */
2802
+ ReferenceTracker.ReferenceTracker = eslintUtils.ReferenceTracker;
2803
+ return ReferenceTracker;
2804
+ }
2805
+
2806
+ var scopeAnalysis = {};
2807
+
2808
+ var hasRequiredScopeAnalysis;
2809
+
2810
+ function requireScopeAnalysis () {
2811
+ if (hasRequiredScopeAnalysis) return scopeAnalysis;
2812
+ hasRequiredScopeAnalysis = 1;
2813
+ var __createBinding = (scopeAnalysis && scopeAnalysis.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2814
+ if (k2 === undefined) k2 = k;
2815
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2816
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2817
+ desc = { enumerable: true, get: function() { return m[k]; } };
2818
+ }
2819
+ Object.defineProperty(o, k2, desc);
2820
+ }) : (function(o, m, k, k2) {
2821
+ if (k2 === undefined) k2 = k;
2822
+ o[k2] = m[k];
2823
+ }));
2824
+ var __setModuleDefault = (scopeAnalysis && scopeAnalysis.__setModuleDefault) || (Object.create ? (function(o, v) {
2825
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
2826
+ }) : function(o, v) {
2827
+ o["default"] = v;
2828
+ });
2829
+ var __importStar = (scopeAnalysis && scopeAnalysis.__importStar) || (function () {
2830
+ var ownKeys = function(o) {
2831
+ ownKeys = Object.getOwnPropertyNames || function (o) {
2832
+ var ar = [];
2833
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
2834
+ return ar;
2835
+ };
2836
+ return ownKeys(o);
2837
+ };
2838
+ return function (mod) {
2839
+ if (mod && mod.__esModule) return mod;
2840
+ var result = {};
2841
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
2842
+ __setModuleDefault(result, mod);
2843
+ return result;
2844
+ };
2845
+ })();
2846
+ Object.defineProperty(scopeAnalysis, "__esModule", { value: true });
2847
+ scopeAnalysis.getInnermostScope = scopeAnalysis.findVariable = void 0;
2848
+ const eslintUtils = __importStar(/*@__PURE__*/ requireEslintUtils$2());
2849
+ /**
2850
+ * Get the variable of a given name.
2851
+ *
2852
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#findvariable}
2853
+ */
2854
+ scopeAnalysis.findVariable = eslintUtils.findVariable;
2855
+ /**
2856
+ * Get the innermost scope which contains a given node.
2857
+ *
2858
+ * @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#getinnermostscope}
2859
+ * @returns The innermost scope which contains the given node.
2860
+ * If such scope doesn't exist then it returns the 1st argument `initialScope`.
2861
+ */
2862
+ scopeAnalysis.getInnermostScope = eslintUtils.getInnermostScope;
2863
+ return scopeAnalysis;
2864
+ }
2865
+
2866
+ var hasRequiredEslintUtils$1;
2867
+
2868
+ function requireEslintUtils$1 () {
2869
+ if (hasRequiredEslintUtils$1) return eslintUtils$2;
2870
+ hasRequiredEslintUtils$1 = 1;
2871
+ (function (exports) {
2872
+ var __createBinding = (eslintUtils$2 && eslintUtils$2.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2873
+ if (k2 === undefined) k2 = k;
2874
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2875
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2876
+ desc = { enumerable: true, get: function() { return m[k]; } };
2877
+ }
2878
+ Object.defineProperty(o, k2, desc);
2879
+ }) : (function(o, m, k, k2) {
2880
+ if (k2 === undefined) k2 = k;
2881
+ o[k2] = m[k];
2882
+ }));
2883
+ var __exportStar = (eslintUtils$2 && eslintUtils$2.__exportStar) || function(m, exports) {
2884
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2885
+ };
2886
+ Object.defineProperty(exports, "__esModule", { value: true });
2887
+ __exportStar(requireAstUtilities(), exports);
2888
+ __exportStar(requirePatternMatcher(), exports);
2889
+ __exportStar(requirePredicates$1(), exports);
2890
+ __exportStar(requireReferenceTracker(), exports);
2891
+ __exportStar(requireScopeAnalysis(), exports);
2892
+ } (eslintUtils$2));
2893
+ return eslintUtils$2;
2894
+ }
2895
+
2896
+ var helpers = {};
2897
+
2898
+ var hasRequiredHelpers;
2899
+
2900
+ function requireHelpers () {
2901
+ if (hasRequiredHelpers) return helpers;
2902
+ hasRequiredHelpers = 1;
2903
+ (function (exports) {
2904
+ Object.defineProperty(exports, "__esModule", { value: true });
2905
+ exports.isNotTokenOfTypeWithConditions = exports.isTokenOfTypeWithConditions = exports.isNodeOfTypeWithConditions = exports.isNodeOfTypes = exports.isNodeOfType = void 0;
2906
+ const isNodeOfType = (nodeType) => (node) => node?.type === nodeType;
2907
+ exports.isNodeOfType = isNodeOfType;
2908
+ const isNodeOfTypes = (nodeTypes) => (node) => !!node && nodeTypes.includes(node.type);
2909
+ exports.isNodeOfTypes = isNodeOfTypes;
2910
+ const isNodeOfTypeWithConditions = (nodeType, conditions) => {
2911
+ const entries = Object.entries(conditions);
2912
+ return (node) => node?.type === nodeType &&
2913
+ entries.every(([key, value]) => node[key] === value);
2914
+ };
2915
+ exports.isNodeOfTypeWithConditions = isNodeOfTypeWithConditions;
2916
+ const isTokenOfTypeWithConditions = (tokenType, conditions) => {
2917
+ const entries = Object.entries(conditions);
2918
+ return (token) => token?.type === tokenType &&
2919
+ entries.every(([key, value]) => token[key] === value);
2920
+ };
2921
+ exports.isTokenOfTypeWithConditions = isTokenOfTypeWithConditions;
2922
+ const isNotTokenOfTypeWithConditions = (tokenType, conditions) => (token) => !(0, exports.isTokenOfTypeWithConditions)(tokenType, conditions)(token);
2923
+ exports.isNotTokenOfTypeWithConditions = isNotTokenOfTypeWithConditions;
2924
+ } (helpers));
2925
+ return helpers;
2926
+ }
2927
+
2928
+ var misc = {};
2929
+
2930
+ var hasRequiredMisc;
2931
+
2932
+ function requireMisc () {
2933
+ if (hasRequiredMisc) return misc;
2934
+ hasRequiredMisc = 1;
2935
+ Object.defineProperty(misc, "__esModule", { value: true });
2936
+ misc.LINEBREAK_MATCHER = void 0;
2937
+ misc.isTokenOnSameLine = isTokenOnSameLine;
2938
+ misc.LINEBREAK_MATCHER = /\r\n|[\r\n\u2028\u2029]/;
2939
+ /**
2940
+ * Determines whether two adjacent tokens are on the same line
2941
+ */
2942
+ function isTokenOnSameLine(left, right) {
2943
+ return left.loc.end.line === right.loc.start.line;
2944
+ }
2945
+ return misc;
2946
+ }
2947
+
2948
+ var predicates = {};
2949
+
2950
+ var tsEstree = {};
2951
+
2952
+ var hasRequiredTsEstree;
2953
+
2954
+ function requireTsEstree () {
2955
+ if (hasRequiredTsEstree) return tsEstree;
2956
+ hasRequiredTsEstree = 1;
2957
+ (function (exports) {
2958
+ // for convenience's sake - export the types directly from here so consumers
2959
+ // don't need to reference/install both packages in their code
2960
+ Object.defineProperty(exports, "__esModule", { value: true });
2961
+ exports.TSESTree = exports.AST_TOKEN_TYPES = exports.AST_NODE_TYPES = void 0;
2962
+ var types_1 = requireDist$1();
2963
+ Object.defineProperty(exports, "AST_NODE_TYPES", { enumerable: true, get: function () { return types_1.AST_NODE_TYPES; } });
2964
+ Object.defineProperty(exports, "AST_TOKEN_TYPES", { enumerable: true, get: function () { return types_1.AST_TOKEN_TYPES; } });
2965
+ Object.defineProperty(exports, "TSESTree", { enumerable: true, get: function () { return types_1.TSESTree; } });
2966
+ } (tsEstree));
2967
+ return tsEstree;
2968
+ }
2969
+
2970
+ var hasRequiredPredicates;
2971
+
2972
+ function requirePredicates () {
2973
+ if (hasRequiredPredicates) return predicates;
2974
+ hasRequiredPredicates = 1;
2975
+ Object.defineProperty(predicates, "__esModule", { value: true });
2976
+ predicates.isLoop = predicates.isImportKeyword = predicates.isTypeKeyword = predicates.isAwaitKeyword = predicates.isAwaitExpression = predicates.isIdentifier = predicates.isConstructor = predicates.isClassOrTypeElement = predicates.isTSConstructorType = predicates.isTSFunctionType = predicates.isFunctionOrFunctionType = predicates.isFunctionType = predicates.isFunction = predicates.isVariableDeclarator = predicates.isTypeAssertion = predicates.isLogicalOrOperator = predicates.isOptionalCallExpression = predicates.isNotNonNullAssertionPunctuator = predicates.isNonNullAssertionPunctuator = predicates.isNotOptionalChainPunctuator = predicates.isOptionalChainPunctuator = void 0;
2977
+ predicates.isSetter = isSetter;
2978
+ const ts_estree_1 = requireTsEstree();
2979
+ const helpers_1 = requireHelpers();
2980
+ predicates.isOptionalChainPunctuator = (0, helpers_1.isTokenOfTypeWithConditions)(ts_estree_1.AST_TOKEN_TYPES.Punctuator, { value: '?.' });
2981
+ predicates.isNotOptionalChainPunctuator = (0, helpers_1.isNotTokenOfTypeWithConditions)(ts_estree_1.AST_TOKEN_TYPES.Punctuator, { value: '?.' });
2982
+ predicates.isNonNullAssertionPunctuator = (0, helpers_1.isTokenOfTypeWithConditions)(ts_estree_1.AST_TOKEN_TYPES.Punctuator, { value: '!' });
2983
+ predicates.isNotNonNullAssertionPunctuator = (0, helpers_1.isNotTokenOfTypeWithConditions)(ts_estree_1.AST_TOKEN_TYPES.Punctuator, { value: '!' });
2984
+ /**
2985
+ * Returns true if and only if the node represents: foo?.() or foo.bar?.()
2986
+ */
2987
+ predicates.isOptionalCallExpression = (0, helpers_1.isNodeOfTypeWithConditions)(ts_estree_1.AST_NODE_TYPES.CallExpression,
2988
+ // this flag means the call expression itself is option
2989
+ // i.e. it is foo.bar?.() and not foo?.bar()
2990
+ { optional: true });
2991
+ /**
2992
+ * Returns true if and only if the node represents logical OR
2993
+ */
2994
+ predicates.isLogicalOrOperator = (0, helpers_1.isNodeOfTypeWithConditions)(ts_estree_1.AST_NODE_TYPES.LogicalExpression, { operator: '||' });
2995
+ /**
2996
+ * Checks if a node is a type assertion:
2997
+ * ```
2998
+ * x as foo
2999
+ * <foo>x
3000
+ * ```
3001
+ */
3002
+ predicates.isTypeAssertion = (0, helpers_1.isNodeOfTypes)([
3003
+ ts_estree_1.AST_NODE_TYPES.TSAsExpression,
3004
+ ts_estree_1.AST_NODE_TYPES.TSTypeAssertion,
3005
+ ]);
3006
+ predicates.isVariableDeclarator = (0, helpers_1.isNodeOfType)(ts_estree_1.AST_NODE_TYPES.VariableDeclarator);
3007
+ const functionTypes = [
3008
+ ts_estree_1.AST_NODE_TYPES.ArrowFunctionExpression,
3009
+ ts_estree_1.AST_NODE_TYPES.FunctionDeclaration,
3010
+ ts_estree_1.AST_NODE_TYPES.FunctionExpression,
3011
+ ];
3012
+ predicates.isFunction = (0, helpers_1.isNodeOfTypes)(functionTypes);
3013
+ const functionTypeTypes = [
3014
+ ts_estree_1.AST_NODE_TYPES.TSCallSignatureDeclaration,
3015
+ ts_estree_1.AST_NODE_TYPES.TSConstructorType,
3016
+ ts_estree_1.AST_NODE_TYPES.TSConstructSignatureDeclaration,
3017
+ ts_estree_1.AST_NODE_TYPES.TSDeclareFunction,
3018
+ ts_estree_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
3019
+ ts_estree_1.AST_NODE_TYPES.TSFunctionType,
3020
+ ts_estree_1.AST_NODE_TYPES.TSMethodSignature,
3021
+ ];
3022
+ predicates.isFunctionType = (0, helpers_1.isNodeOfTypes)(functionTypeTypes);
3023
+ predicates.isFunctionOrFunctionType = (0, helpers_1.isNodeOfTypes)([
3024
+ ...functionTypes,
3025
+ ...functionTypeTypes,
3026
+ ]);
3027
+ predicates.isTSFunctionType = (0, helpers_1.isNodeOfType)(ts_estree_1.AST_NODE_TYPES.TSFunctionType);
3028
+ predicates.isTSConstructorType = (0, helpers_1.isNodeOfType)(ts_estree_1.AST_NODE_TYPES.TSConstructorType);
3029
+ predicates.isClassOrTypeElement = (0, helpers_1.isNodeOfTypes)([
3030
+ // ClassElement
3031
+ ts_estree_1.AST_NODE_TYPES.PropertyDefinition,
3032
+ ts_estree_1.AST_NODE_TYPES.FunctionExpression,
3033
+ ts_estree_1.AST_NODE_TYPES.MethodDefinition,
3034
+ ts_estree_1.AST_NODE_TYPES.TSAbstractPropertyDefinition,
3035
+ ts_estree_1.AST_NODE_TYPES.TSAbstractMethodDefinition,
3036
+ ts_estree_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
3037
+ ts_estree_1.AST_NODE_TYPES.TSIndexSignature,
3038
+ // TypeElement
3039
+ ts_estree_1.AST_NODE_TYPES.TSCallSignatureDeclaration,
3040
+ ts_estree_1.AST_NODE_TYPES.TSConstructSignatureDeclaration,
3041
+ // AST_NODE_TYPES.TSIndexSignature,
3042
+ ts_estree_1.AST_NODE_TYPES.TSMethodSignature,
3043
+ ts_estree_1.AST_NODE_TYPES.TSPropertySignature,
3044
+ ]);
3045
+ /**
3046
+ * Checks if a node is a constructor method.
3047
+ */
3048
+ predicates.isConstructor = (0, helpers_1.isNodeOfTypeWithConditions)(ts_estree_1.AST_NODE_TYPES.MethodDefinition, { kind: 'constructor' });
3049
+ /**
3050
+ * Checks if a node is a setter method.
3051
+ */
3052
+ function isSetter(node) {
3053
+ return (!!node &&
3054
+ (node.type === ts_estree_1.AST_NODE_TYPES.MethodDefinition ||
3055
+ node.type === ts_estree_1.AST_NODE_TYPES.Property) &&
3056
+ node.kind === 'set');
3057
+ }
3058
+ predicates.isIdentifier = (0, helpers_1.isNodeOfType)(ts_estree_1.AST_NODE_TYPES.Identifier);
3059
+ /**
3060
+ * Checks if a node represents an `await …` expression.
3061
+ */
3062
+ predicates.isAwaitExpression = (0, helpers_1.isNodeOfType)(ts_estree_1.AST_NODE_TYPES.AwaitExpression);
3063
+ /**
3064
+ * Checks if a possible token is the `await` keyword.
3065
+ */
3066
+ predicates.isAwaitKeyword = (0, helpers_1.isTokenOfTypeWithConditions)(ts_estree_1.AST_TOKEN_TYPES.Identifier, { value: 'await' });
3067
+ /**
3068
+ * Checks if a possible token is the `type` keyword.
3069
+ */
3070
+ predicates.isTypeKeyword = (0, helpers_1.isTokenOfTypeWithConditions)(ts_estree_1.AST_TOKEN_TYPES.Identifier, { value: 'type' });
3071
+ /**
3072
+ * Checks if a possible token is the `import` keyword.
3073
+ */
3074
+ predicates.isImportKeyword = (0, helpers_1.isTokenOfTypeWithConditions)(ts_estree_1.AST_TOKEN_TYPES.Keyword, { value: 'import' });
3075
+ predicates.isLoop = (0, helpers_1.isNodeOfTypes)([
3076
+ ts_estree_1.AST_NODE_TYPES.DoWhileStatement,
3077
+ ts_estree_1.AST_NODE_TYPES.ForStatement,
3078
+ ts_estree_1.AST_NODE_TYPES.ForInStatement,
3079
+ ts_estree_1.AST_NODE_TYPES.ForOfStatement,
3080
+ ts_estree_1.AST_NODE_TYPES.WhileStatement,
3081
+ ]);
3082
+ return predicates;
3083
+ }
3084
+
3085
+ var hasRequiredAstUtils;
3086
+
3087
+ function requireAstUtils () {
3088
+ if (hasRequiredAstUtils) return astUtils;
3089
+ hasRequiredAstUtils = 1;
3090
+ (function (exports) {
3091
+ var __createBinding = (astUtils && astUtils.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3092
+ if (k2 === undefined) k2 = k;
3093
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3094
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3095
+ desc = { enumerable: true, get: function() { return m[k]; } };
3096
+ }
3097
+ Object.defineProperty(o, k2, desc);
3098
+ }) : (function(o, m, k, k2) {
3099
+ if (k2 === undefined) k2 = k;
3100
+ o[k2] = m[k];
3101
+ }));
3102
+ var __exportStar = (astUtils && astUtils.__exportStar) || function(m, exports) {
3103
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3104
+ };
3105
+ Object.defineProperty(exports, "__esModule", { value: true });
3106
+ __exportStar(requireEslintUtils$1(), exports);
3107
+ __exportStar(requireHelpers(), exports);
3108
+ __exportStar(requireMisc(), exports);
3109
+ __exportStar(requirePredicates(), exports);
3110
+ } (astUtils));
3111
+ return astUtils;
3112
+ }
3113
+
3114
+ var eslintUtils = {};
3115
+
3116
+ var applyDefault = {};
3117
+
3118
+ var deepMerge = {};
3119
+
3120
+ var hasRequiredDeepMerge;
3121
+
3122
+ function requireDeepMerge () {
3123
+ if (hasRequiredDeepMerge) return deepMerge;
3124
+ hasRequiredDeepMerge = 1;
3125
+ Object.defineProperty(deepMerge, "__esModule", { value: true });
3126
+ deepMerge.isObjectNotArray = isObjectNotArray;
3127
+ deepMerge.deepMerge = deepMerge$1;
3128
+ /**
3129
+ * Check if the variable contains an object strictly rejecting arrays
3130
+ * @returns `true` if obj is an object
3131
+ */
3132
+ function isObjectNotArray(obj) {
3133
+ return typeof obj === 'object' && obj != null && !Array.isArray(obj);
3134
+ }
3135
+ /**
3136
+ * Pure function - doesn't mutate either parameter!
3137
+ * Merges two objects together deeply, overwriting the properties in first with the properties in second
3138
+ * @param first The first object
3139
+ * @param second The second object
3140
+ * @returns a new object
3141
+ */
3142
+ function deepMerge$1(first = {}, second = {}) {
3143
+ // get the unique set of keys across both objects
3144
+ const keys = new Set([...Object.keys(first), ...Object.keys(second)]);
3145
+ return Object.fromEntries([...keys].map(key => {
3146
+ const firstHasKey = key in first;
3147
+ const secondHasKey = key in second;
3148
+ const firstValue = first[key];
3149
+ const secondValue = second[key];
3150
+ let value;
3151
+ if (firstHasKey && secondHasKey) {
3152
+ if (isObjectNotArray(firstValue) && isObjectNotArray(secondValue)) {
3153
+ // object type
3154
+ value = deepMerge$1(firstValue, secondValue);
3155
+ }
3156
+ else {
3157
+ // value type
3158
+ value = secondValue;
3159
+ }
3160
+ }
3161
+ else if (firstHasKey) {
3162
+ value = firstValue;
3163
+ }
3164
+ else {
3165
+ value = secondValue;
3166
+ }
3167
+ return [key, value];
3168
+ }));
3169
+ }
3170
+ return deepMerge;
3171
+ }
3172
+
3173
+ var hasRequiredApplyDefault;
3174
+
3175
+ function requireApplyDefault () {
3176
+ if (hasRequiredApplyDefault) return applyDefault;
3177
+ hasRequiredApplyDefault = 1;
3178
+ Object.defineProperty(applyDefault, "__esModule", { value: true });
3179
+ applyDefault.applyDefault = applyDefault$1;
3180
+ const deepMerge_1 = requireDeepMerge();
3181
+ /**
3182
+ * Pure function - doesn't mutate either parameter!
3183
+ * Uses the default options and overrides with the options provided by the user
3184
+ * @param defaultOptions the defaults
3185
+ * @param userOptions the user opts
3186
+ * @returns the options with defaults
3187
+ */
3188
+ function applyDefault$1(defaultOptions, userOptions) {
3189
+ // clone defaults
3190
+ const options = structuredClone(defaultOptions);
3191
+ if (userOptions == null) {
3192
+ return options;
3193
+ }
3194
+ // For avoiding the type error
3195
+ // `This expression is not callable. Type 'unknown' has no call signatures.ts(2349)`
3196
+ options.forEach((opt, i) => {
3197
+ // eslint-disable-next-line @typescript-eslint/internal/eqeq-nullish
3198
+ if (userOptions[i] !== undefined) {
3199
+ const userOpt = userOptions[i];
3200
+ if ((0, deepMerge_1.isObjectNotArray)(userOpt) && (0, deepMerge_1.isObjectNotArray)(opt)) {
3201
+ options[i] = (0, deepMerge_1.deepMerge)(opt, userOpt);
3202
+ }
3203
+ else {
3204
+ options[i] = userOpt;
3205
+ }
3206
+ }
3207
+ });
3208
+ return options;
3209
+ }
3210
+ return applyDefault;
3211
+ }
3212
+
3213
+ var getParserServices = {};
3214
+
3215
+ var parserSeemsToBeTSESLint = {};
3216
+
3217
+ var hasRequiredParserSeemsToBeTSESLint;
3218
+
3219
+ function requireParserSeemsToBeTSESLint () {
3220
+ if (hasRequiredParserSeemsToBeTSESLint) return parserSeemsToBeTSESLint;
3221
+ hasRequiredParserSeemsToBeTSESLint = 1;
3222
+ Object.defineProperty(parserSeemsToBeTSESLint, "__esModule", { value: true });
3223
+ parserSeemsToBeTSESLint.parserSeemsToBeTSESLint = parserSeemsToBeTSESLint$1;
3224
+ function parserSeemsToBeTSESLint$1(parser) {
3225
+ return !!parser && /(?:typescript-eslint|\.\.)[\w/\\]*parser/.test(parser);
3226
+ }
3227
+ return parserSeemsToBeTSESLint;
3228
+ }
3229
+
3230
+ var hasRequiredGetParserServices;
3231
+
3232
+ function requireGetParserServices () {
3233
+ if (hasRequiredGetParserServices) return getParserServices;
3234
+ hasRequiredGetParserServices = 1;
3235
+ Object.defineProperty(getParserServices, "__esModule", { value: true });
3236
+ getParserServices.getParserServices = getParserServices$1;
3237
+ const parserSeemsToBeTSESLint_1 = requireParserSeemsToBeTSESLint();
3238
+ const ERROR_MESSAGE_REQUIRES_PARSER_SERVICES = "You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file. See https://typescript-eslint.io/getting-started/typed-linting for enabling linting with type information.";
3239
+ const ERROR_MESSAGE_UNKNOWN_PARSER = 'Note: detected a parser other than @typescript-eslint/parser. Make sure the parser is configured to forward "parserOptions.project" to @typescript-eslint/parser.';
3240
+ function getParserServices$1(context, allowWithoutFullTypeInformation = false) {
3241
+ const parser = context.parserPath || context.languageOptions.parser?.meta?.name;
3242
+ // This check is unnecessary if the user is using the latest version of our parser.
3243
+ //
3244
+ // However the world isn't perfect:
3245
+ // - Users often use old parser versions.
3246
+ // Old versions of the parser would not return any parserServices unless parserOptions.project was set.
3247
+ // - Users sometimes use parsers that aren't @typescript-eslint/parser
3248
+ // Other parsers won't return the parser services we expect (if they return any at all).
3249
+ //
3250
+ // This check allows us to handle bad user setups whilst providing a nice user-facing
3251
+ // error message explaining the problem.
3252
+ if (context.sourceCode.parserServices?.esTreeNodeToTSNodeMap == null ||
3253
+ context.sourceCode.parserServices.tsNodeToESTreeNodeMap == null) {
3254
+ throwError(parser);
3255
+ }
3256
+ // if a rule requires full type information, then hard fail if it doesn't exist
3257
+ // this forces the user to supply parserOptions.project
3258
+ if (context.sourceCode.parserServices.program == null &&
3259
+ !allowWithoutFullTypeInformation) {
3260
+ throwError(parser);
3261
+ }
3262
+ return context.sourceCode.parserServices;
3263
+ }
3264
+ /* eslint-enable @typescript-eslint/unified-signatures */
3265
+ function throwError(parser) {
3266
+ const messages = [
3267
+ ERROR_MESSAGE_REQUIRES_PARSER_SERVICES,
3268
+ `Parser: ${parser || '(unknown)'}`,
3269
+ !(0, parserSeemsToBeTSESLint_1.parserSeemsToBeTSESLint)(parser) && ERROR_MESSAGE_UNKNOWN_PARSER,
3270
+ ].filter(Boolean);
3271
+ throw new Error(messages.join('\n'));
3272
+ }
3273
+ return getParserServices;
3274
+ }
3275
+
3276
+ var InferTypesFromRule = {};
3277
+
3278
+ var hasRequiredInferTypesFromRule;
3279
+
3280
+ function requireInferTypesFromRule () {
3281
+ if (hasRequiredInferTypesFromRule) return InferTypesFromRule;
3282
+ hasRequiredInferTypesFromRule = 1;
3283
+ Object.defineProperty(InferTypesFromRule, "__esModule", { value: true });
3284
+ return InferTypesFromRule;
3285
+ }
3286
+
3287
+ var nullThrows = {};
3288
+
3289
+ var hasRequiredNullThrows;
3290
+
3291
+ function requireNullThrows () {
3292
+ if (hasRequiredNullThrows) return nullThrows;
3293
+ hasRequiredNullThrows = 1;
3294
+ Object.defineProperty(nullThrows, "__esModule", { value: true });
3295
+ nullThrows.NullThrowsReasons = void 0;
3296
+ nullThrows.nullThrows = nullThrows$1;
3297
+ /**
3298
+ * A set of common reasons for calling nullThrows
3299
+ */
3300
+ nullThrows.NullThrowsReasons = {
3301
+ MissingParent: 'Expected node to have a parent.',
3302
+ MissingToken: (token, thing) => `Expected to find a ${token} for the ${thing}.`,
3303
+ };
3304
+ /**
3305
+ * Assert that a value must not be null or undefined.
3306
+ * This is a nice explicit alternative to the non-null assertion operator.
3307
+ */
3308
+ function nullThrows$1(value, message) {
3309
+ if (value == null) {
3310
+ throw new Error(`Non-null Assertion Failed: ${message}`);
3311
+ }
3312
+ return value;
3313
+ }
3314
+ return nullThrows;
3315
+ }
3316
+
3317
+ var RuleCreator = {};
3318
+
3319
+ var hasRequiredRuleCreator;
3320
+
3321
+ function requireRuleCreator () {
3322
+ if (hasRequiredRuleCreator) return RuleCreator;
3323
+ hasRequiredRuleCreator = 1;
3324
+ Object.defineProperty(RuleCreator, "__esModule", { value: true });
3325
+ RuleCreator.RuleCreator = RuleCreator$1;
3326
+ const applyDefault_1 = requireApplyDefault();
3327
+ /**
3328
+ * Creates reusable function to create rules with default options and docs URLs.
3329
+ *
3330
+ * @param urlCreator Creates a documentation URL for a given rule name.
3331
+ * @returns Function to create a rule with the docs URL format.
3332
+ */
3333
+ function RuleCreator$1(urlCreator) {
3334
+ // This function will get much easier to call when this is merged https://github.com/Microsoft/TypeScript/pull/26349
3335
+ // TODO - when the above PR lands; add type checking for the context.report `data` property
3336
+ return function createNamedRule({ meta, name, ...rule }) {
3337
+ return createRule({
3338
+ meta: {
3339
+ ...meta,
3340
+ docs: {
3341
+ ...meta.docs,
3342
+ url: urlCreator(name),
3343
+ },
3344
+ },
3345
+ ...rule,
3346
+ });
3347
+ };
3348
+ }
3349
+ function createRule({ create, defaultOptions, meta, }) {
3350
+ return {
3351
+ create(context) {
3352
+ const optionsWithDefault = (0, applyDefault_1.applyDefault)(defaultOptions, context.options);
3353
+ return create(context, optionsWithDefault);
3354
+ },
3355
+ defaultOptions,
3356
+ meta,
3357
+ };
3358
+ }
3359
+ /**
3360
+ * Creates a well-typed TSESLint custom ESLint rule without a docs URL.
3361
+ *
3362
+ * @returns Well-typed TSESLint custom ESLint rule.
3363
+ * @remarks It is generally better to provide a docs URL function to RuleCreator.
3364
+ */
3365
+ RuleCreator$1.withoutDocs = function withoutDocs(args) {
3366
+ return createRule(args);
3367
+ };
3368
+ return RuleCreator;
3369
+ }
3370
+
3371
+ var hasRequiredEslintUtils;
3372
+
3373
+ function requireEslintUtils () {
3374
+ if (hasRequiredEslintUtils) return eslintUtils;
3375
+ hasRequiredEslintUtils = 1;
3376
+ (function (exports) {
3377
+ var __createBinding = (eslintUtils && eslintUtils.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3378
+ if (k2 === undefined) k2 = k;
3379
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3380
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3381
+ desc = { enumerable: true, get: function() { return m[k]; } };
3382
+ }
3383
+ Object.defineProperty(o, k2, desc);
3384
+ }) : (function(o, m, k, k2) {
3385
+ if (k2 === undefined) k2 = k;
3386
+ o[k2] = m[k];
3387
+ }));
3388
+ var __exportStar = (eslintUtils && eslintUtils.__exportStar) || function(m, exports) {
3389
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3390
+ };
3391
+ Object.defineProperty(exports, "__esModule", { value: true });
3392
+ __exportStar(requireApplyDefault(), exports);
3393
+ __exportStar(requireDeepMerge(), exports);
3394
+ __exportStar(requireGetParserServices(), exports);
3395
+ __exportStar(requireInferTypesFromRule(), exports);
3396
+ __exportStar(requireNullThrows(), exports);
3397
+ __exportStar(requireRuleCreator(), exports);
3398
+ } (eslintUtils));
3399
+ return eslintUtils;
3400
+ }
3401
+
3402
+ var jsonSchema = {};
3403
+
3404
+ var hasRequiredJsonSchema;
3405
+
3406
+ function requireJsonSchema () {
3407
+ if (hasRequiredJsonSchema) return jsonSchema;
3408
+ hasRequiredJsonSchema = 1;
3409
+ /**
3410
+ * This is a fork of https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13f63c2eb8d7479caf01ab8d72f9e3683368a8f5/types/json-schema/index.d.ts
3411
+ * We intentionally fork this because:
3412
+ * - ESLint ***ONLY*** supports JSONSchema v4
3413
+ * - We want to provide stricter types
3414
+ */
3415
+ Object.defineProperty(jsonSchema, "__esModule", { value: true });
3416
+ return jsonSchema;
3417
+ }
3418
+
3419
+ var tsEslint = {};
3420
+
3421
+ var AST = {};
3422
+
3423
+ var hasRequiredAST;
3424
+
3425
+ function requireAST () {
3426
+ if (hasRequiredAST) return AST;
3427
+ hasRequiredAST = 1;
3428
+ /* eslint-disable @typescript-eslint/no-namespace, no-restricted-syntax */
3429
+ Object.defineProperty(AST, "__esModule", { value: true });
3430
+ return AST;
3431
+ }
3432
+
3433
+ var Config = {};
3434
+
3435
+ var hasRequiredConfig;
3436
+
3437
+ function requireConfig () {
3438
+ if (hasRequiredConfig) return Config;
3439
+ hasRequiredConfig = 1;
3440
+ /* eslint-disable @typescript-eslint/consistent-indexed-object-style, @typescript-eslint/no-namespace */
3441
+ Object.defineProperty(Config, "__esModule", { value: true });
3442
+ return Config;
3443
+ }
3444
+
3445
+ var ESLint = {};
3446
+
3447
+ var FlatESLint = {};
3448
+
3449
+ var hasRequiredFlatESLint;
3450
+
3451
+ function requireFlatESLint () {
3452
+ if (hasRequiredFlatESLint) return FlatESLint;
3453
+ hasRequiredFlatESLint = 1;
3454
+ Object.defineProperty(FlatESLint, "__esModule", { value: true });
3455
+ FlatESLint.FlatESLint = void 0;
3456
+ /* eslint-disable @typescript-eslint/no-namespace */
3457
+ const use_at_your_own_risk_1 = requireUnsupportedApi();
3458
+ /**
3459
+ * The ESLint class is the primary class to use in Node.js applications.
3460
+ * This class depends on the Node.js fs module and the file system, so you cannot use it in browsers.
3461
+ *
3462
+ * If you want to lint code on browsers, use the Linter class instead.
3463
+ */
3464
+ let FlatESLint$1 = class FlatESLint extends use_at_your_own_risk_1.FlatESLint {
3465
+ };
3466
+ FlatESLint.FlatESLint = FlatESLint$1;
3467
+ return FlatESLint;
3468
+ }
3469
+
3470
+ var LegacyESLint = {};
3471
+
3472
+ var hasRequiredLegacyESLint;
3473
+
3474
+ function requireLegacyESLint () {
3475
+ if (hasRequiredLegacyESLint) return LegacyESLint;
3476
+ hasRequiredLegacyESLint = 1;
3477
+ /* eslint-disable @typescript-eslint/no-namespace */
3478
+ Object.defineProperty(LegacyESLint, "__esModule", { value: true });
3479
+ LegacyESLint.LegacyESLint = void 0;
3480
+ const use_at_your_own_risk_1 = requireUnsupportedApi();
3481
+ /**
3482
+ * The ESLint class is the primary class to use in Node.js applications.
3483
+ * This class depends on the Node.js fs module and the file system, so you cannot use it in browsers.
3484
+ *
3485
+ * If you want to lint code on browsers, use the Linter class instead.
3486
+ */
3487
+ let LegacyESLint$1 = class LegacyESLint extends use_at_your_own_risk_1.LegacyESLint {
3488
+ };
3489
+ LegacyESLint.LegacyESLint = LegacyESLint$1;
3490
+ return LegacyESLint;
3491
+ }
3492
+
3493
+ var hasRequiredESLint;
3494
+
3495
+ function requireESLint () {
3496
+ if (hasRequiredESLint) return ESLint;
3497
+ hasRequiredESLint = 1;
3498
+ (function (exports) {
3499
+ Object.defineProperty(exports, "__esModule", { value: true });
3500
+ exports.LegacyESLint = exports.ESLint = exports.FlatESLint = void 0;
3501
+ var FlatESLint_1 = requireFlatESLint();
3502
+ Object.defineProperty(exports, "FlatESLint", { enumerable: true, get: function () { return FlatESLint_1.FlatESLint; } });
3503
+ var FlatESLint_2 = requireFlatESLint();
3504
+ Object.defineProperty(exports, "ESLint", { enumerable: true, get: function () { return FlatESLint_2.FlatESLint; } });
3505
+ var LegacyESLint_1 = requireLegacyESLint();
3506
+ // TODO(eslint@v10) - remove this in the next major
3507
+ /**
3508
+ * @deprecated - use ESLint instead
3509
+ */
3510
+ Object.defineProperty(exports, "LegacyESLint", { enumerable: true, get: function () { return LegacyESLint_1.LegacyESLint; } });
3511
+ } (ESLint));
3512
+ return ESLint;
3513
+ }
3514
+
3515
+ var Linter = {};
3516
+
3517
+ var hasRequiredLinter;
3518
+
3519
+ function requireLinter () {
3520
+ if (hasRequiredLinter) return Linter;
3521
+ hasRequiredLinter = 1;
3522
+ /* eslint-disable @typescript-eslint/no-namespace, no-restricted-syntax */
3523
+ Object.defineProperty(Linter, "__esModule", { value: true });
3524
+ Linter.Linter = void 0;
3525
+ const eslint_1 = requireApi();
3526
+ /**
3527
+ * The Linter object does the actual evaluation of the JavaScript code. It doesn't do any filesystem operations, it
3528
+ * simply parses and reports on the code. In particular, the Linter object does not process configuration objects
3529
+ * or files.
3530
+ */
3531
+ let Linter$1 = class Linter extends eslint_1.Linter {
3532
+ };
3533
+ Linter.Linter = Linter$1;
3534
+ return Linter;
3535
+ }
3536
+
3537
+ var Parser = {};
3538
+
3539
+ var hasRequiredParser;
3540
+
3541
+ function requireParser () {
3542
+ if (hasRequiredParser) return Parser;
3543
+ hasRequiredParser = 1;
3544
+ /* eslint-disable @typescript-eslint/no-namespace */
3545
+ Object.defineProperty(Parser, "__esModule", { value: true });
3546
+ return Parser;
3547
+ }
3548
+
3549
+ var ParserOptions = {};
3550
+
3551
+ var hasRequiredParserOptions;
3552
+
3553
+ function requireParserOptions () {
3554
+ if (hasRequiredParserOptions) return ParserOptions;
3555
+ hasRequiredParserOptions = 1;
3556
+ Object.defineProperty(ParserOptions, "__esModule", { value: true });
3557
+ return ParserOptions;
3558
+ }
3559
+
3560
+ var Processor = {};
3561
+
3562
+ var hasRequiredProcessor;
3563
+
3564
+ function requireProcessor () {
3565
+ if (hasRequiredProcessor) return Processor;
3566
+ hasRequiredProcessor = 1;
3567
+ /* eslint-disable @typescript-eslint/no-namespace */
3568
+ Object.defineProperty(Processor, "__esModule", { value: true });
3569
+ return Processor;
3570
+ }
3571
+
3572
+ var Rule = {};
3573
+
3574
+ var hasRequiredRule;
3575
+
3576
+ function requireRule () {
3577
+ if (hasRequiredRule) return Rule;
3578
+ hasRequiredRule = 1;
3579
+ Object.defineProperty(Rule, "__esModule", { value: true });
3580
+ return Rule;
3581
+ }
3582
+
3583
+ var RuleTester = {};
3584
+
3585
+ var hasRequiredRuleTester;
3586
+
3587
+ function requireRuleTester () {
3588
+ if (hasRequiredRuleTester) return RuleTester;
3589
+ hasRequiredRuleTester = 1;
3590
+ Object.defineProperty(RuleTester, "__esModule", { value: true });
3591
+ RuleTester.RuleTester = void 0;
3592
+ /* eslint-disable @typescript-eslint/no-deprecated */
3593
+ const eslint_1 = requireApi();
3594
+ /**
3595
+ * @deprecated Use `@typescript-eslint/rule-tester` instead.
3596
+ */
3597
+ let RuleTester$1 = class RuleTester extends eslint_1.RuleTester {
3598
+ };
3599
+ RuleTester.RuleTester = RuleTester$1;
3600
+ return RuleTester;
3601
+ }
3602
+
3603
+ var Scope = {};
3604
+
3605
+ var hasRequiredScope;
3606
+
3607
+ function requireScope () {
3608
+ if (hasRequiredScope) return Scope;
3609
+ hasRequiredScope = 1;
3610
+ /* eslint-disable @typescript-eslint/no-namespace */
3611
+ var __createBinding = (Scope && Scope.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3612
+ if (k2 === undefined) k2 = k;
3613
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3614
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3615
+ desc = { enumerable: true, get: function() { return m[k]; } };
3616
+ }
3617
+ Object.defineProperty(o, k2, desc);
3618
+ }) : (function(o, m, k, k2) {
3619
+ if (k2 === undefined) k2 = k;
3620
+ o[k2] = m[k];
3621
+ }));
3622
+ var __setModuleDefault = (Scope && Scope.__setModuleDefault) || (Object.create ? (function(o, v) {
3623
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
3624
+ }) : function(o, v) {
3625
+ o["default"] = v;
3626
+ });
3627
+ var __importStar = (Scope && Scope.__importStar) || (function () {
3628
+ var ownKeys = function(o) {
3629
+ ownKeys = Object.getOwnPropertyNames || function (o) {
3630
+ var ar = [];
3631
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
3632
+ return ar;
3633
+ };
3634
+ return ownKeys(o);
3635
+ };
3636
+ return function (mod) {
3637
+ if (mod && mod.__esModule) return mod;
3638
+ var result = {};
3639
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
3640
+ __setModuleDefault(result, mod);
3641
+ return result;
3642
+ };
3643
+ })();
3644
+ Object.defineProperty(Scope, "__esModule", { value: true });
3645
+ Scope.Scope = void 0;
3646
+ const scopeManager = __importStar(requireDist$2());
3647
+ var Scope$1;
3648
+ (function (Scope) {
3649
+ Scope.ScopeType = scopeManager.ScopeType;
3650
+ Scope.DefinitionType = scopeManager.DefinitionType;
3651
+ })(Scope$1 || (Scope.Scope = Scope$1 = {}));
3652
+ return Scope;
3653
+ }
3654
+
3655
+ var SourceCode = {};
3656
+
3657
+ var hasRequiredSourceCode;
3658
+
3659
+ function requireSourceCode () {
3660
+ if (hasRequiredSourceCode) return SourceCode;
3661
+ hasRequiredSourceCode = 1;
3662
+ /* eslint-disable @typescript-eslint/no-namespace, no-restricted-syntax */
3663
+ Object.defineProperty(SourceCode, "__esModule", { value: true });
3664
+ SourceCode.SourceCode = void 0;
3665
+ const eslint_1 = requireApi();
3666
+ let SourceCode$1 = class SourceCode extends eslint_1.SourceCode {
3667
+ };
3668
+ SourceCode.SourceCode = SourceCode$1;
3669
+ return SourceCode;
3670
+ }
3671
+
3672
+ var hasRequiredTsEslint;
3673
+
3674
+ function requireTsEslint () {
3675
+ if (hasRequiredTsEslint) return tsEslint;
3676
+ hasRequiredTsEslint = 1;
3677
+ (function (exports) {
3678
+ var __createBinding = (tsEslint && tsEslint.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3679
+ if (k2 === undefined) k2 = k;
3680
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3681
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3682
+ desc = { enumerable: true, get: function() { return m[k]; } };
3683
+ }
3684
+ Object.defineProperty(o, k2, desc);
3685
+ }) : (function(o, m, k, k2) {
3686
+ if (k2 === undefined) k2 = k;
3687
+ o[k2] = m[k];
3688
+ }));
3689
+ var __exportStar = (tsEslint && tsEslint.__exportStar) || function(m, exports) {
3690
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3691
+ };
3692
+ Object.defineProperty(exports, "__esModule", { value: true });
3693
+ __exportStar(requireAST(), exports);
3694
+ __exportStar(requireConfig(), exports);
3695
+ __exportStar(requireESLint(), exports);
3696
+ __exportStar(requireLinter(), exports);
3697
+ __exportStar(requireParser(), exports);
3698
+ __exportStar(requireParserOptions(), exports);
3699
+ __exportStar(requireProcessor(), exports);
3700
+ __exportStar(requireRule(), exports);
3701
+ __exportStar(requireRuleTester(), exports);
3702
+ __exportStar(requireScope(), exports);
3703
+ __exportStar(requireSourceCode(), exports);
3704
+ } (tsEslint));
3705
+ return tsEslint;
3706
+ }
3707
+
3708
+ var tsUtils = {};
3709
+
3710
+ var isArray = {};
3711
+
3712
+ var hasRequiredIsArray;
3713
+
3714
+ function requireIsArray () {
3715
+ if (hasRequiredIsArray) return isArray;
3716
+ hasRequiredIsArray = 1;
3717
+ Object.defineProperty(isArray, "__esModule", { value: true });
3718
+ isArray.isArray = isArray$1;
3719
+ // https://github.com/microsoft/TypeScript/issues/17002
3720
+ function isArray$1(arg) {
3721
+ return Array.isArray(arg);
3722
+ }
3723
+ return isArray;
3724
+ }
3725
+
3726
+ var NoInfer = {};
3727
+
3728
+ var hasRequiredNoInfer;
3729
+
3730
+ function requireNoInfer () {
3731
+ if (hasRequiredNoInfer) return NoInfer;
3732
+ hasRequiredNoInfer = 1;
3733
+ Object.defineProperty(NoInfer, "__esModule", { value: true });
3734
+ return NoInfer;
3735
+ }
3736
+
3737
+ var hasRequiredTsUtils;
3738
+
3739
+ function requireTsUtils () {
3740
+ if (hasRequiredTsUtils) return tsUtils;
3741
+ hasRequiredTsUtils = 1;
3742
+ (function (exports) {
3743
+ var __createBinding = (tsUtils && tsUtils.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3744
+ if (k2 === undefined) k2 = k;
3745
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3746
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3747
+ desc = { enumerable: true, get: function() { return m[k]; } };
3748
+ }
3749
+ Object.defineProperty(o, k2, desc);
3750
+ }) : (function(o, m, k, k2) {
3751
+ if (k2 === undefined) k2 = k;
3752
+ o[k2] = m[k];
3753
+ }));
3754
+ var __exportStar = (tsUtils && tsUtils.__exportStar) || function(m, exports) {
3755
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3756
+ };
3757
+ Object.defineProperty(exports, "__esModule", { value: true });
3758
+ __exportStar(requireIsArray(), exports);
3759
+ __exportStar(requireNoInfer(), exports);
3760
+ } (tsUtils));
3761
+ return tsUtils;
3762
+ }
3763
+
3764
+ var hasRequiredDist;
3765
+
3766
+ function requireDist () {
3767
+ if (hasRequiredDist) return dist;
3768
+ hasRequiredDist = 1;
3769
+ (function (exports) {
3770
+ var __createBinding = (dist && dist.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3771
+ if (k2 === undefined) k2 = k;
3772
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3773
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3774
+ desc = { enumerable: true, get: function() { return m[k]; } };
3775
+ }
3776
+ Object.defineProperty(o, k2, desc);
3777
+ }) : (function(o, m, k, k2) {
3778
+ if (k2 === undefined) k2 = k;
3779
+ o[k2] = m[k];
3780
+ }));
3781
+ var __setModuleDefault = (dist && dist.__setModuleDefault) || (Object.create ? (function(o, v) {
3782
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
3783
+ }) : function(o, v) {
3784
+ o["default"] = v;
3785
+ });
3786
+ var __importStar = (dist && dist.__importStar) || (function () {
3787
+ var ownKeys = function(o) {
3788
+ ownKeys = Object.getOwnPropertyNames || function (o) {
3789
+ var ar = [];
3790
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
3791
+ return ar;
3792
+ };
3793
+ return ownKeys(o);
3794
+ };
3795
+ return function (mod) {
3796
+ if (mod && mod.__esModule) return mod;
3797
+ var result = {};
3798
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
3799
+ __setModuleDefault(result, mod);
3800
+ return result;
3801
+ };
3802
+ })();
3803
+ var __exportStar = (dist && dist.__exportStar) || function(m, exports) {
3804
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
3805
+ };
3806
+ Object.defineProperty(exports, "__esModule", { value: true });
3807
+ exports.TSUtils = exports.TSESLint = exports.JSONSchema = exports.ESLintUtils = exports.ASTUtils = void 0;
3808
+ exports.ASTUtils = __importStar(requireAstUtils());
3809
+ exports.ESLintUtils = __importStar(requireEslintUtils());
3810
+ exports.JSONSchema = __importStar(requireJsonSchema());
3811
+ exports.TSESLint = __importStar(requireTsEslint());
3812
+ __exportStar(requireTsEstree(), exports);
3813
+ exports.TSUtils = __importStar(requireTsUtils());
3814
+ } (dist));
3815
+ return dist;
3816
+ }
3817
+
3818
+ export { requireAstUtils as a, requireEslintUtils as b, requireDist as r };