@solvro/config 2.0.0-beta.3 → 2.0.0-beta.5

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.
@@ -0,0 +1,2133 @@
1
+ import {
2
+ typescriptStrict,
3
+ unicorn
4
+ } from "./chunk-OEFF22F3.js";
5
+ import {
6
+ imports
7
+ } from "./chunk-DHQ2VVRM.js";
8
+ import "./chunk-HM3MY7J3.js";
9
+ import {
10
+ __commonJS,
11
+ __toESM,
12
+ init_esm_shims
13
+ } from "./chunk-J5OUMHDO.js";
14
+
15
+ // node_modules/eslint-utils/node_modules/eslint-visitor-keys/lib/visitor-keys.json
16
+ var require_visitor_keys = __commonJS({
17
+ "node_modules/eslint-utils/node_modules/eslint-visitor-keys/lib/visitor-keys.json"(exports, module) {
18
+ module.exports = {
19
+ AssignmentExpression: [
20
+ "left",
21
+ "right"
22
+ ],
23
+ AssignmentPattern: [
24
+ "left",
25
+ "right"
26
+ ],
27
+ ArrayExpression: [
28
+ "elements"
29
+ ],
30
+ ArrayPattern: [
31
+ "elements"
32
+ ],
33
+ ArrowFunctionExpression: [
34
+ "params",
35
+ "body"
36
+ ],
37
+ AwaitExpression: [
38
+ "argument"
39
+ ],
40
+ BlockStatement: [
41
+ "body"
42
+ ],
43
+ BinaryExpression: [
44
+ "left",
45
+ "right"
46
+ ],
47
+ BreakStatement: [
48
+ "label"
49
+ ],
50
+ CallExpression: [
51
+ "callee",
52
+ "arguments"
53
+ ],
54
+ CatchClause: [
55
+ "param",
56
+ "body"
57
+ ],
58
+ ChainExpression: [
59
+ "expression"
60
+ ],
61
+ ClassBody: [
62
+ "body"
63
+ ],
64
+ ClassDeclaration: [
65
+ "id",
66
+ "superClass",
67
+ "body"
68
+ ],
69
+ ClassExpression: [
70
+ "id",
71
+ "superClass",
72
+ "body"
73
+ ],
74
+ ConditionalExpression: [
75
+ "test",
76
+ "consequent",
77
+ "alternate"
78
+ ],
79
+ ContinueStatement: [
80
+ "label"
81
+ ],
82
+ DebuggerStatement: [],
83
+ DoWhileStatement: [
84
+ "body",
85
+ "test"
86
+ ],
87
+ EmptyStatement: [],
88
+ ExportAllDeclaration: [
89
+ "exported",
90
+ "source"
91
+ ],
92
+ ExportDefaultDeclaration: [
93
+ "declaration"
94
+ ],
95
+ ExportNamedDeclaration: [
96
+ "declaration",
97
+ "specifiers",
98
+ "source"
99
+ ],
100
+ ExportSpecifier: [
101
+ "exported",
102
+ "local"
103
+ ],
104
+ ExpressionStatement: [
105
+ "expression"
106
+ ],
107
+ ExperimentalRestProperty: [
108
+ "argument"
109
+ ],
110
+ ExperimentalSpreadProperty: [
111
+ "argument"
112
+ ],
113
+ ForStatement: [
114
+ "init",
115
+ "test",
116
+ "update",
117
+ "body"
118
+ ],
119
+ ForInStatement: [
120
+ "left",
121
+ "right",
122
+ "body"
123
+ ],
124
+ ForOfStatement: [
125
+ "left",
126
+ "right",
127
+ "body"
128
+ ],
129
+ FunctionDeclaration: [
130
+ "id",
131
+ "params",
132
+ "body"
133
+ ],
134
+ FunctionExpression: [
135
+ "id",
136
+ "params",
137
+ "body"
138
+ ],
139
+ Identifier: [],
140
+ IfStatement: [
141
+ "test",
142
+ "consequent",
143
+ "alternate"
144
+ ],
145
+ ImportDeclaration: [
146
+ "specifiers",
147
+ "source"
148
+ ],
149
+ ImportDefaultSpecifier: [
150
+ "local"
151
+ ],
152
+ ImportExpression: [
153
+ "source"
154
+ ],
155
+ ImportNamespaceSpecifier: [
156
+ "local"
157
+ ],
158
+ ImportSpecifier: [
159
+ "imported",
160
+ "local"
161
+ ],
162
+ JSXAttribute: [
163
+ "name",
164
+ "value"
165
+ ],
166
+ JSXClosingElement: [
167
+ "name"
168
+ ],
169
+ JSXElement: [
170
+ "openingElement",
171
+ "children",
172
+ "closingElement"
173
+ ],
174
+ JSXEmptyExpression: [],
175
+ JSXExpressionContainer: [
176
+ "expression"
177
+ ],
178
+ JSXIdentifier: [],
179
+ JSXMemberExpression: [
180
+ "object",
181
+ "property"
182
+ ],
183
+ JSXNamespacedName: [
184
+ "namespace",
185
+ "name"
186
+ ],
187
+ JSXOpeningElement: [
188
+ "name",
189
+ "attributes"
190
+ ],
191
+ JSXSpreadAttribute: [
192
+ "argument"
193
+ ],
194
+ JSXText: [],
195
+ JSXFragment: [
196
+ "openingFragment",
197
+ "children",
198
+ "closingFragment"
199
+ ],
200
+ Literal: [],
201
+ LabeledStatement: [
202
+ "label",
203
+ "body"
204
+ ],
205
+ LogicalExpression: [
206
+ "left",
207
+ "right"
208
+ ],
209
+ MemberExpression: [
210
+ "object",
211
+ "property"
212
+ ],
213
+ MetaProperty: [
214
+ "meta",
215
+ "property"
216
+ ],
217
+ MethodDefinition: [
218
+ "key",
219
+ "value"
220
+ ],
221
+ NewExpression: [
222
+ "callee",
223
+ "arguments"
224
+ ],
225
+ ObjectExpression: [
226
+ "properties"
227
+ ],
228
+ ObjectPattern: [
229
+ "properties"
230
+ ],
231
+ PrivateIdentifier: [],
232
+ Program: [
233
+ "body"
234
+ ],
235
+ Property: [
236
+ "key",
237
+ "value"
238
+ ],
239
+ PropertyDefinition: [
240
+ "key",
241
+ "value"
242
+ ],
243
+ RestElement: [
244
+ "argument"
245
+ ],
246
+ ReturnStatement: [
247
+ "argument"
248
+ ],
249
+ SequenceExpression: [
250
+ "expressions"
251
+ ],
252
+ SpreadElement: [
253
+ "argument"
254
+ ],
255
+ Super: [],
256
+ SwitchStatement: [
257
+ "discriminant",
258
+ "cases"
259
+ ],
260
+ SwitchCase: [
261
+ "test",
262
+ "consequent"
263
+ ],
264
+ TaggedTemplateExpression: [
265
+ "tag",
266
+ "quasi"
267
+ ],
268
+ TemplateElement: [],
269
+ TemplateLiteral: [
270
+ "quasis",
271
+ "expressions"
272
+ ],
273
+ ThisExpression: [],
274
+ ThrowStatement: [
275
+ "argument"
276
+ ],
277
+ TryStatement: [
278
+ "block",
279
+ "handler",
280
+ "finalizer"
281
+ ],
282
+ UnaryExpression: [
283
+ "argument"
284
+ ],
285
+ UpdateExpression: [
286
+ "argument"
287
+ ],
288
+ VariableDeclaration: [
289
+ "declarations"
290
+ ],
291
+ VariableDeclarator: [
292
+ "id",
293
+ "init"
294
+ ],
295
+ WhileStatement: [
296
+ "test",
297
+ "body"
298
+ ],
299
+ WithStatement: [
300
+ "object",
301
+ "body"
302
+ ],
303
+ YieldExpression: [
304
+ "argument"
305
+ ]
306
+ };
307
+ }
308
+ });
309
+
310
+ // node_modules/eslint-utils/node_modules/eslint-visitor-keys/lib/index.js
311
+ var require_lib = __commonJS({
312
+ "node_modules/eslint-utils/node_modules/eslint-visitor-keys/lib/index.js"(exports, module) {
313
+ "use strict";
314
+ init_esm_shims();
315
+ var KEYS = require_visitor_keys();
316
+ var NODE_TYPES = Object.freeze(Object.keys(KEYS));
317
+ for (const type of NODE_TYPES) {
318
+ Object.freeze(KEYS[type]);
319
+ }
320
+ Object.freeze(KEYS);
321
+ var KEY_BLACKLIST = /* @__PURE__ */ new Set([
322
+ "parent",
323
+ "leadingComments",
324
+ "trailingComments"
325
+ ]);
326
+ function filterKey(key) {
327
+ return !KEY_BLACKLIST.has(key) && key[0] !== "_";
328
+ }
329
+ module.exports = Object.freeze({
330
+ /**
331
+ * Visitor keys.
332
+ * @type {{ [type: string]: string[] | undefined }}
333
+ */
334
+ KEYS,
335
+ /**
336
+ * Get visitor keys of a given node.
337
+ * @param {Object} node The AST node to get keys.
338
+ * @returns {string[]} Visitor keys of the node.
339
+ */
340
+ getKeys(node) {
341
+ return Object.keys(node).filter(filterKey);
342
+ },
343
+ // Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
344
+ // eslint-disable-next-line valid-jsdoc
345
+ /**
346
+ * Make the union set with `KEYS` and given keys.
347
+ * @param {Object} additionalKeys The additional keys.
348
+ * @returns {{ [type: string]: string[] | undefined }} The union set.
349
+ */
350
+ unionWith(additionalKeys) {
351
+ const retv = Object.assign({}, KEYS);
352
+ for (const type of Object.keys(additionalKeys)) {
353
+ if (retv.hasOwnProperty(type)) {
354
+ const keys = new Set(additionalKeys[type]);
355
+ for (const key of retv[type]) {
356
+ keys.add(key);
357
+ }
358
+ retv[type] = Object.freeze(Array.from(keys));
359
+ } else {
360
+ retv[type] = Object.freeze(Array.from(additionalKeys[type]));
361
+ }
362
+ }
363
+ return Object.freeze(retv);
364
+ }
365
+ });
366
+ }
367
+ });
368
+
369
+ // src/eslint/presets/react.ts
370
+ init_esm_shims();
371
+
372
+ // src/eslint/configs/a11y.ts
373
+ init_esm_shims();
374
+ import jsxA11y from "eslint-plugin-jsx-a11y";
375
+ import globals from "globals";
376
+ function a11y() {
377
+ return [
378
+ {
379
+ files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
380
+ ...jsxA11y.flatConfigs.recommended,
381
+ languageOptions: {
382
+ ...jsxA11y.flatConfigs.recommended.languageOptions,
383
+ globals: {
384
+ ...globals.serviceworker,
385
+ ...globals.browser
386
+ }
387
+ },
388
+ settings: {
389
+ "jsx-a11y": {
390
+ components: {
391
+ Input: "input",
392
+ Button: "button",
393
+ Link: "a",
394
+ Label: "label",
395
+ Select: "select",
396
+ Textarea: "textarea"
397
+ },
398
+ attributes: {
399
+ for: ["htmlFor", "for"]
400
+ }
401
+ }
402
+ }
403
+ }
404
+ ];
405
+ }
406
+
407
+ // src/eslint/configs/react.ts
408
+ init_esm_shims();
409
+ import pluginQuery from "@tanstack/eslint-plugin-query";
410
+ import pluginReact from "eslint-plugin-react";
411
+ import pluginReactHooks from "eslint-plugin-react-hooks";
412
+
413
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/index.js
414
+ init_esm_shims();
415
+
416
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-empty-effect.js
417
+ init_esm_shims();
418
+
419
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/util/react.js
420
+ init_esm_shims();
421
+
422
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/util/ast.js
423
+ init_esm_shims();
424
+
425
+ // node_modules/eslint-utils/index.mjs
426
+ init_esm_shims();
427
+ var import_eslint_visitor_keys = __toESM(require_lib(), 1);
428
+ function getInnermostScope(initialScope, node) {
429
+ const location = node.range[0];
430
+ let scope = initialScope;
431
+ let found = false;
432
+ do {
433
+ found = false;
434
+ for (const childScope of scope.childScopes) {
435
+ const range = childScope.block.range;
436
+ if (range[0] <= location && location < range[1]) {
437
+ scope = childScope;
438
+ found = true;
439
+ break;
440
+ }
441
+ }
442
+ } while (found);
443
+ return scope;
444
+ }
445
+ function findVariable(initialScope, nameOrNode) {
446
+ let name8 = "";
447
+ let scope = initialScope;
448
+ if (typeof nameOrNode === "string") {
449
+ name8 = nameOrNode;
450
+ } else {
451
+ name8 = nameOrNode.name;
452
+ scope = getInnermostScope(scope, nameOrNode);
453
+ }
454
+ while (scope != null) {
455
+ const variable = scope.set.get(name8);
456
+ if (variable != null) {
457
+ return variable;
458
+ }
459
+ scope = scope.upper;
460
+ }
461
+ return null;
462
+ }
463
+ function negate0(token) {
464
+ return !this(token);
465
+ }
466
+ function negate(f) {
467
+ return negate0.bind(f);
468
+ }
469
+ function isPunctuatorTokenWithValue(token, value) {
470
+ return token.type === "Punctuator" && token.value === value;
471
+ }
472
+ function isArrowToken(token) {
473
+ return isPunctuatorTokenWithValue(token, "=>");
474
+ }
475
+ function isCommaToken(token) {
476
+ return isPunctuatorTokenWithValue(token, ",");
477
+ }
478
+ function isSemicolonToken(token) {
479
+ return isPunctuatorTokenWithValue(token, ";");
480
+ }
481
+ function isColonToken(token) {
482
+ return isPunctuatorTokenWithValue(token, ":");
483
+ }
484
+ function isOpeningParenToken(token) {
485
+ return isPunctuatorTokenWithValue(token, "(");
486
+ }
487
+ function isClosingParenToken(token) {
488
+ return isPunctuatorTokenWithValue(token, ")");
489
+ }
490
+ function isOpeningBracketToken(token) {
491
+ return isPunctuatorTokenWithValue(token, "[");
492
+ }
493
+ function isClosingBracketToken(token) {
494
+ return isPunctuatorTokenWithValue(token, "]");
495
+ }
496
+ function isOpeningBraceToken(token) {
497
+ return isPunctuatorTokenWithValue(token, "{");
498
+ }
499
+ function isClosingBraceToken(token) {
500
+ return isPunctuatorTokenWithValue(token, "}");
501
+ }
502
+ function isCommentToken(token) {
503
+ return ["Block", "Line", "Shebang"].includes(token.type);
504
+ }
505
+ var isNotArrowToken = negate(isArrowToken);
506
+ var isNotCommaToken = negate(isCommaToken);
507
+ var isNotSemicolonToken = negate(isSemicolonToken);
508
+ var isNotColonToken = negate(isColonToken);
509
+ var isNotOpeningParenToken = negate(isOpeningParenToken);
510
+ var isNotClosingParenToken = negate(isClosingParenToken);
511
+ var isNotOpeningBracketToken = negate(isOpeningBracketToken);
512
+ var isNotClosingBracketToken = negate(isClosingBracketToken);
513
+ var isNotOpeningBraceToken = negate(isOpeningBraceToken);
514
+ var isNotClosingBraceToken = negate(isClosingBraceToken);
515
+ var isNotCommentToken = negate(isCommentToken);
516
+ var globalObject = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
517
+ var builtinNames = Object.freeze(
518
+ /* @__PURE__ */ new Set([
519
+ "Array",
520
+ "ArrayBuffer",
521
+ "BigInt",
522
+ "BigInt64Array",
523
+ "BigUint64Array",
524
+ "Boolean",
525
+ "DataView",
526
+ "Date",
527
+ "decodeURI",
528
+ "decodeURIComponent",
529
+ "encodeURI",
530
+ "encodeURIComponent",
531
+ "escape",
532
+ "Float32Array",
533
+ "Float64Array",
534
+ "Function",
535
+ "Infinity",
536
+ "Int16Array",
537
+ "Int32Array",
538
+ "Int8Array",
539
+ "isFinite",
540
+ "isNaN",
541
+ "isPrototypeOf",
542
+ "JSON",
543
+ "Map",
544
+ "Math",
545
+ "NaN",
546
+ "Number",
547
+ "Object",
548
+ "parseFloat",
549
+ "parseInt",
550
+ "Promise",
551
+ "Proxy",
552
+ "Reflect",
553
+ "RegExp",
554
+ "Set",
555
+ "String",
556
+ "Symbol",
557
+ "Uint16Array",
558
+ "Uint32Array",
559
+ "Uint8Array",
560
+ "Uint8ClampedArray",
561
+ "undefined",
562
+ "unescape",
563
+ "WeakMap",
564
+ "WeakSet"
565
+ ])
566
+ );
567
+ var callAllowed = new Set(
568
+ [
569
+ Array.isArray,
570
+ typeof BigInt === "function" ? BigInt : void 0,
571
+ Boolean,
572
+ Date,
573
+ Date.parse,
574
+ decodeURI,
575
+ decodeURIComponent,
576
+ encodeURI,
577
+ encodeURIComponent,
578
+ escape,
579
+ isFinite,
580
+ isNaN,
581
+ isPrototypeOf,
582
+ ...Object.getOwnPropertyNames(Math).map((k) => Math[k]).filter((f) => typeof f === "function"),
583
+ Number,
584
+ Number.isFinite,
585
+ Number.isNaN,
586
+ Number.parseFloat,
587
+ Number.parseInt,
588
+ Object,
589
+ Object.entries,
590
+ Object.is,
591
+ Object.isExtensible,
592
+ Object.isFrozen,
593
+ Object.isSealed,
594
+ Object.keys,
595
+ Object.values,
596
+ parseFloat,
597
+ parseInt,
598
+ RegExp,
599
+ String,
600
+ String.fromCharCode,
601
+ String.fromCodePoint,
602
+ String.raw,
603
+ Symbol.for,
604
+ Symbol.keyFor,
605
+ unescape
606
+ ].filter((f) => typeof f === "function")
607
+ );
608
+ var callPassThrough = /* @__PURE__ */ new Set([
609
+ Object.freeze,
610
+ Object.preventExtensions,
611
+ Object.seal
612
+ ]);
613
+ function getPropertyDescriptor(object, name8) {
614
+ let x = object;
615
+ while ((typeof x === "object" || typeof x === "function") && x !== null) {
616
+ const d = Object.getOwnPropertyDescriptor(x, name8);
617
+ if (d) {
618
+ return d;
619
+ }
620
+ x = Object.getPrototypeOf(x);
621
+ }
622
+ return null;
623
+ }
624
+ function isGetter(object, name8) {
625
+ const d = getPropertyDescriptor(object, name8);
626
+ return d != null && d.get != null;
627
+ }
628
+ function getElementValues(nodeList, initialScope) {
629
+ const valueList = [];
630
+ for (let i = 0; i < nodeList.length; ++i) {
631
+ const elementNode = nodeList[i];
632
+ if (elementNode == null) {
633
+ valueList.length = i + 1;
634
+ } else if (elementNode.type === "SpreadElement") {
635
+ const argument = getStaticValueR(elementNode.argument, initialScope);
636
+ if (argument == null) {
637
+ return null;
638
+ }
639
+ valueList.push(...argument.value);
640
+ } else {
641
+ const element = getStaticValueR(elementNode, initialScope);
642
+ if (element == null) {
643
+ return null;
644
+ }
645
+ valueList.push(element.value);
646
+ }
647
+ }
648
+ return valueList;
649
+ }
650
+ var operations = Object.freeze({
651
+ ArrayExpression(node, initialScope) {
652
+ const elements = getElementValues(node.elements, initialScope);
653
+ return elements != null ? { value: elements } : null;
654
+ },
655
+ AssignmentExpression(node, initialScope) {
656
+ if (node.operator === "=") {
657
+ return getStaticValueR(node.right, initialScope);
658
+ }
659
+ return null;
660
+ },
661
+ //eslint-disable-next-line complexity
662
+ BinaryExpression(node, initialScope) {
663
+ if (node.operator === "in" || node.operator === "instanceof") {
664
+ return null;
665
+ }
666
+ const left = getStaticValueR(node.left, initialScope);
667
+ const right = getStaticValueR(node.right, initialScope);
668
+ if (left != null && right != null) {
669
+ switch (node.operator) {
670
+ case "==":
671
+ return { value: left.value == right.value };
672
+ //eslint-disable-line eqeqeq
673
+ case "!=":
674
+ return { value: left.value != right.value };
675
+ //eslint-disable-line eqeqeq
676
+ case "===":
677
+ return { value: left.value === right.value };
678
+ case "!==":
679
+ return { value: left.value !== right.value };
680
+ case "<":
681
+ return { value: left.value < right.value };
682
+ case "<=":
683
+ return { value: left.value <= right.value };
684
+ case ">":
685
+ return { value: left.value > right.value };
686
+ case ">=":
687
+ return { value: left.value >= right.value };
688
+ case "<<":
689
+ return { value: left.value << right.value };
690
+ case ">>":
691
+ return { value: left.value >> right.value };
692
+ case ">>>":
693
+ return { value: left.value >>> right.value };
694
+ case "+":
695
+ return { value: left.value + right.value };
696
+ case "-":
697
+ return { value: left.value - right.value };
698
+ case "*":
699
+ return { value: left.value * right.value };
700
+ case "/":
701
+ return { value: left.value / right.value };
702
+ case "%":
703
+ return { value: left.value % right.value };
704
+ case "**":
705
+ return { value: Math.pow(left.value, right.value) };
706
+ case "|":
707
+ return { value: left.value | right.value };
708
+ case "^":
709
+ return { value: left.value ^ right.value };
710
+ case "&":
711
+ return { value: left.value & right.value };
712
+ }
713
+ }
714
+ return null;
715
+ },
716
+ CallExpression(node, initialScope) {
717
+ const calleeNode = node.callee;
718
+ const args = getElementValues(node.arguments, initialScope);
719
+ if (args != null) {
720
+ if (calleeNode.type === "MemberExpression") {
721
+ if (calleeNode.property.type === "PrivateIdentifier") {
722
+ return null;
723
+ }
724
+ const object = getStaticValueR(calleeNode.object, initialScope);
725
+ if (object != null) {
726
+ if (object.value == null && (object.optional || node.optional)) {
727
+ return { value: void 0, optional: true };
728
+ }
729
+ const property = getStaticPropertyNameValue(
730
+ calleeNode,
731
+ initialScope
732
+ );
733
+ if (property != null) {
734
+ const receiver = object.value;
735
+ const methodName = property.value;
736
+ if (callAllowed.has(receiver[methodName])) {
737
+ return { value: receiver[methodName](...args) };
738
+ }
739
+ if (callPassThrough.has(receiver[methodName])) {
740
+ return { value: args[0] };
741
+ }
742
+ }
743
+ }
744
+ } else {
745
+ const callee = getStaticValueR(calleeNode, initialScope);
746
+ if (callee != null) {
747
+ if (callee.value == null && node.optional) {
748
+ return { value: void 0, optional: true };
749
+ }
750
+ const func = callee.value;
751
+ if (callAllowed.has(func)) {
752
+ return { value: func(...args) };
753
+ }
754
+ if (callPassThrough.has(func)) {
755
+ return { value: args[0] };
756
+ }
757
+ }
758
+ }
759
+ }
760
+ return null;
761
+ },
762
+ ConditionalExpression(node, initialScope) {
763
+ const test = getStaticValueR(node.test, initialScope);
764
+ if (test != null) {
765
+ return test.value ? getStaticValueR(node.consequent, initialScope) : getStaticValueR(node.alternate, initialScope);
766
+ }
767
+ return null;
768
+ },
769
+ ExpressionStatement(node, initialScope) {
770
+ return getStaticValueR(node.expression, initialScope);
771
+ },
772
+ Identifier(node, initialScope) {
773
+ if (initialScope != null) {
774
+ const variable = findVariable(initialScope, node);
775
+ if (variable != null && variable.defs.length === 0 && builtinNames.has(variable.name) && variable.name in globalObject) {
776
+ return { value: globalObject[variable.name] };
777
+ }
778
+ if (variable != null && variable.defs.length === 1) {
779
+ const def = variable.defs[0];
780
+ if (def.parent && def.parent.kind === "const" && // TODO(mysticatea): don't support destructuring here.
781
+ def.node.id.type === "Identifier") {
782
+ return getStaticValueR(def.node.init, initialScope);
783
+ }
784
+ }
785
+ }
786
+ return null;
787
+ },
788
+ Literal(node) {
789
+ if ((node.regex != null || node.bigint != null) && node.value == null) {
790
+ return null;
791
+ }
792
+ return { value: node.value };
793
+ },
794
+ LogicalExpression(node, initialScope) {
795
+ const left = getStaticValueR(node.left, initialScope);
796
+ if (left != null) {
797
+ if (node.operator === "||" && Boolean(left.value) === true || node.operator === "&&" && Boolean(left.value) === false || node.operator === "??" && left.value != null) {
798
+ return left;
799
+ }
800
+ const right = getStaticValueR(node.right, initialScope);
801
+ if (right != null) {
802
+ return right;
803
+ }
804
+ }
805
+ return null;
806
+ },
807
+ MemberExpression(node, initialScope) {
808
+ if (node.property.type === "PrivateIdentifier") {
809
+ return null;
810
+ }
811
+ const object = getStaticValueR(node.object, initialScope);
812
+ if (object != null) {
813
+ if (object.value == null && (object.optional || node.optional)) {
814
+ return { value: void 0, optional: true };
815
+ }
816
+ const property = getStaticPropertyNameValue(node, initialScope);
817
+ if (property != null && !isGetter(object.value, property.value)) {
818
+ return { value: object.value[property.value] };
819
+ }
820
+ }
821
+ return null;
822
+ },
823
+ ChainExpression(node, initialScope) {
824
+ const expression = getStaticValueR(node.expression, initialScope);
825
+ if (expression != null) {
826
+ return { value: expression.value };
827
+ }
828
+ return null;
829
+ },
830
+ NewExpression(node, initialScope) {
831
+ const callee = getStaticValueR(node.callee, initialScope);
832
+ const args = getElementValues(node.arguments, initialScope);
833
+ if (callee != null && args != null) {
834
+ const Func = callee.value;
835
+ if (callAllowed.has(Func)) {
836
+ return { value: new Func(...args) };
837
+ }
838
+ }
839
+ return null;
840
+ },
841
+ ObjectExpression(node, initialScope) {
842
+ const object = {};
843
+ for (const propertyNode of node.properties) {
844
+ if (propertyNode.type === "Property") {
845
+ if (propertyNode.kind !== "init") {
846
+ return null;
847
+ }
848
+ const key = getStaticPropertyNameValue(
849
+ propertyNode,
850
+ initialScope
851
+ );
852
+ const value = getStaticValueR(propertyNode.value, initialScope);
853
+ if (key == null || value == null) {
854
+ return null;
855
+ }
856
+ object[key.value] = value.value;
857
+ } else if (propertyNode.type === "SpreadElement" || propertyNode.type === "ExperimentalSpreadProperty") {
858
+ const argument = getStaticValueR(
859
+ propertyNode.argument,
860
+ initialScope
861
+ );
862
+ if (argument == null) {
863
+ return null;
864
+ }
865
+ Object.assign(object, argument.value);
866
+ } else {
867
+ return null;
868
+ }
869
+ }
870
+ return { value: object };
871
+ },
872
+ SequenceExpression(node, initialScope) {
873
+ const last = node.expressions[node.expressions.length - 1];
874
+ return getStaticValueR(last, initialScope);
875
+ },
876
+ TaggedTemplateExpression(node, initialScope) {
877
+ const tag = getStaticValueR(node.tag, initialScope);
878
+ const expressions = getElementValues(
879
+ node.quasi.expressions,
880
+ initialScope
881
+ );
882
+ if (tag != null && expressions != null) {
883
+ const func = tag.value;
884
+ const strings = node.quasi.quasis.map((q) => q.value.cooked);
885
+ strings.raw = node.quasi.quasis.map((q) => q.value.raw);
886
+ if (func === String.raw) {
887
+ return { value: func(strings, ...expressions) };
888
+ }
889
+ }
890
+ return null;
891
+ },
892
+ TemplateLiteral(node, initialScope) {
893
+ const expressions = getElementValues(node.expressions, initialScope);
894
+ if (expressions != null) {
895
+ let value = node.quasis[0].value.cooked;
896
+ for (let i = 0; i < expressions.length; ++i) {
897
+ value += expressions[i];
898
+ value += node.quasis[i + 1].value.cooked;
899
+ }
900
+ return { value };
901
+ }
902
+ return null;
903
+ },
904
+ UnaryExpression(node, initialScope) {
905
+ if (node.operator === "delete") {
906
+ return null;
907
+ }
908
+ if (node.operator === "void") {
909
+ return { value: void 0 };
910
+ }
911
+ const arg = getStaticValueR(node.argument, initialScope);
912
+ if (arg != null) {
913
+ switch (node.operator) {
914
+ case "-":
915
+ return { value: -arg.value };
916
+ case "+":
917
+ return { value: +arg.value };
918
+ //eslint-disable-line no-implicit-coercion
919
+ case "!":
920
+ return { value: !arg.value };
921
+ case "~":
922
+ return { value: ~arg.value };
923
+ case "typeof":
924
+ return { value: typeof arg.value };
925
+ }
926
+ }
927
+ return null;
928
+ }
929
+ });
930
+ function getStaticValueR(node, initialScope) {
931
+ if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
932
+ return operations[node.type](node, initialScope);
933
+ }
934
+ return null;
935
+ }
936
+ function getStaticPropertyNameValue(node, initialScope) {
937
+ const nameNode = node.type === "Property" ? node.key : node.property;
938
+ if (node.computed) {
939
+ return getStaticValueR(nameNode, initialScope);
940
+ }
941
+ if (nameNode.type === "Identifier") {
942
+ return { value: nameNode.name };
943
+ }
944
+ if (nameNode.type === "Literal") {
945
+ if (nameNode.bigint) {
946
+ return { value: nameNode.bigint };
947
+ }
948
+ return { value: String(nameNode.value) };
949
+ }
950
+ return null;
951
+ }
952
+ function getStaticValue(node, initialScope = null) {
953
+ try {
954
+ return getStaticValueR(node, initialScope);
955
+ } catch (_error) {
956
+ return null;
957
+ }
958
+ }
959
+ function getStringIfConstant(node, initialScope = null) {
960
+ if (node && node.type === "Literal" && node.value === null) {
961
+ if (node.regex) {
962
+ return `/${node.regex.pattern}/${node.regex.flags}`;
963
+ }
964
+ if (node.bigint) {
965
+ return node.bigint;
966
+ }
967
+ }
968
+ const evaluated = getStaticValue(node, initialScope);
969
+ return evaluated && String(evaluated.value);
970
+ }
971
+ function getPropertyName(node, initialScope) {
972
+ switch (node.type) {
973
+ case "MemberExpression":
974
+ if (node.computed) {
975
+ return getStringIfConstant(node.property, initialScope);
976
+ }
977
+ if (node.property.type === "PrivateIdentifier") {
978
+ return null;
979
+ }
980
+ return node.property.name;
981
+ case "Property":
982
+ case "MethodDefinition":
983
+ case "PropertyDefinition":
984
+ if (node.computed) {
985
+ return getStringIfConstant(node.key, initialScope);
986
+ }
987
+ if (node.key.type === "Literal") {
988
+ return String(node.key.value);
989
+ }
990
+ if (node.key.type === "PrivateIdentifier") {
991
+ return null;
992
+ }
993
+ return node.key.name;
994
+ }
995
+ return null;
996
+ }
997
+ var typeConversionBinaryOps = Object.freeze(
998
+ /* @__PURE__ */ new Set([
999
+ "==",
1000
+ "!=",
1001
+ "<",
1002
+ "<=",
1003
+ ">",
1004
+ ">=",
1005
+ "<<",
1006
+ ">>",
1007
+ ">>>",
1008
+ "+",
1009
+ "-",
1010
+ "*",
1011
+ "/",
1012
+ "%",
1013
+ "|",
1014
+ "^",
1015
+ "&",
1016
+ "in"
1017
+ ])
1018
+ );
1019
+ var typeConversionUnaryOps = Object.freeze(/* @__PURE__ */ new Set(["-", "+", "!", "~"]));
1020
+ function isNode(x) {
1021
+ return x !== null && typeof x === "object" && typeof x.type === "string";
1022
+ }
1023
+ var visitor = Object.freeze(
1024
+ Object.assign(/* @__PURE__ */ Object.create(null), {
1025
+ $visit(node, options, visitorKeys) {
1026
+ const { type } = node;
1027
+ if (typeof this[type] === "function") {
1028
+ return this[type](node, options, visitorKeys);
1029
+ }
1030
+ return this.$visitChildren(node, options, visitorKeys);
1031
+ },
1032
+ $visitChildren(node, options, visitorKeys) {
1033
+ const { type } = node;
1034
+ for (const key of visitorKeys[type] || import_eslint_visitor_keys.default.getKeys(node)) {
1035
+ const value = node[key];
1036
+ if (Array.isArray(value)) {
1037
+ for (const element of value) {
1038
+ if (isNode(element) && this.$visit(element, options, visitorKeys)) {
1039
+ return true;
1040
+ }
1041
+ }
1042
+ } else if (isNode(value) && this.$visit(value, options, visitorKeys)) {
1043
+ return true;
1044
+ }
1045
+ }
1046
+ return false;
1047
+ },
1048
+ ArrowFunctionExpression() {
1049
+ return false;
1050
+ },
1051
+ AssignmentExpression() {
1052
+ return true;
1053
+ },
1054
+ AwaitExpression() {
1055
+ return true;
1056
+ },
1057
+ BinaryExpression(node, options, visitorKeys) {
1058
+ if (options.considerImplicitTypeConversion && typeConversionBinaryOps.has(node.operator) && (node.left.type !== "Literal" || node.right.type !== "Literal")) {
1059
+ return true;
1060
+ }
1061
+ return this.$visitChildren(node, options, visitorKeys);
1062
+ },
1063
+ CallExpression() {
1064
+ return true;
1065
+ },
1066
+ FunctionExpression() {
1067
+ return false;
1068
+ },
1069
+ ImportExpression() {
1070
+ return true;
1071
+ },
1072
+ MemberExpression(node, options, visitorKeys) {
1073
+ if (options.considerGetters) {
1074
+ return true;
1075
+ }
1076
+ if (options.considerImplicitTypeConversion && node.computed && node.property.type !== "Literal") {
1077
+ return true;
1078
+ }
1079
+ return this.$visitChildren(node, options, visitorKeys);
1080
+ },
1081
+ MethodDefinition(node, options, visitorKeys) {
1082
+ if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
1083
+ return true;
1084
+ }
1085
+ return this.$visitChildren(node, options, visitorKeys);
1086
+ },
1087
+ NewExpression() {
1088
+ return true;
1089
+ },
1090
+ Property(node, options, visitorKeys) {
1091
+ if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
1092
+ return true;
1093
+ }
1094
+ return this.$visitChildren(node, options, visitorKeys);
1095
+ },
1096
+ PropertyDefinition(node, options, visitorKeys) {
1097
+ if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
1098
+ return true;
1099
+ }
1100
+ return this.$visitChildren(node, options, visitorKeys);
1101
+ },
1102
+ UnaryExpression(node, options, visitorKeys) {
1103
+ if (node.operator === "delete") {
1104
+ return true;
1105
+ }
1106
+ if (options.considerImplicitTypeConversion && typeConversionUnaryOps.has(node.operator) && node.argument.type !== "Literal") {
1107
+ return true;
1108
+ }
1109
+ return this.$visitChildren(node, options, visitorKeys);
1110
+ },
1111
+ UpdateExpression() {
1112
+ return true;
1113
+ },
1114
+ YieldExpression() {
1115
+ return true;
1116
+ }
1117
+ })
1118
+ );
1119
+ var IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u;
1120
+ var has = Function.call.bind(Object.hasOwnProperty);
1121
+ var READ = Symbol("read");
1122
+ var CALL = Symbol("call");
1123
+ var CONSTRUCT = Symbol("construct");
1124
+ var ESM = Symbol("esm");
1125
+ var requireCall = { require: { [CALL]: true } };
1126
+ function isModifiedGlobal(variable) {
1127
+ return variable == null || variable.defs.length !== 0 || variable.references.some((r) => r.isWrite());
1128
+ }
1129
+ function isPassThrough(node) {
1130
+ const parent = node.parent;
1131
+ switch (parent && parent.type) {
1132
+ case "ConditionalExpression":
1133
+ return parent.consequent === node || parent.alternate === node;
1134
+ case "LogicalExpression":
1135
+ return true;
1136
+ case "SequenceExpression":
1137
+ return parent.expressions[parent.expressions.length - 1] === node;
1138
+ case "ChainExpression":
1139
+ return true;
1140
+ default:
1141
+ return false;
1142
+ }
1143
+ }
1144
+ var ReferenceTracker = class {
1145
+ /**
1146
+ * Initialize this tracker.
1147
+ * @param {Scope} globalScope The global scope.
1148
+ * @param {object} [options] The options.
1149
+ * @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules.
1150
+ * @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object.
1151
+ */
1152
+ constructor(globalScope, {
1153
+ mode = "strict",
1154
+ globalObjectNames = ["global", "globalThis", "self", "window"]
1155
+ } = {}) {
1156
+ this.variableStack = [];
1157
+ this.globalScope = globalScope;
1158
+ this.mode = mode;
1159
+ this.globalObjectNames = globalObjectNames.slice(0);
1160
+ }
1161
+ /**
1162
+ * Iterate the references of global variables.
1163
+ * @param {object} traceMap The trace map.
1164
+ * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1165
+ */
1166
+ *iterateGlobalReferences(traceMap) {
1167
+ for (const key of Object.keys(traceMap)) {
1168
+ const nextTraceMap = traceMap[key];
1169
+ const path = [key];
1170
+ const variable = this.globalScope.set.get(key);
1171
+ if (isModifiedGlobal(variable)) {
1172
+ continue;
1173
+ }
1174
+ yield* this._iterateVariableReferences(
1175
+ variable,
1176
+ path,
1177
+ nextTraceMap,
1178
+ true
1179
+ );
1180
+ }
1181
+ for (const key of this.globalObjectNames) {
1182
+ const path = [];
1183
+ const variable = this.globalScope.set.get(key);
1184
+ if (isModifiedGlobal(variable)) {
1185
+ continue;
1186
+ }
1187
+ yield* this._iterateVariableReferences(
1188
+ variable,
1189
+ path,
1190
+ traceMap,
1191
+ false
1192
+ );
1193
+ }
1194
+ }
1195
+ /**
1196
+ * Iterate the references of CommonJS modules.
1197
+ * @param {object} traceMap The trace map.
1198
+ * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1199
+ */
1200
+ *iterateCjsReferences(traceMap) {
1201
+ for (const { node } of this.iterateGlobalReferences(requireCall)) {
1202
+ const key = getStringIfConstant(node.arguments[0]);
1203
+ if (key == null || !has(traceMap, key)) {
1204
+ continue;
1205
+ }
1206
+ const nextTraceMap = traceMap[key];
1207
+ const path = [key];
1208
+ if (nextTraceMap[READ]) {
1209
+ yield {
1210
+ node,
1211
+ path,
1212
+ type: READ,
1213
+ info: nextTraceMap[READ]
1214
+ };
1215
+ }
1216
+ yield* this._iteratePropertyReferences(node, path, nextTraceMap);
1217
+ }
1218
+ }
1219
+ /**
1220
+ * Iterate the references of ES modules.
1221
+ * @param {object} traceMap The trace map.
1222
+ * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1223
+ */
1224
+ *iterateEsmReferences(traceMap) {
1225
+ const programNode = this.globalScope.block;
1226
+ for (const node of programNode.body) {
1227
+ if (!IMPORT_TYPE.test(node.type) || node.source == null) {
1228
+ continue;
1229
+ }
1230
+ const moduleId = node.source.value;
1231
+ if (!has(traceMap, moduleId)) {
1232
+ continue;
1233
+ }
1234
+ const nextTraceMap = traceMap[moduleId];
1235
+ const path = [moduleId];
1236
+ if (nextTraceMap[READ]) {
1237
+ yield { node, path, type: READ, info: nextTraceMap[READ] };
1238
+ }
1239
+ if (node.type === "ExportAllDeclaration") {
1240
+ for (const key of Object.keys(nextTraceMap)) {
1241
+ const exportTraceMap = nextTraceMap[key];
1242
+ if (exportTraceMap[READ]) {
1243
+ yield {
1244
+ node,
1245
+ path: path.concat(key),
1246
+ type: READ,
1247
+ info: exportTraceMap[READ]
1248
+ };
1249
+ }
1250
+ }
1251
+ } else {
1252
+ for (const specifier of node.specifiers) {
1253
+ const esm = has(nextTraceMap, ESM);
1254
+ const it = this._iterateImportReferences(
1255
+ specifier,
1256
+ path,
1257
+ esm ? nextTraceMap : this.mode === "legacy" ? { default: nextTraceMap, ...nextTraceMap } : { default: nextTraceMap }
1258
+ );
1259
+ if (esm) {
1260
+ yield* it;
1261
+ } else {
1262
+ for (const report of it) {
1263
+ report.path = report.path.filter(exceptDefault);
1264
+ if (report.path.length >= 2 || report.type !== READ) {
1265
+ yield report;
1266
+ }
1267
+ }
1268
+ }
1269
+ }
1270
+ }
1271
+ }
1272
+ }
1273
+ /**
1274
+ * Iterate the references for a given variable.
1275
+ * @param {Variable} variable The variable to iterate that references.
1276
+ * @param {string[]} path The current path.
1277
+ * @param {object} traceMap The trace map.
1278
+ * @param {boolean} shouldReport = The flag to report those references.
1279
+ * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1280
+ */
1281
+ *_iterateVariableReferences(variable, path, traceMap, shouldReport) {
1282
+ if (this.variableStack.includes(variable)) {
1283
+ return;
1284
+ }
1285
+ this.variableStack.push(variable);
1286
+ try {
1287
+ for (const reference of variable.references) {
1288
+ if (!reference.isRead()) {
1289
+ continue;
1290
+ }
1291
+ const node = reference.identifier;
1292
+ if (shouldReport && traceMap[READ]) {
1293
+ yield { node, path, type: READ, info: traceMap[READ] };
1294
+ }
1295
+ yield* this._iteratePropertyReferences(node, path, traceMap);
1296
+ }
1297
+ } finally {
1298
+ this.variableStack.pop();
1299
+ }
1300
+ }
1301
+ /**
1302
+ * Iterate the references for a given AST node.
1303
+ * @param rootNode The AST node to iterate references.
1304
+ * @param {string[]} path The current path.
1305
+ * @param {object} traceMap The trace map.
1306
+ * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1307
+ */
1308
+ //eslint-disable-next-line complexity
1309
+ *_iteratePropertyReferences(rootNode, path, traceMap) {
1310
+ let node = rootNode;
1311
+ while (isPassThrough(node)) {
1312
+ node = node.parent;
1313
+ }
1314
+ const parent = node.parent;
1315
+ if (parent.type === "MemberExpression") {
1316
+ if (parent.object === node) {
1317
+ const key = getPropertyName(parent);
1318
+ if (key == null || !has(traceMap, key)) {
1319
+ return;
1320
+ }
1321
+ path = path.concat(key);
1322
+ const nextTraceMap = traceMap[key];
1323
+ if (nextTraceMap[READ]) {
1324
+ yield {
1325
+ node: parent,
1326
+ path,
1327
+ type: READ,
1328
+ info: nextTraceMap[READ]
1329
+ };
1330
+ }
1331
+ yield* this._iteratePropertyReferences(
1332
+ parent,
1333
+ path,
1334
+ nextTraceMap
1335
+ );
1336
+ }
1337
+ return;
1338
+ }
1339
+ if (parent.type === "CallExpression") {
1340
+ if (parent.callee === node && traceMap[CALL]) {
1341
+ yield { node: parent, path, type: CALL, info: traceMap[CALL] };
1342
+ }
1343
+ return;
1344
+ }
1345
+ if (parent.type === "NewExpression") {
1346
+ if (parent.callee === node && traceMap[CONSTRUCT]) {
1347
+ yield {
1348
+ node: parent,
1349
+ path,
1350
+ type: CONSTRUCT,
1351
+ info: traceMap[CONSTRUCT]
1352
+ };
1353
+ }
1354
+ return;
1355
+ }
1356
+ if (parent.type === "AssignmentExpression") {
1357
+ if (parent.right === node) {
1358
+ yield* this._iterateLhsReferences(parent.left, path, traceMap);
1359
+ yield* this._iteratePropertyReferences(parent, path, traceMap);
1360
+ }
1361
+ return;
1362
+ }
1363
+ if (parent.type === "AssignmentPattern") {
1364
+ if (parent.right === node) {
1365
+ yield* this._iterateLhsReferences(parent.left, path, traceMap);
1366
+ }
1367
+ return;
1368
+ }
1369
+ if (parent.type === "VariableDeclarator") {
1370
+ if (parent.init === node) {
1371
+ yield* this._iterateLhsReferences(parent.id, path, traceMap);
1372
+ }
1373
+ }
1374
+ }
1375
+ /**
1376
+ * Iterate the references for a given Pattern node.
1377
+ * @param {Node} patternNode The Pattern node to iterate references.
1378
+ * @param {string[]} path The current path.
1379
+ * @param {object} traceMap The trace map.
1380
+ * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1381
+ */
1382
+ *_iterateLhsReferences(patternNode, path, traceMap) {
1383
+ if (patternNode.type === "Identifier") {
1384
+ const variable = findVariable(this.globalScope, patternNode);
1385
+ if (variable != null) {
1386
+ yield* this._iterateVariableReferences(
1387
+ variable,
1388
+ path,
1389
+ traceMap,
1390
+ false
1391
+ );
1392
+ }
1393
+ return;
1394
+ }
1395
+ if (patternNode.type === "ObjectPattern") {
1396
+ for (const property of patternNode.properties) {
1397
+ const key = getPropertyName(property);
1398
+ if (key == null || !has(traceMap, key)) {
1399
+ continue;
1400
+ }
1401
+ const nextPath = path.concat(key);
1402
+ const nextTraceMap = traceMap[key];
1403
+ if (nextTraceMap[READ]) {
1404
+ yield {
1405
+ node: property,
1406
+ path: nextPath,
1407
+ type: READ,
1408
+ info: nextTraceMap[READ]
1409
+ };
1410
+ }
1411
+ yield* this._iterateLhsReferences(
1412
+ property.value,
1413
+ nextPath,
1414
+ nextTraceMap
1415
+ );
1416
+ }
1417
+ return;
1418
+ }
1419
+ if (patternNode.type === "AssignmentPattern") {
1420
+ yield* this._iterateLhsReferences(patternNode.left, path, traceMap);
1421
+ }
1422
+ }
1423
+ /**
1424
+ * Iterate the references for a given ModuleSpecifier node.
1425
+ * @param {Node} specifierNode The ModuleSpecifier node to iterate references.
1426
+ * @param {string[]} path The current path.
1427
+ * @param {object} traceMap The trace map.
1428
+ * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
1429
+ */
1430
+ *_iterateImportReferences(specifierNode, path, traceMap) {
1431
+ const type = specifierNode.type;
1432
+ if (type === "ImportSpecifier" || type === "ImportDefaultSpecifier") {
1433
+ const key = type === "ImportDefaultSpecifier" ? "default" : specifierNode.imported.name;
1434
+ if (!has(traceMap, key)) {
1435
+ return;
1436
+ }
1437
+ path = path.concat(key);
1438
+ const nextTraceMap = traceMap[key];
1439
+ if (nextTraceMap[READ]) {
1440
+ yield {
1441
+ node: specifierNode,
1442
+ path,
1443
+ type: READ,
1444
+ info: nextTraceMap[READ]
1445
+ };
1446
+ }
1447
+ yield* this._iterateVariableReferences(
1448
+ findVariable(this.globalScope, specifierNode.local),
1449
+ path,
1450
+ nextTraceMap,
1451
+ false
1452
+ );
1453
+ return;
1454
+ }
1455
+ if (type === "ImportNamespaceSpecifier") {
1456
+ yield* this._iterateVariableReferences(
1457
+ findVariable(this.globalScope, specifierNode.local),
1458
+ path,
1459
+ traceMap,
1460
+ false
1461
+ );
1462
+ return;
1463
+ }
1464
+ if (type === "ExportSpecifier") {
1465
+ const key = specifierNode.local.name;
1466
+ if (!has(traceMap, key)) {
1467
+ return;
1468
+ }
1469
+ path = path.concat(key);
1470
+ const nextTraceMap = traceMap[key];
1471
+ if (nextTraceMap[READ]) {
1472
+ yield {
1473
+ node: specifierNode,
1474
+ path,
1475
+ type: READ,
1476
+ info: nextTraceMap[READ]
1477
+ };
1478
+ }
1479
+ }
1480
+ }
1481
+ };
1482
+ ReferenceTracker.READ = READ;
1483
+ ReferenceTracker.CALL = CALL;
1484
+ ReferenceTracker.CONSTRUCT = CONSTRUCT;
1485
+ ReferenceTracker.ESM = ESM;
1486
+ function exceptDefault(name8, index) {
1487
+ return !(index === 1 && name8 === "default");
1488
+ }
1489
+
1490
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/util/ast.js
1491
+ var traverse = (context, node, visit, visited = /* @__PURE__ */ new Set()) => {
1492
+ if (visited.has(node)) {
1493
+ return;
1494
+ }
1495
+ visited.add(node);
1496
+ visit(node);
1497
+ (context.sourceCode.visitorKeys[node.type] || []).map((key) => node[key]).filter(Boolean).flatMap((child) => Array.isArray(child) ? child : [child]).filter(Boolean).filter((child) => typeof child.type === "string").forEach((child) => traverse(context, child, visit, visited));
1498
+ };
1499
+ var findDownstreamNodes = (context, topNode, type) => {
1500
+ const nodes = [];
1501
+ traverse(context, topNode, (node) => {
1502
+ if (node.type === type) {
1503
+ nodes.push(node);
1504
+ }
1505
+ });
1506
+ return nodes;
1507
+ };
1508
+ var getUpstreamVariables = (context, node, filter, visited = /* @__PURE__ */ new Set()) => {
1509
+ if (visited.has(node)) {
1510
+ return [];
1511
+ }
1512
+ visited.add(node);
1513
+ const variable = findVariable(context.sourceCode.getScope(node), node);
1514
+ if (!variable) {
1515
+ return [];
1516
+ }
1517
+ const upstreamVariables = variable.defs.filter((def) => !!def.node.init).filter((def) => filter(def.node)).flatMap((def) => findDownstreamNodes(context, def.node.init, "Identifier")).flatMap(
1518
+ (identifier) => getUpstreamVariables(context, identifier, filter, visited)
1519
+ );
1520
+ return upstreamVariables.length === 0 ? [variable] : upstreamVariables;
1521
+ };
1522
+ var getDownstreamRefs = (context, node) => findDownstreamNodes(context, node, "Identifier").map((identifier) => getRef(context, identifier)).filter(Boolean);
1523
+ var getRef = (context, identifier) => findVariable(
1524
+ context.sourceCode.getScope(identifier),
1525
+ identifier
1526
+ )?.references.find((ref) => ref.identifier === identifier);
1527
+ var getCallExpr = (ref, current = ref.identifier.parent) => {
1528
+ if (current.type === "CallExpression") {
1529
+ let node = ref.identifier;
1530
+ while (node.parent.type === "MemberExpression") {
1531
+ node = node.parent;
1532
+ }
1533
+ if (current.callee === node) {
1534
+ return current;
1535
+ }
1536
+ }
1537
+ if (current.type === "MemberExpression") {
1538
+ return getCallExpr(ref, current.parent);
1539
+ }
1540
+ return void 0;
1541
+ };
1542
+ var isIIFE = (node) => node.type === "CallExpression" && (node.callee.type === "ArrowFunctionExpression" || node.callee.type === "FunctionExpression");
1543
+
1544
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/util/react.js
1545
+ var isReactFunctionalComponent = (node) => (node.type === "FunctionDeclaration" || node.type === "VariableDeclarator" && (node.init.type === "ArrowFunctionExpression" || node.init.type === "CallExpression")) && node.id.type === "Identifier" && node.id.name[0].toUpperCase() === node.id.name[0];
1546
+ var isReactFunctionalHOC = (node) => node.type === "VariableDeclarator" && node.init && node.init.type === "CallExpression" && node.init.callee.type === "Identifier" && !["memo", "forwardRef"].includes(node.init.callee.name) && node.init.arguments.length > 0 && (node.init.arguments[0].type === "ArrowFunctionExpression" || node.init.arguments[0].type === "FunctionExpression") && node.id.type === "Identifier" && node.id.name[0].toUpperCase() === node.id.name[0];
1547
+ var isCustomHook = (node) => (node.type === "FunctionDeclaration" || node.type === "VariableDeclarator" && node.init && (node.init.type === "ArrowFunctionExpression" || node.init.type === "FunctionExpression")) && node.id.type === "Identifier" && node.id.name.startsWith("use") && node.id.name[3] === node.id.name[3].toUpperCase();
1548
+ var isUseState = (node) => node.type === "VariableDeclarator" && node.init && node.init.type === "CallExpression" && node.init.callee.name === "useState" && node.id.type === "ArrayPattern" && // Not sure its usecase, but may just have the setter
1549
+ (node.id.elements.length === 1 || node.id.elements.length === 2) && node.id.elements.every((el) => {
1550
+ return !el || el.type === "Identifier";
1551
+ });
1552
+ var isUseEffect = (node) => node.type === "CallExpression" && (node.callee.type === "Identifier" && (node.callee.name === "useEffect" || node.callee.name === "useLayoutEffect") || node.callee.type === "MemberExpression" && node.callee.object.name === "React" && (node.callee.property.name === "useEffect" || node.callee.property.name === "useLayoutEffect"));
1553
+ var getEffectFn = (node) => {
1554
+ if (!isUseEffect(node) || node.arguments.length < 1) {
1555
+ return void 0;
1556
+ }
1557
+ const effectFn = node.arguments[0];
1558
+ if (effectFn.type !== "ArrowFunctionExpression" && effectFn.type !== "FunctionExpression") {
1559
+ return void 0;
1560
+ }
1561
+ return effectFn;
1562
+ };
1563
+ var getEffectFnRefs = (context, node) => {
1564
+ const effectFn = getEffectFn(node);
1565
+ if (!effectFn) {
1566
+ return null;
1567
+ }
1568
+ return getDownstreamRefs(context, effectFn);
1569
+ };
1570
+ function getDependenciesRefs(context, node) {
1571
+ if (!isUseEffect(node) || node.arguments.length < 2) {
1572
+ return void 0;
1573
+ }
1574
+ const depsArr = node.arguments[1];
1575
+ if (depsArr.type !== "ArrayExpression") {
1576
+ return void 0;
1577
+ }
1578
+ return getDownstreamRefs(context, depsArr);
1579
+ }
1580
+ var isFnRef = (ref) => getCallExpr(ref) !== void 0;
1581
+ var isStateSetter = (context, ref) => isFnRef(ref) && getUpstreamReactVariables(context, ref.identifier).notEmptyEvery(
1582
+ (variable) => isState(variable)
1583
+ );
1584
+ var isPropCallback = (context, ref) => isFnRef(ref) && getUpstreamReactVariables(context, ref.identifier).notEmptyEvery(
1585
+ (variable) => isProp(variable)
1586
+ );
1587
+ var isState = (variable) => variable.defs.some((def) => isUseState(def.node));
1588
+ var isProp = (variable) => variable.defs.some(
1589
+ (def) => def.type === "Parameter" && (isReactFunctionalComponent(getDeclNode(def.node)) || isCustomHook(getDeclNode(def.node)))
1590
+ );
1591
+ var isHOCProp = (variable) => variable.defs.some(
1592
+ (def) => def.type === "Parameter" && isReactFunctionalHOC(getDeclNode(def.node))
1593
+ );
1594
+ var getDeclNode = (node) => node.type === "ArrowFunctionExpression" ? node.parent.type === "CallExpression" ? node.parent.parent : node.parent : node;
1595
+ var getUseStateNode = (context, ref) => {
1596
+ return getUpstreamReactVariables(context, ref.identifier).find((variable) => isState(variable))?.defs.find((def) => isUseState(def.node))?.node;
1597
+ };
1598
+ var isDirectCall = (node) => {
1599
+ if (!node) {
1600
+ return false;
1601
+ } else if ((node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression") && !isIIFE(node.parent)) {
1602
+ return isUseEffect(node.parent);
1603
+ } else {
1604
+ return isDirectCall(node.parent);
1605
+ }
1606
+ };
1607
+ var findPropUsedToResetAllState = (context, effectFnRefs, depsRefs, useEffectNode) => {
1608
+ const stateSetterRefs = effectFnRefs.filter(
1609
+ (ref) => isStateSetter(context, ref)
1610
+ );
1611
+ const isAllStateReset = stateSetterRefs.length > 0 && stateSetterRefs.every((ref) => isSetStateToInitialValue(context, ref)) && stateSetterRefs.length === countUseStates(context, findContainingNode(useEffectNode));
1612
+ return isAllStateReset ? depsRefs.find((ref) => isProp(ref.resolved)) : void 0;
1613
+ };
1614
+ var isSetStateToInitialValue = (context, setterRef) => {
1615
+ const setStateToValue = getCallExpr(setterRef).arguments[0];
1616
+ const stateInitialValue = getUseStateNode(context, setterRef).init.arguments[0];
1617
+ const isUndefined = (node) => node === void 0 || node.name === "undefined";
1618
+ if (isUndefined(setStateToValue) && isUndefined(stateInitialValue)) {
1619
+ return true;
1620
+ }
1621
+ if (setStateToValue === null && stateInitialValue === null) {
1622
+ return true;
1623
+ } else if (setStateToValue && !stateInitialValue || !setStateToValue && stateInitialValue) {
1624
+ return false;
1625
+ }
1626
+ return context.sourceCode.getText(setStateToValue) === context.sourceCode.getText(stateInitialValue);
1627
+ };
1628
+ var countUseStates = (context, componentNode) => {
1629
+ let count = 0;
1630
+ traverse(context, componentNode, (node) => {
1631
+ if (isUseState(node)) {
1632
+ count++;
1633
+ }
1634
+ });
1635
+ return count;
1636
+ };
1637
+ var findContainingNode = (node) => {
1638
+ if (!node) {
1639
+ return void 0;
1640
+ } else if (isReactFunctionalComponent(node) || isReactFunctionalHOC(node) || isCustomHook(node)) {
1641
+ return node;
1642
+ } else {
1643
+ return findContainingNode(node.parent);
1644
+ }
1645
+ };
1646
+ var getUpstreamReactVariables = (context, node) => getUpstreamVariables(
1647
+ context,
1648
+ node,
1649
+ // Stop at the *usage* of `useState` - don't go up to the `useState` variable.
1650
+ // Not needed for props - they don't go "too far".
1651
+ // We could remove this and check for the `useState` variable instead,
1652
+ // but then all our tests need to import it so we can traverse up to it.
1653
+ // And would need to change `getUseStateNode()` too?
1654
+ // TODO: Could probably organize these filters better.
1655
+ (node2) => !isUseState(node2)
1656
+ ).filter(
1657
+ (variable) => isProp(variable) || variable.defs.every((def) => def.type !== "Parameter")
1658
+ );
1659
+
1660
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-empty-effect.js
1661
+ var name = "no-empty-effect";
1662
+ var messages = {
1663
+ avoidEmptyEffect: "avoidEmptyEffect"
1664
+ };
1665
+ var rule = {
1666
+ meta: {
1667
+ type: "suggestion",
1668
+ docs: {
1669
+ description: "Disallow empty React effects."
1670
+ },
1671
+ schema: [],
1672
+ messages: {
1673
+ [messages.avoidEmptyEffect]: "This effect is empty and could be removed."
1674
+ }
1675
+ },
1676
+ create: (context) => ({
1677
+ CallExpression: (node) => {
1678
+ if (!isUseEffect(node)) return;
1679
+ const effectFnRefs = getEffectFnRefs(context, node);
1680
+ if (effectFnRefs?.length === 0) {
1681
+ context.report({
1682
+ node,
1683
+ messageId: messages.avoidEmptyEffect
1684
+ });
1685
+ }
1686
+ }
1687
+ })
1688
+ };
1689
+
1690
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-reset-all-state-when-a-prop-changes.js
1691
+ init_esm_shims();
1692
+ var name2 = "no-reset-all-state-when-a-prop-changes";
1693
+ var messages2 = {
1694
+ avoidResettingAllStateWhenAPropChanges: "avoidResettingAllStateWhenAPropChanges"
1695
+ };
1696
+ var rule2 = {
1697
+ meta: {
1698
+ type: "suggestion",
1699
+ docs: {
1700
+ description: "Disallow resetting all state in an effect when a prop changes.",
1701
+ url: "https://react.dev/learn/you-might-not-need-an-effect#resetting-all-state-when-a-prop-changes"
1702
+ },
1703
+ schema: [],
1704
+ messages: {
1705
+ [messages2.avoidResettingAllStateWhenAPropChanges]: 'Avoid resetting all state when a prop changes. If "{{prop}}" is a key, pass it as `key` instead so React will reset the component.'
1706
+ }
1707
+ },
1708
+ create: (context) => ({
1709
+ CallExpression: (node) => {
1710
+ if (!isUseEffect(node)) return;
1711
+ const effectFnRefs = getEffectFnRefs(context, node);
1712
+ const depsRefs = getDependenciesRefs(context, node);
1713
+ if (!effectFnRefs || !depsRefs) return;
1714
+ const propUsedToResetAllState = findPropUsedToResetAllState(
1715
+ context,
1716
+ effectFnRefs,
1717
+ depsRefs,
1718
+ node
1719
+ );
1720
+ if (propUsedToResetAllState) {
1721
+ context.report({
1722
+ node,
1723
+ messageId: messages2.avoidResettingAllStateWhenAPropChanges,
1724
+ data: { prop: propUsedToResetAllState.identifier.name }
1725
+ });
1726
+ }
1727
+ }
1728
+ })
1729
+ };
1730
+
1731
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-event-handler.js
1732
+ init_esm_shims();
1733
+ var name3 = "no-event-handler";
1734
+ var messages3 = {
1735
+ avoidEventHandler: "avoidEventHandler"
1736
+ };
1737
+ var rule3 = {
1738
+ meta: {
1739
+ type: "suggestion",
1740
+ docs: {
1741
+ description: "Disallow using state and an effect as an event handler.",
1742
+ url: "https://react.dev/learn/you-might-not-need-an-effect#sharing-logic-between-event-handlers"
1743
+ },
1744
+ schema: [],
1745
+ messages: {
1746
+ [messages3.avoidEventHandler]: "Avoid using state and effects as an event handler. Instead, call the event handling code directly when the event occurs."
1747
+ }
1748
+ },
1749
+ create: (context) => ({
1750
+ CallExpression: (node) => {
1751
+ if (!isUseEffect(node)) return;
1752
+ const effectFnRefs = getEffectFnRefs(context, node);
1753
+ const depsRefs = getDependenciesRefs(context, node);
1754
+ if (!effectFnRefs || !depsRefs) return;
1755
+ findDownstreamNodes(context, node, "IfStatement").filter((ifNode) => !ifNode.alternate).filter(
1756
+ (ifNode) => getDownstreamRefs(context, ifNode.test).flatMap(
1757
+ (ref) => getUpstreamReactVariables(context, ref.identifier)
1758
+ ).notEmptyEvery((variable) => isState(variable))
1759
+ ).forEach((ifNode) => {
1760
+ context.report({
1761
+ node: ifNode.test,
1762
+ messageId: messages3.avoidEventHandler
1763
+ });
1764
+ });
1765
+ }
1766
+ })
1767
+ };
1768
+
1769
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-parent-child-coupling.js
1770
+ init_esm_shims();
1771
+ var name4 = "no-parent-child-coupling";
1772
+ var messages4 = {
1773
+ avoidParentChildCoupling: "avoidParentChildCoupling"
1774
+ };
1775
+ var rule4 = {
1776
+ meta: {
1777
+ type: "suggestion",
1778
+ docs: {
1779
+ description: "Disallow coupling parent behavior or state to a child component in an effect.",
1780
+ url: "https://react.dev/learn/you-might-not-need-an-effect#notifying-parent-components-about-state-changes"
1781
+ },
1782
+ schema: [],
1783
+ messages: {
1784
+ [messages4.avoidParentChildCoupling]: "Avoid coupling parent behavior or state to a child component. Instead, lift shared logic or state up to the parent."
1785
+ }
1786
+ },
1787
+ create: (context) => ({
1788
+ CallExpression: (node) => {
1789
+ if (!isUseEffect(node)) return;
1790
+ const effectFnRefs = getEffectFnRefs(context, node);
1791
+ const depsRefs = getDependenciesRefs(context, node);
1792
+ if (!effectFnRefs || !depsRefs) return;
1793
+ effectFnRefs.filter(isFnRef).filter((ref) => isDirectCall(ref.identifier)).forEach((ref) => {
1794
+ if (isPropCallback(context, ref) && !isHOCProp(ref.resolved)) {
1795
+ context.report({
1796
+ node: getCallExpr(ref),
1797
+ messageId: messages4.avoidParentChildCoupling
1798
+ });
1799
+ }
1800
+ });
1801
+ }
1802
+ })
1803
+ };
1804
+
1805
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-initialize-state.js
1806
+ init_esm_shims();
1807
+ var name5 = "no-initialize-state";
1808
+ var messages5 = {
1809
+ avoidInitializingState: "avoidInitializingState"
1810
+ };
1811
+ var rule5 = {
1812
+ meta: {
1813
+ type: "suggestion",
1814
+ docs: {
1815
+ description: "Disallow initializing state in an effect."
1816
+ },
1817
+ schema: [],
1818
+ messages: {
1819
+ [messages5.avoidInitializingState]: 'Avoid initializing state in an effect. Instead, pass "{{state}}"\'s initial value to its `useState`.'
1820
+ }
1821
+ },
1822
+ create: (context) => ({
1823
+ CallExpression: (node) => {
1824
+ if (!isUseEffect(node)) return;
1825
+ const effectFnRefs = getEffectFnRefs(context, node);
1826
+ const depsRefs = getDependenciesRefs(context, node);
1827
+ if (!effectFnRefs || !depsRefs) return;
1828
+ if (depsRefs.length > 0) return;
1829
+ effectFnRefs.filter(isFnRef).filter((ref) => isDirectCall(ref.identifier)).filter((ref) => isStateSetter(context, ref)).forEach((ref) => {
1830
+ const useStateNode = getUseStateNode(context, ref);
1831
+ const stateName = (useStateNode.id.elements[0] ?? useStateNode.id.elements[1])?.name;
1832
+ context.report({
1833
+ node: getCallExpr(ref),
1834
+ messageId: messages5.avoidInitializingState,
1835
+ data: { state: stateName }
1836
+ });
1837
+ });
1838
+ }
1839
+ })
1840
+ };
1841
+
1842
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-chain-state-updates.js
1843
+ init_esm_shims();
1844
+ var name6 = "no-chain-state-updates";
1845
+ var messages6 = {
1846
+ avoidChainingStateUpdates: "avoidChainingStateUpdates"
1847
+ };
1848
+ var rule6 = {
1849
+ meta: {
1850
+ type: "suggestion",
1851
+ docs: {
1852
+ description: "Disallow chaining state changes in an effect.",
1853
+ url: "https://react.dev/learn/you-might-not-need-an-effect#chains-of-computations"
1854
+ },
1855
+ schema: [],
1856
+ messages: {
1857
+ [messages6.avoidChainingStateUpdates]: "Avoid chaining state changes. When possible, update all relevant state simultaneously."
1858
+ }
1859
+ },
1860
+ create: (context) => ({
1861
+ CallExpression: (node) => {
1862
+ if (!isUseEffect(node)) return;
1863
+ const effectFnRefs = getEffectFnRefs(context, node);
1864
+ const depsRefs = getDependenciesRefs(context, node);
1865
+ if (!effectFnRefs || !depsRefs) return;
1866
+ const isAllDepsInternal = depsRefs.flatMap((ref) => getUpstreamReactVariables(context, ref.identifier)).notEmptyEvery(
1867
+ (variable) => isState(variable) || isProp(variable) && !isHOCProp(variable)
1868
+ );
1869
+ effectFnRefs.filter(isFnRef).filter((ref) => isDirectCall(ref.identifier)).filter((ref) => isStateSetter(context, ref)).forEach((ref) => {
1870
+ const callExpr = getCallExpr(ref);
1871
+ const argsRefs = callExpr.arguments.flatMap(
1872
+ (arg) => getDownstreamRefs(context, arg)
1873
+ );
1874
+ const argsUpstreamVariables = argsRefs.flatMap(
1875
+ (ref2) => getUpstreamReactVariables(context, ref2.identifier)
1876
+ );
1877
+ const isAllArgsInternal = argsUpstreamVariables.notEmptyEvery(
1878
+ (variable) => isState(variable) || isProp(variable) && !isHOCProp(variable)
1879
+ );
1880
+ const isSomeArgsExternal = argsUpstreamVariables.some(
1881
+ (variable) => !isState(variable) && !isProp(variable) || isHOCProp(variable)
1882
+ );
1883
+ if (!isAllArgsInternal && !isSomeArgsExternal && isAllDepsInternal) {
1884
+ context.report({
1885
+ node: callExpr,
1886
+ messageId: messages6.avoidChainingStateUpdates
1887
+ });
1888
+ }
1889
+ });
1890
+ }
1891
+ })
1892
+ };
1893
+
1894
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-derived-state.js
1895
+ init_esm_shims();
1896
+
1897
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/util/javascript.js
1898
+ init_esm_shims();
1899
+ Array.prototype.notEmptyEvery = function(predicate) {
1900
+ return this.length > 0 && this.every(predicate);
1901
+ };
1902
+ var arraysEqual = (arr1, arr2) => {
1903
+ if (arr1.length !== arr2.length) {
1904
+ return false;
1905
+ }
1906
+ return arr1.every((element, index) => element === arr2[index]);
1907
+ };
1908
+
1909
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-derived-state.js
1910
+ var name7 = "no-derived-state";
1911
+ var messages7 = {
1912
+ avoidDerivedState: "avoidDerivedState"
1913
+ };
1914
+ var rule7 = {
1915
+ meta: {
1916
+ type: "suggestion",
1917
+ docs: {
1918
+ description: "Disallow storing derived state in an effect.",
1919
+ url: "https://react.dev/learn/you-might-not-need-an-effect#updating-state-based-on-props-or-state"
1920
+ },
1921
+ schema: [],
1922
+ messages: {
1923
+ [messages7.avoidDerivedState]: 'Avoid storing derived state. Compute "{{state}}" directly during render, optionally with `useMemo` if it\'s expensive.'
1924
+ }
1925
+ },
1926
+ create: (context) => ({
1927
+ CallExpression: (node) => {
1928
+ if (!isUseEffect(node)) return;
1929
+ const effectFnRefs = getEffectFnRefs(context, node);
1930
+ const depsRefs = getDependenciesRefs(context, node);
1931
+ if (!effectFnRefs || !depsRefs) return;
1932
+ effectFnRefs.filter(isFnRef).filter((ref) => isDirectCall(ref.identifier)).filter((ref) => isStateSetter(context, ref)).forEach((ref) => {
1933
+ const callExpr = getCallExpr(ref);
1934
+ const useStateNode = getUseStateNode(context, ref);
1935
+ const stateName = (useStateNode.id.elements[0] ?? useStateNode.id.elements[1])?.name;
1936
+ const argsRefs = callExpr.arguments.flatMap(
1937
+ (arg) => getDownstreamRefs(context, arg)
1938
+ );
1939
+ const argsUpstreamVariables = argsRefs.flatMap(
1940
+ (ref2) => getUpstreamReactVariables(context, ref2.identifier)
1941
+ );
1942
+ const isAllArgsInternal = argsUpstreamVariables.notEmptyEvery(
1943
+ (variable) => isState(variable) || isProp(variable) && !isHOCProp(variable)
1944
+ );
1945
+ const isAllArgsInDeps = argsRefs.filter(
1946
+ (ref2) => ref2.resolved.defs.every((def) => def.type !== "Parameter")
1947
+ ).notEmptyEvery(
1948
+ (argRef) => depsRefs.some(
1949
+ (depRef) => arraysEqual(
1950
+ getUpstreamReactVariables(context, argRef.identifier),
1951
+ getUpstreamReactVariables(context, depRef.identifier)
1952
+ )
1953
+ )
1954
+ );
1955
+ const isStateSetterCalledOnce = ref.resolved.references.length - 1 === 1;
1956
+ if (isAllArgsInternal || isAllArgsInDeps && isStateSetterCalledOnce) {
1957
+ context.report({
1958
+ node: callExpr,
1959
+ messageId: messages7.avoidDerivedState,
1960
+ data: { state: stateName }
1961
+ });
1962
+ }
1963
+ });
1964
+ }
1965
+ })
1966
+ };
1967
+
1968
+ // node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/index.js
1969
+ import globals2 from "globals";
1970
+ var plugin = {
1971
+ meta: {
1972
+ name: "react-you-might-not-need-an-effect"
1973
+ },
1974
+ configs: {},
1975
+ rules: {
1976
+ [name]: rule,
1977
+ [name2]: rule2,
1978
+ [name3]: rule3,
1979
+ [name4]: rule4,
1980
+ [name5]: rule5,
1981
+ [name6]: rule6,
1982
+ [name7]: rule7
1983
+ }
1984
+ };
1985
+ var recommendedRules = Object.keys(plugin.rules).reduce((acc, ruleName) => {
1986
+ acc[plugin.meta.name + "/" + ruleName] = "warn";
1987
+ return acc;
1988
+ }, {});
1989
+ var languageOptions = {
1990
+ globals: {
1991
+ // NOTE: Required so we can resolve global references to their upstream global variables
1992
+ ...globals2.browser
1993
+ },
1994
+ parserOptions: {
1995
+ ecmaFeatures: {
1996
+ jsx: true
1997
+ }
1998
+ }
1999
+ };
2000
+ Object.assign(plugin.configs, {
2001
+ // flat config format
2002
+ recommended: {
2003
+ files: ["**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],
2004
+ plugins: {
2005
+ // Object.assign above so we can reference `plugin` here
2006
+ [plugin.meta.name]: plugin
2007
+ },
2008
+ rules: recommendedRules,
2009
+ languageOptions
2010
+ },
2011
+ "legacy-recommended": {
2012
+ plugins: [plugin.meta.name],
2013
+ rules: recommendedRules,
2014
+ ...languageOptions
2015
+ }
2016
+ });
2017
+ var src_default = plugin;
2018
+
2019
+ // src/eslint/configs/react.ts
2020
+ import { isPackageExists } from "local-pkg";
2021
+ var nextJsPackages = ["next"];
2022
+ async function react() {
2023
+ const isUsingNext = nextJsPackages.some((index) => isPackageExists(index));
2024
+ const nextjsConfig = [];
2025
+ if (isUsingNext) {
2026
+ const nextPlugin = await import("@next/eslint-plugin-next").then(
2027
+ (d) => d.default
2028
+ );
2029
+ nextjsConfig.push(
2030
+ {
2031
+ name: "solvro/next/setup",
2032
+ plugins: {
2033
+ "@next/next": nextPlugin
2034
+ },
2035
+ rules: nextPlugin.configs.recommended.rules
2036
+ },
2037
+ {
2038
+ files: [
2039
+ "**/app/**/{page,loading,layout,template,error,not-found,unauthorized,forbidden,default,robots,sitemap}.{js,jsx,ts,tsx}",
2040
+ "**/pages/**/*.{js,jsx,ts,tsx}"
2041
+ ],
2042
+ name: "solvro/next/pages",
2043
+ rules: {
2044
+ "import/no-default-export": "off"
2045
+ }
2046
+ }
2047
+ );
2048
+ }
2049
+ return [
2050
+ {
2051
+ name: "solvro/react/setup",
2052
+ plugins: {
2053
+ react: pluginReact,
2054
+ "react-hooks": pluginReactHooks
2055
+ }
2056
+ },
2057
+ ...nextjsConfig,
2058
+ {
2059
+ files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
2060
+ languageOptions: {
2061
+ parserOptions: {
2062
+ ecmaFeatures: {
2063
+ jsx: true
2064
+ }
2065
+ },
2066
+ sourceType: "module"
2067
+ },
2068
+ settings: {
2069
+ react: {
2070
+ version: "detect"
2071
+ }
2072
+ },
2073
+ name: "solvro/react/rules",
2074
+ rules: {
2075
+ ...pluginReact.configs.flat.recommended.rules,
2076
+ ...pluginReact.configs.flat["jsx-runtime"].rules,
2077
+ "react/no-danger": "warn",
2078
+ "react/jsx-no-leaked-render": "warn",
2079
+ // recommended rules react-hooks
2080
+ "react-hooks/exhaustive-deps": "warn",
2081
+ "react-hooks/rules-of-hooks": "error",
2082
+ "react/jsx-no-useless-fragment": "error",
2083
+ "react/function-component-definition": [
2084
+ "error",
2085
+ {
2086
+ unnamedComponents: "arrow-function",
2087
+ namedComponents: "function-declaration"
2088
+ }
2089
+ ],
2090
+ "react/hook-use-state": [
2091
+ "error",
2092
+ {
2093
+ allowDestructuredState: true
2094
+ }
2095
+ ],
2096
+ "react/no-array-index-key": "warn"
2097
+ }
2098
+ },
2099
+ ...pluginQuery.configs["flat/recommended"],
2100
+ src_default.configs.recommended,
2101
+ {
2102
+ name: "solvro/react/disables",
2103
+ files: ["**/components/ui/*.{jsx,tsx}"],
2104
+ rules: {
2105
+ "react/prop-types": "off",
2106
+ "no-shadow": "off",
2107
+ "@typescript-eslint/no-shadow": "off",
2108
+ "@typescript-eslint/restrict-template-expressions": "off",
2109
+ "unicorn/no-document-cookie": "off",
2110
+ "@typescript-eslint/no-redeclare": "off",
2111
+ "@typescript-eslint/no-deprecated": "off"
2112
+ }
2113
+ }
2114
+ ];
2115
+ }
2116
+
2117
+ // src/eslint/presets/react.ts
2118
+ var reactPreset = async () => [
2119
+ ...a11y(),
2120
+ ...unicorn(),
2121
+ ...typescriptStrict(),
2122
+ ...imports({ forbidDefaultExport: true }),
2123
+ ...await react()
2124
+ ];
2125
+ export {
2126
+ reactPreset
2127
+ };
2128
+ /*! Bundled license information:
2129
+
2130
+ eslint-utils/index.mjs:
2131
+ (*! @author Toru Nagashima <https://github.com/mysticatea> *)
2132
+ */
2133
+ //# sourceMappingURL=react-4BBIFFXI.js.map