@whoj/eslint-config 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1520 +0,0 @@
1
- import {
2
- require_eslint_visitor_keys
3
- } from "./chunk-IDB36RF3.js";
4
- import {
5
- __commonJS,
6
- init_esm_shims
7
- } from "./chunk-MKNYKNDN.js";
8
-
9
- // node_modules/.pnpm/@eslint-community+eslint-utils@4.4.1_eslint@9.19.0_jiti@2.4.2_/node_modules/@eslint-community/eslint-utils/index.js
10
- var require_eslint_utils = __commonJS({
11
- "node_modules/.pnpm/@eslint-community+eslint-utils@4.4.1_eslint@9.19.0_jiti@2.4.2_/node_modules/@eslint-community/eslint-utils/index.js"(exports) {
12
- "use strict";
13
- init_esm_shims();
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- var eslintVisitorKeys = require_eslint_visitor_keys();
16
- function getInnermostScope(initialScope, node) {
17
- const location = node.range[0];
18
- let scope = initialScope;
19
- let found = false;
20
- do {
21
- found = false;
22
- for (const childScope of scope.childScopes) {
23
- const range = childScope.block.range;
24
- if (range[0] <= location && location < range[1]) {
25
- scope = childScope;
26
- found = true;
27
- break;
28
- }
29
- }
30
- } while (found);
31
- return scope;
32
- }
33
- function findVariable(initialScope, nameOrNode) {
34
- let name = "";
35
- let scope = initialScope;
36
- if (typeof nameOrNode === "string") {
37
- name = nameOrNode;
38
- } else {
39
- name = nameOrNode.name;
40
- scope = getInnermostScope(scope, nameOrNode);
41
- }
42
- while (scope != null) {
43
- const variable = scope.set.get(name);
44
- if (variable != null) {
45
- return variable;
46
- }
47
- scope = scope.upper;
48
- }
49
- return null;
50
- }
51
- function negate(f) {
52
- return (token) => !f(token);
53
- }
54
- function isPunctuatorTokenWithValue(token, value) {
55
- return token.type === "Punctuator" && token.value === value;
56
- }
57
- function isArrowToken(token) {
58
- return isPunctuatorTokenWithValue(token, "=>");
59
- }
60
- function isCommaToken(token) {
61
- return isPunctuatorTokenWithValue(token, ",");
62
- }
63
- function isSemicolonToken(token) {
64
- return isPunctuatorTokenWithValue(token, ";");
65
- }
66
- function isColonToken(token) {
67
- return isPunctuatorTokenWithValue(token, ":");
68
- }
69
- function isOpeningParenToken(token) {
70
- return isPunctuatorTokenWithValue(token, "(");
71
- }
72
- function isClosingParenToken(token) {
73
- return isPunctuatorTokenWithValue(token, ")");
74
- }
75
- function isOpeningBracketToken(token) {
76
- return isPunctuatorTokenWithValue(token, "[");
77
- }
78
- function isClosingBracketToken(token) {
79
- return isPunctuatorTokenWithValue(token, "]");
80
- }
81
- function isOpeningBraceToken(token) {
82
- return isPunctuatorTokenWithValue(token, "{");
83
- }
84
- function isClosingBraceToken(token) {
85
- return isPunctuatorTokenWithValue(token, "}");
86
- }
87
- function isCommentToken(token) {
88
- return ["Block", "Line", "Shebang"].includes(token.type);
89
- }
90
- var isNotArrowToken = negate(isArrowToken);
91
- var isNotCommaToken = negate(isCommaToken);
92
- var isNotSemicolonToken = negate(isSemicolonToken);
93
- var isNotColonToken = negate(isColonToken);
94
- var isNotOpeningParenToken = negate(isOpeningParenToken);
95
- var isNotClosingParenToken = negate(isClosingParenToken);
96
- var isNotOpeningBracketToken = negate(isOpeningBracketToken);
97
- var isNotClosingBracketToken = negate(isClosingBracketToken);
98
- var isNotOpeningBraceToken = negate(isOpeningBraceToken);
99
- var isNotClosingBraceToken = negate(isClosingBraceToken);
100
- var isNotCommentToken = negate(isCommentToken);
101
- function getOpeningParenOfParams(node, sourceCode) {
102
- return node.id ? sourceCode.getTokenAfter(node.id, isOpeningParenToken) : sourceCode.getFirstToken(node, isOpeningParenToken);
103
- }
104
- function getFunctionHeadLocation(node, sourceCode) {
105
- const parent = node.parent;
106
- let start = null;
107
- let end = null;
108
- if (node.type === "ArrowFunctionExpression") {
109
- const arrowToken = sourceCode.getTokenBefore(node.body, isArrowToken);
110
- start = arrowToken.loc.start;
111
- end = arrowToken.loc.end;
112
- } else if (parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") {
113
- start = parent.loc.start;
114
- end = getOpeningParenOfParams(node, sourceCode).loc.start;
115
- } else {
116
- start = node.loc.start;
117
- end = getOpeningParenOfParams(node, sourceCode).loc.start;
118
- }
119
- return {
120
- start: { ...start },
121
- end: { ...end }
122
- };
123
- }
124
- var globalObject = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
125
- var builtinNames = Object.freeze(
126
- /* @__PURE__ */ new Set([
127
- "Array",
128
- "ArrayBuffer",
129
- "BigInt",
130
- "BigInt64Array",
131
- "BigUint64Array",
132
- "Boolean",
133
- "DataView",
134
- "Date",
135
- "decodeURI",
136
- "decodeURIComponent",
137
- "encodeURI",
138
- "encodeURIComponent",
139
- "escape",
140
- "Float32Array",
141
- "Float64Array",
142
- "Function",
143
- "Infinity",
144
- "Int16Array",
145
- "Int32Array",
146
- "Int8Array",
147
- "isFinite",
148
- "isNaN",
149
- "isPrototypeOf",
150
- "JSON",
151
- "Map",
152
- "Math",
153
- "NaN",
154
- "Number",
155
- "Object",
156
- "parseFloat",
157
- "parseInt",
158
- "Promise",
159
- "Proxy",
160
- "Reflect",
161
- "RegExp",
162
- "Set",
163
- "String",
164
- "Symbol",
165
- "Uint16Array",
166
- "Uint32Array",
167
- "Uint8Array",
168
- "Uint8ClampedArray",
169
- "undefined",
170
- "unescape",
171
- "WeakMap",
172
- "WeakSet"
173
- ])
174
- );
175
- var callAllowed = new Set(
176
- [
177
- Array.isArray,
178
- Array.of,
179
- Array.prototype.at,
180
- Array.prototype.concat,
181
- Array.prototype.entries,
182
- Array.prototype.every,
183
- Array.prototype.filter,
184
- Array.prototype.find,
185
- Array.prototype.findIndex,
186
- Array.prototype.flat,
187
- Array.prototype.includes,
188
- Array.prototype.indexOf,
189
- Array.prototype.join,
190
- Array.prototype.keys,
191
- Array.prototype.lastIndexOf,
192
- Array.prototype.slice,
193
- Array.prototype.some,
194
- Array.prototype.toString,
195
- Array.prototype.values,
196
- typeof BigInt === "function" ? BigInt : void 0,
197
- Boolean,
198
- Date,
199
- Date.parse,
200
- decodeURI,
201
- decodeURIComponent,
202
- encodeURI,
203
- encodeURIComponent,
204
- escape,
205
- isFinite,
206
- isNaN,
207
- isPrototypeOf,
208
- Map,
209
- Map.prototype.entries,
210
- Map.prototype.get,
211
- Map.prototype.has,
212
- Map.prototype.keys,
213
- Map.prototype.values,
214
- ...Object.getOwnPropertyNames(Math).filter((k) => k !== "random").map((k) => Math[k]).filter((f) => typeof f === "function"),
215
- Number,
216
- Number.isFinite,
217
- Number.isNaN,
218
- Number.parseFloat,
219
- Number.parseInt,
220
- Number.prototype.toExponential,
221
- Number.prototype.toFixed,
222
- Number.prototype.toPrecision,
223
- Number.prototype.toString,
224
- Object,
225
- Object.entries,
226
- Object.is,
227
- Object.isExtensible,
228
- Object.isFrozen,
229
- Object.isSealed,
230
- Object.keys,
231
- Object.values,
232
- parseFloat,
233
- parseInt,
234
- RegExp,
235
- Set,
236
- Set.prototype.entries,
237
- Set.prototype.has,
238
- Set.prototype.keys,
239
- Set.prototype.values,
240
- String,
241
- String.fromCharCode,
242
- String.fromCodePoint,
243
- String.raw,
244
- String.prototype.at,
245
- String.prototype.charAt,
246
- String.prototype.charCodeAt,
247
- String.prototype.codePointAt,
248
- String.prototype.concat,
249
- String.prototype.endsWith,
250
- String.prototype.includes,
251
- String.prototype.indexOf,
252
- String.prototype.lastIndexOf,
253
- String.prototype.normalize,
254
- String.prototype.padEnd,
255
- String.prototype.padStart,
256
- String.prototype.slice,
257
- String.prototype.startsWith,
258
- String.prototype.substr,
259
- String.prototype.substring,
260
- String.prototype.toLowerCase,
261
- String.prototype.toString,
262
- String.prototype.toUpperCase,
263
- String.prototype.trim,
264
- String.prototype.trimEnd,
265
- String.prototype.trimLeft,
266
- String.prototype.trimRight,
267
- String.prototype.trimStart,
268
- Symbol.for,
269
- Symbol.keyFor,
270
- unescape
271
- ].filter((f) => typeof f === "function")
272
- );
273
- var callPassThrough = /* @__PURE__ */ new Set([
274
- Object.freeze,
275
- Object.preventExtensions,
276
- Object.seal
277
- ]);
278
- var getterAllowed = [
279
- [Map, /* @__PURE__ */ new Set(["size"])],
280
- [
281
- RegExp,
282
- /* @__PURE__ */ new Set([
283
- "dotAll",
284
- "flags",
285
- "global",
286
- "hasIndices",
287
- "ignoreCase",
288
- "multiline",
289
- "source",
290
- "sticky",
291
- "unicode"
292
- ])
293
- ],
294
- [Set, /* @__PURE__ */ new Set(["size"])]
295
- ];
296
- function getPropertyDescriptor(object, name) {
297
- let x = object;
298
- while ((typeof x === "object" || typeof x === "function") && x !== null) {
299
- const d = Object.getOwnPropertyDescriptor(x, name);
300
- if (d) {
301
- return d;
302
- }
303
- x = Object.getPrototypeOf(x);
304
- }
305
- return null;
306
- }
307
- function isGetter(object, name) {
308
- const d = getPropertyDescriptor(object, name);
309
- return d != null && d.get != null;
310
- }
311
- function getElementValues(nodeList, initialScope) {
312
- const valueList = [];
313
- for (let i = 0; i < nodeList.length; ++i) {
314
- const elementNode = nodeList[i];
315
- if (elementNode == null) {
316
- valueList.length = i + 1;
317
- } else if (elementNode.type === "SpreadElement") {
318
- const argument = getStaticValueR(elementNode.argument, initialScope);
319
- if (argument == null) {
320
- return null;
321
- }
322
- valueList.push(...argument.value);
323
- } else {
324
- const element = getStaticValueR(elementNode, initialScope);
325
- if (element == null) {
326
- return null;
327
- }
328
- valueList.push(element.value);
329
- }
330
- }
331
- return valueList;
332
- }
333
- function isEffectivelyConst(variable) {
334
- const refs = variable.references;
335
- const inits = refs.filter((r) => r.init).length;
336
- const reads = refs.filter((r) => r.isReadOnly()).length;
337
- if (inits === 1 && reads + inits === refs.length) {
338
- return true;
339
- }
340
- return false;
341
- }
342
- var operations = Object.freeze({
343
- ArrayExpression(node, initialScope) {
344
- const elements = getElementValues(node.elements, initialScope);
345
- return elements != null ? { value: elements } : null;
346
- },
347
- AssignmentExpression(node, initialScope) {
348
- if (node.operator === "=") {
349
- return getStaticValueR(node.right, initialScope);
350
- }
351
- return null;
352
- },
353
- //eslint-disable-next-line complexity
354
- BinaryExpression(node, initialScope) {
355
- if (node.operator === "in" || node.operator === "instanceof") {
356
- return null;
357
- }
358
- const left = getStaticValueR(node.left, initialScope);
359
- const right = getStaticValueR(node.right, initialScope);
360
- if (left != null && right != null) {
361
- switch (node.operator) {
362
- case "==":
363
- return { value: left.value == right.value };
364
- //eslint-disable-line eqeqeq
365
- case "!=":
366
- return { value: left.value != right.value };
367
- //eslint-disable-line eqeqeq
368
- case "===":
369
- return { value: left.value === right.value };
370
- case "!==":
371
- return { value: left.value !== right.value };
372
- case "<":
373
- return { value: left.value < right.value };
374
- case "<=":
375
- return { value: left.value <= right.value };
376
- case ">":
377
- return { value: left.value > right.value };
378
- case ">=":
379
- return { value: left.value >= right.value };
380
- case "<<":
381
- return { value: left.value << right.value };
382
- case ">>":
383
- return { value: left.value >> right.value };
384
- case ">>>":
385
- return { value: left.value >>> right.value };
386
- case "+":
387
- return { value: left.value + right.value };
388
- case "-":
389
- return { value: left.value - right.value };
390
- case "*":
391
- return { value: left.value * right.value };
392
- case "/":
393
- return { value: left.value / right.value };
394
- case "%":
395
- return { value: left.value % right.value };
396
- case "**":
397
- return { value: left.value ** right.value };
398
- case "|":
399
- return { value: left.value | right.value };
400
- case "^":
401
- return { value: left.value ^ right.value };
402
- case "&":
403
- return { value: left.value & right.value };
404
- }
405
- }
406
- return null;
407
- },
408
- CallExpression(node, initialScope) {
409
- const calleeNode = node.callee;
410
- const args = getElementValues(node.arguments, initialScope);
411
- if (args != null) {
412
- if (calleeNode.type === "MemberExpression") {
413
- if (calleeNode.property.type === "PrivateIdentifier") {
414
- return null;
415
- }
416
- const object = getStaticValueR(calleeNode.object, initialScope);
417
- if (object != null) {
418
- if (object.value == null && (object.optional || node.optional)) {
419
- return { value: void 0, optional: true };
420
- }
421
- const property = getStaticPropertyNameValue(
422
- calleeNode,
423
- initialScope
424
- );
425
- if (property != null) {
426
- const receiver = object.value;
427
- const methodName = property.value;
428
- if (callAllowed.has(receiver[methodName])) {
429
- return { value: receiver[methodName](...args) };
430
- }
431
- if (callPassThrough.has(receiver[methodName])) {
432
- return { value: args[0] };
433
- }
434
- }
435
- }
436
- } else {
437
- const callee = getStaticValueR(calleeNode, initialScope);
438
- if (callee != null) {
439
- if (callee.value == null && node.optional) {
440
- return { value: void 0, optional: true };
441
- }
442
- const func = callee.value;
443
- if (callAllowed.has(func)) {
444
- return { value: func(...args) };
445
- }
446
- if (callPassThrough.has(func)) {
447
- return { value: args[0] };
448
- }
449
- }
450
- }
451
- }
452
- return null;
453
- },
454
- ConditionalExpression(node, initialScope) {
455
- const test = getStaticValueR(node.test, initialScope);
456
- if (test != null) {
457
- return test.value ? getStaticValueR(node.consequent, initialScope) : getStaticValueR(node.alternate, initialScope);
458
- }
459
- return null;
460
- },
461
- ExpressionStatement(node, initialScope) {
462
- return getStaticValueR(node.expression, initialScope);
463
- },
464
- Identifier(node, initialScope) {
465
- if (initialScope != null) {
466
- const variable = findVariable(initialScope, node);
467
- if (variable != null && variable.defs.length === 0 && builtinNames.has(variable.name) && variable.name in globalObject) {
468
- return { value: globalObject[variable.name] };
469
- }
470
- if (variable != null && variable.defs.length === 1) {
471
- const def = variable.defs[0];
472
- if (def.parent && def.type === "Variable" && (def.parent.kind === "const" || isEffectivelyConst(variable)) && // TODO(mysticatea): don't support destructuring here.
473
- def.node.id.type === "Identifier") {
474
- return getStaticValueR(def.node.init, initialScope);
475
- }
476
- }
477
- }
478
- return null;
479
- },
480
- Literal(node) {
481
- if ((node.regex != null || node.bigint != null) && node.value == null) {
482
- return null;
483
- }
484
- return { value: node.value };
485
- },
486
- LogicalExpression(node, initialScope) {
487
- const left = getStaticValueR(node.left, initialScope);
488
- if (left != null) {
489
- if (node.operator === "||" && Boolean(left.value) === true || node.operator === "&&" && Boolean(left.value) === false || node.operator === "??" && left.value != null) {
490
- return left;
491
- }
492
- const right = getStaticValueR(node.right, initialScope);
493
- if (right != null) {
494
- return right;
495
- }
496
- }
497
- return null;
498
- },
499
- MemberExpression(node, initialScope) {
500
- if (node.property.type === "PrivateIdentifier") {
501
- return null;
502
- }
503
- const object = getStaticValueR(node.object, initialScope);
504
- if (object != null) {
505
- if (object.value == null && (object.optional || node.optional)) {
506
- return { value: void 0, optional: true };
507
- }
508
- const property = getStaticPropertyNameValue(node, initialScope);
509
- if (property != null) {
510
- if (!isGetter(object.value, property.value)) {
511
- return { value: object.value[property.value] };
512
- }
513
- for (const [classFn, allowed] of getterAllowed) {
514
- if (object.value instanceof classFn && allowed.has(property.value)) {
515
- return { value: object.value[property.value] };
516
- }
517
- }
518
- }
519
- }
520
- return null;
521
- },
522
- ChainExpression(node, initialScope) {
523
- const expression = getStaticValueR(node.expression, initialScope);
524
- if (expression != null) {
525
- return { value: expression.value };
526
- }
527
- return null;
528
- },
529
- NewExpression(node, initialScope) {
530
- const callee = getStaticValueR(node.callee, initialScope);
531
- const args = getElementValues(node.arguments, initialScope);
532
- if (callee != null && args != null) {
533
- const Func = callee.value;
534
- if (callAllowed.has(Func)) {
535
- return { value: new Func(...args) };
536
- }
537
- }
538
- return null;
539
- },
540
- ObjectExpression(node, initialScope) {
541
- const object = {};
542
- for (const propertyNode of node.properties) {
543
- if (propertyNode.type === "Property") {
544
- if (propertyNode.kind !== "init") {
545
- return null;
546
- }
547
- const key = getStaticPropertyNameValue(
548
- propertyNode,
549
- initialScope
550
- );
551
- const value = getStaticValueR(propertyNode.value, initialScope);
552
- if (key == null || value == null) {
553
- return null;
554
- }
555
- object[key.value] = value.value;
556
- } else if (propertyNode.type === "SpreadElement" || propertyNode.type === "ExperimentalSpreadProperty") {
557
- const argument = getStaticValueR(
558
- propertyNode.argument,
559
- initialScope
560
- );
561
- if (argument == null) {
562
- return null;
563
- }
564
- Object.assign(object, argument.value);
565
- } else {
566
- return null;
567
- }
568
- }
569
- return { value: object };
570
- },
571
- SequenceExpression(node, initialScope) {
572
- const last = node.expressions[node.expressions.length - 1];
573
- return getStaticValueR(last, initialScope);
574
- },
575
- TaggedTemplateExpression(node, initialScope) {
576
- const tag = getStaticValueR(node.tag, initialScope);
577
- const expressions = getElementValues(
578
- node.quasi.expressions,
579
- initialScope
580
- );
581
- if (tag != null && expressions != null) {
582
- const func = tag.value;
583
- const strings = node.quasi.quasis.map((q) => q.value.cooked);
584
- strings.raw = node.quasi.quasis.map((q) => q.value.raw);
585
- if (func === String.raw) {
586
- return { value: func(strings, ...expressions) };
587
- }
588
- }
589
- return null;
590
- },
591
- TemplateLiteral(node, initialScope) {
592
- const expressions = getElementValues(node.expressions, initialScope);
593
- if (expressions != null) {
594
- let value = node.quasis[0].value.cooked;
595
- for (let i = 0; i < expressions.length; ++i) {
596
- value += expressions[i];
597
- value += node.quasis[i + 1].value.cooked;
598
- }
599
- return { value };
600
- }
601
- return null;
602
- },
603
- UnaryExpression(node, initialScope) {
604
- if (node.operator === "delete") {
605
- return null;
606
- }
607
- if (node.operator === "void") {
608
- return { value: void 0 };
609
- }
610
- const arg = getStaticValueR(node.argument, initialScope);
611
- if (arg != null) {
612
- switch (node.operator) {
613
- case "-":
614
- return { value: -arg.value };
615
- case "+":
616
- return { value: +arg.value };
617
- //eslint-disable-line no-implicit-coercion
618
- case "!":
619
- return { value: !arg.value };
620
- case "~":
621
- return { value: ~arg.value };
622
- case "typeof":
623
- return { value: typeof arg.value };
624
- }
625
- }
626
- return null;
627
- }
628
- });
629
- function getStaticValueR(node, initialScope) {
630
- if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
631
- return operations[node.type](node, initialScope);
632
- }
633
- return null;
634
- }
635
- function getStaticPropertyNameValue(node, initialScope) {
636
- const nameNode = node.type === "Property" ? node.key : node.property;
637
- if (node.computed) {
638
- return getStaticValueR(nameNode, initialScope);
639
- }
640
- if (nameNode.type === "Identifier") {
641
- return { value: nameNode.name };
642
- }
643
- if (nameNode.type === "Literal") {
644
- if (nameNode.bigint) {
645
- return { value: nameNode.bigint };
646
- }
647
- return { value: String(nameNode.value) };
648
- }
649
- return null;
650
- }
651
- function getStaticValue(node, initialScope = null) {
652
- try {
653
- return getStaticValueR(node, initialScope);
654
- } catch (_error) {
655
- return null;
656
- }
657
- }
658
- function getStringIfConstant(node, initialScope = null) {
659
- if (node && node.type === "Literal" && node.value === null) {
660
- if (node.regex) {
661
- return `/${node.regex.pattern}/${node.regex.flags}`;
662
- }
663
- if (node.bigint) {
664
- return node.bigint;
665
- }
666
- }
667
- const evaluated = getStaticValue(node, initialScope);
668
- return evaluated && String(evaluated.value);
669
- }
670
- function getPropertyName(node, initialScope) {
671
- switch (node.type) {
672
- case "MemberExpression":
673
- if (node.computed) {
674
- return getStringIfConstant(node.property, initialScope);
675
- }
676
- if (node.property.type === "PrivateIdentifier") {
677
- return null;
678
- }
679
- return node.property.name;
680
- case "Property":
681
- case "MethodDefinition":
682
- case "PropertyDefinition":
683
- if (node.computed) {
684
- return getStringIfConstant(node.key, initialScope);
685
- }
686
- if (node.key.type === "Literal") {
687
- return String(node.key.value);
688
- }
689
- if (node.key.type === "PrivateIdentifier") {
690
- return null;
691
- }
692
- return node.key.name;
693
- }
694
- return null;
695
- }
696
- function getFunctionNameWithKind(node, sourceCode) {
697
- const parent = node.parent;
698
- const tokens = [];
699
- const isObjectMethod = parent.type === "Property" && parent.value === node;
700
- const isClassMethod = parent.type === "MethodDefinition" && parent.value === node;
701
- const isClassFieldMethod = parent.type === "PropertyDefinition" && parent.value === node;
702
- if (isClassMethod || isClassFieldMethod) {
703
- if (parent.static) {
704
- tokens.push("static");
705
- }
706
- if (parent.key.type === "PrivateIdentifier") {
707
- tokens.push("private");
708
- }
709
- }
710
- if (node.async) {
711
- tokens.push("async");
712
- }
713
- if (node.generator) {
714
- tokens.push("generator");
715
- }
716
- if (isObjectMethod || isClassMethod) {
717
- if (parent.kind === "constructor") {
718
- return "constructor";
719
- }
720
- if (parent.kind === "get") {
721
- tokens.push("getter");
722
- } else if (parent.kind === "set") {
723
- tokens.push("setter");
724
- } else {
725
- tokens.push("method");
726
- }
727
- } else if (isClassFieldMethod) {
728
- tokens.push("method");
729
- } else {
730
- if (node.type === "ArrowFunctionExpression") {
731
- tokens.push("arrow");
732
- }
733
- tokens.push("function");
734
- }
735
- if (isObjectMethod || isClassMethod || isClassFieldMethod) {
736
- if (parent.key.type === "PrivateIdentifier") {
737
- tokens.push(`#${parent.key.name}`);
738
- } else {
739
- const name = getPropertyName(parent);
740
- if (name) {
741
- tokens.push(`'${name}'`);
742
- } else if (sourceCode) {
743
- const keyText = sourceCode.getText(parent.key);
744
- if (!keyText.includes("\n")) {
745
- tokens.push(`[${keyText}]`);
746
- }
747
- }
748
- }
749
- } else if (node.id) {
750
- tokens.push(`'${node.id.name}'`);
751
- } else if (parent.type === "VariableDeclarator" && parent.id && parent.id.type === "Identifier") {
752
- tokens.push(`'${parent.id.name}'`);
753
- } else if ((parent.type === "AssignmentExpression" || parent.type === "AssignmentPattern") && parent.left && parent.left.type === "Identifier") {
754
- tokens.push(`'${parent.left.name}'`);
755
- } else if (parent.type === "ExportDefaultDeclaration" && parent.declaration === node) {
756
- tokens.push("'default'");
757
- }
758
- return tokens.join(" ");
759
- }
760
- var typeConversionBinaryOps = Object.freeze(
761
- /* @__PURE__ */ new Set([
762
- "==",
763
- "!=",
764
- "<",
765
- "<=",
766
- ">",
767
- ">=",
768
- "<<",
769
- ">>",
770
- ">>>",
771
- "+",
772
- "-",
773
- "*",
774
- "/",
775
- "%",
776
- "|",
777
- "^",
778
- "&",
779
- "in"
780
- ])
781
- );
782
- var typeConversionUnaryOps = Object.freeze(/* @__PURE__ */ new Set(["-", "+", "!", "~"]));
783
- function isNode(x) {
784
- return x !== null && typeof x === "object" && typeof x.type === "string";
785
- }
786
- var visitor = Object.freeze(
787
- Object.assign(/* @__PURE__ */ Object.create(null), {
788
- $visit(node, options, visitorKeys) {
789
- const { type } = node;
790
- if (typeof this[type] === "function") {
791
- return this[type](node, options, visitorKeys);
792
- }
793
- return this.$visitChildren(node, options, visitorKeys);
794
- },
795
- $visitChildren(node, options, visitorKeys) {
796
- const { type } = node;
797
- for (const key of visitorKeys[type] || eslintVisitorKeys.getKeys(node)) {
798
- const value = node[key];
799
- if (Array.isArray(value)) {
800
- for (const element of value) {
801
- if (isNode(element) && this.$visit(element, options, visitorKeys)) {
802
- return true;
803
- }
804
- }
805
- } else if (isNode(value) && this.$visit(value, options, visitorKeys)) {
806
- return true;
807
- }
808
- }
809
- return false;
810
- },
811
- ArrowFunctionExpression() {
812
- return false;
813
- },
814
- AssignmentExpression() {
815
- return true;
816
- },
817
- AwaitExpression() {
818
- return true;
819
- },
820
- BinaryExpression(node, options, visitorKeys) {
821
- if (options.considerImplicitTypeConversion && typeConversionBinaryOps.has(node.operator) && (node.left.type !== "Literal" || node.right.type !== "Literal")) {
822
- return true;
823
- }
824
- return this.$visitChildren(node, options, visitorKeys);
825
- },
826
- CallExpression() {
827
- return true;
828
- },
829
- FunctionExpression() {
830
- return false;
831
- },
832
- ImportExpression() {
833
- return true;
834
- },
835
- MemberExpression(node, options, visitorKeys) {
836
- if (options.considerGetters) {
837
- return true;
838
- }
839
- if (options.considerImplicitTypeConversion && node.computed && node.property.type !== "Literal") {
840
- return true;
841
- }
842
- return this.$visitChildren(node, options, visitorKeys);
843
- },
844
- MethodDefinition(node, options, visitorKeys) {
845
- if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
846
- return true;
847
- }
848
- return this.$visitChildren(node, options, visitorKeys);
849
- },
850
- NewExpression() {
851
- return true;
852
- },
853
- Property(node, options, visitorKeys) {
854
- if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
855
- return true;
856
- }
857
- return this.$visitChildren(node, options, visitorKeys);
858
- },
859
- PropertyDefinition(node, options, visitorKeys) {
860
- if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
861
- return true;
862
- }
863
- return this.$visitChildren(node, options, visitorKeys);
864
- },
865
- UnaryExpression(node, options, visitorKeys) {
866
- if (node.operator === "delete") {
867
- return true;
868
- }
869
- if (options.considerImplicitTypeConversion && typeConversionUnaryOps.has(node.operator) && node.argument.type !== "Literal") {
870
- return true;
871
- }
872
- return this.$visitChildren(node, options, visitorKeys);
873
- },
874
- UpdateExpression() {
875
- return true;
876
- },
877
- YieldExpression() {
878
- return true;
879
- }
880
- })
881
- );
882
- function hasSideEffect(node, sourceCode, { considerGetters = false, considerImplicitTypeConversion = false } = {}) {
883
- return visitor.$visit(
884
- node,
885
- { considerGetters, considerImplicitTypeConversion },
886
- sourceCode.visitorKeys || eslintVisitorKeys.KEYS
887
- );
888
- }
889
- function getParentSyntaxParen(node, sourceCode) {
890
- const parent = node.parent;
891
- switch (parent.type) {
892
- case "CallExpression":
893
- case "NewExpression":
894
- if (parent.arguments.length === 1 && parent.arguments[0] === node) {
895
- return sourceCode.getTokenAfter(
896
- parent.callee,
897
- isOpeningParenToken
898
- );
899
- }
900
- return null;
901
- case "DoWhileStatement":
902
- if (parent.test === node) {
903
- return sourceCode.getTokenAfter(
904
- parent.body,
905
- isOpeningParenToken
906
- );
907
- }
908
- return null;
909
- case "IfStatement":
910
- case "WhileStatement":
911
- if (parent.test === node) {
912
- return sourceCode.getFirstToken(parent, 1);
913
- }
914
- return null;
915
- case "ImportExpression":
916
- if (parent.source === node) {
917
- return sourceCode.getFirstToken(parent, 1);
918
- }
919
- return null;
920
- case "SwitchStatement":
921
- if (parent.discriminant === node) {
922
- return sourceCode.getFirstToken(parent, 1);
923
- }
924
- return null;
925
- case "WithStatement":
926
- if (parent.object === node) {
927
- return sourceCode.getFirstToken(parent, 1);
928
- }
929
- return null;
930
- default:
931
- return null;
932
- }
933
- }
934
- function isParenthesized(timesOrNode, nodeOrSourceCode, optionalSourceCode) {
935
- let times, node, sourceCode, maybeLeftParen, maybeRightParen;
936
- if (typeof timesOrNode === "number") {
937
- times = timesOrNode | 0;
938
- node = nodeOrSourceCode;
939
- sourceCode = optionalSourceCode;
940
- if (!(times >= 1)) {
941
- throw new TypeError("'times' should be a positive integer.");
942
- }
943
- } else {
944
- times = 1;
945
- node = timesOrNode;
946
- sourceCode = nodeOrSourceCode;
947
- }
948
- if (node == null || // `Program` can't be parenthesized
949
- node.parent == null || // `CatchClause.param` can't be parenthesized, example `try {} catch (error) {}`
950
- node.parent.type === "CatchClause" && node.parent.param === node) {
951
- return false;
952
- }
953
- maybeLeftParen = maybeRightParen = node;
954
- do {
955
- maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen);
956
- maybeRightParen = sourceCode.getTokenAfter(maybeRightParen);
957
- } while (maybeLeftParen != null && maybeRightParen != null && isOpeningParenToken(maybeLeftParen) && isClosingParenToken(maybeRightParen) && // Avoid false positive such as `if (a) {}`
958
- maybeLeftParen !== getParentSyntaxParen(node, sourceCode) && --times > 0);
959
- return times === 0;
960
- }
961
- var placeholder = /\$(?:[$&`']|[1-9][0-9]?)/gu;
962
- var internal = /* @__PURE__ */ new WeakMap();
963
- function isEscaped(str, index2) {
964
- let escaped = false;
965
- for (let i = index2 - 1; i >= 0 && str.charCodeAt(i) === 92; --i) {
966
- escaped = !escaped;
967
- }
968
- return escaped;
969
- }
970
- function replaceS(matcher, str, replacement) {
971
- const chunks = [];
972
- let index2 = 0;
973
- let match = null;
974
- function replacer(key) {
975
- switch (key) {
976
- case "$$":
977
- return "$";
978
- case "$&":
979
- return match[0];
980
- case "$`":
981
- return str.slice(0, match.index);
982
- case "$'":
983
- return str.slice(match.index + match[0].length);
984
- default: {
985
- const i = key.slice(1);
986
- if (i in match) {
987
- return match[i];
988
- }
989
- return key;
990
- }
991
- }
992
- }
993
- for (match of matcher.execAll(str)) {
994
- chunks.push(str.slice(index2, match.index));
995
- chunks.push(replacement.replace(placeholder, replacer));
996
- index2 = match.index + match[0].length;
997
- }
998
- chunks.push(str.slice(index2));
999
- return chunks.join("");
1000
- }
1001
- function replaceF(matcher, str, replace) {
1002
- const chunks = [];
1003
- let index2 = 0;
1004
- for (const match of matcher.execAll(str)) {
1005
- chunks.push(str.slice(index2, match.index));
1006
- chunks.push(String(replace(...match, match.index, match.input)));
1007
- index2 = match.index + match[0].length;
1008
- }
1009
- chunks.push(str.slice(index2));
1010
- return chunks.join("");
1011
- }
1012
- var PatternMatcher = class {
1013
- /**
1014
- * Initialize this matcher.
1015
- * @param {RegExp} pattern The pattern to match.
1016
- * @param {{escaped:boolean}} options The options.
1017
- */
1018
- constructor(pattern, { escaped = false } = {}) {
1019
- if (!(pattern instanceof RegExp)) {
1020
- throw new TypeError("'pattern' should be a RegExp instance.");
1021
- }
1022
- if (!pattern.flags.includes("g")) {
1023
- throw new Error("'pattern' should contains 'g' flag.");
1024
- }
1025
- internal.set(this, {
1026
- pattern: new RegExp(pattern.source, pattern.flags),
1027
- escaped: Boolean(escaped)
1028
- });
1029
- }
1030
- /**
1031
- * Find the pattern in a given string.
1032
- * @param {string} str The string to find.
1033
- * @returns {IterableIterator<RegExpExecArray>} The iterator which iterate the matched information.
1034
- */
1035
- *execAll(str) {
1036
- const { pattern, escaped } = internal.get(this);
1037
- let match = null;
1038
- let lastIndex = 0;
1039
- pattern.lastIndex = 0;
1040
- while ((match = pattern.exec(str)) != null) {
1041
- if (escaped || !isEscaped(str, match.index)) {
1042
- lastIndex = pattern.lastIndex;
1043
- yield match;
1044
- pattern.lastIndex = lastIndex;
1045
- }
1046
- }
1047
- }
1048
- /**
1049
- * Check whether the pattern is found in a given string.
1050
- * @param {string} str The string to check.
1051
- * @returns {boolean} `true` if the pattern was found in the string.
1052
- */
1053
- test(str) {
1054
- const it = this.execAll(str);
1055
- const ret = it.next();
1056
- return !ret.done;
1057
- }
1058
- /**
1059
- * Replace a given string.
1060
- * @param {string} str The string to be replaced.
1061
- * @param {(string|((...strs:string[])=>string))} replacer The string or function to replace. This is the same as the 2nd argument of `String.prototype.replace`.
1062
- * @returns {string} The replaced string.
1063
- */
1064
- [Symbol.replace](str, replacer) {
1065
- return typeof replacer === "function" ? replaceF(this, String(str), replacer) : replaceS(this, String(str), String(replacer));
1066
- }
1067
- };
1068
- var IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u;
1069
- var has = Function.call.bind(Object.hasOwnProperty);
1070
- var READ = Symbol("read");
1071
- var CALL = Symbol("call");
1072
- var CONSTRUCT = Symbol("construct");
1073
- var ESM = Symbol("esm");
1074
- var requireCall = { require: { [CALL]: true } };
1075
- function isModifiedGlobal(variable) {
1076
- return variable == null || variable.defs.length !== 0 || variable.references.some((r) => r.isWrite());
1077
- }
1078
- function isPassThrough(node) {
1079
- const parent = node.parent;
1080
- switch (parent && parent.type) {
1081
- case "ConditionalExpression":
1082
- return parent.consequent === node || parent.alternate === node;
1083
- case "LogicalExpression":
1084
- return true;
1085
- case "SequenceExpression":
1086
- return parent.expressions[parent.expressions.length - 1] === node;
1087
- case "ChainExpression":
1088
- return true;
1089
- default:
1090
- return false;
1091
- }
1092
- }
1093
- var ReferenceTracker = class {
1094
- /**
1095
- * Initialize this tracker.
1096
- * @param {Scope} globalScope The global scope.
1097
- * @param {object} [options] The options.
1098
- * @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules.
1099
- * @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object.
1100
- */
1101
- constructor(globalScope, {
1102
- mode = "strict",
1103
- globalObjectNames = ["global", "globalThis", "self", "window"]
1104
- } = {}) {
1105
- this.variableStack = [];
1106
- this.globalScope = globalScope;
1107
- this.mode = mode;
1108
- this.globalObjectNames = globalObjectNames.slice(0);
1109
- }
1110
- /**
1111
- * Iterate the references of global variables.
1112
- * @param {object} traceMap The trace map.
1113
- * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1114
- */
1115
- *iterateGlobalReferences(traceMap) {
1116
- for (const key of Object.keys(traceMap)) {
1117
- const nextTraceMap = traceMap[key];
1118
- const path = [key];
1119
- const variable = this.globalScope.set.get(key);
1120
- if (isModifiedGlobal(variable)) {
1121
- continue;
1122
- }
1123
- yield* this._iterateVariableReferences(
1124
- variable,
1125
- path,
1126
- nextTraceMap,
1127
- true
1128
- );
1129
- }
1130
- for (const key of this.globalObjectNames) {
1131
- const path = [];
1132
- const variable = this.globalScope.set.get(key);
1133
- if (isModifiedGlobal(variable)) {
1134
- continue;
1135
- }
1136
- yield* this._iterateVariableReferences(
1137
- variable,
1138
- path,
1139
- traceMap,
1140
- false
1141
- );
1142
- }
1143
- }
1144
- /**
1145
- * Iterate the references of CommonJS modules.
1146
- * @param {object} traceMap The trace map.
1147
- * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1148
- */
1149
- *iterateCjsReferences(traceMap) {
1150
- for (const { node } of this.iterateGlobalReferences(requireCall)) {
1151
- const key = getStringIfConstant(node.arguments[0]);
1152
- if (key == null || !has(traceMap, key)) {
1153
- continue;
1154
- }
1155
- const nextTraceMap = traceMap[key];
1156
- const path = [key];
1157
- if (nextTraceMap[READ]) {
1158
- yield {
1159
- node,
1160
- path,
1161
- type: READ,
1162
- info: nextTraceMap[READ]
1163
- };
1164
- }
1165
- yield* this._iteratePropertyReferences(node, path, nextTraceMap);
1166
- }
1167
- }
1168
- /**
1169
- * Iterate the references of ES modules.
1170
- * @param {object} traceMap The trace map.
1171
- * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1172
- */
1173
- *iterateEsmReferences(traceMap) {
1174
- const programNode = this.globalScope.block;
1175
- for (const node of programNode.body) {
1176
- if (!IMPORT_TYPE.test(node.type) || node.source == null) {
1177
- continue;
1178
- }
1179
- const moduleId = node.source.value;
1180
- if (!has(traceMap, moduleId)) {
1181
- continue;
1182
- }
1183
- const nextTraceMap = traceMap[moduleId];
1184
- const path = [moduleId];
1185
- if (nextTraceMap[READ]) {
1186
- yield { node, path, type: READ, info: nextTraceMap[READ] };
1187
- }
1188
- if (node.type === "ExportAllDeclaration") {
1189
- for (const key of Object.keys(nextTraceMap)) {
1190
- const exportTraceMap = nextTraceMap[key];
1191
- if (exportTraceMap[READ]) {
1192
- yield {
1193
- node,
1194
- path: path.concat(key),
1195
- type: READ,
1196
- info: exportTraceMap[READ]
1197
- };
1198
- }
1199
- }
1200
- } else {
1201
- for (const specifier of node.specifiers) {
1202
- const esm = has(nextTraceMap, ESM);
1203
- const it = this._iterateImportReferences(
1204
- specifier,
1205
- path,
1206
- esm ? nextTraceMap : this.mode === "legacy" ? { default: nextTraceMap, ...nextTraceMap } : { default: nextTraceMap }
1207
- );
1208
- if (esm) {
1209
- yield* it;
1210
- } else {
1211
- for (const report of it) {
1212
- report.path = report.path.filter(exceptDefault);
1213
- if (report.path.length >= 2 || report.type !== READ) {
1214
- yield report;
1215
- }
1216
- }
1217
- }
1218
- }
1219
- }
1220
- }
1221
- }
1222
- /**
1223
- * Iterate the references for a given variable.
1224
- * @param {Variable} variable The variable to iterate that references.
1225
- * @param {string[]} path The current path.
1226
- * @param {object} traceMap The trace map.
1227
- * @param {boolean} shouldReport = The flag to report those references.
1228
- * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1229
- */
1230
- *_iterateVariableReferences(variable, path, traceMap, shouldReport) {
1231
- if (this.variableStack.includes(variable)) {
1232
- return;
1233
- }
1234
- this.variableStack.push(variable);
1235
- try {
1236
- for (const reference of variable.references) {
1237
- if (!reference.isRead()) {
1238
- continue;
1239
- }
1240
- const node = reference.identifier;
1241
- if (shouldReport && traceMap[READ]) {
1242
- yield { node, path, type: READ, info: traceMap[READ] };
1243
- }
1244
- yield* this._iteratePropertyReferences(node, path, traceMap);
1245
- }
1246
- } finally {
1247
- this.variableStack.pop();
1248
- }
1249
- }
1250
- /**
1251
- * Iterate the references for a given AST node.
1252
- * @param rootNode The AST node to iterate references.
1253
- * @param {string[]} path The current path.
1254
- * @param {object} traceMap The trace map.
1255
- * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1256
- */
1257
- //eslint-disable-next-line complexity
1258
- *_iteratePropertyReferences(rootNode, path, traceMap) {
1259
- let node = rootNode;
1260
- while (isPassThrough(node)) {
1261
- node = node.parent;
1262
- }
1263
- const parent = node.parent;
1264
- if (parent.type === "MemberExpression") {
1265
- if (parent.object === node) {
1266
- const key = getPropertyName(parent);
1267
- if (key == null || !has(traceMap, key)) {
1268
- return;
1269
- }
1270
- path = path.concat(key);
1271
- const nextTraceMap = traceMap[key];
1272
- if (nextTraceMap[READ]) {
1273
- yield {
1274
- node: parent,
1275
- path,
1276
- type: READ,
1277
- info: nextTraceMap[READ]
1278
- };
1279
- }
1280
- yield* this._iteratePropertyReferences(
1281
- parent,
1282
- path,
1283
- nextTraceMap
1284
- );
1285
- }
1286
- return;
1287
- }
1288
- if (parent.type === "CallExpression") {
1289
- if (parent.callee === node && traceMap[CALL]) {
1290
- yield { node: parent, path, type: CALL, info: traceMap[CALL] };
1291
- }
1292
- return;
1293
- }
1294
- if (parent.type === "NewExpression") {
1295
- if (parent.callee === node && traceMap[CONSTRUCT]) {
1296
- yield {
1297
- node: parent,
1298
- path,
1299
- type: CONSTRUCT,
1300
- info: traceMap[CONSTRUCT]
1301
- };
1302
- }
1303
- return;
1304
- }
1305
- if (parent.type === "AssignmentExpression") {
1306
- if (parent.right === node) {
1307
- yield* this._iterateLhsReferences(parent.left, path, traceMap);
1308
- yield* this._iteratePropertyReferences(parent, path, traceMap);
1309
- }
1310
- return;
1311
- }
1312
- if (parent.type === "AssignmentPattern") {
1313
- if (parent.right === node) {
1314
- yield* this._iterateLhsReferences(parent.left, path, traceMap);
1315
- }
1316
- return;
1317
- }
1318
- if (parent.type === "VariableDeclarator") {
1319
- if (parent.init === node) {
1320
- yield* this._iterateLhsReferences(parent.id, path, traceMap);
1321
- }
1322
- }
1323
- }
1324
- /**
1325
- * Iterate the references for a given Pattern node.
1326
- * @param {Node} patternNode The Pattern node to iterate references.
1327
- * @param {string[]} path The current path.
1328
- * @param {object} traceMap The trace map.
1329
- * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1330
- */
1331
- *_iterateLhsReferences(patternNode, path, traceMap) {
1332
- if (patternNode.type === "Identifier") {
1333
- const variable = findVariable(this.globalScope, patternNode);
1334
- if (variable != null) {
1335
- yield* this._iterateVariableReferences(
1336
- variable,
1337
- path,
1338
- traceMap,
1339
- false
1340
- );
1341
- }
1342
- return;
1343
- }
1344
- if (patternNode.type === "ObjectPattern") {
1345
- for (const property of patternNode.properties) {
1346
- const key = getPropertyName(property);
1347
- if (key == null || !has(traceMap, key)) {
1348
- continue;
1349
- }
1350
- const nextPath = path.concat(key);
1351
- const nextTraceMap = traceMap[key];
1352
- if (nextTraceMap[READ]) {
1353
- yield {
1354
- node: property,
1355
- path: nextPath,
1356
- type: READ,
1357
- info: nextTraceMap[READ]
1358
- };
1359
- }
1360
- yield* this._iterateLhsReferences(
1361
- property.value,
1362
- nextPath,
1363
- nextTraceMap
1364
- );
1365
- }
1366
- return;
1367
- }
1368
- if (patternNode.type === "AssignmentPattern") {
1369
- yield* this._iterateLhsReferences(patternNode.left, path, traceMap);
1370
- }
1371
- }
1372
- /**
1373
- * Iterate the references for a given ModuleSpecifier node.
1374
- * @param {Node} specifierNode The ModuleSpecifier node to iterate references.
1375
- * @param {string[]} path The current path.
1376
- * @param {object} traceMap The trace map.
1377
- * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1378
- */
1379
- *_iterateImportReferences(specifierNode, path, traceMap) {
1380
- const type = specifierNode.type;
1381
- if (type === "ImportSpecifier" || type === "ImportDefaultSpecifier") {
1382
- const key = type === "ImportDefaultSpecifier" ? "default" : specifierNode.imported.name;
1383
- if (!has(traceMap, key)) {
1384
- return;
1385
- }
1386
- path = path.concat(key);
1387
- const nextTraceMap = traceMap[key];
1388
- if (nextTraceMap[READ]) {
1389
- yield {
1390
- node: specifierNode,
1391
- path,
1392
- type: READ,
1393
- info: nextTraceMap[READ]
1394
- };
1395
- }
1396
- yield* this._iterateVariableReferences(
1397
- findVariable(this.globalScope, specifierNode.local),
1398
- path,
1399
- nextTraceMap,
1400
- false
1401
- );
1402
- return;
1403
- }
1404
- if (type === "ImportNamespaceSpecifier") {
1405
- yield* this._iterateVariableReferences(
1406
- findVariable(this.globalScope, specifierNode.local),
1407
- path,
1408
- traceMap,
1409
- false
1410
- );
1411
- return;
1412
- }
1413
- if (type === "ExportSpecifier") {
1414
- const key = specifierNode.local.name;
1415
- if (!has(traceMap, key)) {
1416
- return;
1417
- }
1418
- path = path.concat(key);
1419
- const nextTraceMap = traceMap[key];
1420
- if (nextTraceMap[READ]) {
1421
- yield {
1422
- node: specifierNode,
1423
- path,
1424
- type: READ,
1425
- info: nextTraceMap[READ]
1426
- };
1427
- }
1428
- }
1429
- }
1430
- };
1431
- ReferenceTracker.READ = READ;
1432
- ReferenceTracker.CALL = CALL;
1433
- ReferenceTracker.CONSTRUCT = CONSTRUCT;
1434
- ReferenceTracker.ESM = ESM;
1435
- function exceptDefault(name, index2) {
1436
- return !(index2 === 1 && name === "default");
1437
- }
1438
- var index = {
1439
- CALL,
1440
- CONSTRUCT,
1441
- ESM,
1442
- findVariable,
1443
- getFunctionHeadLocation,
1444
- getFunctionNameWithKind,
1445
- getInnermostScope,
1446
- getPropertyName,
1447
- getStaticValue,
1448
- getStringIfConstant,
1449
- hasSideEffect,
1450
- isArrowToken,
1451
- isClosingBraceToken,
1452
- isClosingBracketToken,
1453
- isClosingParenToken,
1454
- isColonToken,
1455
- isCommaToken,
1456
- isCommentToken,
1457
- isNotArrowToken,
1458
- isNotClosingBraceToken,
1459
- isNotClosingBracketToken,
1460
- isNotClosingParenToken,
1461
- isNotColonToken,
1462
- isNotCommaToken,
1463
- isNotCommentToken,
1464
- isNotOpeningBraceToken,
1465
- isNotOpeningBracketToken,
1466
- isNotOpeningParenToken,
1467
- isNotSemicolonToken,
1468
- isOpeningBraceToken,
1469
- isOpeningBracketToken,
1470
- isOpeningParenToken,
1471
- isParenthesized,
1472
- isSemicolonToken,
1473
- PatternMatcher,
1474
- READ,
1475
- ReferenceTracker
1476
- };
1477
- exports.CALL = CALL;
1478
- exports.CONSTRUCT = CONSTRUCT;
1479
- exports.ESM = ESM;
1480
- exports.PatternMatcher = PatternMatcher;
1481
- exports.READ = READ;
1482
- exports.ReferenceTracker = ReferenceTracker;
1483
- exports["default"] = index;
1484
- exports.findVariable = findVariable;
1485
- exports.getFunctionHeadLocation = getFunctionHeadLocation;
1486
- exports.getFunctionNameWithKind = getFunctionNameWithKind;
1487
- exports.getInnermostScope = getInnermostScope;
1488
- exports.getPropertyName = getPropertyName;
1489
- exports.getStaticValue = getStaticValue;
1490
- exports.getStringIfConstant = getStringIfConstant;
1491
- exports.hasSideEffect = hasSideEffect;
1492
- exports.isArrowToken = isArrowToken;
1493
- exports.isClosingBraceToken = isClosingBraceToken;
1494
- exports.isClosingBracketToken = isClosingBracketToken;
1495
- exports.isClosingParenToken = isClosingParenToken;
1496
- exports.isColonToken = isColonToken;
1497
- exports.isCommaToken = isCommaToken;
1498
- exports.isCommentToken = isCommentToken;
1499
- exports.isNotArrowToken = isNotArrowToken;
1500
- exports.isNotClosingBraceToken = isNotClosingBraceToken;
1501
- exports.isNotClosingBracketToken = isNotClosingBracketToken;
1502
- exports.isNotClosingParenToken = isNotClosingParenToken;
1503
- exports.isNotColonToken = isNotColonToken;
1504
- exports.isNotCommaToken = isNotCommaToken;
1505
- exports.isNotCommentToken = isNotCommentToken;
1506
- exports.isNotOpeningBraceToken = isNotOpeningBraceToken;
1507
- exports.isNotOpeningBracketToken = isNotOpeningBracketToken;
1508
- exports.isNotOpeningParenToken = isNotOpeningParenToken;
1509
- exports.isNotSemicolonToken = isNotSemicolonToken;
1510
- exports.isOpeningBraceToken = isOpeningBraceToken;
1511
- exports.isOpeningBracketToken = isOpeningBracketToken;
1512
- exports.isOpeningParenToken = isOpeningParenToken;
1513
- exports.isParenthesized = isParenthesized;
1514
- exports.isSemicolonToken = isSemicolonToken;
1515
- }
1516
- });
1517
-
1518
- export {
1519
- require_eslint_utils
1520
- };