]> git.proxmox.com Git - pve-eslint.git/blob - src/lib/eslint.js
commit build of 8.3.0
[pve-eslint.git] / src / lib / eslint.js
1 (function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory();
4 else if(typeof define === 'function' && define.amd)
5 define([], factory);
6 else if(typeof exports === 'object')
7 exports["eslint"] = factory();
8 else
9 root["eslint"] = factory();
10 })(this, function() {
11 return /******/ (() => { // webpackBootstrap
12 /******/ var __webpack_modules__ = ([
13 /* 0 */
14 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
15
16 __webpack_require__(1);
17
18 __webpack_require__(84);
19
20 __webpack_require__(85);
21
22 __webpack_require__(86);
23
24 __webpack_require__(87);
25
26 __webpack_require__(88);
27
28 __webpack_require__(89);
29
30 __webpack_require__(90);
31
32 __webpack_require__(91);
33
34 __webpack_require__(92);
35
36 __webpack_require__(93);
37
38 __webpack_require__(94);
39
40 __webpack_require__(95);
41
42 __webpack_require__(96);
43
44 __webpack_require__(97);
45
46 __webpack_require__(98);
47
48 __webpack_require__(113);
49
50 __webpack_require__(115);
51
52 __webpack_require__(117);
53
54 __webpack_require__(119);
55
56 __webpack_require__(121);
57
58 __webpack_require__(123);
59
60 __webpack_require__(124);
61
62 __webpack_require__(125);
63
64 __webpack_require__(126);
65
66 __webpack_require__(128);
67
68 __webpack_require__(129);
69
70 __webpack_require__(131);
71
72 __webpack_require__(135);
73
74 __webpack_require__(136);
75
76 __webpack_require__(137);
77
78 __webpack_require__(138);
79
80 __webpack_require__(142);
81
82 __webpack_require__(143);
83
84 __webpack_require__(145);
85
86 __webpack_require__(146);
87
88 __webpack_require__(147);
89
90 __webpack_require__(150);
91
92 __webpack_require__(151);
93
94 __webpack_require__(152);
95
96 __webpack_require__(153);
97
98 __webpack_require__(154);
99
100 __webpack_require__(159);
101
102 __webpack_require__(161);
103
104 __webpack_require__(162);
105
106 __webpack_require__(163);
107
108 __webpack_require__(164);
109
110 __webpack_require__(171);
111
112 __webpack_require__(173);
113
114 __webpack_require__(176);
115
116 __webpack_require__(177);
117
118 __webpack_require__(178);
119
120 __webpack_require__(179);
121
122 __webpack_require__(180);
123
124 __webpack_require__(181);
125
126 __webpack_require__(185);
127
128 __webpack_require__(186);
129
130 __webpack_require__(188);
131
132 __webpack_require__(189);
133
134 __webpack_require__(190);
135
136 __webpack_require__(192);
137
138 __webpack_require__(193);
139
140 __webpack_require__(194);
141
142 __webpack_require__(195);
143
144 __webpack_require__(196);
145
146 __webpack_require__(197);
147
148 __webpack_require__(205);
149
150 __webpack_require__(207);
151
152 __webpack_require__(208);
153
154 __webpack_require__(209);
155
156 __webpack_require__(211);
157
158 __webpack_require__(212);
159
160 __webpack_require__(214);
161
162 __webpack_require__(215);
163
164 __webpack_require__(217);
165
166 __webpack_require__(218);
167
168 __webpack_require__(219);
169
170 __webpack_require__(220);
171
172 __webpack_require__(221);
173
174 __webpack_require__(222);
175
176 __webpack_require__(223);
177
178 __webpack_require__(224);
179
180 __webpack_require__(225);
181
182 __webpack_require__(226);
183
184 __webpack_require__(227);
185
186 __webpack_require__(231);
187
188 __webpack_require__(232);
189
190 __webpack_require__(234);
191
192 __webpack_require__(236);
193
194 __webpack_require__(237);
195
196 __webpack_require__(238);
197
198 __webpack_require__(239);
199
200 __webpack_require__(240);
201
202 __webpack_require__(242);
203
204 __webpack_require__(244);
205
206 __webpack_require__(245);
207
208 __webpack_require__(246);
209
210 __webpack_require__(248);
211
212 __webpack_require__(249);
213
214 __webpack_require__(251);
215
216 __webpack_require__(252);
217
218 __webpack_require__(253);
219
220 __webpack_require__(254);
221
222 __webpack_require__(256);
223
224 __webpack_require__(257);
225
226 __webpack_require__(258);
227
228 __webpack_require__(259);
229
230 __webpack_require__(260);
231
232 __webpack_require__(261);
233
234 __webpack_require__(262);
235
236 __webpack_require__(263);
237
238 __webpack_require__(265);
239
240 __webpack_require__(266);
241
242 __webpack_require__(267);
243
244 __webpack_require__(268);
245
246 __webpack_require__(269);
247
248 __webpack_require__(270);
249
250 __webpack_require__(271);
251
252 __webpack_require__(272);
253
254 __webpack_require__(273);
255
256 __webpack_require__(274);
257
258 __webpack_require__(276);
259
260 __webpack_require__(277);
261
262 __webpack_require__(278);
263
264 __webpack_require__(279);
265
266 __webpack_require__(291);
267
268 __webpack_require__(292);
269
270 __webpack_require__(293);
271
272 __webpack_require__(294);
273
274 __webpack_require__(295);
275
276 __webpack_require__(296);
277
278 __webpack_require__(297);
279
280 __webpack_require__(298);
281
282 __webpack_require__(300);
283
284 __webpack_require__(301);
285
286 __webpack_require__(302);
287
288 __webpack_require__(303);
289
290 __webpack_require__(304);
291
292 __webpack_require__(305);
293
294 __webpack_require__(306);
295
296 __webpack_require__(307);
297
298 __webpack_require__(308);
299
300 __webpack_require__(309);
301
302 __webpack_require__(315);
303
304 __webpack_require__(316);
305
306 __webpack_require__(318);
307
308 __webpack_require__(319);
309
310 __webpack_require__(320);
311
312 __webpack_require__(321);
313
314 __webpack_require__(322);
315
316 __webpack_require__(323);
317
318 __webpack_require__(324);
319
320 __webpack_require__(326);
321
322 __webpack_require__(329);
323
324 __webpack_require__(330);
325
326 __webpack_require__(331);
327
328 __webpack_require__(332);
329
330 __webpack_require__(336);
331
332 __webpack_require__(337);
333
334 __webpack_require__(339);
335
336 __webpack_require__(340);
337
338 __webpack_require__(341);
339
340 __webpack_require__(342);
341
342 __webpack_require__(344);
343
344 __webpack_require__(345);
345
346 __webpack_require__(346);
347
348 __webpack_require__(347);
349
350 __webpack_require__(348);
351
352 __webpack_require__(349);
353
354 __webpack_require__(351);
355
356 __webpack_require__(352);
357
358 __webpack_require__(353);
359
360 __webpack_require__(356);
361
362 __webpack_require__(357);
363
364 __webpack_require__(358);
365
366 __webpack_require__(359);
367
368 __webpack_require__(360);
369
370 __webpack_require__(361);
371
372 __webpack_require__(362);
373
374 __webpack_require__(363);
375
376 __webpack_require__(364);
377
378 __webpack_require__(365);
379
380 __webpack_require__(366);
381
382 __webpack_require__(367);
383
384 __webpack_require__(368);
385
386 __webpack_require__(374);
387
388 __webpack_require__(375);
389
390 __webpack_require__(376);
391
392 __webpack_require__(377);
393
394 __webpack_require__(378);
395
396 __webpack_require__(379);
397
398 __webpack_require__(380);
399
400 __webpack_require__(381);
401
402 __webpack_require__(382);
403
404 __webpack_require__(383);
405
406 __webpack_require__(384);
407
408 __webpack_require__(385);
409
410 __webpack_require__(386);
411
412 __webpack_require__(390);
413
414 __webpack_require__(391);
415
416 __webpack_require__(392);
417
418 __webpack_require__(393);
419
420 __webpack_require__(394);
421
422 __webpack_require__(395);
423
424 __webpack_require__(396);
425
426 __webpack_require__(397);
427
428 __webpack_require__(398);
429
430 __webpack_require__(399);
431
432 __webpack_require__(400);
433
434 __webpack_require__(401);
435
436 __webpack_require__(402);
437
438 __webpack_require__(403);
439
440 __webpack_require__(404);
441
442 __webpack_require__(405);
443
444 __webpack_require__(406);
445
446 __webpack_require__(407);
447
448 __webpack_require__(408);
449
450 __webpack_require__(409);
451
452 __webpack_require__(410);
453
454 __webpack_require__(411);
455
456 __webpack_require__(412);
457
458 __webpack_require__(414);
459
460 __webpack_require__(415);
461
462 __webpack_require__(418);
463
464 __webpack_require__(419);
465
466 __webpack_require__(420);
467
468 __webpack_require__(421);
469
470 __webpack_require__(422);
471
472 __webpack_require__(426);
473
474 __webpack_require__(425);
475
476 module.exports = __webpack_require__(77);
477
478 /***/ }),
479 /* 1 */
480 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
481
482 "use strict";
483
484
485 var $ = __webpack_require__(2);
486
487 var global = __webpack_require__(3);
488
489 var getBuiltIn = __webpack_require__(20);
490
491 var apply = __webpack_require__(62);
492
493 var call = __webpack_require__(7);
494
495 var uncurryThis = __webpack_require__(12);
496
497 var IS_PURE = __webpack_require__(32);
498
499 var DESCRIPTORS = __webpack_require__(5);
500
501 var NATIVE_SYMBOL = __webpack_require__(23);
502
503 var fails = __webpack_require__(6);
504
505 var hasOwn = __webpack_require__(35);
506
507 var isArray = __webpack_require__(63);
508
509 var isCallable = __webpack_require__(18);
510
511 var isObject = __webpack_require__(17);
512
513 var isPrototypeOf = __webpack_require__(21);
514
515 var isSymbol = __webpack_require__(19);
516
517 var anObject = __webpack_require__(42);
518
519 var toObject = __webpack_require__(36);
520
521 var toIndexedObject = __webpack_require__(10);
522
523 var toPropertyKey = __webpack_require__(15);
524
525 var $toString = __webpack_require__(64);
526
527 var createPropertyDescriptor = __webpack_require__(9);
528
529 var nativeObjectCreate = __webpack_require__(67);
530
531 var objectKeys = __webpack_require__(69);
532
533 var getOwnPropertyNamesModule = __webpack_require__(52);
534
535 var getOwnPropertyNamesExternal = __webpack_require__(71);
536
537 var getOwnPropertySymbolsModule = __webpack_require__(60);
538
539 var getOwnPropertyDescriptorModule = __webpack_require__(4);
540
541 var definePropertyModule = __webpack_require__(41);
542
543 var propertyIsEnumerableModule = __webpack_require__(8);
544
545 var arraySlice = __webpack_require__(74);
546
547 var redefine = __webpack_require__(43);
548
549 var shared = __webpack_require__(31);
550
551 var sharedKey = __webpack_require__(47);
552
553 var hiddenKeys = __webpack_require__(48);
554
555 var uid = __webpack_require__(37);
556
557 var wellKnownSymbol = __webpack_require__(30);
558
559 var wrappedWellKnownSymbolModule = __webpack_require__(75);
560
561 var defineWellKnownSymbol = __webpack_require__(76);
562
563 var setToStringTag = __webpack_require__(78);
564
565 var InternalStateModule = __webpack_require__(45);
566
567 var $forEach = (__webpack_require__(79).forEach);
568
569 var HIDDEN = sharedKey('hidden');
570 var SYMBOL = 'Symbol';
571 var PROTOTYPE = 'prototype';
572 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
573 var setInternalState = InternalStateModule.set;
574 var getInternalState = InternalStateModule.getterFor(SYMBOL);
575 var ObjectPrototype = Object[PROTOTYPE];
576 var $Symbol = global.Symbol;
577 var SymbolPrototype = $Symbol && $Symbol[PROTOTYPE];
578 var TypeError = global.TypeError;
579 var QObject = global.QObject;
580 var $stringify = getBuiltIn('JSON', 'stringify');
581 var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
582 var nativeDefineProperty = definePropertyModule.f;
583 var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f;
584 var nativePropertyIsEnumerable = propertyIsEnumerableModule.f;
585 var push = uncurryThis([].push);
586 var AllSymbols = shared('symbols');
587 var ObjectPrototypeSymbols = shared('op-symbols');
588 var StringToSymbolRegistry = shared('string-to-symbol-registry');
589 var SymbolToStringRegistry = shared('symbol-to-string-registry');
590 var WellKnownSymbolsStore = shared('wks'); // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
591
592 var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
593
594 var setSymbolDescriptor = DESCRIPTORS && fails(function () {
595 return nativeObjectCreate(nativeDefineProperty({}, 'a', {
596 get: function () {
597 return nativeDefineProperty(this, 'a', {
598 value: 7
599 }).a;
600 }
601 })).a != 7;
602 }) ? function (O, P, Attributes) {
603 var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P);
604 if (ObjectPrototypeDescriptor) delete ObjectPrototype[P];
605 nativeDefineProperty(O, P, Attributes);
606
607 if (ObjectPrototypeDescriptor && O !== ObjectPrototype) {
608 nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor);
609 }
610 } : nativeDefineProperty;
611
612 var wrap = function (tag, description) {
613 var symbol = AllSymbols[tag] = nativeObjectCreate(SymbolPrototype);
614 setInternalState(symbol, {
615 type: SYMBOL,
616 tag: tag,
617 description: description
618 });
619 if (!DESCRIPTORS) symbol.description = description;
620 return symbol;
621 };
622
623 var $defineProperty = function defineProperty(O, P, Attributes) {
624 if (O === ObjectPrototype) $defineProperty(ObjectPrototypeSymbols, P, Attributes);
625 anObject(O);
626 var key = toPropertyKey(P);
627 anObject(Attributes);
628
629 if (hasOwn(AllSymbols, key)) {
630 if (!Attributes.enumerable) {
631 if (!hasOwn(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {}));
632 O[HIDDEN][key] = true;
633 } else {
634 if (hasOwn(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false;
635 Attributes = nativeObjectCreate(Attributes, {
636 enumerable: createPropertyDescriptor(0, false)
637 });
638 }
639
640 return setSymbolDescriptor(O, key, Attributes);
641 }
642
643 return nativeDefineProperty(O, key, Attributes);
644 };
645
646 var $defineProperties = function defineProperties(O, Properties) {
647 anObject(O);
648 var properties = toIndexedObject(Properties);
649 var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties));
650 $forEach(keys, function (key) {
651 if (!DESCRIPTORS || call($propertyIsEnumerable, properties, key)) $defineProperty(O, key, properties[key]);
652 });
653 return O;
654 };
655
656 var $create = function create(O, Properties) {
657 return Properties === undefined ? nativeObjectCreate(O) : $defineProperties(nativeObjectCreate(O), Properties);
658 };
659
660 var $propertyIsEnumerable = function propertyIsEnumerable(V) {
661 var P = toPropertyKey(V);
662 var enumerable = call(nativePropertyIsEnumerable, this, P);
663 if (this === ObjectPrototype && hasOwn(AllSymbols, P) && !hasOwn(ObjectPrototypeSymbols, P)) return false;
664 return enumerable || !hasOwn(this, P) || !hasOwn(AllSymbols, P) || hasOwn(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true;
665 };
666
667 var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) {
668 var it = toIndexedObject(O);
669 var key = toPropertyKey(P);
670 if (it === ObjectPrototype && hasOwn(AllSymbols, key) && !hasOwn(ObjectPrototypeSymbols, key)) return;
671 var descriptor = nativeGetOwnPropertyDescriptor(it, key);
672
673 if (descriptor && hasOwn(AllSymbols, key) && !(hasOwn(it, HIDDEN) && it[HIDDEN][key])) {
674 descriptor.enumerable = true;
675 }
676
677 return descriptor;
678 };
679
680 var $getOwnPropertyNames = function getOwnPropertyNames(O) {
681 var names = nativeGetOwnPropertyNames(toIndexedObject(O));
682 var result = [];
683 $forEach(names, function (key) {
684 if (!hasOwn(AllSymbols, key) && !hasOwn(hiddenKeys, key)) push(result, key);
685 });
686 return result;
687 };
688
689 var $getOwnPropertySymbols = function getOwnPropertySymbols(O) {
690 var IS_OBJECT_PROTOTYPE = O === ObjectPrototype;
691 var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O));
692 var result = [];
693 $forEach(names, function (key) {
694 if (hasOwn(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn(ObjectPrototype, key))) {
695 push(result, AllSymbols[key]);
696 }
697 });
698 return result;
699 }; // `Symbol` constructor
700 // https://tc39.es/ecma262/#sec-symbol-constructor
701
702
703 if (!NATIVE_SYMBOL) {
704 $Symbol = function Symbol() {
705 if (isPrototypeOf(SymbolPrototype, this)) throw TypeError('Symbol is not a constructor');
706 var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]);
707 var tag = uid(description);
708
709 var setter = function (value) {
710 if (this === ObjectPrototype) call(setter, ObjectPrototypeSymbols, value);
711 if (hasOwn(this, HIDDEN) && hasOwn(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
712 setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value));
713 };
714
715 if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, {
716 configurable: true,
717 set: setter
718 });
719 return wrap(tag, description);
720 };
721
722 SymbolPrototype = $Symbol[PROTOTYPE];
723 redefine(SymbolPrototype, 'toString', function toString() {
724 return getInternalState(this).tag;
725 });
726 redefine($Symbol, 'withoutSetter', function (description) {
727 return wrap(uid(description), description);
728 });
729 propertyIsEnumerableModule.f = $propertyIsEnumerable;
730 definePropertyModule.f = $defineProperty;
731 getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor;
732 getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames;
733 getOwnPropertySymbolsModule.f = $getOwnPropertySymbols;
734
735 wrappedWellKnownSymbolModule.f = function (name) {
736 return wrap(wellKnownSymbol(name), name);
737 };
738
739 if (DESCRIPTORS) {
740 // https://github.com/tc39/proposal-Symbol-description
741 nativeDefineProperty(SymbolPrototype, 'description', {
742 configurable: true,
743 get: function description() {
744 return getInternalState(this).description;
745 }
746 });
747
748 if (!IS_PURE) {
749 redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, {
750 unsafe: true
751 });
752 }
753 }
754 }
755
756 $({
757 global: true,
758 wrap: true,
759 forced: !NATIVE_SYMBOL,
760 sham: !NATIVE_SYMBOL
761 }, {
762 Symbol: $Symbol
763 });
764 $forEach(objectKeys(WellKnownSymbolsStore), function (name) {
765 defineWellKnownSymbol(name);
766 });
767 $({
768 target: SYMBOL,
769 stat: true,
770 forced: !NATIVE_SYMBOL
771 }, {
772 // `Symbol.for` method
773 // https://tc39.es/ecma262/#sec-symbol.for
774 'for': function (key) {
775 var string = $toString(key);
776 if (hasOwn(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string];
777 var symbol = $Symbol(string);
778 StringToSymbolRegistry[string] = symbol;
779 SymbolToStringRegistry[symbol] = string;
780 return symbol;
781 },
782 // `Symbol.keyFor` method
783 // https://tc39.es/ecma262/#sec-symbol.keyfor
784 keyFor: function keyFor(sym) {
785 if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol');
786 if (hasOwn(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym];
787 },
788 useSetter: function () {
789 USE_SETTER = true;
790 },
791 useSimple: function () {
792 USE_SETTER = false;
793 }
794 });
795 $({
796 target: 'Object',
797 stat: true,
798 forced: !NATIVE_SYMBOL,
799 sham: !DESCRIPTORS
800 }, {
801 // `Object.create` method
802 // https://tc39.es/ecma262/#sec-object.create
803 create: $create,
804 // `Object.defineProperty` method
805 // https://tc39.es/ecma262/#sec-object.defineproperty
806 defineProperty: $defineProperty,
807 // `Object.defineProperties` method
808 // https://tc39.es/ecma262/#sec-object.defineproperties
809 defineProperties: $defineProperties,
810 // `Object.getOwnPropertyDescriptor` method
811 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
812 getOwnPropertyDescriptor: $getOwnPropertyDescriptor
813 });
814 $({
815 target: 'Object',
816 stat: true,
817 forced: !NATIVE_SYMBOL
818 }, {
819 // `Object.getOwnPropertyNames` method
820 // https://tc39.es/ecma262/#sec-object.getownpropertynames
821 getOwnPropertyNames: $getOwnPropertyNames,
822 // `Object.getOwnPropertySymbols` method
823 // https://tc39.es/ecma262/#sec-object.getownpropertysymbols
824 getOwnPropertySymbols: $getOwnPropertySymbols
825 }); // Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
826 // https://bugs.chromium.org/p/v8/issues/detail?id=3443
827
828 $({
829 target: 'Object',
830 stat: true,
831 forced: fails(function () {
832 getOwnPropertySymbolsModule.f(1);
833 })
834 }, {
835 getOwnPropertySymbols: function getOwnPropertySymbols(it) {
836 return getOwnPropertySymbolsModule.f(toObject(it));
837 }
838 }); // `JSON.stringify` method behavior with symbols
839 // https://tc39.es/ecma262/#sec-json.stringify
840
841 if ($stringify) {
842 var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails(function () {
843 var symbol = $Symbol(); // MS Edge converts symbol values to JSON as {}
844
845 return $stringify([symbol]) != '[null]' // WebKit converts symbol values to JSON as null
846 || $stringify({
847 a: symbol
848 }) != '{}' // V8 throws on boxed symbols
849 || $stringify(Object(symbol)) != '{}';
850 });
851 $({
852 target: 'JSON',
853 stat: true,
854 forced: FORCED_JSON_STRINGIFY
855 }, {
856 // eslint-disable-next-line no-unused-vars -- required for `.length`
857 stringify: function stringify(it, replacer, space) {
858 var args = arraySlice(arguments);
859 var $replacer = replacer;
860 if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
861
862 if (!isArray(replacer)) replacer = function (key, value) {
863 if (isCallable($replacer)) value = call($replacer, this, key, value);
864 if (!isSymbol(value)) return value;
865 };
866 args[1] = replacer;
867 return apply($stringify, null, args);
868 }
869 });
870 } // `Symbol.prototype[@@toPrimitive]` method
871 // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
872
873
874 if (!SymbolPrototype[TO_PRIMITIVE]) {
875 var valueOf = SymbolPrototype.valueOf; // eslint-disable-next-line no-unused-vars -- required for .length
876
877 redefine(SymbolPrototype, TO_PRIMITIVE, function (hint) {
878 // TODO: improve hint logic
879 return call(valueOf, this);
880 });
881 } // `Symbol.prototype[@@toStringTag]` property
882 // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag
883
884
885 setToStringTag($Symbol, SYMBOL);
886 hiddenKeys[HIDDEN] = true;
887
888 /***/ }),
889 /* 2 */
890 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
891
892 var global = __webpack_require__(3);
893
894 var getOwnPropertyDescriptor = (__webpack_require__(4).f);
895
896 var createNonEnumerableProperty = __webpack_require__(40);
897
898 var redefine = __webpack_require__(43);
899
900 var setGlobal = __webpack_require__(34);
901
902 var copyConstructorProperties = __webpack_require__(50);
903
904 var isForced = __webpack_require__(61);
905 /*
906 options.target - name of the target object
907 options.global - target is the global object
908 options.stat - export as static methods of target
909 options.proto - export as prototype methods of target
910 options.real - real prototype method for the `pure` version
911 options.forced - export even if the native feature is available
912 options.bind - bind methods to the target, required for the `pure` version
913 options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
914 options.unsafe - use the simple assignment of property instead of delete + defineProperty
915 options.sham - add a flag to not completely full polyfills
916 options.enumerable - export as enumerable property
917 options.noTargetGet - prevent calling a getter on target
918 options.name - the .name of the function if it does not match the key
919 */
920
921
922 module.exports = function (options, source) {
923 var TARGET = options.target;
924 var GLOBAL = options.global;
925 var STATIC = options.stat;
926 var FORCED, target, key, targetProperty, sourceProperty, descriptor;
927
928 if (GLOBAL) {
929 target = global;
930 } else if (STATIC) {
931 target = global[TARGET] || setGlobal(TARGET, {});
932 } else {
933 target = (global[TARGET] || {}).prototype;
934 }
935
936 if (target) for (key in source) {
937 sourceProperty = source[key];
938
939 if (options.noTargetGet) {
940 descriptor = getOwnPropertyDescriptor(target, key);
941 targetProperty = descriptor && descriptor.value;
942 } else targetProperty = target[key];
943
944 FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contained in target
945
946 if (!FORCED && targetProperty !== undefined) {
947 if (typeof sourceProperty == typeof targetProperty) continue;
948 copyConstructorProperties(sourceProperty, targetProperty);
949 } // add a flag to not completely full polyfills
950
951
952 if (options.sham || targetProperty && targetProperty.sham) {
953 createNonEnumerableProperty(sourceProperty, 'sham', true);
954 } // extend global
955
956
957 redefine(target, key, sourceProperty, options);
958 }
959 };
960
961 /***/ }),
962 /* 3 */
963 /***/ ((module) => {
964
965 var check = function (it) {
966 return it && it.Math == Math && it;
967 }; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
968
969
970 module.exports = // eslint-disable-next-line es/no-global-this -- safe
971 check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || // eslint-disable-next-line no-restricted-globals -- safe
972 check(typeof self == 'object' && self) || check(typeof global == 'object' && global) || // eslint-disable-next-line no-new-func -- fallback
973 function () {
974 return this;
975 }() || Function('return this')();
976
977 /***/ }),
978 /* 4 */
979 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
980
981 var DESCRIPTORS = __webpack_require__(5);
982
983 var call = __webpack_require__(7);
984
985 var propertyIsEnumerableModule = __webpack_require__(8);
986
987 var createPropertyDescriptor = __webpack_require__(9);
988
989 var toIndexedObject = __webpack_require__(10);
990
991 var toPropertyKey = __webpack_require__(15);
992
993 var hasOwn = __webpack_require__(35);
994
995 var IE8_DOM_DEFINE = __webpack_require__(38); // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
996
997
998 var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method
999 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
1000
1001 exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
1002 O = toIndexedObject(O);
1003 P = toPropertyKey(P);
1004 if (IE8_DOM_DEFINE) try {
1005 return $getOwnPropertyDescriptor(O, P);
1006 } catch (error) {
1007 /* empty */
1008 }
1009 if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
1010 };
1011
1012 /***/ }),
1013 /* 5 */
1014 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1015
1016 var fails = __webpack_require__(6); // Detect IE8's incomplete defineProperty implementation
1017
1018
1019 module.exports = !fails(function () {
1020 // eslint-disable-next-line es/no-object-defineproperty -- required for testing
1021 return Object.defineProperty({}, 1, {
1022 get: function () {
1023 return 7;
1024 }
1025 })[1] != 7;
1026 });
1027
1028 /***/ }),
1029 /* 6 */
1030 /***/ ((module) => {
1031
1032 module.exports = function (exec) {
1033 try {
1034 return !!exec();
1035 } catch (error) {
1036 return true;
1037 }
1038 };
1039
1040 /***/ }),
1041 /* 7 */
1042 /***/ ((module) => {
1043
1044 var call = Function.prototype.call;
1045 module.exports = call.bind ? call.bind(call) : function () {
1046 return call.apply(call, arguments);
1047 };
1048
1049 /***/ }),
1050 /* 8 */
1051 /***/ ((__unused_webpack_module, exports) => {
1052
1053 "use strict";
1054
1055
1056 var $propertyIsEnumerable = {}.propertyIsEnumerable; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1057
1058 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // Nashorn ~ JDK8 bug
1059
1060 var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({
1061 1: 2
1062 }, 1); // `Object.prototype.propertyIsEnumerable` method implementation
1063 // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
1064
1065 exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
1066 var descriptor = getOwnPropertyDescriptor(this, V);
1067 return !!descriptor && descriptor.enumerable;
1068 } : $propertyIsEnumerable;
1069
1070 /***/ }),
1071 /* 9 */
1072 /***/ ((module) => {
1073
1074 module.exports = function (bitmap, value) {
1075 return {
1076 enumerable: !(bitmap & 1),
1077 configurable: !(bitmap & 2),
1078 writable: !(bitmap & 4),
1079 value: value
1080 };
1081 };
1082
1083 /***/ }),
1084 /* 10 */
1085 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1086
1087 // toObject with fallback for non-array-like ES3 strings
1088 var IndexedObject = __webpack_require__(11);
1089
1090 var requireObjectCoercible = __webpack_require__(14);
1091
1092 module.exports = function (it) {
1093 return IndexedObject(requireObjectCoercible(it));
1094 };
1095
1096 /***/ }),
1097 /* 11 */
1098 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1099
1100 var global = __webpack_require__(3);
1101
1102 var uncurryThis = __webpack_require__(12);
1103
1104 var fails = __webpack_require__(6);
1105
1106 var classof = __webpack_require__(13);
1107
1108 var Object = global.Object;
1109 var split = uncurryThis(''.split); // fallback for non-array-like ES3 and non-enumerable old V8 strings
1110
1111 module.exports = fails(function () {
1112 // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
1113 // eslint-disable-next-line no-prototype-builtins -- safe
1114 return !Object('z').propertyIsEnumerable(0);
1115 }) ? function (it) {
1116 return classof(it) == 'String' ? split(it, '') : Object(it);
1117 } : Object;
1118
1119 /***/ }),
1120 /* 12 */
1121 /***/ ((module) => {
1122
1123 var FunctionPrototype = Function.prototype;
1124 var bind = FunctionPrototype.bind;
1125 var call = FunctionPrototype.call;
1126 var callBind = bind && bind.bind(call);
1127 module.exports = bind ? function (fn) {
1128 return fn && callBind(call, fn);
1129 } : function (fn) {
1130 return fn && function () {
1131 return call.apply(fn, arguments);
1132 };
1133 };
1134
1135 /***/ }),
1136 /* 13 */
1137 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1138
1139 var uncurryThis = __webpack_require__(12);
1140
1141 var toString = uncurryThis({}.toString);
1142 var stringSlice = uncurryThis(''.slice);
1143
1144 module.exports = function (it) {
1145 return stringSlice(toString(it), 8, -1);
1146 };
1147
1148 /***/ }),
1149 /* 14 */
1150 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1151
1152 var global = __webpack_require__(3);
1153
1154 var TypeError = global.TypeError; // `RequireObjectCoercible` abstract operation
1155 // https://tc39.es/ecma262/#sec-requireobjectcoercible
1156
1157 module.exports = function (it) {
1158 if (it == undefined) throw TypeError("Can't call method on " + it);
1159 return it;
1160 };
1161
1162 /***/ }),
1163 /* 15 */
1164 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1165
1166 var toPrimitive = __webpack_require__(16);
1167
1168 var isSymbol = __webpack_require__(19); // `ToPropertyKey` abstract operation
1169 // https://tc39.es/ecma262/#sec-topropertykey
1170
1171
1172 module.exports = function (argument) {
1173 var key = toPrimitive(argument, 'string');
1174 return isSymbol(key) ? key : key + '';
1175 };
1176
1177 /***/ }),
1178 /* 16 */
1179 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1180
1181 var global = __webpack_require__(3);
1182
1183 var call = __webpack_require__(7);
1184
1185 var isObject = __webpack_require__(17);
1186
1187 var isSymbol = __webpack_require__(19);
1188
1189 var getMethod = __webpack_require__(26);
1190
1191 var ordinaryToPrimitive = __webpack_require__(29);
1192
1193 var wellKnownSymbol = __webpack_require__(30);
1194
1195 var TypeError = global.TypeError;
1196 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); // `ToPrimitive` abstract operation
1197 // https://tc39.es/ecma262/#sec-toprimitive
1198
1199 module.exports = function (input, pref) {
1200 if (!isObject(input) || isSymbol(input)) return input;
1201 var exoticToPrim = getMethod(input, TO_PRIMITIVE);
1202 var result;
1203
1204 if (exoticToPrim) {
1205 if (pref === undefined) pref = 'default';
1206 result = call(exoticToPrim, input, pref);
1207 if (!isObject(result) || isSymbol(result)) return result;
1208 throw TypeError("Can't convert object to primitive value");
1209 }
1210
1211 if (pref === undefined) pref = 'number';
1212 return ordinaryToPrimitive(input, pref);
1213 };
1214
1215 /***/ }),
1216 /* 17 */
1217 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1218
1219 var isCallable = __webpack_require__(18);
1220
1221 module.exports = function (it) {
1222 return typeof it == 'object' ? it !== null : isCallable(it);
1223 };
1224
1225 /***/ }),
1226 /* 18 */
1227 /***/ ((module) => {
1228
1229 // `IsCallable` abstract operation
1230 // https://tc39.es/ecma262/#sec-iscallable
1231 module.exports = function (argument) {
1232 return typeof argument == 'function';
1233 };
1234
1235 /***/ }),
1236 /* 19 */
1237 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1238
1239 var global = __webpack_require__(3);
1240
1241 var getBuiltIn = __webpack_require__(20);
1242
1243 var isCallable = __webpack_require__(18);
1244
1245 var isPrototypeOf = __webpack_require__(21);
1246
1247 var USE_SYMBOL_AS_UID = __webpack_require__(22);
1248
1249 var Object = global.Object;
1250 module.exports = USE_SYMBOL_AS_UID ? function (it) {
1251 return typeof it == 'symbol';
1252 } : function (it) {
1253 var $Symbol = getBuiltIn('Symbol');
1254 return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, Object(it));
1255 };
1256
1257 /***/ }),
1258 /* 20 */
1259 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1260
1261 var global = __webpack_require__(3);
1262
1263 var isCallable = __webpack_require__(18);
1264
1265 var aFunction = function (argument) {
1266 return isCallable(argument) ? argument : undefined;
1267 };
1268
1269 module.exports = function (namespace, method) {
1270 return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method];
1271 };
1272
1273 /***/ }),
1274 /* 21 */
1275 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1276
1277 var uncurryThis = __webpack_require__(12);
1278
1279 module.exports = uncurryThis({}.isPrototypeOf);
1280
1281 /***/ }),
1282 /* 22 */
1283 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1284
1285 /* eslint-disable es/no-symbol -- required for testing */
1286 var NATIVE_SYMBOL = __webpack_require__(23);
1287
1288 module.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == 'symbol';
1289
1290 /***/ }),
1291 /* 23 */
1292 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1293
1294 /* eslint-disable es/no-symbol -- required for testing */
1295 var V8_VERSION = __webpack_require__(24);
1296
1297 var fails = __webpack_require__(6); // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
1298
1299
1300 module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
1301 var symbol = Symbol(); // Chrome 38 Symbol has incorrect toString conversion
1302 // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
1303
1304 return !String(symbol) || !(Object(symbol) instanceof Symbol) || // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
1305 !Symbol.sham && V8_VERSION && V8_VERSION < 41;
1306 });
1307
1308 /***/ }),
1309 /* 24 */
1310 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1311
1312 var global = __webpack_require__(3);
1313
1314 var userAgent = __webpack_require__(25);
1315
1316 var process = global.process;
1317 var Deno = global.Deno;
1318 var versions = process && process.versions || Deno && Deno.version;
1319 var v8 = versions && versions.v8;
1320 var match, version;
1321
1322 if (v8) {
1323 match = v8.split('.'); // in old Chrome, versions of V8 isn't V8 = Chrome / 10
1324 // but their correct versions are not interesting for us
1325
1326 version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
1327 } // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
1328 // so check `userAgent` even if `.v8` exists, but 0
1329
1330
1331 if (!version && userAgent) {
1332 match = userAgent.match(/Edge\/(\d+)/);
1333
1334 if (!match || match[1] >= 74) {
1335 match = userAgent.match(/Chrome\/(\d+)/);
1336 if (match) version = +match[1];
1337 }
1338 }
1339
1340 module.exports = version;
1341
1342 /***/ }),
1343 /* 25 */
1344 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1345
1346 var getBuiltIn = __webpack_require__(20);
1347
1348 module.exports = getBuiltIn('navigator', 'userAgent') || '';
1349
1350 /***/ }),
1351 /* 26 */
1352 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1353
1354 var aCallable = __webpack_require__(27); // `GetMethod` abstract operation
1355 // https://tc39.es/ecma262/#sec-getmethod
1356
1357
1358 module.exports = function (V, P) {
1359 var func = V[P];
1360 return func == null ? undefined : aCallable(func);
1361 };
1362
1363 /***/ }),
1364 /* 27 */
1365 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1366
1367 var global = __webpack_require__(3);
1368
1369 var isCallable = __webpack_require__(18);
1370
1371 var tryToString = __webpack_require__(28);
1372
1373 var TypeError = global.TypeError; // `Assert: IsCallable(argument) is true`
1374
1375 module.exports = function (argument) {
1376 if (isCallable(argument)) return argument;
1377 throw TypeError(tryToString(argument) + ' is not a function');
1378 };
1379
1380 /***/ }),
1381 /* 28 */
1382 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1383
1384 var global = __webpack_require__(3);
1385
1386 var String = global.String;
1387
1388 module.exports = function (argument) {
1389 try {
1390 return String(argument);
1391 } catch (error) {
1392 return 'Object';
1393 }
1394 };
1395
1396 /***/ }),
1397 /* 29 */
1398 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1399
1400 var global = __webpack_require__(3);
1401
1402 var call = __webpack_require__(7);
1403
1404 var isCallable = __webpack_require__(18);
1405
1406 var isObject = __webpack_require__(17);
1407
1408 var TypeError = global.TypeError; // `OrdinaryToPrimitive` abstract operation
1409 // https://tc39.es/ecma262/#sec-ordinarytoprimitive
1410
1411 module.exports = function (input, pref) {
1412 var fn, val;
1413 if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
1414 if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
1415 if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
1416 throw TypeError("Can't convert object to primitive value");
1417 };
1418
1419 /***/ }),
1420 /* 30 */
1421 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1422
1423 var global = __webpack_require__(3);
1424
1425 var shared = __webpack_require__(31);
1426
1427 var hasOwn = __webpack_require__(35);
1428
1429 var uid = __webpack_require__(37);
1430
1431 var NATIVE_SYMBOL = __webpack_require__(23);
1432
1433 var USE_SYMBOL_AS_UID = __webpack_require__(22);
1434
1435 var WellKnownSymbolsStore = shared('wks');
1436 var Symbol = global.Symbol;
1437 var symbolFor = Symbol && Symbol['for'];
1438 var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid;
1439
1440 module.exports = function (name) {
1441 if (!hasOwn(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) {
1442 var description = 'Symbol.' + name;
1443
1444 if (NATIVE_SYMBOL && hasOwn(Symbol, name)) {
1445 WellKnownSymbolsStore[name] = Symbol[name];
1446 } else if (USE_SYMBOL_AS_UID && symbolFor) {
1447 WellKnownSymbolsStore[name] = symbolFor(description);
1448 } else {
1449 WellKnownSymbolsStore[name] = createWellKnownSymbol(description);
1450 }
1451 }
1452
1453 return WellKnownSymbolsStore[name];
1454 };
1455
1456 /***/ }),
1457 /* 31 */
1458 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1459
1460 var IS_PURE = __webpack_require__(32);
1461
1462 var store = __webpack_require__(33);
1463
1464 (module.exports = function (key, value) {
1465 return store[key] || (store[key] = value !== undefined ? value : {});
1466 })('versions', []).push({
1467 version: '3.19.2',
1468 mode: IS_PURE ? 'pure' : 'global',
1469 copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
1470 });
1471
1472 /***/ }),
1473 /* 32 */
1474 /***/ ((module) => {
1475
1476 module.exports = false;
1477
1478 /***/ }),
1479 /* 33 */
1480 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1481
1482 var global = __webpack_require__(3);
1483
1484 var setGlobal = __webpack_require__(34);
1485
1486 var SHARED = '__core-js_shared__';
1487 var store = global[SHARED] || setGlobal(SHARED, {});
1488 module.exports = store;
1489
1490 /***/ }),
1491 /* 34 */
1492 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1493
1494 var global = __webpack_require__(3); // eslint-disable-next-line es/no-object-defineproperty -- safe
1495
1496
1497 var defineProperty = Object.defineProperty;
1498
1499 module.exports = function (key, value) {
1500 try {
1501 defineProperty(global, key, {
1502 value: value,
1503 configurable: true,
1504 writable: true
1505 });
1506 } catch (error) {
1507 global[key] = value;
1508 }
1509
1510 return value;
1511 };
1512
1513 /***/ }),
1514 /* 35 */
1515 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1516
1517 var uncurryThis = __webpack_require__(12);
1518
1519 var toObject = __webpack_require__(36);
1520
1521 var hasOwnProperty = uncurryThis({}.hasOwnProperty); // `HasOwnProperty` abstract operation
1522 // https://tc39.es/ecma262/#sec-hasownproperty
1523
1524 module.exports = Object.hasOwn || function hasOwn(it, key) {
1525 return hasOwnProperty(toObject(it), key);
1526 };
1527
1528 /***/ }),
1529 /* 36 */
1530 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1531
1532 var global = __webpack_require__(3);
1533
1534 var requireObjectCoercible = __webpack_require__(14);
1535
1536 var Object = global.Object; // `ToObject` abstract operation
1537 // https://tc39.es/ecma262/#sec-toobject
1538
1539 module.exports = function (argument) {
1540 return Object(requireObjectCoercible(argument));
1541 };
1542
1543 /***/ }),
1544 /* 37 */
1545 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1546
1547 var uncurryThis = __webpack_require__(12);
1548
1549 var id = 0;
1550 var postfix = Math.random();
1551 var toString = uncurryThis(1.0.toString);
1552
1553 module.exports = function (key) {
1554 return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
1555 };
1556
1557 /***/ }),
1558 /* 38 */
1559 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1560
1561 var DESCRIPTORS = __webpack_require__(5);
1562
1563 var fails = __webpack_require__(6);
1564
1565 var createElement = __webpack_require__(39); // Thank's IE8 for his funny defineProperty
1566
1567
1568 module.exports = !DESCRIPTORS && !fails(function () {
1569 // eslint-disable-next-line es/no-object-defineproperty -- requied for testing
1570 return Object.defineProperty(createElement('div'), 'a', {
1571 get: function () {
1572 return 7;
1573 }
1574 }).a != 7;
1575 });
1576
1577 /***/ }),
1578 /* 39 */
1579 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1580
1581 var global = __webpack_require__(3);
1582
1583 var isObject = __webpack_require__(17);
1584
1585 var document = global.document; // typeof document.createElement is 'object' in old IE
1586
1587 var EXISTS = isObject(document) && isObject(document.createElement);
1588
1589 module.exports = function (it) {
1590 return EXISTS ? document.createElement(it) : {};
1591 };
1592
1593 /***/ }),
1594 /* 40 */
1595 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1596
1597 var DESCRIPTORS = __webpack_require__(5);
1598
1599 var definePropertyModule = __webpack_require__(41);
1600
1601 var createPropertyDescriptor = __webpack_require__(9);
1602
1603 module.exports = DESCRIPTORS ? function (object, key, value) {
1604 return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
1605 } : function (object, key, value) {
1606 object[key] = value;
1607 return object;
1608 };
1609
1610 /***/ }),
1611 /* 41 */
1612 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1613
1614 var global = __webpack_require__(3);
1615
1616 var DESCRIPTORS = __webpack_require__(5);
1617
1618 var IE8_DOM_DEFINE = __webpack_require__(38);
1619
1620 var anObject = __webpack_require__(42);
1621
1622 var toPropertyKey = __webpack_require__(15);
1623
1624 var TypeError = global.TypeError; // eslint-disable-next-line es/no-object-defineproperty -- safe
1625
1626 var $defineProperty = Object.defineProperty; // `Object.defineProperty` method
1627 // https://tc39.es/ecma262/#sec-object.defineproperty
1628
1629 exports.f = DESCRIPTORS ? $defineProperty : function defineProperty(O, P, Attributes) {
1630 anObject(O);
1631 P = toPropertyKey(P);
1632 anObject(Attributes);
1633 if (IE8_DOM_DEFINE) try {
1634 return $defineProperty(O, P, Attributes);
1635 } catch (error) {
1636 /* empty */
1637 }
1638 if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
1639 if ('value' in Attributes) O[P] = Attributes.value;
1640 return O;
1641 };
1642
1643 /***/ }),
1644 /* 42 */
1645 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1646
1647 var global = __webpack_require__(3);
1648
1649 var isObject = __webpack_require__(17);
1650
1651 var String = global.String;
1652 var TypeError = global.TypeError; // `Assert: Type(argument) is Object`
1653
1654 module.exports = function (argument) {
1655 if (isObject(argument)) return argument;
1656 throw TypeError(String(argument) + ' is not an object');
1657 };
1658
1659 /***/ }),
1660 /* 43 */
1661 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1662
1663 var global = __webpack_require__(3);
1664
1665 var isCallable = __webpack_require__(18);
1666
1667 var hasOwn = __webpack_require__(35);
1668
1669 var createNonEnumerableProperty = __webpack_require__(40);
1670
1671 var setGlobal = __webpack_require__(34);
1672
1673 var inspectSource = __webpack_require__(44);
1674
1675 var InternalStateModule = __webpack_require__(45);
1676
1677 var CONFIGURABLE_FUNCTION_NAME = (__webpack_require__(49).CONFIGURABLE);
1678
1679 var getInternalState = InternalStateModule.get;
1680 var enforceInternalState = InternalStateModule.enforce;
1681 var TEMPLATE = String(String).split('String');
1682 (module.exports = function (O, key, value, options) {
1683 var unsafe = options ? !!options.unsafe : false;
1684 var simple = options ? !!options.enumerable : false;
1685 var noTargetGet = options ? !!options.noTargetGet : false;
1686 var name = options && options.name !== undefined ? options.name : key;
1687 var state;
1688
1689 if (isCallable(value)) {
1690 if (String(name).slice(0, 7) === 'Symbol(') {
1691 name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']';
1692 }
1693
1694 if (!hasOwn(value, 'name') || CONFIGURABLE_FUNCTION_NAME && value.name !== name) {
1695 createNonEnumerableProperty(value, 'name', name);
1696 }
1697
1698 state = enforceInternalState(value);
1699
1700 if (!state.source) {
1701 state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
1702 }
1703 }
1704
1705 if (O === global) {
1706 if (simple) O[key] = value;else setGlobal(key, value);
1707 return;
1708 } else if (!unsafe) {
1709 delete O[key];
1710 } else if (!noTargetGet && O[key]) {
1711 simple = true;
1712 }
1713
1714 if (simple) O[key] = value;else createNonEnumerableProperty(O, key, value); // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
1715 })(Function.prototype, 'toString', function toString() {
1716 return isCallable(this) && getInternalState(this).source || inspectSource(this);
1717 });
1718
1719 /***/ }),
1720 /* 44 */
1721 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1722
1723 var uncurryThis = __webpack_require__(12);
1724
1725 var isCallable = __webpack_require__(18);
1726
1727 var store = __webpack_require__(33);
1728
1729 var functionToString = uncurryThis(Function.toString); // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
1730
1731 if (!isCallable(store.inspectSource)) {
1732 store.inspectSource = function (it) {
1733 return functionToString(it);
1734 };
1735 }
1736
1737 module.exports = store.inspectSource;
1738
1739 /***/ }),
1740 /* 45 */
1741 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1742
1743 var NATIVE_WEAK_MAP = __webpack_require__(46);
1744
1745 var global = __webpack_require__(3);
1746
1747 var uncurryThis = __webpack_require__(12);
1748
1749 var isObject = __webpack_require__(17);
1750
1751 var createNonEnumerableProperty = __webpack_require__(40);
1752
1753 var hasOwn = __webpack_require__(35);
1754
1755 var shared = __webpack_require__(33);
1756
1757 var sharedKey = __webpack_require__(47);
1758
1759 var hiddenKeys = __webpack_require__(48);
1760
1761 var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
1762 var TypeError = global.TypeError;
1763 var WeakMap = global.WeakMap;
1764 var set, get, has;
1765
1766 var enforce = function (it) {
1767 return has(it) ? get(it) : set(it, {});
1768 };
1769
1770 var getterFor = function (TYPE) {
1771 return function (it) {
1772 var state;
1773
1774 if (!isObject(it) || (state = get(it)).type !== TYPE) {
1775 throw TypeError('Incompatible receiver, ' + TYPE + ' required');
1776 }
1777
1778 return state;
1779 };
1780 };
1781
1782 if (NATIVE_WEAK_MAP || shared.state) {
1783 var store = shared.state || (shared.state = new WeakMap());
1784 var wmget = uncurryThis(store.get);
1785 var wmhas = uncurryThis(store.has);
1786 var wmset = uncurryThis(store.set);
1787
1788 set = function (it, metadata) {
1789 if (wmhas(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
1790 metadata.facade = it;
1791 wmset(store, it, metadata);
1792 return metadata;
1793 };
1794
1795 get = function (it) {
1796 return wmget(store, it) || {};
1797 };
1798
1799 has = function (it) {
1800 return wmhas(store, it);
1801 };
1802 } else {
1803 var STATE = sharedKey('state');
1804 hiddenKeys[STATE] = true;
1805
1806 set = function (it, metadata) {
1807 if (hasOwn(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
1808 metadata.facade = it;
1809 createNonEnumerableProperty(it, STATE, metadata);
1810 return metadata;
1811 };
1812
1813 get = function (it) {
1814 return hasOwn(it, STATE) ? it[STATE] : {};
1815 };
1816
1817 has = function (it) {
1818 return hasOwn(it, STATE);
1819 };
1820 }
1821
1822 module.exports = {
1823 set: set,
1824 get: get,
1825 has: has,
1826 enforce: enforce,
1827 getterFor: getterFor
1828 };
1829
1830 /***/ }),
1831 /* 46 */
1832 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1833
1834 var global = __webpack_require__(3);
1835
1836 var isCallable = __webpack_require__(18);
1837
1838 var inspectSource = __webpack_require__(44);
1839
1840 var WeakMap = global.WeakMap;
1841 module.exports = isCallable(WeakMap) && /native code/.test(inspectSource(WeakMap));
1842
1843 /***/ }),
1844 /* 47 */
1845 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1846
1847 var shared = __webpack_require__(31);
1848
1849 var uid = __webpack_require__(37);
1850
1851 var keys = shared('keys');
1852
1853 module.exports = function (key) {
1854 return keys[key] || (keys[key] = uid(key));
1855 };
1856
1857 /***/ }),
1858 /* 48 */
1859 /***/ ((module) => {
1860
1861 module.exports = {};
1862
1863 /***/ }),
1864 /* 49 */
1865 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1866
1867 var DESCRIPTORS = __webpack_require__(5);
1868
1869 var hasOwn = __webpack_require__(35);
1870
1871 var FunctionPrototype = Function.prototype; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1872
1873 var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
1874 var EXISTS = hasOwn(FunctionPrototype, 'name'); // additional protection from minified / mangled / dropped function names
1875
1876 var PROPER = EXISTS && function something() {
1877 /* empty */
1878 }.name === 'something';
1879
1880 var CONFIGURABLE = EXISTS && (!DESCRIPTORS || DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable);
1881 module.exports = {
1882 EXISTS: EXISTS,
1883 PROPER: PROPER,
1884 CONFIGURABLE: CONFIGURABLE
1885 };
1886
1887 /***/ }),
1888 /* 50 */
1889 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1890
1891 var hasOwn = __webpack_require__(35);
1892
1893 var ownKeys = __webpack_require__(51);
1894
1895 var getOwnPropertyDescriptorModule = __webpack_require__(4);
1896
1897 var definePropertyModule = __webpack_require__(41);
1898
1899 module.exports = function (target, source) {
1900 var keys = ownKeys(source);
1901 var defineProperty = definePropertyModule.f;
1902 var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
1903
1904 for (var i = 0; i < keys.length; i++) {
1905 var key = keys[i];
1906 if (!hasOwn(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
1907 }
1908 };
1909
1910 /***/ }),
1911 /* 51 */
1912 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1913
1914 var getBuiltIn = __webpack_require__(20);
1915
1916 var uncurryThis = __webpack_require__(12);
1917
1918 var getOwnPropertyNamesModule = __webpack_require__(52);
1919
1920 var getOwnPropertySymbolsModule = __webpack_require__(60);
1921
1922 var anObject = __webpack_require__(42);
1923
1924 var concat = uncurryThis([].concat); // all object keys, includes non-enumerable and symbols
1925
1926 module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
1927 var keys = getOwnPropertyNamesModule.f(anObject(it));
1928 var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
1929 return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
1930 };
1931
1932 /***/ }),
1933 /* 52 */
1934 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1935
1936 var internalObjectKeys = __webpack_require__(53);
1937
1938 var enumBugKeys = __webpack_require__(59);
1939
1940 var hiddenKeys = enumBugKeys.concat('length', 'prototype'); // `Object.getOwnPropertyNames` method
1941 // https://tc39.es/ecma262/#sec-object.getownpropertynames
1942 // eslint-disable-next-line es/no-object-getownpropertynames -- safe
1943
1944 exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
1945 return internalObjectKeys(O, hiddenKeys);
1946 };
1947
1948 /***/ }),
1949 /* 53 */
1950 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1951
1952 var uncurryThis = __webpack_require__(12);
1953
1954 var hasOwn = __webpack_require__(35);
1955
1956 var toIndexedObject = __webpack_require__(10);
1957
1958 var indexOf = (__webpack_require__(54).indexOf);
1959
1960 var hiddenKeys = __webpack_require__(48);
1961
1962 var push = uncurryThis([].push);
1963
1964 module.exports = function (object, names) {
1965 var O = toIndexedObject(object);
1966 var i = 0;
1967 var result = [];
1968 var key;
1969
1970 for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key); // Don't enum bug & hidden keys
1971
1972
1973 while (names.length > i) if (hasOwn(O, key = names[i++])) {
1974 ~indexOf(result, key) || push(result, key);
1975 }
1976
1977 return result;
1978 };
1979
1980 /***/ }),
1981 /* 54 */
1982 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1983
1984 var toIndexedObject = __webpack_require__(10);
1985
1986 var toAbsoluteIndex = __webpack_require__(55);
1987
1988 var lengthOfArrayLike = __webpack_require__(57); // `Array.prototype.{ indexOf, includes }` methods implementation
1989
1990
1991 var createMethod = function (IS_INCLUDES) {
1992 return function ($this, el, fromIndex) {
1993 var O = toIndexedObject($this);
1994 var length = lengthOfArrayLike(O);
1995 var index = toAbsoluteIndex(fromIndex, length);
1996 var value; // Array#includes uses SameValueZero equality algorithm
1997 // eslint-disable-next-line no-self-compare -- NaN check
1998
1999 if (IS_INCLUDES && el != el) while (length > index) {
2000 value = O[index++]; // eslint-disable-next-line no-self-compare -- NaN check
2001
2002 if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not
2003 } else for (; length > index; index++) {
2004 if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
2005 }
2006 return !IS_INCLUDES && -1;
2007 };
2008 };
2009
2010 module.exports = {
2011 // `Array.prototype.includes` method
2012 // https://tc39.es/ecma262/#sec-array.prototype.includes
2013 includes: createMethod(true),
2014 // `Array.prototype.indexOf` method
2015 // https://tc39.es/ecma262/#sec-array.prototype.indexof
2016 indexOf: createMethod(false)
2017 };
2018
2019 /***/ }),
2020 /* 55 */
2021 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2022
2023 var toIntegerOrInfinity = __webpack_require__(56);
2024
2025 var max = Math.max;
2026 var min = Math.min; // Helper for a popular repeating case of the spec:
2027 // Let integer be ? ToInteger(index).
2028 // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
2029
2030 module.exports = function (index, length) {
2031 var integer = toIntegerOrInfinity(index);
2032 return integer < 0 ? max(integer + length, 0) : min(integer, length);
2033 };
2034
2035 /***/ }),
2036 /* 56 */
2037 /***/ ((module) => {
2038
2039 var ceil = Math.ceil;
2040 var floor = Math.floor; // `ToIntegerOrInfinity` abstract operation
2041 // https://tc39.es/ecma262/#sec-tointegerorinfinity
2042
2043 module.exports = function (argument) {
2044 var number = +argument; // eslint-disable-next-line no-self-compare -- safe
2045
2046 return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number);
2047 };
2048
2049 /***/ }),
2050 /* 57 */
2051 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2052
2053 var toLength = __webpack_require__(58); // `LengthOfArrayLike` abstract operation
2054 // https://tc39.es/ecma262/#sec-lengthofarraylike
2055
2056
2057 module.exports = function (obj) {
2058 return toLength(obj.length);
2059 };
2060
2061 /***/ }),
2062 /* 58 */
2063 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2064
2065 var toIntegerOrInfinity = __webpack_require__(56);
2066
2067 var min = Math.min; // `ToLength` abstract operation
2068 // https://tc39.es/ecma262/#sec-tolength
2069
2070 module.exports = function (argument) {
2071 return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
2072 };
2073
2074 /***/ }),
2075 /* 59 */
2076 /***/ ((module) => {
2077
2078 // IE8- don't enum bug keys
2079 module.exports = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf'];
2080
2081 /***/ }),
2082 /* 60 */
2083 /***/ ((__unused_webpack_module, exports) => {
2084
2085 // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
2086 exports.f = Object.getOwnPropertySymbols;
2087
2088 /***/ }),
2089 /* 61 */
2090 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2091
2092 var fails = __webpack_require__(6);
2093
2094 var isCallable = __webpack_require__(18);
2095
2096 var replacement = /#|\.prototype\./;
2097
2098 var isForced = function (feature, detection) {
2099 var value = data[normalize(feature)];
2100 return value == POLYFILL ? true : value == NATIVE ? false : isCallable(detection) ? fails(detection) : !!detection;
2101 };
2102
2103 var normalize = isForced.normalize = function (string) {
2104 return String(string).replace(replacement, '.').toLowerCase();
2105 };
2106
2107 var data = isForced.data = {};
2108 var NATIVE = isForced.NATIVE = 'N';
2109 var POLYFILL = isForced.POLYFILL = 'P';
2110 module.exports = isForced;
2111
2112 /***/ }),
2113 /* 62 */
2114 /***/ ((module) => {
2115
2116 var FunctionPrototype = Function.prototype;
2117 var apply = FunctionPrototype.apply;
2118 var bind = FunctionPrototype.bind;
2119 var call = FunctionPrototype.call; // eslint-disable-next-line es/no-reflect -- safe
2120
2121 module.exports = typeof Reflect == 'object' && Reflect.apply || (bind ? call.bind(apply) : function () {
2122 return call.apply(apply, arguments);
2123 });
2124
2125 /***/ }),
2126 /* 63 */
2127 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2128
2129 var classof = __webpack_require__(13); // `IsArray` abstract operation
2130 // https://tc39.es/ecma262/#sec-isarray
2131 // eslint-disable-next-line es/no-array-isarray -- safe
2132
2133
2134 module.exports = Array.isArray || function isArray(argument) {
2135 return classof(argument) == 'Array';
2136 };
2137
2138 /***/ }),
2139 /* 64 */
2140 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2141
2142 var global = __webpack_require__(3);
2143
2144 var classof = __webpack_require__(65);
2145
2146 var String = global.String;
2147
2148 module.exports = function (argument) {
2149 if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
2150 return String(argument);
2151 };
2152
2153 /***/ }),
2154 /* 65 */
2155 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2156
2157 var global = __webpack_require__(3);
2158
2159 var TO_STRING_TAG_SUPPORT = __webpack_require__(66);
2160
2161 var isCallable = __webpack_require__(18);
2162
2163 var classofRaw = __webpack_require__(13);
2164
2165 var wellKnownSymbol = __webpack_require__(30);
2166
2167 var TO_STRING_TAG = wellKnownSymbol('toStringTag');
2168 var Object = global.Object; // ES3 wrong here
2169
2170 var CORRECT_ARGUMENTS = classofRaw(function () {
2171 return arguments;
2172 }()) == 'Arguments'; // fallback for IE11 Script Access Denied error
2173
2174 var tryGet = function (it, key) {
2175 try {
2176 return it[key];
2177 } catch (error) {
2178 /* empty */
2179 }
2180 }; // getting tag from ES6+ `Object.prototype.toString`
2181
2182
2183 module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
2184 var O, tag, result;
2185 return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case
2186 : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag // builtinTag case
2187 : CORRECT_ARGUMENTS ? classofRaw(O) // ES3 arguments fallback
2188 : (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
2189 };
2190
2191 /***/ }),
2192 /* 66 */
2193 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2194
2195 var wellKnownSymbol = __webpack_require__(30);
2196
2197 var TO_STRING_TAG = wellKnownSymbol('toStringTag');
2198 var test = {};
2199 test[TO_STRING_TAG] = 'z';
2200 module.exports = String(test) === '[object z]';
2201
2202 /***/ }),
2203 /* 67 */
2204 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2205
2206 /* global ActiveXObject -- old IE, WSH */
2207 var anObject = __webpack_require__(42);
2208
2209 var defineProperties = __webpack_require__(68);
2210
2211 var enumBugKeys = __webpack_require__(59);
2212
2213 var hiddenKeys = __webpack_require__(48);
2214
2215 var html = __webpack_require__(70);
2216
2217 var documentCreateElement = __webpack_require__(39);
2218
2219 var sharedKey = __webpack_require__(47);
2220
2221 var GT = '>';
2222 var LT = '<';
2223 var PROTOTYPE = 'prototype';
2224 var SCRIPT = 'script';
2225 var IE_PROTO = sharedKey('IE_PROTO');
2226
2227 var EmptyConstructor = function () {
2228 /* empty */
2229 };
2230
2231 var scriptTag = function (content) {
2232 return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
2233 }; // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
2234
2235
2236 var NullProtoObjectViaActiveX = function (activeXDocument) {
2237 activeXDocument.write(scriptTag(''));
2238 activeXDocument.close();
2239 var temp = activeXDocument.parentWindow.Object;
2240 activeXDocument = null; // avoid memory leak
2241
2242 return temp;
2243 }; // Create object with fake `null` prototype: use iframe Object with cleared prototype
2244
2245
2246 var NullProtoObjectViaIFrame = function () {
2247 // Thrash, waste and sodomy: IE GC bug
2248 var iframe = documentCreateElement('iframe');
2249 var JS = 'java' + SCRIPT + ':';
2250 var iframeDocument;
2251 iframe.style.display = 'none';
2252 html.appendChild(iframe); // https://github.com/zloirock/core-js/issues/475
2253
2254 iframe.src = String(JS);
2255 iframeDocument = iframe.contentWindow.document;
2256 iframeDocument.open();
2257 iframeDocument.write(scriptTag('document.F=Object'));
2258 iframeDocument.close();
2259 return iframeDocument.F;
2260 }; // Check for document.domain and active x support
2261 // No need to use active x approach when document.domain is not set
2262 // see https://github.com/es-shims/es5-shim/issues/150
2263 // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
2264 // avoid IE GC bug
2265
2266
2267 var activeXDocument;
2268
2269 var NullProtoObject = function () {
2270 try {
2271 activeXDocument = new ActiveXObject('htmlfile');
2272 } catch (error) {
2273 /* ignore */
2274 }
2275
2276 NullProtoObject = typeof document != 'undefined' ? document.domain && activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) // old IE
2277 : NullProtoObjectViaIFrame() : NullProtoObjectViaActiveX(activeXDocument); // WSH
2278
2279 var length = enumBugKeys.length;
2280
2281 while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
2282
2283 return NullProtoObject();
2284 };
2285
2286 hiddenKeys[IE_PROTO] = true; // `Object.create` method
2287 // https://tc39.es/ecma262/#sec-object.create
2288
2289 module.exports = Object.create || function create(O, Properties) {
2290 var result;
2291
2292 if (O !== null) {
2293 EmptyConstructor[PROTOTYPE] = anObject(O);
2294 result = new EmptyConstructor();
2295 EmptyConstructor[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill
2296
2297 result[IE_PROTO] = O;
2298 } else result = NullProtoObject();
2299
2300 return Properties === undefined ? result : defineProperties(result, Properties);
2301 };
2302
2303 /***/ }),
2304 /* 68 */
2305 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2306
2307 var DESCRIPTORS = __webpack_require__(5);
2308
2309 var definePropertyModule = __webpack_require__(41);
2310
2311 var anObject = __webpack_require__(42);
2312
2313 var toIndexedObject = __webpack_require__(10);
2314
2315 var objectKeys = __webpack_require__(69); // `Object.defineProperties` method
2316 // https://tc39.es/ecma262/#sec-object.defineproperties
2317 // eslint-disable-next-line es/no-object-defineproperties -- safe
2318
2319
2320 module.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) {
2321 anObject(O);
2322 var props = toIndexedObject(Properties);
2323 var keys = objectKeys(Properties);
2324 var length = keys.length;
2325 var index = 0;
2326 var key;
2327
2328 while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
2329
2330 return O;
2331 };
2332
2333 /***/ }),
2334 /* 69 */
2335 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2336
2337 var internalObjectKeys = __webpack_require__(53);
2338
2339 var enumBugKeys = __webpack_require__(59); // `Object.keys` method
2340 // https://tc39.es/ecma262/#sec-object.keys
2341 // eslint-disable-next-line es/no-object-keys -- safe
2342
2343
2344 module.exports = Object.keys || function keys(O) {
2345 return internalObjectKeys(O, enumBugKeys);
2346 };
2347
2348 /***/ }),
2349 /* 70 */
2350 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2351
2352 var getBuiltIn = __webpack_require__(20);
2353
2354 module.exports = getBuiltIn('document', 'documentElement');
2355
2356 /***/ }),
2357 /* 71 */
2358 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2359
2360 /* eslint-disable es/no-object-getownpropertynames -- safe */
2361 var classof = __webpack_require__(13);
2362
2363 var toIndexedObject = __webpack_require__(10);
2364
2365 var $getOwnPropertyNames = (__webpack_require__(52).f);
2366
2367 var arraySlice = __webpack_require__(72);
2368
2369 var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
2370
2371 var getWindowNames = function (it) {
2372 try {
2373 return $getOwnPropertyNames(it);
2374 } catch (error) {
2375 return arraySlice(windowNames);
2376 }
2377 }; // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
2378
2379
2380 module.exports.f = function getOwnPropertyNames(it) {
2381 return windowNames && classof(it) == 'Window' ? getWindowNames(it) : $getOwnPropertyNames(toIndexedObject(it));
2382 };
2383
2384 /***/ }),
2385 /* 72 */
2386 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2387
2388 var global = __webpack_require__(3);
2389
2390 var toAbsoluteIndex = __webpack_require__(55);
2391
2392 var lengthOfArrayLike = __webpack_require__(57);
2393
2394 var createProperty = __webpack_require__(73);
2395
2396 var Array = global.Array;
2397 var max = Math.max;
2398
2399 module.exports = function (O, start, end) {
2400 var length = lengthOfArrayLike(O);
2401 var k = toAbsoluteIndex(start, length);
2402 var fin = toAbsoluteIndex(end === undefined ? length : end, length);
2403 var result = Array(max(fin - k, 0));
2404
2405 for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
2406
2407 result.length = n;
2408 return result;
2409 };
2410
2411 /***/ }),
2412 /* 73 */
2413 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2414
2415 "use strict";
2416
2417
2418 var toPropertyKey = __webpack_require__(15);
2419
2420 var definePropertyModule = __webpack_require__(41);
2421
2422 var createPropertyDescriptor = __webpack_require__(9);
2423
2424 module.exports = function (object, key, value) {
2425 var propertyKey = toPropertyKey(key);
2426 if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));else object[propertyKey] = value;
2427 };
2428
2429 /***/ }),
2430 /* 74 */
2431 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2432
2433 var uncurryThis = __webpack_require__(12);
2434
2435 module.exports = uncurryThis([].slice);
2436
2437 /***/ }),
2438 /* 75 */
2439 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2440
2441 var wellKnownSymbol = __webpack_require__(30);
2442
2443 exports.f = wellKnownSymbol;
2444
2445 /***/ }),
2446 /* 76 */
2447 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2448
2449 var path = __webpack_require__(77);
2450
2451 var hasOwn = __webpack_require__(35);
2452
2453 var wrappedWellKnownSymbolModule = __webpack_require__(75);
2454
2455 var defineProperty = (__webpack_require__(41).f);
2456
2457 module.exports = function (NAME) {
2458 var Symbol = path.Symbol || (path.Symbol = {});
2459 if (!hasOwn(Symbol, NAME)) defineProperty(Symbol, NAME, {
2460 value: wrappedWellKnownSymbolModule.f(NAME)
2461 });
2462 };
2463
2464 /***/ }),
2465 /* 77 */
2466 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2467
2468 var global = __webpack_require__(3);
2469
2470 module.exports = global;
2471
2472 /***/ }),
2473 /* 78 */
2474 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2475
2476 var defineProperty = (__webpack_require__(41).f);
2477
2478 var hasOwn = __webpack_require__(35);
2479
2480 var wellKnownSymbol = __webpack_require__(30);
2481
2482 var TO_STRING_TAG = wellKnownSymbol('toStringTag');
2483
2484 module.exports = function (it, TAG, STATIC) {
2485 if (it && !hasOwn(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
2486 defineProperty(it, TO_STRING_TAG, {
2487 configurable: true,
2488 value: TAG
2489 });
2490 }
2491 };
2492
2493 /***/ }),
2494 /* 79 */
2495 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2496
2497 var bind = __webpack_require__(80);
2498
2499 var uncurryThis = __webpack_require__(12);
2500
2501 var IndexedObject = __webpack_require__(11);
2502
2503 var toObject = __webpack_require__(36);
2504
2505 var lengthOfArrayLike = __webpack_require__(57);
2506
2507 var arraySpeciesCreate = __webpack_require__(81);
2508
2509 var push = uncurryThis([].push); // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation
2510
2511 var createMethod = function (TYPE) {
2512 var IS_MAP = TYPE == 1;
2513 var IS_FILTER = TYPE == 2;
2514 var IS_SOME = TYPE == 3;
2515 var IS_EVERY = TYPE == 4;
2516 var IS_FIND_INDEX = TYPE == 6;
2517 var IS_FILTER_REJECT = TYPE == 7;
2518 var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
2519 return function ($this, callbackfn, that, specificCreate) {
2520 var O = toObject($this);
2521 var self = IndexedObject(O);
2522 var boundFunction = bind(callbackfn, that);
2523 var length = lengthOfArrayLike(self);
2524 var index = 0;
2525 var create = specificCreate || arraySpeciesCreate;
2526 var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
2527 var value, result;
2528
2529 for (; length > index; index++) if (NO_HOLES || index in self) {
2530 value = self[index];
2531 result = boundFunction(value, index, O);
2532
2533 if (TYPE) {
2534 if (IS_MAP) target[index] = result; // map
2535 else if (result) switch (TYPE) {
2536 case 3:
2537 return true;
2538 // some
2539
2540 case 5:
2541 return value;
2542 // find
2543
2544 case 6:
2545 return index;
2546 // findIndex
2547
2548 case 2:
2549 push(target, value);
2550 // filter
2551 } else switch (TYPE) {
2552 case 4:
2553 return false;
2554 // every
2555
2556 case 7:
2557 push(target, value);
2558 // filterReject
2559 }
2560 }
2561 }
2562
2563 return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
2564 };
2565 };
2566
2567 module.exports = {
2568 // `Array.prototype.forEach` method
2569 // https://tc39.es/ecma262/#sec-array.prototype.foreach
2570 forEach: createMethod(0),
2571 // `Array.prototype.map` method
2572 // https://tc39.es/ecma262/#sec-array.prototype.map
2573 map: createMethod(1),
2574 // `Array.prototype.filter` method
2575 // https://tc39.es/ecma262/#sec-array.prototype.filter
2576 filter: createMethod(2),
2577 // `Array.prototype.some` method
2578 // https://tc39.es/ecma262/#sec-array.prototype.some
2579 some: createMethod(3),
2580 // `Array.prototype.every` method
2581 // https://tc39.es/ecma262/#sec-array.prototype.every
2582 every: createMethod(4),
2583 // `Array.prototype.find` method
2584 // https://tc39.es/ecma262/#sec-array.prototype.find
2585 find: createMethod(5),
2586 // `Array.prototype.findIndex` method
2587 // https://tc39.es/ecma262/#sec-array.prototype.findIndex
2588 findIndex: createMethod(6),
2589 // `Array.prototype.filterReject` method
2590 // https://github.com/tc39/proposal-array-filtering
2591 filterReject: createMethod(7)
2592 };
2593
2594 /***/ }),
2595 /* 80 */
2596 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2597
2598 var uncurryThis = __webpack_require__(12);
2599
2600 var aCallable = __webpack_require__(27);
2601
2602 var bind = uncurryThis(uncurryThis.bind); // optional / simple context binding
2603
2604 module.exports = function (fn, that) {
2605 aCallable(fn);
2606 return that === undefined ? fn : bind ? bind(fn, that) : function
2607 /* ...args */
2608 () {
2609 return fn.apply(that, arguments);
2610 };
2611 };
2612
2613 /***/ }),
2614 /* 81 */
2615 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2616
2617 var arraySpeciesConstructor = __webpack_require__(82); // `ArraySpeciesCreate` abstract operation
2618 // https://tc39.es/ecma262/#sec-arrayspeciescreate
2619
2620
2621 module.exports = function (originalArray, length) {
2622 return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
2623 };
2624
2625 /***/ }),
2626 /* 82 */
2627 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2628
2629 var global = __webpack_require__(3);
2630
2631 var isArray = __webpack_require__(63);
2632
2633 var isConstructor = __webpack_require__(83);
2634
2635 var isObject = __webpack_require__(17);
2636
2637 var wellKnownSymbol = __webpack_require__(30);
2638
2639 var SPECIES = wellKnownSymbol('species');
2640 var Array = global.Array; // a part of `ArraySpeciesCreate` abstract operation
2641 // https://tc39.es/ecma262/#sec-arrayspeciescreate
2642
2643 module.exports = function (originalArray) {
2644 var C;
2645
2646 if (isArray(originalArray)) {
2647 C = originalArray.constructor; // cross-realm fallback
2648
2649 if (isConstructor(C) && (C === Array || isArray(C.prototype))) C = undefined;else if (isObject(C)) {
2650 C = C[SPECIES];
2651 if (C === null) C = undefined;
2652 }
2653 }
2654
2655 return C === undefined ? Array : C;
2656 };
2657
2658 /***/ }),
2659 /* 83 */
2660 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2661
2662 var uncurryThis = __webpack_require__(12);
2663
2664 var fails = __webpack_require__(6);
2665
2666 var isCallable = __webpack_require__(18);
2667
2668 var classof = __webpack_require__(65);
2669
2670 var getBuiltIn = __webpack_require__(20);
2671
2672 var inspectSource = __webpack_require__(44);
2673
2674 var noop = function () {
2675 /* empty */
2676 };
2677
2678 var empty = [];
2679 var construct = getBuiltIn('Reflect', 'construct');
2680 var constructorRegExp = /^\s*(?:class|function)\b/;
2681 var exec = uncurryThis(constructorRegExp.exec);
2682 var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
2683
2684 var isConstructorModern = function (argument) {
2685 if (!isCallable(argument)) return false;
2686
2687 try {
2688 construct(noop, empty, argument);
2689 return true;
2690 } catch (error) {
2691 return false;
2692 }
2693 };
2694
2695 var isConstructorLegacy = function (argument) {
2696 if (!isCallable(argument)) return false;
2697
2698 switch (classof(argument)) {
2699 case 'AsyncFunction':
2700 case 'GeneratorFunction':
2701 case 'AsyncGeneratorFunction':
2702 return false;
2703 // we can't check .prototype since constructors produced by .bind haven't it
2704 }
2705
2706 return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
2707 }; // `IsConstructor` abstract operation
2708 // https://tc39.es/ecma262/#sec-isconstructor
2709
2710
2711 module.exports = !construct || fails(function () {
2712 var called;
2713 return isConstructorModern(isConstructorModern.call) || !isConstructorModern(Object) || !isConstructorModern(function () {
2714 called = true;
2715 }) || called;
2716 }) ? isConstructorLegacy : isConstructorModern;
2717
2718 /***/ }),
2719 /* 84 */
2720 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2721
2722 "use strict";
2723 // `Symbol.prototype.description` getter
2724 // https://tc39.es/ecma262/#sec-symbol.prototype.description
2725
2726
2727 var $ = __webpack_require__(2);
2728
2729 var DESCRIPTORS = __webpack_require__(5);
2730
2731 var global = __webpack_require__(3);
2732
2733 var uncurryThis = __webpack_require__(12);
2734
2735 var hasOwn = __webpack_require__(35);
2736
2737 var isCallable = __webpack_require__(18);
2738
2739 var isPrototypeOf = __webpack_require__(21);
2740
2741 var toString = __webpack_require__(64);
2742
2743 var defineProperty = (__webpack_require__(41).f);
2744
2745 var copyConstructorProperties = __webpack_require__(50);
2746
2747 var NativeSymbol = global.Symbol;
2748 var SymbolPrototype = NativeSymbol && NativeSymbol.prototype;
2749
2750 if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototype) || // Safari 12 bug
2751 NativeSymbol().description !== undefined)) {
2752 var EmptyStringDescriptionStore = {}; // wrap Symbol constructor for correct work with undefined description
2753
2754 var SymbolWrapper = function Symbol() {
2755 var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString(arguments[0]);
2756 var result = isPrototypeOf(SymbolPrototype, this) ? new NativeSymbol(description) // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
2757 : description === undefined ? NativeSymbol() : NativeSymbol(description);
2758 if (description === '') EmptyStringDescriptionStore[result] = true;
2759 return result;
2760 };
2761
2762 copyConstructorProperties(SymbolWrapper, NativeSymbol);
2763 SymbolWrapper.prototype = SymbolPrototype;
2764 SymbolPrototype.constructor = SymbolWrapper;
2765 var NATIVE_SYMBOL = String(NativeSymbol('test')) == 'Symbol(test)';
2766 var symbolToString = uncurryThis(SymbolPrototype.toString);
2767 var symbolValueOf = uncurryThis(SymbolPrototype.valueOf);
2768 var regexp = /^Symbol\((.*)\)[^)]+$/;
2769 var replace = uncurryThis(''.replace);
2770 var stringSlice = uncurryThis(''.slice);
2771 defineProperty(SymbolPrototype, 'description', {
2772 configurable: true,
2773 get: function description() {
2774 var symbol = symbolValueOf(this);
2775 var string = symbolToString(symbol);
2776 if (hasOwn(EmptyStringDescriptionStore, symbol)) return '';
2777 var desc = NATIVE_SYMBOL ? stringSlice(string, 7, -1) : replace(string, regexp, '$1');
2778 return desc === '' ? undefined : desc;
2779 }
2780 });
2781 $({
2782 global: true,
2783 forced: true
2784 }, {
2785 Symbol: SymbolWrapper
2786 });
2787 }
2788
2789 /***/ }),
2790 /* 85 */
2791 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2792
2793 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.asyncIterator` well-known symbol
2794 // https://tc39.es/ecma262/#sec-symbol.asynciterator
2795
2796
2797 defineWellKnownSymbol('asyncIterator');
2798
2799 /***/ }),
2800 /* 86 */
2801 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2802
2803 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.hasInstance` well-known symbol
2804 // https://tc39.es/ecma262/#sec-symbol.hasinstance
2805
2806
2807 defineWellKnownSymbol('hasInstance');
2808
2809 /***/ }),
2810 /* 87 */
2811 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2812
2813 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.isConcatSpreadable` well-known symbol
2814 // https://tc39.es/ecma262/#sec-symbol.isconcatspreadable
2815
2816
2817 defineWellKnownSymbol('isConcatSpreadable');
2818
2819 /***/ }),
2820 /* 88 */
2821 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2822
2823 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.iterator` well-known symbol
2824 // https://tc39.es/ecma262/#sec-symbol.iterator
2825
2826
2827 defineWellKnownSymbol('iterator');
2828
2829 /***/ }),
2830 /* 89 */
2831 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2832
2833 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.match` well-known symbol
2834 // https://tc39.es/ecma262/#sec-symbol.match
2835
2836
2837 defineWellKnownSymbol('match');
2838
2839 /***/ }),
2840 /* 90 */
2841 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2842
2843 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.matchAll` well-known symbol
2844 // https://tc39.es/ecma262/#sec-symbol.matchall
2845
2846
2847 defineWellKnownSymbol('matchAll');
2848
2849 /***/ }),
2850 /* 91 */
2851 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2852
2853 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.replace` well-known symbol
2854 // https://tc39.es/ecma262/#sec-symbol.replace
2855
2856
2857 defineWellKnownSymbol('replace');
2858
2859 /***/ }),
2860 /* 92 */
2861 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2862
2863 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.search` well-known symbol
2864 // https://tc39.es/ecma262/#sec-symbol.search
2865
2866
2867 defineWellKnownSymbol('search');
2868
2869 /***/ }),
2870 /* 93 */
2871 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2872
2873 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.species` well-known symbol
2874 // https://tc39.es/ecma262/#sec-symbol.species
2875
2876
2877 defineWellKnownSymbol('species');
2878
2879 /***/ }),
2880 /* 94 */
2881 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2882
2883 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.split` well-known symbol
2884 // https://tc39.es/ecma262/#sec-symbol.split
2885
2886
2887 defineWellKnownSymbol('split');
2888
2889 /***/ }),
2890 /* 95 */
2891 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2892
2893 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.toPrimitive` well-known symbol
2894 // https://tc39.es/ecma262/#sec-symbol.toprimitive
2895
2896
2897 defineWellKnownSymbol('toPrimitive');
2898
2899 /***/ }),
2900 /* 96 */
2901 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2902
2903 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.toStringTag` well-known symbol
2904 // https://tc39.es/ecma262/#sec-symbol.tostringtag
2905
2906
2907 defineWellKnownSymbol('toStringTag');
2908
2909 /***/ }),
2910 /* 97 */
2911 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2912
2913 var defineWellKnownSymbol = __webpack_require__(76); // `Symbol.unscopables` well-known symbol
2914 // https://tc39.es/ecma262/#sec-symbol.unscopables
2915
2916
2917 defineWellKnownSymbol('unscopables');
2918
2919 /***/ }),
2920 /* 98 */
2921 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2922
2923 "use strict";
2924
2925
2926 var $ = __webpack_require__(2);
2927
2928 var global = __webpack_require__(3);
2929
2930 var isPrototypeOf = __webpack_require__(21);
2931
2932 var getPrototypeOf = __webpack_require__(99);
2933
2934 var setPrototypeOf = __webpack_require__(101);
2935
2936 var copyConstructorProperties = __webpack_require__(50);
2937
2938 var create = __webpack_require__(67);
2939
2940 var createNonEnumerableProperty = __webpack_require__(40);
2941
2942 var createPropertyDescriptor = __webpack_require__(9);
2943
2944 var clearErrorStack = __webpack_require__(103);
2945
2946 var installErrorCause = __webpack_require__(104);
2947
2948 var iterate = __webpack_require__(105);
2949
2950 var normalizeStringArgument = __webpack_require__(111);
2951
2952 var wellKnownSymbol = __webpack_require__(30);
2953
2954 var ERROR_STACK_INSTALLABLE = __webpack_require__(112);
2955
2956 var TO_STRING_TAG = wellKnownSymbol('toStringTag');
2957 var Error = global.Error;
2958 var push = [].push;
2959
2960 var $AggregateError = function AggregateError(errors, message
2961 /* , options */
2962 ) {
2963 var options = arguments.length > 2 ? arguments[2] : undefined;
2964 var isInstance = isPrototypeOf(AggregateErrorPrototype, this);
2965 var that;
2966
2967 if (setPrototypeOf) {
2968 that = setPrototypeOf(new Error(undefined), isInstance ? getPrototypeOf(this) : AggregateErrorPrototype);
2969 } else {
2970 that = isInstance ? this : create(AggregateErrorPrototype);
2971 createNonEnumerableProperty(that, TO_STRING_TAG, 'Error');
2972 }
2973
2974 createNonEnumerableProperty(that, 'message', normalizeStringArgument(message, ''));
2975 if (ERROR_STACK_INSTALLABLE) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1));
2976 installErrorCause(that, options);
2977 var errorsArray = [];
2978 iterate(errors, push, {
2979 that: errorsArray
2980 });
2981 createNonEnumerableProperty(that, 'errors', errorsArray);
2982 return that;
2983 };
2984
2985 if (setPrototypeOf) setPrototypeOf($AggregateError, Error);else copyConstructorProperties($AggregateError, Error);
2986 var AggregateErrorPrototype = $AggregateError.prototype = create(Error.prototype, {
2987 constructor: createPropertyDescriptor(1, $AggregateError),
2988 message: createPropertyDescriptor(1, ''),
2989 name: createPropertyDescriptor(1, 'AggregateError')
2990 }); // `AggregateError` constructor
2991 // https://tc39.es/ecma262/#sec-aggregate-error-constructor
2992
2993 $({
2994 global: true
2995 }, {
2996 AggregateError: $AggregateError
2997 });
2998
2999 /***/ }),
3000 /* 99 */
3001 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3002
3003 var global = __webpack_require__(3);
3004
3005 var hasOwn = __webpack_require__(35);
3006
3007 var isCallable = __webpack_require__(18);
3008
3009 var toObject = __webpack_require__(36);
3010
3011 var sharedKey = __webpack_require__(47);
3012
3013 var CORRECT_PROTOTYPE_GETTER = __webpack_require__(100);
3014
3015 var IE_PROTO = sharedKey('IE_PROTO');
3016 var Object = global.Object;
3017 var ObjectPrototype = Object.prototype; // `Object.getPrototypeOf` method
3018 // https://tc39.es/ecma262/#sec-object.getprototypeof
3019
3020 module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
3021 var object = toObject(O);
3022 if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
3023 var constructor = object.constructor;
3024
3025 if (isCallable(constructor) && object instanceof constructor) {
3026 return constructor.prototype;
3027 }
3028
3029 return object instanceof Object ? ObjectPrototype : null;
3030 };
3031
3032 /***/ }),
3033 /* 100 */
3034 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3035
3036 var fails = __webpack_require__(6);
3037
3038 module.exports = !fails(function () {
3039 function F() {
3040 /* empty */
3041 }
3042
3043 F.prototype.constructor = null; // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
3044
3045 return Object.getPrototypeOf(new F()) !== F.prototype;
3046 });
3047
3048 /***/ }),
3049 /* 101 */
3050 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3051
3052 /* eslint-disable no-proto -- safe */
3053 var uncurryThis = __webpack_require__(12);
3054
3055 var anObject = __webpack_require__(42);
3056
3057 var aPossiblePrototype = __webpack_require__(102); // `Object.setPrototypeOf` method
3058 // https://tc39.es/ecma262/#sec-object.setprototypeof
3059 // Works with __proto__ only. Old v8 can't work with null proto objects.
3060 // eslint-disable-next-line es/no-object-setprototypeof -- safe
3061
3062
3063 module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () {
3064 var CORRECT_SETTER = false;
3065 var test = {};
3066 var setter;
3067
3068 try {
3069 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
3070 setter = uncurryThis(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
3071 setter(test, []);
3072 CORRECT_SETTER = test instanceof Array;
3073 } catch (error) {
3074 /* empty */
3075 }
3076
3077 return function setPrototypeOf(O, proto) {
3078 anObject(O);
3079 aPossiblePrototype(proto);
3080 if (CORRECT_SETTER) setter(O, proto);else O.__proto__ = proto;
3081 return O;
3082 };
3083 }() : undefined);
3084
3085 /***/ }),
3086 /* 102 */
3087 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3088
3089 var global = __webpack_require__(3);
3090
3091 var isCallable = __webpack_require__(18);
3092
3093 var String = global.String;
3094 var TypeError = global.TypeError;
3095
3096 module.exports = function (argument) {
3097 if (typeof argument == 'object' || isCallable(argument)) return argument;
3098 throw TypeError("Can't set " + String(argument) + ' as a prototype');
3099 };
3100
3101 /***/ }),
3102 /* 103 */
3103 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3104
3105 var uncurryThis = __webpack_require__(12);
3106
3107 var arraySlice = __webpack_require__(72);
3108
3109 var replace = uncurryThis(''.replace);
3110 var split = uncurryThis(''.split);
3111 var join = uncurryThis([].join);
3112
3113 var TEST = function (arg) {
3114 return String(Error(arg).stack);
3115 }('zxcasd');
3116
3117 var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/;
3118 var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST);
3119 var IS_FIREFOX_OR_SAFARI_STACK = /@[^\n]*\n/.test(TEST) && !/zxcasd/.test(TEST);
3120
3121 module.exports = function (stack, dropEntries) {
3122 if (typeof stack != 'string') return stack;
3123
3124 if (IS_V8_OR_CHAKRA_STACK) {
3125 while (dropEntries--) stack = replace(stack, V8_OR_CHAKRA_STACK_ENTRY, '');
3126 } else if (IS_FIREFOX_OR_SAFARI_STACK) {
3127 return join(arraySlice(split(stack, '\n'), dropEntries), '\n');
3128 }
3129
3130 return stack;
3131 };
3132
3133 /***/ }),
3134 /* 104 */
3135 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3136
3137 var isObject = __webpack_require__(17);
3138
3139 var createNonEnumerableProperty = __webpack_require__(40); // `InstallErrorCause` abstract operation
3140 // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
3141
3142
3143 module.exports = function (O, options) {
3144 if (isObject(options) && 'cause' in options) {
3145 createNonEnumerableProperty(O, 'cause', options.cause);
3146 }
3147 };
3148
3149 /***/ }),
3150 /* 105 */
3151 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3152
3153 var global = __webpack_require__(3);
3154
3155 var bind = __webpack_require__(80);
3156
3157 var call = __webpack_require__(7);
3158
3159 var anObject = __webpack_require__(42);
3160
3161 var tryToString = __webpack_require__(28);
3162
3163 var isArrayIteratorMethod = __webpack_require__(106);
3164
3165 var lengthOfArrayLike = __webpack_require__(57);
3166
3167 var isPrototypeOf = __webpack_require__(21);
3168
3169 var getIterator = __webpack_require__(108);
3170
3171 var getIteratorMethod = __webpack_require__(109);
3172
3173 var iteratorClose = __webpack_require__(110);
3174
3175 var TypeError = global.TypeError;
3176
3177 var Result = function (stopped, result) {
3178 this.stopped = stopped;
3179 this.result = result;
3180 };
3181
3182 var ResultPrototype = Result.prototype;
3183
3184 module.exports = function (iterable, unboundFunction, options) {
3185 var that = options && options.that;
3186 var AS_ENTRIES = !!(options && options.AS_ENTRIES);
3187 var IS_ITERATOR = !!(options && options.IS_ITERATOR);
3188 var INTERRUPTED = !!(options && options.INTERRUPTED);
3189 var fn = bind(unboundFunction, that);
3190 var iterator, iterFn, index, length, result, next, step;
3191
3192 var stop = function (condition) {
3193 if (iterator) iteratorClose(iterator, 'normal', condition);
3194 return new Result(true, condition);
3195 };
3196
3197 var callFn = function (value) {
3198 if (AS_ENTRIES) {
3199 anObject(value);
3200 return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
3201 }
3202
3203 return INTERRUPTED ? fn(value, stop) : fn(value);
3204 };
3205
3206 if (IS_ITERATOR) {
3207 iterator = iterable;
3208 } else {
3209 iterFn = getIteratorMethod(iterable);
3210 if (!iterFn) throw TypeError(tryToString(iterable) + ' is not iterable'); // optimisation for array iterators
3211
3212 if (isArrayIteratorMethod(iterFn)) {
3213 for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
3214 result = callFn(iterable[index]);
3215 if (result && isPrototypeOf(ResultPrototype, result)) return result;
3216 }
3217
3218 return new Result(false);
3219 }
3220
3221 iterator = getIterator(iterable, iterFn);
3222 }
3223
3224 next = iterator.next;
3225
3226 while (!(step = call(next, iterator)).done) {
3227 try {
3228 result = callFn(step.value);
3229 } catch (error) {
3230 iteratorClose(iterator, 'throw', error);
3231 }
3232
3233 if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
3234 }
3235
3236 return new Result(false);
3237 };
3238
3239 /***/ }),
3240 /* 106 */
3241 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3242
3243 var wellKnownSymbol = __webpack_require__(30);
3244
3245 var Iterators = __webpack_require__(107);
3246
3247 var ITERATOR = wellKnownSymbol('iterator');
3248 var ArrayPrototype = Array.prototype; // check on default Array iterator
3249
3250 module.exports = function (it) {
3251 return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
3252 };
3253
3254 /***/ }),
3255 /* 107 */
3256 /***/ ((module) => {
3257
3258 module.exports = {};
3259
3260 /***/ }),
3261 /* 108 */
3262 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3263
3264 var global = __webpack_require__(3);
3265
3266 var call = __webpack_require__(7);
3267
3268 var aCallable = __webpack_require__(27);
3269
3270 var anObject = __webpack_require__(42);
3271
3272 var tryToString = __webpack_require__(28);
3273
3274 var getIteratorMethod = __webpack_require__(109);
3275
3276 var TypeError = global.TypeError;
3277
3278 module.exports = function (argument, usingIterator) {
3279 var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
3280 if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));
3281 throw TypeError(tryToString(argument) + ' is not iterable');
3282 };
3283
3284 /***/ }),
3285 /* 109 */
3286 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3287
3288 var classof = __webpack_require__(65);
3289
3290 var getMethod = __webpack_require__(26);
3291
3292 var Iterators = __webpack_require__(107);
3293
3294 var wellKnownSymbol = __webpack_require__(30);
3295
3296 var ITERATOR = wellKnownSymbol('iterator');
3297
3298 module.exports = function (it) {
3299 if (it != undefined) return getMethod(it, ITERATOR) || getMethod(it, '@@iterator') || Iterators[classof(it)];
3300 };
3301
3302 /***/ }),
3303 /* 110 */
3304 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3305
3306 var call = __webpack_require__(7);
3307
3308 var anObject = __webpack_require__(42);
3309
3310 var getMethod = __webpack_require__(26);
3311
3312 module.exports = function (iterator, kind, value) {
3313 var innerResult, innerError;
3314 anObject(iterator);
3315
3316 try {
3317 innerResult = getMethod(iterator, 'return');
3318
3319 if (!innerResult) {
3320 if (kind === 'throw') throw value;
3321 return value;
3322 }
3323
3324 innerResult = call(innerResult, iterator);
3325 } catch (error) {
3326 innerError = true;
3327 innerResult = error;
3328 }
3329
3330 if (kind === 'throw') throw value;
3331 if (innerError) throw innerResult;
3332 anObject(innerResult);
3333 return value;
3334 };
3335
3336 /***/ }),
3337 /* 111 */
3338 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3339
3340 var toString = __webpack_require__(64);
3341
3342 module.exports = function (argument, $default) {
3343 return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument);
3344 };
3345
3346 /***/ }),
3347 /* 112 */
3348 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3349
3350 var fails = __webpack_require__(6);
3351
3352 var createPropertyDescriptor = __webpack_require__(9);
3353
3354 module.exports = !fails(function () {
3355 var error = Error('a');
3356 if (!('stack' in error)) return true; // eslint-disable-next-line es/no-object-defineproperty -- safe
3357
3358 Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7));
3359 return error.stack !== 7;
3360 });
3361
3362 /***/ }),
3363 /* 113 */
3364 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3365
3366 "use strict";
3367
3368
3369 var $ = __webpack_require__(2);
3370
3371 var toObject = __webpack_require__(36);
3372
3373 var lengthOfArrayLike = __webpack_require__(57);
3374
3375 var toIntegerOrInfinity = __webpack_require__(56);
3376
3377 var addToUnscopables = __webpack_require__(114); // `Array.prototype.at` method
3378 // https://github.com/tc39/proposal-relative-indexing-method
3379
3380
3381 $({
3382 target: 'Array',
3383 proto: true
3384 }, {
3385 at: function at(index) {
3386 var O = toObject(this);
3387 var len = lengthOfArrayLike(O);
3388 var relativeIndex = toIntegerOrInfinity(index);
3389 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex;
3390 return k < 0 || k >= len ? undefined : O[k];
3391 }
3392 });
3393 addToUnscopables('at');
3394
3395 /***/ }),
3396 /* 114 */
3397 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3398
3399 var wellKnownSymbol = __webpack_require__(30);
3400
3401 var create = __webpack_require__(67);
3402
3403 var definePropertyModule = __webpack_require__(41);
3404
3405 var UNSCOPABLES = wellKnownSymbol('unscopables');
3406 var ArrayPrototype = Array.prototype; // Array.prototype[@@unscopables]
3407 // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
3408
3409 if (ArrayPrototype[UNSCOPABLES] == undefined) {
3410 definePropertyModule.f(ArrayPrototype, UNSCOPABLES, {
3411 configurable: true,
3412 value: create(null)
3413 });
3414 } // add a key to Array.prototype[@@unscopables]
3415
3416
3417 module.exports = function (key) {
3418 ArrayPrototype[UNSCOPABLES][key] = true;
3419 };
3420
3421 /***/ }),
3422 /* 115 */
3423 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3424
3425 "use strict";
3426
3427
3428 var $ = __webpack_require__(2);
3429
3430 var global = __webpack_require__(3);
3431
3432 var fails = __webpack_require__(6);
3433
3434 var isArray = __webpack_require__(63);
3435
3436 var isObject = __webpack_require__(17);
3437
3438 var toObject = __webpack_require__(36);
3439
3440 var lengthOfArrayLike = __webpack_require__(57);
3441
3442 var createProperty = __webpack_require__(73);
3443
3444 var arraySpeciesCreate = __webpack_require__(81);
3445
3446 var arrayMethodHasSpeciesSupport = __webpack_require__(116);
3447
3448 var wellKnownSymbol = __webpack_require__(30);
3449
3450 var V8_VERSION = __webpack_require__(24);
3451
3452 var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
3453 var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
3454 var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
3455 var TypeError = global.TypeError; // We can't use this feature detection in V8 since it causes
3456 // deoptimization and serious performance degradation
3457 // https://github.com/zloirock/core-js/issues/679
3458
3459 var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {
3460 var array = [];
3461 array[IS_CONCAT_SPREADABLE] = false;
3462 return array.concat()[0] !== array;
3463 });
3464 var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
3465
3466 var isConcatSpreadable = function (O) {
3467 if (!isObject(O)) return false;
3468 var spreadable = O[IS_CONCAT_SPREADABLE];
3469 return spreadable !== undefined ? !!spreadable : isArray(O);
3470 };
3471
3472 var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT; // `Array.prototype.concat` method
3473 // https://tc39.es/ecma262/#sec-array.prototype.concat
3474 // with adding support of @@isConcatSpreadable and @@species
3475
3476 $({
3477 target: 'Array',
3478 proto: true,
3479 forced: FORCED
3480 }, {
3481 // eslint-disable-next-line no-unused-vars -- required for `.length`
3482 concat: function concat(arg) {
3483 var O = toObject(this);
3484 var A = arraySpeciesCreate(O, 0);
3485 var n = 0;
3486 var i, k, length, len, E;
3487
3488 for (i = -1, length = arguments.length; i < length; i++) {
3489 E = i === -1 ? O : arguments[i];
3490
3491 if (isConcatSpreadable(E)) {
3492 len = lengthOfArrayLike(E);
3493 if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
3494
3495 for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
3496 } else {
3497 if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
3498 createProperty(A, n++, E);
3499 }
3500 }
3501
3502 A.length = n;
3503 return A;
3504 }
3505 });
3506
3507 /***/ }),
3508 /* 116 */
3509 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3510
3511 var fails = __webpack_require__(6);
3512
3513 var wellKnownSymbol = __webpack_require__(30);
3514
3515 var V8_VERSION = __webpack_require__(24);
3516
3517 var SPECIES = wellKnownSymbol('species');
3518
3519 module.exports = function (METHOD_NAME) {
3520 // We can't use this feature detection in V8 since it causes
3521 // deoptimization and serious performance degradation
3522 // https://github.com/zloirock/core-js/issues/677
3523 return V8_VERSION >= 51 || !fails(function () {
3524 var array = [];
3525 var constructor = array.constructor = {};
3526
3527 constructor[SPECIES] = function () {
3528 return {
3529 foo: 1
3530 };
3531 };
3532
3533 return array[METHOD_NAME](Boolean).foo !== 1;
3534 });
3535 };
3536
3537 /***/ }),
3538 /* 117 */
3539 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3540
3541 var $ = __webpack_require__(2);
3542
3543 var copyWithin = __webpack_require__(118);
3544
3545 var addToUnscopables = __webpack_require__(114); // `Array.prototype.copyWithin` method
3546 // https://tc39.es/ecma262/#sec-array.prototype.copywithin
3547
3548
3549 $({
3550 target: 'Array',
3551 proto: true
3552 }, {
3553 copyWithin: copyWithin
3554 }); // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
3555
3556 addToUnscopables('copyWithin');
3557
3558 /***/ }),
3559 /* 118 */
3560 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3561
3562 "use strict";
3563
3564
3565 var toObject = __webpack_require__(36);
3566
3567 var toAbsoluteIndex = __webpack_require__(55);
3568
3569 var lengthOfArrayLike = __webpack_require__(57);
3570
3571 var min = Math.min; // `Array.prototype.copyWithin` method implementation
3572 // https://tc39.es/ecma262/#sec-array.prototype.copywithin
3573 // eslint-disable-next-line es/no-array-prototype-copywithin -- safe
3574
3575 module.exports = [].copyWithin || function copyWithin(target
3576 /* = 0 */
3577 , start
3578 /* = 0, end = @length */
3579 ) {
3580 var O = toObject(this);
3581 var len = lengthOfArrayLike(O);
3582 var to = toAbsoluteIndex(target, len);
3583 var from = toAbsoluteIndex(start, len);
3584 var end = arguments.length > 2 ? arguments[2] : undefined;
3585 var count = min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);
3586 var inc = 1;
3587
3588 if (from < to && to < from + count) {
3589 inc = -1;
3590 from += count - 1;
3591 to += count - 1;
3592 }
3593
3594 while (count-- > 0) {
3595 if (from in O) O[to] = O[from];else delete O[to];
3596 to += inc;
3597 from += inc;
3598 }
3599
3600 return O;
3601 };
3602
3603 /***/ }),
3604 /* 119 */
3605 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3606
3607 "use strict";
3608
3609
3610 var $ = __webpack_require__(2);
3611
3612 var $every = (__webpack_require__(79).every);
3613
3614 var arrayMethodIsStrict = __webpack_require__(120);
3615
3616 var STRICT_METHOD = arrayMethodIsStrict('every'); // `Array.prototype.every` method
3617 // https://tc39.es/ecma262/#sec-array.prototype.every
3618
3619 $({
3620 target: 'Array',
3621 proto: true,
3622 forced: !STRICT_METHOD
3623 }, {
3624 every: function every(callbackfn
3625 /* , thisArg */
3626 ) {
3627 return $every(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
3628 }
3629 });
3630
3631 /***/ }),
3632 /* 120 */
3633 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3634
3635 "use strict";
3636
3637
3638 var fails = __webpack_require__(6);
3639
3640 module.exports = function (METHOD_NAME, argument) {
3641 var method = [][METHOD_NAME];
3642 return !!method && fails(function () {
3643 // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
3644 method.call(null, argument || function () {
3645 throw 1;
3646 }, 1);
3647 });
3648 };
3649
3650 /***/ }),
3651 /* 121 */
3652 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3653
3654 var $ = __webpack_require__(2);
3655
3656 var fill = __webpack_require__(122);
3657
3658 var addToUnscopables = __webpack_require__(114); // `Array.prototype.fill` method
3659 // https://tc39.es/ecma262/#sec-array.prototype.fill
3660
3661
3662 $({
3663 target: 'Array',
3664 proto: true
3665 }, {
3666 fill: fill
3667 }); // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
3668
3669 addToUnscopables('fill');
3670
3671 /***/ }),
3672 /* 122 */
3673 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3674
3675 "use strict";
3676
3677
3678 var toObject = __webpack_require__(36);
3679
3680 var toAbsoluteIndex = __webpack_require__(55);
3681
3682 var lengthOfArrayLike = __webpack_require__(57); // `Array.prototype.fill` method implementation
3683 // https://tc39.es/ecma262/#sec-array.prototype.fill
3684
3685
3686 module.exports = function fill(value
3687 /* , start = 0, end = @length */
3688 ) {
3689 var O = toObject(this);
3690 var length = lengthOfArrayLike(O);
3691 var argumentsLength = arguments.length;
3692 var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);
3693 var end = argumentsLength > 2 ? arguments[2] : undefined;
3694 var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
3695
3696 while (endPos > index) O[index++] = value;
3697
3698 return O;
3699 };
3700
3701 /***/ }),
3702 /* 123 */
3703 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3704
3705 "use strict";
3706
3707
3708 var $ = __webpack_require__(2);
3709
3710 var $filter = (__webpack_require__(79).filter);
3711
3712 var arrayMethodHasSpeciesSupport = __webpack_require__(116);
3713
3714 var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter'); // `Array.prototype.filter` method
3715 // https://tc39.es/ecma262/#sec-array.prototype.filter
3716 // with adding support of @@species
3717
3718 $({
3719 target: 'Array',
3720 proto: true,
3721 forced: !HAS_SPECIES_SUPPORT
3722 }, {
3723 filter: function filter(callbackfn
3724 /* , thisArg */
3725 ) {
3726 return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
3727 }
3728 });
3729
3730 /***/ }),
3731 /* 124 */
3732 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3733
3734 "use strict";
3735
3736
3737 var $ = __webpack_require__(2);
3738
3739 var $find = (__webpack_require__(79).find);
3740
3741 var addToUnscopables = __webpack_require__(114);
3742
3743 var FIND = 'find';
3744 var SKIPS_HOLES = true; // Shouldn't skip holes
3745
3746 if (FIND in []) Array(1)[FIND](function () {
3747 SKIPS_HOLES = false;
3748 }); // `Array.prototype.find` method
3749 // https://tc39.es/ecma262/#sec-array.prototype.find
3750
3751 $({
3752 target: 'Array',
3753 proto: true,
3754 forced: SKIPS_HOLES
3755 }, {
3756 find: function find(callbackfn
3757 /* , that = undefined */
3758 ) {
3759 return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
3760 }
3761 }); // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
3762
3763 addToUnscopables(FIND);
3764
3765 /***/ }),
3766 /* 125 */
3767 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3768
3769 "use strict";
3770
3771
3772 var $ = __webpack_require__(2);
3773
3774 var $findIndex = (__webpack_require__(79).findIndex);
3775
3776 var addToUnscopables = __webpack_require__(114);
3777
3778 var FIND_INDEX = 'findIndex';
3779 var SKIPS_HOLES = true; // Shouldn't skip holes
3780
3781 if (FIND_INDEX in []) Array(1)[FIND_INDEX](function () {
3782 SKIPS_HOLES = false;
3783 }); // `Array.prototype.findIndex` method
3784 // https://tc39.es/ecma262/#sec-array.prototype.findindex
3785
3786 $({
3787 target: 'Array',
3788 proto: true,
3789 forced: SKIPS_HOLES
3790 }, {
3791 findIndex: function findIndex(callbackfn
3792 /* , that = undefined */
3793 ) {
3794 return $findIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
3795 }
3796 }); // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
3797
3798 addToUnscopables(FIND_INDEX);
3799
3800 /***/ }),
3801 /* 126 */
3802 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3803
3804 "use strict";
3805
3806
3807 var $ = __webpack_require__(2);
3808
3809 var flattenIntoArray = __webpack_require__(127);
3810
3811 var toObject = __webpack_require__(36);
3812
3813 var lengthOfArrayLike = __webpack_require__(57);
3814
3815 var toIntegerOrInfinity = __webpack_require__(56);
3816
3817 var arraySpeciesCreate = __webpack_require__(81); // `Array.prototype.flat` method
3818 // https://tc39.es/ecma262/#sec-array.prototype.flat
3819
3820
3821 $({
3822 target: 'Array',
3823 proto: true
3824 }, {
3825 flat: function
3826 /* depthArg = 1 */
3827 flat() {
3828 var depthArg = arguments.length ? arguments[0] : undefined;
3829 var O = toObject(this);
3830 var sourceLen = lengthOfArrayLike(O);
3831 var A = arraySpeciesCreate(O, 0);
3832 A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
3833 return A;
3834 }
3835 });
3836
3837 /***/ }),
3838 /* 127 */
3839 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3840
3841 "use strict";
3842
3843
3844 var global = __webpack_require__(3);
3845
3846 var isArray = __webpack_require__(63);
3847
3848 var lengthOfArrayLike = __webpack_require__(57);
3849
3850 var bind = __webpack_require__(80);
3851
3852 var TypeError = global.TypeError; // `FlattenIntoArray` abstract operation
3853 // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
3854
3855 var flattenIntoArray = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
3856 var targetIndex = start;
3857 var sourceIndex = 0;
3858 var mapFn = mapper ? bind(mapper, thisArg) : false;
3859 var element, elementLen;
3860
3861 while (sourceIndex < sourceLen) {
3862 if (sourceIndex in source) {
3863 element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
3864
3865 if (depth > 0 && isArray(element)) {
3866 elementLen = lengthOfArrayLike(element);
3867 targetIndex = flattenIntoArray(target, original, element, elementLen, targetIndex, depth - 1) - 1;
3868 } else {
3869 if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError('Exceed the acceptable array length');
3870 target[targetIndex] = element;
3871 }
3872
3873 targetIndex++;
3874 }
3875
3876 sourceIndex++;
3877 }
3878
3879 return targetIndex;
3880 };
3881
3882 module.exports = flattenIntoArray;
3883
3884 /***/ }),
3885 /* 128 */
3886 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3887
3888 "use strict";
3889
3890
3891 var $ = __webpack_require__(2);
3892
3893 var flattenIntoArray = __webpack_require__(127);
3894
3895 var aCallable = __webpack_require__(27);
3896
3897 var toObject = __webpack_require__(36);
3898
3899 var lengthOfArrayLike = __webpack_require__(57);
3900
3901 var arraySpeciesCreate = __webpack_require__(81); // `Array.prototype.flatMap` method
3902 // https://tc39.es/ecma262/#sec-array.prototype.flatmap
3903
3904
3905 $({
3906 target: 'Array',
3907 proto: true
3908 }, {
3909 flatMap: function flatMap(callbackfn
3910 /* , thisArg */
3911 ) {
3912 var O = toObject(this);
3913 var sourceLen = lengthOfArrayLike(O);
3914 var A;
3915 aCallable(callbackfn);
3916 A = arraySpeciesCreate(O, 0);
3917 A.length = flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
3918 return A;
3919 }
3920 });
3921
3922 /***/ }),
3923 /* 129 */
3924 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3925
3926 "use strict";
3927
3928
3929 var $ = __webpack_require__(2);
3930
3931 var forEach = __webpack_require__(130); // `Array.prototype.forEach` method
3932 // https://tc39.es/ecma262/#sec-array.prototype.foreach
3933 // eslint-disable-next-line es/no-array-prototype-foreach -- safe
3934
3935
3936 $({
3937 target: 'Array',
3938 proto: true,
3939 forced: [].forEach != forEach
3940 }, {
3941 forEach: forEach
3942 });
3943
3944 /***/ }),
3945 /* 130 */
3946 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3947
3948 "use strict";
3949
3950
3951 var $forEach = (__webpack_require__(79).forEach);
3952
3953 var arrayMethodIsStrict = __webpack_require__(120);
3954
3955 var STRICT_METHOD = arrayMethodIsStrict('forEach'); // `Array.prototype.forEach` method implementation
3956 // https://tc39.es/ecma262/#sec-array.prototype.foreach
3957
3958 module.exports = !STRICT_METHOD ? function forEach(callbackfn
3959 /* , thisArg */
3960 ) {
3961 return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); // eslint-disable-next-line es/no-array-prototype-foreach -- safe
3962 } : [].forEach;
3963
3964 /***/ }),
3965 /* 131 */
3966 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
3967
3968 var $ = __webpack_require__(2);
3969
3970 var from = __webpack_require__(132);
3971
3972 var checkCorrectnessOfIteration = __webpack_require__(134);
3973
3974 var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
3975 // eslint-disable-next-line es/no-array-from -- required for testing
3976 Array.from(iterable);
3977 }); // `Array.from` method
3978 // https://tc39.es/ecma262/#sec-array.from
3979
3980 $({
3981 target: 'Array',
3982 stat: true,
3983 forced: INCORRECT_ITERATION
3984 }, {
3985 from: from
3986 });
3987
3988 /***/ }),
3989 /* 132 */
3990 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
3991
3992 "use strict";
3993
3994
3995 var global = __webpack_require__(3);
3996
3997 var bind = __webpack_require__(80);
3998
3999 var call = __webpack_require__(7);
4000
4001 var toObject = __webpack_require__(36);
4002
4003 var callWithSafeIterationClosing = __webpack_require__(133);
4004
4005 var isArrayIteratorMethod = __webpack_require__(106);
4006
4007 var isConstructor = __webpack_require__(83);
4008
4009 var lengthOfArrayLike = __webpack_require__(57);
4010
4011 var createProperty = __webpack_require__(73);
4012
4013 var getIterator = __webpack_require__(108);
4014
4015 var getIteratorMethod = __webpack_require__(109);
4016
4017 var Array = global.Array; // `Array.from` method implementation
4018 // https://tc39.es/ecma262/#sec-array.from
4019
4020 module.exports = function from(arrayLike
4021 /* , mapfn = undefined, thisArg = undefined */
4022 ) {
4023 var O = toObject(arrayLike);
4024 var IS_CONSTRUCTOR = isConstructor(this);
4025 var argumentsLength = arguments.length;
4026 var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
4027 var mapping = mapfn !== undefined;
4028 if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
4029 var iteratorMethod = getIteratorMethod(O);
4030 var index = 0;
4031 var length, result, step, iterator, next, value; // if the target is not iterable or it's an array with the default iterator - use a simple case
4032
4033 if (iteratorMethod && !(this == Array && isArrayIteratorMethod(iteratorMethod))) {
4034 iterator = getIterator(O, iteratorMethod);
4035 next = iterator.next;
4036 result = IS_CONSTRUCTOR ? new this() : [];
4037
4038 for (; !(step = call(next, iterator)).done; index++) {
4039 value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
4040 createProperty(result, index, value);
4041 }
4042 } else {
4043 length = lengthOfArrayLike(O);
4044 result = IS_CONSTRUCTOR ? new this(length) : Array(length);
4045
4046 for (; length > index; index++) {
4047 value = mapping ? mapfn(O[index], index) : O[index];
4048 createProperty(result, index, value);
4049 }
4050 }
4051
4052 result.length = index;
4053 return result;
4054 };
4055
4056 /***/ }),
4057 /* 133 */
4058 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4059
4060 var anObject = __webpack_require__(42);
4061
4062 var iteratorClose = __webpack_require__(110); // call something on iterator step with safe closing on error
4063
4064
4065 module.exports = function (iterator, fn, value, ENTRIES) {
4066 try {
4067 return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
4068 } catch (error) {
4069 iteratorClose(iterator, 'throw', error);
4070 }
4071 };
4072
4073 /***/ }),
4074 /* 134 */
4075 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4076
4077 var wellKnownSymbol = __webpack_require__(30);
4078
4079 var ITERATOR = wellKnownSymbol('iterator');
4080 var SAFE_CLOSING = false;
4081
4082 try {
4083 var called = 0;
4084 var iteratorWithReturn = {
4085 next: function () {
4086 return {
4087 done: !!called++
4088 };
4089 },
4090 'return': function () {
4091 SAFE_CLOSING = true;
4092 }
4093 };
4094
4095 iteratorWithReturn[ITERATOR] = function () {
4096 return this;
4097 }; // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
4098
4099
4100 Array.from(iteratorWithReturn, function () {
4101 throw 2;
4102 });
4103 } catch (error) {
4104 /* empty */
4105 }
4106
4107 module.exports = function (exec, SKIP_CLOSING) {
4108 if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
4109 var ITERATION_SUPPORT = false;
4110
4111 try {
4112 var object = {};
4113
4114 object[ITERATOR] = function () {
4115 return {
4116 next: function () {
4117 return {
4118 done: ITERATION_SUPPORT = true
4119 };
4120 }
4121 };
4122 };
4123
4124 exec(object);
4125 } catch (error) {
4126 /* empty */
4127 }
4128
4129 return ITERATION_SUPPORT;
4130 };
4131
4132 /***/ }),
4133 /* 135 */
4134 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4135
4136 "use strict";
4137
4138
4139 var $ = __webpack_require__(2);
4140
4141 var $includes = (__webpack_require__(54).includes);
4142
4143 var addToUnscopables = __webpack_require__(114); // `Array.prototype.includes` method
4144 // https://tc39.es/ecma262/#sec-array.prototype.includes
4145
4146
4147 $({
4148 target: 'Array',
4149 proto: true
4150 }, {
4151 includes: function includes(el
4152 /* , fromIndex = 0 */
4153 ) {
4154 return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
4155 }
4156 }); // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
4157
4158 addToUnscopables('includes');
4159
4160 /***/ }),
4161 /* 136 */
4162 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4163
4164 "use strict";
4165
4166 /* eslint-disable es/no-array-prototype-indexof -- required for testing */
4167
4168 var $ = __webpack_require__(2);
4169
4170 var uncurryThis = __webpack_require__(12);
4171
4172 var $IndexOf = (__webpack_require__(54).indexOf);
4173
4174 var arrayMethodIsStrict = __webpack_require__(120);
4175
4176 var un$IndexOf = uncurryThis([].indexOf);
4177 var NEGATIVE_ZERO = !!un$IndexOf && 1 / un$IndexOf([1], 1, -0) < 0;
4178 var STRICT_METHOD = arrayMethodIsStrict('indexOf'); // `Array.prototype.indexOf` method
4179 // https://tc39.es/ecma262/#sec-array.prototype.indexof
4180
4181 $({
4182 target: 'Array',
4183 proto: true,
4184 forced: NEGATIVE_ZERO || !STRICT_METHOD
4185 }, {
4186 indexOf: function indexOf(searchElement
4187 /* , fromIndex = 0 */
4188 ) {
4189 var fromIndex = arguments.length > 1 ? arguments[1] : undefined;
4190 return NEGATIVE_ZERO // convert -0 to +0
4191 ? un$IndexOf(this, searchElement, fromIndex) || 0 : $IndexOf(this, searchElement, fromIndex);
4192 }
4193 });
4194
4195 /***/ }),
4196 /* 137 */
4197 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4198
4199 var $ = __webpack_require__(2);
4200
4201 var isArray = __webpack_require__(63); // `Array.isArray` method
4202 // https://tc39.es/ecma262/#sec-array.isarray
4203
4204
4205 $({
4206 target: 'Array',
4207 stat: true
4208 }, {
4209 isArray: isArray
4210 });
4211
4212 /***/ }),
4213 /* 138 */
4214 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4215
4216 "use strict";
4217
4218
4219 var toIndexedObject = __webpack_require__(10);
4220
4221 var addToUnscopables = __webpack_require__(114);
4222
4223 var Iterators = __webpack_require__(107);
4224
4225 var InternalStateModule = __webpack_require__(45);
4226
4227 var defineIterator = __webpack_require__(139);
4228
4229 var ARRAY_ITERATOR = 'Array Iterator';
4230 var setInternalState = InternalStateModule.set;
4231 var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR); // `Array.prototype.entries` method
4232 // https://tc39.es/ecma262/#sec-array.prototype.entries
4233 // `Array.prototype.keys` method
4234 // https://tc39.es/ecma262/#sec-array.prototype.keys
4235 // `Array.prototype.values` method
4236 // https://tc39.es/ecma262/#sec-array.prototype.values
4237 // `Array.prototype[@@iterator]` method
4238 // https://tc39.es/ecma262/#sec-array.prototype-@@iterator
4239 // `CreateArrayIterator` internal method
4240 // https://tc39.es/ecma262/#sec-createarrayiterator
4241
4242 module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
4243 setInternalState(this, {
4244 type: ARRAY_ITERATOR,
4245 target: toIndexedObject(iterated),
4246 // target
4247 index: 0,
4248 // next index
4249 kind: kind // kind
4250
4251 }); // `%ArrayIteratorPrototype%.next` method
4252 // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
4253 }, function () {
4254 var state = getInternalState(this);
4255 var target = state.target;
4256 var kind = state.kind;
4257 var index = state.index++;
4258
4259 if (!target || index >= target.length) {
4260 state.target = undefined;
4261 return {
4262 value: undefined,
4263 done: true
4264 };
4265 }
4266
4267 if (kind == 'keys') return {
4268 value: index,
4269 done: false
4270 };
4271 if (kind == 'values') return {
4272 value: target[index],
4273 done: false
4274 };
4275 return {
4276 value: [index, target[index]],
4277 done: false
4278 };
4279 }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values%
4280 // https://tc39.es/ecma262/#sec-createunmappedargumentsobject
4281 // https://tc39.es/ecma262/#sec-createmappedargumentsobject
4282
4283 Iterators.Arguments = Iterators.Array; // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
4284
4285 addToUnscopables('keys');
4286 addToUnscopables('values');
4287 addToUnscopables('entries');
4288
4289 /***/ }),
4290 /* 139 */
4291 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4292
4293 "use strict";
4294
4295
4296 var $ = __webpack_require__(2);
4297
4298 var call = __webpack_require__(7);
4299
4300 var IS_PURE = __webpack_require__(32);
4301
4302 var FunctionName = __webpack_require__(49);
4303
4304 var isCallable = __webpack_require__(18);
4305
4306 var createIteratorConstructor = __webpack_require__(140);
4307
4308 var getPrototypeOf = __webpack_require__(99);
4309
4310 var setPrototypeOf = __webpack_require__(101);
4311
4312 var setToStringTag = __webpack_require__(78);
4313
4314 var createNonEnumerableProperty = __webpack_require__(40);
4315
4316 var redefine = __webpack_require__(43);
4317
4318 var wellKnownSymbol = __webpack_require__(30);
4319
4320 var Iterators = __webpack_require__(107);
4321
4322 var IteratorsCore = __webpack_require__(141);
4323
4324 var PROPER_FUNCTION_NAME = FunctionName.PROPER;
4325 var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
4326 var IteratorPrototype = IteratorsCore.IteratorPrototype;
4327 var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
4328 var ITERATOR = wellKnownSymbol('iterator');
4329 var KEYS = 'keys';
4330 var VALUES = 'values';
4331 var ENTRIES = 'entries';
4332
4333 var returnThis = function () {
4334 return this;
4335 };
4336
4337 module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
4338 createIteratorConstructor(IteratorConstructor, NAME, next);
4339
4340 var getIterationMethod = function (KIND) {
4341 if (KIND === DEFAULT && defaultIterator) return defaultIterator;
4342 if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
4343
4344 switch (KIND) {
4345 case KEYS:
4346 return function keys() {
4347 return new IteratorConstructor(this, KIND);
4348 };
4349
4350 case VALUES:
4351 return function values() {
4352 return new IteratorConstructor(this, KIND);
4353 };
4354
4355 case ENTRIES:
4356 return function entries() {
4357 return new IteratorConstructor(this, KIND);
4358 };
4359 }
4360
4361 return function () {
4362 return new IteratorConstructor(this);
4363 };
4364 };
4365
4366 var TO_STRING_TAG = NAME + ' Iterator';
4367 var INCORRECT_VALUES_NAME = false;
4368 var IterablePrototype = Iterable.prototype;
4369 var nativeIterator = IterablePrototype[ITERATOR] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT];
4370 var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
4371 var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
4372 var CurrentIteratorPrototype, methods, KEY; // fix native
4373
4374 if (anyNativeIterator) {
4375 CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
4376
4377 if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
4378 if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
4379 if (setPrototypeOf) {
4380 setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
4381 } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {
4382 redefine(CurrentIteratorPrototype, ITERATOR, returnThis);
4383 }
4384 } // Set @@toStringTag to native iterators
4385
4386
4387 setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true);
4388 if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis;
4389 }
4390 } // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
4391
4392
4393 if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
4394 if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) {
4395 createNonEnumerableProperty(IterablePrototype, 'name', VALUES);
4396 } else {
4397 INCORRECT_VALUES_NAME = true;
4398
4399 defaultIterator = function values() {
4400 return call(nativeIterator, this);
4401 };
4402 }
4403 } // export additional methods
4404
4405
4406 if (DEFAULT) {
4407 methods = {
4408 values: getIterationMethod(VALUES),
4409 keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
4410 entries: getIterationMethod(ENTRIES)
4411 };
4412 if (FORCED) for (KEY in methods) {
4413 if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
4414 redefine(IterablePrototype, KEY, methods[KEY]);
4415 }
4416 } else $({
4417 target: NAME,
4418 proto: true,
4419 forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME
4420 }, methods);
4421 } // define iterator
4422
4423
4424 if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) {
4425 redefine(IterablePrototype, ITERATOR, defaultIterator, {
4426 name: DEFAULT
4427 });
4428 }
4429
4430 Iterators[NAME] = defaultIterator;
4431 return methods;
4432 };
4433
4434 /***/ }),
4435 /* 140 */
4436 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4437
4438 "use strict";
4439
4440
4441 var IteratorPrototype = (__webpack_require__(141).IteratorPrototype);
4442
4443 var create = __webpack_require__(67);
4444
4445 var createPropertyDescriptor = __webpack_require__(9);
4446
4447 var setToStringTag = __webpack_require__(78);
4448
4449 var Iterators = __webpack_require__(107);
4450
4451 var returnThis = function () {
4452 return this;
4453 };
4454
4455 module.exports = function (IteratorConstructor, NAME, next) {
4456 var TO_STRING_TAG = NAME + ' Iterator';
4457 IteratorConstructor.prototype = create(IteratorPrototype, {
4458 next: createPropertyDescriptor(1, next)
4459 });
4460 setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true);
4461 Iterators[TO_STRING_TAG] = returnThis;
4462 return IteratorConstructor;
4463 };
4464
4465 /***/ }),
4466 /* 141 */
4467 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4468
4469 "use strict";
4470
4471
4472 var fails = __webpack_require__(6);
4473
4474 var isCallable = __webpack_require__(18);
4475
4476 var create = __webpack_require__(67);
4477
4478 var getPrototypeOf = __webpack_require__(99);
4479
4480 var redefine = __webpack_require__(43);
4481
4482 var wellKnownSymbol = __webpack_require__(30);
4483
4484 var IS_PURE = __webpack_require__(32);
4485
4486 var ITERATOR = wellKnownSymbol('iterator');
4487 var BUGGY_SAFARI_ITERATORS = false; // `%IteratorPrototype%` object
4488 // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
4489
4490 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
4491 /* eslint-disable es/no-array-prototype-keys -- safe */
4492
4493 if ([].keys) {
4494 arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next`
4495
4496 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;else {
4497 PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
4498 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
4499 }
4500 }
4501
4502 var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () {
4503 var test = {}; // FF44- legacy iterators case
4504
4505 return IteratorPrototype[ITERATOR].call(test) !== test;
4506 });
4507 if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};else if (IS_PURE) IteratorPrototype = create(IteratorPrototype); // `%IteratorPrototype%[@@iterator]()` method
4508 // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
4509
4510 if (!isCallable(IteratorPrototype[ITERATOR])) {
4511 redefine(IteratorPrototype, ITERATOR, function () {
4512 return this;
4513 });
4514 }
4515
4516 module.exports = {
4517 IteratorPrototype: IteratorPrototype,
4518 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
4519 };
4520
4521 /***/ }),
4522 /* 142 */
4523 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4524
4525 "use strict";
4526
4527
4528 var $ = __webpack_require__(2);
4529
4530 var uncurryThis = __webpack_require__(12);
4531
4532 var IndexedObject = __webpack_require__(11);
4533
4534 var toIndexedObject = __webpack_require__(10);
4535
4536 var arrayMethodIsStrict = __webpack_require__(120);
4537
4538 var un$Join = uncurryThis([].join);
4539 var ES3_STRINGS = IndexedObject != Object;
4540 var STRICT_METHOD = arrayMethodIsStrict('join', ','); // `Array.prototype.join` method
4541 // https://tc39.es/ecma262/#sec-array.prototype.join
4542
4543 $({
4544 target: 'Array',
4545 proto: true,
4546 forced: ES3_STRINGS || !STRICT_METHOD
4547 }, {
4548 join: function join(separator) {
4549 return un$Join(toIndexedObject(this), separator === undefined ? ',' : separator);
4550 }
4551 });
4552
4553 /***/ }),
4554 /* 143 */
4555 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4556
4557 var $ = __webpack_require__(2);
4558
4559 var lastIndexOf = __webpack_require__(144); // `Array.prototype.lastIndexOf` method
4560 // https://tc39.es/ecma262/#sec-array.prototype.lastindexof
4561 // eslint-disable-next-line es/no-array-prototype-lastindexof -- required for testing
4562
4563
4564 $({
4565 target: 'Array',
4566 proto: true,
4567 forced: lastIndexOf !== [].lastIndexOf
4568 }, {
4569 lastIndexOf: lastIndexOf
4570 });
4571
4572 /***/ }),
4573 /* 144 */
4574 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4575
4576 "use strict";
4577
4578 /* eslint-disable es/no-array-prototype-lastindexof -- safe */
4579
4580 var apply = __webpack_require__(62);
4581
4582 var toIndexedObject = __webpack_require__(10);
4583
4584 var toIntegerOrInfinity = __webpack_require__(56);
4585
4586 var lengthOfArrayLike = __webpack_require__(57);
4587
4588 var arrayMethodIsStrict = __webpack_require__(120);
4589
4590 var min = Math.min;
4591 var $lastIndexOf = [].lastIndexOf;
4592 var NEGATIVE_ZERO = !!$lastIndexOf && 1 / [1].lastIndexOf(1, -0) < 0;
4593 var STRICT_METHOD = arrayMethodIsStrict('lastIndexOf');
4594 var FORCED = NEGATIVE_ZERO || !STRICT_METHOD; // `Array.prototype.lastIndexOf` method implementation
4595 // https://tc39.es/ecma262/#sec-array.prototype.lastindexof
4596
4597 module.exports = FORCED ? function lastIndexOf(searchElement
4598 /* , fromIndex = @[*-1] */
4599 ) {
4600 // convert -0 to +0
4601 if (NEGATIVE_ZERO) return apply($lastIndexOf, this, arguments) || 0;
4602 var O = toIndexedObject(this);
4603 var length = lengthOfArrayLike(O);
4604 var index = length - 1;
4605 if (arguments.length > 1) index = min(index, toIntegerOrInfinity(arguments[1]));
4606 if (index < 0) index = length + index;
4607
4608 for (; index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0;
4609
4610 return -1;
4611 } : $lastIndexOf;
4612
4613 /***/ }),
4614 /* 145 */
4615 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4616
4617 "use strict";
4618
4619
4620 var $ = __webpack_require__(2);
4621
4622 var $map = (__webpack_require__(79).map);
4623
4624 var arrayMethodHasSpeciesSupport = __webpack_require__(116);
4625
4626 var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('map'); // `Array.prototype.map` method
4627 // https://tc39.es/ecma262/#sec-array.prototype.map
4628 // with adding support of @@species
4629
4630 $({
4631 target: 'Array',
4632 proto: true,
4633 forced: !HAS_SPECIES_SUPPORT
4634 }, {
4635 map: function map(callbackfn
4636 /* , thisArg */
4637 ) {
4638 return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
4639 }
4640 });
4641
4642 /***/ }),
4643 /* 146 */
4644 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4645
4646 "use strict";
4647
4648
4649 var $ = __webpack_require__(2);
4650
4651 var global = __webpack_require__(3);
4652
4653 var fails = __webpack_require__(6);
4654
4655 var isConstructor = __webpack_require__(83);
4656
4657 var createProperty = __webpack_require__(73);
4658
4659 var Array = global.Array;
4660 var ISNT_GENERIC = fails(function () {
4661 function F() {
4662 /* empty */
4663 }
4664
4665 return !(Array.of.call(F) instanceof F);
4666 }); // `Array.of` method
4667 // https://tc39.es/ecma262/#sec-array.of
4668 // WebKit Array.of isn't generic
4669
4670 $({
4671 target: 'Array',
4672 stat: true,
4673 forced: ISNT_GENERIC
4674 }, {
4675 of: function
4676 /* ...args */
4677 of() {
4678 var index = 0;
4679 var argumentsLength = arguments.length;
4680 var result = new (isConstructor(this) ? this : Array)(argumentsLength);
4681
4682 while (argumentsLength > index) createProperty(result, index, arguments[index++]);
4683
4684 result.length = argumentsLength;
4685 return result;
4686 }
4687 });
4688
4689 /***/ }),
4690 /* 147 */
4691 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4692
4693 "use strict";
4694
4695
4696 var $ = __webpack_require__(2);
4697
4698 var $reduce = (__webpack_require__(148).left);
4699
4700 var arrayMethodIsStrict = __webpack_require__(120);
4701
4702 var CHROME_VERSION = __webpack_require__(24);
4703
4704 var IS_NODE = __webpack_require__(149);
4705
4706 var STRICT_METHOD = arrayMethodIsStrict('reduce'); // Chrome 80-82 has a critical bug
4707 // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
4708
4709 var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83; // `Array.prototype.reduce` method
4710 // https://tc39.es/ecma262/#sec-array.prototype.reduce
4711
4712 $({
4713 target: 'Array',
4714 proto: true,
4715 forced: !STRICT_METHOD || CHROME_BUG
4716 }, {
4717 reduce: function reduce(callbackfn
4718 /* , initialValue */
4719 ) {
4720 var length = arguments.length;
4721 return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
4722 }
4723 });
4724
4725 /***/ }),
4726 /* 148 */
4727 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4728
4729 var global = __webpack_require__(3);
4730
4731 var aCallable = __webpack_require__(27);
4732
4733 var toObject = __webpack_require__(36);
4734
4735 var IndexedObject = __webpack_require__(11);
4736
4737 var lengthOfArrayLike = __webpack_require__(57);
4738
4739 var TypeError = global.TypeError; // `Array.prototype.{ reduce, reduceRight }` methods implementation
4740
4741 var createMethod = function (IS_RIGHT) {
4742 return function (that, callbackfn, argumentsLength, memo) {
4743 aCallable(callbackfn);
4744 var O = toObject(that);
4745 var self = IndexedObject(O);
4746 var length = lengthOfArrayLike(O);
4747 var index = IS_RIGHT ? length - 1 : 0;
4748 var i = IS_RIGHT ? -1 : 1;
4749 if (argumentsLength < 2) while (true) {
4750 if (index in self) {
4751 memo = self[index];
4752 index += i;
4753 break;
4754 }
4755
4756 index += i;
4757
4758 if (IS_RIGHT ? index < 0 : length <= index) {
4759 throw TypeError('Reduce of empty array with no initial value');
4760 }
4761 }
4762
4763 for (; IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) {
4764 memo = callbackfn(memo, self[index], index, O);
4765 }
4766
4767 return memo;
4768 };
4769 };
4770
4771 module.exports = {
4772 // `Array.prototype.reduce` method
4773 // https://tc39.es/ecma262/#sec-array.prototype.reduce
4774 left: createMethod(false),
4775 // `Array.prototype.reduceRight` method
4776 // https://tc39.es/ecma262/#sec-array.prototype.reduceright
4777 right: createMethod(true)
4778 };
4779
4780 /***/ }),
4781 /* 149 */
4782 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4783
4784 var classof = __webpack_require__(13);
4785
4786 var global = __webpack_require__(3);
4787
4788 module.exports = classof(global.process) == 'process';
4789
4790 /***/ }),
4791 /* 150 */
4792 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4793
4794 "use strict";
4795
4796
4797 var $ = __webpack_require__(2);
4798
4799 var $reduceRight = (__webpack_require__(148).right);
4800
4801 var arrayMethodIsStrict = __webpack_require__(120);
4802
4803 var CHROME_VERSION = __webpack_require__(24);
4804
4805 var IS_NODE = __webpack_require__(149);
4806
4807 var STRICT_METHOD = arrayMethodIsStrict('reduceRight'); // Chrome 80-82 has a critical bug
4808 // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
4809
4810 var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83; // `Array.prototype.reduceRight` method
4811 // https://tc39.es/ecma262/#sec-array.prototype.reduceright
4812
4813 $({
4814 target: 'Array',
4815 proto: true,
4816 forced: !STRICT_METHOD || CHROME_BUG
4817 }, {
4818 reduceRight: function reduceRight(callbackfn
4819 /* , initialValue */
4820 ) {
4821 return $reduceRight(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
4822 }
4823 });
4824
4825 /***/ }),
4826 /* 151 */
4827 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4828
4829 "use strict";
4830
4831
4832 var $ = __webpack_require__(2);
4833
4834 var uncurryThis = __webpack_require__(12);
4835
4836 var isArray = __webpack_require__(63);
4837
4838 var un$Reverse = uncurryThis([].reverse);
4839 var test = [1, 2]; // `Array.prototype.reverse` method
4840 // https://tc39.es/ecma262/#sec-array.prototype.reverse
4841 // fix for Safari 12.0 bug
4842 // https://bugs.webkit.org/show_bug.cgi?id=188794
4843
4844 $({
4845 target: 'Array',
4846 proto: true,
4847 forced: String(test) === String(test.reverse())
4848 }, {
4849 reverse: function reverse() {
4850 // eslint-disable-next-line no-self-assign -- dirty hack
4851 if (isArray(this)) this.length = this.length;
4852 return un$Reverse(this);
4853 }
4854 });
4855
4856 /***/ }),
4857 /* 152 */
4858 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4859
4860 "use strict";
4861
4862
4863 var $ = __webpack_require__(2);
4864
4865 var global = __webpack_require__(3);
4866
4867 var isArray = __webpack_require__(63);
4868
4869 var isConstructor = __webpack_require__(83);
4870
4871 var isObject = __webpack_require__(17);
4872
4873 var toAbsoluteIndex = __webpack_require__(55);
4874
4875 var lengthOfArrayLike = __webpack_require__(57);
4876
4877 var toIndexedObject = __webpack_require__(10);
4878
4879 var createProperty = __webpack_require__(73);
4880
4881 var wellKnownSymbol = __webpack_require__(30);
4882
4883 var arrayMethodHasSpeciesSupport = __webpack_require__(116);
4884
4885 var un$Slice = __webpack_require__(74);
4886
4887 var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
4888 var SPECIES = wellKnownSymbol('species');
4889 var Array = global.Array;
4890 var max = Math.max; // `Array.prototype.slice` method
4891 // https://tc39.es/ecma262/#sec-array.prototype.slice
4892 // fallback for not array-like ES3 strings and DOM objects
4893
4894 $({
4895 target: 'Array',
4896 proto: true,
4897 forced: !HAS_SPECIES_SUPPORT
4898 }, {
4899 slice: function slice(start, end) {
4900 var O = toIndexedObject(this);
4901 var length = lengthOfArrayLike(O);
4902 var k = toAbsoluteIndex(start, length);
4903 var fin = toAbsoluteIndex(end === undefined ? length : end, length); // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
4904
4905 var Constructor, result, n;
4906
4907 if (isArray(O)) {
4908 Constructor = O.constructor; // cross-realm fallback
4909
4910 if (isConstructor(Constructor) && (Constructor === Array || isArray(Constructor.prototype))) {
4911 Constructor = undefined;
4912 } else if (isObject(Constructor)) {
4913 Constructor = Constructor[SPECIES];
4914 if (Constructor === null) Constructor = undefined;
4915 }
4916
4917 if (Constructor === Array || Constructor === undefined) {
4918 return un$Slice(O, k, fin);
4919 }
4920 }
4921
4922 result = new (Constructor === undefined ? Array : Constructor)(max(fin - k, 0));
4923
4924 for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
4925
4926 result.length = n;
4927 return result;
4928 }
4929 });
4930
4931 /***/ }),
4932 /* 153 */
4933 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4934
4935 "use strict";
4936
4937
4938 var $ = __webpack_require__(2);
4939
4940 var $some = (__webpack_require__(79).some);
4941
4942 var arrayMethodIsStrict = __webpack_require__(120);
4943
4944 var STRICT_METHOD = arrayMethodIsStrict('some'); // `Array.prototype.some` method
4945 // https://tc39.es/ecma262/#sec-array.prototype.some
4946
4947 $({
4948 target: 'Array',
4949 proto: true,
4950 forced: !STRICT_METHOD
4951 }, {
4952 some: function some(callbackfn
4953 /* , thisArg */
4954 ) {
4955 return $some(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
4956 }
4957 });
4958
4959 /***/ }),
4960 /* 154 */
4961 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
4962
4963 "use strict";
4964
4965
4966 var $ = __webpack_require__(2);
4967
4968 var uncurryThis = __webpack_require__(12);
4969
4970 var aCallable = __webpack_require__(27);
4971
4972 var toObject = __webpack_require__(36);
4973
4974 var lengthOfArrayLike = __webpack_require__(57);
4975
4976 var toString = __webpack_require__(64);
4977
4978 var fails = __webpack_require__(6);
4979
4980 var internalSort = __webpack_require__(155);
4981
4982 var arrayMethodIsStrict = __webpack_require__(120);
4983
4984 var FF = __webpack_require__(156);
4985
4986 var IE_OR_EDGE = __webpack_require__(157);
4987
4988 var V8 = __webpack_require__(24);
4989
4990 var WEBKIT = __webpack_require__(158);
4991
4992 var test = [];
4993 var un$Sort = uncurryThis(test.sort);
4994 var push = uncurryThis(test.push); // IE8-
4995
4996 var FAILS_ON_UNDEFINED = fails(function () {
4997 test.sort(undefined);
4998 }); // V8 bug
4999
5000 var FAILS_ON_NULL = fails(function () {
5001 test.sort(null);
5002 }); // Old WebKit
5003
5004 var STRICT_METHOD = arrayMethodIsStrict('sort');
5005 var STABLE_SORT = !fails(function () {
5006 // feature detection can be too slow, so check engines versions
5007 if (V8) return V8 < 70;
5008 if (FF && FF > 3) return;
5009 if (IE_OR_EDGE) return true;
5010 if (WEBKIT) return WEBKIT < 603;
5011 var result = '';
5012 var code, chr, value, index; // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
5013
5014 for (code = 65; code < 76; code++) {
5015 chr = String.fromCharCode(code);
5016
5017 switch (code) {
5018 case 66:
5019 case 69:
5020 case 70:
5021 case 72:
5022 value = 3;
5023 break;
5024
5025 case 68:
5026 case 71:
5027 value = 4;
5028 break;
5029
5030 default:
5031 value = 2;
5032 }
5033
5034 for (index = 0; index < 47; index++) {
5035 test.push({
5036 k: chr + index,
5037 v: value
5038 });
5039 }
5040 }
5041
5042 test.sort(function (a, b) {
5043 return b.v - a.v;
5044 });
5045
5046 for (index = 0; index < test.length; index++) {
5047 chr = test[index].k.charAt(0);
5048 if (result.charAt(result.length - 1) !== chr) result += chr;
5049 }
5050
5051 return result !== 'DGBEFHACIJK';
5052 });
5053 var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
5054
5055 var getSortCompare = function (comparefn) {
5056 return function (x, y) {
5057 if (y === undefined) return -1;
5058 if (x === undefined) return 1;
5059 if (comparefn !== undefined) return +comparefn(x, y) || 0;
5060 return toString(x) > toString(y) ? 1 : -1;
5061 };
5062 }; // `Array.prototype.sort` method
5063 // https://tc39.es/ecma262/#sec-array.prototype.sort
5064
5065
5066 $({
5067 target: 'Array',
5068 proto: true,
5069 forced: FORCED
5070 }, {
5071 sort: function sort(comparefn) {
5072 if (comparefn !== undefined) aCallable(comparefn);
5073 var array = toObject(this);
5074 if (STABLE_SORT) return comparefn === undefined ? un$Sort(array) : un$Sort(array, comparefn);
5075 var items = [];
5076 var arrayLength = lengthOfArrayLike(array);
5077 var itemsLength, index;
5078
5079 for (index = 0; index < arrayLength; index++) {
5080 if (index in array) push(items, array[index]);
5081 }
5082
5083 internalSort(items, getSortCompare(comparefn));
5084 itemsLength = items.length;
5085 index = 0;
5086
5087 while (index < itemsLength) array[index] = items[index++];
5088
5089 while (index < arrayLength) delete array[index++];
5090
5091 return array;
5092 }
5093 });
5094
5095 /***/ }),
5096 /* 155 */
5097 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5098
5099 var arraySlice = __webpack_require__(72);
5100
5101 var floor = Math.floor;
5102
5103 var mergeSort = function (array, comparefn) {
5104 var length = array.length;
5105 var middle = floor(length / 2);
5106 return length < 8 ? insertionSort(array, comparefn) : merge(array, mergeSort(arraySlice(array, 0, middle), comparefn), mergeSort(arraySlice(array, middle), comparefn), comparefn);
5107 };
5108
5109 var insertionSort = function (array, comparefn) {
5110 var length = array.length;
5111 var i = 1;
5112 var element, j;
5113
5114 while (i < length) {
5115 j = i;
5116 element = array[i];
5117
5118 while (j && comparefn(array[j - 1], element) > 0) {
5119 array[j] = array[--j];
5120 }
5121
5122 if (j !== i++) array[j] = element;
5123 }
5124
5125 return array;
5126 };
5127
5128 var merge = function (array, left, right, comparefn) {
5129 var llength = left.length;
5130 var rlength = right.length;
5131 var lindex = 0;
5132 var rindex = 0;
5133
5134 while (lindex < llength || rindex < rlength) {
5135 array[lindex + rindex] = lindex < llength && rindex < rlength ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] : lindex < llength ? left[lindex++] : right[rindex++];
5136 }
5137
5138 return array;
5139 };
5140
5141 module.exports = mergeSort;
5142
5143 /***/ }),
5144 /* 156 */
5145 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5146
5147 var userAgent = __webpack_require__(25);
5148
5149 var firefox = userAgent.match(/firefox\/(\d+)/i);
5150 module.exports = !!firefox && +firefox[1];
5151
5152 /***/ }),
5153 /* 157 */
5154 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5155
5156 var UA = __webpack_require__(25);
5157
5158 module.exports = /MSIE|Trident/.test(UA);
5159
5160 /***/ }),
5161 /* 158 */
5162 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5163
5164 var userAgent = __webpack_require__(25);
5165
5166 var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
5167 module.exports = !!webkit && +webkit[1];
5168
5169 /***/ }),
5170 /* 159 */
5171 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
5172
5173 var setSpecies = __webpack_require__(160); // `Array[@@species]` getter
5174 // https://tc39.es/ecma262/#sec-get-array-@@species
5175
5176
5177 setSpecies('Array');
5178
5179 /***/ }),
5180 /* 160 */
5181 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5182
5183 "use strict";
5184
5185
5186 var getBuiltIn = __webpack_require__(20);
5187
5188 var definePropertyModule = __webpack_require__(41);
5189
5190 var wellKnownSymbol = __webpack_require__(30);
5191
5192 var DESCRIPTORS = __webpack_require__(5);
5193
5194 var SPECIES = wellKnownSymbol('species');
5195
5196 module.exports = function (CONSTRUCTOR_NAME) {
5197 var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
5198 var defineProperty = definePropertyModule.f;
5199
5200 if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
5201 defineProperty(Constructor, SPECIES, {
5202 configurable: true,
5203 get: function () {
5204 return this;
5205 }
5206 });
5207 }
5208 };
5209
5210 /***/ }),
5211 /* 161 */
5212 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
5213
5214 "use strict";
5215
5216
5217 var $ = __webpack_require__(2);
5218
5219 var global = __webpack_require__(3);
5220
5221 var toAbsoluteIndex = __webpack_require__(55);
5222
5223 var toIntegerOrInfinity = __webpack_require__(56);
5224
5225 var lengthOfArrayLike = __webpack_require__(57);
5226
5227 var toObject = __webpack_require__(36);
5228
5229 var arraySpeciesCreate = __webpack_require__(81);
5230
5231 var createProperty = __webpack_require__(73);
5232
5233 var arrayMethodHasSpeciesSupport = __webpack_require__(116);
5234
5235 var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice');
5236 var TypeError = global.TypeError;
5237 var max = Math.max;
5238 var min = Math.min;
5239 var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
5240 var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded'; // `Array.prototype.splice` method
5241 // https://tc39.es/ecma262/#sec-array.prototype.splice
5242 // with adding support of @@species
5243
5244 $({
5245 target: 'Array',
5246 proto: true,
5247 forced: !HAS_SPECIES_SUPPORT
5248 }, {
5249 splice: function splice(start, deleteCount
5250 /* , ...items */
5251 ) {
5252 var O = toObject(this);
5253 var len = lengthOfArrayLike(O);
5254 var actualStart = toAbsoluteIndex(start, len);
5255 var argumentsLength = arguments.length;
5256 var insertCount, actualDeleteCount, A, k, from, to;
5257
5258 if (argumentsLength === 0) {
5259 insertCount = actualDeleteCount = 0;
5260 } else if (argumentsLength === 1) {
5261 insertCount = 0;
5262 actualDeleteCount = len - actualStart;
5263 } else {
5264 insertCount = argumentsLength - 2;
5265 actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
5266 }
5267
5268 if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) {
5269 throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
5270 }
5271
5272 A = arraySpeciesCreate(O, actualDeleteCount);
5273
5274 for (k = 0; k < actualDeleteCount; k++) {
5275 from = actualStart + k;
5276 if (from in O) createProperty(A, k, O[from]);
5277 }
5278
5279 A.length = actualDeleteCount;
5280
5281 if (insertCount < actualDeleteCount) {
5282 for (k = actualStart; k < len - actualDeleteCount; k++) {
5283 from = k + actualDeleteCount;
5284 to = k + insertCount;
5285 if (from in O) O[to] = O[from];else delete O[to];
5286 }
5287
5288 for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
5289 } else if (insertCount > actualDeleteCount) {
5290 for (k = len - actualDeleteCount; k > actualStart; k--) {
5291 from = k + actualDeleteCount - 1;
5292 to = k + insertCount - 1;
5293 if (from in O) O[to] = O[from];else delete O[to];
5294 }
5295 }
5296
5297 for (k = 0; k < insertCount; k++) {
5298 O[k + actualStart] = arguments[k + 2];
5299 }
5300
5301 O.length = len - actualDeleteCount + insertCount;
5302 return A;
5303 }
5304 });
5305
5306 /***/ }),
5307 /* 162 */
5308 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
5309
5310 // this method was added to unscopables after implementation
5311 // in popular engines, so it's moved to a separate module
5312 var addToUnscopables = __webpack_require__(114); // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
5313
5314
5315 addToUnscopables('flat');
5316
5317 /***/ }),
5318 /* 163 */
5319 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
5320
5321 // this method was added to unscopables after implementation
5322 // in popular engines, so it's moved to a separate module
5323 var addToUnscopables = __webpack_require__(114); // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
5324
5325
5326 addToUnscopables('flatMap');
5327
5328 /***/ }),
5329 /* 164 */
5330 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
5331
5332 "use strict";
5333
5334
5335 var $ = __webpack_require__(2);
5336
5337 var global = __webpack_require__(3);
5338
5339 var arrayBufferModule = __webpack_require__(165);
5340
5341 var setSpecies = __webpack_require__(160);
5342
5343 var ARRAY_BUFFER = 'ArrayBuffer';
5344 var ArrayBuffer = arrayBufferModule[ARRAY_BUFFER];
5345 var NativeArrayBuffer = global[ARRAY_BUFFER]; // `ArrayBuffer` constructor
5346 // https://tc39.es/ecma262/#sec-arraybuffer-constructor
5347
5348 $({
5349 global: true,
5350 forced: NativeArrayBuffer !== ArrayBuffer
5351 }, {
5352 ArrayBuffer: ArrayBuffer
5353 });
5354 setSpecies(ARRAY_BUFFER);
5355
5356 /***/ }),
5357 /* 165 */
5358 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5359
5360 "use strict";
5361
5362
5363 var global = __webpack_require__(3);
5364
5365 var uncurryThis = __webpack_require__(12);
5366
5367 var DESCRIPTORS = __webpack_require__(5);
5368
5369 var NATIVE_ARRAY_BUFFER = __webpack_require__(166);
5370
5371 var FunctionName = __webpack_require__(49);
5372
5373 var createNonEnumerableProperty = __webpack_require__(40);
5374
5375 var redefineAll = __webpack_require__(167);
5376
5377 var fails = __webpack_require__(6);
5378
5379 var anInstance = __webpack_require__(168);
5380
5381 var toIntegerOrInfinity = __webpack_require__(56);
5382
5383 var toLength = __webpack_require__(58);
5384
5385 var toIndex = __webpack_require__(169);
5386
5387 var IEEE754 = __webpack_require__(170);
5388
5389 var getPrototypeOf = __webpack_require__(99);
5390
5391 var setPrototypeOf = __webpack_require__(101);
5392
5393 var getOwnPropertyNames = (__webpack_require__(52).f);
5394
5395 var defineProperty = (__webpack_require__(41).f);
5396
5397 var arrayFill = __webpack_require__(122);
5398
5399 var arraySlice = __webpack_require__(72);
5400
5401 var setToStringTag = __webpack_require__(78);
5402
5403 var InternalStateModule = __webpack_require__(45);
5404
5405 var PROPER_FUNCTION_NAME = FunctionName.PROPER;
5406 var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
5407 var getInternalState = InternalStateModule.get;
5408 var setInternalState = InternalStateModule.set;
5409 var ARRAY_BUFFER = 'ArrayBuffer';
5410 var DATA_VIEW = 'DataView';
5411 var PROTOTYPE = 'prototype';
5412 var WRONG_LENGTH = 'Wrong length';
5413 var WRONG_INDEX = 'Wrong index';
5414 var NativeArrayBuffer = global[ARRAY_BUFFER];
5415 var $ArrayBuffer = NativeArrayBuffer;
5416 var ArrayBufferPrototype = $ArrayBuffer && $ArrayBuffer[PROTOTYPE];
5417 var $DataView = global[DATA_VIEW];
5418 var DataViewPrototype = $DataView && $DataView[PROTOTYPE];
5419 var ObjectPrototype = Object.prototype;
5420 var Array = global.Array;
5421 var RangeError = global.RangeError;
5422 var fill = uncurryThis(arrayFill);
5423 var reverse = uncurryThis([].reverse);
5424 var packIEEE754 = IEEE754.pack;
5425 var unpackIEEE754 = IEEE754.unpack;
5426
5427 var packInt8 = function (number) {
5428 return [number & 0xFF];
5429 };
5430
5431 var packInt16 = function (number) {
5432 return [number & 0xFF, number >> 8 & 0xFF];
5433 };
5434
5435 var packInt32 = function (number) {
5436 return [number & 0xFF, number >> 8 & 0xFF, number >> 16 & 0xFF, number >> 24 & 0xFF];
5437 };
5438
5439 var unpackInt32 = function (buffer) {
5440 return buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0];
5441 };
5442
5443 var packFloat32 = function (number) {
5444 return packIEEE754(number, 23, 4);
5445 };
5446
5447 var packFloat64 = function (number) {
5448 return packIEEE754(number, 52, 8);
5449 };
5450
5451 var addGetter = function (Constructor, key) {
5452 defineProperty(Constructor[PROTOTYPE], key, {
5453 get: function () {
5454 return getInternalState(this)[key];
5455 }
5456 });
5457 };
5458
5459 var get = function (view, count, index, isLittleEndian) {
5460 var intIndex = toIndex(index);
5461 var store = getInternalState(view);
5462 if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX);
5463 var bytes = getInternalState(store.buffer).bytes;
5464 var start = intIndex + store.byteOffset;
5465 var pack = arraySlice(bytes, start, start + count);
5466 return isLittleEndian ? pack : reverse(pack);
5467 };
5468
5469 var set = function (view, count, index, conversion, value, isLittleEndian) {
5470 var intIndex = toIndex(index);
5471 var store = getInternalState(view);
5472 if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX);
5473 var bytes = getInternalState(store.buffer).bytes;
5474 var start = intIndex + store.byteOffset;
5475 var pack = conversion(+value);
5476
5477 for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1];
5478 };
5479
5480 if (!NATIVE_ARRAY_BUFFER) {
5481 $ArrayBuffer = function ArrayBuffer(length) {
5482 anInstance(this, ArrayBufferPrototype);
5483 var byteLength = toIndex(length);
5484 setInternalState(this, {
5485 bytes: fill(Array(byteLength), 0),
5486 byteLength: byteLength
5487 });
5488 if (!DESCRIPTORS) this.byteLength = byteLength;
5489 };
5490
5491 ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE];
5492
5493 $DataView = function DataView(buffer, byteOffset, byteLength) {
5494 anInstance(this, DataViewPrototype);
5495 anInstance(buffer, ArrayBufferPrototype);
5496 var bufferLength = getInternalState(buffer).byteLength;
5497 var offset = toIntegerOrInfinity(byteOffset);
5498 if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset');
5499 byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);
5500 if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);
5501 setInternalState(this, {
5502 buffer: buffer,
5503 byteLength: byteLength,
5504 byteOffset: offset
5505 });
5506
5507 if (!DESCRIPTORS) {
5508 this.buffer = buffer;
5509 this.byteLength = byteLength;
5510 this.byteOffset = offset;
5511 }
5512 };
5513
5514 DataViewPrototype = $DataView[PROTOTYPE];
5515
5516 if (DESCRIPTORS) {
5517 addGetter($ArrayBuffer, 'byteLength');
5518 addGetter($DataView, 'buffer');
5519 addGetter($DataView, 'byteLength');
5520 addGetter($DataView, 'byteOffset');
5521 }
5522
5523 redefineAll(DataViewPrototype, {
5524 getInt8: function getInt8(byteOffset) {
5525 return get(this, 1, byteOffset)[0] << 24 >> 24;
5526 },
5527 getUint8: function getUint8(byteOffset) {
5528 return get(this, 1, byteOffset)[0];
5529 },
5530 getInt16: function getInt16(byteOffset
5531 /* , littleEndian */
5532 ) {
5533 var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);
5534 return (bytes[1] << 8 | bytes[0]) << 16 >> 16;
5535 },
5536 getUint16: function getUint16(byteOffset
5537 /* , littleEndian */
5538 ) {
5539 var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined);
5540 return bytes[1] << 8 | bytes[0];
5541 },
5542 getInt32: function getInt32(byteOffset
5543 /* , littleEndian */
5544 ) {
5545 return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined));
5546 },
5547 getUint32: function getUint32(byteOffset
5548 /* , littleEndian */
5549 ) {
5550 return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0;
5551 },
5552 getFloat32: function getFloat32(byteOffset
5553 /* , littleEndian */
5554 ) {
5555 return unpackIEEE754(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23);
5556 },
5557 getFloat64: function getFloat64(byteOffset
5558 /* , littleEndian */
5559 ) {
5560 return unpackIEEE754(get(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52);
5561 },
5562 setInt8: function setInt8(byteOffset, value) {
5563 set(this, 1, byteOffset, packInt8, value);
5564 },
5565 setUint8: function setUint8(byteOffset, value) {
5566 set(this, 1, byteOffset, packInt8, value);
5567 },
5568 setInt16: function setInt16(byteOffset, value
5569 /* , littleEndian */
5570 ) {
5571 set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined);
5572 },
5573 setUint16: function setUint16(byteOffset, value
5574 /* , littleEndian */
5575 ) {
5576 set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined);
5577 },
5578 setInt32: function setInt32(byteOffset, value
5579 /* , littleEndian */
5580 ) {
5581 set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined);
5582 },
5583 setUint32: function setUint32(byteOffset, value
5584 /* , littleEndian */
5585 ) {
5586 set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined);
5587 },
5588 setFloat32: function setFloat32(byteOffset, value
5589 /* , littleEndian */
5590 ) {
5591 set(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined);
5592 },
5593 setFloat64: function setFloat64(byteOffset, value
5594 /* , littleEndian */
5595 ) {
5596 set(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined);
5597 }
5598 });
5599 } else {
5600 var INCORRECT_ARRAY_BUFFER_NAME = PROPER_FUNCTION_NAME && NativeArrayBuffer.name !== ARRAY_BUFFER;
5601 /* eslint-disable no-new -- required for testing */
5602
5603 if (!fails(function () {
5604 NativeArrayBuffer(1);
5605 }) || !fails(function () {
5606 new NativeArrayBuffer(-1);
5607 }) || fails(function () {
5608 new NativeArrayBuffer();
5609 new NativeArrayBuffer(1.5);
5610 new NativeArrayBuffer(NaN);
5611 return INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME;
5612 })) {
5613 /* eslint-enable no-new -- required for testing */
5614 $ArrayBuffer = function ArrayBuffer(length) {
5615 anInstance(this, ArrayBufferPrototype);
5616 return new NativeArrayBuffer(toIndex(length));
5617 };
5618
5619 $ArrayBuffer[PROTOTYPE] = ArrayBufferPrototype;
5620
5621 for (var keys = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys.length > j;) {
5622 if (!((key = keys[j++]) in $ArrayBuffer)) {
5623 createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]);
5624 }
5625 }
5626
5627 ArrayBufferPrototype.constructor = $ArrayBuffer;
5628 } else if (INCORRECT_ARRAY_BUFFER_NAME && CONFIGURABLE_FUNCTION_NAME) {
5629 createNonEnumerableProperty(NativeArrayBuffer, 'name', ARRAY_BUFFER);
5630 } // WebKit bug - the same parent prototype for typed arrays and data view
5631
5632
5633 if (setPrototypeOf && getPrototypeOf(DataViewPrototype) !== ObjectPrototype) {
5634 setPrototypeOf(DataViewPrototype, ObjectPrototype);
5635 } // iOS Safari 7.x bug
5636
5637
5638 var testView = new $DataView(new $ArrayBuffer(2));
5639 var $setInt8 = uncurryThis(DataViewPrototype.setInt8);
5640 testView.setInt8(0, 2147483648);
5641 testView.setInt8(1, 2147483649);
5642 if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll(DataViewPrototype, {
5643 setInt8: function setInt8(byteOffset, value) {
5644 $setInt8(this, byteOffset, value << 24 >> 24);
5645 },
5646 setUint8: function setUint8(byteOffset, value) {
5647 $setInt8(this, byteOffset, value << 24 >> 24);
5648 }
5649 }, {
5650 unsafe: true
5651 });
5652 }
5653
5654 setToStringTag($ArrayBuffer, ARRAY_BUFFER);
5655 setToStringTag($DataView, DATA_VIEW);
5656 module.exports = {
5657 ArrayBuffer: $ArrayBuffer,
5658 DataView: $DataView
5659 };
5660
5661 /***/ }),
5662 /* 166 */
5663 /***/ ((module) => {
5664
5665 // eslint-disable-next-line es/no-typed-arrays -- safe
5666 module.exports = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined';
5667
5668 /***/ }),
5669 /* 167 */
5670 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5671
5672 var redefine = __webpack_require__(43);
5673
5674 module.exports = function (target, src, options) {
5675 for (var key in src) redefine(target, key, src[key], options);
5676
5677 return target;
5678 };
5679
5680 /***/ }),
5681 /* 168 */
5682 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5683
5684 var global = __webpack_require__(3);
5685
5686 var isPrototypeOf = __webpack_require__(21);
5687
5688 var TypeError = global.TypeError;
5689
5690 module.exports = function (it, Prototype) {
5691 if (isPrototypeOf(Prototype, it)) return it;
5692 throw TypeError('Incorrect invocation');
5693 };
5694
5695 /***/ }),
5696 /* 169 */
5697 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5698
5699 var global = __webpack_require__(3);
5700
5701 var toIntegerOrInfinity = __webpack_require__(56);
5702
5703 var toLength = __webpack_require__(58);
5704
5705 var RangeError = global.RangeError; // `ToIndex` abstract operation
5706 // https://tc39.es/ecma262/#sec-toindex
5707
5708 module.exports = function (it) {
5709 if (it === undefined) return 0;
5710 var number = toIntegerOrInfinity(it);
5711 var length = toLength(number);
5712 if (number !== length) throw RangeError('Wrong length or index');
5713 return length;
5714 };
5715
5716 /***/ }),
5717 /* 170 */
5718 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5719
5720 // IEEE754 conversions based on https://github.com/feross/ieee754
5721 var global = __webpack_require__(3);
5722
5723 var Array = global.Array;
5724 var abs = Math.abs;
5725 var pow = Math.pow;
5726 var floor = Math.floor;
5727 var log = Math.log;
5728 var LN2 = Math.LN2;
5729
5730 var pack = function (number, mantissaLength, bytes) {
5731 var buffer = Array(bytes);
5732 var exponentLength = bytes * 8 - mantissaLength - 1;
5733 var eMax = (1 << exponentLength) - 1;
5734 var eBias = eMax >> 1;
5735 var rt = mantissaLength === 23 ? pow(2, -24) - pow(2, -77) : 0;
5736 var sign = number < 0 || number === 0 && 1 / number < 0 ? 1 : 0;
5737 var index = 0;
5738 var exponent, mantissa, c;
5739 number = abs(number); // eslint-disable-next-line no-self-compare -- NaN check
5740
5741 if (number != number || number === Infinity) {
5742 // eslint-disable-next-line no-self-compare -- NaN check
5743 mantissa = number != number ? 1 : 0;
5744 exponent = eMax;
5745 } else {
5746 exponent = floor(log(number) / LN2);
5747 c = pow(2, -exponent);
5748
5749 if (number * c < 1) {
5750 exponent--;
5751 c *= 2;
5752 }
5753
5754 if (exponent + eBias >= 1) {
5755 number += rt / c;
5756 } else {
5757 number += rt * pow(2, 1 - eBias);
5758 }
5759
5760 if (number * c >= 2) {
5761 exponent++;
5762 c /= 2;
5763 }
5764
5765 if (exponent + eBias >= eMax) {
5766 mantissa = 0;
5767 exponent = eMax;
5768 } else if (exponent + eBias >= 1) {
5769 mantissa = (number * c - 1) * pow(2, mantissaLength);
5770 exponent = exponent + eBias;
5771 } else {
5772 mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength);
5773 exponent = 0;
5774 }
5775 }
5776
5777 while (mantissaLength >= 8) {
5778 buffer[index++] = mantissa & 255;
5779 mantissa /= 256;
5780 mantissaLength -= 8;
5781 }
5782
5783 exponent = exponent << mantissaLength | mantissa;
5784 exponentLength += mantissaLength;
5785
5786 while (exponentLength > 0) {
5787 buffer[index++] = exponent & 255;
5788 exponent /= 256;
5789 exponentLength -= 8;
5790 }
5791
5792 buffer[--index] |= sign * 128;
5793 return buffer;
5794 };
5795
5796 var unpack = function (buffer, mantissaLength) {
5797 var bytes = buffer.length;
5798 var exponentLength = bytes * 8 - mantissaLength - 1;
5799 var eMax = (1 << exponentLength) - 1;
5800 var eBias = eMax >> 1;
5801 var nBits = exponentLength - 7;
5802 var index = bytes - 1;
5803 var sign = buffer[index--];
5804 var exponent = sign & 127;
5805 var mantissa;
5806 sign >>= 7;
5807
5808 while (nBits > 0) {
5809 exponent = exponent * 256 + buffer[index--];
5810 nBits -= 8;
5811 }
5812
5813 mantissa = exponent & (1 << -nBits) - 1;
5814 exponent >>= -nBits;
5815 nBits += mantissaLength;
5816
5817 while (nBits > 0) {
5818 mantissa = mantissa * 256 + buffer[index--];
5819 nBits -= 8;
5820 }
5821
5822 if (exponent === 0) {
5823 exponent = 1 - eBias;
5824 } else if (exponent === eMax) {
5825 return mantissa ? NaN : sign ? -Infinity : Infinity;
5826 } else {
5827 mantissa = mantissa + pow(2, mantissaLength);
5828 exponent = exponent - eBias;
5829 }
5830
5831 return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength);
5832 };
5833
5834 module.exports = {
5835 pack: pack,
5836 unpack: unpack
5837 };
5838
5839 /***/ }),
5840 /* 171 */
5841 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
5842
5843 var $ = __webpack_require__(2);
5844
5845 var ArrayBufferViewCore = __webpack_require__(172);
5846
5847 var NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; // `ArrayBuffer.isView` method
5848 // https://tc39.es/ecma262/#sec-arraybuffer.isview
5849
5850 $({
5851 target: 'ArrayBuffer',
5852 stat: true,
5853 forced: !NATIVE_ARRAY_BUFFER_VIEWS
5854 }, {
5855 isView: ArrayBufferViewCore.isView
5856 });
5857
5858 /***/ }),
5859 /* 172 */
5860 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5861
5862 "use strict";
5863
5864
5865 var NATIVE_ARRAY_BUFFER = __webpack_require__(166);
5866
5867 var DESCRIPTORS = __webpack_require__(5);
5868
5869 var global = __webpack_require__(3);
5870
5871 var isCallable = __webpack_require__(18);
5872
5873 var isObject = __webpack_require__(17);
5874
5875 var hasOwn = __webpack_require__(35);
5876
5877 var classof = __webpack_require__(65);
5878
5879 var tryToString = __webpack_require__(28);
5880
5881 var createNonEnumerableProperty = __webpack_require__(40);
5882
5883 var redefine = __webpack_require__(43);
5884
5885 var defineProperty = (__webpack_require__(41).f);
5886
5887 var isPrototypeOf = __webpack_require__(21);
5888
5889 var getPrototypeOf = __webpack_require__(99);
5890
5891 var setPrototypeOf = __webpack_require__(101);
5892
5893 var wellKnownSymbol = __webpack_require__(30);
5894
5895 var uid = __webpack_require__(37);
5896
5897 var Int8Array = global.Int8Array;
5898 var Int8ArrayPrototype = Int8Array && Int8Array.prototype;
5899 var Uint8ClampedArray = global.Uint8ClampedArray;
5900 var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype;
5901 var TypedArray = Int8Array && getPrototypeOf(Int8Array);
5902 var TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype);
5903 var ObjectPrototype = Object.prototype;
5904 var TypeError = global.TypeError;
5905 var TO_STRING_TAG = wellKnownSymbol('toStringTag');
5906 var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG');
5907 var TYPED_ARRAY_CONSTRUCTOR = uid('TYPED_ARRAY_CONSTRUCTOR'); // Fixing native typed arrays in Opera Presto crashes the browser, see #595
5908
5909 var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera';
5910 var TYPED_ARRAY_TAG_REQIRED = false;
5911 var NAME, Constructor, Prototype;
5912 var TypedArrayConstructorsList = {
5913 Int8Array: 1,
5914 Uint8Array: 1,
5915 Uint8ClampedArray: 1,
5916 Int16Array: 2,
5917 Uint16Array: 2,
5918 Int32Array: 4,
5919 Uint32Array: 4,
5920 Float32Array: 4,
5921 Float64Array: 8
5922 };
5923 var BigIntArrayConstructorsList = {
5924 BigInt64Array: 8,
5925 BigUint64Array: 8
5926 };
5927
5928 var isView = function isView(it) {
5929 if (!isObject(it)) return false;
5930 var klass = classof(it);
5931 return klass === 'DataView' || hasOwn(TypedArrayConstructorsList, klass) || hasOwn(BigIntArrayConstructorsList, klass);
5932 };
5933
5934 var isTypedArray = function (it) {
5935 if (!isObject(it)) return false;
5936 var klass = classof(it);
5937 return hasOwn(TypedArrayConstructorsList, klass) || hasOwn(BigIntArrayConstructorsList, klass);
5938 };
5939
5940 var aTypedArray = function (it) {
5941 if (isTypedArray(it)) return it;
5942 throw TypeError('Target is not a typed array');
5943 };
5944
5945 var aTypedArrayConstructor = function (C) {
5946 if (isCallable(C) && (!setPrototypeOf || isPrototypeOf(TypedArray, C))) return C;
5947 throw TypeError(tryToString(C) + ' is not a typed array constructor');
5948 };
5949
5950 var exportTypedArrayMethod = function (KEY, property, forced) {
5951 if (!DESCRIPTORS) return;
5952 if (forced) for (var ARRAY in TypedArrayConstructorsList) {
5953 var TypedArrayConstructor = global[ARRAY];
5954 if (TypedArrayConstructor && hasOwn(TypedArrayConstructor.prototype, KEY)) try {
5955 delete TypedArrayConstructor.prototype[KEY];
5956 } catch (error) {
5957 /* empty */
5958 }
5959 }
5960
5961 if (!TypedArrayPrototype[KEY] || forced) {
5962 redefine(TypedArrayPrototype, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property);
5963 }
5964 };
5965
5966 var exportTypedArrayStaticMethod = function (KEY, property, forced) {
5967 var ARRAY, TypedArrayConstructor;
5968 if (!DESCRIPTORS) return;
5969
5970 if (setPrototypeOf) {
5971 if (forced) for (ARRAY in TypedArrayConstructorsList) {
5972 TypedArrayConstructor = global[ARRAY];
5973 if (TypedArrayConstructor && hasOwn(TypedArrayConstructor, KEY)) try {
5974 delete TypedArrayConstructor[KEY];
5975 } catch (error) {
5976 /* empty */
5977 }
5978 }
5979
5980 if (!TypedArray[KEY] || forced) {
5981 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable
5982 try {
5983 return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property);
5984 } catch (error) {
5985 /* empty */
5986 }
5987 } else return;
5988 }
5989
5990 for (ARRAY in TypedArrayConstructorsList) {
5991 TypedArrayConstructor = global[ARRAY];
5992
5993 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) {
5994 redefine(TypedArrayConstructor, KEY, property);
5995 }
5996 }
5997 };
5998
5999 for (NAME in TypedArrayConstructorsList) {
6000 Constructor = global[NAME];
6001 Prototype = Constructor && Constructor.prototype;
6002 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor);else NATIVE_ARRAY_BUFFER_VIEWS = false;
6003 }
6004
6005 for (NAME in BigIntArrayConstructorsList) {
6006 Constructor = global[NAME];
6007 Prototype = Constructor && Constructor.prototype;
6008 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor);
6009 } // WebKit bug - typed arrays constructors prototype is Object.prototype
6010
6011
6012 if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) {
6013 // eslint-disable-next-line no-shadow -- safe
6014 TypedArray = function TypedArray() {
6015 throw TypeError('Incorrect invocation');
6016 };
6017
6018 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {
6019 if (global[NAME]) setPrototypeOf(global[NAME], TypedArray);
6020 }
6021 }
6022
6023 if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) {
6024 TypedArrayPrototype = TypedArray.prototype;
6025 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {
6026 if (global[NAME]) setPrototypeOf(global[NAME].prototype, TypedArrayPrototype);
6027 }
6028 } // WebKit bug - one more object in Uint8ClampedArray prototype chain
6029
6030
6031 if (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) {
6032 setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype);
6033 }
6034
6035 if (DESCRIPTORS && !hasOwn(TypedArrayPrototype, TO_STRING_TAG)) {
6036 TYPED_ARRAY_TAG_REQIRED = true;
6037 defineProperty(TypedArrayPrototype, TO_STRING_TAG, {
6038 get: function () {
6039 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined;
6040 }
6041 });
6042
6043 for (NAME in TypedArrayConstructorsList) if (global[NAME]) {
6044 createNonEnumerableProperty(global[NAME], TYPED_ARRAY_TAG, NAME);
6045 }
6046 }
6047
6048 module.exports = {
6049 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS,
6050 TYPED_ARRAY_CONSTRUCTOR: TYPED_ARRAY_CONSTRUCTOR,
6051 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG,
6052 aTypedArray: aTypedArray,
6053 aTypedArrayConstructor: aTypedArrayConstructor,
6054 exportTypedArrayMethod: exportTypedArrayMethod,
6055 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod,
6056 isView: isView,
6057 isTypedArray: isTypedArray,
6058 TypedArray: TypedArray,
6059 TypedArrayPrototype: TypedArrayPrototype
6060 };
6061
6062 /***/ }),
6063 /* 173 */
6064 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6065
6066 "use strict";
6067
6068
6069 var $ = __webpack_require__(2);
6070
6071 var uncurryThis = __webpack_require__(12);
6072
6073 var fails = __webpack_require__(6);
6074
6075 var ArrayBufferModule = __webpack_require__(165);
6076
6077 var anObject = __webpack_require__(42);
6078
6079 var toAbsoluteIndex = __webpack_require__(55);
6080
6081 var toLength = __webpack_require__(58);
6082
6083 var speciesConstructor = __webpack_require__(174);
6084
6085 var ArrayBuffer = ArrayBufferModule.ArrayBuffer;
6086 var DataView = ArrayBufferModule.DataView;
6087 var DataViewPrototype = DataView.prototype;
6088 var un$ArrayBufferSlice = uncurryThis(ArrayBuffer.prototype.slice);
6089 var getUint8 = uncurryThis(DataViewPrototype.getUint8);
6090 var setUint8 = uncurryThis(DataViewPrototype.setUint8);
6091 var INCORRECT_SLICE = fails(function () {
6092 return !new ArrayBuffer(2).slice(1, undefined).byteLength;
6093 }); // `ArrayBuffer.prototype.slice` method
6094 // https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice
6095
6096 $({
6097 target: 'ArrayBuffer',
6098 proto: true,
6099 unsafe: true,
6100 forced: INCORRECT_SLICE
6101 }, {
6102 slice: function slice(start, end) {
6103 if (un$ArrayBufferSlice && end === undefined) {
6104 return un$ArrayBufferSlice(anObject(this), start); // FF fix
6105 }
6106
6107 var length = anObject(this).byteLength;
6108 var first = toAbsoluteIndex(start, length);
6109 var fin = toAbsoluteIndex(end === undefined ? length : end, length);
6110 var result = new (speciesConstructor(this, ArrayBuffer))(toLength(fin - first));
6111 var viewSource = new DataView(this);
6112 var viewTarget = new DataView(result);
6113 var index = 0;
6114
6115 while (first < fin) {
6116 setUint8(viewTarget, index++, getUint8(viewSource, first++));
6117 }
6118
6119 return result;
6120 }
6121 });
6122
6123 /***/ }),
6124 /* 174 */
6125 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6126
6127 var anObject = __webpack_require__(42);
6128
6129 var aConstructor = __webpack_require__(175);
6130
6131 var wellKnownSymbol = __webpack_require__(30);
6132
6133 var SPECIES = wellKnownSymbol('species'); // `SpeciesConstructor` abstract operation
6134 // https://tc39.es/ecma262/#sec-speciesconstructor
6135
6136 module.exports = function (O, defaultConstructor) {
6137 var C = anObject(O).constructor;
6138 var S;
6139 return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aConstructor(S);
6140 };
6141
6142 /***/ }),
6143 /* 175 */
6144 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6145
6146 var global = __webpack_require__(3);
6147
6148 var isConstructor = __webpack_require__(83);
6149
6150 var tryToString = __webpack_require__(28);
6151
6152 var TypeError = global.TypeError; // `Assert: IsConstructor(argument) is true`
6153
6154 module.exports = function (argument) {
6155 if (isConstructor(argument)) return argument;
6156 throw TypeError(tryToString(argument) + ' is not a constructor');
6157 };
6158
6159 /***/ }),
6160 /* 176 */
6161 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6162
6163 var $ = __webpack_require__(2);
6164
6165 var ArrayBufferModule = __webpack_require__(165);
6166
6167 var NATIVE_ARRAY_BUFFER = __webpack_require__(166); // `DataView` constructor
6168 // https://tc39.es/ecma262/#sec-dataview-constructor
6169
6170
6171 $({
6172 global: true,
6173 forced: !NATIVE_ARRAY_BUFFER
6174 }, {
6175 DataView: ArrayBufferModule.DataView
6176 });
6177
6178 /***/ }),
6179 /* 177 */
6180 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6181
6182 "use strict";
6183
6184
6185 var $ = __webpack_require__(2);
6186
6187 var uncurryThis = __webpack_require__(12);
6188
6189 var fails = __webpack_require__(6);
6190
6191 var FORCED = fails(function () {
6192 return new Date(16e11).getYear() !== 120;
6193 });
6194 var getFullYear = uncurryThis(Date.prototype.getFullYear); // `Date.prototype.getYear` method
6195 // https://tc39.es/ecma262/#sec-date.prototype.getyear
6196
6197 $({
6198 target: 'Date',
6199 proto: true,
6200 forced: FORCED
6201 }, {
6202 getYear: function getYear() {
6203 return getFullYear(this) - 1900;
6204 }
6205 });
6206
6207 /***/ }),
6208 /* 178 */
6209 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6210
6211 var $ = __webpack_require__(2);
6212
6213 var global = __webpack_require__(3);
6214
6215 var uncurryThis = __webpack_require__(12);
6216
6217 var Date = global.Date;
6218 var getTime = uncurryThis(Date.prototype.getTime); // `Date.now` method
6219 // https://tc39.es/ecma262/#sec-date.now
6220
6221 $({
6222 target: 'Date',
6223 stat: true
6224 }, {
6225 now: function now() {
6226 return getTime(new Date());
6227 }
6228 });
6229
6230 /***/ }),
6231 /* 179 */
6232 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6233
6234 "use strict";
6235
6236
6237 var $ = __webpack_require__(2);
6238
6239 var uncurryThis = __webpack_require__(12);
6240
6241 var toIntegerOrInfinity = __webpack_require__(56);
6242
6243 var DatePrototype = Date.prototype;
6244 var getTime = uncurryThis(DatePrototype.getTime);
6245 var setFullYear = uncurryThis(DatePrototype.setFullYear); // `Date.prototype.setYear` method
6246 // https://tc39.es/ecma262/#sec-date.prototype.setyear
6247
6248 $({
6249 target: 'Date',
6250 proto: true
6251 }, {
6252 setYear: function setYear(year) {
6253 // validate
6254 getTime(this);
6255 var yi = toIntegerOrInfinity(year);
6256 var yyyy = 0 <= yi && yi <= 99 ? yi + 1900 : yi;
6257 return setFullYear(this, yyyy);
6258 }
6259 });
6260
6261 /***/ }),
6262 /* 180 */
6263 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6264
6265 var $ = __webpack_require__(2); // `Date.prototype.toGMTString` method
6266 // https://tc39.es/ecma262/#sec-date.prototype.togmtstring
6267
6268
6269 $({
6270 target: 'Date',
6271 proto: true
6272 }, {
6273 toGMTString: Date.prototype.toUTCString
6274 });
6275
6276 /***/ }),
6277 /* 181 */
6278 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6279
6280 var $ = __webpack_require__(2);
6281
6282 var toISOString = __webpack_require__(182); // `Date.prototype.toISOString` method
6283 // https://tc39.es/ecma262/#sec-date.prototype.toisostring
6284 // PhantomJS / old WebKit has a broken implementations
6285
6286
6287 $({
6288 target: 'Date',
6289 proto: true,
6290 forced: Date.prototype.toISOString !== toISOString
6291 }, {
6292 toISOString: toISOString
6293 });
6294
6295 /***/ }),
6296 /* 182 */
6297 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6298
6299 "use strict";
6300
6301
6302 var global = __webpack_require__(3);
6303
6304 var uncurryThis = __webpack_require__(12);
6305
6306 var fails = __webpack_require__(6);
6307
6308 var padStart = (__webpack_require__(183).start);
6309
6310 var RangeError = global.RangeError;
6311 var abs = Math.abs;
6312 var DatePrototype = Date.prototype;
6313 var n$DateToISOString = DatePrototype.toISOString;
6314 var getTime = uncurryThis(DatePrototype.getTime);
6315 var getUTCDate = uncurryThis(DatePrototype.getUTCDate);
6316 var getUTCFullYear = uncurryThis(DatePrototype.getUTCFullYear);
6317 var getUTCHours = uncurryThis(DatePrototype.getUTCHours);
6318 var getUTCMilliseconds = uncurryThis(DatePrototype.getUTCMilliseconds);
6319 var getUTCMinutes = uncurryThis(DatePrototype.getUTCMinutes);
6320 var getUTCMonth = uncurryThis(DatePrototype.getUTCMonth);
6321 var getUTCSeconds = uncurryThis(DatePrototype.getUTCSeconds); // `Date.prototype.toISOString` method implementation
6322 // https://tc39.es/ecma262/#sec-date.prototype.toisostring
6323 // PhantomJS / old WebKit fails here:
6324
6325 module.exports = fails(function () {
6326 return n$DateToISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z';
6327 }) || !fails(function () {
6328 n$DateToISOString.call(new Date(NaN));
6329 }) ? function toISOString() {
6330 if (!isFinite(getTime(this))) throw RangeError('Invalid time value');
6331 var date = this;
6332 var year = getUTCFullYear(date);
6333 var milliseconds = getUTCMilliseconds(date);
6334 var sign = year < 0 ? '-' : year > 9999 ? '+' : '';
6335 return sign + padStart(abs(year), sign ? 6 : 4, 0) + '-' + padStart(getUTCMonth(date) + 1, 2, 0) + '-' + padStart(getUTCDate(date), 2, 0) + 'T' + padStart(getUTCHours(date), 2, 0) + ':' + padStart(getUTCMinutes(date), 2, 0) + ':' + padStart(getUTCSeconds(date), 2, 0) + '.' + padStart(milliseconds, 3, 0) + 'Z';
6336 } : n$DateToISOString;
6337
6338 /***/ }),
6339 /* 183 */
6340 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6341
6342 // https://github.com/tc39/proposal-string-pad-start-end
6343 var uncurryThis = __webpack_require__(12);
6344
6345 var toLength = __webpack_require__(58);
6346
6347 var toString = __webpack_require__(64);
6348
6349 var $repeat = __webpack_require__(184);
6350
6351 var requireObjectCoercible = __webpack_require__(14);
6352
6353 var repeat = uncurryThis($repeat);
6354 var stringSlice = uncurryThis(''.slice);
6355 var ceil = Math.ceil; // `String.prototype.{ padStart, padEnd }` methods implementation
6356
6357 var createMethod = function (IS_END) {
6358 return function ($this, maxLength, fillString) {
6359 var S = toString(requireObjectCoercible($this));
6360 var intMaxLength = toLength(maxLength);
6361 var stringLength = S.length;
6362 var fillStr = fillString === undefined ? ' ' : toString(fillString);
6363 var fillLen, stringFiller;
6364 if (intMaxLength <= stringLength || fillStr == '') return S;
6365 fillLen = intMaxLength - stringLength;
6366 stringFiller = repeat(fillStr, ceil(fillLen / fillStr.length));
6367 if (stringFiller.length > fillLen) stringFiller = stringSlice(stringFiller, 0, fillLen);
6368 return IS_END ? S + stringFiller : stringFiller + S;
6369 };
6370 };
6371
6372 module.exports = {
6373 // `String.prototype.padStart` method
6374 // https://tc39.es/ecma262/#sec-string.prototype.padstart
6375 start: createMethod(false),
6376 // `String.prototype.padEnd` method
6377 // https://tc39.es/ecma262/#sec-string.prototype.padend
6378 end: createMethod(true)
6379 };
6380
6381 /***/ }),
6382 /* 184 */
6383 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6384
6385 "use strict";
6386
6387
6388 var global = __webpack_require__(3);
6389
6390 var toIntegerOrInfinity = __webpack_require__(56);
6391
6392 var toString = __webpack_require__(64);
6393
6394 var requireObjectCoercible = __webpack_require__(14);
6395
6396 var RangeError = global.RangeError; // `String.prototype.repeat` method implementation
6397 // https://tc39.es/ecma262/#sec-string.prototype.repeat
6398
6399 module.exports = function repeat(count) {
6400 var str = toString(requireObjectCoercible(this));
6401 var result = '';
6402 var n = toIntegerOrInfinity(count);
6403 if (n < 0 || n == Infinity) throw RangeError('Wrong number of repetitions');
6404
6405 for (; n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;
6406
6407 return result;
6408 };
6409
6410 /***/ }),
6411 /* 185 */
6412 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6413
6414 "use strict";
6415
6416
6417 var $ = __webpack_require__(2);
6418
6419 var fails = __webpack_require__(6);
6420
6421 var toObject = __webpack_require__(36);
6422
6423 var toPrimitive = __webpack_require__(16);
6424
6425 var FORCED = fails(function () {
6426 return new Date(NaN).toJSON() !== null || Date.prototype.toJSON.call({
6427 toISOString: function () {
6428 return 1;
6429 }
6430 }) !== 1;
6431 }); // `Date.prototype.toJSON` method
6432 // https://tc39.es/ecma262/#sec-date.prototype.tojson
6433
6434 $({
6435 target: 'Date',
6436 proto: true,
6437 forced: FORCED
6438 }, {
6439 // eslint-disable-next-line no-unused-vars -- required for `.length`
6440 toJSON: function toJSON(key) {
6441 var O = toObject(this);
6442 var pv = toPrimitive(O, 'number');
6443 return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();
6444 }
6445 });
6446
6447 /***/ }),
6448 /* 186 */
6449 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6450
6451 var hasOwn = __webpack_require__(35);
6452
6453 var redefine = __webpack_require__(43);
6454
6455 var dateToPrimitive = __webpack_require__(187);
6456
6457 var wellKnownSymbol = __webpack_require__(30);
6458
6459 var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
6460 var DatePrototype = Date.prototype; // `Date.prototype[@@toPrimitive]` method
6461 // https://tc39.es/ecma262/#sec-date.prototype-@@toprimitive
6462
6463 if (!hasOwn(DatePrototype, TO_PRIMITIVE)) {
6464 redefine(DatePrototype, TO_PRIMITIVE, dateToPrimitive);
6465 }
6466
6467 /***/ }),
6468 /* 187 */
6469 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6470
6471 "use strict";
6472
6473
6474 var global = __webpack_require__(3);
6475
6476 var anObject = __webpack_require__(42);
6477
6478 var ordinaryToPrimitive = __webpack_require__(29);
6479
6480 var TypeError = global.TypeError; // `Date.prototype[@@toPrimitive](hint)` method implementation
6481 // https://tc39.es/ecma262/#sec-date.prototype-@@toprimitive
6482
6483 module.exports = function (hint) {
6484 anObject(this);
6485 if (hint === 'string' || hint === 'default') hint = 'string';else if (hint !== 'number') throw TypeError('Incorrect hint');
6486 return ordinaryToPrimitive(this, hint);
6487 };
6488
6489 /***/ }),
6490 /* 188 */
6491 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6492
6493 var uncurryThis = __webpack_require__(12);
6494
6495 var redefine = __webpack_require__(43);
6496
6497 var DatePrototype = Date.prototype;
6498 var INVALID_DATE = 'Invalid Date';
6499 var TO_STRING = 'toString';
6500 var un$DateToString = uncurryThis(DatePrototype[TO_STRING]);
6501 var getTime = uncurryThis(DatePrototype.getTime); // `Date.prototype.toString` method
6502 // https://tc39.es/ecma262/#sec-date.prototype.tostring
6503
6504 if (String(new Date(NaN)) != INVALID_DATE) {
6505 redefine(DatePrototype, TO_STRING, function toString() {
6506 var value = getTime(this); // eslint-disable-next-line no-self-compare -- NaN check
6507
6508 return value === value ? un$DateToString(this) : INVALID_DATE;
6509 });
6510 }
6511
6512 /***/ }),
6513 /* 189 */
6514 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6515
6516 "use strict";
6517
6518
6519 var $ = __webpack_require__(2);
6520
6521 var uncurryThis = __webpack_require__(12);
6522
6523 var toString = __webpack_require__(64);
6524
6525 var charAt = uncurryThis(''.charAt);
6526 var charCodeAt = uncurryThis(''.charCodeAt);
6527 var exec = uncurryThis(/./.exec);
6528 var numberToString = uncurryThis(1.0.toString);
6529 var toUpperCase = uncurryThis(''.toUpperCase);
6530 var raw = /[\w*+\-./@]/;
6531
6532 var hex = function (code, length) {
6533 var result = numberToString(code, 16);
6534
6535 while (result.length < length) result = '0' + result;
6536
6537 return result;
6538 }; // `escape` method
6539 // https://tc39.es/ecma262/#sec-escape-string
6540
6541
6542 $({
6543 global: true
6544 }, {
6545 escape: function escape(string) {
6546 var str = toString(string);
6547 var result = '';
6548 var length = str.length;
6549 var index = 0;
6550 var chr, code;
6551
6552 while (index < length) {
6553 chr = charAt(str, index++);
6554
6555 if (exec(raw, chr)) {
6556 result += chr;
6557 } else {
6558 code = charCodeAt(chr, 0);
6559
6560 if (code < 256) {
6561 result += '%' + hex(code, 2);
6562 } else {
6563 result += '%u' + toUpperCase(hex(code, 4));
6564 }
6565 }
6566 }
6567
6568 return result;
6569 }
6570 });
6571
6572 /***/ }),
6573 /* 190 */
6574 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6575
6576 var $ = __webpack_require__(2);
6577
6578 var bind = __webpack_require__(191); // `Function.prototype.bind` method
6579 // https://tc39.es/ecma262/#sec-function.prototype.bind
6580
6581
6582 $({
6583 target: 'Function',
6584 proto: true
6585 }, {
6586 bind: bind
6587 });
6588
6589 /***/ }),
6590 /* 191 */
6591 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6592
6593 "use strict";
6594
6595
6596 var global = __webpack_require__(3);
6597
6598 var uncurryThis = __webpack_require__(12);
6599
6600 var aCallable = __webpack_require__(27);
6601
6602 var isObject = __webpack_require__(17);
6603
6604 var hasOwn = __webpack_require__(35);
6605
6606 var arraySlice = __webpack_require__(74);
6607
6608 var Function = global.Function;
6609 var concat = uncurryThis([].concat);
6610 var join = uncurryThis([].join);
6611 var factories = {};
6612
6613 var construct = function (C, argsLength, args) {
6614 if (!hasOwn(factories, argsLength)) {
6615 for (var list = [], i = 0; i < argsLength; i++) list[i] = 'a[' + i + ']';
6616
6617 factories[argsLength] = Function('C,a', 'return new C(' + join(list, ',') + ')');
6618 }
6619
6620 return factories[argsLength](C, args);
6621 }; // `Function.prototype.bind` method implementation
6622 // https://tc39.es/ecma262/#sec-function.prototype.bind
6623
6624
6625 module.exports = Function.bind || function bind(that
6626 /* , ...args */
6627 ) {
6628 var F = aCallable(this);
6629 var Prototype = F.prototype;
6630 var partArgs = arraySlice(arguments, 1);
6631
6632 var boundFunction = function
6633 /* args... */
6634 bound() {
6635 var args = concat(partArgs, arraySlice(arguments));
6636 return this instanceof boundFunction ? construct(F, args.length, args) : F.apply(that, args);
6637 };
6638
6639 if (isObject(Prototype)) boundFunction.prototype = Prototype;
6640 return boundFunction;
6641 };
6642
6643 /***/ }),
6644 /* 192 */
6645 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6646
6647 "use strict";
6648
6649
6650 var isCallable = __webpack_require__(18);
6651
6652 var isObject = __webpack_require__(17);
6653
6654 var definePropertyModule = __webpack_require__(41);
6655
6656 var getPrototypeOf = __webpack_require__(99);
6657
6658 var wellKnownSymbol = __webpack_require__(30);
6659
6660 var HAS_INSTANCE = wellKnownSymbol('hasInstance');
6661 var FunctionPrototype = Function.prototype; // `Function.prototype[@@hasInstance]` method
6662 // https://tc39.es/ecma262/#sec-function.prototype-@@hasinstance
6663
6664 if (!(HAS_INSTANCE in FunctionPrototype)) {
6665 definePropertyModule.f(FunctionPrototype, HAS_INSTANCE, {
6666 value: function (O) {
6667 if (!isCallable(this) || !isObject(O)) return false;
6668 var P = this.prototype;
6669 if (!isObject(P)) return O instanceof this; // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
6670
6671 while (O = getPrototypeOf(O)) if (P === O) return true;
6672
6673 return false;
6674 }
6675 });
6676 }
6677
6678 /***/ }),
6679 /* 193 */
6680 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6681
6682 var DESCRIPTORS = __webpack_require__(5);
6683
6684 var FUNCTION_NAME_EXISTS = (__webpack_require__(49).EXISTS);
6685
6686 var uncurryThis = __webpack_require__(12);
6687
6688 var defineProperty = (__webpack_require__(41).f);
6689
6690 var FunctionPrototype = Function.prototype;
6691 var functionToString = uncurryThis(FunctionPrototype.toString);
6692 var nameRE = /function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/;
6693 var regExpExec = uncurryThis(nameRE.exec);
6694 var NAME = 'name'; // Function instances `.name` property
6695 // https://tc39.es/ecma262/#sec-function-instances-name
6696
6697 if (DESCRIPTORS && !FUNCTION_NAME_EXISTS) {
6698 defineProperty(FunctionPrototype, NAME, {
6699 configurable: true,
6700 get: function () {
6701 try {
6702 return regExpExec(nameRE, functionToString(this))[1];
6703 } catch (error) {
6704 return '';
6705 }
6706 }
6707 });
6708 }
6709
6710 /***/ }),
6711 /* 194 */
6712 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6713
6714 var $ = __webpack_require__(2);
6715
6716 var global = __webpack_require__(3); // `globalThis` object
6717 // https://tc39.es/ecma262/#sec-globalthis
6718
6719
6720 $({
6721 global: true
6722 }, {
6723 globalThis: global
6724 });
6725
6726 /***/ }),
6727 /* 195 */
6728 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6729
6730 var $ = __webpack_require__(2);
6731
6732 var global = __webpack_require__(3);
6733
6734 var getBuiltIn = __webpack_require__(20);
6735
6736 var apply = __webpack_require__(62);
6737
6738 var uncurryThis = __webpack_require__(12);
6739
6740 var fails = __webpack_require__(6);
6741
6742 var Array = global.Array;
6743 var $stringify = getBuiltIn('JSON', 'stringify');
6744 var exec = uncurryThis(/./.exec);
6745 var charAt = uncurryThis(''.charAt);
6746 var charCodeAt = uncurryThis(''.charCodeAt);
6747 var replace = uncurryThis(''.replace);
6748 var numberToString = uncurryThis(1.0.toString);
6749 var tester = /[\uD800-\uDFFF]/g;
6750 var low = /^[\uD800-\uDBFF]$/;
6751 var hi = /^[\uDC00-\uDFFF]$/;
6752
6753 var fix = function (match, offset, string) {
6754 var prev = charAt(string, offset - 1);
6755 var next = charAt(string, offset + 1);
6756
6757 if (exec(low, match) && !exec(hi, next) || exec(hi, match) && !exec(low, prev)) {
6758 return '\\u' + numberToString(charCodeAt(match, 0), 16);
6759 }
6760
6761 return match;
6762 };
6763
6764 var FORCED = fails(function () {
6765 return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"' || $stringify('\uDEAD') !== '"\\udead"';
6766 });
6767
6768 if ($stringify) {
6769 // `JSON.stringify` method
6770 // https://tc39.es/ecma262/#sec-json.stringify
6771 // https://github.com/tc39/proposal-well-formed-stringify
6772 $({
6773 target: 'JSON',
6774 stat: true,
6775 forced: FORCED
6776 }, {
6777 // eslint-disable-next-line no-unused-vars -- required for `.length`
6778 stringify: function stringify(it, replacer, space) {
6779 for (var i = 0, l = arguments.length, args = Array(l); i < l; i++) args[i] = arguments[i];
6780
6781 var result = apply($stringify, null, args);
6782 return typeof result == 'string' ? replace(result, tester, fix) : result;
6783 }
6784 });
6785 }
6786
6787 /***/ }),
6788 /* 196 */
6789 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6790
6791 var global = __webpack_require__(3);
6792
6793 var setToStringTag = __webpack_require__(78); // JSON[@@toStringTag] property
6794 // https://tc39.es/ecma262/#sec-json-@@tostringtag
6795
6796
6797 setToStringTag(global.JSON, 'JSON', true);
6798
6799 /***/ }),
6800 /* 197 */
6801 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
6802
6803 "use strict";
6804
6805
6806 var collection = __webpack_require__(198);
6807
6808 var collectionStrong = __webpack_require__(204); // `Map` constructor
6809 // https://tc39.es/ecma262/#sec-map-objects
6810
6811
6812 collection('Map', function (init) {
6813 return function Map() {
6814 return init(this, arguments.length ? arguments[0] : undefined);
6815 };
6816 }, collectionStrong);
6817
6818 /***/ }),
6819 /* 198 */
6820 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6821
6822 "use strict";
6823
6824
6825 var $ = __webpack_require__(2);
6826
6827 var global = __webpack_require__(3);
6828
6829 var uncurryThis = __webpack_require__(12);
6830
6831 var isForced = __webpack_require__(61);
6832
6833 var redefine = __webpack_require__(43);
6834
6835 var InternalMetadataModule = __webpack_require__(199);
6836
6837 var iterate = __webpack_require__(105);
6838
6839 var anInstance = __webpack_require__(168);
6840
6841 var isCallable = __webpack_require__(18);
6842
6843 var isObject = __webpack_require__(17);
6844
6845 var fails = __webpack_require__(6);
6846
6847 var checkCorrectnessOfIteration = __webpack_require__(134);
6848
6849 var setToStringTag = __webpack_require__(78);
6850
6851 var inheritIfRequired = __webpack_require__(203);
6852
6853 module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
6854 var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
6855 var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
6856 var ADDER = IS_MAP ? 'set' : 'add';
6857 var NativeConstructor = global[CONSTRUCTOR_NAME];
6858 var NativePrototype = NativeConstructor && NativeConstructor.prototype;
6859 var Constructor = NativeConstructor;
6860 var exported = {};
6861
6862 var fixMethod = function (KEY) {
6863 var uncurriedNativeMethod = uncurryThis(NativePrototype[KEY]);
6864 redefine(NativePrototype, KEY, KEY == 'add' ? function add(value) {
6865 uncurriedNativeMethod(this, value === 0 ? 0 : value);
6866 return this;
6867 } : KEY == 'delete' ? function (key) {
6868 return IS_WEAK && !isObject(key) ? false : uncurriedNativeMethod(this, key === 0 ? 0 : key);
6869 } : KEY == 'get' ? function get(key) {
6870 return IS_WEAK && !isObject(key) ? undefined : uncurriedNativeMethod(this, key === 0 ? 0 : key);
6871 } : KEY == 'has' ? function has(key) {
6872 return IS_WEAK && !isObject(key) ? false : uncurriedNativeMethod(this, key === 0 ? 0 : key);
6873 } : function set(key, value) {
6874 uncurriedNativeMethod(this, key === 0 ? 0 : key, value);
6875 return this;
6876 });
6877 };
6878
6879 var REPLACE = isForced(CONSTRUCTOR_NAME, !isCallable(NativeConstructor) || !(IS_WEAK || NativePrototype.forEach && !fails(function () {
6880 new NativeConstructor().entries().next();
6881 })));
6882
6883 if (REPLACE) {
6884 // create collection constructor
6885 Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
6886 InternalMetadataModule.enable();
6887 } else if (isForced(CONSTRUCTOR_NAME, true)) {
6888 var instance = new Constructor(); // early implementations not supports chaining
6889
6890 var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance; // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
6891
6892 var THROWS_ON_PRIMITIVES = fails(function () {
6893 instance.has(1);
6894 }); // most early implementations doesn't supports iterables, most modern - not close it correctly
6895 // eslint-disable-next-line no-new -- required for testing
6896
6897 var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) {
6898 new NativeConstructor(iterable);
6899 }); // for early implementations -0 and +0 not the same
6900
6901 var BUGGY_ZERO = !IS_WEAK && fails(function () {
6902 // V8 ~ Chromium 42- fails only with 5+ elements
6903 var $instance = new NativeConstructor();
6904 var index = 5;
6905
6906 while (index--) $instance[ADDER](index, index);
6907
6908 return !$instance.has(-0);
6909 });
6910
6911 if (!ACCEPT_ITERABLES) {
6912 Constructor = wrapper(function (dummy, iterable) {
6913 anInstance(dummy, NativePrototype);
6914 var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor);
6915 if (iterable != undefined) iterate(iterable, that[ADDER], {
6916 that: that,
6917 AS_ENTRIES: IS_MAP
6918 });
6919 return that;
6920 });
6921 Constructor.prototype = NativePrototype;
6922 NativePrototype.constructor = Constructor;
6923 }
6924
6925 if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
6926 fixMethod('delete');
6927 fixMethod('has');
6928 IS_MAP && fixMethod('get');
6929 }
6930
6931 if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); // weak collections should not contains .clear method
6932
6933 if (IS_WEAK && NativePrototype.clear) delete NativePrototype.clear;
6934 }
6935
6936 exported[CONSTRUCTOR_NAME] = Constructor;
6937 $({
6938 global: true,
6939 forced: Constructor != NativeConstructor
6940 }, exported);
6941 setToStringTag(Constructor, CONSTRUCTOR_NAME);
6942 if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
6943 return Constructor;
6944 };
6945
6946 /***/ }),
6947 /* 199 */
6948 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6949
6950 var $ = __webpack_require__(2);
6951
6952 var uncurryThis = __webpack_require__(12);
6953
6954 var hiddenKeys = __webpack_require__(48);
6955
6956 var isObject = __webpack_require__(17);
6957
6958 var hasOwn = __webpack_require__(35);
6959
6960 var defineProperty = (__webpack_require__(41).f);
6961
6962 var getOwnPropertyNamesModule = __webpack_require__(52);
6963
6964 var getOwnPropertyNamesExternalModule = __webpack_require__(71);
6965
6966 var isExtensible = __webpack_require__(200);
6967
6968 var uid = __webpack_require__(37);
6969
6970 var FREEZING = __webpack_require__(202);
6971
6972 var REQUIRED = false;
6973 var METADATA = uid('meta');
6974 var id = 0;
6975
6976 var setMetadata = function (it) {
6977 defineProperty(it, METADATA, {
6978 value: {
6979 objectID: 'O' + id++,
6980 // object ID
6981 weakData: {} // weak collections IDs
6982
6983 }
6984 });
6985 };
6986
6987 var fastKey = function (it, create) {
6988 // return a primitive with prefix
6989 if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
6990
6991 if (!hasOwn(it, METADATA)) {
6992 // can't set metadata to uncaught frozen object
6993 if (!isExtensible(it)) return 'F'; // not necessary to add metadata
6994
6995 if (!create) return 'E'; // add missing metadata
6996
6997 setMetadata(it); // return object ID
6998 }
6999
7000 return it[METADATA].objectID;
7001 };
7002
7003 var getWeakData = function (it, create) {
7004 if (!hasOwn(it, METADATA)) {
7005 // can't set metadata to uncaught frozen object
7006 if (!isExtensible(it)) return true; // not necessary to add metadata
7007
7008 if (!create) return false; // add missing metadata
7009
7010 setMetadata(it); // return the store of weak collections IDs
7011 }
7012
7013 return it[METADATA].weakData;
7014 }; // add metadata on freeze-family methods calling
7015
7016
7017 var onFreeze = function (it) {
7018 if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA)) setMetadata(it);
7019 return it;
7020 };
7021
7022 var enable = function () {
7023 meta.enable = function () {
7024 /* empty */
7025 };
7026
7027 REQUIRED = true;
7028 var getOwnPropertyNames = getOwnPropertyNamesModule.f;
7029 var splice = uncurryThis([].splice);
7030 var test = {};
7031 test[METADATA] = 1; // prevent exposing of metadata key
7032
7033 if (getOwnPropertyNames(test).length) {
7034 getOwnPropertyNamesModule.f = function (it) {
7035 var result = getOwnPropertyNames(it);
7036
7037 for (var i = 0, length = result.length; i < length; i++) {
7038 if (result[i] === METADATA) {
7039 splice(result, i, 1);
7040 break;
7041 }
7042 }
7043
7044 return result;
7045 };
7046
7047 $({
7048 target: 'Object',
7049 stat: true,
7050 forced: true
7051 }, {
7052 getOwnPropertyNames: getOwnPropertyNamesExternalModule.f
7053 });
7054 }
7055 };
7056
7057 var meta = module.exports = {
7058 enable: enable,
7059 fastKey: fastKey,
7060 getWeakData: getWeakData,
7061 onFreeze: onFreeze
7062 };
7063 hiddenKeys[METADATA] = true;
7064
7065 /***/ }),
7066 /* 200 */
7067 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
7068
7069 var fails = __webpack_require__(6);
7070
7071 var isObject = __webpack_require__(17);
7072
7073 var classof = __webpack_require__(13);
7074
7075 var ARRAY_BUFFER_NON_EXTENSIBLE = __webpack_require__(201); // eslint-disable-next-line es/no-object-isextensible -- safe
7076
7077
7078 var $isExtensible = Object.isExtensible;
7079 var FAILS_ON_PRIMITIVES = fails(function () {
7080 $isExtensible(1);
7081 }); // `Object.isExtensible` method
7082 // https://tc39.es/ecma262/#sec-object.isextensible
7083
7084 module.exports = FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE ? function isExtensible(it) {
7085 if (!isObject(it)) return false;
7086 if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return false;
7087 return $isExtensible ? $isExtensible(it) : true;
7088 } : $isExtensible;
7089
7090 /***/ }),
7091 /* 201 */
7092 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
7093
7094 // FF26- bug: ArrayBuffers are non-extensible, but Object.isExtensible does not report it
7095 var fails = __webpack_require__(6);
7096
7097 module.exports = fails(function () {
7098 if (typeof ArrayBuffer == 'function') {
7099 var buffer = new ArrayBuffer(8); // eslint-disable-next-line es/no-object-isextensible, es/no-object-defineproperty -- safe
7100
7101 if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', {
7102 value: 8
7103 });
7104 }
7105 });
7106
7107 /***/ }),
7108 /* 202 */
7109 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
7110
7111 var fails = __webpack_require__(6);
7112
7113 module.exports = !fails(function () {
7114 // eslint-disable-next-line es/no-object-isextensible, es/no-object-preventextensions -- required for testing
7115 return Object.isExtensible(Object.preventExtensions({}));
7116 });
7117
7118 /***/ }),
7119 /* 203 */
7120 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
7121
7122 var isCallable = __webpack_require__(18);
7123
7124 var isObject = __webpack_require__(17);
7125
7126 var setPrototypeOf = __webpack_require__(101); // makes subclassing work correct for wrapped built-ins
7127
7128
7129 module.exports = function ($this, dummy, Wrapper) {
7130 var NewTarget, NewTargetPrototype;
7131 if ( // it can work only with native `setPrototypeOf`
7132 setPrototypeOf && // we haven't completely correct pre-ES6 way for getting `new.target`, so use this
7133 isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype) setPrototypeOf($this, NewTargetPrototype);
7134 return $this;
7135 };
7136
7137 /***/ }),
7138 /* 204 */
7139 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
7140
7141 "use strict";
7142
7143
7144 var defineProperty = (__webpack_require__(41).f);
7145
7146 var create = __webpack_require__(67);
7147
7148 var redefineAll = __webpack_require__(167);
7149
7150 var bind = __webpack_require__(80);
7151
7152 var anInstance = __webpack_require__(168);
7153
7154 var iterate = __webpack_require__(105);
7155
7156 var defineIterator = __webpack_require__(139);
7157
7158 var setSpecies = __webpack_require__(160);
7159
7160 var DESCRIPTORS = __webpack_require__(5);
7161
7162 var fastKey = (__webpack_require__(199).fastKey);
7163
7164 var InternalStateModule = __webpack_require__(45);
7165
7166 var setInternalState = InternalStateModule.set;
7167 var internalStateGetterFor = InternalStateModule.getterFor;
7168 module.exports = {
7169 getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
7170 var Constructor = wrapper(function (that, iterable) {
7171 anInstance(that, Prototype);
7172 setInternalState(that, {
7173 type: CONSTRUCTOR_NAME,
7174 index: create(null),
7175 first: undefined,
7176 last: undefined,
7177 size: 0
7178 });
7179 if (!DESCRIPTORS) that.size = 0;
7180 if (iterable != undefined) iterate(iterable, that[ADDER], {
7181 that: that,
7182 AS_ENTRIES: IS_MAP
7183 });
7184 });
7185 var Prototype = Constructor.prototype;
7186 var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
7187
7188 var define = function (that, key, value) {
7189 var state = getInternalState(that);
7190 var entry = getEntry(that, key);
7191 var previous, index; // change existing entry
7192
7193 if (entry) {
7194 entry.value = value; // create new entry
7195 } else {
7196 state.last = entry = {
7197 index: index = fastKey(key, true),
7198 key: key,
7199 value: value,
7200 previous: previous = state.last,
7201 next: undefined,
7202 removed: false
7203 };
7204 if (!state.first) state.first = entry;
7205 if (previous) previous.next = entry;
7206 if (DESCRIPTORS) state.size++;else that.size++; // add to index
7207
7208 if (index !== 'F') state.index[index] = entry;
7209 }
7210
7211 return that;
7212 };
7213
7214 var getEntry = function (that, key) {
7215 var state = getInternalState(that); // fast case
7216
7217 var index = fastKey(key);
7218 var entry;
7219 if (index !== 'F') return state.index[index]; // frozen object case
7220
7221 for (entry = state.first; entry; entry = entry.next) {
7222 if (entry.key == key) return entry;
7223 }
7224 };
7225
7226 redefineAll(Prototype, {
7227 // `{ Map, Set }.prototype.clear()` methods
7228 // https://tc39.es/ecma262/#sec-map.prototype.clear
7229 // https://tc39.es/ecma262/#sec-set.prototype.clear
7230 clear: function clear() {
7231 var that = this;
7232 var state = getInternalState(that);
7233 var data = state.index;
7234 var entry = state.first;
7235
7236 while (entry) {
7237 entry.removed = true;
7238 if (entry.previous) entry.previous = entry.previous.next = undefined;
7239 delete data[entry.index];
7240 entry = entry.next;
7241 }
7242
7243 state.first = state.last = undefined;
7244 if (DESCRIPTORS) state.size = 0;else that.size = 0;
7245 },
7246 // `{ Map, Set }.prototype.delete(key)` methods
7247 // https://tc39.es/ecma262/#sec-map.prototype.delete
7248 // https://tc39.es/ecma262/#sec-set.prototype.delete
7249 'delete': function (key) {
7250 var that = this;
7251 var state = getInternalState(that);
7252 var entry = getEntry(that, key);
7253
7254 if (entry) {
7255 var next = entry.next;
7256 var prev = entry.previous;
7257 delete state.index[entry.index];
7258 entry.removed = true;
7259 if (prev) prev.next = next;
7260 if (next) next.previous = prev;
7261 if (state.first == entry) state.first = next;
7262 if (state.last == entry) state.last = prev;
7263 if (DESCRIPTORS) state.size--;else that.size--;
7264 }
7265
7266 return !!entry;
7267 },
7268 // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods
7269 // https://tc39.es/ecma262/#sec-map.prototype.foreach
7270 // https://tc39.es/ecma262/#sec-set.prototype.foreach
7271 forEach: function forEach(callbackfn
7272 /* , that = undefined */
7273 ) {
7274 var state = getInternalState(this);
7275 var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
7276 var entry;
7277
7278 while (entry = entry ? entry.next : state.first) {
7279 boundFunction(entry.value, entry.key, this); // revert to the last existing entry
7280
7281 while (entry && entry.removed) entry = entry.previous;
7282 }
7283 },
7284 // `{ Map, Set}.prototype.has(key)` methods
7285 // https://tc39.es/ecma262/#sec-map.prototype.has
7286 // https://tc39.es/ecma262/#sec-set.prototype.has
7287 has: function has(key) {
7288 return !!getEntry(this, key);
7289 }
7290 });
7291 redefineAll(Prototype, IS_MAP ? {
7292 // `Map.prototype.get(key)` method
7293 // https://tc39.es/ecma262/#sec-map.prototype.get
7294 get: function get(key) {
7295 var entry = getEntry(this, key);
7296 return entry && entry.value;
7297 },
7298 // `Map.prototype.set(key, value)` method
7299 // https://tc39.es/ecma262/#sec-map.prototype.set
7300 set: function set(key, value) {
7301 return define(this, key === 0 ? 0 : key, value);
7302 }
7303 } : {
7304 // `Set.prototype.add(value)` method
7305 // https://tc39.es/ecma262/#sec-set.prototype.add
7306 add: function add(value) {
7307 return define(this, value = value === 0 ? 0 : value, value);
7308 }
7309 });
7310 if (DESCRIPTORS) defineProperty(Prototype, 'size', {
7311 get: function () {
7312 return getInternalState(this).size;
7313 }
7314 });
7315 return Constructor;
7316 },
7317 setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) {
7318 var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
7319 var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
7320 var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME); // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods
7321 // https://tc39.es/ecma262/#sec-map.prototype.entries
7322 // https://tc39.es/ecma262/#sec-map.prototype.keys
7323 // https://tc39.es/ecma262/#sec-map.prototype.values
7324 // https://tc39.es/ecma262/#sec-map.prototype-@@iterator
7325 // https://tc39.es/ecma262/#sec-set.prototype.entries
7326 // https://tc39.es/ecma262/#sec-set.prototype.keys
7327 // https://tc39.es/ecma262/#sec-set.prototype.values
7328 // https://tc39.es/ecma262/#sec-set.prototype-@@iterator
7329
7330 defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) {
7331 setInternalState(this, {
7332 type: ITERATOR_NAME,
7333 target: iterated,
7334 state: getInternalCollectionState(iterated),
7335 kind: kind,
7336 last: undefined
7337 });
7338 }, function () {
7339 var state = getInternalIteratorState(this);
7340 var kind = state.kind;
7341 var entry = state.last; // revert to the last existing entry
7342
7343 while (entry && entry.removed) entry = entry.previous; // get next entry
7344
7345
7346 if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
7347 // or finish the iteration
7348 state.target = undefined;
7349 return {
7350 value: undefined,
7351 done: true
7352 };
7353 } // return step by kind
7354
7355
7356 if (kind == 'keys') return {
7357 value: entry.key,
7358 done: false
7359 };
7360 if (kind == 'values') return {
7361 value: entry.value,
7362 done: false
7363 };
7364 return {
7365 value: [entry.key, entry.value],
7366 done: false
7367 };
7368 }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); // `{ Map, Set }.prototype[@@species]` accessors
7369 // https://tc39.es/ecma262/#sec-get-map-@@species
7370 // https://tc39.es/ecma262/#sec-get-set-@@species
7371
7372 setSpecies(CONSTRUCTOR_NAME);
7373 }
7374 };
7375
7376 /***/ }),
7377 /* 205 */
7378 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7379
7380 var $ = __webpack_require__(2);
7381
7382 var log1p = __webpack_require__(206); // eslint-disable-next-line es/no-math-acosh -- required for testing
7383
7384
7385 var $acosh = Math.acosh;
7386 var log = Math.log;
7387 var sqrt = Math.sqrt;
7388 var LN2 = Math.LN2;
7389 var FORCED = !$acosh // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509
7390 || Math.floor($acosh(Number.MAX_VALUE)) != 710 // Tor Browser bug: Math.acosh(Infinity) -> NaN
7391 || $acosh(Infinity) != Infinity; // `Math.acosh` method
7392 // https://tc39.es/ecma262/#sec-math.acosh
7393
7394 $({
7395 target: 'Math',
7396 stat: true,
7397 forced: FORCED
7398 }, {
7399 acosh: function acosh(x) {
7400 return (x = +x) < 1 ? NaN : x > 94906265.62425156 ? log(x) + LN2 : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));
7401 }
7402 });
7403
7404 /***/ }),
7405 /* 206 */
7406 /***/ ((module) => {
7407
7408 var log = Math.log; // `Math.log1p` method implementation
7409 // https://tc39.es/ecma262/#sec-math.log1p
7410 // eslint-disable-next-line es/no-math-log1p -- safe
7411
7412 module.exports = Math.log1p || function log1p(x) {
7413 return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : log(1 + x);
7414 };
7415
7416 /***/ }),
7417 /* 207 */
7418 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7419
7420 var $ = __webpack_require__(2); // eslint-disable-next-line es/no-math-asinh -- required for testing
7421
7422
7423 var $asinh = Math.asinh;
7424 var log = Math.log;
7425 var sqrt = Math.sqrt;
7426
7427 function asinh(x) {
7428 return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : log(x + sqrt(x * x + 1));
7429 } // `Math.asinh` method
7430 // https://tc39.es/ecma262/#sec-math.asinh
7431 // Tor Browser bug: Math.asinh(0) -> -0
7432
7433
7434 $({
7435 target: 'Math',
7436 stat: true,
7437 forced: !($asinh && 1 / $asinh(0) > 0)
7438 }, {
7439 asinh: asinh
7440 });
7441
7442 /***/ }),
7443 /* 208 */
7444 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7445
7446 var $ = __webpack_require__(2); // eslint-disable-next-line es/no-math-atanh -- required for testing
7447
7448
7449 var $atanh = Math.atanh;
7450 var log = Math.log; // `Math.atanh` method
7451 // https://tc39.es/ecma262/#sec-math.atanh
7452 // Tor Browser bug: Math.atanh(-0) -> 0
7453
7454 $({
7455 target: 'Math',
7456 stat: true,
7457 forced: !($atanh && 1 / $atanh(-0) < 0)
7458 }, {
7459 atanh: function atanh(x) {
7460 return (x = +x) == 0 ? x : log((1 + x) / (1 - x)) / 2;
7461 }
7462 });
7463
7464 /***/ }),
7465 /* 209 */
7466 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7467
7468 var $ = __webpack_require__(2);
7469
7470 var sign = __webpack_require__(210);
7471
7472 var abs = Math.abs;
7473 var pow = Math.pow; // `Math.cbrt` method
7474 // https://tc39.es/ecma262/#sec-math.cbrt
7475
7476 $({
7477 target: 'Math',
7478 stat: true
7479 }, {
7480 cbrt: function cbrt(x) {
7481 return sign(x = +x) * pow(abs(x), 1 / 3);
7482 }
7483 });
7484
7485 /***/ }),
7486 /* 210 */
7487 /***/ ((module) => {
7488
7489 // `Math.sign` method implementation
7490 // https://tc39.es/ecma262/#sec-math.sign
7491 // eslint-disable-next-line es/no-math-sign -- safe
7492 module.exports = Math.sign || function sign(x) {
7493 // eslint-disable-next-line no-self-compare -- NaN check
7494 return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
7495 };
7496
7497 /***/ }),
7498 /* 211 */
7499 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7500
7501 var $ = __webpack_require__(2);
7502
7503 var floor = Math.floor;
7504 var log = Math.log;
7505 var LOG2E = Math.LOG2E; // `Math.clz32` method
7506 // https://tc39.es/ecma262/#sec-math.clz32
7507
7508 $({
7509 target: 'Math',
7510 stat: true
7511 }, {
7512 clz32: function clz32(x) {
7513 return (x >>>= 0) ? 31 - floor(log(x + 0.5) * LOG2E) : 32;
7514 }
7515 });
7516
7517 /***/ }),
7518 /* 212 */
7519 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7520
7521 var $ = __webpack_require__(2);
7522
7523 var expm1 = __webpack_require__(213); // eslint-disable-next-line es/no-math-cosh -- required for testing
7524
7525
7526 var $cosh = Math.cosh;
7527 var abs = Math.abs;
7528 var E = Math.E; // `Math.cosh` method
7529 // https://tc39.es/ecma262/#sec-math.cosh
7530
7531 $({
7532 target: 'Math',
7533 stat: true,
7534 forced: !$cosh || $cosh(710) === Infinity
7535 }, {
7536 cosh: function cosh(x) {
7537 var t = expm1(abs(x) - 1) + 1;
7538 return (t + 1 / (t * E * E)) * (E / 2);
7539 }
7540 });
7541
7542 /***/ }),
7543 /* 213 */
7544 /***/ ((module) => {
7545
7546 // eslint-disable-next-line es/no-math-expm1 -- safe
7547 var $expm1 = Math.expm1;
7548 var exp = Math.exp; // `Math.expm1` method implementation
7549 // https://tc39.es/ecma262/#sec-math.expm1
7550
7551 module.exports = !$expm1 // Old FF bug
7552 || $expm1(10) > 22025.465794806719 || $expm1(10) < 22025.4657948067165168 // Tor Browser bug
7553 || $expm1(-2e-17) != -2e-17 ? function expm1(x) {
7554 return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : exp(x) - 1;
7555 } : $expm1;
7556
7557 /***/ }),
7558 /* 214 */
7559 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7560
7561 var $ = __webpack_require__(2);
7562
7563 var expm1 = __webpack_require__(213); // `Math.expm1` method
7564 // https://tc39.es/ecma262/#sec-math.expm1
7565 // eslint-disable-next-line es/no-math-expm1 -- required for testing
7566
7567
7568 $({
7569 target: 'Math',
7570 stat: true,
7571 forced: expm1 != Math.expm1
7572 }, {
7573 expm1: expm1
7574 });
7575
7576 /***/ }),
7577 /* 215 */
7578 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7579
7580 var $ = __webpack_require__(2);
7581
7582 var fround = __webpack_require__(216); // `Math.fround` method
7583 // https://tc39.es/ecma262/#sec-math.fround
7584
7585
7586 $({
7587 target: 'Math',
7588 stat: true
7589 }, {
7590 fround: fround
7591 });
7592
7593 /***/ }),
7594 /* 216 */
7595 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
7596
7597 var sign = __webpack_require__(210);
7598
7599 var abs = Math.abs;
7600 var pow = Math.pow;
7601 var EPSILON = pow(2, -52);
7602 var EPSILON32 = pow(2, -23);
7603 var MAX32 = pow(2, 127) * (2 - EPSILON32);
7604 var MIN32 = pow(2, -126);
7605
7606 var roundTiesToEven = function (n) {
7607 return n + 1 / EPSILON - 1 / EPSILON;
7608 }; // `Math.fround` method implementation
7609 // https://tc39.es/ecma262/#sec-math.fround
7610 // eslint-disable-next-line es/no-math-fround -- safe
7611
7612
7613 module.exports = Math.fround || function fround(x) {
7614 var $abs = abs(x);
7615 var $sign = sign(x);
7616 var a, result;
7617 if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;
7618 a = (1 + EPSILON32 / EPSILON) * $abs;
7619 result = a - (a - $abs); // eslint-disable-next-line no-self-compare -- NaN check
7620
7621 if (result > MAX32 || result != result) return $sign * Infinity;
7622 return $sign * result;
7623 };
7624
7625 /***/ }),
7626 /* 217 */
7627 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7628
7629 var $ = __webpack_require__(2); // eslint-disable-next-line es/no-math-hypot -- required for testing
7630
7631
7632 var $hypot = Math.hypot;
7633 var abs = Math.abs;
7634 var sqrt = Math.sqrt; // Chrome 77 bug
7635 // https://bugs.chromium.org/p/v8/issues/detail?id=9546
7636
7637 var BUGGY = !!$hypot && $hypot(Infinity, NaN) !== Infinity; // `Math.hypot` method
7638 // https://tc39.es/ecma262/#sec-math.hypot
7639
7640 $({
7641 target: 'Math',
7642 stat: true,
7643 forced: BUGGY
7644 }, {
7645 // eslint-disable-next-line no-unused-vars -- required for `.length`
7646 hypot: function hypot(value1, value2) {
7647 var sum = 0;
7648 var i = 0;
7649 var aLen = arguments.length;
7650 var larg = 0;
7651 var arg, div;
7652
7653 while (i < aLen) {
7654 arg = abs(arguments[i++]);
7655
7656 if (larg < arg) {
7657 div = larg / arg;
7658 sum = sum * div * div + 1;
7659 larg = arg;
7660 } else if (arg > 0) {
7661 div = arg / larg;
7662 sum += div * div;
7663 } else sum += arg;
7664 }
7665
7666 return larg === Infinity ? Infinity : larg * sqrt(sum);
7667 }
7668 });
7669
7670 /***/ }),
7671 /* 218 */
7672 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7673
7674 var $ = __webpack_require__(2);
7675
7676 var fails = __webpack_require__(6); // eslint-disable-next-line es/no-math-imul -- required for testing
7677
7678
7679 var $imul = Math.imul;
7680 var FORCED = fails(function () {
7681 return $imul(0xFFFFFFFF, 5) != -5 || $imul.length != 2;
7682 }); // `Math.imul` method
7683 // https://tc39.es/ecma262/#sec-math.imul
7684 // some WebKit versions fails with big numbers, some has wrong arity
7685
7686 $({
7687 target: 'Math',
7688 stat: true,
7689 forced: FORCED
7690 }, {
7691 imul: function imul(x, y) {
7692 var UINT16 = 0xFFFF;
7693 var xn = +x;
7694 var yn = +y;
7695 var xl = UINT16 & xn;
7696 var yl = UINT16 & yn;
7697 return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);
7698 }
7699 });
7700
7701 /***/ }),
7702 /* 219 */
7703 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7704
7705 var $ = __webpack_require__(2);
7706
7707 var log = Math.log;
7708 var LOG10E = Math.LOG10E; // `Math.log10` method
7709 // https://tc39.es/ecma262/#sec-math.log10
7710
7711 $({
7712 target: 'Math',
7713 stat: true
7714 }, {
7715 log10: function log10(x) {
7716 return log(x) * LOG10E;
7717 }
7718 });
7719
7720 /***/ }),
7721 /* 220 */
7722 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7723
7724 var $ = __webpack_require__(2);
7725
7726 var log1p = __webpack_require__(206); // `Math.log1p` method
7727 // https://tc39.es/ecma262/#sec-math.log1p
7728
7729
7730 $({
7731 target: 'Math',
7732 stat: true
7733 }, {
7734 log1p: log1p
7735 });
7736
7737 /***/ }),
7738 /* 221 */
7739 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7740
7741 var $ = __webpack_require__(2);
7742
7743 var log = Math.log;
7744 var LN2 = Math.LN2; // `Math.log2` method
7745 // https://tc39.es/ecma262/#sec-math.log2
7746
7747 $({
7748 target: 'Math',
7749 stat: true
7750 }, {
7751 log2: function log2(x) {
7752 return log(x) / LN2;
7753 }
7754 });
7755
7756 /***/ }),
7757 /* 222 */
7758 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7759
7760 var $ = __webpack_require__(2);
7761
7762 var sign = __webpack_require__(210); // `Math.sign` method
7763 // https://tc39.es/ecma262/#sec-math.sign
7764
7765
7766 $({
7767 target: 'Math',
7768 stat: true
7769 }, {
7770 sign: sign
7771 });
7772
7773 /***/ }),
7774 /* 223 */
7775 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7776
7777 var $ = __webpack_require__(2);
7778
7779 var fails = __webpack_require__(6);
7780
7781 var expm1 = __webpack_require__(213);
7782
7783 var abs = Math.abs;
7784 var exp = Math.exp;
7785 var E = Math.E;
7786 var FORCED = fails(function () {
7787 // eslint-disable-next-line es/no-math-sinh -- required for testing
7788 return Math.sinh(-2e-17) != -2e-17;
7789 }); // `Math.sinh` method
7790 // https://tc39.es/ecma262/#sec-math.sinh
7791 // V8 near Chromium 38 has a problem with very small numbers
7792
7793 $({
7794 target: 'Math',
7795 stat: true,
7796 forced: FORCED
7797 }, {
7798 sinh: function sinh(x) {
7799 return abs(x = +x) < 1 ? (expm1(x) - expm1(-x)) / 2 : (exp(x - 1) - exp(-x - 1)) * (E / 2);
7800 }
7801 });
7802
7803 /***/ }),
7804 /* 224 */
7805 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7806
7807 var $ = __webpack_require__(2);
7808
7809 var expm1 = __webpack_require__(213);
7810
7811 var exp = Math.exp; // `Math.tanh` method
7812 // https://tc39.es/ecma262/#sec-math.tanh
7813
7814 $({
7815 target: 'Math',
7816 stat: true
7817 }, {
7818 tanh: function tanh(x) {
7819 var a = expm1(x = +x);
7820 var b = expm1(-x);
7821 return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
7822 }
7823 });
7824
7825 /***/ }),
7826 /* 225 */
7827 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7828
7829 var setToStringTag = __webpack_require__(78); // Math[@@toStringTag] property
7830 // https://tc39.es/ecma262/#sec-math-@@tostringtag
7831
7832
7833 setToStringTag(Math, 'Math', true);
7834
7835 /***/ }),
7836 /* 226 */
7837 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7838
7839 var $ = __webpack_require__(2);
7840
7841 var ceil = Math.ceil;
7842 var floor = Math.floor; // `Math.trunc` method
7843 // https://tc39.es/ecma262/#sec-math.trunc
7844
7845 $({
7846 target: 'Math',
7847 stat: true
7848 }, {
7849 trunc: function trunc(it) {
7850 return (it > 0 ? floor : ceil)(it);
7851 }
7852 });
7853
7854 /***/ }),
7855 /* 227 */
7856 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
7857
7858 "use strict";
7859
7860
7861 var DESCRIPTORS = __webpack_require__(5);
7862
7863 var global = __webpack_require__(3);
7864
7865 var uncurryThis = __webpack_require__(12);
7866
7867 var isForced = __webpack_require__(61);
7868
7869 var redefine = __webpack_require__(43);
7870
7871 var hasOwn = __webpack_require__(35);
7872
7873 var inheritIfRequired = __webpack_require__(203);
7874
7875 var isPrototypeOf = __webpack_require__(21);
7876
7877 var isSymbol = __webpack_require__(19);
7878
7879 var toPrimitive = __webpack_require__(16);
7880
7881 var fails = __webpack_require__(6);
7882
7883 var getOwnPropertyNames = (__webpack_require__(52).f);
7884
7885 var getOwnPropertyDescriptor = (__webpack_require__(4).f);
7886
7887 var defineProperty = (__webpack_require__(41).f);
7888
7889 var thisNumberValue = __webpack_require__(228);
7890
7891 var trim = (__webpack_require__(229).trim);
7892
7893 var NUMBER = 'Number';
7894 var NativeNumber = global[NUMBER];
7895 var NumberPrototype = NativeNumber.prototype;
7896 var TypeError = global.TypeError;
7897 var arraySlice = uncurryThis(''.slice);
7898 var charCodeAt = uncurryThis(''.charCodeAt); // `ToNumeric` abstract operation
7899 // https://tc39.es/ecma262/#sec-tonumeric
7900
7901 var toNumeric = function (value) {
7902 var primValue = toPrimitive(value, 'number');
7903 return typeof primValue == 'bigint' ? primValue : toNumber(primValue);
7904 }; // `ToNumber` abstract operation
7905 // https://tc39.es/ecma262/#sec-tonumber
7906
7907
7908 var toNumber = function (argument) {
7909 var it = toPrimitive(argument, 'number');
7910 var first, third, radix, maxCode, digits, length, index, code;
7911 if (isSymbol(it)) throw TypeError('Cannot convert a Symbol value to a number');
7912
7913 if (typeof it == 'string' && it.length > 2) {
7914 it = trim(it);
7915 first = charCodeAt(it, 0);
7916
7917 if (first === 43 || first === 45) {
7918 third = charCodeAt(it, 2);
7919 if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
7920 } else if (first === 48) {
7921 switch (charCodeAt(it, 1)) {
7922 case 66:
7923 case 98:
7924 radix = 2;
7925 maxCode = 49;
7926 break;
7927 // fast equal of /^0b[01]+$/i
7928
7929 case 79:
7930 case 111:
7931 radix = 8;
7932 maxCode = 55;
7933 break;
7934 // fast equal of /^0o[0-7]+$/i
7935
7936 default:
7937 return +it;
7938 }
7939
7940 digits = arraySlice(it, 2);
7941 length = digits.length;
7942
7943 for (index = 0; index < length; index++) {
7944 code = charCodeAt(digits, index); // parseInt parses a string to a first unavailable symbol
7945 // but ToNumber should return NaN if a string contains unavailable symbols
7946
7947 if (code < 48 || code > maxCode) return NaN;
7948 }
7949
7950 return parseInt(digits, radix);
7951 }
7952 }
7953
7954 return +it;
7955 }; // `Number` constructor
7956 // https://tc39.es/ecma262/#sec-number-constructor
7957
7958
7959 if (isForced(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {
7960 var NumberWrapper = function Number(value) {
7961 var n = arguments.length < 1 ? 0 : NativeNumber(toNumeric(value));
7962 var dummy = this; // check on 1..constructor(foo) case
7963
7964 return isPrototypeOf(NumberPrototype, dummy) && fails(function () {
7965 thisNumberValue(dummy);
7966 }) ? inheritIfRequired(Object(n), dummy, NumberWrapper) : n;
7967 };
7968
7969 for (var keys = DESCRIPTORS ? getOwnPropertyNames(NativeNumber) : ( // ES3:
7970 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' + // ES2015 (in case, if modules with ES2015 Number statics required before):
7971 'EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,' + // ESNext
7972 'fromString,range').split(','), j = 0, key; keys.length > j; j++) {
7973 if (hasOwn(NativeNumber, key = keys[j]) && !hasOwn(NumberWrapper, key)) {
7974 defineProperty(NumberWrapper, key, getOwnPropertyDescriptor(NativeNumber, key));
7975 }
7976 }
7977
7978 NumberWrapper.prototype = NumberPrototype;
7979 NumberPrototype.constructor = NumberWrapper;
7980 redefine(global, NUMBER, NumberWrapper);
7981 }
7982
7983 /***/ }),
7984 /* 228 */
7985 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
7986
7987 var uncurryThis = __webpack_require__(12); // `thisNumberValue` abstract operation
7988 // https://tc39.es/ecma262/#sec-thisnumbervalue
7989
7990
7991 module.exports = uncurryThis(1.0.valueOf);
7992
7993 /***/ }),
7994 /* 229 */
7995 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
7996
7997 var uncurryThis = __webpack_require__(12);
7998
7999 var requireObjectCoercible = __webpack_require__(14);
8000
8001 var toString = __webpack_require__(64);
8002
8003 var whitespaces = __webpack_require__(230);
8004
8005 var replace = uncurryThis(''.replace);
8006 var whitespace = '[' + whitespaces + ']';
8007 var ltrim = RegExp('^' + whitespace + whitespace + '*');
8008 var rtrim = RegExp(whitespace + whitespace + '*$'); // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
8009
8010 var createMethod = function (TYPE) {
8011 return function ($this) {
8012 var string = toString(requireObjectCoercible($this));
8013 if (TYPE & 1) string = replace(string, ltrim, '');
8014 if (TYPE & 2) string = replace(string, rtrim, '');
8015 return string;
8016 };
8017 };
8018
8019 module.exports = {
8020 // `String.prototype.{ trimLeft, trimStart }` methods
8021 // https://tc39.es/ecma262/#sec-string.prototype.trimstart
8022 start: createMethod(1),
8023 // `String.prototype.{ trimRight, trimEnd }` methods
8024 // https://tc39.es/ecma262/#sec-string.prototype.trimend
8025 end: createMethod(2),
8026 // `String.prototype.trim` method
8027 // https://tc39.es/ecma262/#sec-string.prototype.trim
8028 trim: createMethod(3)
8029 };
8030
8031 /***/ }),
8032 /* 230 */
8033 /***/ ((module) => {
8034
8035 // a string of all valid unicode whitespaces
8036 module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' + '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
8037
8038 /***/ }),
8039 /* 231 */
8040 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8041
8042 var $ = __webpack_require__(2); // `Number.EPSILON` constant
8043 // https://tc39.es/ecma262/#sec-number.epsilon
8044
8045
8046 $({
8047 target: 'Number',
8048 stat: true
8049 }, {
8050 EPSILON: Math.pow(2, -52)
8051 });
8052
8053 /***/ }),
8054 /* 232 */
8055 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8056
8057 var $ = __webpack_require__(2);
8058
8059 var numberIsFinite = __webpack_require__(233); // `Number.isFinite` method
8060 // https://tc39.es/ecma262/#sec-number.isfinite
8061
8062
8063 $({
8064 target: 'Number',
8065 stat: true
8066 }, {
8067 isFinite: numberIsFinite
8068 });
8069
8070 /***/ }),
8071 /* 233 */
8072 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8073
8074 var global = __webpack_require__(3);
8075
8076 var globalIsFinite = global.isFinite; // `Number.isFinite` method
8077 // https://tc39.es/ecma262/#sec-number.isfinite
8078 // eslint-disable-next-line es/no-number-isfinite -- safe
8079
8080 module.exports = Number.isFinite || function isFinite(it) {
8081 return typeof it == 'number' && globalIsFinite(it);
8082 };
8083
8084 /***/ }),
8085 /* 234 */
8086 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8087
8088 var $ = __webpack_require__(2);
8089
8090 var isIntegralNumber = __webpack_require__(235); // `Number.isInteger` method
8091 // https://tc39.es/ecma262/#sec-number.isinteger
8092
8093
8094 $({
8095 target: 'Number',
8096 stat: true
8097 }, {
8098 isInteger: isIntegralNumber
8099 });
8100
8101 /***/ }),
8102 /* 235 */
8103 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8104
8105 var isObject = __webpack_require__(17);
8106
8107 var floor = Math.floor; // `IsIntegralNumber` abstract operation
8108 // https://tc39.es/ecma262/#sec-isintegralnumber
8109 // eslint-disable-next-line es/no-number-isinteger -- safe
8110
8111 module.exports = Number.isInteger || function isInteger(it) {
8112 return !isObject(it) && isFinite(it) && floor(it) === it;
8113 };
8114
8115 /***/ }),
8116 /* 236 */
8117 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8118
8119 var $ = __webpack_require__(2); // `Number.isNaN` method
8120 // https://tc39.es/ecma262/#sec-number.isnan
8121
8122
8123 $({
8124 target: 'Number',
8125 stat: true
8126 }, {
8127 isNaN: function isNaN(number) {
8128 // eslint-disable-next-line no-self-compare -- NaN check
8129 return number != number;
8130 }
8131 });
8132
8133 /***/ }),
8134 /* 237 */
8135 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8136
8137 var $ = __webpack_require__(2);
8138
8139 var isIntegralNumber = __webpack_require__(235);
8140
8141 var abs = Math.abs; // `Number.isSafeInteger` method
8142 // https://tc39.es/ecma262/#sec-number.issafeinteger
8143
8144 $({
8145 target: 'Number',
8146 stat: true
8147 }, {
8148 isSafeInteger: function isSafeInteger(number) {
8149 return isIntegralNumber(number) && abs(number) <= 0x1FFFFFFFFFFFFF;
8150 }
8151 });
8152
8153 /***/ }),
8154 /* 238 */
8155 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8156
8157 var $ = __webpack_require__(2); // `Number.MAX_SAFE_INTEGER` constant
8158 // https://tc39.es/ecma262/#sec-number.max_safe_integer
8159
8160
8161 $({
8162 target: 'Number',
8163 stat: true
8164 }, {
8165 MAX_SAFE_INTEGER: 0x1FFFFFFFFFFFFF
8166 });
8167
8168 /***/ }),
8169 /* 239 */
8170 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8171
8172 var $ = __webpack_require__(2); // `Number.MIN_SAFE_INTEGER` constant
8173 // https://tc39.es/ecma262/#sec-number.min_safe_integer
8174
8175
8176 $({
8177 target: 'Number',
8178 stat: true
8179 }, {
8180 MIN_SAFE_INTEGER: -0x1FFFFFFFFFFFFF
8181 });
8182
8183 /***/ }),
8184 /* 240 */
8185 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8186
8187 var $ = __webpack_require__(2);
8188
8189 var parseFloat = __webpack_require__(241); // `Number.parseFloat` method
8190 // https://tc39.es/ecma262/#sec-number.parseFloat
8191 // eslint-disable-next-line es/no-number-parsefloat -- required for testing
8192
8193
8194 $({
8195 target: 'Number',
8196 stat: true,
8197 forced: Number.parseFloat != parseFloat
8198 }, {
8199 parseFloat: parseFloat
8200 });
8201
8202 /***/ }),
8203 /* 241 */
8204 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8205
8206 var global = __webpack_require__(3);
8207
8208 var fails = __webpack_require__(6);
8209
8210 var uncurryThis = __webpack_require__(12);
8211
8212 var toString = __webpack_require__(64);
8213
8214 var trim = (__webpack_require__(229).trim);
8215
8216 var whitespaces = __webpack_require__(230);
8217
8218 var charAt = uncurryThis(''.charAt);
8219 var n$ParseFloat = global.parseFloat;
8220 var Symbol = global.Symbol;
8221 var ITERATOR = Symbol && Symbol.iterator;
8222 var FORCED = 1 / n$ParseFloat(whitespaces + '-0') !== -Infinity // MS Edge 18- broken with boxed symbols
8223 || ITERATOR && !fails(function () {
8224 n$ParseFloat(Object(ITERATOR));
8225 }); // `parseFloat` method
8226 // https://tc39.es/ecma262/#sec-parsefloat-string
8227
8228 module.exports = FORCED ? function parseFloat(string) {
8229 var trimmedString = trim(toString(string));
8230 var result = n$ParseFloat(trimmedString);
8231 return result === 0 && charAt(trimmedString, 0) == '-' ? -0 : result;
8232 } : n$ParseFloat;
8233
8234 /***/ }),
8235 /* 242 */
8236 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8237
8238 var $ = __webpack_require__(2);
8239
8240 var parseInt = __webpack_require__(243); // `Number.parseInt` method
8241 // https://tc39.es/ecma262/#sec-number.parseint
8242 // eslint-disable-next-line es/no-number-parseint -- required for testing
8243
8244
8245 $({
8246 target: 'Number',
8247 stat: true,
8248 forced: Number.parseInt != parseInt
8249 }, {
8250 parseInt: parseInt
8251 });
8252
8253 /***/ }),
8254 /* 243 */
8255 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8256
8257 var global = __webpack_require__(3);
8258
8259 var fails = __webpack_require__(6);
8260
8261 var uncurryThis = __webpack_require__(12);
8262
8263 var toString = __webpack_require__(64);
8264
8265 var trim = (__webpack_require__(229).trim);
8266
8267 var whitespaces = __webpack_require__(230);
8268
8269 var $parseInt = global.parseInt;
8270 var Symbol = global.Symbol;
8271 var ITERATOR = Symbol && Symbol.iterator;
8272 var hex = /^[+-]?0x/i;
8273 var exec = uncurryThis(hex.exec);
8274 var FORCED = $parseInt(whitespaces + '08') !== 8 || $parseInt(whitespaces + '0x16') !== 22 // MS Edge 18- broken with boxed symbols
8275 || ITERATOR && !fails(function () {
8276 $parseInt(Object(ITERATOR));
8277 }); // `parseInt` method
8278 // https://tc39.es/ecma262/#sec-parseint-string-radix
8279
8280 module.exports = FORCED ? function parseInt(string, radix) {
8281 var S = trim(toString(string));
8282 return $parseInt(S, radix >>> 0 || (exec(hex, S) ? 16 : 10));
8283 } : $parseInt;
8284
8285 /***/ }),
8286 /* 244 */
8287 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8288
8289 "use strict";
8290
8291
8292 var $ = __webpack_require__(2);
8293
8294 var global = __webpack_require__(3);
8295
8296 var uncurryThis = __webpack_require__(12);
8297
8298 var toIntegerOrInfinity = __webpack_require__(56);
8299
8300 var thisNumberValue = __webpack_require__(228);
8301
8302 var $repeat = __webpack_require__(184);
8303
8304 var fails = __webpack_require__(6);
8305
8306 var RangeError = global.RangeError;
8307 var String = global.String;
8308 var floor = Math.floor;
8309 var repeat = uncurryThis($repeat);
8310 var stringSlice = uncurryThis(''.slice);
8311 var un$ToFixed = uncurryThis(1.0.toFixed);
8312
8313 var pow = function (x, n, acc) {
8314 return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc);
8315 };
8316
8317 var log = function (x) {
8318 var n = 0;
8319 var x2 = x;
8320
8321 while (x2 >= 4096) {
8322 n += 12;
8323 x2 /= 4096;
8324 }
8325
8326 while (x2 >= 2) {
8327 n += 1;
8328 x2 /= 2;
8329 }
8330
8331 return n;
8332 };
8333
8334 var multiply = function (data, n, c) {
8335 var index = -1;
8336 var c2 = c;
8337
8338 while (++index < 6) {
8339 c2 += n * data[index];
8340 data[index] = c2 % 1e7;
8341 c2 = floor(c2 / 1e7);
8342 }
8343 };
8344
8345 var divide = function (data, n) {
8346 var index = 6;
8347 var c = 0;
8348
8349 while (--index >= 0) {
8350 c += data[index];
8351 data[index] = floor(c / n);
8352 c = c % n * 1e7;
8353 }
8354 };
8355
8356 var dataToString = function (data) {
8357 var index = 6;
8358 var s = '';
8359
8360 while (--index >= 0) {
8361 if (s !== '' || index === 0 || data[index] !== 0) {
8362 var t = String(data[index]);
8363 s = s === '' ? t : s + repeat('0', 7 - t.length) + t;
8364 }
8365 }
8366
8367 return s;
8368 };
8369
8370 var FORCED = fails(function () {
8371 return un$ToFixed(0.00008, 3) !== '0.000' || un$ToFixed(0.9, 0) !== '1' || un$ToFixed(1.255, 2) !== '1.25' || un$ToFixed(1000000000000000128.0, 0) !== '1000000000000000128';
8372 }) || !fails(function () {
8373 // V8 ~ Android 4.3-
8374 un$ToFixed({});
8375 }); // `Number.prototype.toFixed` method
8376 // https://tc39.es/ecma262/#sec-number.prototype.tofixed
8377
8378 $({
8379 target: 'Number',
8380 proto: true,
8381 forced: FORCED
8382 }, {
8383 toFixed: function toFixed(fractionDigits) {
8384 var number = thisNumberValue(this);
8385 var fractDigits = toIntegerOrInfinity(fractionDigits);
8386 var data = [0, 0, 0, 0, 0, 0];
8387 var sign = '';
8388 var result = '0';
8389 var e, z, j, k;
8390 if (fractDigits < 0 || fractDigits > 20) throw RangeError('Incorrect fraction digits'); // eslint-disable-next-line no-self-compare -- NaN check
8391
8392 if (number != number) return 'NaN';
8393 if (number <= -1e21 || number >= 1e21) return String(number);
8394
8395 if (number < 0) {
8396 sign = '-';
8397 number = -number;
8398 }
8399
8400 if (number > 1e-21) {
8401 e = log(number * pow(2, 69, 1)) - 69;
8402 z = e < 0 ? number * pow(2, -e, 1) : number / pow(2, e, 1);
8403 z *= 0x10000000000000;
8404 e = 52 - e;
8405
8406 if (e > 0) {
8407 multiply(data, 0, z);
8408 j = fractDigits;
8409
8410 while (j >= 7) {
8411 multiply(data, 1e7, 0);
8412 j -= 7;
8413 }
8414
8415 multiply(data, pow(10, j, 1), 0);
8416 j = e - 1;
8417
8418 while (j >= 23) {
8419 divide(data, 1 << 23);
8420 j -= 23;
8421 }
8422
8423 divide(data, 1 << j);
8424 multiply(data, 1, 1);
8425 divide(data, 2);
8426 result = dataToString(data);
8427 } else {
8428 multiply(data, 0, z);
8429 multiply(data, 1 << -e, 0);
8430 result = dataToString(data) + repeat('0', fractDigits);
8431 }
8432 }
8433
8434 if (fractDigits > 0) {
8435 k = result.length;
8436 result = sign + (k <= fractDigits ? '0.' + repeat('0', fractDigits - k) + result : stringSlice(result, 0, k - fractDigits) + '.' + stringSlice(result, k - fractDigits));
8437 } else {
8438 result = sign + result;
8439 }
8440
8441 return result;
8442 }
8443 });
8444
8445 /***/ }),
8446 /* 245 */
8447 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8448
8449 "use strict";
8450
8451
8452 var $ = __webpack_require__(2);
8453
8454 var uncurryThis = __webpack_require__(12);
8455
8456 var fails = __webpack_require__(6);
8457
8458 var thisNumberValue = __webpack_require__(228);
8459
8460 var un$ToPrecision = uncurryThis(1.0.toPrecision);
8461 var FORCED = fails(function () {
8462 // IE7-
8463 return un$ToPrecision(1, undefined) !== '1';
8464 }) || !fails(function () {
8465 // V8 ~ Android 4.3-
8466 un$ToPrecision({});
8467 }); // `Number.prototype.toPrecision` method
8468 // https://tc39.es/ecma262/#sec-number.prototype.toprecision
8469
8470 $({
8471 target: 'Number',
8472 proto: true,
8473 forced: FORCED
8474 }, {
8475 toPrecision: function toPrecision(precision) {
8476 return precision === undefined ? un$ToPrecision(thisNumberValue(this)) : un$ToPrecision(thisNumberValue(this), precision);
8477 }
8478 });
8479
8480 /***/ }),
8481 /* 246 */
8482 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8483
8484 var $ = __webpack_require__(2);
8485
8486 var assign = __webpack_require__(247); // `Object.assign` method
8487 // https://tc39.es/ecma262/#sec-object.assign
8488 // eslint-disable-next-line es/no-object-assign -- required for testing
8489
8490
8491 $({
8492 target: 'Object',
8493 stat: true,
8494 forced: Object.assign !== assign
8495 }, {
8496 assign: assign
8497 });
8498
8499 /***/ }),
8500 /* 247 */
8501 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8502
8503 "use strict";
8504
8505
8506 var DESCRIPTORS = __webpack_require__(5);
8507
8508 var uncurryThis = __webpack_require__(12);
8509
8510 var call = __webpack_require__(7);
8511
8512 var fails = __webpack_require__(6);
8513
8514 var objectKeys = __webpack_require__(69);
8515
8516 var getOwnPropertySymbolsModule = __webpack_require__(60);
8517
8518 var propertyIsEnumerableModule = __webpack_require__(8);
8519
8520 var toObject = __webpack_require__(36);
8521
8522 var IndexedObject = __webpack_require__(11); // eslint-disable-next-line es/no-object-assign -- safe
8523
8524
8525 var $assign = Object.assign; // eslint-disable-next-line es/no-object-defineproperty -- required for testing
8526
8527 var defineProperty = Object.defineProperty;
8528 var concat = uncurryThis([].concat); // `Object.assign` method
8529 // https://tc39.es/ecma262/#sec-object.assign
8530
8531 module.exports = !$assign || fails(function () {
8532 // should have correct order of operations (Edge bug)
8533 if (DESCRIPTORS && $assign({
8534 b: 1
8535 }, $assign(defineProperty({}, 'a', {
8536 enumerable: true,
8537 get: function () {
8538 defineProperty(this, 'b', {
8539 value: 3,
8540 enumerable: false
8541 });
8542 }
8543 }), {
8544 b: 2
8545 })).b !== 1) return true; // should work with symbols and should have deterministic property order (V8 bug)
8546
8547 var A = {};
8548 var B = {}; // eslint-disable-next-line es/no-symbol -- safe
8549
8550 var symbol = Symbol();
8551 var alphabet = 'abcdefghijklmnopqrst';
8552 A[symbol] = 7;
8553 alphabet.split('').forEach(function (chr) {
8554 B[chr] = chr;
8555 });
8556 return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet;
8557 }) ? function assign(target, source) {
8558 // eslint-disable-line no-unused-vars -- required for `.length`
8559 var T = toObject(target);
8560 var argumentsLength = arguments.length;
8561 var index = 1;
8562 var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
8563 var propertyIsEnumerable = propertyIsEnumerableModule.f;
8564
8565 while (argumentsLength > index) {
8566 var S = IndexedObject(arguments[index++]);
8567 var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
8568 var length = keys.length;
8569 var j = 0;
8570 var key;
8571
8572 while (length > j) {
8573 key = keys[j++];
8574 if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
8575 }
8576 }
8577
8578 return T;
8579 } : $assign;
8580
8581 /***/ }),
8582 /* 248 */
8583 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8584
8585 var $ = __webpack_require__(2);
8586
8587 var DESCRIPTORS = __webpack_require__(5);
8588
8589 var create = __webpack_require__(67); // `Object.create` method
8590 // https://tc39.es/ecma262/#sec-object.create
8591
8592
8593 $({
8594 target: 'Object',
8595 stat: true,
8596 sham: !DESCRIPTORS
8597 }, {
8598 create: create
8599 });
8600
8601 /***/ }),
8602 /* 249 */
8603 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8604
8605 "use strict";
8606
8607
8608 var $ = __webpack_require__(2);
8609
8610 var DESCRIPTORS = __webpack_require__(5);
8611
8612 var FORCED = __webpack_require__(250);
8613
8614 var aCallable = __webpack_require__(27);
8615
8616 var toObject = __webpack_require__(36);
8617
8618 var definePropertyModule = __webpack_require__(41); // `Object.prototype.__defineGetter__` method
8619 // https://tc39.es/ecma262/#sec-object.prototype.__defineGetter__
8620
8621
8622 if (DESCRIPTORS) {
8623 $({
8624 target: 'Object',
8625 proto: true,
8626 forced: FORCED
8627 }, {
8628 __defineGetter__: function __defineGetter__(P, getter) {
8629 definePropertyModule.f(toObject(this), P, {
8630 get: aCallable(getter),
8631 enumerable: true,
8632 configurable: true
8633 });
8634 }
8635 });
8636 }
8637
8638 /***/ }),
8639 /* 250 */
8640 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8641
8642 "use strict";
8643
8644
8645 var IS_PURE = __webpack_require__(32);
8646
8647 var global = __webpack_require__(3);
8648
8649 var fails = __webpack_require__(6);
8650
8651 var WEBKIT = __webpack_require__(158); // Forced replacement object prototype accessors methods
8652
8653
8654 module.exports = IS_PURE || !fails(function () {
8655 // This feature detection crashes old WebKit
8656 // https://github.com/zloirock/core-js/issues/232
8657 if (WEBKIT && WEBKIT < 535) return;
8658 var key = Math.random(); // In FF throws only define methods
8659 // eslint-disable-next-line no-undef, no-useless-call -- required for testing
8660
8661 __defineSetter__.call(null, key, function () {
8662 /* empty */
8663 });
8664
8665 delete global[key];
8666 });
8667
8668 /***/ }),
8669 /* 251 */
8670 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8671
8672 var $ = __webpack_require__(2);
8673
8674 var DESCRIPTORS = __webpack_require__(5);
8675
8676 var defineProperties = __webpack_require__(68); // `Object.defineProperties` method
8677 // https://tc39.es/ecma262/#sec-object.defineproperties
8678
8679
8680 $({
8681 target: 'Object',
8682 stat: true,
8683 forced: !DESCRIPTORS,
8684 sham: !DESCRIPTORS
8685 }, {
8686 defineProperties: defineProperties
8687 });
8688
8689 /***/ }),
8690 /* 252 */
8691 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8692
8693 var $ = __webpack_require__(2);
8694
8695 var DESCRIPTORS = __webpack_require__(5);
8696
8697 var objectDefinePropertyModile = __webpack_require__(41); // `Object.defineProperty` method
8698 // https://tc39.es/ecma262/#sec-object.defineproperty
8699
8700
8701 $({
8702 target: 'Object',
8703 stat: true,
8704 forced: !DESCRIPTORS,
8705 sham: !DESCRIPTORS
8706 }, {
8707 defineProperty: objectDefinePropertyModile.f
8708 });
8709
8710 /***/ }),
8711 /* 253 */
8712 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8713
8714 "use strict";
8715
8716
8717 var $ = __webpack_require__(2);
8718
8719 var DESCRIPTORS = __webpack_require__(5);
8720
8721 var FORCED = __webpack_require__(250);
8722
8723 var aCallable = __webpack_require__(27);
8724
8725 var toObject = __webpack_require__(36);
8726
8727 var definePropertyModule = __webpack_require__(41); // `Object.prototype.__defineSetter__` method
8728 // https://tc39.es/ecma262/#sec-object.prototype.__defineSetter__
8729
8730
8731 if (DESCRIPTORS) {
8732 $({
8733 target: 'Object',
8734 proto: true,
8735 forced: FORCED
8736 }, {
8737 __defineSetter__: function __defineSetter__(P, setter) {
8738 definePropertyModule.f(toObject(this), P, {
8739 set: aCallable(setter),
8740 enumerable: true,
8741 configurable: true
8742 });
8743 }
8744 });
8745 }
8746
8747 /***/ }),
8748 /* 254 */
8749 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8750
8751 var $ = __webpack_require__(2);
8752
8753 var $entries = (__webpack_require__(255).entries); // `Object.entries` method
8754 // https://tc39.es/ecma262/#sec-object.entries
8755
8756
8757 $({
8758 target: 'Object',
8759 stat: true
8760 }, {
8761 entries: function entries(O) {
8762 return $entries(O);
8763 }
8764 });
8765
8766 /***/ }),
8767 /* 255 */
8768 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8769
8770 var DESCRIPTORS = __webpack_require__(5);
8771
8772 var uncurryThis = __webpack_require__(12);
8773
8774 var objectKeys = __webpack_require__(69);
8775
8776 var toIndexedObject = __webpack_require__(10);
8777
8778 var $propertyIsEnumerable = (__webpack_require__(8).f);
8779
8780 var propertyIsEnumerable = uncurryThis($propertyIsEnumerable);
8781 var push = uncurryThis([].push); // `Object.{ entries, values }` methods implementation
8782
8783 var createMethod = function (TO_ENTRIES) {
8784 return function (it) {
8785 var O = toIndexedObject(it);
8786 var keys = objectKeys(O);
8787 var length = keys.length;
8788 var i = 0;
8789 var result = [];
8790 var key;
8791
8792 while (length > i) {
8793 key = keys[i++];
8794
8795 if (!DESCRIPTORS || propertyIsEnumerable(O, key)) {
8796 push(result, TO_ENTRIES ? [key, O[key]] : O[key]);
8797 }
8798 }
8799
8800 return result;
8801 };
8802 };
8803
8804 module.exports = {
8805 // `Object.entries` method
8806 // https://tc39.es/ecma262/#sec-object.entries
8807 entries: createMethod(true),
8808 // `Object.values` method
8809 // https://tc39.es/ecma262/#sec-object.values
8810 values: createMethod(false)
8811 };
8812
8813 /***/ }),
8814 /* 256 */
8815 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8816
8817 var $ = __webpack_require__(2);
8818
8819 var FREEZING = __webpack_require__(202);
8820
8821 var fails = __webpack_require__(6);
8822
8823 var isObject = __webpack_require__(17);
8824
8825 var onFreeze = (__webpack_require__(199).onFreeze); // eslint-disable-next-line es/no-object-freeze -- safe
8826
8827
8828 var $freeze = Object.freeze;
8829 var FAILS_ON_PRIMITIVES = fails(function () {
8830 $freeze(1);
8831 }); // `Object.freeze` method
8832 // https://tc39.es/ecma262/#sec-object.freeze
8833
8834 $({
8835 target: 'Object',
8836 stat: true,
8837 forced: FAILS_ON_PRIMITIVES,
8838 sham: !FREEZING
8839 }, {
8840 freeze: function freeze(it) {
8841 return $freeze && isObject(it) ? $freeze(onFreeze(it)) : it;
8842 }
8843 });
8844
8845 /***/ }),
8846 /* 257 */
8847 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8848
8849 var $ = __webpack_require__(2);
8850
8851 var iterate = __webpack_require__(105);
8852
8853 var createProperty = __webpack_require__(73); // `Object.fromEntries` method
8854 // https://github.com/tc39/proposal-object-from-entries
8855
8856
8857 $({
8858 target: 'Object',
8859 stat: true
8860 }, {
8861 fromEntries: function fromEntries(iterable) {
8862 var obj = {};
8863 iterate(iterable, function (k, v) {
8864 createProperty(obj, k, v);
8865 }, {
8866 AS_ENTRIES: true
8867 });
8868 return obj;
8869 }
8870 });
8871
8872 /***/ }),
8873 /* 258 */
8874 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8875
8876 var $ = __webpack_require__(2);
8877
8878 var fails = __webpack_require__(6);
8879
8880 var toIndexedObject = __webpack_require__(10);
8881
8882 var nativeGetOwnPropertyDescriptor = (__webpack_require__(4).f);
8883
8884 var DESCRIPTORS = __webpack_require__(5);
8885
8886 var FAILS_ON_PRIMITIVES = fails(function () {
8887 nativeGetOwnPropertyDescriptor(1);
8888 });
8889 var FORCED = !DESCRIPTORS || FAILS_ON_PRIMITIVES; // `Object.getOwnPropertyDescriptor` method
8890 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
8891
8892 $({
8893 target: 'Object',
8894 stat: true,
8895 forced: FORCED,
8896 sham: !DESCRIPTORS
8897 }, {
8898 getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) {
8899 return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key);
8900 }
8901 });
8902
8903 /***/ }),
8904 /* 259 */
8905 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8906
8907 var $ = __webpack_require__(2);
8908
8909 var DESCRIPTORS = __webpack_require__(5);
8910
8911 var ownKeys = __webpack_require__(51);
8912
8913 var toIndexedObject = __webpack_require__(10);
8914
8915 var getOwnPropertyDescriptorModule = __webpack_require__(4);
8916
8917 var createProperty = __webpack_require__(73); // `Object.getOwnPropertyDescriptors` method
8918 // https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
8919
8920
8921 $({
8922 target: 'Object',
8923 stat: true,
8924 sham: !DESCRIPTORS
8925 }, {
8926 getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
8927 var O = toIndexedObject(object);
8928 var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
8929 var keys = ownKeys(O);
8930 var result = {};
8931 var index = 0;
8932 var key, descriptor;
8933
8934 while (keys.length > index) {
8935 descriptor = getOwnPropertyDescriptor(O, key = keys[index++]);
8936 if (descriptor !== undefined) createProperty(result, key, descriptor);
8937 }
8938
8939 return result;
8940 }
8941 });
8942
8943 /***/ }),
8944 /* 260 */
8945 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8946
8947 var $ = __webpack_require__(2);
8948
8949 var fails = __webpack_require__(6);
8950
8951 var getOwnPropertyNames = (__webpack_require__(71).f); // eslint-disable-next-line es/no-object-getownpropertynames -- required for testing
8952
8953
8954 var FAILS_ON_PRIMITIVES = fails(function () {
8955 return !Object.getOwnPropertyNames(1);
8956 }); // `Object.getOwnPropertyNames` method
8957 // https://tc39.es/ecma262/#sec-object.getownpropertynames
8958
8959 $({
8960 target: 'Object',
8961 stat: true,
8962 forced: FAILS_ON_PRIMITIVES
8963 }, {
8964 getOwnPropertyNames: getOwnPropertyNames
8965 });
8966
8967 /***/ }),
8968 /* 261 */
8969 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
8970
8971 var $ = __webpack_require__(2);
8972
8973 var fails = __webpack_require__(6);
8974
8975 var toObject = __webpack_require__(36);
8976
8977 var nativeGetPrototypeOf = __webpack_require__(99);
8978
8979 var CORRECT_PROTOTYPE_GETTER = __webpack_require__(100);
8980
8981 var FAILS_ON_PRIMITIVES = fails(function () {
8982 nativeGetPrototypeOf(1);
8983 }); // `Object.getPrototypeOf` method
8984 // https://tc39.es/ecma262/#sec-object.getprototypeof
8985
8986 $({
8987 target: 'Object',
8988 stat: true,
8989 forced: FAILS_ON_PRIMITIVES,
8990 sham: !CORRECT_PROTOTYPE_GETTER
8991 }, {
8992 getPrototypeOf: function getPrototypeOf(it) {
8993 return nativeGetPrototypeOf(toObject(it));
8994 }
8995 });
8996
8997 /***/ }),
8998 /* 262 */
8999 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9000
9001 var $ = __webpack_require__(2);
9002
9003 var hasOwn = __webpack_require__(35); // `Object.hasOwn` method
9004 // https://github.com/tc39/proposal-accessible-object-hasownproperty
9005
9006
9007 $({
9008 target: 'Object',
9009 stat: true
9010 }, {
9011 hasOwn: hasOwn
9012 });
9013
9014 /***/ }),
9015 /* 263 */
9016 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9017
9018 var $ = __webpack_require__(2);
9019
9020 var is = __webpack_require__(264); // `Object.is` method
9021 // https://tc39.es/ecma262/#sec-object.is
9022
9023
9024 $({
9025 target: 'Object',
9026 stat: true
9027 }, {
9028 is: is
9029 });
9030
9031 /***/ }),
9032 /* 264 */
9033 /***/ ((module) => {
9034
9035 // `SameValue` abstract operation
9036 // https://tc39.es/ecma262/#sec-samevalue
9037 // eslint-disable-next-line es/no-object-is -- safe
9038 module.exports = Object.is || function is(x, y) {
9039 // eslint-disable-next-line no-self-compare -- NaN check
9040 return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
9041 };
9042
9043 /***/ }),
9044 /* 265 */
9045 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9046
9047 var $ = __webpack_require__(2);
9048
9049 var $isExtensible = __webpack_require__(200); // `Object.isExtensible` method
9050 // https://tc39.es/ecma262/#sec-object.isextensible
9051 // eslint-disable-next-line es/no-object-isextensible -- safe
9052
9053
9054 $({
9055 target: 'Object',
9056 stat: true,
9057 forced: Object.isExtensible !== $isExtensible
9058 }, {
9059 isExtensible: $isExtensible
9060 });
9061
9062 /***/ }),
9063 /* 266 */
9064 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9065
9066 var $ = __webpack_require__(2);
9067
9068 var fails = __webpack_require__(6);
9069
9070 var isObject = __webpack_require__(17);
9071
9072 var classof = __webpack_require__(13);
9073
9074 var ARRAY_BUFFER_NON_EXTENSIBLE = __webpack_require__(201); // eslint-disable-next-line es/no-object-isfrozen -- safe
9075
9076
9077 var $isFrozen = Object.isFrozen;
9078 var FAILS_ON_PRIMITIVES = fails(function () {
9079 $isFrozen(1);
9080 }); // `Object.isFrozen` method
9081 // https://tc39.es/ecma262/#sec-object.isfrozen
9082
9083 $({
9084 target: 'Object',
9085 stat: true,
9086 forced: FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE
9087 }, {
9088 isFrozen: function isFrozen(it) {
9089 if (!isObject(it)) return true;
9090 if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return true;
9091 return $isFrozen ? $isFrozen(it) : false;
9092 }
9093 });
9094
9095 /***/ }),
9096 /* 267 */
9097 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9098
9099 var $ = __webpack_require__(2);
9100
9101 var fails = __webpack_require__(6);
9102
9103 var isObject = __webpack_require__(17);
9104
9105 var classof = __webpack_require__(13);
9106
9107 var ARRAY_BUFFER_NON_EXTENSIBLE = __webpack_require__(201); // eslint-disable-next-line es/no-object-issealed -- safe
9108
9109
9110 var $isSealed = Object.isSealed;
9111 var FAILS_ON_PRIMITIVES = fails(function () {
9112 $isSealed(1);
9113 }); // `Object.isSealed` method
9114 // https://tc39.es/ecma262/#sec-object.issealed
9115
9116 $({
9117 target: 'Object',
9118 stat: true,
9119 forced: FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE
9120 }, {
9121 isSealed: function isSealed(it) {
9122 if (!isObject(it)) return true;
9123 if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) == 'ArrayBuffer') return true;
9124 return $isSealed ? $isSealed(it) : false;
9125 }
9126 });
9127
9128 /***/ }),
9129 /* 268 */
9130 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9131
9132 var $ = __webpack_require__(2);
9133
9134 var toObject = __webpack_require__(36);
9135
9136 var nativeKeys = __webpack_require__(69);
9137
9138 var fails = __webpack_require__(6);
9139
9140 var FAILS_ON_PRIMITIVES = fails(function () {
9141 nativeKeys(1);
9142 }); // `Object.keys` method
9143 // https://tc39.es/ecma262/#sec-object.keys
9144
9145 $({
9146 target: 'Object',
9147 stat: true,
9148 forced: FAILS_ON_PRIMITIVES
9149 }, {
9150 keys: function keys(it) {
9151 return nativeKeys(toObject(it));
9152 }
9153 });
9154
9155 /***/ }),
9156 /* 269 */
9157 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9158
9159 "use strict";
9160
9161
9162 var $ = __webpack_require__(2);
9163
9164 var DESCRIPTORS = __webpack_require__(5);
9165
9166 var FORCED = __webpack_require__(250);
9167
9168 var toObject = __webpack_require__(36);
9169
9170 var toPropertyKey = __webpack_require__(15);
9171
9172 var getPrototypeOf = __webpack_require__(99);
9173
9174 var getOwnPropertyDescriptor = (__webpack_require__(4).f); // `Object.prototype.__lookupGetter__` method
9175 // https://tc39.es/ecma262/#sec-object.prototype.__lookupGetter__
9176
9177
9178 if (DESCRIPTORS) {
9179 $({
9180 target: 'Object',
9181 proto: true,
9182 forced: FORCED
9183 }, {
9184 __lookupGetter__: function __lookupGetter__(P) {
9185 var O = toObject(this);
9186 var key = toPropertyKey(P);
9187 var desc;
9188
9189 do {
9190 if (desc = getOwnPropertyDescriptor(O, key)) return desc.get;
9191 } while (O = getPrototypeOf(O));
9192 }
9193 });
9194 }
9195
9196 /***/ }),
9197 /* 270 */
9198 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9199
9200 "use strict";
9201
9202
9203 var $ = __webpack_require__(2);
9204
9205 var DESCRIPTORS = __webpack_require__(5);
9206
9207 var FORCED = __webpack_require__(250);
9208
9209 var toObject = __webpack_require__(36);
9210
9211 var toPropertyKey = __webpack_require__(15);
9212
9213 var getPrototypeOf = __webpack_require__(99);
9214
9215 var getOwnPropertyDescriptor = (__webpack_require__(4).f); // `Object.prototype.__lookupSetter__` method
9216 // https://tc39.es/ecma262/#sec-object.prototype.__lookupSetter__
9217
9218
9219 if (DESCRIPTORS) {
9220 $({
9221 target: 'Object',
9222 proto: true,
9223 forced: FORCED
9224 }, {
9225 __lookupSetter__: function __lookupSetter__(P) {
9226 var O = toObject(this);
9227 var key = toPropertyKey(P);
9228 var desc;
9229
9230 do {
9231 if (desc = getOwnPropertyDescriptor(O, key)) return desc.set;
9232 } while (O = getPrototypeOf(O));
9233 }
9234 });
9235 }
9236
9237 /***/ }),
9238 /* 271 */
9239 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9240
9241 var $ = __webpack_require__(2);
9242
9243 var isObject = __webpack_require__(17);
9244
9245 var onFreeze = (__webpack_require__(199).onFreeze);
9246
9247 var FREEZING = __webpack_require__(202);
9248
9249 var fails = __webpack_require__(6); // eslint-disable-next-line es/no-object-preventextensions -- safe
9250
9251
9252 var $preventExtensions = Object.preventExtensions;
9253 var FAILS_ON_PRIMITIVES = fails(function () {
9254 $preventExtensions(1);
9255 }); // `Object.preventExtensions` method
9256 // https://tc39.es/ecma262/#sec-object.preventextensions
9257
9258 $({
9259 target: 'Object',
9260 stat: true,
9261 forced: FAILS_ON_PRIMITIVES,
9262 sham: !FREEZING
9263 }, {
9264 preventExtensions: function preventExtensions(it) {
9265 return $preventExtensions && isObject(it) ? $preventExtensions(onFreeze(it)) : it;
9266 }
9267 });
9268
9269 /***/ }),
9270 /* 272 */
9271 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9272
9273 var $ = __webpack_require__(2);
9274
9275 var isObject = __webpack_require__(17);
9276
9277 var onFreeze = (__webpack_require__(199).onFreeze);
9278
9279 var FREEZING = __webpack_require__(202);
9280
9281 var fails = __webpack_require__(6); // eslint-disable-next-line es/no-object-seal -- safe
9282
9283
9284 var $seal = Object.seal;
9285 var FAILS_ON_PRIMITIVES = fails(function () {
9286 $seal(1);
9287 }); // `Object.seal` method
9288 // https://tc39.es/ecma262/#sec-object.seal
9289
9290 $({
9291 target: 'Object',
9292 stat: true,
9293 forced: FAILS_ON_PRIMITIVES,
9294 sham: !FREEZING
9295 }, {
9296 seal: function seal(it) {
9297 return $seal && isObject(it) ? $seal(onFreeze(it)) : it;
9298 }
9299 });
9300
9301 /***/ }),
9302 /* 273 */
9303 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9304
9305 var $ = __webpack_require__(2);
9306
9307 var setPrototypeOf = __webpack_require__(101); // `Object.setPrototypeOf` method
9308 // https://tc39.es/ecma262/#sec-object.setprototypeof
9309
9310
9311 $({
9312 target: 'Object',
9313 stat: true
9314 }, {
9315 setPrototypeOf: setPrototypeOf
9316 });
9317
9318 /***/ }),
9319 /* 274 */
9320 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9321
9322 var TO_STRING_TAG_SUPPORT = __webpack_require__(66);
9323
9324 var redefine = __webpack_require__(43);
9325
9326 var toString = __webpack_require__(275); // `Object.prototype.toString` method
9327 // https://tc39.es/ecma262/#sec-object.prototype.tostring
9328
9329
9330 if (!TO_STRING_TAG_SUPPORT) {
9331 redefine(Object.prototype, 'toString', toString, {
9332 unsafe: true
9333 });
9334 }
9335
9336 /***/ }),
9337 /* 275 */
9338 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9339
9340 "use strict";
9341
9342
9343 var TO_STRING_TAG_SUPPORT = __webpack_require__(66);
9344
9345 var classof = __webpack_require__(65); // `Object.prototype.toString` method implementation
9346 // https://tc39.es/ecma262/#sec-object.prototype.tostring
9347
9348
9349 module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() {
9350 return '[object ' + classof(this) + ']';
9351 };
9352
9353 /***/ }),
9354 /* 276 */
9355 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9356
9357 var $ = __webpack_require__(2);
9358
9359 var $values = (__webpack_require__(255).values); // `Object.values` method
9360 // https://tc39.es/ecma262/#sec-object.values
9361
9362
9363 $({
9364 target: 'Object',
9365 stat: true
9366 }, {
9367 values: function values(O) {
9368 return $values(O);
9369 }
9370 });
9371
9372 /***/ }),
9373 /* 277 */
9374 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9375
9376 var $ = __webpack_require__(2);
9377
9378 var $parseFloat = __webpack_require__(241); // `parseFloat` method
9379 // https://tc39.es/ecma262/#sec-parsefloat-string
9380
9381
9382 $({
9383 global: true,
9384 forced: parseFloat != $parseFloat
9385 }, {
9386 parseFloat: $parseFloat
9387 });
9388
9389 /***/ }),
9390 /* 278 */
9391 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9392
9393 var $ = __webpack_require__(2);
9394
9395 var $parseInt = __webpack_require__(243); // `parseInt` method
9396 // https://tc39.es/ecma262/#sec-parseint-string-radix
9397
9398
9399 $({
9400 global: true,
9401 forced: parseInt != $parseInt
9402 }, {
9403 parseInt: $parseInt
9404 });
9405
9406 /***/ }),
9407 /* 279 */
9408 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
9409
9410 "use strict";
9411
9412
9413 var $ = __webpack_require__(2);
9414
9415 var IS_PURE = __webpack_require__(32);
9416
9417 var global = __webpack_require__(3);
9418
9419 var getBuiltIn = __webpack_require__(20);
9420
9421 var call = __webpack_require__(7);
9422
9423 var NativePromise = __webpack_require__(280);
9424
9425 var redefine = __webpack_require__(43);
9426
9427 var redefineAll = __webpack_require__(167);
9428
9429 var setPrototypeOf = __webpack_require__(101);
9430
9431 var setToStringTag = __webpack_require__(78);
9432
9433 var setSpecies = __webpack_require__(160);
9434
9435 var aCallable = __webpack_require__(27);
9436
9437 var isCallable = __webpack_require__(18);
9438
9439 var isObject = __webpack_require__(17);
9440
9441 var anInstance = __webpack_require__(168);
9442
9443 var inspectSource = __webpack_require__(44);
9444
9445 var iterate = __webpack_require__(105);
9446
9447 var checkCorrectnessOfIteration = __webpack_require__(134);
9448
9449 var speciesConstructor = __webpack_require__(174);
9450
9451 var task = (__webpack_require__(281).set);
9452
9453 var microtask = __webpack_require__(283);
9454
9455 var promiseResolve = __webpack_require__(286);
9456
9457 var hostReportErrors = __webpack_require__(288);
9458
9459 var newPromiseCapabilityModule = __webpack_require__(287);
9460
9461 var perform = __webpack_require__(289);
9462
9463 var InternalStateModule = __webpack_require__(45);
9464
9465 var isForced = __webpack_require__(61);
9466
9467 var wellKnownSymbol = __webpack_require__(30);
9468
9469 var IS_BROWSER = __webpack_require__(290);
9470
9471 var IS_NODE = __webpack_require__(149);
9472
9473 var V8_VERSION = __webpack_require__(24);
9474
9475 var SPECIES = wellKnownSymbol('species');
9476 var PROMISE = 'Promise';
9477 var getInternalState = InternalStateModule.get;
9478 var setInternalState = InternalStateModule.set;
9479 var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
9480 var NativePromisePrototype = NativePromise && NativePromise.prototype;
9481 var PromiseConstructor = NativePromise;
9482 var PromisePrototype = NativePromisePrototype;
9483 var TypeError = global.TypeError;
9484 var document = global.document;
9485 var process = global.process;
9486 var newPromiseCapability = newPromiseCapabilityModule.f;
9487 var newGenericPromiseCapability = newPromiseCapability;
9488 var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent);
9489 var NATIVE_REJECTION_EVENT = isCallable(global.PromiseRejectionEvent);
9490 var UNHANDLED_REJECTION = 'unhandledrejection';
9491 var REJECTION_HANDLED = 'rejectionhandled';
9492 var PENDING = 0;
9493 var FULFILLED = 1;
9494 var REJECTED = 2;
9495 var HANDLED = 1;
9496 var UNHANDLED = 2;
9497 var SUBCLASSING = false;
9498 var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
9499 var FORCED = isForced(PROMISE, function () {
9500 var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(PromiseConstructor);
9501 var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(PromiseConstructor); // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
9502 // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
9503 // We can't detect it synchronously, so just check versions
9504
9505 if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true; // We need Promise#finally in the pure version for preventing prototype pollution
9506
9507 if (IS_PURE && !PromisePrototype['finally']) return true; // We can't use @@species feature detection in V8 since it causes
9508 // deoptimization and performance degradation
9509 // https://github.com/zloirock/core-js/issues/679
9510
9511 if (V8_VERSION >= 51 && /native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) return false; // Detect correctness of subclassing with @@species support
9512
9513 var promise = new PromiseConstructor(function (resolve) {
9514 resolve(1);
9515 });
9516
9517 var FakePromise = function (exec) {
9518 exec(function () {
9519 /* empty */
9520 }, function () {
9521 /* empty */
9522 });
9523 };
9524
9525 var constructor = promise.constructor = {};
9526 constructor[SPECIES] = FakePromise;
9527 SUBCLASSING = promise.then(function () {
9528 /* empty */
9529 }) instanceof FakePromise;
9530 if (!SUBCLASSING) return true; // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
9531
9532 return !GLOBAL_CORE_JS_PROMISE && IS_BROWSER && !NATIVE_REJECTION_EVENT;
9533 });
9534 var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
9535 PromiseConstructor.all(iterable)['catch'](function () {
9536 /* empty */
9537 });
9538 }); // helpers
9539
9540 var isThenable = function (it) {
9541 var then;
9542 return isObject(it) && isCallable(then = it.then) ? then : false;
9543 };
9544
9545 var notify = function (state, isReject) {
9546 if (state.notified) return;
9547 state.notified = true;
9548 var chain = state.reactions;
9549 microtask(function () {
9550 var value = state.value;
9551 var ok = state.state == FULFILLED;
9552 var index = 0; // variable length - can't use forEach
9553
9554 while (chain.length > index) {
9555 var reaction = chain[index++];
9556 var handler = ok ? reaction.ok : reaction.fail;
9557 var resolve = reaction.resolve;
9558 var reject = reaction.reject;
9559 var domain = reaction.domain;
9560 var result, then, exited;
9561
9562 try {
9563 if (handler) {
9564 if (!ok) {
9565 if (state.rejection === UNHANDLED) onHandleUnhandled(state);
9566 state.rejection = HANDLED;
9567 }
9568
9569 if (handler === true) result = value;else {
9570 if (domain) domain.enter();
9571 result = handler(value); // can throw
9572
9573 if (domain) {
9574 domain.exit();
9575 exited = true;
9576 }
9577 }
9578
9579 if (result === reaction.promise) {
9580 reject(TypeError('Promise-chain cycle'));
9581 } else if (then = isThenable(result)) {
9582 call(then, result, resolve, reject);
9583 } else resolve(result);
9584 } else reject(value);
9585 } catch (error) {
9586 if (domain && !exited) domain.exit();
9587 reject(error);
9588 }
9589 }
9590
9591 state.reactions = [];
9592 state.notified = false;
9593 if (isReject && !state.rejection) onUnhandled(state);
9594 });
9595 };
9596
9597 var dispatchEvent = function (name, promise, reason) {
9598 var event, handler;
9599
9600 if (DISPATCH_EVENT) {
9601 event = document.createEvent('Event');
9602 event.promise = promise;
9603 event.reason = reason;
9604 event.initEvent(name, false, true);
9605 global.dispatchEvent(event);
9606 } else event = {
9607 promise: promise,
9608 reason: reason
9609 };
9610
9611 if (!NATIVE_REJECTION_EVENT && (handler = global['on' + name])) handler(event);else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
9612 };
9613
9614 var onUnhandled = function (state) {
9615 call(task, global, function () {
9616 var promise = state.facade;
9617 var value = state.value;
9618 var IS_UNHANDLED = isUnhandled(state);
9619 var result;
9620
9621 if (IS_UNHANDLED) {
9622 result = perform(function () {
9623 if (IS_NODE) {
9624 process.emit('unhandledRejection', value, promise);
9625 } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
9626 }); // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
9627
9628 state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
9629 if (result.error) throw result.value;
9630 }
9631 });
9632 };
9633
9634 var isUnhandled = function (state) {
9635 return state.rejection !== HANDLED && !state.parent;
9636 };
9637
9638 var onHandleUnhandled = function (state) {
9639 call(task, global, function () {
9640 var promise = state.facade;
9641
9642 if (IS_NODE) {
9643 process.emit('rejectionHandled', promise);
9644 } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
9645 });
9646 };
9647
9648 var bind = function (fn, state, unwrap) {
9649 return function (value) {
9650 fn(state, value, unwrap);
9651 };
9652 };
9653
9654 var internalReject = function (state, value, unwrap) {
9655 if (state.done) return;
9656 state.done = true;
9657 if (unwrap) state = unwrap;
9658 state.value = value;
9659 state.state = REJECTED;
9660 notify(state, true);
9661 };
9662
9663 var internalResolve = function (state, value, unwrap) {
9664 if (state.done) return;
9665 state.done = true;
9666 if (unwrap) state = unwrap;
9667
9668 try {
9669 if (state.facade === value) throw TypeError("Promise can't be resolved itself");
9670 var then = isThenable(value);
9671
9672 if (then) {
9673 microtask(function () {
9674 var wrapper = {
9675 done: false
9676 };
9677
9678 try {
9679 call(then, value, bind(internalResolve, wrapper, state), bind(internalReject, wrapper, state));
9680 } catch (error) {
9681 internalReject(wrapper, error, state);
9682 }
9683 });
9684 } else {
9685 state.value = value;
9686 state.state = FULFILLED;
9687 notify(state, false);
9688 }
9689 } catch (error) {
9690 internalReject({
9691 done: false
9692 }, error, state);
9693 }
9694 }; // constructor polyfill
9695
9696
9697 if (FORCED) {
9698 // 25.4.3.1 Promise(executor)
9699 PromiseConstructor = function Promise(executor) {
9700 anInstance(this, PromisePrototype);
9701 aCallable(executor);
9702 call(Internal, this);
9703 var state = getInternalState(this);
9704
9705 try {
9706 executor(bind(internalResolve, state), bind(internalReject, state));
9707 } catch (error) {
9708 internalReject(state, error);
9709 }
9710 };
9711
9712 PromisePrototype = PromiseConstructor.prototype; // eslint-disable-next-line no-unused-vars -- required for `.length`
9713
9714 Internal = function Promise(executor) {
9715 setInternalState(this, {
9716 type: PROMISE,
9717 done: false,
9718 notified: false,
9719 parent: false,
9720 reactions: [],
9721 rejection: false,
9722 state: PENDING,
9723 value: undefined
9724 });
9725 };
9726
9727 Internal.prototype = redefineAll(PromisePrototype, {
9728 // `Promise.prototype.then` method
9729 // https://tc39.es/ecma262/#sec-promise.prototype.then
9730 then: function then(onFulfilled, onRejected) {
9731 var state = getInternalPromiseState(this);
9732 var reactions = state.reactions;
9733 var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
9734 reaction.ok = isCallable(onFulfilled) ? onFulfilled : true;
9735 reaction.fail = isCallable(onRejected) && onRejected;
9736 reaction.domain = IS_NODE ? process.domain : undefined;
9737 state.parent = true;
9738 reactions[reactions.length] = reaction;
9739 if (state.state != PENDING) notify(state, false);
9740 return reaction.promise;
9741 },
9742 // `Promise.prototype.catch` method
9743 // https://tc39.es/ecma262/#sec-promise.prototype.catch
9744 'catch': function (onRejected) {
9745 return this.then(undefined, onRejected);
9746 }
9747 });
9748
9749 OwnPromiseCapability = function () {
9750 var promise = new Internal();
9751 var state = getInternalState(promise);
9752 this.promise = promise;
9753 this.resolve = bind(internalResolve, state);
9754 this.reject = bind(internalReject, state);
9755 };
9756
9757 newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
9758 return C === PromiseConstructor || C === PromiseWrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C);
9759 };
9760
9761 if (!IS_PURE && isCallable(NativePromise) && NativePromisePrototype !== Object.prototype) {
9762 nativeThen = NativePromisePrototype.then;
9763
9764 if (!SUBCLASSING) {
9765 // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
9766 redefine(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) {
9767 var that = this;
9768 return new PromiseConstructor(function (resolve, reject) {
9769 call(nativeThen, that, resolve, reject);
9770 }).then(onFulfilled, onRejected); // https://github.com/zloirock/core-js/issues/640
9771 }, {
9772 unsafe: true
9773 }); // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
9774
9775 redefine(NativePromisePrototype, 'catch', PromisePrototype['catch'], {
9776 unsafe: true
9777 });
9778 } // make `.constructor === Promise` work for native promise-based APIs
9779
9780
9781 try {
9782 delete NativePromisePrototype.constructor;
9783 } catch (error) {
9784 /* empty */
9785 } // make `instanceof Promise` work for native promise-based APIs
9786
9787
9788 if (setPrototypeOf) {
9789 setPrototypeOf(NativePromisePrototype, PromisePrototype);
9790 }
9791 }
9792 }
9793
9794 $({
9795 global: true,
9796 wrap: true,
9797 forced: FORCED
9798 }, {
9799 Promise: PromiseConstructor
9800 });
9801 setToStringTag(PromiseConstructor, PROMISE, false, true);
9802 setSpecies(PROMISE);
9803 PromiseWrapper = getBuiltIn(PROMISE); // statics
9804
9805 $({
9806 target: PROMISE,
9807 stat: true,
9808 forced: FORCED
9809 }, {
9810 // `Promise.reject` method
9811 // https://tc39.es/ecma262/#sec-promise.reject
9812 reject: function reject(r) {
9813 var capability = newPromiseCapability(this);
9814 call(capability.reject, undefined, r);
9815 return capability.promise;
9816 }
9817 });
9818 $({
9819 target: PROMISE,
9820 stat: true,
9821 forced: IS_PURE || FORCED
9822 }, {
9823 // `Promise.resolve` method
9824 // https://tc39.es/ecma262/#sec-promise.resolve
9825 resolve: function resolve(x) {
9826 return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x);
9827 }
9828 });
9829 $({
9830 target: PROMISE,
9831 stat: true,
9832 forced: INCORRECT_ITERATION
9833 }, {
9834 // `Promise.all` method
9835 // https://tc39.es/ecma262/#sec-promise.all
9836 all: function all(iterable) {
9837 var C = this;
9838 var capability = newPromiseCapability(C);
9839 var resolve = capability.resolve;
9840 var reject = capability.reject;
9841 var result = perform(function () {
9842 var $promiseResolve = aCallable(C.resolve);
9843 var values = [];
9844 var counter = 0;
9845 var remaining = 1;
9846 iterate(iterable, function (promise) {
9847 var index = counter++;
9848 var alreadyCalled = false;
9849 remaining++;
9850 call($promiseResolve, C, promise).then(function (value) {
9851 if (alreadyCalled) return;
9852 alreadyCalled = true;
9853 values[index] = value;
9854 --remaining || resolve(values);
9855 }, reject);
9856 });
9857 --remaining || resolve(values);
9858 });
9859 if (result.error) reject(result.value);
9860 return capability.promise;
9861 },
9862 // `Promise.race` method
9863 // https://tc39.es/ecma262/#sec-promise.race
9864 race: function race(iterable) {
9865 var C = this;
9866 var capability = newPromiseCapability(C);
9867 var reject = capability.reject;
9868 var result = perform(function () {
9869 var $promiseResolve = aCallable(C.resolve);
9870 iterate(iterable, function (promise) {
9871 call($promiseResolve, C, promise).then(capability.resolve, reject);
9872 });
9873 });
9874 if (result.error) reject(result.value);
9875 return capability.promise;
9876 }
9877 });
9878
9879 /***/ }),
9880 /* 280 */
9881 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9882
9883 var global = __webpack_require__(3);
9884
9885 module.exports = global.Promise;
9886
9887 /***/ }),
9888 /* 281 */
9889 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
9890
9891 var global = __webpack_require__(3);
9892
9893 var apply = __webpack_require__(62);
9894
9895 var bind = __webpack_require__(80);
9896
9897 var isCallable = __webpack_require__(18);
9898
9899 var hasOwn = __webpack_require__(35);
9900
9901 var fails = __webpack_require__(6);
9902
9903 var html = __webpack_require__(70);
9904
9905 var arraySlice = __webpack_require__(74);
9906
9907 var createElement = __webpack_require__(39);
9908
9909 var IS_IOS = __webpack_require__(282);
9910
9911 var IS_NODE = __webpack_require__(149);
9912
9913 var set = global.setImmediate;
9914 var clear = global.clearImmediate;
9915 var process = global.process;
9916 var Dispatch = global.Dispatch;
9917 var Function = global.Function;
9918 var MessageChannel = global.MessageChannel;
9919 var String = global.String;
9920 var counter = 0;
9921 var queue = {};
9922 var ONREADYSTATECHANGE = 'onreadystatechange';
9923 var location, defer, channel, port;
9924
9925 try {
9926 // Deno throws a ReferenceError on `location` access without `--location` flag
9927 location = global.location;
9928 } catch (error) {
9929 /* empty */
9930 }
9931
9932 var run = function (id) {
9933 if (hasOwn(queue, id)) {
9934 var fn = queue[id];
9935 delete queue[id];
9936 fn();
9937 }
9938 };
9939
9940 var runner = function (id) {
9941 return function () {
9942 run(id);
9943 };
9944 };
9945
9946 var listener = function (event) {
9947 run(event.data);
9948 };
9949
9950 var post = function (id) {
9951 // old engines have not location.origin
9952 global.postMessage(String(id), location.protocol + '//' + location.host);
9953 }; // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
9954
9955
9956 if (!set || !clear) {
9957 set = function setImmediate(fn) {
9958 var args = arraySlice(arguments, 1);
9959
9960 queue[++counter] = function () {
9961 apply(isCallable(fn) ? fn : Function(fn), undefined, args);
9962 };
9963
9964 defer(counter);
9965 return counter;
9966 };
9967
9968 clear = function clearImmediate(id) {
9969 delete queue[id];
9970 }; // Node.js 0.8-
9971
9972
9973 if (IS_NODE) {
9974 defer = function (id) {
9975 process.nextTick(runner(id));
9976 }; // Sphere (JS game engine) Dispatch API
9977
9978 } else if (Dispatch && Dispatch.now) {
9979 defer = function (id) {
9980 Dispatch.now(runner(id));
9981 }; // Browsers with MessageChannel, includes WebWorkers
9982 // except iOS - https://github.com/zloirock/core-js/issues/624
9983
9984 } else if (MessageChannel && !IS_IOS) {
9985 channel = new MessageChannel();
9986 port = channel.port2;
9987 channel.port1.onmessage = listener;
9988 defer = bind(port.postMessage, port); // Browsers with postMessage, skip WebWorkers
9989 // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
9990 } else if (global.addEventListener && isCallable(global.postMessage) && !global.importScripts && location && location.protocol !== 'file:' && !fails(post)) {
9991 defer = post;
9992 global.addEventListener('message', listener, false); // IE8-
9993 } else if (ONREADYSTATECHANGE in createElement('script')) {
9994 defer = function (id) {
9995 html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
9996 html.removeChild(this);
9997 run(id);
9998 };
9999 }; // Rest old browsers
10000
10001 } else {
10002 defer = function (id) {
10003 setTimeout(runner(id), 0);
10004 };
10005 }
10006 }
10007
10008 module.exports = {
10009 set: set,
10010 clear: clear
10011 };
10012
10013 /***/ }),
10014 /* 282 */
10015 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10016
10017 var userAgent = __webpack_require__(25);
10018
10019 module.exports = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);
10020
10021 /***/ }),
10022 /* 283 */
10023 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10024
10025 var global = __webpack_require__(3);
10026
10027 var bind = __webpack_require__(80);
10028
10029 var getOwnPropertyDescriptor = (__webpack_require__(4).f);
10030
10031 var macrotask = (__webpack_require__(281).set);
10032
10033 var IS_IOS = __webpack_require__(282);
10034
10035 var IS_IOS_PEBBLE = __webpack_require__(284);
10036
10037 var IS_WEBOS_WEBKIT = __webpack_require__(285);
10038
10039 var IS_NODE = __webpack_require__(149);
10040
10041 var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
10042 var document = global.document;
10043 var process = global.process;
10044 var Promise = global.Promise; // Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
10045
10046 var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
10047 var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
10048 var flush, head, last, notify, toggle, node, promise, then; // modern engines have queueMicrotask method
10049
10050 if (!queueMicrotask) {
10051 flush = function () {
10052 var parent, fn;
10053 if (IS_NODE && (parent = process.domain)) parent.exit();
10054
10055 while (head) {
10056 fn = head.fn;
10057 head = head.next;
10058
10059 try {
10060 fn();
10061 } catch (error) {
10062 if (head) notify();else last = undefined;
10063 throw error;
10064 }
10065 }
10066
10067 last = undefined;
10068 if (parent) parent.enter();
10069 }; // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
10070 // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
10071
10072
10073 if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) {
10074 toggle = true;
10075 node = document.createTextNode('');
10076 new MutationObserver(flush).observe(node, {
10077 characterData: true
10078 });
10079
10080 notify = function () {
10081 node.data = toggle = !toggle;
10082 }; // environments with maybe non-completely correct, but existent Promise
10083
10084 } else if (!IS_IOS_PEBBLE && Promise && Promise.resolve) {
10085 // Promise.resolve without an argument throws an error in LG WebOS 2
10086 promise = Promise.resolve(undefined); // workaround of WebKit ~ iOS Safari 10.1 bug
10087
10088 promise.constructor = Promise;
10089 then = bind(promise.then, promise);
10090
10091 notify = function () {
10092 then(flush);
10093 }; // Node.js without promises
10094
10095 } else if (IS_NODE) {
10096 notify = function () {
10097 process.nextTick(flush);
10098 }; // for other environments - macrotask based on:
10099 // - setImmediate
10100 // - MessageChannel
10101 // - window.postMessag
10102 // - onreadystatechange
10103 // - setTimeout
10104
10105 } else {
10106 // strange IE + webpack dev server bug - use .bind(global)
10107 macrotask = bind(macrotask, global);
10108
10109 notify = function () {
10110 macrotask(flush);
10111 };
10112 }
10113 }
10114
10115 module.exports = queueMicrotask || function (fn) {
10116 var task = {
10117 fn: fn,
10118 next: undefined
10119 };
10120 if (last) last.next = task;
10121
10122 if (!head) {
10123 head = task;
10124 notify();
10125 }
10126
10127 last = task;
10128 };
10129
10130 /***/ }),
10131 /* 284 */
10132 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10133
10134 var userAgent = __webpack_require__(25);
10135
10136 var global = __webpack_require__(3);
10137
10138 module.exports = /ipad|iphone|ipod/i.test(userAgent) && global.Pebble !== undefined;
10139
10140 /***/ }),
10141 /* 285 */
10142 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10143
10144 var userAgent = __webpack_require__(25);
10145
10146 module.exports = /web0s(?!.*chrome)/i.test(userAgent);
10147
10148 /***/ }),
10149 /* 286 */
10150 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10151
10152 var anObject = __webpack_require__(42);
10153
10154 var isObject = __webpack_require__(17);
10155
10156 var newPromiseCapability = __webpack_require__(287);
10157
10158 module.exports = function (C, x) {
10159 anObject(C);
10160 if (isObject(x) && x.constructor === C) return x;
10161 var promiseCapability = newPromiseCapability.f(C);
10162 var resolve = promiseCapability.resolve;
10163 resolve(x);
10164 return promiseCapability.promise;
10165 };
10166
10167 /***/ }),
10168 /* 287 */
10169 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10170
10171 "use strict";
10172
10173
10174 var aCallable = __webpack_require__(27);
10175
10176 var PromiseCapability = function (C) {
10177 var resolve, reject;
10178 this.promise = new C(function ($$resolve, $$reject) {
10179 if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
10180 resolve = $$resolve;
10181 reject = $$reject;
10182 });
10183 this.resolve = aCallable(resolve);
10184 this.reject = aCallable(reject);
10185 }; // `NewPromiseCapability` abstract operation
10186 // https://tc39.es/ecma262/#sec-newpromisecapability
10187
10188
10189 module.exports.f = function (C) {
10190 return new PromiseCapability(C);
10191 };
10192
10193 /***/ }),
10194 /* 288 */
10195 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10196
10197 var global = __webpack_require__(3);
10198
10199 module.exports = function (a, b) {
10200 var console = global.console;
10201
10202 if (console && console.error) {
10203 arguments.length == 1 ? console.error(a) : console.error(a, b);
10204 }
10205 };
10206
10207 /***/ }),
10208 /* 289 */
10209 /***/ ((module) => {
10210
10211 module.exports = function (exec) {
10212 try {
10213 return {
10214 error: false,
10215 value: exec()
10216 };
10217 } catch (error) {
10218 return {
10219 error: true,
10220 value: error
10221 };
10222 }
10223 };
10224
10225 /***/ }),
10226 /* 290 */
10227 /***/ ((module) => {
10228
10229 module.exports = typeof window == 'object';
10230
10231 /***/ }),
10232 /* 291 */
10233 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10234
10235 "use strict";
10236
10237
10238 var $ = __webpack_require__(2);
10239
10240 var call = __webpack_require__(7);
10241
10242 var aCallable = __webpack_require__(27);
10243
10244 var newPromiseCapabilityModule = __webpack_require__(287);
10245
10246 var perform = __webpack_require__(289);
10247
10248 var iterate = __webpack_require__(105); // `Promise.allSettled` method
10249 // https://tc39.es/ecma262/#sec-promise.allsettled
10250
10251
10252 $({
10253 target: 'Promise',
10254 stat: true
10255 }, {
10256 allSettled: function allSettled(iterable) {
10257 var C = this;
10258 var capability = newPromiseCapabilityModule.f(C);
10259 var resolve = capability.resolve;
10260 var reject = capability.reject;
10261 var result = perform(function () {
10262 var promiseResolve = aCallable(C.resolve);
10263 var values = [];
10264 var counter = 0;
10265 var remaining = 1;
10266 iterate(iterable, function (promise) {
10267 var index = counter++;
10268 var alreadyCalled = false;
10269 remaining++;
10270 call(promiseResolve, C, promise).then(function (value) {
10271 if (alreadyCalled) return;
10272 alreadyCalled = true;
10273 values[index] = {
10274 status: 'fulfilled',
10275 value: value
10276 };
10277 --remaining || resolve(values);
10278 }, function (error) {
10279 if (alreadyCalled) return;
10280 alreadyCalled = true;
10281 values[index] = {
10282 status: 'rejected',
10283 reason: error
10284 };
10285 --remaining || resolve(values);
10286 });
10287 });
10288 --remaining || resolve(values);
10289 });
10290 if (result.error) reject(result.value);
10291 return capability.promise;
10292 }
10293 });
10294
10295 /***/ }),
10296 /* 292 */
10297 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10298
10299 "use strict";
10300
10301
10302 var $ = __webpack_require__(2);
10303
10304 var aCallable = __webpack_require__(27);
10305
10306 var getBuiltIn = __webpack_require__(20);
10307
10308 var call = __webpack_require__(7);
10309
10310 var newPromiseCapabilityModule = __webpack_require__(287);
10311
10312 var perform = __webpack_require__(289);
10313
10314 var iterate = __webpack_require__(105);
10315
10316 var PROMISE_ANY_ERROR = 'No one promise resolved'; // `Promise.any` method
10317 // https://tc39.es/ecma262/#sec-promise.any
10318
10319 $({
10320 target: 'Promise',
10321 stat: true
10322 }, {
10323 any: function any(iterable) {
10324 var C = this;
10325 var AggregateError = getBuiltIn('AggregateError');
10326 var capability = newPromiseCapabilityModule.f(C);
10327 var resolve = capability.resolve;
10328 var reject = capability.reject;
10329 var result = perform(function () {
10330 var promiseResolve = aCallable(C.resolve);
10331 var errors = [];
10332 var counter = 0;
10333 var remaining = 1;
10334 var alreadyResolved = false;
10335 iterate(iterable, function (promise) {
10336 var index = counter++;
10337 var alreadyRejected = false;
10338 remaining++;
10339 call(promiseResolve, C, promise).then(function (value) {
10340 if (alreadyRejected || alreadyResolved) return;
10341 alreadyResolved = true;
10342 resolve(value);
10343 }, function (error) {
10344 if (alreadyRejected || alreadyResolved) return;
10345 alreadyRejected = true;
10346 errors[index] = error;
10347 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
10348 });
10349 });
10350 --remaining || reject(new AggregateError(errors, PROMISE_ANY_ERROR));
10351 });
10352 if (result.error) reject(result.value);
10353 return capability.promise;
10354 }
10355 });
10356
10357 /***/ }),
10358 /* 293 */
10359 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10360
10361 "use strict";
10362
10363
10364 var $ = __webpack_require__(2);
10365
10366 var IS_PURE = __webpack_require__(32);
10367
10368 var NativePromise = __webpack_require__(280);
10369
10370 var fails = __webpack_require__(6);
10371
10372 var getBuiltIn = __webpack_require__(20);
10373
10374 var isCallable = __webpack_require__(18);
10375
10376 var speciesConstructor = __webpack_require__(174);
10377
10378 var promiseResolve = __webpack_require__(286);
10379
10380 var redefine = __webpack_require__(43); // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
10381
10382
10383 var NON_GENERIC = !!NativePromise && fails(function () {
10384 NativePromise.prototype['finally'].call({
10385 then: function () {
10386 /* empty */
10387 }
10388 }, function () {
10389 /* empty */
10390 });
10391 }); // `Promise.prototype.finally` method
10392 // https://tc39.es/ecma262/#sec-promise.prototype.finally
10393
10394 $({
10395 target: 'Promise',
10396 proto: true,
10397 real: true,
10398 forced: NON_GENERIC
10399 }, {
10400 'finally': function (onFinally) {
10401 var C = speciesConstructor(this, getBuiltIn('Promise'));
10402 var isFunction = isCallable(onFinally);
10403 return this.then(isFunction ? function (x) {
10404 return promiseResolve(C, onFinally()).then(function () {
10405 return x;
10406 });
10407 } : onFinally, isFunction ? function (e) {
10408 return promiseResolve(C, onFinally()).then(function () {
10409 throw e;
10410 });
10411 } : onFinally);
10412 }
10413 }); // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`
10414
10415 if (!IS_PURE && isCallable(NativePromise)) {
10416 var method = getBuiltIn('Promise').prototype['finally'];
10417
10418 if (NativePromise.prototype['finally'] !== method) {
10419 redefine(NativePromise.prototype, 'finally', method, {
10420 unsafe: true
10421 });
10422 }
10423 }
10424
10425 /***/ }),
10426 /* 294 */
10427 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10428
10429 var $ = __webpack_require__(2);
10430
10431 var functionApply = __webpack_require__(62);
10432
10433 var aCallable = __webpack_require__(27);
10434
10435 var anObject = __webpack_require__(42);
10436
10437 var fails = __webpack_require__(6); // MS Edge argumentsList argument is optional
10438
10439
10440 var OPTIONAL_ARGUMENTS_LIST = !fails(function () {
10441 // eslint-disable-next-line es/no-reflect -- required for testing
10442 Reflect.apply(function () {
10443 /* empty */
10444 });
10445 }); // `Reflect.apply` method
10446 // https://tc39.es/ecma262/#sec-reflect.apply
10447
10448 $({
10449 target: 'Reflect',
10450 stat: true,
10451 forced: OPTIONAL_ARGUMENTS_LIST
10452 }, {
10453 apply: function apply(target, thisArgument, argumentsList) {
10454 return functionApply(aCallable(target), thisArgument, anObject(argumentsList));
10455 }
10456 });
10457
10458 /***/ }),
10459 /* 295 */
10460 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10461
10462 var $ = __webpack_require__(2);
10463
10464 var getBuiltIn = __webpack_require__(20);
10465
10466 var apply = __webpack_require__(62);
10467
10468 var bind = __webpack_require__(191);
10469
10470 var aConstructor = __webpack_require__(175);
10471
10472 var anObject = __webpack_require__(42);
10473
10474 var isObject = __webpack_require__(17);
10475
10476 var create = __webpack_require__(67);
10477
10478 var fails = __webpack_require__(6);
10479
10480 var nativeConstruct = getBuiltIn('Reflect', 'construct');
10481 var ObjectPrototype = Object.prototype;
10482 var push = [].push; // `Reflect.construct` method
10483 // https://tc39.es/ecma262/#sec-reflect.construct
10484 // MS Edge supports only 2 arguments and argumentsList argument is optional
10485 // FF Nightly sets third argument as `new.target`, but does not create `this` from it
10486
10487 var NEW_TARGET_BUG = fails(function () {
10488 function F() {
10489 /* empty */
10490 }
10491
10492 return !(nativeConstruct(function () {
10493 /* empty */
10494 }, [], F) instanceof F);
10495 });
10496 var ARGS_BUG = !fails(function () {
10497 nativeConstruct(function () {
10498 /* empty */
10499 });
10500 });
10501 var FORCED = NEW_TARGET_BUG || ARGS_BUG;
10502 $({
10503 target: 'Reflect',
10504 stat: true,
10505 forced: FORCED,
10506 sham: FORCED
10507 }, {
10508 construct: function construct(Target, args
10509 /* , newTarget */
10510 ) {
10511 aConstructor(Target);
10512 anObject(args);
10513 var newTarget = arguments.length < 3 ? Target : aConstructor(arguments[2]);
10514 if (ARGS_BUG && !NEW_TARGET_BUG) return nativeConstruct(Target, args, newTarget);
10515
10516 if (Target == newTarget) {
10517 // w/o altered newTarget, optimization for 0-4 arguments
10518 switch (args.length) {
10519 case 0:
10520 return new Target();
10521
10522 case 1:
10523 return new Target(args[0]);
10524
10525 case 2:
10526 return new Target(args[0], args[1]);
10527
10528 case 3:
10529 return new Target(args[0], args[1], args[2]);
10530
10531 case 4:
10532 return new Target(args[0], args[1], args[2], args[3]);
10533 } // w/o altered newTarget, lot of arguments case
10534
10535
10536 var $args = [null];
10537 apply(push, $args, args);
10538 return new (apply(bind, Target, $args))();
10539 } // with altered newTarget, not support built-in constructors
10540
10541
10542 var proto = newTarget.prototype;
10543 var instance = create(isObject(proto) ? proto : ObjectPrototype);
10544 var result = apply(Target, instance, args);
10545 return isObject(result) ? result : instance;
10546 }
10547 });
10548
10549 /***/ }),
10550 /* 296 */
10551 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10552
10553 var $ = __webpack_require__(2);
10554
10555 var DESCRIPTORS = __webpack_require__(5);
10556
10557 var anObject = __webpack_require__(42);
10558
10559 var toPropertyKey = __webpack_require__(15);
10560
10561 var definePropertyModule = __webpack_require__(41);
10562
10563 var fails = __webpack_require__(6); // MS Edge has broken Reflect.defineProperty - throwing instead of returning false
10564
10565
10566 var ERROR_INSTEAD_OF_FALSE = fails(function () {
10567 // eslint-disable-next-line es/no-reflect -- required for testing
10568 Reflect.defineProperty(definePropertyModule.f({}, 1, {
10569 value: 1
10570 }), 1, {
10571 value: 2
10572 });
10573 }); // `Reflect.defineProperty` method
10574 // https://tc39.es/ecma262/#sec-reflect.defineproperty
10575
10576 $({
10577 target: 'Reflect',
10578 stat: true,
10579 forced: ERROR_INSTEAD_OF_FALSE,
10580 sham: !DESCRIPTORS
10581 }, {
10582 defineProperty: function defineProperty(target, propertyKey, attributes) {
10583 anObject(target);
10584 var key = toPropertyKey(propertyKey);
10585 anObject(attributes);
10586
10587 try {
10588 definePropertyModule.f(target, key, attributes);
10589 return true;
10590 } catch (error) {
10591 return false;
10592 }
10593 }
10594 });
10595
10596 /***/ }),
10597 /* 297 */
10598 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10599
10600 var $ = __webpack_require__(2);
10601
10602 var anObject = __webpack_require__(42);
10603
10604 var getOwnPropertyDescriptor = (__webpack_require__(4).f); // `Reflect.deleteProperty` method
10605 // https://tc39.es/ecma262/#sec-reflect.deleteproperty
10606
10607
10608 $({
10609 target: 'Reflect',
10610 stat: true
10611 }, {
10612 deleteProperty: function deleteProperty(target, propertyKey) {
10613 var descriptor = getOwnPropertyDescriptor(anObject(target), propertyKey);
10614 return descriptor && !descriptor.configurable ? false : delete target[propertyKey];
10615 }
10616 });
10617
10618 /***/ }),
10619 /* 298 */
10620 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10621
10622 var $ = __webpack_require__(2);
10623
10624 var call = __webpack_require__(7);
10625
10626 var isObject = __webpack_require__(17);
10627
10628 var anObject = __webpack_require__(42);
10629
10630 var isDataDescriptor = __webpack_require__(299);
10631
10632 var getOwnPropertyDescriptorModule = __webpack_require__(4);
10633
10634 var getPrototypeOf = __webpack_require__(99); // `Reflect.get` method
10635 // https://tc39.es/ecma262/#sec-reflect.get
10636
10637
10638 function get(target, propertyKey
10639 /* , receiver */
10640 ) {
10641 var receiver = arguments.length < 3 ? target : arguments[2];
10642 var descriptor, prototype;
10643 if (anObject(target) === receiver) return target[propertyKey];
10644 descriptor = getOwnPropertyDescriptorModule.f(target, propertyKey);
10645 if (descriptor) return isDataDescriptor(descriptor) ? descriptor.value : descriptor.get === undefined ? undefined : call(descriptor.get, receiver);
10646 if (isObject(prototype = getPrototypeOf(target))) return get(prototype, propertyKey, receiver);
10647 }
10648
10649 $({
10650 target: 'Reflect',
10651 stat: true
10652 }, {
10653 get: get
10654 });
10655
10656 /***/ }),
10657 /* 299 */
10658 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10659
10660 var hasOwn = __webpack_require__(35);
10661
10662 module.exports = function (descriptor) {
10663 return descriptor !== undefined && (hasOwn(descriptor, 'value') || hasOwn(descriptor, 'writable'));
10664 };
10665
10666 /***/ }),
10667 /* 300 */
10668 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10669
10670 var $ = __webpack_require__(2);
10671
10672 var DESCRIPTORS = __webpack_require__(5);
10673
10674 var anObject = __webpack_require__(42);
10675
10676 var getOwnPropertyDescriptorModule = __webpack_require__(4); // `Reflect.getOwnPropertyDescriptor` method
10677 // https://tc39.es/ecma262/#sec-reflect.getownpropertydescriptor
10678
10679
10680 $({
10681 target: 'Reflect',
10682 stat: true,
10683 sham: !DESCRIPTORS
10684 }, {
10685 getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) {
10686 return getOwnPropertyDescriptorModule.f(anObject(target), propertyKey);
10687 }
10688 });
10689
10690 /***/ }),
10691 /* 301 */
10692 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10693
10694 var $ = __webpack_require__(2);
10695
10696 var anObject = __webpack_require__(42);
10697
10698 var objectGetPrototypeOf = __webpack_require__(99);
10699
10700 var CORRECT_PROTOTYPE_GETTER = __webpack_require__(100); // `Reflect.getPrototypeOf` method
10701 // https://tc39.es/ecma262/#sec-reflect.getprototypeof
10702
10703
10704 $({
10705 target: 'Reflect',
10706 stat: true,
10707 sham: !CORRECT_PROTOTYPE_GETTER
10708 }, {
10709 getPrototypeOf: function getPrototypeOf(target) {
10710 return objectGetPrototypeOf(anObject(target));
10711 }
10712 });
10713
10714 /***/ }),
10715 /* 302 */
10716 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10717
10718 var $ = __webpack_require__(2); // `Reflect.has` method
10719 // https://tc39.es/ecma262/#sec-reflect.has
10720
10721
10722 $({
10723 target: 'Reflect',
10724 stat: true
10725 }, {
10726 has: function has(target, propertyKey) {
10727 return propertyKey in target;
10728 }
10729 });
10730
10731 /***/ }),
10732 /* 303 */
10733 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10734
10735 var $ = __webpack_require__(2);
10736
10737 var anObject = __webpack_require__(42);
10738
10739 var $isExtensible = __webpack_require__(200); // `Reflect.isExtensible` method
10740 // https://tc39.es/ecma262/#sec-reflect.isextensible
10741
10742
10743 $({
10744 target: 'Reflect',
10745 stat: true
10746 }, {
10747 isExtensible: function isExtensible(target) {
10748 anObject(target);
10749 return $isExtensible(target);
10750 }
10751 });
10752
10753 /***/ }),
10754 /* 304 */
10755 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10756
10757 var $ = __webpack_require__(2);
10758
10759 var ownKeys = __webpack_require__(51); // `Reflect.ownKeys` method
10760 // https://tc39.es/ecma262/#sec-reflect.ownkeys
10761
10762
10763 $({
10764 target: 'Reflect',
10765 stat: true
10766 }, {
10767 ownKeys: ownKeys
10768 });
10769
10770 /***/ }),
10771 /* 305 */
10772 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10773
10774 var $ = __webpack_require__(2);
10775
10776 var getBuiltIn = __webpack_require__(20);
10777
10778 var anObject = __webpack_require__(42);
10779
10780 var FREEZING = __webpack_require__(202); // `Reflect.preventExtensions` method
10781 // https://tc39.es/ecma262/#sec-reflect.preventextensions
10782
10783
10784 $({
10785 target: 'Reflect',
10786 stat: true,
10787 sham: !FREEZING
10788 }, {
10789 preventExtensions: function preventExtensions(target) {
10790 anObject(target);
10791
10792 try {
10793 var objectPreventExtensions = getBuiltIn('Object', 'preventExtensions');
10794 if (objectPreventExtensions) objectPreventExtensions(target);
10795 return true;
10796 } catch (error) {
10797 return false;
10798 }
10799 }
10800 });
10801
10802 /***/ }),
10803 /* 306 */
10804 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10805
10806 var $ = __webpack_require__(2);
10807
10808 var call = __webpack_require__(7);
10809
10810 var anObject = __webpack_require__(42);
10811
10812 var isObject = __webpack_require__(17);
10813
10814 var isDataDescriptor = __webpack_require__(299);
10815
10816 var fails = __webpack_require__(6);
10817
10818 var definePropertyModule = __webpack_require__(41);
10819
10820 var getOwnPropertyDescriptorModule = __webpack_require__(4);
10821
10822 var getPrototypeOf = __webpack_require__(99);
10823
10824 var createPropertyDescriptor = __webpack_require__(9); // `Reflect.set` method
10825 // https://tc39.es/ecma262/#sec-reflect.set
10826
10827
10828 function set(target, propertyKey, V
10829 /* , receiver */
10830 ) {
10831 var receiver = arguments.length < 4 ? target : arguments[3];
10832 var ownDescriptor = getOwnPropertyDescriptorModule.f(anObject(target), propertyKey);
10833 var existingDescriptor, prototype, setter;
10834
10835 if (!ownDescriptor) {
10836 if (isObject(prototype = getPrototypeOf(target))) {
10837 return set(prototype, propertyKey, V, receiver);
10838 }
10839
10840 ownDescriptor = createPropertyDescriptor(0);
10841 }
10842
10843 if (isDataDescriptor(ownDescriptor)) {
10844 if (ownDescriptor.writable === false || !isObject(receiver)) return false;
10845
10846 if (existingDescriptor = getOwnPropertyDescriptorModule.f(receiver, propertyKey)) {
10847 if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false;
10848 existingDescriptor.value = V;
10849 definePropertyModule.f(receiver, propertyKey, existingDescriptor);
10850 } else definePropertyModule.f(receiver, propertyKey, createPropertyDescriptor(0, V));
10851 } else {
10852 setter = ownDescriptor.set;
10853 if (setter === undefined) return false;
10854 call(setter, receiver, V);
10855 }
10856
10857 return true;
10858 } // MS Edge 17-18 Reflect.set allows setting the property to object
10859 // with non-writable property on the prototype
10860
10861
10862 var MS_EDGE_BUG = fails(function () {
10863 var Constructor = function () {
10864 /* empty */
10865 };
10866
10867 var object = definePropertyModule.f(new Constructor(), 'a', {
10868 configurable: true
10869 }); // eslint-disable-next-line es/no-reflect -- required for testing
10870
10871 return Reflect.set(Constructor.prototype, 'a', 1, object) !== false;
10872 });
10873 $({
10874 target: 'Reflect',
10875 stat: true,
10876 forced: MS_EDGE_BUG
10877 }, {
10878 set: set
10879 });
10880
10881 /***/ }),
10882 /* 307 */
10883 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10884
10885 var $ = __webpack_require__(2);
10886
10887 var anObject = __webpack_require__(42);
10888
10889 var aPossiblePrototype = __webpack_require__(102);
10890
10891 var objectSetPrototypeOf = __webpack_require__(101); // `Reflect.setPrototypeOf` method
10892 // https://tc39.es/ecma262/#sec-reflect.setprototypeof
10893
10894
10895 if (objectSetPrototypeOf) $({
10896 target: 'Reflect',
10897 stat: true
10898 }, {
10899 setPrototypeOf: function setPrototypeOf(target, proto) {
10900 anObject(target);
10901 aPossiblePrototype(proto);
10902
10903 try {
10904 objectSetPrototypeOf(target, proto);
10905 return true;
10906 } catch (error) {
10907 return false;
10908 }
10909 }
10910 });
10911
10912 /***/ }),
10913 /* 308 */
10914 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10915
10916 var $ = __webpack_require__(2);
10917
10918 var global = __webpack_require__(3);
10919
10920 var setToStringTag = __webpack_require__(78);
10921
10922 $({
10923 global: true
10924 }, {
10925 Reflect: {}
10926 }); // Reflect[@@toStringTag] property
10927 // https://tc39.es/ecma262/#sec-reflect-@@tostringtag
10928
10929 setToStringTag(global.Reflect, 'Reflect', true);
10930
10931 /***/ }),
10932 /* 309 */
10933 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
10934
10935 var DESCRIPTORS = __webpack_require__(5);
10936
10937 var global = __webpack_require__(3);
10938
10939 var uncurryThis = __webpack_require__(12);
10940
10941 var isForced = __webpack_require__(61);
10942
10943 var inheritIfRequired = __webpack_require__(203);
10944
10945 var createNonEnumerableProperty = __webpack_require__(40);
10946
10947 var defineProperty = (__webpack_require__(41).f);
10948
10949 var getOwnPropertyNames = (__webpack_require__(52).f);
10950
10951 var isPrototypeOf = __webpack_require__(21);
10952
10953 var isRegExp = __webpack_require__(310);
10954
10955 var toString = __webpack_require__(64);
10956
10957 var regExpFlags = __webpack_require__(311);
10958
10959 var stickyHelpers = __webpack_require__(312);
10960
10961 var redefine = __webpack_require__(43);
10962
10963 var fails = __webpack_require__(6);
10964
10965 var hasOwn = __webpack_require__(35);
10966
10967 var enforceInternalState = (__webpack_require__(45).enforce);
10968
10969 var setSpecies = __webpack_require__(160);
10970
10971 var wellKnownSymbol = __webpack_require__(30);
10972
10973 var UNSUPPORTED_DOT_ALL = __webpack_require__(313);
10974
10975 var UNSUPPORTED_NCG = __webpack_require__(314);
10976
10977 var MATCH = wellKnownSymbol('match');
10978 var NativeRegExp = global.RegExp;
10979 var RegExpPrototype = NativeRegExp.prototype;
10980 var SyntaxError = global.SyntaxError;
10981 var getFlags = uncurryThis(regExpFlags);
10982 var exec = uncurryThis(RegExpPrototype.exec);
10983 var charAt = uncurryThis(''.charAt);
10984 var replace = uncurryThis(''.replace);
10985 var stringIndexOf = uncurryThis(''.indexOf);
10986 var stringSlice = uncurryThis(''.slice); // TODO: Use only propper RegExpIdentifierName
10987
10988 var IS_NCG = /^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/;
10989 var re1 = /a/g;
10990 var re2 = /a/g; // "new" should create a new object, old webkit bug
10991
10992 var CORRECT_NEW = new NativeRegExp(re1) !== re1;
10993 var MISSED_STICKY = stickyHelpers.MISSED_STICKY;
10994 var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
10995 var BASE_FORCED = DESCRIPTORS && (!CORRECT_NEW || MISSED_STICKY || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG || fails(function () {
10996 re2[MATCH] = false; // RegExp constructor can alter flags and IsRegExp works correct with @@match
10997
10998 return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i';
10999 }));
11000
11001 var handleDotAll = function (string) {
11002 var length = string.length;
11003 var index = 0;
11004 var result = '';
11005 var brackets = false;
11006 var chr;
11007
11008 for (; index <= length; index++) {
11009 chr = charAt(string, index);
11010
11011 if (chr === '\\') {
11012 result += chr + charAt(string, ++index);
11013 continue;
11014 }
11015
11016 if (!brackets && chr === '.') {
11017 result += '[\\s\\S]';
11018 } else {
11019 if (chr === '[') {
11020 brackets = true;
11021 } else if (chr === ']') {
11022 brackets = false;
11023 }
11024
11025 result += chr;
11026 }
11027 }
11028
11029 return result;
11030 };
11031
11032 var handleNCG = function (string) {
11033 var length = string.length;
11034 var index = 0;
11035 var result = '';
11036 var named = [];
11037 var names = {};
11038 var brackets = false;
11039 var ncg = false;
11040 var groupid = 0;
11041 var groupname = '';
11042 var chr;
11043
11044 for (; index <= length; index++) {
11045 chr = charAt(string, index);
11046
11047 if (chr === '\\') {
11048 chr = chr + charAt(string, ++index);
11049 } else if (chr === ']') {
11050 brackets = false;
11051 } else if (!brackets) switch (true) {
11052 case chr === '[':
11053 brackets = true;
11054 break;
11055
11056 case chr === '(':
11057 if (exec(IS_NCG, stringSlice(string, index + 1))) {
11058 index += 2;
11059 ncg = true;
11060 }
11061
11062 result += chr;
11063 groupid++;
11064 continue;
11065
11066 case chr === '>' && ncg:
11067 if (groupname === '' || hasOwn(names, groupname)) {
11068 throw new SyntaxError('Invalid capture group name');
11069 }
11070
11071 names[groupname] = true;
11072 named[named.length] = [groupname, groupid];
11073 ncg = false;
11074 groupname = '';
11075 continue;
11076 }
11077
11078 if (ncg) groupname += chr;else result += chr;
11079 }
11080
11081 return [result, named];
11082 }; // `RegExp` constructor
11083 // https://tc39.es/ecma262/#sec-regexp-constructor
11084
11085
11086 if (isForced('RegExp', BASE_FORCED)) {
11087 var RegExpWrapper = function RegExp(pattern, flags) {
11088 var thisIsRegExp = isPrototypeOf(RegExpPrototype, this);
11089 var patternIsRegExp = isRegExp(pattern);
11090 var flagsAreUndefined = flags === undefined;
11091 var groups = [];
11092 var rawPattern = pattern;
11093 var rawFlags, dotAll, sticky, handled, result, state;
11094
11095 if (!thisIsRegExp && patternIsRegExp && flagsAreUndefined && pattern.constructor === RegExpWrapper) {
11096 return pattern;
11097 }
11098
11099 if (patternIsRegExp || isPrototypeOf(RegExpPrototype, pattern)) {
11100 pattern = pattern.source;
11101 if (flagsAreUndefined) flags = 'flags' in rawPattern ? rawPattern.flags : getFlags(rawPattern);
11102 }
11103
11104 pattern = pattern === undefined ? '' : toString(pattern);
11105 flags = flags === undefined ? '' : toString(flags);
11106 rawPattern = pattern;
11107
11108 if (UNSUPPORTED_DOT_ALL && 'dotAll' in re1) {
11109 dotAll = !!flags && stringIndexOf(flags, 's') > -1;
11110 if (dotAll) flags = replace(flags, /s/g, '');
11111 }
11112
11113 rawFlags = flags;
11114
11115 if (MISSED_STICKY && 'sticky' in re1) {
11116 sticky = !!flags && stringIndexOf(flags, 'y') > -1;
11117 if (sticky && UNSUPPORTED_Y) flags = replace(flags, /y/g, '');
11118 }
11119
11120 if (UNSUPPORTED_NCG) {
11121 handled = handleNCG(pattern);
11122 pattern = handled[0];
11123 groups = handled[1];
11124 }
11125
11126 result = inheritIfRequired(NativeRegExp(pattern, flags), thisIsRegExp ? this : RegExpPrototype, RegExpWrapper);
11127
11128 if (dotAll || sticky || groups.length) {
11129 state = enforceInternalState(result);
11130
11131 if (dotAll) {
11132 state.dotAll = true;
11133 state.raw = RegExpWrapper(handleDotAll(pattern), rawFlags);
11134 }
11135
11136 if (sticky) state.sticky = true;
11137 if (groups.length) state.groups = groups;
11138 }
11139
11140 if (pattern !== rawPattern) try {
11141 // fails in old engines, but we have no alternatives for unsupported regex syntax
11142 createNonEnumerableProperty(result, 'source', rawPattern === '' ? '(?:)' : rawPattern);
11143 } catch (error) {
11144 /* empty */
11145 }
11146 return result;
11147 };
11148
11149 var proxy = function (key) {
11150 key in RegExpWrapper || defineProperty(RegExpWrapper, key, {
11151 configurable: true,
11152 get: function () {
11153 return NativeRegExp[key];
11154 },
11155 set: function (it) {
11156 NativeRegExp[key] = it;
11157 }
11158 });
11159 };
11160
11161 for (var keys = getOwnPropertyNames(NativeRegExp), index = 0; keys.length > index;) {
11162 proxy(keys[index++]);
11163 }
11164
11165 RegExpPrototype.constructor = RegExpWrapper;
11166 RegExpWrapper.prototype = RegExpPrototype;
11167 redefine(global, 'RegExp', RegExpWrapper);
11168 } // https://tc39.es/ecma262/#sec-get-regexp-@@species
11169
11170
11171 setSpecies('RegExp');
11172
11173 /***/ }),
11174 /* 310 */
11175 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
11176
11177 var isObject = __webpack_require__(17);
11178
11179 var classof = __webpack_require__(13);
11180
11181 var wellKnownSymbol = __webpack_require__(30);
11182
11183 var MATCH = wellKnownSymbol('match'); // `IsRegExp` abstract operation
11184 // https://tc39.es/ecma262/#sec-isregexp
11185
11186 module.exports = function (it) {
11187 var isRegExp;
11188 return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp');
11189 };
11190
11191 /***/ }),
11192 /* 311 */
11193 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
11194
11195 "use strict";
11196
11197
11198 var anObject = __webpack_require__(42); // `RegExp.prototype.flags` getter implementation
11199 // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
11200
11201
11202 module.exports = function () {
11203 var that = anObject(this);
11204 var result = '';
11205 if (that.global) result += 'g';
11206 if (that.ignoreCase) result += 'i';
11207 if (that.multiline) result += 'm';
11208 if (that.dotAll) result += 's';
11209 if (that.unicode) result += 'u';
11210 if (that.sticky) result += 'y';
11211 return result;
11212 };
11213
11214 /***/ }),
11215 /* 312 */
11216 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
11217
11218 var fails = __webpack_require__(6);
11219
11220 var global = __webpack_require__(3); // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
11221
11222
11223 var $RegExp = global.RegExp;
11224 var UNSUPPORTED_Y = fails(function () {
11225 var re = $RegExp('a', 'y');
11226 re.lastIndex = 2;
11227 return re.exec('abcd') != null;
11228 }); // UC Browser bug
11229 // https://github.com/zloirock/core-js/issues/1008
11230
11231 var MISSED_STICKY = UNSUPPORTED_Y || fails(function () {
11232 return !$RegExp('a', 'y').sticky;
11233 });
11234 var BROKEN_CARET = UNSUPPORTED_Y || fails(function () {
11235 // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
11236 var re = $RegExp('^r', 'gy');
11237 re.lastIndex = 2;
11238 return re.exec('str') != null;
11239 });
11240 module.exports = {
11241 BROKEN_CARET: BROKEN_CARET,
11242 MISSED_STICKY: MISSED_STICKY,
11243 UNSUPPORTED_Y: UNSUPPORTED_Y
11244 };
11245
11246 /***/ }),
11247 /* 313 */
11248 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
11249
11250 var fails = __webpack_require__(6);
11251
11252 var global = __webpack_require__(3); // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
11253
11254
11255 var $RegExp = global.RegExp;
11256 module.exports = fails(function () {
11257 var re = $RegExp('.', 's');
11258 return !(re.dotAll && re.exec('\n') && re.flags === 's');
11259 });
11260
11261 /***/ }),
11262 /* 314 */
11263 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
11264
11265 var fails = __webpack_require__(6);
11266
11267 var global = __webpack_require__(3); // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
11268
11269
11270 var $RegExp = global.RegExp;
11271 module.exports = fails(function () {
11272 var re = $RegExp('(?<a>b)', 'g');
11273 return re.exec('b').groups.a !== 'b' || 'b'.replace(re, '$<a>c') !== 'bc';
11274 });
11275
11276 /***/ }),
11277 /* 315 */
11278 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11279
11280 var global = __webpack_require__(3);
11281
11282 var DESCRIPTORS = __webpack_require__(5);
11283
11284 var UNSUPPORTED_DOT_ALL = __webpack_require__(313);
11285
11286 var classof = __webpack_require__(13);
11287
11288 var defineProperty = (__webpack_require__(41).f);
11289
11290 var getInternalState = (__webpack_require__(45).get);
11291
11292 var RegExpPrototype = RegExp.prototype;
11293 var TypeError = global.TypeError; // `RegExp.prototype.dotAll` getter
11294 // https://tc39.es/ecma262/#sec-get-regexp.prototype.dotall
11295
11296 if (DESCRIPTORS && UNSUPPORTED_DOT_ALL) {
11297 defineProperty(RegExpPrototype, 'dotAll', {
11298 configurable: true,
11299 get: function () {
11300 if (this === RegExpPrototype) return undefined; // We can't use InternalStateModule.getterFor because
11301 // we don't add metadata for regexps created by a literal.
11302
11303 if (classof(this) === 'RegExp') {
11304 return !!getInternalState(this).dotAll;
11305 }
11306
11307 throw TypeError('Incompatible receiver, RegExp required');
11308 }
11309 });
11310 }
11311
11312 /***/ }),
11313 /* 316 */
11314 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11315
11316 "use strict";
11317
11318
11319 var $ = __webpack_require__(2);
11320
11321 var exec = __webpack_require__(317); // `RegExp.prototype.exec` method
11322 // https://tc39.es/ecma262/#sec-regexp.prototype.exec
11323
11324
11325 $({
11326 target: 'RegExp',
11327 proto: true,
11328 forced: /./.exec !== exec
11329 }, {
11330 exec: exec
11331 });
11332
11333 /***/ }),
11334 /* 317 */
11335 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
11336
11337 "use strict";
11338
11339 /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
11340
11341 /* eslint-disable regexp/no-useless-quantifier -- testing */
11342
11343 var call = __webpack_require__(7);
11344
11345 var uncurryThis = __webpack_require__(12);
11346
11347 var toString = __webpack_require__(64);
11348
11349 var regexpFlags = __webpack_require__(311);
11350
11351 var stickyHelpers = __webpack_require__(312);
11352
11353 var shared = __webpack_require__(31);
11354
11355 var create = __webpack_require__(67);
11356
11357 var getInternalState = (__webpack_require__(45).get);
11358
11359 var UNSUPPORTED_DOT_ALL = __webpack_require__(313);
11360
11361 var UNSUPPORTED_NCG = __webpack_require__(314);
11362
11363 var nativeReplace = shared('native-string-replace', String.prototype.replace);
11364 var nativeExec = RegExp.prototype.exec;
11365 var patchedExec = nativeExec;
11366 var charAt = uncurryThis(''.charAt);
11367 var indexOf = uncurryThis(''.indexOf);
11368 var replace = uncurryThis(''.replace);
11369 var stringSlice = uncurryThis(''.slice);
11370
11371 var UPDATES_LAST_INDEX_WRONG = function () {
11372 var re1 = /a/;
11373 var re2 = /b*/g;
11374 call(nativeExec, re1, 'a');
11375 call(nativeExec, re2, 'a');
11376 return re1.lastIndex !== 0 || re2.lastIndex !== 0;
11377 }();
11378
11379 var UNSUPPORTED_Y = stickyHelpers.BROKEN_CARET; // nonparticipating capturing group, copied from es5-shim's String#split patch.
11380
11381 var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
11382 var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;
11383
11384 if (PATCH) {
11385 patchedExec = function exec(string) {
11386 var re = this;
11387 var state = getInternalState(re);
11388 var str = toString(string);
11389 var raw = state.raw;
11390 var result, reCopy, lastIndex, match, i, object, group;
11391
11392 if (raw) {
11393 raw.lastIndex = re.lastIndex;
11394 result = call(patchedExec, raw, str);
11395 re.lastIndex = raw.lastIndex;
11396 return result;
11397 }
11398
11399 var groups = state.groups;
11400 var sticky = UNSUPPORTED_Y && re.sticky;
11401 var flags = call(regexpFlags, re);
11402 var source = re.source;
11403 var charsAdded = 0;
11404 var strCopy = str;
11405
11406 if (sticky) {
11407 flags = replace(flags, 'y', '');
11408
11409 if (indexOf(flags, 'g') === -1) {
11410 flags += 'g';
11411 }
11412
11413 strCopy = stringSlice(str, re.lastIndex); // Support anchored sticky behavior.
11414
11415 if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt(str, re.lastIndex - 1) !== '\n')) {
11416 source = '(?: ' + source + ')';
11417 strCopy = ' ' + strCopy;
11418 charsAdded++;
11419 } // ^(? + rx + ) is needed, in combination with some str slicing, to
11420 // simulate the 'y' flag.
11421
11422
11423 reCopy = new RegExp('^(?:' + source + ')', flags);
11424 }
11425
11426 if (NPCG_INCLUDED) {
11427 reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
11428 }
11429
11430 if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
11431 match = call(nativeExec, sticky ? reCopy : re, strCopy);
11432
11433 if (sticky) {
11434 if (match) {
11435 match.input = stringSlice(match.input, charsAdded);
11436 match[0] = stringSlice(match[0], charsAdded);
11437 match.index = re.lastIndex;
11438 re.lastIndex += match[0].length;
11439 } else re.lastIndex = 0;
11440 } else if (UPDATES_LAST_INDEX_WRONG && match) {
11441 re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
11442 }
11443
11444 if (NPCG_INCLUDED && match && match.length > 1) {
11445 // Fix browsers whose `exec` methods don't consistently return `undefined`
11446 // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
11447 call(nativeReplace, match[0], reCopy, function () {
11448 for (i = 1; i < arguments.length - 2; i++) {
11449 if (arguments[i] === undefined) match[i] = undefined;
11450 }
11451 });
11452 }
11453
11454 if (match && groups) {
11455 match.groups = object = create(null);
11456
11457 for (i = 0; i < groups.length; i++) {
11458 group = groups[i];
11459 object[group[0]] = match[group[1]];
11460 }
11461 }
11462
11463 return match;
11464 };
11465 }
11466
11467 module.exports = patchedExec;
11468
11469 /***/ }),
11470 /* 318 */
11471 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11472
11473 var DESCRIPTORS = __webpack_require__(5);
11474
11475 var objectDefinePropertyModule = __webpack_require__(41);
11476
11477 var regExpFlags = __webpack_require__(311);
11478
11479 var fails = __webpack_require__(6);
11480
11481 var RegExpPrototype = RegExp.prototype;
11482 var FORCED = DESCRIPTORS && fails(function () {
11483 // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
11484 return Object.getOwnPropertyDescriptor(RegExpPrototype, 'flags').get.call({
11485 dotAll: true,
11486 sticky: true
11487 }) !== 'sy';
11488 }); // `RegExp.prototype.flags` getter
11489 // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
11490
11491 if (FORCED) objectDefinePropertyModule.f(RegExpPrototype, 'flags', {
11492 configurable: true,
11493 get: regExpFlags
11494 });
11495
11496 /***/ }),
11497 /* 319 */
11498 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11499
11500 var global = __webpack_require__(3);
11501
11502 var DESCRIPTORS = __webpack_require__(5);
11503
11504 var MISSED_STICKY = (__webpack_require__(312).MISSED_STICKY);
11505
11506 var classof = __webpack_require__(13);
11507
11508 var defineProperty = (__webpack_require__(41).f);
11509
11510 var getInternalState = (__webpack_require__(45).get);
11511
11512 var RegExpPrototype = RegExp.prototype;
11513 var TypeError = global.TypeError; // `RegExp.prototype.sticky` getter
11514 // https://tc39.es/ecma262/#sec-get-regexp.prototype.sticky
11515
11516 if (DESCRIPTORS && MISSED_STICKY) {
11517 defineProperty(RegExpPrototype, 'sticky', {
11518 configurable: true,
11519 get: function () {
11520 if (this === RegExpPrototype) return undefined; // We can't use InternalStateModule.getterFor because
11521 // we don't add metadata for regexps created by a literal.
11522
11523 if (classof(this) === 'RegExp') {
11524 return !!getInternalState(this).sticky;
11525 }
11526
11527 throw TypeError('Incompatible receiver, RegExp required');
11528 }
11529 });
11530 }
11531
11532 /***/ }),
11533 /* 320 */
11534 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11535
11536 "use strict";
11537 // TODO: Remove from `core-js@4` since it's moved to entry points
11538
11539 __webpack_require__(316);
11540
11541 var $ = __webpack_require__(2);
11542
11543 var global = __webpack_require__(3);
11544
11545 var call = __webpack_require__(7);
11546
11547 var uncurryThis = __webpack_require__(12);
11548
11549 var isCallable = __webpack_require__(18);
11550
11551 var isObject = __webpack_require__(17);
11552
11553 var DELEGATES_TO_EXEC = function () {
11554 var execCalled = false;
11555 var re = /[ac]/;
11556
11557 re.exec = function () {
11558 execCalled = true;
11559 return /./.exec.apply(this, arguments);
11560 };
11561
11562 return re.test('abc') === true && execCalled;
11563 }();
11564
11565 var Error = global.Error;
11566 var un$Test = uncurryThis(/./.test); // `RegExp.prototype.test` method
11567 // https://tc39.es/ecma262/#sec-regexp.prototype.test
11568
11569 $({
11570 target: 'RegExp',
11571 proto: true,
11572 forced: !DELEGATES_TO_EXEC
11573 }, {
11574 test: function (str) {
11575 var exec = this.exec;
11576 if (!isCallable(exec)) return un$Test(this, str);
11577 var result = call(exec, this, str);
11578
11579 if (result !== null && !isObject(result)) {
11580 throw new Error('RegExp exec method returned something other than an Object or null');
11581 }
11582
11583 return !!result;
11584 }
11585 });
11586
11587 /***/ }),
11588 /* 321 */
11589 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11590
11591 "use strict";
11592
11593
11594 var uncurryThis = __webpack_require__(12);
11595
11596 var PROPER_FUNCTION_NAME = (__webpack_require__(49).PROPER);
11597
11598 var redefine = __webpack_require__(43);
11599
11600 var anObject = __webpack_require__(42);
11601
11602 var isPrototypeOf = __webpack_require__(21);
11603
11604 var $toString = __webpack_require__(64);
11605
11606 var fails = __webpack_require__(6);
11607
11608 var regExpFlags = __webpack_require__(311);
11609
11610 var TO_STRING = 'toString';
11611 var RegExpPrototype = RegExp.prototype;
11612 var n$ToString = RegExpPrototype[TO_STRING];
11613 var getFlags = uncurryThis(regExpFlags);
11614 var NOT_GENERIC = fails(function () {
11615 return n$ToString.call({
11616 source: 'a',
11617 flags: 'b'
11618 }) != '/a/b';
11619 }); // FF44- RegExp#toString has a wrong name
11620
11621 var INCORRECT_NAME = PROPER_FUNCTION_NAME && n$ToString.name != TO_STRING; // `RegExp.prototype.toString` method
11622 // https://tc39.es/ecma262/#sec-regexp.prototype.tostring
11623
11624 if (NOT_GENERIC || INCORRECT_NAME) {
11625 redefine(RegExp.prototype, TO_STRING, function toString() {
11626 var R = anObject(this);
11627 var p = $toString(R.source);
11628 var rf = R.flags;
11629 var f = $toString(rf === undefined && isPrototypeOf(RegExpPrototype, R) && !('flags' in RegExpPrototype) ? getFlags(R) : rf);
11630 return '/' + p + '/' + f;
11631 }, {
11632 unsafe: true
11633 });
11634 }
11635
11636 /***/ }),
11637 /* 322 */
11638 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11639
11640 "use strict";
11641
11642
11643 var collection = __webpack_require__(198);
11644
11645 var collectionStrong = __webpack_require__(204); // `Set` constructor
11646 // https://tc39.es/ecma262/#sec-set-objects
11647
11648
11649 collection('Set', function (init) {
11650 return function Set() {
11651 return init(this, arguments.length ? arguments[0] : undefined);
11652 };
11653 }, collectionStrong);
11654
11655 /***/ }),
11656 /* 323 */
11657 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11658
11659 "use strict";
11660
11661
11662 var $ = __webpack_require__(2);
11663
11664 var uncurryThis = __webpack_require__(12);
11665
11666 var requireObjectCoercible = __webpack_require__(14);
11667
11668 var toIntegerOrInfinity = __webpack_require__(56);
11669
11670 var toString = __webpack_require__(64);
11671
11672 var fails = __webpack_require__(6);
11673
11674 var charAt = uncurryThis(''.charAt);
11675 var FORCED = fails(function () {
11676 return '𠮷'.at(0) !== '\uD842';
11677 }); // `String.prototype.at` method
11678 // https://github.com/tc39/proposal-relative-indexing-method
11679
11680 $({
11681 target: 'String',
11682 proto: true,
11683 forced: FORCED
11684 }, {
11685 at: function at(index) {
11686 var S = toString(requireObjectCoercible(this));
11687 var len = S.length;
11688 var relativeIndex = toIntegerOrInfinity(index);
11689 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex;
11690 return k < 0 || k >= len ? undefined : charAt(S, k);
11691 }
11692 });
11693
11694 /***/ }),
11695 /* 324 */
11696 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11697
11698 "use strict";
11699
11700
11701 var $ = __webpack_require__(2);
11702
11703 var codeAt = (__webpack_require__(325).codeAt); // `String.prototype.codePointAt` method
11704 // https://tc39.es/ecma262/#sec-string.prototype.codepointat
11705
11706
11707 $({
11708 target: 'String',
11709 proto: true
11710 }, {
11711 codePointAt: function codePointAt(pos) {
11712 return codeAt(this, pos);
11713 }
11714 });
11715
11716 /***/ }),
11717 /* 325 */
11718 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
11719
11720 var uncurryThis = __webpack_require__(12);
11721
11722 var toIntegerOrInfinity = __webpack_require__(56);
11723
11724 var toString = __webpack_require__(64);
11725
11726 var requireObjectCoercible = __webpack_require__(14);
11727
11728 var charAt = uncurryThis(''.charAt);
11729 var charCodeAt = uncurryThis(''.charCodeAt);
11730 var stringSlice = uncurryThis(''.slice);
11731
11732 var createMethod = function (CONVERT_TO_STRING) {
11733 return function ($this, pos) {
11734 var S = toString(requireObjectCoercible($this));
11735 var position = toIntegerOrInfinity(pos);
11736 var size = S.length;
11737 var first, second;
11738 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
11739 first = charCodeAt(S, position);
11740 return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? charAt(S, position) : first : CONVERT_TO_STRING ? stringSlice(S, position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
11741 };
11742 };
11743
11744 module.exports = {
11745 // `String.prototype.codePointAt` method
11746 // https://tc39.es/ecma262/#sec-string.prototype.codepointat
11747 codeAt: createMethod(false),
11748 // `String.prototype.at` method
11749 // https://github.com/mathiasbynens/String.prototype.at
11750 charAt: createMethod(true)
11751 };
11752
11753 /***/ }),
11754 /* 326 */
11755 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11756
11757 "use strict";
11758
11759
11760 var $ = __webpack_require__(2);
11761
11762 var uncurryThis = __webpack_require__(12);
11763
11764 var getOwnPropertyDescriptor = (__webpack_require__(4).f);
11765
11766 var toLength = __webpack_require__(58);
11767
11768 var toString = __webpack_require__(64);
11769
11770 var notARegExp = __webpack_require__(327);
11771
11772 var requireObjectCoercible = __webpack_require__(14);
11773
11774 var correctIsRegExpLogic = __webpack_require__(328);
11775
11776 var IS_PURE = __webpack_require__(32); // eslint-disable-next-line es/no-string-prototype-endswith -- safe
11777
11778
11779 var un$EndsWith = uncurryThis(''.endsWith);
11780 var slice = uncurryThis(''.slice);
11781 var min = Math.min;
11782 var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('endsWith'); // https://github.com/zloirock/core-js/pull/702
11783
11784 var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
11785 var descriptor = getOwnPropertyDescriptor(String.prototype, 'endsWith');
11786 return descriptor && !descriptor.writable;
11787 }(); // `String.prototype.endsWith` method
11788 // https://tc39.es/ecma262/#sec-string.prototype.endswith
11789
11790 $({
11791 target: 'String',
11792 proto: true,
11793 forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC
11794 }, {
11795 endsWith: function endsWith(searchString
11796 /* , endPosition = @length */
11797 ) {
11798 var that = toString(requireObjectCoercible(this));
11799 notARegExp(searchString);
11800 var endPosition = arguments.length > 1 ? arguments[1] : undefined;
11801 var len = that.length;
11802 var end = endPosition === undefined ? len : min(toLength(endPosition), len);
11803 var search = toString(searchString);
11804 return un$EndsWith ? un$EndsWith(that, search, end) : slice(that, end - search.length, end) === search;
11805 }
11806 });
11807
11808 /***/ }),
11809 /* 327 */
11810 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
11811
11812 var global = __webpack_require__(3);
11813
11814 var isRegExp = __webpack_require__(310);
11815
11816 var TypeError = global.TypeError;
11817
11818 module.exports = function (it) {
11819 if (isRegExp(it)) {
11820 throw TypeError("The method doesn't accept regular expressions");
11821 }
11822
11823 return it;
11824 };
11825
11826 /***/ }),
11827 /* 328 */
11828 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
11829
11830 var wellKnownSymbol = __webpack_require__(30);
11831
11832 var MATCH = wellKnownSymbol('match');
11833
11834 module.exports = function (METHOD_NAME) {
11835 var regexp = /./;
11836
11837 try {
11838 '/./'[METHOD_NAME](regexp);
11839 } catch (error1) {
11840 try {
11841 regexp[MATCH] = false;
11842 return '/./'[METHOD_NAME](regexp);
11843 } catch (error2) {
11844 /* empty */
11845 }
11846 }
11847
11848 return false;
11849 };
11850
11851 /***/ }),
11852 /* 329 */
11853 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11854
11855 var $ = __webpack_require__(2);
11856
11857 var global = __webpack_require__(3);
11858
11859 var uncurryThis = __webpack_require__(12);
11860
11861 var toAbsoluteIndex = __webpack_require__(55);
11862
11863 var RangeError = global.RangeError;
11864 var fromCharCode = String.fromCharCode; // eslint-disable-next-line es/no-string-fromcodepoint -- required for testing
11865
11866 var $fromCodePoint = String.fromCodePoint;
11867 var join = uncurryThis([].join); // length should be 1, old FF problem
11868
11869 var INCORRECT_LENGTH = !!$fromCodePoint && $fromCodePoint.length != 1; // `String.fromCodePoint` method
11870 // https://tc39.es/ecma262/#sec-string.fromcodepoint
11871
11872 $({
11873 target: 'String',
11874 stat: true,
11875 forced: INCORRECT_LENGTH
11876 }, {
11877 // eslint-disable-next-line no-unused-vars -- required for `.length`
11878 fromCodePoint: function fromCodePoint(x) {
11879 var elements = [];
11880 var length = arguments.length;
11881 var i = 0;
11882 var code;
11883
11884 while (length > i) {
11885 code = +arguments[i++];
11886 if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw RangeError(code + ' is not a valid code point');
11887 elements[i] = code < 0x10000 ? fromCharCode(code) : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00);
11888 }
11889
11890 return join(elements, '');
11891 }
11892 });
11893
11894 /***/ }),
11895 /* 330 */
11896 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11897
11898 "use strict";
11899
11900
11901 var $ = __webpack_require__(2);
11902
11903 var uncurryThis = __webpack_require__(12);
11904
11905 var notARegExp = __webpack_require__(327);
11906
11907 var requireObjectCoercible = __webpack_require__(14);
11908
11909 var toString = __webpack_require__(64);
11910
11911 var correctIsRegExpLogic = __webpack_require__(328);
11912
11913 var stringIndexOf = uncurryThis(''.indexOf); // `String.prototype.includes` method
11914 // https://tc39.es/ecma262/#sec-string.prototype.includes
11915
11916 $({
11917 target: 'String',
11918 proto: true,
11919 forced: !correctIsRegExpLogic('includes')
11920 }, {
11921 includes: function includes(searchString
11922 /* , position = 0 */
11923 ) {
11924 return !!~stringIndexOf(toString(requireObjectCoercible(this)), toString(notARegExp(searchString)), arguments.length > 1 ? arguments[1] : undefined);
11925 }
11926 });
11927
11928 /***/ }),
11929 /* 331 */
11930 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11931
11932 "use strict";
11933
11934
11935 var charAt = (__webpack_require__(325).charAt);
11936
11937 var toString = __webpack_require__(64);
11938
11939 var InternalStateModule = __webpack_require__(45);
11940
11941 var defineIterator = __webpack_require__(139);
11942
11943 var STRING_ITERATOR = 'String Iterator';
11944 var setInternalState = InternalStateModule.set;
11945 var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR); // `String.prototype[@@iterator]` method
11946 // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
11947
11948 defineIterator(String, 'String', function (iterated) {
11949 setInternalState(this, {
11950 type: STRING_ITERATOR,
11951 string: toString(iterated),
11952 index: 0
11953 }); // `%StringIteratorPrototype%.next` method
11954 // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
11955 }, function next() {
11956 var state = getInternalState(this);
11957 var string = state.string;
11958 var index = state.index;
11959 var point;
11960 if (index >= string.length) return {
11961 value: undefined,
11962 done: true
11963 };
11964 point = charAt(string, index);
11965 state.index += point.length;
11966 return {
11967 value: point,
11968 done: false
11969 };
11970 });
11971
11972 /***/ }),
11973 /* 332 */
11974 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
11975
11976 "use strict";
11977
11978
11979 var call = __webpack_require__(7);
11980
11981 var fixRegExpWellKnownSymbolLogic = __webpack_require__(333);
11982
11983 var anObject = __webpack_require__(42);
11984
11985 var toLength = __webpack_require__(58);
11986
11987 var toString = __webpack_require__(64);
11988
11989 var requireObjectCoercible = __webpack_require__(14);
11990
11991 var getMethod = __webpack_require__(26);
11992
11993 var advanceStringIndex = __webpack_require__(334);
11994
11995 var regExpExec = __webpack_require__(335); // @@match logic
11996
11997
11998 fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) {
11999 return [// `String.prototype.match` method
12000 // https://tc39.es/ecma262/#sec-string.prototype.match
12001 function match(regexp) {
12002 var O = requireObjectCoercible(this);
12003 var matcher = regexp == undefined ? undefined : getMethod(regexp, MATCH);
12004 return matcher ? call(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString(O));
12005 }, // `RegExp.prototype[@@match]` method
12006 // https://tc39.es/ecma262/#sec-regexp.prototype-@@match
12007 function (string) {
12008 var rx = anObject(this);
12009 var S = toString(string);
12010 var res = maybeCallNative(nativeMatch, rx, S);
12011 if (res.done) return res.value;
12012 if (!rx.global) return regExpExec(rx, S);
12013 var fullUnicode = rx.unicode;
12014 rx.lastIndex = 0;
12015 var A = [];
12016 var n = 0;
12017 var result;
12018
12019 while ((result = regExpExec(rx, S)) !== null) {
12020 var matchStr = toString(result[0]);
12021 A[n] = matchStr;
12022 if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
12023 n++;
12024 }
12025
12026 return n === 0 ? null : A;
12027 }];
12028 });
12029
12030 /***/ }),
12031 /* 333 */
12032 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
12033
12034 "use strict";
12035 // TODO: Remove from `core-js@4` since it's moved to entry points
12036
12037 __webpack_require__(316);
12038
12039 var uncurryThis = __webpack_require__(12);
12040
12041 var redefine = __webpack_require__(43);
12042
12043 var regexpExec = __webpack_require__(317);
12044
12045 var fails = __webpack_require__(6);
12046
12047 var wellKnownSymbol = __webpack_require__(30);
12048
12049 var createNonEnumerableProperty = __webpack_require__(40);
12050
12051 var SPECIES = wellKnownSymbol('species');
12052 var RegExpPrototype = RegExp.prototype;
12053
12054 module.exports = function (KEY, exec, FORCED, SHAM) {
12055 var SYMBOL = wellKnownSymbol(KEY);
12056 var DELEGATES_TO_SYMBOL = !fails(function () {
12057 // String methods call symbol-named RegEp methods
12058 var O = {};
12059
12060 O[SYMBOL] = function () {
12061 return 7;
12062 };
12063
12064 return ''[KEY](O) != 7;
12065 });
12066 var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
12067 // Symbol-named RegExp methods call .exec
12068 var execCalled = false;
12069 var re = /a/;
12070
12071 if (KEY === 'split') {
12072 // We can't use real regex here since it causes deoptimization
12073 // and serious performance degradation in V8
12074 // https://github.com/zloirock/core-js/issues/306
12075 re = {}; // RegExp[@@split] doesn't call the regex's exec method, but first creates
12076 // a new one. We need to return the patched regex when creating the new one.
12077
12078 re.constructor = {};
12079
12080 re.constructor[SPECIES] = function () {
12081 return re;
12082 };
12083
12084 re.flags = '';
12085 re[SYMBOL] = /./[SYMBOL];
12086 }
12087
12088 re.exec = function () {
12089 execCalled = true;
12090 return null;
12091 };
12092
12093 re[SYMBOL]('');
12094 return !execCalled;
12095 });
12096
12097 if (!DELEGATES_TO_SYMBOL || !DELEGATES_TO_EXEC || FORCED) {
12098 var uncurriedNativeRegExpMethod = uncurryThis(/./[SYMBOL]);
12099 var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
12100 var uncurriedNativeMethod = uncurryThis(nativeMethod);
12101 var $exec = regexp.exec;
12102
12103 if ($exec === regexpExec || $exec === RegExpPrototype.exec) {
12104 if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
12105 // The native String method already delegates to @@method (this
12106 // polyfilled function), leasing to infinite recursion.
12107 // We avoid it by directly calling the native @@method method.
12108 return {
12109 done: true,
12110 value: uncurriedNativeRegExpMethod(regexp, str, arg2)
12111 };
12112 }
12113
12114 return {
12115 done: true,
12116 value: uncurriedNativeMethod(str, regexp, arg2)
12117 };
12118 }
12119
12120 return {
12121 done: false
12122 };
12123 });
12124 redefine(String.prototype, KEY, methods[0]);
12125 redefine(RegExpPrototype, SYMBOL, methods[1]);
12126 }
12127
12128 if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
12129 };
12130
12131 /***/ }),
12132 /* 334 */
12133 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
12134
12135 "use strict";
12136
12137
12138 var charAt = (__webpack_require__(325).charAt); // `AdvanceStringIndex` abstract operation
12139 // https://tc39.es/ecma262/#sec-advancestringindex
12140
12141
12142 module.exports = function (S, index, unicode) {
12143 return index + (unicode ? charAt(S, index).length : 1);
12144 };
12145
12146 /***/ }),
12147 /* 335 */
12148 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
12149
12150 var global = __webpack_require__(3);
12151
12152 var call = __webpack_require__(7);
12153
12154 var anObject = __webpack_require__(42);
12155
12156 var isCallable = __webpack_require__(18);
12157
12158 var classof = __webpack_require__(13);
12159
12160 var regexpExec = __webpack_require__(317);
12161
12162 var TypeError = global.TypeError; // `RegExpExec` abstract operation
12163 // https://tc39.es/ecma262/#sec-regexpexec
12164
12165 module.exports = function (R, S) {
12166 var exec = R.exec;
12167
12168 if (isCallable(exec)) {
12169 var result = call(exec, R, S);
12170 if (result !== null) anObject(result);
12171 return result;
12172 }
12173
12174 if (classof(R) === 'RegExp') return call(regexpExec, R, S);
12175 throw TypeError('RegExp#exec called on incompatible receiver');
12176 };
12177
12178 /***/ }),
12179 /* 336 */
12180 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
12181
12182 "use strict";
12183
12184 /* eslint-disable es/no-string-prototype-matchall -- safe */
12185
12186 var $ = __webpack_require__(2);
12187
12188 var global = __webpack_require__(3);
12189
12190 var call = __webpack_require__(7);
12191
12192 var uncurryThis = __webpack_require__(12);
12193
12194 var createIteratorConstructor = __webpack_require__(140);
12195
12196 var requireObjectCoercible = __webpack_require__(14);
12197
12198 var toLength = __webpack_require__(58);
12199
12200 var toString = __webpack_require__(64);
12201
12202 var anObject = __webpack_require__(42);
12203
12204 var classof = __webpack_require__(13);
12205
12206 var isPrototypeOf = __webpack_require__(21);
12207
12208 var isRegExp = __webpack_require__(310);
12209
12210 var regExpFlags = __webpack_require__(311);
12211
12212 var getMethod = __webpack_require__(26);
12213
12214 var redefine = __webpack_require__(43);
12215
12216 var fails = __webpack_require__(6);
12217
12218 var wellKnownSymbol = __webpack_require__(30);
12219
12220 var speciesConstructor = __webpack_require__(174);
12221
12222 var advanceStringIndex = __webpack_require__(334);
12223
12224 var regExpExec = __webpack_require__(335);
12225
12226 var InternalStateModule = __webpack_require__(45);
12227
12228 var IS_PURE = __webpack_require__(32);
12229
12230 var MATCH_ALL = wellKnownSymbol('matchAll');
12231 var REGEXP_STRING = 'RegExp String';
12232 var REGEXP_STRING_ITERATOR = REGEXP_STRING + ' Iterator';
12233 var setInternalState = InternalStateModule.set;
12234 var getInternalState = InternalStateModule.getterFor(REGEXP_STRING_ITERATOR);
12235 var RegExpPrototype = RegExp.prototype;
12236 var TypeError = global.TypeError;
12237 var getFlags = uncurryThis(regExpFlags);
12238 var stringIndexOf = uncurryThis(''.indexOf);
12239 var un$MatchAll = uncurryThis(''.matchAll);
12240 var WORKS_WITH_NON_GLOBAL_REGEX = !!un$MatchAll && !fails(function () {
12241 un$MatchAll('a', /./);
12242 });
12243 var $RegExpStringIterator = createIteratorConstructor(function RegExpStringIterator(regexp, string, $global, fullUnicode) {
12244 setInternalState(this, {
12245 type: REGEXP_STRING_ITERATOR,
12246 regexp: regexp,
12247 string: string,
12248 global: $global,
12249 unicode: fullUnicode,
12250 done: false
12251 });
12252 }, REGEXP_STRING, function next() {
12253 var state = getInternalState(this);
12254 if (state.done) return {
12255 value: undefined,
12256 done: true
12257 };
12258 var R = state.regexp;
12259 var S = state.string;
12260 var match = regExpExec(R, S);
12261 if (match === null) return {
12262 value: undefined,
12263 done: state.done = true
12264 };
12265
12266 if (state.global) {
12267 if (toString(match[0]) === '') R.lastIndex = advanceStringIndex(S, toLength(R.lastIndex), state.unicode);
12268 return {
12269 value: match,
12270 done: false
12271 };
12272 }
12273
12274 state.done = true;
12275 return {
12276 value: match,
12277 done: false
12278 };
12279 });
12280
12281 var $matchAll = function (string) {
12282 var R = anObject(this);
12283 var S = toString(string);
12284 var C, flagsValue, flags, matcher, $global, fullUnicode;
12285 C = speciesConstructor(R, RegExp);
12286 flagsValue = R.flags;
12287
12288 if (flagsValue === undefined && isPrototypeOf(RegExpPrototype, R) && !('flags' in RegExpPrototype)) {
12289 flagsValue = getFlags(R);
12290 }
12291
12292 flags = flagsValue === undefined ? '' : toString(flagsValue);
12293 matcher = new C(C === RegExp ? R.source : R, flags);
12294 $global = !!~stringIndexOf(flags, 'g');
12295 fullUnicode = !!~stringIndexOf(flags, 'u');
12296 matcher.lastIndex = toLength(R.lastIndex);
12297 return new $RegExpStringIterator(matcher, S, $global, fullUnicode);
12298 }; // `String.prototype.matchAll` method
12299 // https://tc39.es/ecma262/#sec-string.prototype.matchall
12300
12301
12302 $({
12303 target: 'String',
12304 proto: true,
12305 forced: WORKS_WITH_NON_GLOBAL_REGEX
12306 }, {
12307 matchAll: function matchAll(regexp) {
12308 var O = requireObjectCoercible(this);
12309 var flags, S, matcher, rx;
12310
12311 if (regexp != null) {
12312 if (isRegExp(regexp)) {
12313 flags = toString(requireObjectCoercible('flags' in RegExpPrototype ? regexp.flags : getFlags(regexp)));
12314 if (!~stringIndexOf(flags, 'g')) throw TypeError('`.matchAll` does not allow non-global regexes');
12315 }
12316
12317 if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp);
12318 matcher = getMethod(regexp, MATCH_ALL);
12319 if (matcher === undefined && IS_PURE && classof(regexp) == 'RegExp') matcher = $matchAll;
12320 if (matcher) return call(matcher, regexp, O);
12321 } else if (WORKS_WITH_NON_GLOBAL_REGEX) return un$MatchAll(O, regexp);
12322
12323 S = toString(O);
12324 rx = new RegExp(regexp, 'g');
12325 return IS_PURE ? call($matchAll, rx, S) : rx[MATCH_ALL](S);
12326 }
12327 });
12328 IS_PURE || MATCH_ALL in RegExpPrototype || redefine(RegExpPrototype, MATCH_ALL, $matchAll);
12329
12330 /***/ }),
12331 /* 337 */
12332 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
12333
12334 "use strict";
12335
12336
12337 var $ = __webpack_require__(2);
12338
12339 var $padEnd = (__webpack_require__(183).end);
12340
12341 var WEBKIT_BUG = __webpack_require__(338); // `String.prototype.padEnd` method
12342 // https://tc39.es/ecma262/#sec-string.prototype.padend
12343
12344
12345 $({
12346 target: 'String',
12347 proto: true,
12348 forced: WEBKIT_BUG
12349 }, {
12350 padEnd: function padEnd(maxLength
12351 /* , fillString = ' ' */
12352 ) {
12353 return $padEnd(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
12354 }
12355 });
12356
12357 /***/ }),
12358 /* 338 */
12359 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
12360
12361 // https://github.com/zloirock/core-js/issues/280
12362 var userAgent = __webpack_require__(25);
12363
12364 module.exports = /Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent);
12365
12366 /***/ }),
12367 /* 339 */
12368 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
12369
12370 "use strict";
12371
12372
12373 var $ = __webpack_require__(2);
12374
12375 var $padStart = (__webpack_require__(183).start);
12376
12377 var WEBKIT_BUG = __webpack_require__(338); // `String.prototype.padStart` method
12378 // https://tc39.es/ecma262/#sec-string.prototype.padstart
12379
12380
12381 $({
12382 target: 'String',
12383 proto: true,
12384 forced: WEBKIT_BUG
12385 }, {
12386 padStart: function padStart(maxLength
12387 /* , fillString = ' ' */
12388 ) {
12389 return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
12390 }
12391 });
12392
12393 /***/ }),
12394 /* 340 */
12395 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
12396
12397 var $ = __webpack_require__(2);
12398
12399 var uncurryThis = __webpack_require__(12);
12400
12401 var toIndexedObject = __webpack_require__(10);
12402
12403 var toObject = __webpack_require__(36);
12404
12405 var toString = __webpack_require__(64);
12406
12407 var lengthOfArrayLike = __webpack_require__(57);
12408
12409 var push = uncurryThis([].push);
12410 var join = uncurryThis([].join); // `String.raw` method
12411 // https://tc39.es/ecma262/#sec-string.raw
12412
12413 $({
12414 target: 'String',
12415 stat: true
12416 }, {
12417 raw: function raw(template) {
12418 var rawTemplate = toIndexedObject(toObject(template).raw);
12419 var literalSegments = lengthOfArrayLike(rawTemplate);
12420 var argumentsLength = arguments.length;
12421 var elements = [];
12422 var i = 0;
12423
12424 while (literalSegments > i) {
12425 push(elements, toString(rawTemplate[i++]));
12426 if (i === literalSegments) return join(elements, '');
12427 if (i < argumentsLength) push(elements, toString(arguments[i]));
12428 }
12429 }
12430 });
12431
12432 /***/ }),
12433 /* 341 */
12434 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
12435
12436 var $ = __webpack_require__(2);
12437
12438 var repeat = __webpack_require__(184); // `String.prototype.repeat` method
12439 // https://tc39.es/ecma262/#sec-string.prototype.repeat
12440
12441
12442 $({
12443 target: 'String',
12444 proto: true
12445 }, {
12446 repeat: repeat
12447 });
12448
12449 /***/ }),
12450 /* 342 */
12451 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
12452
12453 "use strict";
12454
12455
12456 var apply = __webpack_require__(62);
12457
12458 var call = __webpack_require__(7);
12459
12460 var uncurryThis = __webpack_require__(12);
12461
12462 var fixRegExpWellKnownSymbolLogic = __webpack_require__(333);
12463
12464 var fails = __webpack_require__(6);
12465
12466 var anObject = __webpack_require__(42);
12467
12468 var isCallable = __webpack_require__(18);
12469
12470 var toIntegerOrInfinity = __webpack_require__(56);
12471
12472 var toLength = __webpack_require__(58);
12473
12474 var toString = __webpack_require__(64);
12475
12476 var requireObjectCoercible = __webpack_require__(14);
12477
12478 var advanceStringIndex = __webpack_require__(334);
12479
12480 var getMethod = __webpack_require__(26);
12481
12482 var getSubstitution = __webpack_require__(343);
12483
12484 var regExpExec = __webpack_require__(335);
12485
12486 var wellKnownSymbol = __webpack_require__(30);
12487
12488 var REPLACE = wellKnownSymbol('replace');
12489 var max = Math.max;
12490 var min = Math.min;
12491 var concat = uncurryThis([].concat);
12492 var push = uncurryThis([].push);
12493 var stringIndexOf = uncurryThis(''.indexOf);
12494 var stringSlice = uncurryThis(''.slice);
12495
12496 var maybeToString = function (it) {
12497 return it === undefined ? it : String(it);
12498 }; // IE <= 11 replaces $0 with the whole match, as if it was $&
12499 // https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
12500
12501
12502 var REPLACE_KEEPS_$0 = function () {
12503 // eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing
12504 return 'a'.replace(/./, '$0') === '$0';
12505 }(); // Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
12506
12507
12508 var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = function () {
12509 if (/./[REPLACE]) {
12510 return /./[REPLACE]('a', '$0') === '';
12511 }
12512
12513 return false;
12514 }();
12515
12516 var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
12517 var re = /./;
12518
12519 re.exec = function () {
12520 var result = [];
12521 result.groups = {
12522 a: '7'
12523 };
12524 return result;
12525 }; // eslint-disable-next-line regexp/no-useless-dollar-replacements -- false positive
12526
12527
12528 return ''.replace(re, '$<a>') !== '7';
12529 }); // @@replace logic
12530
12531 fixRegExpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNative) {
12532 var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0';
12533 return [// `String.prototype.replace` method
12534 // https://tc39.es/ecma262/#sec-string.prototype.replace
12535 function replace(searchValue, replaceValue) {
12536 var O = requireObjectCoercible(this);
12537 var replacer = searchValue == undefined ? undefined : getMethod(searchValue, REPLACE);
12538 return replacer ? call(replacer, searchValue, O, replaceValue) : call(nativeReplace, toString(O), searchValue, replaceValue);
12539 }, // `RegExp.prototype[@@replace]` method
12540 // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace
12541 function (string, replaceValue) {
12542 var rx = anObject(this);
12543 var S = toString(string);
12544
12545 if (typeof replaceValue == 'string' && stringIndexOf(replaceValue, UNSAFE_SUBSTITUTE) === -1 && stringIndexOf(replaceValue, '$<') === -1) {
12546 var res = maybeCallNative(nativeReplace, rx, S, replaceValue);
12547 if (res.done) return res.value;
12548 }
12549
12550 var functionalReplace = isCallable(replaceValue);
12551 if (!functionalReplace) replaceValue = toString(replaceValue);
12552 var global = rx.global;
12553
12554 if (global) {
12555 var fullUnicode = rx.unicode;
12556 rx.lastIndex = 0;
12557 }
12558
12559 var results = [];
12560
12561 while (true) {
12562 var result = regExpExec(rx, S);
12563 if (result === null) break;
12564 push(results, result);
12565 if (!global) break;
12566 var matchStr = toString(result[0]);
12567 if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
12568 }
12569
12570 var accumulatedResult = '';
12571 var nextSourcePosition = 0;
12572
12573 for (var i = 0; i < results.length; i++) {
12574 result = results[i];
12575 var matched = toString(result[0]);
12576 var position = max(min(toIntegerOrInfinity(result.index), S.length), 0);
12577 var captures = []; // NOTE: This is equivalent to
12578 // captures = result.slice(1).map(maybeToString)
12579 // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
12580 // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
12581 // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
12582
12583 for (var j = 1; j < result.length; j++) push(captures, maybeToString(result[j]));
12584
12585 var namedCaptures = result.groups;
12586
12587 if (functionalReplace) {
12588 var replacerArgs = concat([matched], captures, position, S);
12589 if (namedCaptures !== undefined) push(replacerArgs, namedCaptures);
12590 var replacement = toString(apply(replaceValue, undefined, replacerArgs));
12591 } else {
12592 replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
12593 }
12594
12595 if (position >= nextSourcePosition) {
12596 accumulatedResult += stringSlice(S, nextSourcePosition, position) + replacement;
12597 nextSourcePosition = position + matched.length;
12598 }
12599 }
12600
12601 return accumulatedResult + stringSlice(S, nextSourcePosition);
12602 }];
12603 }, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE);
12604
12605 /***/ }),
12606 /* 343 */
12607 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
12608
12609 var uncurryThis = __webpack_require__(12);
12610
12611 var toObject = __webpack_require__(36);
12612
12613 var floor = Math.floor;
12614 var charAt = uncurryThis(''.charAt);
12615 var replace = uncurryThis(''.replace);
12616 var stringSlice = uncurryThis(''.slice);
12617 var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g;
12618 var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; // `GetSubstitution` abstract operation
12619 // https://tc39.es/ecma262/#sec-getsubstitution
12620
12621 module.exports = function (matched, str, position, captures, namedCaptures, replacement) {
12622 var tailPos = position + matched.length;
12623 var m = captures.length;
12624 var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
12625
12626 if (namedCaptures !== undefined) {
12627 namedCaptures = toObject(namedCaptures);
12628 symbols = SUBSTITUTION_SYMBOLS;
12629 }
12630
12631 return replace(replacement, symbols, function (match, ch) {
12632 var capture;
12633
12634 switch (charAt(ch, 0)) {
12635 case '$':
12636 return '$';
12637
12638 case '&':
12639 return matched;
12640
12641 case '`':
12642 return stringSlice(str, 0, position);
12643
12644 case "'":
12645 return stringSlice(str, tailPos);
12646
12647 case '<':
12648 capture = namedCaptures[stringSlice(ch, 1, -1)];
12649 break;
12650
12651 default:
12652 // \d\d?
12653 var n = +ch;
12654 if (n === 0) return match;
12655
12656 if (n > m) {
12657 var f = floor(n / 10);
12658 if (f === 0) return match;
12659 if (f <= m) return captures[f - 1] === undefined ? charAt(ch, 1) : captures[f - 1] + charAt(ch, 1);
12660 return match;
12661 }
12662
12663 capture = captures[n - 1];
12664 }
12665
12666 return capture === undefined ? '' : capture;
12667 });
12668 };
12669
12670 /***/ }),
12671 /* 344 */
12672 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
12673
12674 "use strict";
12675
12676
12677 var $ = __webpack_require__(2);
12678
12679 var global = __webpack_require__(3);
12680
12681 var call = __webpack_require__(7);
12682
12683 var uncurryThis = __webpack_require__(12);
12684
12685 var requireObjectCoercible = __webpack_require__(14);
12686
12687 var isCallable = __webpack_require__(18);
12688
12689 var isRegExp = __webpack_require__(310);
12690
12691 var toString = __webpack_require__(64);
12692
12693 var getMethod = __webpack_require__(26);
12694
12695 var regExpFlags = __webpack_require__(311);
12696
12697 var getSubstitution = __webpack_require__(343);
12698
12699 var wellKnownSymbol = __webpack_require__(30);
12700
12701 var IS_PURE = __webpack_require__(32);
12702
12703 var REPLACE = wellKnownSymbol('replace');
12704 var RegExpPrototype = RegExp.prototype;
12705 var TypeError = global.TypeError;
12706 var getFlags = uncurryThis(regExpFlags);
12707 var indexOf = uncurryThis(''.indexOf);
12708 var replace = uncurryThis(''.replace);
12709 var stringSlice = uncurryThis(''.slice);
12710 var max = Math.max;
12711
12712 var stringIndexOf = function (string, searchValue, fromIndex) {
12713 if (fromIndex > string.length) return -1;
12714 if (searchValue === '') return fromIndex;
12715 return indexOf(string, searchValue, fromIndex);
12716 }; // `String.prototype.replaceAll` method
12717 // https://tc39.es/ecma262/#sec-string.prototype.replaceall
12718
12719
12720 $({
12721 target: 'String',
12722 proto: true
12723 }, {
12724 replaceAll: function replaceAll(searchValue, replaceValue) {
12725 var O = requireObjectCoercible(this);
12726 var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, replacement;
12727 var position = 0;
12728 var endOfLastMatch = 0;
12729 var result = '';
12730
12731 if (searchValue != null) {
12732 IS_REG_EXP = isRegExp(searchValue);
12733
12734 if (IS_REG_EXP) {
12735 flags = toString(requireObjectCoercible('flags' in RegExpPrototype ? searchValue.flags : getFlags(searchValue)));
12736 if (!~indexOf(flags, 'g')) throw TypeError('`.replaceAll` does not allow non-global regexes');
12737 }
12738
12739 replacer = getMethod(searchValue, REPLACE);
12740
12741 if (replacer) {
12742 return call(replacer, searchValue, O, replaceValue);
12743 } else if (IS_PURE && IS_REG_EXP) {
12744 return replace(toString(O), searchValue, replaceValue);
12745 }
12746 }
12747
12748 string = toString(O);
12749 searchString = toString(searchValue);
12750 functionalReplace = isCallable(replaceValue);
12751 if (!functionalReplace) replaceValue = toString(replaceValue);
12752 searchLength = searchString.length;
12753 advanceBy = max(1, searchLength);
12754 position = stringIndexOf(string, searchString, 0);
12755
12756 while (position !== -1) {
12757 replacement = functionalReplace ? toString(replaceValue(searchString, position, string)) : getSubstitution(searchString, string, position, [], undefined, replaceValue);
12758 result += stringSlice(string, endOfLastMatch, position) + replacement;
12759 endOfLastMatch = position + searchLength;
12760 position = stringIndexOf(string, searchString, position + advanceBy);
12761 }
12762
12763 if (endOfLastMatch < string.length) {
12764 result += stringSlice(string, endOfLastMatch);
12765 }
12766
12767 return result;
12768 }
12769 });
12770
12771 /***/ }),
12772 /* 345 */
12773 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
12774
12775 "use strict";
12776
12777
12778 var call = __webpack_require__(7);
12779
12780 var fixRegExpWellKnownSymbolLogic = __webpack_require__(333);
12781
12782 var anObject = __webpack_require__(42);
12783
12784 var requireObjectCoercible = __webpack_require__(14);
12785
12786 var sameValue = __webpack_require__(264);
12787
12788 var toString = __webpack_require__(64);
12789
12790 var getMethod = __webpack_require__(26);
12791
12792 var regExpExec = __webpack_require__(335); // @@search logic
12793
12794
12795 fixRegExpWellKnownSymbolLogic('search', function (SEARCH, nativeSearch, maybeCallNative) {
12796 return [// `String.prototype.search` method
12797 // https://tc39.es/ecma262/#sec-string.prototype.search
12798 function search(regexp) {
12799 var O = requireObjectCoercible(this);
12800 var searcher = regexp == undefined ? undefined : getMethod(regexp, SEARCH);
12801 return searcher ? call(searcher, regexp, O) : new RegExp(regexp)[SEARCH](toString(O));
12802 }, // `RegExp.prototype[@@search]` method
12803 // https://tc39.es/ecma262/#sec-regexp.prototype-@@search
12804 function (string) {
12805 var rx = anObject(this);
12806 var S = toString(string);
12807 var res = maybeCallNative(nativeSearch, rx, S);
12808 if (res.done) return res.value;
12809 var previousLastIndex = rx.lastIndex;
12810 if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;
12811 var result = regExpExec(rx, S);
12812 if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex;
12813 return result === null ? -1 : result.index;
12814 }];
12815 });
12816
12817 /***/ }),
12818 /* 346 */
12819 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
12820
12821 "use strict";
12822
12823
12824 var apply = __webpack_require__(62);
12825
12826 var call = __webpack_require__(7);
12827
12828 var uncurryThis = __webpack_require__(12);
12829
12830 var fixRegExpWellKnownSymbolLogic = __webpack_require__(333);
12831
12832 var isRegExp = __webpack_require__(310);
12833
12834 var anObject = __webpack_require__(42);
12835
12836 var requireObjectCoercible = __webpack_require__(14);
12837
12838 var speciesConstructor = __webpack_require__(174);
12839
12840 var advanceStringIndex = __webpack_require__(334);
12841
12842 var toLength = __webpack_require__(58);
12843
12844 var toString = __webpack_require__(64);
12845
12846 var getMethod = __webpack_require__(26);
12847
12848 var arraySlice = __webpack_require__(72);
12849
12850 var callRegExpExec = __webpack_require__(335);
12851
12852 var regexpExec = __webpack_require__(317);
12853
12854 var stickyHelpers = __webpack_require__(312);
12855
12856 var fails = __webpack_require__(6);
12857
12858 var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
12859 var MAX_UINT32 = 0xFFFFFFFF;
12860 var min = Math.min;
12861 var $push = [].push;
12862 var exec = uncurryThis(/./.exec);
12863 var push = uncurryThis($push);
12864 var stringSlice = uncurryThis(''.slice); // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
12865 // Weex JS has frozen built-in prototypes, so use try / catch wrapper
12866
12867 var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
12868 // eslint-disable-next-line regexp/no-empty-group -- required for testing
12869 var re = /(?:)/;
12870 var originalExec = re.exec;
12871
12872 re.exec = function () {
12873 return originalExec.apply(this, arguments);
12874 };
12875
12876 var result = 'ab'.split(re);
12877 return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
12878 }); // @@split logic
12879
12880 fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) {
12881 var internalSplit;
12882
12883 if ('abbc'.split(/(b)*/)[1] == 'c' || // eslint-disable-next-line regexp/no-empty-group -- required for testing
12884 'test'.split(/(?:)/, -1).length != 4 || 'ab'.split(/(?:ab)*/).length != 2 || '.'.split(/(.?)(.?)/).length != 4 || // eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing
12885 '.'.split(/()()/).length > 1 || ''.split(/.?/).length) {
12886 // based on es5-shim implementation, need to rework it
12887 internalSplit = function (separator, limit) {
12888 var string = toString(requireObjectCoercible(this));
12889 var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
12890 if (lim === 0) return [];
12891 if (separator === undefined) return [string]; // If `separator` is not a regex, use native split
12892
12893 if (!isRegExp(separator)) {
12894 return call(nativeSplit, string, separator, lim);
12895 }
12896
12897 var output = [];
12898 var flags = (separator.ignoreCase ? 'i' : '') + (separator.multiline ? 'm' : '') + (separator.unicode ? 'u' : '') + (separator.sticky ? 'y' : '');
12899 var lastLastIndex = 0; // Make `global` and avoid `lastIndex` issues by working with a copy
12900
12901 var separatorCopy = new RegExp(separator.source, flags + 'g');
12902 var match, lastIndex, lastLength;
12903
12904 while (match = call(regexpExec, separatorCopy, string)) {
12905 lastIndex = separatorCopy.lastIndex;
12906
12907 if (lastIndex > lastLastIndex) {
12908 push(output, stringSlice(string, lastLastIndex, match.index));
12909 if (match.length > 1 && match.index < string.length) apply($push, output, arraySlice(match, 1));
12910 lastLength = match[0].length;
12911 lastLastIndex = lastIndex;
12912 if (output.length >= lim) break;
12913 }
12914
12915 if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
12916 }
12917
12918 if (lastLastIndex === string.length) {
12919 if (lastLength || !exec(separatorCopy, '')) push(output, '');
12920 } else push(output, stringSlice(string, lastLastIndex));
12921
12922 return output.length > lim ? arraySlice(output, 0, lim) : output;
12923 }; // Chakra, V8
12924
12925 } else if ('0'.split(undefined, 0).length) {
12926 internalSplit = function (separator, limit) {
12927 return separator === undefined && limit === 0 ? [] : call(nativeSplit, this, separator, limit);
12928 };
12929 } else internalSplit = nativeSplit;
12930
12931 return [// `String.prototype.split` method
12932 // https://tc39.es/ecma262/#sec-string.prototype.split
12933 function split(separator, limit) {
12934 var O = requireObjectCoercible(this);
12935 var splitter = separator == undefined ? undefined : getMethod(separator, SPLIT);
12936 return splitter ? call(splitter, separator, O, limit) : call(internalSplit, toString(O), separator, limit);
12937 }, // `RegExp.prototype[@@split]` method
12938 // https://tc39.es/ecma262/#sec-regexp.prototype-@@split
12939 //
12940 // NOTE: This cannot be properly polyfilled in engines that don't support
12941 // the 'y' flag.
12942 function (string, limit) {
12943 var rx = anObject(this);
12944 var S = toString(string);
12945 var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit);
12946 if (res.done) return res.value;
12947 var C = speciesConstructor(rx, RegExp);
12948 var unicodeMatching = rx.unicode;
12949 var flags = (rx.ignoreCase ? 'i' : '') + (rx.multiline ? 'm' : '') + (rx.unicode ? 'u' : '') + (UNSUPPORTED_Y ? 'g' : 'y'); // ^(? + rx + ) is needed, in combination with some S slicing, to
12950 // simulate the 'y' flag.
12951
12952 var splitter = new C(UNSUPPORTED_Y ? '^(?:' + rx.source + ')' : rx, flags);
12953 var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
12954 if (lim === 0) return [];
12955 if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];
12956 var p = 0;
12957 var q = 0;
12958 var A = [];
12959
12960 while (q < S.length) {
12961 splitter.lastIndex = UNSUPPORTED_Y ? 0 : q;
12962 var z = callRegExpExec(splitter, UNSUPPORTED_Y ? stringSlice(S, q) : S);
12963 var e;
12964
12965 if (z === null || (e = min(toLength(splitter.lastIndex + (UNSUPPORTED_Y ? q : 0)), S.length)) === p) {
12966 q = advanceStringIndex(S, q, unicodeMatching);
12967 } else {
12968 push(A, stringSlice(S, p, q));
12969 if (A.length === lim) return A;
12970
12971 for (var i = 1; i <= z.length - 1; i++) {
12972 push(A, z[i]);
12973 if (A.length === lim) return A;
12974 }
12975
12976 q = p = e;
12977 }
12978 }
12979
12980 push(A, stringSlice(S, p));
12981 return A;
12982 }];
12983 }, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
12984
12985 /***/ }),
12986 /* 347 */
12987 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
12988
12989 "use strict";
12990
12991
12992 var $ = __webpack_require__(2);
12993
12994 var uncurryThis = __webpack_require__(12);
12995
12996 var getOwnPropertyDescriptor = (__webpack_require__(4).f);
12997
12998 var toLength = __webpack_require__(58);
12999
13000 var toString = __webpack_require__(64);
13001
13002 var notARegExp = __webpack_require__(327);
13003
13004 var requireObjectCoercible = __webpack_require__(14);
13005
13006 var correctIsRegExpLogic = __webpack_require__(328);
13007
13008 var IS_PURE = __webpack_require__(32); // eslint-disable-next-line es/no-string-prototype-startswith -- safe
13009
13010
13011 var un$StartsWith = uncurryThis(''.startsWith);
13012 var stringSlice = uncurryThis(''.slice);
13013 var min = Math.min;
13014 var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith'); // https://github.com/zloirock/core-js/pull/702
13015
13016 var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
13017 var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
13018 return descriptor && !descriptor.writable;
13019 }(); // `String.prototype.startsWith` method
13020 // https://tc39.es/ecma262/#sec-string.prototype.startswith
13021
13022 $({
13023 target: 'String',
13024 proto: true,
13025 forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC
13026 }, {
13027 startsWith: function startsWith(searchString
13028 /* , position = 0 */
13029 ) {
13030 var that = toString(requireObjectCoercible(this));
13031 notARegExp(searchString);
13032 var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
13033 var search = toString(searchString);
13034 return un$StartsWith ? un$StartsWith(that, search, index) : stringSlice(that, index, index + search.length) === search;
13035 }
13036 });
13037
13038 /***/ }),
13039 /* 348 */
13040 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13041
13042 "use strict";
13043
13044
13045 var $ = __webpack_require__(2);
13046
13047 var uncurryThis = __webpack_require__(12);
13048
13049 var requireObjectCoercible = __webpack_require__(14);
13050
13051 var toIntegerOrInfinity = __webpack_require__(56);
13052
13053 var toString = __webpack_require__(64);
13054
13055 var stringSlice = uncurryThis(''.slice);
13056 var max = Math.max;
13057 var min = Math.min; // eslint-disable-next-line unicorn/prefer-string-slice -- required for testing
13058
13059 var FORCED = !''.substr || 'ab'.substr(-1) !== 'b'; // `String.prototype.substr` method
13060 // https://tc39.es/ecma262/#sec-string.prototype.substr
13061
13062 $({
13063 target: 'String',
13064 proto: true,
13065 forced: FORCED
13066 }, {
13067 substr: function substr(start, length) {
13068 var that = toString(requireObjectCoercible(this));
13069 var size = that.length;
13070 var intStart = toIntegerOrInfinity(start);
13071 var intLength, intEnd;
13072 if (intStart === Infinity) intStart = 0;
13073 if (intStart < 0) intStart = max(size + intStart, 0);
13074 intLength = length === undefined ? size : toIntegerOrInfinity(length);
13075 if (intLength <= 0 || intLength === Infinity) return '';
13076 intEnd = min(intStart + intLength, size);
13077 return intStart >= intEnd ? '' : stringSlice(that, intStart, intEnd);
13078 }
13079 });
13080
13081 /***/ }),
13082 /* 349 */
13083 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13084
13085 "use strict";
13086
13087
13088 var $ = __webpack_require__(2);
13089
13090 var $trim = (__webpack_require__(229).trim);
13091
13092 var forcedStringTrimMethod = __webpack_require__(350); // `String.prototype.trim` method
13093 // https://tc39.es/ecma262/#sec-string.prototype.trim
13094
13095
13096 $({
13097 target: 'String',
13098 proto: true,
13099 forced: forcedStringTrimMethod('trim')
13100 }, {
13101 trim: function trim() {
13102 return $trim(this);
13103 }
13104 });
13105
13106 /***/ }),
13107 /* 350 */
13108 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
13109
13110 var PROPER_FUNCTION_NAME = (__webpack_require__(49).PROPER);
13111
13112 var fails = __webpack_require__(6);
13113
13114 var whitespaces = __webpack_require__(230);
13115
13116 var non = '\u200B\u0085\u180E'; // check that a method works with the correct list
13117 // of whitespaces and has a correct name
13118
13119 module.exports = function (METHOD_NAME) {
13120 return fails(function () {
13121 return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() !== non || PROPER_FUNCTION_NAME && whitespaces[METHOD_NAME].name !== METHOD_NAME;
13122 });
13123 };
13124
13125 /***/ }),
13126 /* 351 */
13127 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13128
13129 "use strict";
13130
13131
13132 var $ = __webpack_require__(2);
13133
13134 var $trimEnd = (__webpack_require__(229).end);
13135
13136 var forcedStringTrimMethod = __webpack_require__(350);
13137
13138 var FORCED = forcedStringTrimMethod('trimEnd');
13139 var trimEnd = FORCED ? function trimEnd() {
13140 return $trimEnd(this); // eslint-disable-next-line es/no-string-prototype-trimstart-trimend -- safe
13141 } : ''.trimEnd; // `String.prototype.{ trimEnd, trimRight }` methods
13142 // https://tc39.es/ecma262/#sec-string.prototype.trimend
13143 // https://tc39.es/ecma262/#String.prototype.trimright
13144
13145 $({
13146 target: 'String',
13147 proto: true,
13148 name: 'trimEnd',
13149 forced: FORCED
13150 }, {
13151 trimEnd: trimEnd,
13152 trimRight: trimEnd
13153 });
13154
13155 /***/ }),
13156 /* 352 */
13157 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13158
13159 "use strict";
13160
13161
13162 var $ = __webpack_require__(2);
13163
13164 var $trimStart = (__webpack_require__(229).start);
13165
13166 var forcedStringTrimMethod = __webpack_require__(350);
13167
13168 var FORCED = forcedStringTrimMethod('trimStart');
13169 var trimStart = FORCED ? function trimStart() {
13170 return $trimStart(this); // eslint-disable-next-line es/no-string-prototype-trimstart-trimend -- safe
13171 } : ''.trimStart; // `String.prototype.{ trimStart, trimLeft }` methods
13172 // https://tc39.es/ecma262/#sec-string.prototype.trimstart
13173 // https://tc39.es/ecma262/#String.prototype.trimleft
13174
13175 $({
13176 target: 'String',
13177 proto: true,
13178 name: 'trimStart',
13179 forced: FORCED
13180 }, {
13181 trimStart: trimStart,
13182 trimLeft: trimStart
13183 });
13184
13185 /***/ }),
13186 /* 353 */
13187 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13188
13189 "use strict";
13190
13191
13192 var $ = __webpack_require__(2);
13193
13194 var createHTML = __webpack_require__(354);
13195
13196 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.anchor` method
13197 // https://tc39.es/ecma262/#sec-string.prototype.anchor
13198
13199
13200 $({
13201 target: 'String',
13202 proto: true,
13203 forced: forcedStringHTMLMethod('anchor')
13204 }, {
13205 anchor: function anchor(name) {
13206 return createHTML(this, 'a', 'name', name);
13207 }
13208 });
13209
13210 /***/ }),
13211 /* 354 */
13212 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
13213
13214 var uncurryThis = __webpack_require__(12);
13215
13216 var requireObjectCoercible = __webpack_require__(14);
13217
13218 var toString = __webpack_require__(64);
13219
13220 var quot = /"/g;
13221 var replace = uncurryThis(''.replace); // `CreateHTML` abstract operation
13222 // https://tc39.es/ecma262/#sec-createhtml
13223
13224 module.exports = function (string, tag, attribute, value) {
13225 var S = toString(requireObjectCoercible(string));
13226 var p1 = '<' + tag;
13227 if (attribute !== '') p1 += ' ' + attribute + '="' + replace(toString(value), quot, '&quot;') + '"';
13228 return p1 + '>' + S + '</' + tag + '>';
13229 };
13230
13231 /***/ }),
13232 /* 355 */
13233 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
13234
13235 var fails = __webpack_require__(6); // check the existence of a method, lowercase
13236 // of a tag and escaping quotes in arguments
13237
13238
13239 module.exports = function (METHOD_NAME) {
13240 return fails(function () {
13241 var test = ''[METHOD_NAME]('"');
13242 return test !== test.toLowerCase() || test.split('"').length > 3;
13243 });
13244 };
13245
13246 /***/ }),
13247 /* 356 */
13248 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13249
13250 "use strict";
13251
13252
13253 var $ = __webpack_require__(2);
13254
13255 var createHTML = __webpack_require__(354);
13256
13257 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.big` method
13258 // https://tc39.es/ecma262/#sec-string.prototype.big
13259
13260
13261 $({
13262 target: 'String',
13263 proto: true,
13264 forced: forcedStringHTMLMethod('big')
13265 }, {
13266 big: function big() {
13267 return createHTML(this, 'big', '', '');
13268 }
13269 });
13270
13271 /***/ }),
13272 /* 357 */
13273 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13274
13275 "use strict";
13276
13277
13278 var $ = __webpack_require__(2);
13279
13280 var createHTML = __webpack_require__(354);
13281
13282 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.blink` method
13283 // https://tc39.es/ecma262/#sec-string.prototype.blink
13284
13285
13286 $({
13287 target: 'String',
13288 proto: true,
13289 forced: forcedStringHTMLMethod('blink')
13290 }, {
13291 blink: function blink() {
13292 return createHTML(this, 'blink', '', '');
13293 }
13294 });
13295
13296 /***/ }),
13297 /* 358 */
13298 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13299
13300 "use strict";
13301
13302
13303 var $ = __webpack_require__(2);
13304
13305 var createHTML = __webpack_require__(354);
13306
13307 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.bold` method
13308 // https://tc39.es/ecma262/#sec-string.prototype.bold
13309
13310
13311 $({
13312 target: 'String',
13313 proto: true,
13314 forced: forcedStringHTMLMethod('bold')
13315 }, {
13316 bold: function bold() {
13317 return createHTML(this, 'b', '', '');
13318 }
13319 });
13320
13321 /***/ }),
13322 /* 359 */
13323 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13324
13325 "use strict";
13326
13327
13328 var $ = __webpack_require__(2);
13329
13330 var createHTML = __webpack_require__(354);
13331
13332 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.fixed` method
13333 // https://tc39.es/ecma262/#sec-string.prototype.fixed
13334
13335
13336 $({
13337 target: 'String',
13338 proto: true,
13339 forced: forcedStringHTMLMethod('fixed')
13340 }, {
13341 fixed: function fixed() {
13342 return createHTML(this, 'tt', '', '');
13343 }
13344 });
13345
13346 /***/ }),
13347 /* 360 */
13348 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13349
13350 "use strict";
13351
13352
13353 var $ = __webpack_require__(2);
13354
13355 var createHTML = __webpack_require__(354);
13356
13357 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.fontcolor` method
13358 // https://tc39.es/ecma262/#sec-string.prototype.fontcolor
13359
13360
13361 $({
13362 target: 'String',
13363 proto: true,
13364 forced: forcedStringHTMLMethod('fontcolor')
13365 }, {
13366 fontcolor: function fontcolor(color) {
13367 return createHTML(this, 'font', 'color', color);
13368 }
13369 });
13370
13371 /***/ }),
13372 /* 361 */
13373 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13374
13375 "use strict";
13376
13377
13378 var $ = __webpack_require__(2);
13379
13380 var createHTML = __webpack_require__(354);
13381
13382 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.fontsize` method
13383 // https://tc39.es/ecma262/#sec-string.prototype.fontsize
13384
13385
13386 $({
13387 target: 'String',
13388 proto: true,
13389 forced: forcedStringHTMLMethod('fontsize')
13390 }, {
13391 fontsize: function fontsize(size) {
13392 return createHTML(this, 'font', 'size', size);
13393 }
13394 });
13395
13396 /***/ }),
13397 /* 362 */
13398 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13399
13400 "use strict";
13401
13402
13403 var $ = __webpack_require__(2);
13404
13405 var createHTML = __webpack_require__(354);
13406
13407 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.italics` method
13408 // https://tc39.es/ecma262/#sec-string.prototype.italics
13409
13410
13411 $({
13412 target: 'String',
13413 proto: true,
13414 forced: forcedStringHTMLMethod('italics')
13415 }, {
13416 italics: function italics() {
13417 return createHTML(this, 'i', '', '');
13418 }
13419 });
13420
13421 /***/ }),
13422 /* 363 */
13423 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13424
13425 "use strict";
13426
13427
13428 var $ = __webpack_require__(2);
13429
13430 var createHTML = __webpack_require__(354);
13431
13432 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.link` method
13433 // https://tc39.es/ecma262/#sec-string.prototype.link
13434
13435
13436 $({
13437 target: 'String',
13438 proto: true,
13439 forced: forcedStringHTMLMethod('link')
13440 }, {
13441 link: function link(url) {
13442 return createHTML(this, 'a', 'href', url);
13443 }
13444 });
13445
13446 /***/ }),
13447 /* 364 */
13448 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13449
13450 "use strict";
13451
13452
13453 var $ = __webpack_require__(2);
13454
13455 var createHTML = __webpack_require__(354);
13456
13457 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.small` method
13458 // https://tc39.es/ecma262/#sec-string.prototype.small
13459
13460
13461 $({
13462 target: 'String',
13463 proto: true,
13464 forced: forcedStringHTMLMethod('small')
13465 }, {
13466 small: function small() {
13467 return createHTML(this, 'small', '', '');
13468 }
13469 });
13470
13471 /***/ }),
13472 /* 365 */
13473 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13474
13475 "use strict";
13476
13477
13478 var $ = __webpack_require__(2);
13479
13480 var createHTML = __webpack_require__(354);
13481
13482 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.strike` method
13483 // https://tc39.es/ecma262/#sec-string.prototype.strike
13484
13485
13486 $({
13487 target: 'String',
13488 proto: true,
13489 forced: forcedStringHTMLMethod('strike')
13490 }, {
13491 strike: function strike() {
13492 return createHTML(this, 'strike', '', '');
13493 }
13494 });
13495
13496 /***/ }),
13497 /* 366 */
13498 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13499
13500 "use strict";
13501
13502
13503 var $ = __webpack_require__(2);
13504
13505 var createHTML = __webpack_require__(354);
13506
13507 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.sub` method
13508 // https://tc39.es/ecma262/#sec-string.prototype.sub
13509
13510
13511 $({
13512 target: 'String',
13513 proto: true,
13514 forced: forcedStringHTMLMethod('sub')
13515 }, {
13516 sub: function sub() {
13517 return createHTML(this, 'sub', '', '');
13518 }
13519 });
13520
13521 /***/ }),
13522 /* 367 */
13523 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13524
13525 "use strict";
13526
13527
13528 var $ = __webpack_require__(2);
13529
13530 var createHTML = __webpack_require__(354);
13531
13532 var forcedStringHTMLMethod = __webpack_require__(355); // `String.prototype.sup` method
13533 // https://tc39.es/ecma262/#sec-string.prototype.sup
13534
13535
13536 $({
13537 target: 'String',
13538 proto: true,
13539 forced: forcedStringHTMLMethod('sup')
13540 }, {
13541 sup: function sup() {
13542 return createHTML(this, 'sup', '', '');
13543 }
13544 });
13545
13546 /***/ }),
13547 /* 368 */
13548 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13549
13550 var createTypedArrayConstructor = __webpack_require__(369); // `Float32Array` constructor
13551 // https://tc39.es/ecma262/#sec-typedarray-objects
13552
13553
13554 createTypedArrayConstructor('Float32', function (init) {
13555 return function Float32Array(data, byteOffset, length) {
13556 return init(this, data, byteOffset, length);
13557 };
13558 });
13559
13560 /***/ }),
13561 /* 369 */
13562 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
13563
13564 "use strict";
13565
13566
13567 var $ = __webpack_require__(2);
13568
13569 var global = __webpack_require__(3);
13570
13571 var call = __webpack_require__(7);
13572
13573 var DESCRIPTORS = __webpack_require__(5);
13574
13575 var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = __webpack_require__(370);
13576
13577 var ArrayBufferViewCore = __webpack_require__(172);
13578
13579 var ArrayBufferModule = __webpack_require__(165);
13580
13581 var anInstance = __webpack_require__(168);
13582
13583 var createPropertyDescriptor = __webpack_require__(9);
13584
13585 var createNonEnumerableProperty = __webpack_require__(40);
13586
13587 var isIntegralNumber = __webpack_require__(235);
13588
13589 var toLength = __webpack_require__(58);
13590
13591 var toIndex = __webpack_require__(169);
13592
13593 var toOffset = __webpack_require__(371);
13594
13595 var toPropertyKey = __webpack_require__(15);
13596
13597 var hasOwn = __webpack_require__(35);
13598
13599 var classof = __webpack_require__(65);
13600
13601 var isObject = __webpack_require__(17);
13602
13603 var isSymbol = __webpack_require__(19);
13604
13605 var create = __webpack_require__(67);
13606
13607 var isPrototypeOf = __webpack_require__(21);
13608
13609 var setPrototypeOf = __webpack_require__(101);
13610
13611 var getOwnPropertyNames = (__webpack_require__(52).f);
13612
13613 var typedArrayFrom = __webpack_require__(373);
13614
13615 var forEach = (__webpack_require__(79).forEach);
13616
13617 var setSpecies = __webpack_require__(160);
13618
13619 var definePropertyModule = __webpack_require__(41);
13620
13621 var getOwnPropertyDescriptorModule = __webpack_require__(4);
13622
13623 var InternalStateModule = __webpack_require__(45);
13624
13625 var inheritIfRequired = __webpack_require__(203);
13626
13627 var getInternalState = InternalStateModule.get;
13628 var setInternalState = InternalStateModule.set;
13629 var nativeDefineProperty = definePropertyModule.f;
13630 var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
13631 var round = Math.round;
13632 var RangeError = global.RangeError;
13633 var ArrayBuffer = ArrayBufferModule.ArrayBuffer;
13634 var ArrayBufferPrototype = ArrayBuffer.prototype;
13635 var DataView = ArrayBufferModule.DataView;
13636 var NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS;
13637 var TYPED_ARRAY_CONSTRUCTOR = ArrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR;
13638 var TYPED_ARRAY_TAG = ArrayBufferViewCore.TYPED_ARRAY_TAG;
13639 var TypedArray = ArrayBufferViewCore.TypedArray;
13640 var TypedArrayPrototype = ArrayBufferViewCore.TypedArrayPrototype;
13641 var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
13642 var isTypedArray = ArrayBufferViewCore.isTypedArray;
13643 var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT';
13644 var WRONG_LENGTH = 'Wrong length';
13645
13646 var fromList = function (C, list) {
13647 aTypedArrayConstructor(C);
13648 var index = 0;
13649 var length = list.length;
13650 var result = new C(length);
13651
13652 while (length > index) result[index] = list[index++];
13653
13654 return result;
13655 };
13656
13657 var addGetter = function (it, key) {
13658 nativeDefineProperty(it, key, {
13659 get: function () {
13660 return getInternalState(this)[key];
13661 }
13662 });
13663 };
13664
13665 var isArrayBuffer = function (it) {
13666 var klass;
13667 return isPrototypeOf(ArrayBufferPrototype, it) || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer';
13668 };
13669
13670 var isTypedArrayIndex = function (target, key) {
13671 return isTypedArray(target) && !isSymbol(key) && key in target && isIntegralNumber(+key) && key >= 0;
13672 };
13673
13674 var wrappedGetOwnPropertyDescriptor = function getOwnPropertyDescriptor(target, key) {
13675 key = toPropertyKey(key);
13676 return isTypedArrayIndex(target, key) ? createPropertyDescriptor(2, target[key]) : nativeGetOwnPropertyDescriptor(target, key);
13677 };
13678
13679 var wrappedDefineProperty = function defineProperty(target, key, descriptor) {
13680 key = toPropertyKey(key);
13681
13682 if (isTypedArrayIndex(target, key) && isObject(descriptor) && hasOwn(descriptor, 'value') && !hasOwn(descriptor, 'get') && !hasOwn(descriptor, 'set') // TODO: add validation descriptor w/o calling accessors
13683 && !descriptor.configurable && (!hasOwn(descriptor, 'writable') || descriptor.writable) && (!hasOwn(descriptor, 'enumerable') || descriptor.enumerable)) {
13684 target[key] = descriptor.value;
13685 return target;
13686 }
13687
13688 return nativeDefineProperty(target, key, descriptor);
13689 };
13690
13691 if (DESCRIPTORS) {
13692 if (!NATIVE_ARRAY_BUFFER_VIEWS) {
13693 getOwnPropertyDescriptorModule.f = wrappedGetOwnPropertyDescriptor;
13694 definePropertyModule.f = wrappedDefineProperty;
13695 addGetter(TypedArrayPrototype, 'buffer');
13696 addGetter(TypedArrayPrototype, 'byteOffset');
13697 addGetter(TypedArrayPrototype, 'byteLength');
13698 addGetter(TypedArrayPrototype, 'length');
13699 }
13700
13701 $({
13702 target: 'Object',
13703 stat: true,
13704 forced: !NATIVE_ARRAY_BUFFER_VIEWS
13705 }, {
13706 getOwnPropertyDescriptor: wrappedGetOwnPropertyDescriptor,
13707 defineProperty: wrappedDefineProperty
13708 });
13709
13710 module.exports = function (TYPE, wrapper, CLAMPED) {
13711 var BYTES = TYPE.match(/\d+$/)[0] / 8;
13712 var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array';
13713 var GETTER = 'get' + TYPE;
13714 var SETTER = 'set' + TYPE;
13715 var NativeTypedArrayConstructor = global[CONSTRUCTOR_NAME];
13716 var TypedArrayConstructor = NativeTypedArrayConstructor;
13717 var TypedArrayConstructorPrototype = TypedArrayConstructor && TypedArrayConstructor.prototype;
13718 var exported = {};
13719
13720 var getter = function (that, index) {
13721 var data = getInternalState(that);
13722 return data.view[GETTER](index * BYTES + data.byteOffset, true);
13723 };
13724
13725 var setter = function (that, index, value) {
13726 var data = getInternalState(that);
13727 if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF;
13728 data.view[SETTER](index * BYTES + data.byteOffset, value, true);
13729 };
13730
13731 var addElement = function (that, index) {
13732 nativeDefineProperty(that, index, {
13733 get: function () {
13734 return getter(this, index);
13735 },
13736 set: function (value) {
13737 return setter(this, index, value);
13738 },
13739 enumerable: true
13740 });
13741 };
13742
13743 if (!NATIVE_ARRAY_BUFFER_VIEWS) {
13744 TypedArrayConstructor = wrapper(function (that, data, offset, $length) {
13745 anInstance(that, TypedArrayConstructorPrototype);
13746 var index = 0;
13747 var byteOffset = 0;
13748 var buffer, byteLength, length;
13749
13750 if (!isObject(data)) {
13751 length = toIndex(data);
13752 byteLength = length * BYTES;
13753 buffer = new ArrayBuffer(byteLength);
13754 } else if (isArrayBuffer(data)) {
13755 buffer = data;
13756 byteOffset = toOffset(offset, BYTES);
13757 var $len = data.byteLength;
13758
13759 if ($length === undefined) {
13760 if ($len % BYTES) throw RangeError(WRONG_LENGTH);
13761 byteLength = $len - byteOffset;
13762 if (byteLength < 0) throw RangeError(WRONG_LENGTH);
13763 } else {
13764 byteLength = toLength($length) * BYTES;
13765 if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH);
13766 }
13767
13768 length = byteLength / BYTES;
13769 } else if (isTypedArray(data)) {
13770 return fromList(TypedArrayConstructor, data);
13771 } else {
13772 return call(typedArrayFrom, TypedArrayConstructor, data);
13773 }
13774
13775 setInternalState(that, {
13776 buffer: buffer,
13777 byteOffset: byteOffset,
13778 byteLength: byteLength,
13779 length: length,
13780 view: new DataView(buffer)
13781 });
13782
13783 while (index < length) addElement(that, index++);
13784 });
13785 if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray);
13786 TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = create(TypedArrayPrototype);
13787 } else if (TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS) {
13788 TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) {
13789 anInstance(dummy, TypedArrayConstructorPrototype);
13790 return inheritIfRequired(function () {
13791 if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data));
13792 if (isArrayBuffer(data)) return $length !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length) : typedArrayOffset !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) : new NativeTypedArrayConstructor(data);
13793 if (isTypedArray(data)) return fromList(TypedArrayConstructor, data);
13794 return call(typedArrayFrom, TypedArrayConstructor, data);
13795 }(), dummy, TypedArrayConstructor);
13796 });
13797 if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray);
13798 forEach(getOwnPropertyNames(NativeTypedArrayConstructor), function (key) {
13799 if (!(key in TypedArrayConstructor)) {
13800 createNonEnumerableProperty(TypedArrayConstructor, key, NativeTypedArrayConstructor[key]);
13801 }
13802 });
13803 TypedArrayConstructor.prototype = TypedArrayConstructorPrototype;
13804 }
13805
13806 if (TypedArrayConstructorPrototype.constructor !== TypedArrayConstructor) {
13807 createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor);
13808 }
13809
13810 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_CONSTRUCTOR, TypedArrayConstructor);
13811
13812 if (TYPED_ARRAY_TAG) {
13813 createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME);
13814 }
13815
13816 exported[CONSTRUCTOR_NAME] = TypedArrayConstructor;
13817 $({
13818 global: true,
13819 forced: TypedArrayConstructor != NativeTypedArrayConstructor,
13820 sham: !NATIVE_ARRAY_BUFFER_VIEWS
13821 }, exported);
13822
13823 if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) {
13824 createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES);
13825 }
13826
13827 if (!(BYTES_PER_ELEMENT in TypedArrayConstructorPrototype)) {
13828 createNonEnumerableProperty(TypedArrayConstructorPrototype, BYTES_PER_ELEMENT, BYTES);
13829 }
13830
13831 setSpecies(CONSTRUCTOR_NAME);
13832 };
13833 } else module.exports = function () {
13834 /* empty */
13835 };
13836
13837 /***/ }),
13838 /* 370 */
13839 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
13840
13841 /* eslint-disable no-new -- required for testing */
13842 var global = __webpack_require__(3);
13843
13844 var fails = __webpack_require__(6);
13845
13846 var checkCorrectnessOfIteration = __webpack_require__(134);
13847
13848 var NATIVE_ARRAY_BUFFER_VIEWS = (__webpack_require__(172).NATIVE_ARRAY_BUFFER_VIEWS);
13849
13850 var ArrayBuffer = global.ArrayBuffer;
13851 var Int8Array = global.Int8Array;
13852 module.exports = !NATIVE_ARRAY_BUFFER_VIEWS || !fails(function () {
13853 Int8Array(1);
13854 }) || !fails(function () {
13855 new Int8Array(-1);
13856 }) || !checkCorrectnessOfIteration(function (iterable) {
13857 new Int8Array();
13858 new Int8Array(null);
13859 new Int8Array(1.5);
13860 new Int8Array(iterable);
13861 }, true) || fails(function () {
13862 // Safari (11+) bug - a reason why even Safari 13 should load a typed array polyfill
13863 return new Int8Array(new ArrayBuffer(2), 1, undefined).length !== 1;
13864 });
13865
13866 /***/ }),
13867 /* 371 */
13868 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
13869
13870 var global = __webpack_require__(3);
13871
13872 var toPositiveInteger = __webpack_require__(372);
13873
13874 var RangeError = global.RangeError;
13875
13876 module.exports = function (it, BYTES) {
13877 var offset = toPositiveInteger(it);
13878 if (offset % BYTES) throw RangeError('Wrong offset');
13879 return offset;
13880 };
13881
13882 /***/ }),
13883 /* 372 */
13884 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
13885
13886 var global = __webpack_require__(3);
13887
13888 var toIntegerOrInfinity = __webpack_require__(56);
13889
13890 var RangeError = global.RangeError;
13891
13892 module.exports = function (it) {
13893 var result = toIntegerOrInfinity(it);
13894 if (result < 0) throw RangeError("The argument can't be less than 0");
13895 return result;
13896 };
13897
13898 /***/ }),
13899 /* 373 */
13900 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
13901
13902 var bind = __webpack_require__(80);
13903
13904 var call = __webpack_require__(7);
13905
13906 var aConstructor = __webpack_require__(175);
13907
13908 var toObject = __webpack_require__(36);
13909
13910 var lengthOfArrayLike = __webpack_require__(57);
13911
13912 var getIterator = __webpack_require__(108);
13913
13914 var getIteratorMethod = __webpack_require__(109);
13915
13916 var isArrayIteratorMethod = __webpack_require__(106);
13917
13918 var aTypedArrayConstructor = (__webpack_require__(172).aTypedArrayConstructor);
13919
13920 module.exports = function from(source
13921 /* , mapfn, thisArg */
13922 ) {
13923 var C = aConstructor(this);
13924 var O = toObject(source);
13925 var argumentsLength = arguments.length;
13926 var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
13927 var mapping = mapfn !== undefined;
13928 var iteratorMethod = getIteratorMethod(O);
13929 var i, length, result, step, iterator, next;
13930
13931 if (iteratorMethod && !isArrayIteratorMethod(iteratorMethod)) {
13932 iterator = getIterator(O, iteratorMethod);
13933 next = iterator.next;
13934 O = [];
13935
13936 while (!(step = call(next, iterator)).done) {
13937 O.push(step.value);
13938 }
13939 }
13940
13941 if (mapping && argumentsLength > 2) {
13942 mapfn = bind(mapfn, arguments[2]);
13943 }
13944
13945 length = lengthOfArrayLike(O);
13946 result = new (aTypedArrayConstructor(C))(length);
13947
13948 for (i = 0; length > i; i++) {
13949 result[i] = mapping ? mapfn(O[i], i) : O[i];
13950 }
13951
13952 return result;
13953 };
13954
13955 /***/ }),
13956 /* 374 */
13957 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13958
13959 var createTypedArrayConstructor = __webpack_require__(369); // `Float64Array` constructor
13960 // https://tc39.es/ecma262/#sec-typedarray-objects
13961
13962
13963 createTypedArrayConstructor('Float64', function (init) {
13964 return function Float64Array(data, byteOffset, length) {
13965 return init(this, data, byteOffset, length);
13966 };
13967 });
13968
13969 /***/ }),
13970 /* 375 */
13971 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13972
13973 var createTypedArrayConstructor = __webpack_require__(369); // `Int8Array` constructor
13974 // https://tc39.es/ecma262/#sec-typedarray-objects
13975
13976
13977 createTypedArrayConstructor('Int8', function (init) {
13978 return function Int8Array(data, byteOffset, length) {
13979 return init(this, data, byteOffset, length);
13980 };
13981 });
13982
13983 /***/ }),
13984 /* 376 */
13985 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
13986
13987 var createTypedArrayConstructor = __webpack_require__(369); // `Int16Array` constructor
13988 // https://tc39.es/ecma262/#sec-typedarray-objects
13989
13990
13991 createTypedArrayConstructor('Int16', function (init) {
13992 return function Int16Array(data, byteOffset, length) {
13993 return init(this, data, byteOffset, length);
13994 };
13995 });
13996
13997 /***/ }),
13998 /* 377 */
13999 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14000
14001 var createTypedArrayConstructor = __webpack_require__(369); // `Int32Array` constructor
14002 // https://tc39.es/ecma262/#sec-typedarray-objects
14003
14004
14005 createTypedArrayConstructor('Int32', function (init) {
14006 return function Int32Array(data, byteOffset, length) {
14007 return init(this, data, byteOffset, length);
14008 };
14009 });
14010
14011 /***/ }),
14012 /* 378 */
14013 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14014
14015 var createTypedArrayConstructor = __webpack_require__(369); // `Uint8Array` constructor
14016 // https://tc39.es/ecma262/#sec-typedarray-objects
14017
14018
14019 createTypedArrayConstructor('Uint8', function (init) {
14020 return function Uint8Array(data, byteOffset, length) {
14021 return init(this, data, byteOffset, length);
14022 };
14023 });
14024
14025 /***/ }),
14026 /* 379 */
14027 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14028
14029 var createTypedArrayConstructor = __webpack_require__(369); // `Uint8ClampedArray` constructor
14030 // https://tc39.es/ecma262/#sec-typedarray-objects
14031
14032
14033 createTypedArrayConstructor('Uint8', function (init) {
14034 return function Uint8ClampedArray(data, byteOffset, length) {
14035 return init(this, data, byteOffset, length);
14036 };
14037 }, true);
14038
14039 /***/ }),
14040 /* 380 */
14041 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14042
14043 var createTypedArrayConstructor = __webpack_require__(369); // `Uint16Array` constructor
14044 // https://tc39.es/ecma262/#sec-typedarray-objects
14045
14046
14047 createTypedArrayConstructor('Uint16', function (init) {
14048 return function Uint16Array(data, byteOffset, length) {
14049 return init(this, data, byteOffset, length);
14050 };
14051 });
14052
14053 /***/ }),
14054 /* 381 */
14055 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14056
14057 var createTypedArrayConstructor = __webpack_require__(369); // `Uint32Array` constructor
14058 // https://tc39.es/ecma262/#sec-typedarray-objects
14059
14060
14061 createTypedArrayConstructor('Uint32', function (init) {
14062 return function Uint32Array(data, byteOffset, length) {
14063 return init(this, data, byteOffset, length);
14064 };
14065 });
14066
14067 /***/ }),
14068 /* 382 */
14069 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14070
14071 "use strict";
14072
14073
14074 var ArrayBufferViewCore = __webpack_require__(172);
14075
14076 var lengthOfArrayLike = __webpack_require__(57);
14077
14078 var toIntegerOrInfinity = __webpack_require__(56);
14079
14080 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14081 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.at` method
14082 // https://github.com/tc39/proposal-relative-indexing-method
14083
14084 exportTypedArrayMethod('at', function at(index) {
14085 var O = aTypedArray(this);
14086 var len = lengthOfArrayLike(O);
14087 var relativeIndex = toIntegerOrInfinity(index);
14088 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex;
14089 return k < 0 || k >= len ? undefined : O[k];
14090 });
14091
14092 /***/ }),
14093 /* 383 */
14094 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14095
14096 "use strict";
14097
14098
14099 var uncurryThis = __webpack_require__(12);
14100
14101 var ArrayBufferViewCore = __webpack_require__(172);
14102
14103 var $ArrayCopyWithin = __webpack_require__(118);
14104
14105 var u$ArrayCopyWithin = uncurryThis($ArrayCopyWithin);
14106 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14107 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.copyWithin` method
14108 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.copywithin
14109
14110 exportTypedArrayMethod('copyWithin', function copyWithin(target, start
14111 /* , end */
14112 ) {
14113 return u$ArrayCopyWithin(aTypedArray(this), target, start, arguments.length > 2 ? arguments[2] : undefined);
14114 });
14115
14116 /***/ }),
14117 /* 384 */
14118 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14119
14120 "use strict";
14121
14122
14123 var ArrayBufferViewCore = __webpack_require__(172);
14124
14125 var $every = (__webpack_require__(79).every);
14126
14127 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14128 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.every` method
14129 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.every
14130
14131 exportTypedArrayMethod('every', function every(callbackfn
14132 /* , thisArg */
14133 ) {
14134 return $every(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
14135 });
14136
14137 /***/ }),
14138 /* 385 */
14139 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14140
14141 "use strict";
14142
14143
14144 var ArrayBufferViewCore = __webpack_require__(172);
14145
14146 var call = __webpack_require__(7);
14147
14148 var $fill = __webpack_require__(122);
14149
14150 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14151 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.fill` method
14152 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.fill
14153
14154 exportTypedArrayMethod('fill', function fill(value
14155 /* , start, end */
14156 ) {
14157 var length = arguments.length;
14158 return call($fill, aTypedArray(this), value, length > 1 ? arguments[1] : undefined, length > 2 ? arguments[2] : undefined);
14159 });
14160
14161 /***/ }),
14162 /* 386 */
14163 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14164
14165 "use strict";
14166
14167
14168 var ArrayBufferViewCore = __webpack_require__(172);
14169
14170 var $filter = (__webpack_require__(79).filter);
14171
14172 var fromSpeciesAndList = __webpack_require__(387);
14173
14174 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14175 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.filter` method
14176 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.filter
14177
14178 exportTypedArrayMethod('filter', function filter(callbackfn
14179 /* , thisArg */
14180 ) {
14181 var list = $filter(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
14182 return fromSpeciesAndList(this, list);
14183 });
14184
14185 /***/ }),
14186 /* 387 */
14187 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
14188
14189 var arrayFromConstructorAndList = __webpack_require__(388);
14190
14191 var typedArraySpeciesConstructor = __webpack_require__(389);
14192
14193 module.exports = function (instance, list) {
14194 return arrayFromConstructorAndList(typedArraySpeciesConstructor(instance), list);
14195 };
14196
14197 /***/ }),
14198 /* 388 */
14199 /***/ ((module) => {
14200
14201 module.exports = function (Constructor, list) {
14202 var index = 0;
14203 var length = list.length;
14204 var result = new Constructor(length);
14205
14206 while (length > index) result[index] = list[index++];
14207
14208 return result;
14209 };
14210
14211 /***/ }),
14212 /* 389 */
14213 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
14214
14215 var ArrayBufferViewCore = __webpack_require__(172);
14216
14217 var speciesConstructor = __webpack_require__(174);
14218
14219 var TYPED_ARRAY_CONSTRUCTOR = ArrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR;
14220 var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor; // a part of `TypedArraySpeciesCreate` abstract operation
14221 // https://tc39.es/ecma262/#typedarray-species-create
14222
14223 module.exports = function (originalArray) {
14224 return aTypedArrayConstructor(speciesConstructor(originalArray, originalArray[TYPED_ARRAY_CONSTRUCTOR]));
14225 };
14226
14227 /***/ }),
14228 /* 390 */
14229 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14230
14231 "use strict";
14232
14233
14234 var ArrayBufferViewCore = __webpack_require__(172);
14235
14236 var $find = (__webpack_require__(79).find);
14237
14238 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14239 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.find` method
14240 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.find
14241
14242 exportTypedArrayMethod('find', function find(predicate
14243 /* , thisArg */
14244 ) {
14245 return $find(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
14246 });
14247
14248 /***/ }),
14249 /* 391 */
14250 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14251
14252 "use strict";
14253
14254
14255 var ArrayBufferViewCore = __webpack_require__(172);
14256
14257 var $findIndex = (__webpack_require__(79).findIndex);
14258
14259 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14260 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.findIndex` method
14261 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.findindex
14262
14263 exportTypedArrayMethod('findIndex', function findIndex(predicate
14264 /* , thisArg */
14265 ) {
14266 return $findIndex(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
14267 });
14268
14269 /***/ }),
14270 /* 392 */
14271 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14272
14273 "use strict";
14274
14275
14276 var ArrayBufferViewCore = __webpack_require__(172);
14277
14278 var $forEach = (__webpack_require__(79).forEach);
14279
14280 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14281 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.forEach` method
14282 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.foreach
14283
14284 exportTypedArrayMethod('forEach', function forEach(callbackfn
14285 /* , thisArg */
14286 ) {
14287 $forEach(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
14288 });
14289
14290 /***/ }),
14291 /* 393 */
14292 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14293
14294 "use strict";
14295
14296
14297 var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = __webpack_require__(370);
14298
14299 var exportTypedArrayStaticMethod = (__webpack_require__(172).exportTypedArrayStaticMethod);
14300
14301 var typedArrayFrom = __webpack_require__(373); // `%TypedArray%.from` method
14302 // https://tc39.es/ecma262/#sec-%typedarray%.from
14303
14304
14305 exportTypedArrayStaticMethod('from', typedArrayFrom, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS);
14306
14307 /***/ }),
14308 /* 394 */
14309 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14310
14311 "use strict";
14312
14313
14314 var ArrayBufferViewCore = __webpack_require__(172);
14315
14316 var $includes = (__webpack_require__(54).includes);
14317
14318 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14319 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.includes` method
14320 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.includes
14321
14322 exportTypedArrayMethod('includes', function includes(searchElement
14323 /* , fromIndex */
14324 ) {
14325 return $includes(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
14326 });
14327
14328 /***/ }),
14329 /* 395 */
14330 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14331
14332 "use strict";
14333
14334
14335 var ArrayBufferViewCore = __webpack_require__(172);
14336
14337 var $indexOf = (__webpack_require__(54).indexOf);
14338
14339 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14340 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.indexOf` method
14341 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.indexof
14342
14343 exportTypedArrayMethod('indexOf', function indexOf(searchElement
14344 /* , fromIndex */
14345 ) {
14346 return $indexOf(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
14347 });
14348
14349 /***/ }),
14350 /* 396 */
14351 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14352
14353 "use strict";
14354
14355
14356 var global = __webpack_require__(3);
14357
14358 var uncurryThis = __webpack_require__(12);
14359
14360 var PROPER_FUNCTION_NAME = (__webpack_require__(49).PROPER);
14361
14362 var ArrayBufferViewCore = __webpack_require__(172);
14363
14364 var ArrayIterators = __webpack_require__(138);
14365
14366 var wellKnownSymbol = __webpack_require__(30);
14367
14368 var ITERATOR = wellKnownSymbol('iterator');
14369 var Uint8Array = global.Uint8Array;
14370 var arrayValues = uncurryThis(ArrayIterators.values);
14371 var arrayKeys = uncurryThis(ArrayIterators.keys);
14372 var arrayEntries = uncurryThis(ArrayIterators.entries);
14373 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14374 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
14375 var nativeTypedArrayIterator = Uint8Array && Uint8Array.prototype[ITERATOR];
14376 var PROPER_ARRAY_VALUES_NAME = !!nativeTypedArrayIterator && nativeTypedArrayIterator.name === 'values';
14377
14378 var typedArrayValues = function values() {
14379 return arrayValues(aTypedArray(this));
14380 }; // `%TypedArray%.prototype.entries` method
14381 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.entries
14382
14383
14384 exportTypedArrayMethod('entries', function entries() {
14385 return arrayEntries(aTypedArray(this));
14386 }); // `%TypedArray%.prototype.keys` method
14387 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.keys
14388
14389 exportTypedArrayMethod('keys', function keys() {
14390 return arrayKeys(aTypedArray(this));
14391 }); // `%TypedArray%.prototype.values` method
14392 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.values
14393
14394 exportTypedArrayMethod('values', typedArrayValues, PROPER_FUNCTION_NAME && !PROPER_ARRAY_VALUES_NAME); // `%TypedArray%.prototype[@@iterator]` method
14395 // https://tc39.es/ecma262/#sec-%typedarray%.prototype-@@iterator
14396
14397 exportTypedArrayMethod(ITERATOR, typedArrayValues, PROPER_FUNCTION_NAME && !PROPER_ARRAY_VALUES_NAME);
14398
14399 /***/ }),
14400 /* 397 */
14401 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14402
14403 "use strict";
14404
14405
14406 var ArrayBufferViewCore = __webpack_require__(172);
14407
14408 var uncurryThis = __webpack_require__(12);
14409
14410 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14411 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
14412 var $join = uncurryThis([].join); // `%TypedArray%.prototype.join` method
14413 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.join
14414
14415 exportTypedArrayMethod('join', function join(separator) {
14416 return $join(aTypedArray(this), separator);
14417 });
14418
14419 /***/ }),
14420 /* 398 */
14421 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14422
14423 "use strict";
14424
14425
14426 var ArrayBufferViewCore = __webpack_require__(172);
14427
14428 var apply = __webpack_require__(62);
14429
14430 var $lastIndexOf = __webpack_require__(144);
14431
14432 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14433 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.lastIndexOf` method
14434 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.lastindexof
14435
14436 exportTypedArrayMethod('lastIndexOf', function lastIndexOf(searchElement
14437 /* , fromIndex */
14438 ) {
14439 var length = arguments.length;
14440 return apply($lastIndexOf, aTypedArray(this), length > 1 ? [searchElement, arguments[1]] : [searchElement]);
14441 });
14442
14443 /***/ }),
14444 /* 399 */
14445 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14446
14447 "use strict";
14448
14449
14450 var ArrayBufferViewCore = __webpack_require__(172);
14451
14452 var $map = (__webpack_require__(79).map);
14453
14454 var typedArraySpeciesConstructor = __webpack_require__(389);
14455
14456 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14457 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.map` method
14458 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.map
14459
14460 exportTypedArrayMethod('map', function map(mapfn
14461 /* , thisArg */
14462 ) {
14463 return $map(aTypedArray(this), mapfn, arguments.length > 1 ? arguments[1] : undefined, function (O, length) {
14464 return new (typedArraySpeciesConstructor(O))(length);
14465 });
14466 });
14467
14468 /***/ }),
14469 /* 400 */
14470 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14471
14472 "use strict";
14473
14474
14475 var ArrayBufferViewCore = __webpack_require__(172);
14476
14477 var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = __webpack_require__(370);
14478
14479 var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
14480 var exportTypedArrayStaticMethod = ArrayBufferViewCore.exportTypedArrayStaticMethod; // `%TypedArray%.of` method
14481 // https://tc39.es/ecma262/#sec-%typedarray%.of
14482
14483 exportTypedArrayStaticMethod('of', function
14484 /* ...items */
14485 of() {
14486 var index = 0;
14487 var length = arguments.length;
14488 var result = new (aTypedArrayConstructor(this))(length);
14489
14490 while (length > index) result[index] = arguments[index++];
14491
14492 return result;
14493 }, TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS);
14494
14495 /***/ }),
14496 /* 401 */
14497 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14498
14499 "use strict";
14500
14501
14502 var ArrayBufferViewCore = __webpack_require__(172);
14503
14504 var $reduce = (__webpack_require__(148).left);
14505
14506 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14507 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.reduce` method
14508 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduce
14509
14510 exportTypedArrayMethod('reduce', function reduce(callbackfn
14511 /* , initialValue */
14512 ) {
14513 var length = arguments.length;
14514 return $reduce(aTypedArray(this), callbackfn, length, length > 1 ? arguments[1] : undefined);
14515 });
14516
14517 /***/ }),
14518 /* 402 */
14519 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14520
14521 "use strict";
14522
14523
14524 var ArrayBufferViewCore = __webpack_require__(172);
14525
14526 var $reduceRight = (__webpack_require__(148).right);
14527
14528 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14529 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.reduceRicht` method
14530 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduceright
14531
14532 exportTypedArrayMethod('reduceRight', function reduceRight(callbackfn
14533 /* , initialValue */
14534 ) {
14535 var length = arguments.length;
14536 return $reduceRight(aTypedArray(this), callbackfn, length, length > 1 ? arguments[1] : undefined);
14537 });
14538
14539 /***/ }),
14540 /* 403 */
14541 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14542
14543 "use strict";
14544
14545
14546 var ArrayBufferViewCore = __webpack_require__(172);
14547
14548 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14549 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
14550 var floor = Math.floor; // `%TypedArray%.prototype.reverse` method
14551 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reverse
14552
14553 exportTypedArrayMethod('reverse', function reverse() {
14554 var that = this;
14555 var length = aTypedArray(that).length;
14556 var middle = floor(length / 2);
14557 var index = 0;
14558 var value;
14559
14560 while (index < middle) {
14561 value = that[index];
14562 that[index++] = that[--length];
14563 that[length] = value;
14564 }
14565
14566 return that;
14567 });
14568
14569 /***/ }),
14570 /* 404 */
14571 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14572
14573 "use strict";
14574
14575
14576 var global = __webpack_require__(3);
14577
14578 var ArrayBufferViewCore = __webpack_require__(172);
14579
14580 var lengthOfArrayLike = __webpack_require__(57);
14581
14582 var toOffset = __webpack_require__(371);
14583
14584 var toObject = __webpack_require__(36);
14585
14586 var fails = __webpack_require__(6);
14587
14588 var RangeError = global.RangeError;
14589 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14590 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
14591 var FORCED = fails(function () {
14592 // eslint-disable-next-line es/no-typed-arrays -- required for testing
14593 new Int8Array(1).set({});
14594 }); // `%TypedArray%.prototype.set` method
14595 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.set
14596
14597 exportTypedArrayMethod('set', function set(arrayLike
14598 /* , offset */
14599 ) {
14600 aTypedArray(this);
14601 var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1);
14602 var length = this.length;
14603 var src = toObject(arrayLike);
14604 var len = lengthOfArrayLike(src);
14605 var index = 0;
14606 if (len + offset > length) throw RangeError('Wrong length');
14607
14608 while (index < len) this[offset + index] = src[index++];
14609 }, FORCED);
14610
14611 /***/ }),
14612 /* 405 */
14613 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14614
14615 "use strict";
14616
14617
14618 var ArrayBufferViewCore = __webpack_require__(172);
14619
14620 var typedArraySpeciesConstructor = __webpack_require__(389);
14621
14622 var fails = __webpack_require__(6);
14623
14624 var arraySlice = __webpack_require__(74);
14625
14626 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14627 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
14628 var FORCED = fails(function () {
14629 // eslint-disable-next-line es/no-typed-arrays -- required for testing
14630 new Int8Array(1).slice();
14631 }); // `%TypedArray%.prototype.slice` method
14632 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice
14633
14634 exportTypedArrayMethod('slice', function slice(start, end) {
14635 var list = arraySlice(aTypedArray(this), start, end);
14636 var C = typedArraySpeciesConstructor(this);
14637 var index = 0;
14638 var length = list.length;
14639 var result = new C(length);
14640
14641 while (length > index) result[index] = list[index++];
14642
14643 return result;
14644 }, FORCED);
14645
14646 /***/ }),
14647 /* 406 */
14648 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14649
14650 "use strict";
14651
14652
14653 var ArrayBufferViewCore = __webpack_require__(172);
14654
14655 var $some = (__webpack_require__(79).some);
14656
14657 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14658 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.some` method
14659 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.some
14660
14661 exportTypedArrayMethod('some', function some(callbackfn
14662 /* , thisArg */
14663 ) {
14664 return $some(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
14665 });
14666
14667 /***/ }),
14668 /* 407 */
14669 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14670
14671 "use strict";
14672
14673
14674 var global = __webpack_require__(3);
14675
14676 var uncurryThis = __webpack_require__(12);
14677
14678 var fails = __webpack_require__(6);
14679
14680 var aCallable = __webpack_require__(27);
14681
14682 var internalSort = __webpack_require__(155);
14683
14684 var ArrayBufferViewCore = __webpack_require__(172);
14685
14686 var FF = __webpack_require__(156);
14687
14688 var IE_OR_EDGE = __webpack_require__(157);
14689
14690 var V8 = __webpack_require__(24);
14691
14692 var WEBKIT = __webpack_require__(158);
14693
14694 var Array = global.Array;
14695 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14696 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
14697 var Uint16Array = global.Uint16Array;
14698 var un$Sort = Uint16Array && uncurryThis(Uint16Array.prototype.sort); // WebKit
14699
14700 var ACCEPT_INCORRECT_ARGUMENTS = !!un$Sort && !(fails(function () {
14701 un$Sort(new Uint16Array(2), null);
14702 }) && fails(function () {
14703 un$Sort(new Uint16Array(2), {});
14704 }));
14705 var STABLE_SORT = !!un$Sort && !fails(function () {
14706 // feature detection can be too slow, so check engines versions
14707 if (V8) return V8 < 74;
14708 if (FF) return FF < 67;
14709 if (IE_OR_EDGE) return true;
14710 if (WEBKIT) return WEBKIT < 602;
14711 var array = new Uint16Array(516);
14712 var expected = Array(516);
14713 var index, mod;
14714
14715 for (index = 0; index < 516; index++) {
14716 mod = index % 4;
14717 array[index] = 515 - index;
14718 expected[index] = index - 2 * mod + 3;
14719 }
14720
14721 un$Sort(array, function (a, b) {
14722 return (a / 4 | 0) - (b / 4 | 0);
14723 });
14724
14725 for (index = 0; index < 516; index++) {
14726 if (array[index] !== expected[index]) return true;
14727 }
14728 });
14729
14730 var getSortCompare = function (comparefn) {
14731 return function (x, y) {
14732 if (comparefn !== undefined) return +comparefn(x, y) || 0; // eslint-disable-next-line no-self-compare -- NaN check
14733
14734 if (y !== y) return -1; // eslint-disable-next-line no-self-compare -- NaN check
14735
14736 if (x !== x) return 1;
14737 if (x === 0 && y === 0) return 1 / x > 0 && 1 / y < 0 ? 1 : -1;
14738 return x > y;
14739 };
14740 }; // `%TypedArray%.prototype.sort` method
14741 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort
14742
14743
14744 exportTypedArrayMethod('sort', function sort(comparefn) {
14745 if (comparefn !== undefined) aCallable(comparefn);
14746 if (STABLE_SORT) return un$Sort(this, comparefn);
14747 return internalSort(aTypedArray(this), getSortCompare(comparefn));
14748 }, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS);
14749
14750 /***/ }),
14751 /* 408 */
14752 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14753
14754 "use strict";
14755
14756
14757 var ArrayBufferViewCore = __webpack_require__(172);
14758
14759 var toLength = __webpack_require__(58);
14760
14761 var toAbsoluteIndex = __webpack_require__(55);
14762
14763 var typedArraySpeciesConstructor = __webpack_require__(389);
14764
14765 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14766 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.subarray` method
14767 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.subarray
14768
14769 exportTypedArrayMethod('subarray', function subarray(begin, end) {
14770 var O = aTypedArray(this);
14771 var length = O.length;
14772 var beginIndex = toAbsoluteIndex(begin, length);
14773 var C = typedArraySpeciesConstructor(O);
14774 return new C(O.buffer, O.byteOffset + beginIndex * O.BYTES_PER_ELEMENT, toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - beginIndex));
14775 });
14776
14777 /***/ }),
14778 /* 409 */
14779 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14780
14781 "use strict";
14782
14783
14784 var global = __webpack_require__(3);
14785
14786 var apply = __webpack_require__(62);
14787
14788 var ArrayBufferViewCore = __webpack_require__(172);
14789
14790 var fails = __webpack_require__(6);
14791
14792 var arraySlice = __webpack_require__(74);
14793
14794 var Int8Array = global.Int8Array;
14795 var aTypedArray = ArrayBufferViewCore.aTypedArray;
14796 var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
14797 var $toLocaleString = [].toLocaleString; // iOS Safari 6.x fails here
14798
14799 var TO_LOCALE_STRING_BUG = !!Int8Array && fails(function () {
14800 $toLocaleString.call(new Int8Array(1));
14801 });
14802 var FORCED = fails(function () {
14803 return [1, 2].toLocaleString() != new Int8Array([1, 2]).toLocaleString();
14804 }) || !fails(function () {
14805 Int8Array.prototype.toLocaleString.call([1, 2]);
14806 }); // `%TypedArray%.prototype.toLocaleString` method
14807 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.tolocalestring
14808
14809 exportTypedArrayMethod('toLocaleString', function toLocaleString() {
14810 return apply($toLocaleString, TO_LOCALE_STRING_BUG ? arraySlice(aTypedArray(this)) : aTypedArray(this), arraySlice(arguments));
14811 }, FORCED);
14812
14813 /***/ }),
14814 /* 410 */
14815 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14816
14817 "use strict";
14818
14819
14820 var exportTypedArrayMethod = (__webpack_require__(172).exportTypedArrayMethod);
14821
14822 var fails = __webpack_require__(6);
14823
14824 var global = __webpack_require__(3);
14825
14826 var uncurryThis = __webpack_require__(12);
14827
14828 var Uint8Array = global.Uint8Array;
14829 var Uint8ArrayPrototype = Uint8Array && Uint8Array.prototype || {};
14830 var arrayToString = [].toString;
14831 var join = uncurryThis([].join);
14832
14833 if (fails(function () {
14834 arrayToString.call({});
14835 })) {
14836 arrayToString = function toString() {
14837 return join(this);
14838 };
14839 }
14840
14841 var IS_NOT_ARRAY_METHOD = Uint8ArrayPrototype.toString != arrayToString; // `%TypedArray%.prototype.toString` method
14842 // https://tc39.es/ecma262/#sec-%typedarray%.prototype.tostring
14843
14844 exportTypedArrayMethod('toString', arrayToString, IS_NOT_ARRAY_METHOD);
14845
14846 /***/ }),
14847 /* 411 */
14848 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14849
14850 "use strict";
14851
14852
14853 var $ = __webpack_require__(2);
14854
14855 var uncurryThis = __webpack_require__(12);
14856
14857 var toString = __webpack_require__(64);
14858
14859 var fromCharCode = String.fromCharCode;
14860 var charAt = uncurryThis(''.charAt);
14861 var exec = uncurryThis(/./.exec);
14862 var stringSlice = uncurryThis(''.slice);
14863 var hex2 = /^[\da-f]{2}$/i;
14864 var hex4 = /^[\da-f]{4}$/i; // `unescape` method
14865 // https://tc39.es/ecma262/#sec-unescape-string
14866
14867 $({
14868 global: true
14869 }, {
14870 unescape: function unescape(string) {
14871 var str = toString(string);
14872 var result = '';
14873 var length = str.length;
14874 var index = 0;
14875 var chr, part;
14876
14877 while (index < length) {
14878 chr = charAt(str, index++);
14879
14880 if (chr === '%') {
14881 if (charAt(str, index) === 'u') {
14882 part = stringSlice(str, index + 1, index + 5);
14883
14884 if (exec(hex4, part)) {
14885 result += fromCharCode(parseInt(part, 16));
14886 index += 5;
14887 continue;
14888 }
14889 } else {
14890 part = stringSlice(str, index, index + 2);
14891
14892 if (exec(hex2, part)) {
14893 result += fromCharCode(parseInt(part, 16));
14894 index += 2;
14895 continue;
14896 }
14897 }
14898 }
14899
14900 result += chr;
14901 }
14902
14903 return result;
14904 }
14905 });
14906
14907 /***/ }),
14908 /* 412 */
14909 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
14910
14911 "use strict";
14912
14913
14914 var global = __webpack_require__(3);
14915
14916 var uncurryThis = __webpack_require__(12);
14917
14918 var redefineAll = __webpack_require__(167);
14919
14920 var InternalMetadataModule = __webpack_require__(199);
14921
14922 var collection = __webpack_require__(198);
14923
14924 var collectionWeak = __webpack_require__(413);
14925
14926 var isObject = __webpack_require__(17);
14927
14928 var isExtensible = __webpack_require__(200);
14929
14930 var enforceIternalState = (__webpack_require__(45).enforce);
14931
14932 var NATIVE_WEAK_MAP = __webpack_require__(46);
14933
14934 var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
14935 var InternalWeakMap;
14936
14937 var wrapper = function (init) {
14938 return function WeakMap() {
14939 return init(this, arguments.length ? arguments[0] : undefined);
14940 };
14941 }; // `WeakMap` constructor
14942 // https://tc39.es/ecma262/#sec-weakmap-constructor
14943
14944
14945 var $WeakMap = collection('WeakMap', wrapper, collectionWeak); // IE11 WeakMap frozen keys fix
14946 // We can't use feature detection because it crash some old IE builds
14947 // https://github.com/zloirock/core-js/issues/485
14948
14949 if (NATIVE_WEAK_MAP && IS_IE11) {
14950 InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
14951 InternalMetadataModule.enable();
14952 var WeakMapPrototype = $WeakMap.prototype;
14953 var nativeDelete = uncurryThis(WeakMapPrototype['delete']);
14954 var nativeHas = uncurryThis(WeakMapPrototype.has);
14955 var nativeGet = uncurryThis(WeakMapPrototype.get);
14956 var nativeSet = uncurryThis(WeakMapPrototype.set);
14957 redefineAll(WeakMapPrototype, {
14958 'delete': function (key) {
14959 if (isObject(key) && !isExtensible(key)) {
14960 var state = enforceIternalState(this);
14961 if (!state.frozen) state.frozen = new InternalWeakMap();
14962 return nativeDelete(this, key) || state.frozen['delete'](key);
14963 }
14964
14965 return nativeDelete(this, key);
14966 },
14967 has: function has(key) {
14968 if (isObject(key) && !isExtensible(key)) {
14969 var state = enforceIternalState(this);
14970 if (!state.frozen) state.frozen = new InternalWeakMap();
14971 return nativeHas(this, key) || state.frozen.has(key);
14972 }
14973
14974 return nativeHas(this, key);
14975 },
14976 get: function get(key) {
14977 if (isObject(key) && !isExtensible(key)) {
14978 var state = enforceIternalState(this);
14979 if (!state.frozen) state.frozen = new InternalWeakMap();
14980 return nativeHas(this, key) ? nativeGet(this, key) : state.frozen.get(key);
14981 }
14982
14983 return nativeGet(this, key);
14984 },
14985 set: function set(key, value) {
14986 if (isObject(key) && !isExtensible(key)) {
14987 var state = enforceIternalState(this);
14988 if (!state.frozen) state.frozen = new InternalWeakMap();
14989 nativeHas(this, key) ? nativeSet(this, key, value) : state.frozen.set(key, value);
14990 } else nativeSet(this, key, value);
14991
14992 return this;
14993 }
14994 });
14995 }
14996
14997 /***/ }),
14998 /* 413 */
14999 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
15000
15001 "use strict";
15002
15003
15004 var uncurryThis = __webpack_require__(12);
15005
15006 var redefineAll = __webpack_require__(167);
15007
15008 var getWeakData = (__webpack_require__(199).getWeakData);
15009
15010 var anObject = __webpack_require__(42);
15011
15012 var isObject = __webpack_require__(17);
15013
15014 var anInstance = __webpack_require__(168);
15015
15016 var iterate = __webpack_require__(105);
15017
15018 var ArrayIterationModule = __webpack_require__(79);
15019
15020 var hasOwn = __webpack_require__(35);
15021
15022 var InternalStateModule = __webpack_require__(45);
15023
15024 var setInternalState = InternalStateModule.set;
15025 var internalStateGetterFor = InternalStateModule.getterFor;
15026 var find = ArrayIterationModule.find;
15027 var findIndex = ArrayIterationModule.findIndex;
15028 var splice = uncurryThis([].splice);
15029 var id = 0; // fallback for uncaught frozen keys
15030
15031 var uncaughtFrozenStore = function (store) {
15032 return store.frozen || (store.frozen = new UncaughtFrozenStore());
15033 };
15034
15035 var UncaughtFrozenStore = function () {
15036 this.entries = [];
15037 };
15038
15039 var findUncaughtFrozen = function (store, key) {
15040 return find(store.entries, function (it) {
15041 return it[0] === key;
15042 });
15043 };
15044
15045 UncaughtFrozenStore.prototype = {
15046 get: function (key) {
15047 var entry = findUncaughtFrozen(this, key);
15048 if (entry) return entry[1];
15049 },
15050 has: function (key) {
15051 return !!findUncaughtFrozen(this, key);
15052 },
15053 set: function (key, value) {
15054 var entry = findUncaughtFrozen(this, key);
15055 if (entry) entry[1] = value;else this.entries.push([key, value]);
15056 },
15057 'delete': function (key) {
15058 var index = findIndex(this.entries, function (it) {
15059 return it[0] === key;
15060 });
15061 if (~index) splice(this.entries, index, 1);
15062 return !!~index;
15063 }
15064 };
15065 module.exports = {
15066 getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
15067 var Constructor = wrapper(function (that, iterable) {
15068 anInstance(that, Prototype);
15069 setInternalState(that, {
15070 type: CONSTRUCTOR_NAME,
15071 id: id++,
15072 frozen: undefined
15073 });
15074 if (iterable != undefined) iterate(iterable, that[ADDER], {
15075 that: that,
15076 AS_ENTRIES: IS_MAP
15077 });
15078 });
15079 var Prototype = Constructor.prototype;
15080 var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
15081
15082 var define = function (that, key, value) {
15083 var state = getInternalState(that);
15084 var data = getWeakData(anObject(key), true);
15085 if (data === true) uncaughtFrozenStore(state).set(key, value);else data[state.id] = value;
15086 return that;
15087 };
15088
15089 redefineAll(Prototype, {
15090 // `{ WeakMap, WeakSet }.prototype.delete(key)` methods
15091 // https://tc39.es/ecma262/#sec-weakmap.prototype.delete
15092 // https://tc39.es/ecma262/#sec-weakset.prototype.delete
15093 'delete': function (key) {
15094 var state = getInternalState(this);
15095 if (!isObject(key)) return false;
15096 var data = getWeakData(key);
15097 if (data === true) return uncaughtFrozenStore(state)['delete'](key);
15098 return data && hasOwn(data, state.id) && delete data[state.id];
15099 },
15100 // `{ WeakMap, WeakSet }.prototype.has(key)` methods
15101 // https://tc39.es/ecma262/#sec-weakmap.prototype.has
15102 // https://tc39.es/ecma262/#sec-weakset.prototype.has
15103 has: function has(key) {
15104 var state = getInternalState(this);
15105 if (!isObject(key)) return false;
15106 var data = getWeakData(key);
15107 if (data === true) return uncaughtFrozenStore(state).has(key);
15108 return data && hasOwn(data, state.id);
15109 }
15110 });
15111 redefineAll(Prototype, IS_MAP ? {
15112 // `WeakMap.prototype.get(key)` method
15113 // https://tc39.es/ecma262/#sec-weakmap.prototype.get
15114 get: function get(key) {
15115 var state = getInternalState(this);
15116
15117 if (isObject(key)) {
15118 var data = getWeakData(key);
15119 if (data === true) return uncaughtFrozenStore(state).get(key);
15120 return data ? data[state.id] : undefined;
15121 }
15122 },
15123 // `WeakMap.prototype.set(key, value)` method
15124 // https://tc39.es/ecma262/#sec-weakmap.prototype.set
15125 set: function set(key, value) {
15126 return define(this, key, value);
15127 }
15128 } : {
15129 // `WeakSet.prototype.add(value)` method
15130 // https://tc39.es/ecma262/#sec-weakset.prototype.add
15131 add: function add(value) {
15132 return define(this, value, true);
15133 }
15134 });
15135 return Constructor;
15136 }
15137 };
15138
15139 /***/ }),
15140 /* 414 */
15141 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
15142
15143 "use strict";
15144
15145
15146 var collection = __webpack_require__(198);
15147
15148 var collectionWeak = __webpack_require__(413); // `WeakSet` constructor
15149 // https://tc39.es/ecma262/#sec-weakset-constructor
15150
15151
15152 collection('WeakSet', function (init) {
15153 return function WeakSet() {
15154 return init(this, arguments.length ? arguments[0] : undefined);
15155 };
15156 }, collectionWeak);
15157
15158 /***/ }),
15159 /* 415 */
15160 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
15161
15162 var global = __webpack_require__(3);
15163
15164 var DOMIterables = __webpack_require__(416);
15165
15166 var DOMTokenListPrototype = __webpack_require__(417);
15167
15168 var forEach = __webpack_require__(130);
15169
15170 var createNonEnumerableProperty = __webpack_require__(40);
15171
15172 var handlePrototype = function (CollectionPrototype) {
15173 // some Chrome versions have non-configurable methods on DOMTokenList
15174 if (CollectionPrototype && CollectionPrototype.forEach !== forEach) try {
15175 createNonEnumerableProperty(CollectionPrototype, 'forEach', forEach);
15176 } catch (error) {
15177 CollectionPrototype.forEach = forEach;
15178 }
15179 };
15180
15181 for (var COLLECTION_NAME in DOMIterables) {
15182 if (DOMIterables[COLLECTION_NAME]) {
15183 handlePrototype(global[COLLECTION_NAME] && global[COLLECTION_NAME].prototype);
15184 }
15185 }
15186
15187 handlePrototype(DOMTokenListPrototype);
15188
15189 /***/ }),
15190 /* 416 */
15191 /***/ ((module) => {
15192
15193 // iterable DOM collections
15194 // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
15195 module.exports = {
15196 CSSRuleList: 0,
15197 CSSStyleDeclaration: 0,
15198 CSSValueList: 0,
15199 ClientRectList: 0,
15200 DOMRectList: 0,
15201 DOMStringList: 0,
15202 DOMTokenList: 1,
15203 DataTransferItemList: 0,
15204 FileList: 0,
15205 HTMLAllCollection: 0,
15206 HTMLCollection: 0,
15207 HTMLFormElement: 0,
15208 HTMLSelectElement: 0,
15209 MediaList: 0,
15210 MimeTypeArray: 0,
15211 NamedNodeMap: 0,
15212 NodeList: 1,
15213 PaintRequestList: 0,
15214 Plugin: 0,
15215 PluginArray: 0,
15216 SVGLengthList: 0,
15217 SVGNumberList: 0,
15218 SVGPathSegList: 0,
15219 SVGPointList: 0,
15220 SVGStringList: 0,
15221 SVGTransformList: 0,
15222 SourceBufferList: 0,
15223 StyleSheetList: 0,
15224 TextTrackCueList: 0,
15225 TextTrackList: 0,
15226 TouchList: 0
15227 };
15228
15229 /***/ }),
15230 /* 417 */
15231 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
15232
15233 // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList`
15234 var documentCreateElement = __webpack_require__(39);
15235
15236 var classList = documentCreateElement('span').classList;
15237 var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype;
15238 module.exports = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype;
15239
15240 /***/ }),
15241 /* 418 */
15242 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
15243
15244 var global = __webpack_require__(3);
15245
15246 var DOMIterables = __webpack_require__(416);
15247
15248 var DOMTokenListPrototype = __webpack_require__(417);
15249
15250 var ArrayIteratorMethods = __webpack_require__(138);
15251
15252 var createNonEnumerableProperty = __webpack_require__(40);
15253
15254 var wellKnownSymbol = __webpack_require__(30);
15255
15256 var ITERATOR = wellKnownSymbol('iterator');
15257 var TO_STRING_TAG = wellKnownSymbol('toStringTag');
15258 var ArrayValues = ArrayIteratorMethods.values;
15259
15260 var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
15261 if (CollectionPrototype) {
15262 // some Chrome versions have non-configurable methods on DOMTokenList
15263 if (CollectionPrototype[ITERATOR] !== ArrayValues) try {
15264 createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues);
15265 } catch (error) {
15266 CollectionPrototype[ITERATOR] = ArrayValues;
15267 }
15268
15269 if (!CollectionPrototype[TO_STRING_TAG]) {
15270 createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME);
15271 }
15272
15273 if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) {
15274 // some Chrome versions have non-configurable methods on DOMTokenList
15275 if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try {
15276 createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);
15277 } catch (error) {
15278 CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];
15279 }
15280 }
15281 }
15282 };
15283
15284 for (var COLLECTION_NAME in DOMIterables) {
15285 handlePrototype(global[COLLECTION_NAME] && global[COLLECTION_NAME].prototype, COLLECTION_NAME);
15286 }
15287
15288 handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
15289
15290 /***/ }),
15291 /* 419 */
15292 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
15293
15294 var $ = __webpack_require__(2);
15295
15296 var global = __webpack_require__(3);
15297
15298 var task = __webpack_require__(281);
15299
15300 var FORCED = !global.setImmediate || !global.clearImmediate; // http://w3c.github.io/setImmediate/
15301
15302 $({
15303 global: true,
15304 bind: true,
15305 enumerable: true,
15306 forced: FORCED
15307 }, {
15308 // `setImmediate` method
15309 // http://w3c.github.io/setImmediate/#si-setImmediate
15310 setImmediate: task.set,
15311 // `clearImmediate` method
15312 // http://w3c.github.io/setImmediate/#si-clearImmediate
15313 clearImmediate: task.clear
15314 });
15315
15316 /***/ }),
15317 /* 420 */
15318 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
15319
15320 var $ = __webpack_require__(2);
15321
15322 var global = __webpack_require__(3);
15323
15324 var microtask = __webpack_require__(283);
15325
15326 var IS_NODE = __webpack_require__(149);
15327
15328 var process = global.process; // `queueMicrotask` method
15329 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask
15330
15331 $({
15332 global: true,
15333 enumerable: true,
15334 noTargetGet: true
15335 }, {
15336 queueMicrotask: function queueMicrotask(fn) {
15337 var domain = IS_NODE && process.domain;
15338 microtask(domain ? domain.bind(fn) : fn);
15339 }
15340 });
15341
15342 /***/ }),
15343 /* 421 */
15344 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
15345
15346 var $ = __webpack_require__(2);
15347
15348 var global = __webpack_require__(3);
15349
15350 var apply = __webpack_require__(62);
15351
15352 var isCallable = __webpack_require__(18);
15353
15354 var userAgent = __webpack_require__(25);
15355
15356 var arraySlice = __webpack_require__(74);
15357
15358 var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
15359
15360 var Function = global.Function;
15361
15362 var wrap = function (scheduler) {
15363 return function (handler, timeout
15364 /* , ...arguments */
15365 ) {
15366 var boundArgs = arguments.length > 2;
15367 var args = boundArgs ? arraySlice(arguments, 2) : undefined;
15368 return scheduler(boundArgs ? function () {
15369 apply(isCallable(handler) ? handler : Function(handler), this, args);
15370 } : handler, timeout);
15371 };
15372 }; // ie9- setTimeout & setInterval additional parameters fix
15373 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
15374
15375
15376 $({
15377 global: true,
15378 bind: true,
15379 forced: MSIE
15380 }, {
15381 // `setTimeout` method
15382 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
15383 setTimeout: wrap(global.setTimeout),
15384 // `setInterval` method
15385 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
15386 setInterval: wrap(global.setInterval)
15387 });
15388
15389 /***/ }),
15390 /* 422 */
15391 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
15392
15393 "use strict";
15394 // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
15395
15396 __webpack_require__(331);
15397
15398 var $ = __webpack_require__(2);
15399
15400 var DESCRIPTORS = __webpack_require__(5);
15401
15402 var USE_NATIVE_URL = __webpack_require__(423);
15403
15404 var global = __webpack_require__(3);
15405
15406 var bind = __webpack_require__(80);
15407
15408 var uncurryThis = __webpack_require__(12);
15409
15410 var defineProperties = __webpack_require__(68);
15411
15412 var redefine = __webpack_require__(43);
15413
15414 var anInstance = __webpack_require__(168);
15415
15416 var hasOwn = __webpack_require__(35);
15417
15418 var assign = __webpack_require__(247);
15419
15420 var arrayFrom = __webpack_require__(132);
15421
15422 var arraySlice = __webpack_require__(72);
15423
15424 var codeAt = (__webpack_require__(325).codeAt);
15425
15426 var toASCII = __webpack_require__(424);
15427
15428 var $toString = __webpack_require__(64);
15429
15430 var setToStringTag = __webpack_require__(78);
15431
15432 var URLSearchParamsModule = __webpack_require__(425);
15433
15434 var InternalStateModule = __webpack_require__(45);
15435
15436 var setInternalState = InternalStateModule.set;
15437 var getInternalURLState = InternalStateModule.getterFor('URL');
15438 var URLSearchParams = URLSearchParamsModule.URLSearchParams;
15439 var getInternalSearchParamsState = URLSearchParamsModule.getState;
15440 var NativeURL = global.URL;
15441 var TypeError = global.TypeError;
15442 var parseInt = global.parseInt;
15443 var floor = Math.floor;
15444 var pow = Math.pow;
15445 var charAt = uncurryThis(''.charAt);
15446 var exec = uncurryThis(/./.exec);
15447 var join = uncurryThis([].join);
15448 var numberToString = uncurryThis(1.0.toString);
15449 var pop = uncurryThis([].pop);
15450 var push = uncurryThis([].push);
15451 var replace = uncurryThis(''.replace);
15452 var shift = uncurryThis([].shift);
15453 var split = uncurryThis(''.split);
15454 var stringSlice = uncurryThis(''.slice);
15455 var toLowerCase = uncurryThis(''.toLowerCase);
15456 var unshift = uncurryThis([].unshift);
15457 var INVALID_AUTHORITY = 'Invalid authority';
15458 var INVALID_SCHEME = 'Invalid scheme';
15459 var INVALID_HOST = 'Invalid host';
15460 var INVALID_PORT = 'Invalid port';
15461 var ALPHA = /[a-z]/i; // eslint-disable-next-line regexp/no-obscure-range -- safe
15462
15463 var ALPHANUMERIC = /[\d+-.a-z]/i;
15464 var DIGIT = /\d/;
15465 var HEX_START = /^0x/i;
15466 var OCT = /^[0-7]+$/;
15467 var DEC = /^\d+$/;
15468 var HEX = /^[\da-f]+$/i;
15469 /* eslint-disable regexp/no-control-character -- safe */
15470
15471 var FORBIDDEN_HOST_CODE_POINT = /[\0\t\n\r #%/:<>?@[\\\]^|]/;
15472 var FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT = /[\0\t\n\r #/:<>?@[\\\]^|]/;
15473 var LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE = /^[\u0000-\u0020]+|[\u0000-\u0020]+$/g;
15474 var TAB_AND_NEW_LINE = /[\t\n\r]/g;
15475 /* eslint-enable regexp/no-control-character -- safe */
15476
15477 var EOF; // https://url.spec.whatwg.org/#ipv4-number-parser
15478
15479 var parseIPv4 = function (input) {
15480 var parts = split(input, '.');
15481 var partsLength, numbers, index, part, radix, number, ipv4;
15482
15483 if (parts.length && parts[parts.length - 1] == '') {
15484 parts.length--;
15485 }
15486
15487 partsLength = parts.length;
15488 if (partsLength > 4) return input;
15489 numbers = [];
15490
15491 for (index = 0; index < partsLength; index++) {
15492 part = parts[index];
15493 if (part == '') return input;
15494 radix = 10;
15495
15496 if (part.length > 1 && charAt(part, 0) == '0') {
15497 radix = exec(HEX_START, part) ? 16 : 8;
15498 part = stringSlice(part, radix == 8 ? 1 : 2);
15499 }
15500
15501 if (part === '') {
15502 number = 0;
15503 } else {
15504 if (!exec(radix == 10 ? DEC : radix == 8 ? OCT : HEX, part)) return input;
15505 number = parseInt(part, radix);
15506 }
15507
15508 push(numbers, number);
15509 }
15510
15511 for (index = 0; index < partsLength; index++) {
15512 number = numbers[index];
15513
15514 if (index == partsLength - 1) {
15515 if (number >= pow(256, 5 - partsLength)) return null;
15516 } else if (number > 255) return null;
15517 }
15518
15519 ipv4 = pop(numbers);
15520
15521 for (index = 0; index < numbers.length; index++) {
15522 ipv4 += numbers[index] * pow(256, 3 - index);
15523 }
15524
15525 return ipv4;
15526 }; // https://url.spec.whatwg.org/#concept-ipv6-parser
15527 // eslint-disable-next-line max-statements -- TODO
15528
15529
15530 var parseIPv6 = function (input) {
15531 var address = [0, 0, 0, 0, 0, 0, 0, 0];
15532 var pieceIndex = 0;
15533 var compress = null;
15534 var pointer = 0;
15535 var value, length, numbersSeen, ipv4Piece, number, swaps, swap;
15536
15537 var chr = function () {
15538 return charAt(input, pointer);
15539 };
15540
15541 if (chr() == ':') {
15542 if (charAt(input, 1) != ':') return;
15543 pointer += 2;
15544 pieceIndex++;
15545 compress = pieceIndex;
15546 }
15547
15548 while (chr()) {
15549 if (pieceIndex == 8) return;
15550
15551 if (chr() == ':') {
15552 if (compress !== null) return;
15553 pointer++;
15554 pieceIndex++;
15555 compress = pieceIndex;
15556 continue;
15557 }
15558
15559 value = length = 0;
15560
15561 while (length < 4 && exec(HEX, chr())) {
15562 value = value * 16 + parseInt(chr(), 16);
15563 pointer++;
15564 length++;
15565 }
15566
15567 if (chr() == '.') {
15568 if (length == 0) return;
15569 pointer -= length;
15570 if (pieceIndex > 6) return;
15571 numbersSeen = 0;
15572
15573 while (chr()) {
15574 ipv4Piece = null;
15575
15576 if (numbersSeen > 0) {
15577 if (chr() == '.' && numbersSeen < 4) pointer++;else return;
15578 }
15579
15580 if (!exec(DIGIT, chr())) return;
15581
15582 while (exec(DIGIT, chr())) {
15583 number = parseInt(chr(), 10);
15584 if (ipv4Piece === null) ipv4Piece = number;else if (ipv4Piece == 0) return;else ipv4Piece = ipv4Piece * 10 + number;
15585 if (ipv4Piece > 255) return;
15586 pointer++;
15587 }
15588
15589 address[pieceIndex] = address[pieceIndex] * 256 + ipv4Piece;
15590 numbersSeen++;
15591 if (numbersSeen == 2 || numbersSeen == 4) pieceIndex++;
15592 }
15593
15594 if (numbersSeen != 4) return;
15595 break;
15596 } else if (chr() == ':') {
15597 pointer++;
15598 if (!chr()) return;
15599 } else if (chr()) return;
15600
15601 address[pieceIndex++] = value;
15602 }
15603
15604 if (compress !== null) {
15605 swaps = pieceIndex - compress;
15606 pieceIndex = 7;
15607
15608 while (pieceIndex != 0 && swaps > 0) {
15609 swap = address[pieceIndex];
15610 address[pieceIndex--] = address[compress + swaps - 1];
15611 address[compress + --swaps] = swap;
15612 }
15613 } else if (pieceIndex != 8) return;
15614
15615 return address;
15616 };
15617
15618 var findLongestZeroSequence = function (ipv6) {
15619 var maxIndex = null;
15620 var maxLength = 1;
15621 var currStart = null;
15622 var currLength = 0;
15623 var index = 0;
15624
15625 for (; index < 8; index++) {
15626 if (ipv6[index] !== 0) {
15627 if (currLength > maxLength) {
15628 maxIndex = currStart;
15629 maxLength = currLength;
15630 }
15631
15632 currStart = null;
15633 currLength = 0;
15634 } else {
15635 if (currStart === null) currStart = index;
15636 ++currLength;
15637 }
15638 }
15639
15640 if (currLength > maxLength) {
15641 maxIndex = currStart;
15642 maxLength = currLength;
15643 }
15644
15645 return maxIndex;
15646 }; // https://url.spec.whatwg.org/#host-serializing
15647
15648
15649 var serializeHost = function (host) {
15650 var result, index, compress, ignore0; // ipv4
15651
15652 if (typeof host == 'number') {
15653 result = [];
15654
15655 for (index = 0; index < 4; index++) {
15656 unshift(result, host % 256);
15657 host = floor(host / 256);
15658 }
15659
15660 return join(result, '.'); // ipv6
15661 } else if (typeof host == 'object') {
15662 result = '';
15663 compress = findLongestZeroSequence(host);
15664
15665 for (index = 0; index < 8; index++) {
15666 if (ignore0 && host[index] === 0) continue;
15667 if (ignore0) ignore0 = false;
15668
15669 if (compress === index) {
15670 result += index ? ':' : '::';
15671 ignore0 = true;
15672 } else {
15673 result += numberToString(host[index], 16);
15674 if (index < 7) result += ':';
15675 }
15676 }
15677
15678 return '[' + result + ']';
15679 }
15680
15681 return host;
15682 };
15683
15684 var C0ControlPercentEncodeSet = {};
15685 var fragmentPercentEncodeSet = assign({}, C0ControlPercentEncodeSet, {
15686 ' ': 1,
15687 '"': 1,
15688 '<': 1,
15689 '>': 1,
15690 '`': 1
15691 });
15692 var pathPercentEncodeSet = assign({}, fragmentPercentEncodeSet, {
15693 '#': 1,
15694 '?': 1,
15695 '{': 1,
15696 '}': 1
15697 });
15698 var userinfoPercentEncodeSet = assign({}, pathPercentEncodeSet, {
15699 '/': 1,
15700 ':': 1,
15701 ';': 1,
15702 '=': 1,
15703 '@': 1,
15704 '[': 1,
15705 '\\': 1,
15706 ']': 1,
15707 '^': 1,
15708 '|': 1
15709 });
15710
15711 var percentEncode = function (chr, set) {
15712 var code = codeAt(chr, 0);
15713 return code > 0x20 && code < 0x7F && !hasOwn(set, chr) ? chr : encodeURIComponent(chr);
15714 }; // https://url.spec.whatwg.org/#special-scheme
15715
15716
15717 var specialSchemes = {
15718 ftp: 21,
15719 file: null,
15720 http: 80,
15721 https: 443,
15722 ws: 80,
15723 wss: 443
15724 }; // https://url.spec.whatwg.org/#windows-drive-letter
15725
15726 var isWindowsDriveLetter = function (string, normalized) {
15727 var second;
15728 return string.length == 2 && exec(ALPHA, charAt(string, 0)) && ((second = charAt(string, 1)) == ':' || !normalized && second == '|');
15729 }; // https://url.spec.whatwg.org/#start-with-a-windows-drive-letter
15730
15731
15732 var startsWithWindowsDriveLetter = function (string) {
15733 var third;
15734 return string.length > 1 && isWindowsDriveLetter(stringSlice(string, 0, 2)) && (string.length == 2 || (third = charAt(string, 2)) === '/' || third === '\\' || third === '?' || third === '#');
15735 }; // https://url.spec.whatwg.org/#single-dot-path-segment
15736
15737
15738 var isSingleDot = function (segment) {
15739 return segment === '.' || toLowerCase(segment) === '%2e';
15740 }; // https://url.spec.whatwg.org/#double-dot-path-segment
15741
15742
15743 var isDoubleDot = function (segment) {
15744 segment = toLowerCase(segment);
15745 return segment === '..' || segment === '%2e.' || segment === '.%2e' || segment === '%2e%2e';
15746 }; // States:
15747
15748
15749 var SCHEME_START = {};
15750 var SCHEME = {};
15751 var NO_SCHEME = {};
15752 var SPECIAL_RELATIVE_OR_AUTHORITY = {};
15753 var PATH_OR_AUTHORITY = {};
15754 var RELATIVE = {};
15755 var RELATIVE_SLASH = {};
15756 var SPECIAL_AUTHORITY_SLASHES = {};
15757 var SPECIAL_AUTHORITY_IGNORE_SLASHES = {};
15758 var AUTHORITY = {};
15759 var HOST = {};
15760 var HOSTNAME = {};
15761 var PORT = {};
15762 var FILE = {};
15763 var FILE_SLASH = {};
15764 var FILE_HOST = {};
15765 var PATH_START = {};
15766 var PATH = {};
15767 var CANNOT_BE_A_BASE_URL_PATH = {};
15768 var QUERY = {};
15769 var FRAGMENT = {};
15770
15771 var URLState = function (url, isBase, base) {
15772 var urlString = $toString(url);
15773 var baseState, failure, searchParams;
15774
15775 if (isBase) {
15776 failure = this.parse(urlString);
15777 if (failure) throw TypeError(failure);
15778 this.searchParams = null;
15779 } else {
15780 if (base !== undefined) baseState = new URLState(base, true);
15781 failure = this.parse(urlString, null, baseState);
15782 if (failure) throw TypeError(failure);
15783 searchParams = getInternalSearchParamsState(new URLSearchParams());
15784 searchParams.bindURL(this);
15785 this.searchParams = searchParams;
15786 }
15787 };
15788
15789 URLState.prototype = {
15790 type: 'URL',
15791 // https://url.spec.whatwg.org/#url-parsing
15792 // eslint-disable-next-line max-statements -- TODO
15793 parse: function (input, stateOverride, base) {
15794 var url = this;
15795 var state = stateOverride || SCHEME_START;
15796 var pointer = 0;
15797 var buffer = '';
15798 var seenAt = false;
15799 var seenBracket = false;
15800 var seenPasswordToken = false;
15801 var codePoints, chr, bufferCodePoints, failure;
15802 input = $toString(input);
15803
15804 if (!stateOverride) {
15805 url.scheme = '';
15806 url.username = '';
15807 url.password = '';
15808 url.host = null;
15809 url.port = null;
15810 url.path = [];
15811 url.query = null;
15812 url.fragment = null;
15813 url.cannotBeABaseURL = false;
15814 input = replace(input, LEADING_AND_TRAILING_C0_CONTROL_OR_SPACE, '');
15815 }
15816
15817 input = replace(input, TAB_AND_NEW_LINE, '');
15818 codePoints = arrayFrom(input);
15819
15820 while (pointer <= codePoints.length) {
15821 chr = codePoints[pointer];
15822
15823 switch (state) {
15824 case SCHEME_START:
15825 if (chr && exec(ALPHA, chr)) {
15826 buffer += toLowerCase(chr);
15827 state = SCHEME;
15828 } else if (!stateOverride) {
15829 state = NO_SCHEME;
15830 continue;
15831 } else return INVALID_SCHEME;
15832
15833 break;
15834
15835 case SCHEME:
15836 if (chr && (exec(ALPHANUMERIC, chr) || chr == '+' || chr == '-' || chr == '.')) {
15837 buffer += toLowerCase(chr);
15838 } else if (chr == ':') {
15839 if (stateOverride && (url.isSpecial() != hasOwn(specialSchemes, buffer) || buffer == 'file' && (url.includesCredentials() || url.port !== null) || url.scheme == 'file' && !url.host)) return;
15840 url.scheme = buffer;
15841
15842 if (stateOverride) {
15843 if (url.isSpecial() && specialSchemes[url.scheme] == url.port) url.port = null;
15844 return;
15845 }
15846
15847 buffer = '';
15848
15849 if (url.scheme == 'file') {
15850 state = FILE;
15851 } else if (url.isSpecial() && base && base.scheme == url.scheme) {
15852 state = SPECIAL_RELATIVE_OR_AUTHORITY;
15853 } else if (url.isSpecial()) {
15854 state = SPECIAL_AUTHORITY_SLASHES;
15855 } else if (codePoints[pointer + 1] == '/') {
15856 state = PATH_OR_AUTHORITY;
15857 pointer++;
15858 } else {
15859 url.cannotBeABaseURL = true;
15860 push(url.path, '');
15861 state = CANNOT_BE_A_BASE_URL_PATH;
15862 }
15863 } else if (!stateOverride) {
15864 buffer = '';
15865 state = NO_SCHEME;
15866 pointer = 0;
15867 continue;
15868 } else return INVALID_SCHEME;
15869
15870 break;
15871
15872 case NO_SCHEME:
15873 if (!base || base.cannotBeABaseURL && chr != '#') return INVALID_SCHEME;
15874
15875 if (base.cannotBeABaseURL && chr == '#') {
15876 url.scheme = base.scheme;
15877 url.path = arraySlice(base.path);
15878 url.query = base.query;
15879 url.fragment = '';
15880 url.cannotBeABaseURL = true;
15881 state = FRAGMENT;
15882 break;
15883 }
15884
15885 state = base.scheme == 'file' ? FILE : RELATIVE;
15886 continue;
15887
15888 case SPECIAL_RELATIVE_OR_AUTHORITY:
15889 if (chr == '/' && codePoints[pointer + 1] == '/') {
15890 state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
15891 pointer++;
15892 } else {
15893 state = RELATIVE;
15894 continue;
15895 }
15896
15897 break;
15898
15899 case PATH_OR_AUTHORITY:
15900 if (chr == '/') {
15901 state = AUTHORITY;
15902 break;
15903 } else {
15904 state = PATH;
15905 continue;
15906 }
15907
15908 case RELATIVE:
15909 url.scheme = base.scheme;
15910
15911 if (chr == EOF) {
15912 url.username = base.username;
15913 url.password = base.password;
15914 url.host = base.host;
15915 url.port = base.port;
15916 url.path = arraySlice(base.path);
15917 url.query = base.query;
15918 } else if (chr == '/' || chr == '\\' && url.isSpecial()) {
15919 state = RELATIVE_SLASH;
15920 } else if (chr == '?') {
15921 url.username = base.username;
15922 url.password = base.password;
15923 url.host = base.host;
15924 url.port = base.port;
15925 url.path = arraySlice(base.path);
15926 url.query = '';
15927 state = QUERY;
15928 } else if (chr == '#') {
15929 url.username = base.username;
15930 url.password = base.password;
15931 url.host = base.host;
15932 url.port = base.port;
15933 url.path = arraySlice(base.path);
15934 url.query = base.query;
15935 url.fragment = '';
15936 state = FRAGMENT;
15937 } else {
15938 url.username = base.username;
15939 url.password = base.password;
15940 url.host = base.host;
15941 url.port = base.port;
15942 url.path = arraySlice(base.path);
15943 url.path.length--;
15944 state = PATH;
15945 continue;
15946 }
15947
15948 break;
15949
15950 case RELATIVE_SLASH:
15951 if (url.isSpecial() && (chr == '/' || chr == '\\')) {
15952 state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
15953 } else if (chr == '/') {
15954 state = AUTHORITY;
15955 } else {
15956 url.username = base.username;
15957 url.password = base.password;
15958 url.host = base.host;
15959 url.port = base.port;
15960 state = PATH;
15961 continue;
15962 }
15963
15964 break;
15965
15966 case SPECIAL_AUTHORITY_SLASHES:
15967 state = SPECIAL_AUTHORITY_IGNORE_SLASHES;
15968 if (chr != '/' || charAt(buffer, pointer + 1) != '/') continue;
15969 pointer++;
15970 break;
15971
15972 case SPECIAL_AUTHORITY_IGNORE_SLASHES:
15973 if (chr != '/' && chr != '\\') {
15974 state = AUTHORITY;
15975 continue;
15976 }
15977
15978 break;
15979
15980 case AUTHORITY:
15981 if (chr == '@') {
15982 if (seenAt) buffer = '%40' + buffer;
15983 seenAt = true;
15984 bufferCodePoints = arrayFrom(buffer);
15985
15986 for (var i = 0; i < bufferCodePoints.length; i++) {
15987 var codePoint = bufferCodePoints[i];
15988
15989 if (codePoint == ':' && !seenPasswordToken) {
15990 seenPasswordToken = true;
15991 continue;
15992 }
15993
15994 var encodedCodePoints = percentEncode(codePoint, userinfoPercentEncodeSet);
15995 if (seenPasswordToken) url.password += encodedCodePoints;else url.username += encodedCodePoints;
15996 }
15997
15998 buffer = '';
15999 } else if (chr == EOF || chr == '/' || chr == '?' || chr == '#' || chr == '\\' && url.isSpecial()) {
16000 if (seenAt && buffer == '') return INVALID_AUTHORITY;
16001 pointer -= arrayFrom(buffer).length + 1;
16002 buffer = '';
16003 state = HOST;
16004 } else buffer += chr;
16005
16006 break;
16007
16008 case HOST:
16009 case HOSTNAME:
16010 if (stateOverride && url.scheme == 'file') {
16011 state = FILE_HOST;
16012 continue;
16013 } else if (chr == ':' && !seenBracket) {
16014 if (buffer == '') return INVALID_HOST;
16015 failure = url.parseHost(buffer);
16016 if (failure) return failure;
16017 buffer = '';
16018 state = PORT;
16019 if (stateOverride == HOSTNAME) return;
16020 } else if (chr == EOF || chr == '/' || chr == '?' || chr == '#' || chr == '\\' && url.isSpecial()) {
16021 if (url.isSpecial() && buffer == '') return INVALID_HOST;
16022 if (stateOverride && buffer == '' && (url.includesCredentials() || url.port !== null)) return;
16023 failure = url.parseHost(buffer);
16024 if (failure) return failure;
16025 buffer = '';
16026 state = PATH_START;
16027 if (stateOverride) return;
16028 continue;
16029 } else {
16030 if (chr == '[') seenBracket = true;else if (chr == ']') seenBracket = false;
16031 buffer += chr;
16032 }
16033
16034 break;
16035
16036 case PORT:
16037 if (exec(DIGIT, chr)) {
16038 buffer += chr;
16039 } else if (chr == EOF || chr == '/' || chr == '?' || chr == '#' || chr == '\\' && url.isSpecial() || stateOverride) {
16040 if (buffer != '') {
16041 var port = parseInt(buffer, 10);
16042 if (port > 0xFFFF) return INVALID_PORT;
16043 url.port = url.isSpecial() && port === specialSchemes[url.scheme] ? null : port;
16044 buffer = '';
16045 }
16046
16047 if (stateOverride) return;
16048 state = PATH_START;
16049 continue;
16050 } else return INVALID_PORT;
16051
16052 break;
16053
16054 case FILE:
16055 url.scheme = 'file';
16056 if (chr == '/' || chr == '\\') state = FILE_SLASH;else if (base && base.scheme == 'file') {
16057 if (chr == EOF) {
16058 url.host = base.host;
16059 url.path = arraySlice(base.path);
16060 url.query = base.query;
16061 } else if (chr == '?') {
16062 url.host = base.host;
16063 url.path = arraySlice(base.path);
16064 url.query = '';
16065 state = QUERY;
16066 } else if (chr == '#') {
16067 url.host = base.host;
16068 url.path = arraySlice(base.path);
16069 url.query = base.query;
16070 url.fragment = '';
16071 state = FRAGMENT;
16072 } else {
16073 if (!startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
16074 url.host = base.host;
16075 url.path = arraySlice(base.path);
16076 url.shortenPath();
16077 }
16078
16079 state = PATH;
16080 continue;
16081 }
16082 } else {
16083 state = PATH;
16084 continue;
16085 }
16086 break;
16087
16088 case FILE_SLASH:
16089 if (chr == '/' || chr == '\\') {
16090 state = FILE_HOST;
16091 break;
16092 }
16093
16094 if (base && base.scheme == 'file' && !startsWithWindowsDriveLetter(join(arraySlice(codePoints, pointer), ''))) {
16095 if (isWindowsDriveLetter(base.path[0], true)) push(url.path, base.path[0]);else url.host = base.host;
16096 }
16097
16098 state = PATH;
16099 continue;
16100
16101 case FILE_HOST:
16102 if (chr == EOF || chr == '/' || chr == '\\' || chr == '?' || chr == '#') {
16103 if (!stateOverride && isWindowsDriveLetter(buffer)) {
16104 state = PATH;
16105 } else if (buffer == '') {
16106 url.host = '';
16107 if (stateOverride) return;
16108 state = PATH_START;
16109 } else {
16110 failure = url.parseHost(buffer);
16111 if (failure) return failure;
16112 if (url.host == 'localhost') url.host = '';
16113 if (stateOverride) return;
16114 buffer = '';
16115 state = PATH_START;
16116 }
16117
16118 continue;
16119 } else buffer += chr;
16120
16121 break;
16122
16123 case PATH_START:
16124 if (url.isSpecial()) {
16125 state = PATH;
16126 if (chr != '/' && chr != '\\') continue;
16127 } else if (!stateOverride && chr == '?') {
16128 url.query = '';
16129 state = QUERY;
16130 } else if (!stateOverride && chr == '#') {
16131 url.fragment = '';
16132 state = FRAGMENT;
16133 } else if (chr != EOF) {
16134 state = PATH;
16135 if (chr != '/') continue;
16136 }
16137
16138 break;
16139
16140 case PATH:
16141 if (chr == EOF || chr == '/' || chr == '\\' && url.isSpecial() || !stateOverride && (chr == '?' || chr == '#')) {
16142 if (isDoubleDot(buffer)) {
16143 url.shortenPath();
16144
16145 if (chr != '/' && !(chr == '\\' && url.isSpecial())) {
16146 push(url.path, '');
16147 }
16148 } else if (isSingleDot(buffer)) {
16149 if (chr != '/' && !(chr == '\\' && url.isSpecial())) {
16150 push(url.path, '');
16151 }
16152 } else {
16153 if (url.scheme == 'file' && !url.path.length && isWindowsDriveLetter(buffer)) {
16154 if (url.host) url.host = '';
16155 buffer = charAt(buffer, 0) + ':'; // normalize windows drive letter
16156 }
16157
16158 push(url.path, buffer);
16159 }
16160
16161 buffer = '';
16162
16163 if (url.scheme == 'file' && (chr == EOF || chr == '?' || chr == '#')) {
16164 while (url.path.length > 1 && url.path[0] === '') {
16165 shift(url.path);
16166 }
16167 }
16168
16169 if (chr == '?') {
16170 url.query = '';
16171 state = QUERY;
16172 } else if (chr == '#') {
16173 url.fragment = '';
16174 state = FRAGMENT;
16175 }
16176 } else {
16177 buffer += percentEncode(chr, pathPercentEncodeSet);
16178 }
16179
16180 break;
16181
16182 case CANNOT_BE_A_BASE_URL_PATH:
16183 if (chr == '?') {
16184 url.query = '';
16185 state = QUERY;
16186 } else if (chr == '#') {
16187 url.fragment = '';
16188 state = FRAGMENT;
16189 } else if (chr != EOF) {
16190 url.path[0] += percentEncode(chr, C0ControlPercentEncodeSet);
16191 }
16192
16193 break;
16194
16195 case QUERY:
16196 if (!stateOverride && chr == '#') {
16197 url.fragment = '';
16198 state = FRAGMENT;
16199 } else if (chr != EOF) {
16200 if (chr == "'" && url.isSpecial()) url.query += '%27';else if (chr == '#') url.query += '%23';else url.query += percentEncode(chr, C0ControlPercentEncodeSet);
16201 }
16202
16203 break;
16204
16205 case FRAGMENT:
16206 if (chr != EOF) url.fragment += percentEncode(chr, fragmentPercentEncodeSet);
16207 break;
16208 }
16209
16210 pointer++;
16211 }
16212 },
16213 // https://url.spec.whatwg.org/#host-parsing
16214 parseHost: function (input) {
16215 var result, codePoints, index;
16216
16217 if (charAt(input, 0) == '[') {
16218 if (charAt(input, input.length - 1) != ']') return INVALID_HOST;
16219 result = parseIPv6(stringSlice(input, 1, -1));
16220 if (!result) return INVALID_HOST;
16221 this.host = result; // opaque host
16222 } else if (!this.isSpecial()) {
16223 if (exec(FORBIDDEN_HOST_CODE_POINT_EXCLUDING_PERCENT, input)) return INVALID_HOST;
16224 result = '';
16225 codePoints = arrayFrom(input);
16226
16227 for (index = 0; index < codePoints.length; index++) {
16228 result += percentEncode(codePoints[index], C0ControlPercentEncodeSet);
16229 }
16230
16231 this.host = result;
16232 } else {
16233 input = toASCII(input);
16234 if (exec(FORBIDDEN_HOST_CODE_POINT, input)) return INVALID_HOST;
16235 result = parseIPv4(input);
16236 if (result === null) return INVALID_HOST;
16237 this.host = result;
16238 }
16239 },
16240 // https://url.spec.whatwg.org/#cannot-have-a-username-password-port
16241 cannotHaveUsernamePasswordPort: function () {
16242 return !this.host || this.cannotBeABaseURL || this.scheme == 'file';
16243 },
16244 // https://url.spec.whatwg.org/#include-credentials
16245 includesCredentials: function () {
16246 return this.username != '' || this.password != '';
16247 },
16248 // https://url.spec.whatwg.org/#is-special
16249 isSpecial: function () {
16250 return hasOwn(specialSchemes, this.scheme);
16251 },
16252 // https://url.spec.whatwg.org/#shorten-a-urls-path
16253 shortenPath: function () {
16254 var path = this.path;
16255 var pathSize = path.length;
16256
16257 if (pathSize && (this.scheme != 'file' || pathSize != 1 || !isWindowsDriveLetter(path[0], true))) {
16258 path.length--;
16259 }
16260 },
16261 // https://url.spec.whatwg.org/#concept-url-serializer
16262 serialize: function () {
16263 var url = this;
16264 var scheme = url.scheme;
16265 var username = url.username;
16266 var password = url.password;
16267 var host = url.host;
16268 var port = url.port;
16269 var path = url.path;
16270 var query = url.query;
16271 var fragment = url.fragment;
16272 var output = scheme + ':';
16273
16274 if (host !== null) {
16275 output += '//';
16276
16277 if (url.includesCredentials()) {
16278 output += username + (password ? ':' + password : '') + '@';
16279 }
16280
16281 output += serializeHost(host);
16282 if (port !== null) output += ':' + port;
16283 } else if (scheme == 'file') output += '//';
16284
16285 output += url.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : '';
16286 if (query !== null) output += '?' + query;
16287 if (fragment !== null) output += '#' + fragment;
16288 return output;
16289 },
16290 // https://url.spec.whatwg.org/#dom-url-href
16291 setHref: function (href) {
16292 var failure = this.parse(href);
16293 if (failure) throw TypeError(failure);
16294 this.searchParams.update();
16295 },
16296 // https://url.spec.whatwg.org/#dom-url-origin
16297 getOrigin: function () {
16298 var scheme = this.scheme;
16299 var port = this.port;
16300 if (scheme == 'blob') try {
16301 return new URLConstructor(scheme.path[0]).origin;
16302 } catch (error) {
16303 return 'null';
16304 }
16305 if (scheme == 'file' || !this.isSpecial()) return 'null';
16306 return scheme + '://' + serializeHost(this.host) + (port !== null ? ':' + port : '');
16307 },
16308 // https://url.spec.whatwg.org/#dom-url-protocol
16309 getProtocol: function () {
16310 return this.scheme + ':';
16311 },
16312 setProtocol: function (protocol) {
16313 this.parse($toString(protocol) + ':', SCHEME_START);
16314 },
16315 // https://url.spec.whatwg.org/#dom-url-username
16316 getUsername: function () {
16317 return this.username;
16318 },
16319 setUsername: function (username) {
16320 var codePoints = arrayFrom($toString(username));
16321 if (this.cannotHaveUsernamePasswordPort()) return;
16322 this.username = '';
16323
16324 for (var i = 0; i < codePoints.length; i++) {
16325 this.username += percentEncode(codePoints[i], userinfoPercentEncodeSet);
16326 }
16327 },
16328 // https://url.spec.whatwg.org/#dom-url-password
16329 getPassword: function () {
16330 return this.password;
16331 },
16332 setPassword: function (password) {
16333 var codePoints = arrayFrom($toString(password));
16334 if (this.cannotHaveUsernamePasswordPort()) return;
16335 this.password = '';
16336
16337 for (var i = 0; i < codePoints.length; i++) {
16338 this.password += percentEncode(codePoints[i], userinfoPercentEncodeSet);
16339 }
16340 },
16341 // https://url.spec.whatwg.org/#dom-url-host
16342 getHost: function () {
16343 var host = this.host;
16344 var port = this.port;
16345 return host === null ? '' : port === null ? serializeHost(host) : serializeHost(host) + ':' + port;
16346 },
16347 setHost: function (host) {
16348 if (this.cannotBeABaseURL) return;
16349 this.parse(host, HOST);
16350 },
16351 // https://url.spec.whatwg.org/#dom-url-hostname
16352 getHostname: function () {
16353 var host = this.host;
16354 return host === null ? '' : serializeHost(host);
16355 },
16356 setHostname: function (hostname) {
16357 if (this.cannotBeABaseURL) return;
16358 this.parse(hostname, HOSTNAME);
16359 },
16360 // https://url.spec.whatwg.org/#dom-url-port
16361 getPort: function () {
16362 var port = this.port;
16363 return port === null ? '' : $toString(port);
16364 },
16365 setPort: function (port) {
16366 if (this.cannotHaveUsernamePasswordPort()) return;
16367 port = $toString(port);
16368 if (port == '') this.port = null;else this.parse(port, PORT);
16369 },
16370 // https://url.spec.whatwg.org/#dom-url-pathname
16371 getPathname: function () {
16372 var path = this.path;
16373 return this.cannotBeABaseURL ? path[0] : path.length ? '/' + join(path, '/') : '';
16374 },
16375 setPathname: function (pathname) {
16376 if (this.cannotBeABaseURL) return;
16377 this.path = [];
16378 this.parse(pathname, PATH_START);
16379 },
16380 // https://url.spec.whatwg.org/#dom-url-search
16381 getSearch: function () {
16382 var query = this.query;
16383 return query ? '?' + query : '';
16384 },
16385 setSearch: function (search) {
16386 search = $toString(search);
16387
16388 if (search == '') {
16389 this.query = null;
16390 } else {
16391 if ('?' == charAt(search, 0)) search = stringSlice(search, 1);
16392 this.query = '';
16393 this.parse(search, QUERY);
16394 }
16395
16396 this.searchParams.update();
16397 },
16398 // https://url.spec.whatwg.org/#dom-url-searchparams
16399 getSearchParams: function () {
16400 return this.searchParams.facade;
16401 },
16402 // https://url.spec.whatwg.org/#dom-url-hash
16403 getHash: function () {
16404 var fragment = this.fragment;
16405 return fragment ? '#' + fragment : '';
16406 },
16407 setHash: function (hash) {
16408 hash = $toString(hash);
16409
16410 if (hash == '') {
16411 this.fragment = null;
16412 return;
16413 }
16414
16415 if ('#' == charAt(hash, 0)) hash = stringSlice(hash, 1);
16416 this.fragment = '';
16417 this.parse(hash, FRAGMENT);
16418 },
16419 update: function () {
16420 this.query = this.searchParams.serialize() || null;
16421 }
16422 }; // `URL` constructor
16423 // https://url.spec.whatwg.org/#url-class
16424
16425 var URLConstructor = function URL(url
16426 /* , base */
16427 ) {
16428 var that = anInstance(this, URLPrototype);
16429 var base = arguments.length > 1 ? arguments[1] : undefined;
16430 var state = setInternalState(that, new URLState(url, false, base));
16431
16432 if (!DESCRIPTORS) {
16433 that.href = state.serialize();
16434 that.origin = state.getOrigin();
16435 that.protocol = state.getProtocol();
16436 that.username = state.getUsername();
16437 that.password = state.getPassword();
16438 that.host = state.getHost();
16439 that.hostname = state.getHostname();
16440 that.port = state.getPort();
16441 that.pathname = state.getPathname();
16442 that.search = state.getSearch();
16443 that.searchParams = state.getSearchParams();
16444 that.hash = state.getHash();
16445 }
16446 };
16447
16448 var URLPrototype = URLConstructor.prototype;
16449
16450 var accessorDescriptor = function (getter, setter) {
16451 return {
16452 get: function () {
16453 return getInternalURLState(this)[getter]();
16454 },
16455 set: setter && function (value) {
16456 return getInternalURLState(this)[setter](value);
16457 },
16458 configurable: true,
16459 enumerable: true
16460 };
16461 };
16462
16463 if (DESCRIPTORS) {
16464 defineProperties(URLPrototype, {
16465 // `URL.prototype.href` accessors pair
16466 // https://url.spec.whatwg.org/#dom-url-href
16467 href: accessorDescriptor('serialize', 'setHref'),
16468 // `URL.prototype.origin` getter
16469 // https://url.spec.whatwg.org/#dom-url-origin
16470 origin: accessorDescriptor('getOrigin'),
16471 // `URL.prototype.protocol` accessors pair
16472 // https://url.spec.whatwg.org/#dom-url-protocol
16473 protocol: accessorDescriptor('getProtocol', 'setProtocol'),
16474 // `URL.prototype.username` accessors pair
16475 // https://url.spec.whatwg.org/#dom-url-username
16476 username: accessorDescriptor('getUsername', 'setUsername'),
16477 // `URL.prototype.password` accessors pair
16478 // https://url.spec.whatwg.org/#dom-url-password
16479 password: accessorDescriptor('getPassword', 'setPassword'),
16480 // `URL.prototype.host` accessors pair
16481 // https://url.spec.whatwg.org/#dom-url-host
16482 host: accessorDescriptor('getHost', 'setHost'),
16483 // `URL.prototype.hostname` accessors pair
16484 // https://url.spec.whatwg.org/#dom-url-hostname
16485 hostname: accessorDescriptor('getHostname', 'setHostname'),
16486 // `URL.prototype.port` accessors pair
16487 // https://url.spec.whatwg.org/#dom-url-port
16488 port: accessorDescriptor('getPort', 'setPort'),
16489 // `URL.prototype.pathname` accessors pair
16490 // https://url.spec.whatwg.org/#dom-url-pathname
16491 pathname: accessorDescriptor('getPathname', 'setPathname'),
16492 // `URL.prototype.search` accessors pair
16493 // https://url.spec.whatwg.org/#dom-url-search
16494 search: accessorDescriptor('getSearch', 'setSearch'),
16495 // `URL.prototype.searchParams` getter
16496 // https://url.spec.whatwg.org/#dom-url-searchparams
16497 searchParams: accessorDescriptor('getSearchParams'),
16498 // `URL.prototype.hash` accessors pair
16499 // https://url.spec.whatwg.org/#dom-url-hash
16500 hash: accessorDescriptor('getHash', 'setHash')
16501 });
16502 } // `URL.prototype.toJSON` method
16503 // https://url.spec.whatwg.org/#dom-url-tojson
16504
16505
16506 redefine(URLPrototype, 'toJSON', function toJSON() {
16507 return getInternalURLState(this).serialize();
16508 }, {
16509 enumerable: true
16510 }); // `URL.prototype.toString` method
16511 // https://url.spec.whatwg.org/#URL-stringification-behavior
16512
16513 redefine(URLPrototype, 'toString', function toString() {
16514 return getInternalURLState(this).serialize();
16515 }, {
16516 enumerable: true
16517 });
16518
16519 if (NativeURL) {
16520 var nativeCreateObjectURL = NativeURL.createObjectURL;
16521 var nativeRevokeObjectURL = NativeURL.revokeObjectURL; // `URL.createObjectURL` method
16522 // https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
16523
16524 if (nativeCreateObjectURL) redefine(URLConstructor, 'createObjectURL', bind(nativeCreateObjectURL, NativeURL)); // `URL.revokeObjectURL` method
16525 // https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL
16526
16527 if (nativeRevokeObjectURL) redefine(URLConstructor, 'revokeObjectURL', bind(nativeRevokeObjectURL, NativeURL));
16528 }
16529
16530 setToStringTag(URLConstructor, 'URL');
16531 $({
16532 global: true,
16533 forced: !USE_NATIVE_URL,
16534 sham: !DESCRIPTORS
16535 }, {
16536 URL: URLConstructor
16537 });
16538
16539 /***/ }),
16540 /* 423 */
16541 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
16542
16543 var fails = __webpack_require__(6);
16544
16545 var wellKnownSymbol = __webpack_require__(30);
16546
16547 var IS_PURE = __webpack_require__(32);
16548
16549 var ITERATOR = wellKnownSymbol('iterator');
16550 module.exports = !fails(function () {
16551 var url = new URL('b?a=1&b=2&c=3', 'http://a');
16552 var searchParams = url.searchParams;
16553 var result = '';
16554 url.pathname = 'c%20d';
16555 searchParams.forEach(function (value, key) {
16556 searchParams['delete']('b');
16557 result += key + value;
16558 });
16559 return IS_PURE && !url.toJSON || !searchParams.sort || url.href !== 'http://a/c%20d?a=1&c=3' || searchParams.get('c') !== '3' || String(new URLSearchParams('?a=1')) !== 'a=1' || !searchParams[ITERATOR] // throws in Edge
16560 || new URL('https://a@b').username !== 'a' || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b' // not punycoded in Edge
16561 || new URL('http://тест').host !== 'xn--e1aybc' // not escaped in Chrome 62-
16562 || new URL('http://a#б').hash !== '#%D0%B1' // fails in Chrome 66-
16563 || result !== 'a1c3' // throws in Safari
16564 || new URL('http://x', undefined).host !== 'x';
16565 });
16566
16567 /***/ }),
16568 /* 424 */
16569 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
16570
16571 "use strict";
16572 // based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js
16573
16574 var global = __webpack_require__(3);
16575
16576 var uncurryThis = __webpack_require__(12);
16577
16578 var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
16579
16580 var base = 36;
16581 var tMin = 1;
16582 var tMax = 26;
16583 var skew = 38;
16584 var damp = 700;
16585 var initialBias = 72;
16586 var initialN = 128; // 0x80
16587
16588 var delimiter = '-'; // '\x2D'
16589
16590 var regexNonASCII = /[^\0-\u007E]/; // non-ASCII chars
16591
16592 var regexSeparators = /[.\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
16593
16594 var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
16595 var baseMinusTMin = base - tMin;
16596 var RangeError = global.RangeError;
16597 var exec = uncurryThis(regexSeparators.exec);
16598 var floor = Math.floor;
16599 var fromCharCode = String.fromCharCode;
16600 var charCodeAt = uncurryThis(''.charCodeAt);
16601 var join = uncurryThis([].join);
16602 var push = uncurryThis([].push);
16603 var replace = uncurryThis(''.replace);
16604 var split = uncurryThis(''.split);
16605 var toLowerCase = uncurryThis(''.toLowerCase);
16606 /**
16607 * Creates an array containing the numeric code points of each Unicode
16608 * character in the string. While JavaScript uses UCS-2 internally,
16609 * this function will convert a pair of surrogate halves (each of which
16610 * UCS-2 exposes as separate characters) into a single code point,
16611 * matching UTF-16.
16612 */
16613
16614 var ucs2decode = function (string) {
16615 var output = [];
16616 var counter = 0;
16617 var length = string.length;
16618
16619 while (counter < length) {
16620 var value = charCodeAt(string, counter++);
16621
16622 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
16623 // It's a high surrogate, and there is a next character.
16624 var extra = charCodeAt(string, counter++);
16625
16626 if ((extra & 0xFC00) == 0xDC00) {
16627 // Low surrogate.
16628 push(output, ((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
16629 } else {
16630 // It's an unmatched surrogate; only append this code unit, in case the
16631 // next code unit is the high surrogate of a surrogate pair.
16632 push(output, value);
16633 counter--;
16634 }
16635 } else {
16636 push(output, value);
16637 }
16638 }
16639
16640 return output;
16641 };
16642 /**
16643 * Converts a digit/integer into a basic code point.
16644 */
16645
16646
16647 var digitToBasic = function (digit) {
16648 // 0..25 map to ASCII a..z or A..Z
16649 // 26..35 map to ASCII 0..9
16650 return digit + 22 + 75 * (digit < 26);
16651 };
16652 /**
16653 * Bias adaptation function as per section 3.4 of RFC 3492.
16654 * https://tools.ietf.org/html/rfc3492#section-3.4
16655 */
16656
16657
16658 var adapt = function (delta, numPoints, firstTime) {
16659 var k = 0;
16660 delta = firstTime ? floor(delta / damp) : delta >> 1;
16661 delta += floor(delta / numPoints);
16662
16663 while (delta > baseMinusTMin * tMax >> 1) {
16664 delta = floor(delta / baseMinusTMin);
16665 k += base;
16666 }
16667
16668 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
16669 };
16670 /**
16671 * Converts a string of Unicode symbols (e.g. a domain name label) to a
16672 * Punycode string of ASCII-only symbols.
16673 */
16674
16675
16676 var encode = function (input) {
16677 var output = []; // Convert the input in UCS-2 to an array of Unicode code points.
16678
16679 input = ucs2decode(input); // Cache the length.
16680
16681 var inputLength = input.length; // Initialize the state.
16682
16683 var n = initialN;
16684 var delta = 0;
16685 var bias = initialBias;
16686 var i, currentValue; // Handle the basic code points.
16687
16688 for (i = 0; i < input.length; i++) {
16689 currentValue = input[i];
16690
16691 if (currentValue < 0x80) {
16692 push(output, fromCharCode(currentValue));
16693 }
16694 }
16695
16696 var basicLength = output.length; // number of basic code points.
16697
16698 var handledCPCount = basicLength; // number of code points that have been handled;
16699 // Finish the basic string with a delimiter unless it's empty.
16700
16701 if (basicLength) {
16702 push(output, delimiter);
16703 } // Main encoding loop:
16704
16705
16706 while (handledCPCount < inputLength) {
16707 // All non-basic code points < n have been handled already. Find the next larger one:
16708 var m = maxInt;
16709
16710 for (i = 0; i < input.length; i++) {
16711 currentValue = input[i];
16712
16713 if (currentValue >= n && currentValue < m) {
16714 m = currentValue;
16715 }
16716 } // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, but guard against overflow.
16717
16718
16719 var handledCPCountPlusOne = handledCPCount + 1;
16720
16721 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
16722 throw RangeError(OVERFLOW_ERROR);
16723 }
16724
16725 delta += (m - n) * handledCPCountPlusOne;
16726 n = m;
16727
16728 for (i = 0; i < input.length; i++) {
16729 currentValue = input[i];
16730
16731 if (currentValue < n && ++delta > maxInt) {
16732 throw RangeError(OVERFLOW_ERROR);
16733 }
16734
16735 if (currentValue == n) {
16736 // Represent delta as a generalized variable-length integer.
16737 var q = delta;
16738 var k = base;
16739
16740 while (true) {
16741 var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
16742 if (q < t) break;
16743 var qMinusT = q - t;
16744 var baseMinusT = base - t;
16745 push(output, fromCharCode(digitToBasic(t + qMinusT % baseMinusT)));
16746 q = floor(qMinusT / baseMinusT);
16747 k += base;
16748 }
16749
16750 push(output, fromCharCode(digitToBasic(q)));
16751 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
16752 delta = 0;
16753 handledCPCount++;
16754 }
16755 }
16756
16757 delta++;
16758 n++;
16759 }
16760
16761 return join(output, '');
16762 };
16763
16764 module.exports = function (input) {
16765 var encoded = [];
16766 var labels = split(replace(toLowerCase(input), regexSeparators, '\u002E'), '.');
16767 var i, label;
16768
16769 for (i = 0; i < labels.length; i++) {
16770 label = labels[i];
16771 push(encoded, exec(regexNonASCII, label) ? 'xn--' + encode(label) : label);
16772 }
16773
16774 return join(encoded, '.');
16775 };
16776
16777 /***/ }),
16778 /* 425 */
16779 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
16780
16781 "use strict";
16782 // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
16783
16784 __webpack_require__(138);
16785
16786 var $ = __webpack_require__(2);
16787
16788 var global = __webpack_require__(3);
16789
16790 var getBuiltIn = __webpack_require__(20);
16791
16792 var call = __webpack_require__(7);
16793
16794 var uncurryThis = __webpack_require__(12);
16795
16796 var USE_NATIVE_URL = __webpack_require__(423);
16797
16798 var redefine = __webpack_require__(43);
16799
16800 var redefineAll = __webpack_require__(167);
16801
16802 var setToStringTag = __webpack_require__(78);
16803
16804 var createIteratorConstructor = __webpack_require__(140);
16805
16806 var InternalStateModule = __webpack_require__(45);
16807
16808 var anInstance = __webpack_require__(168);
16809
16810 var isCallable = __webpack_require__(18);
16811
16812 var hasOwn = __webpack_require__(35);
16813
16814 var bind = __webpack_require__(80);
16815
16816 var classof = __webpack_require__(65);
16817
16818 var anObject = __webpack_require__(42);
16819
16820 var isObject = __webpack_require__(17);
16821
16822 var $toString = __webpack_require__(64);
16823
16824 var create = __webpack_require__(67);
16825
16826 var createPropertyDescriptor = __webpack_require__(9);
16827
16828 var getIterator = __webpack_require__(108);
16829
16830 var getIteratorMethod = __webpack_require__(109);
16831
16832 var wellKnownSymbol = __webpack_require__(30);
16833
16834 var arraySort = __webpack_require__(155);
16835
16836 var ITERATOR = wellKnownSymbol('iterator');
16837 var URL_SEARCH_PARAMS = 'URLSearchParams';
16838 var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
16839 var setInternalState = InternalStateModule.set;
16840 var getInternalParamsState = InternalStateModule.getterFor(URL_SEARCH_PARAMS);
16841 var getInternalIteratorState = InternalStateModule.getterFor(URL_SEARCH_PARAMS_ITERATOR);
16842 var n$Fetch = getBuiltIn('fetch');
16843 var N$Request = getBuiltIn('Request');
16844 var Headers = getBuiltIn('Headers');
16845 var RequestPrototype = N$Request && N$Request.prototype;
16846 var HeadersPrototype = Headers && Headers.prototype;
16847 var RegExp = global.RegExp;
16848 var TypeError = global.TypeError;
16849 var decodeURIComponent = global.decodeURIComponent;
16850 var encodeURIComponent = global.encodeURIComponent;
16851 var charAt = uncurryThis(''.charAt);
16852 var join = uncurryThis([].join);
16853 var push = uncurryThis([].push);
16854 var replace = uncurryThis(''.replace);
16855 var shift = uncurryThis([].shift);
16856 var splice = uncurryThis([].splice);
16857 var split = uncurryThis(''.split);
16858 var stringSlice = uncurryThis(''.slice);
16859 var plus = /\+/g;
16860 var sequences = Array(4);
16861
16862 var percentSequence = function (bytes) {
16863 return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
16864 };
16865
16866 var percentDecode = function (sequence) {
16867 try {
16868 return decodeURIComponent(sequence);
16869 } catch (error) {
16870 return sequence;
16871 }
16872 };
16873
16874 var deserialize = function (it) {
16875 var result = replace(it, plus, ' ');
16876 var bytes = 4;
16877
16878 try {
16879 return decodeURIComponent(result);
16880 } catch (error) {
16881 while (bytes) {
16882 result = replace(result, percentSequence(bytes--), percentDecode);
16883 }
16884
16885 return result;
16886 }
16887 };
16888
16889 var find = /[!'()~]|%20/g;
16890 var replacements = {
16891 '!': '%21',
16892 "'": '%27',
16893 '(': '%28',
16894 ')': '%29',
16895 '~': '%7E',
16896 '%20': '+'
16897 };
16898
16899 var replacer = function (match) {
16900 return replacements[match];
16901 };
16902
16903 var serialize = function (it) {
16904 return replace(encodeURIComponent(it), find, replacer);
16905 };
16906
16907 var validateArgumentsLength = function (passed, required) {
16908 if (passed < required) throw TypeError('Not enough arguments');
16909 };
16910
16911 var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
16912 setInternalState(this, {
16913 type: URL_SEARCH_PARAMS_ITERATOR,
16914 iterator: getIterator(getInternalParamsState(params).entries),
16915 kind: kind
16916 });
16917 }, 'Iterator', function next() {
16918 var state = getInternalIteratorState(this);
16919 var kind = state.kind;
16920 var step = state.iterator.next();
16921 var entry = step.value;
16922
16923 if (!step.done) {
16924 step.value = kind === 'keys' ? entry.key : kind === 'values' ? entry.value : [entry.key, entry.value];
16925 }
16926
16927 return step;
16928 });
16929
16930 var URLSearchParamsState = function (init) {
16931 this.entries = [];
16932 this.url = null;
16933
16934 if (init !== undefined) {
16935 if (isObject(init)) this.parseObject(init);else this.parseQuery(typeof init == 'string' ? charAt(init, 0) === '?' ? stringSlice(init, 1) : init : $toString(init));
16936 }
16937 };
16938
16939 URLSearchParamsState.prototype = {
16940 type: URL_SEARCH_PARAMS,
16941 bindURL: function (url) {
16942 this.url = url;
16943 this.update();
16944 },
16945 parseObject: function (object) {
16946 var iteratorMethod = getIteratorMethod(object);
16947 var iterator, next, step, entryIterator, entryNext, first, second;
16948
16949 if (iteratorMethod) {
16950 iterator = getIterator(object, iteratorMethod);
16951 next = iterator.next;
16952
16953 while (!(step = call(next, iterator)).done) {
16954 entryIterator = getIterator(anObject(step.value));
16955 entryNext = entryIterator.next;
16956 if ((first = call(entryNext, entryIterator)).done || (second = call(entryNext, entryIterator)).done || !call(entryNext, entryIterator).done) throw TypeError('Expected sequence with length 2');
16957 push(this.entries, {
16958 key: $toString(first.value),
16959 value: $toString(second.value)
16960 });
16961 }
16962 } else for (var key in object) if (hasOwn(object, key)) {
16963 push(this.entries, {
16964 key: key,
16965 value: $toString(object[key])
16966 });
16967 }
16968 },
16969 parseQuery: function (query) {
16970 if (query) {
16971 var attributes = split(query, '&');
16972 var index = 0;
16973 var attribute, entry;
16974
16975 while (index < attributes.length) {
16976 attribute = attributes[index++];
16977
16978 if (attribute.length) {
16979 entry = split(attribute, '=');
16980 push(this.entries, {
16981 key: deserialize(shift(entry)),
16982 value: deserialize(join(entry, '='))
16983 });
16984 }
16985 }
16986 }
16987 },
16988 serialize: function () {
16989 var entries = this.entries;
16990 var result = [];
16991 var index = 0;
16992 var entry;
16993
16994 while (index < entries.length) {
16995 entry = entries[index++];
16996 push(result, serialize(entry.key) + '=' + serialize(entry.value));
16997 }
16998
16999 return join(result, '&');
17000 },
17001 update: function () {
17002 this.entries.length = 0;
17003 this.parseQuery(this.url.query);
17004 },
17005 updateURL: function () {
17006 if (this.url) this.url.update();
17007 }
17008 }; // `URLSearchParams` constructor
17009 // https://url.spec.whatwg.org/#interface-urlsearchparams
17010
17011 var URLSearchParamsConstructor = function
17012 /* init */
17013 URLSearchParams() {
17014 anInstance(this, URLSearchParamsPrototype);
17015 var init = arguments.length > 0 ? arguments[0] : undefined;
17016 setInternalState(this, new URLSearchParamsState(init));
17017 };
17018
17019 var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;
17020 redefineAll(URLSearchParamsPrototype, {
17021 // `URLSearchParams.prototype.append` method
17022 // https://url.spec.whatwg.org/#dom-urlsearchparams-append
17023 append: function append(name, value) {
17024 validateArgumentsLength(arguments.length, 2);
17025 var state = getInternalParamsState(this);
17026 push(state.entries, {
17027 key: $toString(name),
17028 value: $toString(value)
17029 });
17030 state.updateURL();
17031 },
17032 // `URLSearchParams.prototype.delete` method
17033 // https://url.spec.whatwg.org/#dom-urlsearchparams-delete
17034 'delete': function (name) {
17035 validateArgumentsLength(arguments.length, 1);
17036 var state = getInternalParamsState(this);
17037 var entries = state.entries;
17038 var key = $toString(name);
17039 var index = 0;
17040
17041 while (index < entries.length) {
17042 if (entries[index].key === key) splice(entries, index, 1);else index++;
17043 }
17044
17045 state.updateURL();
17046 },
17047 // `URLSearchParams.prototype.get` method
17048 // https://url.spec.whatwg.org/#dom-urlsearchparams-get
17049 get: function get(name) {
17050 validateArgumentsLength(arguments.length, 1);
17051 var entries = getInternalParamsState(this).entries;
17052 var key = $toString(name);
17053 var index = 0;
17054
17055 for (; index < entries.length; index++) {
17056 if (entries[index].key === key) return entries[index].value;
17057 }
17058
17059 return null;
17060 },
17061 // `URLSearchParams.prototype.getAll` method
17062 // https://url.spec.whatwg.org/#dom-urlsearchparams-getall
17063 getAll: function getAll(name) {
17064 validateArgumentsLength(arguments.length, 1);
17065 var entries = getInternalParamsState(this).entries;
17066 var key = $toString(name);
17067 var result = [];
17068 var index = 0;
17069
17070 for (; index < entries.length; index++) {
17071 if (entries[index].key === key) push(result, entries[index].value);
17072 }
17073
17074 return result;
17075 },
17076 // `URLSearchParams.prototype.has` method
17077 // https://url.spec.whatwg.org/#dom-urlsearchparams-has
17078 has: function has(name) {
17079 validateArgumentsLength(arguments.length, 1);
17080 var entries = getInternalParamsState(this).entries;
17081 var key = $toString(name);
17082 var index = 0;
17083
17084 while (index < entries.length) {
17085 if (entries[index++].key === key) return true;
17086 }
17087
17088 return false;
17089 },
17090 // `URLSearchParams.prototype.set` method
17091 // https://url.spec.whatwg.org/#dom-urlsearchparams-set
17092 set: function set(name, value) {
17093 validateArgumentsLength(arguments.length, 1);
17094 var state = getInternalParamsState(this);
17095 var entries = state.entries;
17096 var found = false;
17097 var key = $toString(name);
17098 var val = $toString(value);
17099 var index = 0;
17100 var entry;
17101
17102 for (; index < entries.length; index++) {
17103 entry = entries[index];
17104
17105 if (entry.key === key) {
17106 if (found) splice(entries, index--, 1);else {
17107 found = true;
17108 entry.value = val;
17109 }
17110 }
17111 }
17112
17113 if (!found) push(entries, {
17114 key: key,
17115 value: val
17116 });
17117 state.updateURL();
17118 },
17119 // `URLSearchParams.prototype.sort` method
17120 // https://url.spec.whatwg.org/#dom-urlsearchparams-sort
17121 sort: function sort() {
17122 var state = getInternalParamsState(this);
17123 arraySort(state.entries, function (a, b) {
17124 return a.key > b.key ? 1 : -1;
17125 });
17126 state.updateURL();
17127 },
17128 // `URLSearchParams.prototype.forEach` method
17129 forEach: function forEach(callback
17130 /* , thisArg */
17131 ) {
17132 var entries = getInternalParamsState(this).entries;
17133 var boundFunction = bind(callback, arguments.length > 1 ? arguments[1] : undefined);
17134 var index = 0;
17135 var entry;
17136
17137 while (index < entries.length) {
17138 entry = entries[index++];
17139 boundFunction(entry.value, entry.key, this);
17140 }
17141 },
17142 // `URLSearchParams.prototype.keys` method
17143 keys: function keys() {
17144 return new URLSearchParamsIterator(this, 'keys');
17145 },
17146 // `URLSearchParams.prototype.values` method
17147 values: function values() {
17148 return new URLSearchParamsIterator(this, 'values');
17149 },
17150 // `URLSearchParams.prototype.entries` method
17151 entries: function entries() {
17152 return new URLSearchParamsIterator(this, 'entries');
17153 }
17154 }, {
17155 enumerable: true
17156 }); // `URLSearchParams.prototype[@@iterator]` method
17157
17158 redefine(URLSearchParamsPrototype, ITERATOR, URLSearchParamsPrototype.entries, {
17159 name: 'entries'
17160 }); // `URLSearchParams.prototype.toString` method
17161 // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
17162
17163 redefine(URLSearchParamsPrototype, 'toString', function toString() {
17164 return getInternalParamsState(this).serialize();
17165 }, {
17166 enumerable: true
17167 });
17168 setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
17169 $({
17170 global: true,
17171 forced: !USE_NATIVE_URL
17172 }, {
17173 URLSearchParams: URLSearchParamsConstructor
17174 }); // Wrap `fetch` and `Request` for correct work with polyfilled `URLSearchParams`
17175
17176 if (!USE_NATIVE_URL && isCallable(Headers)) {
17177 var headersHas = uncurryThis(HeadersPrototype.has);
17178 var headersSet = uncurryThis(HeadersPrototype.set);
17179
17180 var wrapRequestOptions = function (init) {
17181 if (isObject(init)) {
17182 var body = init.body;
17183 var headers;
17184
17185 if (classof(body) === URL_SEARCH_PARAMS) {
17186 headers = init.headers ? new Headers(init.headers) : new Headers();
17187
17188 if (!headersHas(headers, 'content-type')) {
17189 headersSet(headers, 'content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
17190 }
17191
17192 return create(init, {
17193 body: createPropertyDescriptor(0, $toString(body)),
17194 headers: createPropertyDescriptor(0, headers)
17195 });
17196 }
17197 }
17198
17199 return init;
17200 };
17201
17202 if (isCallable(n$Fetch)) {
17203 $({
17204 global: true,
17205 enumerable: true,
17206 forced: true
17207 }, {
17208 fetch: function fetch(input
17209 /* , init */
17210 ) {
17211 return n$Fetch(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {});
17212 }
17213 });
17214 }
17215
17216 if (isCallable(N$Request)) {
17217 var RequestConstructor = function Request(input
17218 /* , init */
17219 ) {
17220 anInstance(this, RequestPrototype);
17221 return new N$Request(input, arguments.length > 1 ? wrapRequestOptions(arguments[1]) : {});
17222 };
17223
17224 RequestPrototype.constructor = RequestConstructor;
17225 RequestConstructor.prototype = RequestPrototype;
17226 $({
17227 global: true,
17228 forced: true
17229 }, {
17230 Request: RequestConstructor
17231 });
17232 }
17233 }
17234
17235 module.exports = {
17236 URLSearchParams: URLSearchParamsConstructor,
17237 getState: getInternalParamsState
17238 };
17239
17240 /***/ }),
17241 /* 426 */
17242 /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
17243
17244 "use strict";
17245
17246
17247 var $ = __webpack_require__(2);
17248
17249 var call = __webpack_require__(7); // `URL.prototype.toJSON` method
17250 // https://url.spec.whatwg.org/#dom-url-tojson
17251
17252
17253 $({
17254 target: 'URL',
17255 proto: true,
17256 enumerable: true
17257 }, {
17258 toJSON: function toJSON() {
17259 return call(URL.prototype.toString, this);
17260 }
17261 });
17262
17263 /***/ }),
17264 /* 427 */
17265 /***/ ((module) => {
17266
17267 /**
17268 * Copyright (c) 2014-present, Facebook, Inc.
17269 *
17270 * This source code is licensed under the MIT license found in the
17271 * LICENSE file in the root directory of this source tree.
17272 */
17273 var runtime = function (exports) {
17274 "use strict";
17275
17276 var Op = Object.prototype;
17277 var hasOwn = Op.hasOwnProperty;
17278 var undefined; // More compressible than void 0.
17279
17280 var $Symbol = typeof Symbol === "function" ? Symbol : {};
17281 var iteratorSymbol = $Symbol.iterator || "@@iterator";
17282 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
17283 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
17284
17285 function define(obj, key, value) {
17286 Object.defineProperty(obj, key, {
17287 value: value,
17288 enumerable: true,
17289 configurable: true,
17290 writable: true
17291 });
17292 return obj[key];
17293 }
17294
17295 try {
17296 // IE 8 has a broken Object.defineProperty that only works on DOM objects.
17297 define({}, "");
17298 } catch (err) {
17299 define = function (obj, key, value) {
17300 return obj[key] = value;
17301 };
17302 }
17303
17304 function wrap(innerFn, outerFn, self, tryLocsList) {
17305 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
17306 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
17307 var generator = Object.create(protoGenerator.prototype);
17308 var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
17309 // .throw, and .return methods.
17310
17311 generator._invoke = makeInvokeMethod(innerFn, self, context);
17312 return generator;
17313 }
17314
17315 exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
17316 // record like context.tryEntries[i].completion. This interface could
17317 // have been (and was previously) designed to take a closure to be
17318 // invoked without arguments, but in all the cases we care about we
17319 // already have an existing method we want to call, so there's no need
17320 // to create a new function object. We can even get away with assuming
17321 // the method takes exactly one argument, since that happens to be true
17322 // in every case, so we don't have to touch the arguments object. The
17323 // only additional allocation required is the completion record, which
17324 // has a stable shape and so hopefully should be cheap to allocate.
17325
17326 function tryCatch(fn, obj, arg) {
17327 try {
17328 return {
17329 type: "normal",
17330 arg: fn.call(obj, arg)
17331 };
17332 } catch (err) {
17333 return {
17334 type: "throw",
17335 arg: err
17336 };
17337 }
17338 }
17339
17340 var GenStateSuspendedStart = "suspendedStart";
17341 var GenStateSuspendedYield = "suspendedYield";
17342 var GenStateExecuting = "executing";
17343 var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
17344 // breaking out of the dispatch switch statement.
17345
17346 var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
17347 // .constructor.prototype properties for functions that return Generator
17348 // objects. For full spec compliance, you may wish to configure your
17349 // minifier not to mangle the names of these two functions.
17350
17351 function Generator() {}
17352
17353 function GeneratorFunction() {}
17354
17355 function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
17356 // don't natively support it.
17357
17358
17359 var IteratorPrototype = {};
17360 define(IteratorPrototype, iteratorSymbol, function () {
17361 return this;
17362 });
17363 var getProto = Object.getPrototypeOf;
17364 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
17365
17366 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
17367 // This environment has a native %IteratorPrototype%; use it instead
17368 // of the polyfill.
17369 IteratorPrototype = NativeIteratorPrototype;
17370 }
17371
17372 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
17373 GeneratorFunction.prototype = GeneratorFunctionPrototype;
17374 define(Gp, "constructor", GeneratorFunctionPrototype);
17375 define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
17376 GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
17377 // Iterator interface in terms of a single ._invoke method.
17378
17379 function defineIteratorMethods(prototype) {
17380 ["next", "throw", "return"].forEach(function (method) {
17381 define(prototype, method, function (arg) {
17382 return this._invoke(method, arg);
17383 });
17384 });
17385 }
17386
17387 exports.isGeneratorFunction = function (genFun) {
17388 var ctor = typeof genFun === "function" && genFun.constructor;
17389 return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
17390 // do is to check its .name property.
17391 (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
17392 };
17393
17394 exports.mark = function (genFun) {
17395 if (Object.setPrototypeOf) {
17396 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
17397 } else {
17398 genFun.__proto__ = GeneratorFunctionPrototype;
17399 define(genFun, toStringTagSymbol, "GeneratorFunction");
17400 }
17401
17402 genFun.prototype = Object.create(Gp);
17403 return genFun;
17404 }; // Within the body of any async function, `await x` is transformed to
17405 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
17406 // `hasOwn.call(value, "__await")` to determine if the yielded value is
17407 // meant to be awaited.
17408
17409
17410 exports.awrap = function (arg) {
17411 return {
17412 __await: arg
17413 };
17414 };
17415
17416 function AsyncIterator(generator, PromiseImpl) {
17417 function invoke(method, arg, resolve, reject) {
17418 var record = tryCatch(generator[method], generator, arg);
17419
17420 if (record.type === "throw") {
17421 reject(record.arg);
17422 } else {
17423 var result = record.arg;
17424 var value = result.value;
17425
17426 if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
17427 return PromiseImpl.resolve(value.__await).then(function (value) {
17428 invoke("next", value, resolve, reject);
17429 }, function (err) {
17430 invoke("throw", err, resolve, reject);
17431 });
17432 }
17433
17434 return PromiseImpl.resolve(value).then(function (unwrapped) {
17435 // When a yielded Promise is resolved, its final value becomes
17436 // the .value of the Promise<{value,done}> result for the
17437 // current iteration.
17438 result.value = unwrapped;
17439 resolve(result);
17440 }, function (error) {
17441 // If a rejected Promise was yielded, throw the rejection back
17442 // into the async generator function so it can be handled there.
17443 return invoke("throw", error, resolve, reject);
17444 });
17445 }
17446 }
17447
17448 var previousPromise;
17449
17450 function enqueue(method, arg) {
17451 function callInvokeWithMethodAndArg() {
17452 return new PromiseImpl(function (resolve, reject) {
17453 invoke(method, arg, resolve, reject);
17454 });
17455 }
17456
17457 return previousPromise = // If enqueue has been called before, then we want to wait until
17458 // all previous Promises have been resolved before calling invoke,
17459 // so that results are always delivered in the correct order. If
17460 // enqueue has not been called before, then it is important to
17461 // call invoke immediately, without waiting on a callback to fire,
17462 // so that the async generator function has the opportunity to do
17463 // any necessary setup in a predictable way. This predictability
17464 // is why the Promise constructor synchronously invokes its
17465 // executor callback, and why async functions synchronously
17466 // execute code before the first await. Since we implement simple
17467 // async functions in terms of async generators, it is especially
17468 // important to get this right, even though it requires care.
17469 previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
17470 // invocations of the iterator.
17471 callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
17472 } // Define the unified helper method that is used to implement .next,
17473 // .throw, and .return (see defineIteratorMethods).
17474
17475
17476 this._invoke = enqueue;
17477 }
17478
17479 defineIteratorMethods(AsyncIterator.prototype);
17480 define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
17481 return this;
17482 });
17483 exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
17484 // AsyncIterator objects; they just return a Promise for the value of
17485 // the final result produced by the iterator.
17486
17487 exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
17488 if (PromiseImpl === void 0) PromiseImpl = Promise;
17489 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
17490 return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
17491 : iter.next().then(function (result) {
17492 return result.done ? result.value : iter.next();
17493 });
17494 };
17495
17496 function makeInvokeMethod(innerFn, self, context) {
17497 var state = GenStateSuspendedStart;
17498 return function invoke(method, arg) {
17499 if (state === GenStateExecuting) {
17500 throw new Error("Generator is already running");
17501 }
17502
17503 if (state === GenStateCompleted) {
17504 if (method === "throw") {
17505 throw arg;
17506 } // Be forgiving, per 25.3.3.3.3 of the spec:
17507 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
17508
17509
17510 return doneResult();
17511 }
17512
17513 context.method = method;
17514 context.arg = arg;
17515
17516 while (true) {
17517 var delegate = context.delegate;
17518
17519 if (delegate) {
17520 var delegateResult = maybeInvokeDelegate(delegate, context);
17521
17522 if (delegateResult) {
17523 if (delegateResult === ContinueSentinel) continue;
17524 return delegateResult;
17525 }
17526 }
17527
17528 if (context.method === "next") {
17529 // Setting context._sent for legacy support of Babel's
17530 // function.sent implementation.
17531 context.sent = context._sent = context.arg;
17532 } else if (context.method === "throw") {
17533 if (state === GenStateSuspendedStart) {
17534 state = GenStateCompleted;
17535 throw context.arg;
17536 }
17537
17538 context.dispatchException(context.arg);
17539 } else if (context.method === "return") {
17540 context.abrupt("return", context.arg);
17541 }
17542
17543 state = GenStateExecuting;
17544 var record = tryCatch(innerFn, self, context);
17545
17546 if (record.type === "normal") {
17547 // If an exception is thrown from innerFn, we leave state ===
17548 // GenStateExecuting and loop back for another invocation.
17549 state = context.done ? GenStateCompleted : GenStateSuspendedYield;
17550
17551 if (record.arg === ContinueSentinel) {
17552 continue;
17553 }
17554
17555 return {
17556 value: record.arg,
17557 done: context.done
17558 };
17559 } else if (record.type === "throw") {
17560 state = GenStateCompleted; // Dispatch the exception by looping back around to the
17561 // context.dispatchException(context.arg) call above.
17562
17563 context.method = "throw";
17564 context.arg = record.arg;
17565 }
17566 }
17567 };
17568 } // Call delegate.iterator[context.method](context.arg) and handle the
17569 // result, either by returning a { value, done } result from the
17570 // delegate iterator, or by modifying context.method and context.arg,
17571 // setting context.delegate to null, and returning the ContinueSentinel.
17572
17573
17574 function maybeInvokeDelegate(delegate, context) {
17575 var method = delegate.iterator[context.method];
17576
17577 if (method === undefined) {
17578 // A .throw or .return when the delegate iterator has no .throw
17579 // method always terminates the yield* loop.
17580 context.delegate = null;
17581
17582 if (context.method === "throw") {
17583 // Note: ["return"] must be used for ES3 parsing compatibility.
17584 if (delegate.iterator["return"]) {
17585 // If the delegate iterator has a return method, give it a
17586 // chance to clean up.
17587 context.method = "return";
17588 context.arg = undefined;
17589 maybeInvokeDelegate(delegate, context);
17590
17591 if (context.method === "throw") {
17592 // If maybeInvokeDelegate(context) changed context.method from
17593 // "return" to "throw", let that override the TypeError below.
17594 return ContinueSentinel;
17595 }
17596 }
17597
17598 context.method = "throw";
17599 context.arg = new TypeError("The iterator does not provide a 'throw' method");
17600 }
17601
17602 return ContinueSentinel;
17603 }
17604
17605 var record = tryCatch(method, delegate.iterator, context.arg);
17606
17607 if (record.type === "throw") {
17608 context.method = "throw";
17609 context.arg = record.arg;
17610 context.delegate = null;
17611 return ContinueSentinel;
17612 }
17613
17614 var info = record.arg;
17615
17616 if (!info) {
17617 context.method = "throw";
17618 context.arg = new TypeError("iterator result is not an object");
17619 context.delegate = null;
17620 return ContinueSentinel;
17621 }
17622
17623 if (info.done) {
17624 // Assign the result of the finished delegate to the temporary
17625 // variable specified by delegate.resultName (see delegateYield).
17626 context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
17627
17628 context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
17629 // exception, let the outer generator proceed normally. If
17630 // context.method was "next", forget context.arg since it has been
17631 // "consumed" by the delegate iterator. If context.method was
17632 // "return", allow the original .return call to continue in the
17633 // outer generator.
17634
17635 if (context.method !== "return") {
17636 context.method = "next";
17637 context.arg = undefined;
17638 }
17639 } else {
17640 // Re-yield the result returned by the delegate method.
17641 return info;
17642 } // The delegate iterator is finished, so forget it and continue with
17643 // the outer generator.
17644
17645
17646 context.delegate = null;
17647 return ContinueSentinel;
17648 } // Define Generator.prototype.{next,throw,return} in terms of the
17649 // unified ._invoke helper method.
17650
17651
17652 defineIteratorMethods(Gp);
17653 define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
17654 // @@iterator function is called on it. Some browsers' implementations of the
17655 // iterator prototype chain incorrectly implement this, causing the Generator
17656 // object to not be returned from this call. This ensures that doesn't happen.
17657 // See https://github.com/facebook/regenerator/issues/274 for more details.
17658
17659 define(Gp, iteratorSymbol, function () {
17660 return this;
17661 });
17662 define(Gp, "toString", function () {
17663 return "[object Generator]";
17664 });
17665
17666 function pushTryEntry(locs) {
17667 var entry = {
17668 tryLoc: locs[0]
17669 };
17670
17671 if (1 in locs) {
17672 entry.catchLoc = locs[1];
17673 }
17674
17675 if (2 in locs) {
17676 entry.finallyLoc = locs[2];
17677 entry.afterLoc = locs[3];
17678 }
17679
17680 this.tryEntries.push(entry);
17681 }
17682
17683 function resetTryEntry(entry) {
17684 var record = entry.completion || {};
17685 record.type = "normal";
17686 delete record.arg;
17687 entry.completion = record;
17688 }
17689
17690 function Context(tryLocsList) {
17691 // The root entry object (effectively a try statement without a catch
17692 // or a finally block) gives us a place to store values thrown from
17693 // locations where there is no enclosing try statement.
17694 this.tryEntries = [{
17695 tryLoc: "root"
17696 }];
17697 tryLocsList.forEach(pushTryEntry, this);
17698 this.reset(true);
17699 }
17700
17701 exports.keys = function (object) {
17702 var keys = [];
17703
17704 for (var key in object) {
17705 keys.push(key);
17706 }
17707
17708 keys.reverse(); // Rather than returning an object with a next method, we keep
17709 // things simple and return the next function itself.
17710
17711 return function next() {
17712 while (keys.length) {
17713 var key = keys.pop();
17714
17715 if (key in object) {
17716 next.value = key;
17717 next.done = false;
17718 return next;
17719 }
17720 } // To avoid creating an additional object, we just hang the .value
17721 // and .done properties off the next function object itself. This
17722 // also ensures that the minifier will not anonymize the function.
17723
17724
17725 next.done = true;
17726 return next;
17727 };
17728 };
17729
17730 function values(iterable) {
17731 if (iterable) {
17732 var iteratorMethod = iterable[iteratorSymbol];
17733
17734 if (iteratorMethod) {
17735 return iteratorMethod.call(iterable);
17736 }
17737
17738 if (typeof iterable.next === "function") {
17739 return iterable;
17740 }
17741
17742 if (!isNaN(iterable.length)) {
17743 var i = -1,
17744 next = function next() {
17745 while (++i < iterable.length) {
17746 if (hasOwn.call(iterable, i)) {
17747 next.value = iterable[i];
17748 next.done = false;
17749 return next;
17750 }
17751 }
17752
17753 next.value = undefined;
17754 next.done = true;
17755 return next;
17756 };
17757
17758 return next.next = next;
17759 }
17760 } // Return an iterator with no values.
17761
17762
17763 return {
17764 next: doneResult
17765 };
17766 }
17767
17768 exports.values = values;
17769
17770 function doneResult() {
17771 return {
17772 value: undefined,
17773 done: true
17774 };
17775 }
17776
17777 Context.prototype = {
17778 constructor: Context,
17779 reset: function (skipTempReset) {
17780 this.prev = 0;
17781 this.next = 0; // Resetting context._sent for legacy support of Babel's
17782 // function.sent implementation.
17783
17784 this.sent = this._sent = undefined;
17785 this.done = false;
17786 this.delegate = null;
17787 this.method = "next";
17788 this.arg = undefined;
17789 this.tryEntries.forEach(resetTryEntry);
17790
17791 if (!skipTempReset) {
17792 for (var name in this) {
17793 // Not sure about the optimal order of these conditions:
17794 if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
17795 this[name] = undefined;
17796 }
17797 }
17798 }
17799 },
17800 stop: function () {
17801 this.done = true;
17802 var rootEntry = this.tryEntries[0];
17803 var rootRecord = rootEntry.completion;
17804
17805 if (rootRecord.type === "throw") {
17806 throw rootRecord.arg;
17807 }
17808
17809 return this.rval;
17810 },
17811 dispatchException: function (exception) {
17812 if (this.done) {
17813 throw exception;
17814 }
17815
17816 var context = this;
17817
17818 function handle(loc, caught) {
17819 record.type = "throw";
17820 record.arg = exception;
17821 context.next = loc;
17822
17823 if (caught) {
17824 // If the dispatched exception was caught by a catch block,
17825 // then let that catch block handle the exception normally.
17826 context.method = "next";
17827 context.arg = undefined;
17828 }
17829
17830 return !!caught;
17831 }
17832
17833 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
17834 var entry = this.tryEntries[i];
17835 var record = entry.completion;
17836
17837 if (entry.tryLoc === "root") {
17838 // Exception thrown outside of any try block that could handle
17839 // it, so set the completion value of the entire function to
17840 // throw the exception.
17841 return handle("end");
17842 }
17843
17844 if (entry.tryLoc <= this.prev) {
17845 var hasCatch = hasOwn.call(entry, "catchLoc");
17846 var hasFinally = hasOwn.call(entry, "finallyLoc");
17847
17848 if (hasCatch && hasFinally) {
17849 if (this.prev < entry.catchLoc) {
17850 return handle(entry.catchLoc, true);
17851 } else if (this.prev < entry.finallyLoc) {
17852 return handle(entry.finallyLoc);
17853 }
17854 } else if (hasCatch) {
17855 if (this.prev < entry.catchLoc) {
17856 return handle(entry.catchLoc, true);
17857 }
17858 } else if (hasFinally) {
17859 if (this.prev < entry.finallyLoc) {
17860 return handle(entry.finallyLoc);
17861 }
17862 } else {
17863 throw new Error("try statement without catch or finally");
17864 }
17865 }
17866 }
17867 },
17868 abrupt: function (type, arg) {
17869 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
17870 var entry = this.tryEntries[i];
17871
17872 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
17873 var finallyEntry = entry;
17874 break;
17875 }
17876 }
17877
17878 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
17879 // Ignore the finally entry if control is not jumping to a
17880 // location outside the try/catch block.
17881 finallyEntry = null;
17882 }
17883
17884 var record = finallyEntry ? finallyEntry.completion : {};
17885 record.type = type;
17886 record.arg = arg;
17887
17888 if (finallyEntry) {
17889 this.method = "next";
17890 this.next = finallyEntry.finallyLoc;
17891 return ContinueSentinel;
17892 }
17893
17894 return this.complete(record);
17895 },
17896 complete: function (record, afterLoc) {
17897 if (record.type === "throw") {
17898 throw record.arg;
17899 }
17900
17901 if (record.type === "break" || record.type === "continue") {
17902 this.next = record.arg;
17903 } else if (record.type === "return") {
17904 this.rval = this.arg = record.arg;
17905 this.method = "return";
17906 this.next = "end";
17907 } else if (record.type === "normal" && afterLoc) {
17908 this.next = afterLoc;
17909 }
17910
17911 return ContinueSentinel;
17912 },
17913 finish: function (finallyLoc) {
17914 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
17915 var entry = this.tryEntries[i];
17916
17917 if (entry.finallyLoc === finallyLoc) {
17918 this.complete(entry.completion, entry.afterLoc);
17919 resetTryEntry(entry);
17920 return ContinueSentinel;
17921 }
17922 }
17923 },
17924 "catch": function (tryLoc) {
17925 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
17926 var entry = this.tryEntries[i];
17927
17928 if (entry.tryLoc === tryLoc) {
17929 var record = entry.completion;
17930
17931 if (record.type === "throw") {
17932 var thrown = record.arg;
17933 resetTryEntry(entry);
17934 }
17935
17936 return thrown;
17937 }
17938 } // The context.catch method must only be called with a location
17939 // argument that corresponds to a known catch block.
17940
17941
17942 throw new Error("illegal catch attempt");
17943 },
17944 delegateYield: function (iterable, resultName, nextLoc) {
17945 this.delegate = {
17946 iterator: values(iterable),
17947 resultName: resultName,
17948 nextLoc: nextLoc
17949 };
17950
17951 if (this.method === "next") {
17952 // Deliberately forget the last sent value so that we don't
17953 // accidentally pass it on to the delegate.
17954 this.arg = undefined;
17955 }
17956
17957 return ContinueSentinel;
17958 }
17959 }; // Regardless of whether this script is executing as a CommonJS module
17960 // or not, return the runtime object so that we can declare the variable
17961 // regeneratorRuntime in the outer scope, which allows this module to be
17962 // injected easily by `bin/regenerator --include-runtime script.js`.
17963
17964 return exports;
17965 }( // If this script is executing as a CommonJS module, use module.exports
17966 // as the regeneratorRuntime namespace. Otherwise create a new empty
17967 // object. Either way, the resulting object will be used to initialize
17968 // the regeneratorRuntime variable at the top of this file.
17969 true ? module.exports : 0);
17970
17971 try {
17972 regeneratorRuntime = runtime;
17973 } catch (accidentalStrictMode) {
17974 // This module should not be running in strict mode, so the above
17975 // assignment should always work unless something is misconfigured. Just
17976 // in case runtime.js accidentally runs in strict mode, in modern engines
17977 // we can explicitly access globalThis. In older engines we can escape
17978 // strict mode using a global Function call. This could conceivably fail
17979 // if a Content Security Policy forbids using Function, but in that case
17980 // the proper solution is to fix the accidental strict mode problem. If
17981 // you've misconfigured your bundler to force strict mode and applied a
17982 // CSP to forbid Function, and you're not willing to fix either of those
17983 // problems, please detail your unique predicament in a GitHub issue.
17984 if (typeof globalThis === "object") {
17985 globalThis.regeneratorRuntime = runtime;
17986 } else {
17987 Function("r", "regeneratorRuntime = r")(runtime);
17988 }
17989 }
17990
17991 /***/ }),
17992 /* 428 */
17993 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
17994
17995 "use strict";
17996 /* provided dependency */ var process = __webpack_require__(494);
17997 /**
17998 * @fileoverview Main Linter Class
17999 * @author Gyandeep Singh
18000 * @author aladdin-add
18001 */
18002 //------------------------------------------------------------------------------
18003 // Requirements
18004 //------------------------------------------------------------------------------
18005
18006 const path = __webpack_require__(429),
18007 eslintScope = __webpack_require__(430),
18008 evk = __webpack_require__(435),
18009 espree = __webpack_require__(436),
18010 merge = __webpack_require__(442),
18011 pkg = __webpack_require__(443),
18012 astUtils = __webpack_require__(444),
18013 {
18014 Legacy: {
18015 ConfigOps,
18016 ConfigValidator,
18017 environments: BuiltInEnvironments
18018 }
18019 } = __webpack_require__(445),
18020 Traverser = __webpack_require__(495),
18021 {
18022 SourceCode
18023 } = __webpack_require__(499),
18024 CodePathAnalyzer = __webpack_require__(517),
18025 applyDisableDirectives = __webpack_require__(524),
18026 ConfigCommentParser = __webpack_require__(526),
18027 NodeEventGenerator = __webpack_require__(539),
18028 createReportTranslator = __webpack_require__(541),
18029 Rules = __webpack_require__(544),
18030 createEmitter = __webpack_require__(855),
18031 SourceCodeFixer = __webpack_require__(856),
18032 timing = __webpack_require__(857),
18033 ruleReplacements = __webpack_require__(858);
18034
18035 const debug = __webpack_require__(496)("eslint:linter");
18036
18037 const MAX_AUTOFIX_PASSES = 10;
18038 const DEFAULT_PARSER_NAME = "espree";
18039 const DEFAULT_ECMA_VERSION = 5;
18040 const commentParser = new ConfigCommentParser();
18041 const DEFAULT_ERROR_LOC = {
18042 start: {
18043 line: 1,
18044 column: 0
18045 },
18046 end: {
18047 line: 1,
18048 column: 1
18049 }
18050 };
18051 const parserSymbol = Symbol.for("eslint.RuleTester.parser"); //------------------------------------------------------------------------------
18052 // Typedefs
18053 //------------------------------------------------------------------------------
18054
18055 /** @typedef {InstanceType<import("../cli-engine/config-array").ConfigArray>} ConfigArray */
18056
18057 /** @typedef {InstanceType<import("../cli-engine/config-array").ExtractedConfig>} ExtractedConfig */
18058
18059 /** @typedef {import("../shared/types").ConfigData} ConfigData */
18060
18061 /** @typedef {import("../shared/types").Environment} Environment */
18062
18063 /** @typedef {import("../shared/types").GlobalConf} GlobalConf */
18064
18065 /** @typedef {import("../shared/types").LintMessage} LintMessage */
18066
18067 /** @typedef {import("../shared/types").ParserOptions} ParserOptions */
18068
18069 /** @typedef {import("../shared/types").Processor} Processor */
18070
18071 /** @typedef {import("../shared/types").Rule} Rule */
18072
18073 /* eslint-disable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/4#issuecomment-778805577 */
18074
18075 /**
18076 * @template T
18077 * @typedef {{ [P in keyof T]-?: T[P] }} Required
18078 */
18079
18080 /* eslint-enable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/4#issuecomment-778805577 */
18081
18082 /**
18083 * @typedef {Object} DisableDirective
18084 * @property {("disable"|"enable"|"disable-line"|"disable-next-line")} type Type of directive
18085 * @property {number} line The line number
18086 * @property {number} column The column number
18087 * @property {(string|null)} ruleId The rule ID
18088 */
18089
18090 /**
18091 * The private data for `Linter` instance.
18092 * @typedef {Object} LinterInternalSlots
18093 * @property {ConfigArray|null} lastConfigArray The `ConfigArray` instance that the last `verify()` call used.
18094 * @property {SourceCode|null} lastSourceCode The `SourceCode` instance that the last `verify()` call used.
18095 * @property {Map<string, Parser>} parserMap The loaded parsers.
18096 * @property {Rules} ruleMap The loaded rules.
18097 */
18098
18099 /**
18100 * @typedef {Object} VerifyOptions
18101 * @property {boolean} [allowInlineConfig] Allow/disallow inline comments' ability
18102 * to change config once it is set. Defaults to true if not supplied.
18103 * Useful if you want to validate JS without comments overriding rules.
18104 * @property {boolean} [disableFixes] if `true` then the linter doesn't make `fix`
18105 * properties into the lint result.
18106 * @property {string} [filename] the filename of the source code.
18107 * @property {boolean | "off" | "warn" | "error"} [reportUnusedDisableDirectives] Adds reported errors for
18108 * unused `eslint-disable` directives.
18109 */
18110
18111 /**
18112 * @typedef {Object} ProcessorOptions
18113 * @property {(filename:string, text:string) => boolean} [filterCodeBlock] the
18114 * predicate function that selects adopt code blocks.
18115 * @property {Processor.postprocess} [postprocess] postprocessor for report
18116 * messages. If provided, this should accept an array of the message lists
18117 * for each code block returned from the preprocessor, apply a mapping to
18118 * the messages as appropriate, and return a one-dimensional array of
18119 * messages.
18120 * @property {Processor.preprocess} [preprocess] preprocessor for source text.
18121 * If provided, this should accept a string of source text, and return an
18122 * array of code blocks to lint.
18123 */
18124
18125 /**
18126 * @typedef {Object} FixOptions
18127 * @property {boolean | ((message: LintMessage) => boolean)} [fix] Determines
18128 * whether fixes should be applied.
18129 */
18130
18131 /**
18132 * @typedef {Object} InternalOptions
18133 * @property {string | null} warnInlineConfig The config name what `noInlineConfig` setting came from. If `noInlineConfig` setting didn't exist, this is null. If this is a config name, then the linter warns directive comments.
18134 * @property {"off" | "warn" | "error"} reportUnusedDisableDirectives (boolean values were normalized)
18135 */
18136 //------------------------------------------------------------------------------
18137 // Helpers
18138 //------------------------------------------------------------------------------
18139
18140 /**
18141 * Ensures that variables representing built-in properties of the Global Object,
18142 * and any globals declared by special block comments, are present in the global
18143 * scope.
18144 * @param {Scope} globalScope The global scope.
18145 * @param {Object} configGlobals The globals declared in configuration
18146 * @param {{exportedVariables: Object, enabledGlobals: Object}} commentDirectives Directives from comment configuration
18147 * @returns {void}
18148 */
18149
18150 function addDeclaredGlobals(globalScope, configGlobals, _ref) {
18151 let {
18152 exportedVariables,
18153 enabledGlobals
18154 } = _ref;
18155
18156 // Define configured global variables.
18157 for (const id of new Set([...Object.keys(configGlobals), ...Object.keys(enabledGlobals)])) {
18158 /*
18159 * `ConfigOps.normalizeConfigGlobal` will throw an error if a configured global value is invalid. However, these errors would
18160 * typically be caught when validating a config anyway (validity for inline global comments is checked separately).
18161 */
18162 const configValue = configGlobals[id] === void 0 ? void 0 : ConfigOps.normalizeConfigGlobal(configGlobals[id]);
18163 const commentValue = enabledGlobals[id] && enabledGlobals[id].value;
18164 const value = commentValue || configValue;
18165 const sourceComments = enabledGlobals[id] && enabledGlobals[id].comments;
18166
18167 if (value === "off") {
18168 continue;
18169 }
18170
18171 let variable = globalScope.set.get(id);
18172
18173 if (!variable) {
18174 variable = new eslintScope.Variable(id, globalScope);
18175 globalScope.variables.push(variable);
18176 globalScope.set.set(id, variable);
18177 }
18178
18179 variable.eslintImplicitGlobalSetting = configValue;
18180 variable.eslintExplicitGlobal = sourceComments !== void 0;
18181 variable.eslintExplicitGlobalComments = sourceComments;
18182 variable.writeable = value === "writable";
18183 } // mark all exported variables as such
18184
18185
18186 Object.keys(exportedVariables).forEach(name => {
18187 const variable = globalScope.set.get(name);
18188
18189 if (variable) {
18190 variable.eslintUsed = true;
18191 }
18192 });
18193 /*
18194 * "through" contains all references which definitions cannot be found.
18195 * Since we augment the global scope using configuration, we need to update
18196 * references and remove the ones that were added by configuration.
18197 */
18198
18199 globalScope.through = globalScope.through.filter(reference => {
18200 const name = reference.identifier.name;
18201 const variable = globalScope.set.get(name);
18202
18203 if (variable) {
18204 /*
18205 * Links the variable and the reference.
18206 * And this reference is removed from `Scope#through`.
18207 */
18208 reference.resolved = variable;
18209 variable.references.push(reference);
18210 return false;
18211 }
18212
18213 return true;
18214 });
18215 }
18216 /**
18217 * creates a missing-rule message.
18218 * @param {string} ruleId the ruleId to create
18219 * @returns {string} created error message
18220 * @private
18221 */
18222
18223
18224 function createMissingRuleMessage(ruleId) {
18225 return Object.prototype.hasOwnProperty.call(ruleReplacements.rules, ruleId) ? "Rule '".concat(ruleId, "' was removed and replaced by: ").concat(ruleReplacements.rules[ruleId].join(", ")) : "Definition for rule '".concat(ruleId, "' was not found.");
18226 }
18227 /**
18228 * creates a linting problem
18229 * @param {Object} options to create linting error
18230 * @param {string} [options.ruleId] the ruleId to report
18231 * @param {Object} [options.loc] the loc to report
18232 * @param {string} [options.message] the error message to report
18233 * @param {string} [options.severity] the error message to report
18234 * @returns {LintMessage} created problem, returns a missing-rule problem if only provided ruleId.
18235 * @private
18236 */
18237
18238
18239 function createLintingProblem(options) {
18240 const {
18241 ruleId = null,
18242 loc = DEFAULT_ERROR_LOC,
18243 message = createMissingRuleMessage(options.ruleId),
18244 severity = 2
18245 } = options;
18246 return {
18247 ruleId,
18248 message,
18249 line: loc.start.line,
18250 column: loc.start.column + 1,
18251 endLine: loc.end.line,
18252 endColumn: loc.end.column + 1,
18253 severity,
18254 nodeType: null
18255 };
18256 }
18257 /**
18258 * Creates a collection of disable directives from a comment
18259 * @param {Object} options to create disable directives
18260 * @param {("disable"|"enable"|"disable-line"|"disable-next-line")} options.type The type of directive comment
18261 * @param {token} options.commentToken The Comment token
18262 * @param {string} options.value The value after the directive in the comment
18263 * comment specified no specific rules, so it applies to all rules (e.g. `eslint-disable`)
18264 * @param {function(string): {create: Function}} options.ruleMapper A map from rule IDs to defined rules
18265 * @returns {Object} Directives and problems from the comment
18266 */
18267
18268
18269 function createDisableDirectives(options) {
18270 const {
18271 commentToken,
18272 type,
18273 value,
18274 ruleMapper
18275 } = options;
18276 const ruleIds = Object.keys(commentParser.parseListConfig(value));
18277 const directiveRules = ruleIds.length ? ruleIds : [null];
18278 const result = {
18279 directives: [],
18280 // valid disable directives
18281 directiveProblems: [] // problems in directives
18282
18283 };
18284 const parentComment = {
18285 commentToken,
18286 ruleIds
18287 };
18288
18289 for (const ruleId of directiveRules) {
18290 // push to directives, if the rule is defined(including null, e.g. /*eslint enable*/)
18291 if (ruleId === null || ruleMapper(ruleId) !== null) {
18292 result.directives.push({
18293 parentComment,
18294 type,
18295 line: commentToken.loc.start.line,
18296 column: commentToken.loc.start.column + 1,
18297 ruleId
18298 });
18299 } else {
18300 result.directiveProblems.push(createLintingProblem({
18301 ruleId,
18302 loc: commentToken.loc
18303 }));
18304 }
18305 }
18306
18307 return result;
18308 }
18309 /**
18310 * Remove the ignored part from a given directive comment and trim it.
18311 * @param {string} value The comment text to strip.
18312 * @returns {string} The stripped text.
18313 */
18314
18315
18316 function stripDirectiveComment(value) {
18317 return value.split(/\s-{2,}\s/u)[0].trim();
18318 }
18319 /**
18320 * Parses comments in file to extract file-specific config of rules, globals
18321 * and environments and merges them with global config; also code blocks
18322 * where reporting is disabled or enabled and merges them with reporting config.
18323 * @param {string} filename The file being checked.
18324 * @param {ASTNode} ast The top node of the AST.
18325 * @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules
18326 * @param {string|null} warnInlineConfig If a string then it should warn directive comments as disabled. The string value is the config name what the setting came from.
18327 * @returns {{configuredRules: Object, enabledGlobals: {value:string,comment:Token}[], exportedVariables: Object, problems: Problem[], disableDirectives: DisableDirective[]}}
18328 * A collection of the directive comments that were found, along with any problems that occurred when parsing
18329 */
18330
18331
18332 function getDirectiveComments(filename, ast, ruleMapper, warnInlineConfig) {
18333 const configuredRules = {};
18334 const enabledGlobals = Object.create(null);
18335 const exportedVariables = {};
18336 const problems = [];
18337 const disableDirectives = [];
18338 const validator = new ConfigValidator({
18339 builtInRules: Rules
18340 });
18341 ast.comments.filter(token => token.type !== "Shebang").forEach(comment => {
18342 const trimmedCommentText = stripDirectiveComment(comment.value);
18343 const match = /^(eslint(?:-env|-enable|-disable(?:(?:-next)?-line)?)?|exported|globals?)(?:\s|$)/u.exec(trimmedCommentText);
18344
18345 if (!match) {
18346 return;
18347 }
18348
18349 const directiveText = match[1];
18350 const lineCommentSupported = /^eslint-disable-(next-)?line$/u.test(directiveText);
18351
18352 if (comment.type === "Line" && !lineCommentSupported) {
18353 return;
18354 }
18355
18356 if (warnInlineConfig) {
18357 const kind = comment.type === "Block" ? "/*".concat(directiveText, "*/") : "//".concat(directiveText);
18358 problems.push(createLintingProblem({
18359 ruleId: null,
18360 message: "'".concat(kind, "' has no effect because you have 'noInlineConfig' setting in ").concat(warnInlineConfig, "."),
18361 loc: comment.loc,
18362 severity: 1
18363 }));
18364 return;
18365 }
18366
18367 if (lineCommentSupported && comment.loc.start.line !== comment.loc.end.line) {
18368 const message = "".concat(directiveText, " comment should not span multiple lines.");
18369 problems.push(createLintingProblem({
18370 ruleId: null,
18371 message,
18372 loc: comment.loc
18373 }));
18374 return;
18375 }
18376
18377 const directiveValue = trimmedCommentText.slice(match.index + directiveText.length);
18378
18379 switch (directiveText) {
18380 case "eslint-disable":
18381 case "eslint-enable":
18382 case "eslint-disable-next-line":
18383 case "eslint-disable-line":
18384 {
18385 const directiveType = directiveText.slice("eslint-".length);
18386 const options = {
18387 commentToken: comment,
18388 type: directiveType,
18389 value: directiveValue,
18390 ruleMapper
18391 };
18392 const {
18393 directives,
18394 directiveProblems
18395 } = createDisableDirectives(options);
18396 disableDirectives.push(...directives);
18397 problems.push(...directiveProblems);
18398 break;
18399 }
18400
18401 case "exported":
18402 Object.assign(exportedVariables, commentParser.parseStringConfig(directiveValue, comment));
18403 break;
18404
18405 case "globals":
18406 case "global":
18407 for (const [id, {
18408 value
18409 }] of Object.entries(commentParser.parseStringConfig(directiveValue, comment))) {
18410 let normalizedValue;
18411
18412 try {
18413 normalizedValue = ConfigOps.normalizeConfigGlobal(value);
18414 } catch (err) {
18415 problems.push(createLintingProblem({
18416 ruleId: null,
18417 loc: comment.loc,
18418 message: err.message
18419 }));
18420 continue;
18421 }
18422
18423 if (enabledGlobals[id]) {
18424 enabledGlobals[id].comments.push(comment);
18425 enabledGlobals[id].value = normalizedValue;
18426 } else {
18427 enabledGlobals[id] = {
18428 comments: [comment],
18429 value: normalizedValue
18430 };
18431 }
18432 }
18433
18434 break;
18435
18436 case "eslint":
18437 {
18438 const parseResult = commentParser.parseJsonConfig(directiveValue, comment.loc);
18439
18440 if (parseResult.success) {
18441 Object.keys(parseResult.config).forEach(name => {
18442 const rule = ruleMapper(name);
18443 const ruleValue = parseResult.config[name];
18444
18445 if (rule === null) {
18446 problems.push(createLintingProblem({
18447 ruleId: name,
18448 loc: comment.loc
18449 }));
18450 return;
18451 }
18452
18453 try {
18454 validator.validateRuleOptions(rule, name, ruleValue);
18455 } catch (err) {
18456 problems.push(createLintingProblem({
18457 ruleId: name,
18458 message: err.message,
18459 loc: comment.loc
18460 })); // do not apply the config, if found invalid options.
18461
18462 return;
18463 }
18464
18465 configuredRules[name] = ruleValue;
18466 });
18467 } else {
18468 problems.push(parseResult.error);
18469 }
18470
18471 break;
18472 }
18473 // no default
18474 }
18475 });
18476 return {
18477 configuredRules,
18478 enabledGlobals,
18479 exportedVariables,
18480 problems,
18481 disableDirectives
18482 };
18483 }
18484 /**
18485 * Normalize ECMAScript version from the initial config
18486 * @param {Parser} parser The parser which uses this options.
18487 * @param {number} ecmaVersion ECMAScript version from the initial config
18488 * @returns {number} normalized ECMAScript version
18489 */
18490
18491
18492 function normalizeEcmaVersion(parser, ecmaVersion) {
18493 if ((parser[parserSymbol] || parser) === espree) {
18494 if (ecmaVersion === "latest") {
18495 return espree.latestEcmaVersion;
18496 }
18497 }
18498 /*
18499 * Calculate ECMAScript edition number from official year version starting with
18500 * ES2015, which corresponds with ES6 (or a difference of 2009).
18501 */
18502
18503
18504 return ecmaVersion >= 2015 ? ecmaVersion - 2009 : ecmaVersion;
18505 }
18506
18507 const eslintEnvPattern = /\/\*\s*eslint-env\s(.+?)(?:\*\/|$)/gsu;
18508 /**
18509 * Checks whether or not there is a comment which has "eslint-env *" in a given text.
18510 * @param {string} text A source code text to check.
18511 * @returns {Object|null} A result of parseListConfig() with "eslint-env *" comment.
18512 */
18513
18514 function findEslintEnv(text) {
18515 let match, retv;
18516 eslintEnvPattern.lastIndex = 0;
18517
18518 while ((match = eslintEnvPattern.exec(text)) !== null) {
18519 if (match[0].endsWith("*/")) {
18520 retv = Object.assign(retv || {}, commentParser.parseListConfig(stripDirectiveComment(match[1])));
18521 }
18522 }
18523
18524 return retv;
18525 }
18526 /**
18527 * Convert "/path/to/<text>" to "<text>".
18528 * `CLIEngine#executeOnText()` method gives "/path/to/<text>" if the filename
18529 * was omitted because `configArray.extractConfig()` requires an absolute path.
18530 * But the linter should pass `<text>` to `RuleContext#getFilename()` in that
18531 * case.
18532 * Also, code blocks can have their virtual filename. If the parent filename was
18533 * `<text>`, the virtual filename is `<text>/0_foo.js` or something like (i.e.,
18534 * it's not an absolute path).
18535 * @param {string} filename The filename to normalize.
18536 * @returns {string} The normalized filename.
18537 */
18538
18539
18540 function normalizeFilename(filename) {
18541 const parts = filename.split(path.sep);
18542 const index = parts.lastIndexOf("<text>");
18543 return index === -1 ? filename : parts.slice(index).join(path.sep);
18544 }
18545 /**
18546 * Normalizes the possible options for `linter.verify` and `linter.verifyAndFix` to a
18547 * consistent shape.
18548 * @param {VerifyOptions} providedOptions Options
18549 * @param {ConfigData} config Config.
18550 * @returns {Required<VerifyOptions> & InternalOptions} Normalized options
18551 */
18552
18553
18554 function normalizeVerifyOptions(providedOptions, config) {
18555 const disableInlineConfig = config.noInlineConfig === true;
18556 const ignoreInlineConfig = providedOptions.allowInlineConfig === false;
18557 const configNameOfNoInlineConfig = config.configNameOfNoInlineConfig ? " (".concat(config.configNameOfNoInlineConfig, ")") : "";
18558 let reportUnusedDisableDirectives = providedOptions.reportUnusedDisableDirectives;
18559
18560 if (typeof reportUnusedDisableDirectives === "boolean") {
18561 reportUnusedDisableDirectives = reportUnusedDisableDirectives ? "error" : "off";
18562 }
18563
18564 if (typeof reportUnusedDisableDirectives !== "string") {
18565 reportUnusedDisableDirectives = config.reportUnusedDisableDirectives ? "warn" : "off";
18566 }
18567
18568 return {
18569 filename: normalizeFilename(providedOptions.filename || "<input>"),
18570 allowInlineConfig: !ignoreInlineConfig,
18571 warnInlineConfig: disableInlineConfig && !ignoreInlineConfig ? "your config".concat(configNameOfNoInlineConfig) : null,
18572 reportUnusedDisableDirectives,
18573 disableFixes: Boolean(providedOptions.disableFixes)
18574 };
18575 }
18576 /**
18577 * Combines the provided parserOptions with the options from environments
18578 * @param {Parser} parser The parser which uses this options.
18579 * @param {ParserOptions} providedOptions The provided 'parserOptions' key in a config
18580 * @param {Environment[]} enabledEnvironments The environments enabled in configuration and with inline comments
18581 * @returns {ParserOptions} Resulting parser options after merge
18582 */
18583
18584
18585 function resolveParserOptions(parser, providedOptions, enabledEnvironments) {
18586 const parserOptionsFromEnv = enabledEnvironments.filter(env => env.parserOptions).reduce((parserOptions, env) => merge(parserOptions, env.parserOptions), {});
18587 const mergedParserOptions = merge(parserOptionsFromEnv, providedOptions || {});
18588 const isModule = mergedParserOptions.sourceType === "module";
18589
18590 if (isModule) {
18591 /*
18592 * can't have global return inside of modules
18593 * TODO: espree validate parserOptions.globalReturn when sourceType is setting to module.(@aladdin-add)
18594 */
18595 mergedParserOptions.ecmaFeatures = Object.assign({}, mergedParserOptions.ecmaFeatures, {
18596 globalReturn: false
18597 });
18598 }
18599
18600 mergedParserOptions.ecmaVersion = normalizeEcmaVersion(parser, mergedParserOptions.ecmaVersion);
18601 return mergedParserOptions;
18602 }
18603 /**
18604 * Combines the provided globals object with the globals from environments
18605 * @param {Record<string, GlobalConf>} providedGlobals The 'globals' key in a config
18606 * @param {Environment[]} enabledEnvironments The environments enabled in configuration and with inline comments
18607 * @returns {Record<string, GlobalConf>} The resolved globals object
18608 */
18609
18610
18611 function resolveGlobals(providedGlobals, enabledEnvironments) {
18612 return Object.assign({}, ...enabledEnvironments.filter(env => env.globals).map(env => env.globals), providedGlobals);
18613 }
18614 /**
18615 * Strips Unicode BOM from a given text.
18616 * @param {string} text A text to strip.
18617 * @returns {string} The stripped text.
18618 */
18619
18620
18621 function stripUnicodeBOM(text) {
18622 /*
18623 * Check Unicode BOM.
18624 * In JavaScript, string data is stored as UTF-16, so BOM is 0xFEFF.
18625 * http://www.ecma-international.org/ecma-262/6.0/#sec-unicode-format-control-characters
18626 */
18627 if (text.charCodeAt(0) === 0xFEFF) {
18628 return text.slice(1);
18629 }
18630
18631 return text;
18632 }
18633 /**
18634 * Get the options for a rule (not including severity), if any
18635 * @param {Array|number} ruleConfig rule configuration
18636 * @returns {Array} of rule options, empty Array if none
18637 */
18638
18639
18640 function getRuleOptions(ruleConfig) {
18641 if (Array.isArray(ruleConfig)) {
18642 return ruleConfig.slice(1);
18643 }
18644
18645 return [];
18646 }
18647 /**
18648 * Analyze scope of the given AST.
18649 * @param {ASTNode} ast The `Program` node to analyze.
18650 * @param {ParserOptions} parserOptions The parser options.
18651 * @param {Record<string, string[]>} visitorKeys The visitor keys.
18652 * @returns {ScopeManager} The analysis result.
18653 */
18654
18655
18656 function analyzeScope(ast, parserOptions, visitorKeys) {
18657 const ecmaFeatures = parserOptions.ecmaFeatures || {};
18658 const ecmaVersion = parserOptions.ecmaVersion || DEFAULT_ECMA_VERSION;
18659 return eslintScope.analyze(ast, {
18660 ignoreEval: true,
18661 nodejsScope: ecmaFeatures.globalReturn,
18662 impliedStrict: ecmaFeatures.impliedStrict,
18663 ecmaVersion: typeof ecmaVersion === "number" ? ecmaVersion : 6,
18664 sourceType: parserOptions.sourceType || "script",
18665 childVisitorKeys: visitorKeys || evk.KEYS,
18666 fallback: Traverser.getKeys
18667 });
18668 }
18669 /**
18670 * Parses text into an AST. Moved out here because the try-catch prevents
18671 * optimization of functions, so it's best to keep the try-catch as isolated
18672 * as possible
18673 * @param {string} text The text to parse.
18674 * @param {Parser} parser The parser to parse.
18675 * @param {ParserOptions} providedParserOptions Options to pass to the parser
18676 * @param {string} filePath The path to the file being parsed.
18677 * @returns {{success: false, error: Problem}|{success: true, sourceCode: SourceCode}}
18678 * An object containing the AST and parser services if parsing was successful, or the error if parsing failed
18679 * @private
18680 */
18681
18682
18683 function parse(text, parser, providedParserOptions, filePath) {
18684 const textToParse = stripUnicodeBOM(text).replace(astUtils.shebangPattern, (match, captured) => "//".concat(captured));
18685 const parserOptions = Object.assign({}, providedParserOptions, {
18686 loc: true,
18687 range: true,
18688 raw: true,
18689 tokens: true,
18690 comment: true,
18691 eslintVisitorKeys: true,
18692 eslintScopeManager: true,
18693 filePath
18694 });
18695 /*
18696 * Check for parsing errors first. If there's a parsing error, nothing
18697 * else can happen. However, a parsing error does not throw an error
18698 * from this method - it's just considered a fatal error message, a
18699 * problem that ESLint identified just like any other.
18700 */
18701
18702 try {
18703 const parseResult = typeof parser.parseForESLint === "function" ? parser.parseForESLint(textToParse, parserOptions) : {
18704 ast: parser.parse(textToParse, parserOptions)
18705 };
18706 const ast = parseResult.ast;
18707 const parserServices = parseResult.services || {};
18708 const visitorKeys = parseResult.visitorKeys || evk.KEYS;
18709 const scopeManager = parseResult.scopeManager || analyzeScope(ast, parserOptions, visitorKeys);
18710 return {
18711 success: true,
18712
18713 /*
18714 * Save all values that `parseForESLint()` returned.
18715 * If a `SourceCode` object is given as the first parameter instead of source code text,
18716 * linter skips the parsing process and reuses the source code object.
18717 * In that case, linter needs all the values that `parseForESLint()` returned.
18718 */
18719 sourceCode: new SourceCode({
18720 text,
18721 ast,
18722 parserServices,
18723 scopeManager,
18724 visitorKeys
18725 })
18726 };
18727 } catch (ex) {
18728 // If the message includes a leading line number, strip it:
18729 const message = "Parsing error: ".concat(ex.message.replace(/^line \d+:/iu, "").trim());
18730 debug("%s\n%s", message, ex.stack);
18731 return {
18732 success: false,
18733 error: {
18734 ruleId: null,
18735 fatal: true,
18736 severity: 2,
18737 message,
18738 line: ex.lineNumber,
18739 column: ex.column
18740 }
18741 };
18742 }
18743 }
18744 /**
18745 * Gets the scope for the current node
18746 * @param {ScopeManager} scopeManager The scope manager for this AST
18747 * @param {ASTNode} currentNode The node to get the scope of
18748 * @returns {eslint-scope.Scope} The scope information for this node
18749 */
18750
18751
18752 function getScope(scopeManager, currentNode) {
18753 // On Program node, get the outermost scope to avoid return Node.js special function scope or ES modules scope.
18754 const inner = currentNode.type !== "Program";
18755
18756 for (let node = currentNode; node; node = node.parent) {
18757 const scope = scopeManager.acquire(node, inner);
18758
18759 if (scope) {
18760 if (scope.type === "function-expression-name") {
18761 return scope.childScopes[0];
18762 }
18763
18764 return scope;
18765 }
18766 }
18767
18768 return scopeManager.scopes[0];
18769 }
18770 /**
18771 * Marks a variable as used in the current scope
18772 * @param {ScopeManager} scopeManager The scope manager for this AST. The scope may be mutated by this function.
18773 * @param {ASTNode} currentNode The node currently being traversed
18774 * @param {Object} parserOptions The options used to parse this text
18775 * @param {string} name The name of the variable that should be marked as used.
18776 * @returns {boolean} True if the variable was found and marked as used, false if not.
18777 */
18778
18779
18780 function markVariableAsUsed(scopeManager, currentNode, parserOptions, name) {
18781 const hasGlobalReturn = parserOptions.ecmaFeatures && parserOptions.ecmaFeatures.globalReturn;
18782 const specialScope = hasGlobalReturn || parserOptions.sourceType === "module";
18783 const currentScope = getScope(scopeManager, currentNode); // Special Node.js scope means we need to start one level deeper
18784
18785 const initialScope = currentScope.type === "global" && specialScope ? currentScope.childScopes[0] : currentScope;
18786
18787 for (let scope = initialScope; scope; scope = scope.upper) {
18788 const variable = scope.variables.find(scopeVar => scopeVar.name === name);
18789
18790 if (variable) {
18791 variable.eslintUsed = true;
18792 return true;
18793 }
18794 }
18795
18796 return false;
18797 }
18798 /**
18799 * Runs a rule, and gets its listeners
18800 * @param {Rule} rule A normalized rule with a `create` method
18801 * @param {Context} ruleContext The context that should be passed to the rule
18802 * @throws {any} Any error during the rule's `create`
18803 * @returns {Object} A map of selector listeners provided by the rule
18804 */
18805
18806
18807 function createRuleListeners(rule, ruleContext) {
18808 try {
18809 return rule.create(ruleContext);
18810 } catch (ex) {
18811 ex.message = "Error while loading rule '".concat(ruleContext.id, "': ").concat(ex.message);
18812 throw ex;
18813 }
18814 }
18815 /**
18816 * Gets all the ancestors of a given node
18817 * @param {ASTNode} node The node
18818 * @returns {ASTNode[]} All the ancestor nodes in the AST, not including the provided node, starting
18819 * from the root node and going inwards to the parent node.
18820 */
18821
18822
18823 function getAncestors(node) {
18824 const ancestorsStartingAtParent = [];
18825
18826 for (let ancestor = node.parent; ancestor; ancestor = ancestor.parent) {
18827 ancestorsStartingAtParent.push(ancestor);
18828 }
18829
18830 return ancestorsStartingAtParent.reverse();
18831 } // methods that exist on SourceCode object
18832
18833
18834 const DEPRECATED_SOURCECODE_PASSTHROUGHS = {
18835 getSource: "getText",
18836 getSourceLines: "getLines",
18837 getAllComments: "getAllComments",
18838 getNodeByRangeIndex: "getNodeByRangeIndex",
18839 getComments: "getComments",
18840 getCommentsBefore: "getCommentsBefore",
18841 getCommentsAfter: "getCommentsAfter",
18842 getCommentsInside: "getCommentsInside",
18843 getJSDocComment: "getJSDocComment",
18844 getFirstToken: "getFirstToken",
18845 getFirstTokens: "getFirstTokens",
18846 getLastToken: "getLastToken",
18847 getLastTokens: "getLastTokens",
18848 getTokenAfter: "getTokenAfter",
18849 getTokenBefore: "getTokenBefore",
18850 getTokenByRangeStart: "getTokenByRangeStart",
18851 getTokens: "getTokens",
18852 getTokensAfter: "getTokensAfter",
18853 getTokensBefore: "getTokensBefore",
18854 getTokensBetween: "getTokensBetween"
18855 };
18856 const BASE_TRAVERSAL_CONTEXT = Object.freeze(Object.keys(DEPRECATED_SOURCECODE_PASSTHROUGHS).reduce((contextInfo, methodName) => Object.assign(contextInfo, {
18857 [methodName]() {
18858 return this.getSourceCode()[DEPRECATED_SOURCECODE_PASSTHROUGHS[methodName]](...arguments);
18859 }
18860
18861 }), {}));
18862 /**
18863 * Runs the given rules on the given SourceCode object
18864 * @param {SourceCode} sourceCode A SourceCode object for the given text
18865 * @param {Object} configuredRules The rules configuration
18866 * @param {function(string): Rule} ruleMapper A mapper function from rule names to rules
18867 * @param {Object} parserOptions The options that were passed to the parser
18868 * @param {string} parserName The name of the parser in the config
18869 * @param {Object} settings The settings that were enabled in the config
18870 * @param {string} filename The reported filename of the code
18871 * @param {boolean} disableFixes If true, it doesn't make `fix` properties.
18872 * @param {string | undefined} cwd cwd of the cli
18873 * @param {string} physicalFilename The full path of the file on disk without any code block information
18874 * @returns {Problem[]} An array of reported problems
18875 */
18876
18877 function runRules(sourceCode, configuredRules, ruleMapper, parserOptions, parserName, settings, filename, disableFixes, cwd, physicalFilename) {
18878 const emitter = createEmitter();
18879 const nodeQueue = [];
18880 let currentNode = sourceCode.ast;
18881 Traverser.traverse(sourceCode.ast, {
18882 enter(node, parent) {
18883 node.parent = parent;
18884 nodeQueue.push({
18885 isEntering: true,
18886 node
18887 });
18888 },
18889
18890 leave(node) {
18891 nodeQueue.push({
18892 isEntering: false,
18893 node
18894 });
18895 },
18896
18897 visitorKeys: sourceCode.visitorKeys
18898 });
18899 /*
18900 * Create a frozen object with the ruleContext properties and methods that are shared by all rules.
18901 * All rule contexts will inherit from this object. This avoids the performance penalty of copying all the
18902 * properties once for each rule.
18903 */
18904
18905 const sharedTraversalContext = Object.freeze(Object.assign(Object.create(BASE_TRAVERSAL_CONTEXT), {
18906 getAncestors: () => getAncestors(currentNode),
18907 getDeclaredVariables: sourceCode.scopeManager.getDeclaredVariables.bind(sourceCode.scopeManager),
18908 getCwd: () => cwd,
18909 getFilename: () => filename,
18910 getPhysicalFilename: () => physicalFilename || filename,
18911 getScope: () => getScope(sourceCode.scopeManager, currentNode),
18912 getSourceCode: () => sourceCode,
18913 markVariableAsUsed: name => markVariableAsUsed(sourceCode.scopeManager, currentNode, parserOptions, name),
18914 parserOptions,
18915 parserPath: parserName,
18916 parserServices: sourceCode.parserServices,
18917 settings
18918 }));
18919 const lintingProblems = [];
18920 Object.keys(configuredRules).forEach(ruleId => {
18921 const severity = ConfigOps.getRuleSeverity(configuredRules[ruleId]); // not load disabled rules
18922
18923 if (severity === 0) {
18924 return;
18925 }
18926
18927 const rule = ruleMapper(ruleId);
18928
18929 if (rule === null) {
18930 lintingProblems.push(createLintingProblem({
18931 ruleId
18932 }));
18933 return;
18934 }
18935
18936 const messageIds = rule.meta && rule.meta.messages;
18937 let reportTranslator = null;
18938 const ruleContext = Object.freeze(Object.assign(Object.create(sharedTraversalContext), {
18939 id: ruleId,
18940 options: getRuleOptions(configuredRules[ruleId]),
18941
18942 report() {
18943 /*
18944 * Create a report translator lazily.
18945 * In a vast majority of cases, any given rule reports zero errors on a given
18946 * piece of code. Creating a translator lazily avoids the performance cost of
18947 * creating a new translator function for each rule that usually doesn't get
18948 * called.
18949 *
18950 * Using lazy report translators improves end-to-end performance by about 3%
18951 * with Node 8.4.0.
18952 */
18953 if (reportTranslator === null) {
18954 reportTranslator = createReportTranslator({
18955 ruleId,
18956 severity,
18957 sourceCode,
18958 messageIds,
18959 disableFixes
18960 });
18961 }
18962
18963 const problem = reportTranslator(...arguments);
18964
18965 if (problem.fix && !(rule.meta && rule.meta.fixable)) {
18966 throw new Error("Fixable rules must set the `meta.fixable` property to \"code\" or \"whitespace\".");
18967 }
18968
18969 if (problem.suggestions && !(rule.meta && rule.meta.hasSuggestions === true)) {
18970 if (rule.meta && rule.meta.docs && typeof rule.meta.docs.suggestion !== "undefined") {
18971 // Encourage migration from the former property name.
18972 throw new Error("Rules with suggestions must set the `meta.hasSuggestions` property to `true`. `meta.docs.suggestion` is ignored by ESLint.");
18973 }
18974
18975 throw new Error("Rules with suggestions must set the `meta.hasSuggestions` property to `true`.");
18976 }
18977
18978 lintingProblems.push(problem);
18979 }
18980
18981 }));
18982 const ruleListeners = createRuleListeners(rule, ruleContext);
18983 /**
18984 * Include `ruleId` in error logs
18985 * @param {Function} ruleListener A rule method that listens for a node.
18986 * @returns {Function} ruleListener wrapped in error handler
18987 */
18988
18989 function addRuleErrorHandler(ruleListener) {
18990 return function ruleErrorHandler() {
18991 try {
18992 return ruleListener(...arguments);
18993 } catch (e) {
18994 e.ruleId = ruleId;
18995 throw e;
18996 }
18997 };
18998 } // add all the selectors from the rule as listeners
18999
19000
19001 Object.keys(ruleListeners).forEach(selector => {
19002 const ruleListener = timing.enabled ? timing.time(ruleId, ruleListeners[selector]) : ruleListeners[selector];
19003 emitter.on(selector, addRuleErrorHandler(ruleListener));
19004 });
19005 }); // only run code path analyzer if the top level node is "Program", skip otherwise
19006
19007 const eventGenerator = nodeQueue[0].node.type === "Program" ? new CodePathAnalyzer(new NodeEventGenerator(emitter, {
19008 visitorKeys: sourceCode.visitorKeys,
19009 fallback: Traverser.getKeys
19010 })) : new NodeEventGenerator(emitter, {
19011 visitorKeys: sourceCode.visitorKeys,
19012 fallback: Traverser.getKeys
19013 });
19014 nodeQueue.forEach(traversalInfo => {
19015 currentNode = traversalInfo.node;
19016
19017 try {
19018 if (traversalInfo.isEntering) {
19019 eventGenerator.enterNode(currentNode);
19020 } else {
19021 eventGenerator.leaveNode(currentNode);
19022 }
19023 } catch (err) {
19024 err.currentNode = currentNode;
19025 throw err;
19026 }
19027 });
19028 return lintingProblems;
19029 }
19030 /**
19031 * Ensure the source code to be a string.
19032 * @param {string|SourceCode} textOrSourceCode The text or source code object.
19033 * @returns {string} The source code text.
19034 */
19035
19036
19037 function ensureText(textOrSourceCode) {
19038 if (typeof textOrSourceCode === "object") {
19039 const {
19040 hasBOM,
19041 text
19042 } = textOrSourceCode;
19043 const bom = hasBOM ? "\uFEFF" : "";
19044 return bom + text;
19045 }
19046
19047 return String(textOrSourceCode);
19048 }
19049 /**
19050 * Get an environment.
19051 * @param {LinterInternalSlots} slots The internal slots of Linter.
19052 * @param {string} envId The environment ID to get.
19053 * @returns {Environment|null} The environment.
19054 */
19055
19056
19057 function getEnv(slots, envId) {
19058 return slots.lastConfigArray && slots.lastConfigArray.pluginEnvironments.get(envId) || BuiltInEnvironments.get(envId) || null;
19059 }
19060 /**
19061 * Get a rule.
19062 * @param {LinterInternalSlots} slots The internal slots of Linter.
19063 * @param {string} ruleId The rule ID to get.
19064 * @returns {Rule|null} The rule.
19065 */
19066
19067
19068 function getRule(slots, ruleId) {
19069 return slots.lastConfigArray && slots.lastConfigArray.pluginRules.get(ruleId) || slots.ruleMap.get(ruleId);
19070 }
19071 /**
19072 * Normalize the value of the cwd
19073 * @param {string | undefined} cwd raw value of the cwd, path to a directory that should be considered as the current working directory, can be undefined.
19074 * @returns {string | undefined} normalized cwd
19075 */
19076
19077
19078 function normalizeCwd(cwd) {
19079 if (cwd) {
19080 return cwd;
19081 }
19082
19083 if (typeof process === "object") {
19084 return process.cwd();
19085 } // It's more explicit to assign the undefined
19086 // eslint-disable-next-line no-undefined -- Consistently returning a value
19087
19088
19089 return undefined;
19090 }
19091 /**
19092 * The map to store private data.
19093 * @type {WeakMap<Linter, LinterInternalSlots>}
19094 */
19095
19096
19097 const internalSlotsMap = new WeakMap(); //------------------------------------------------------------------------------
19098 // Public Interface
19099 //------------------------------------------------------------------------------
19100
19101 /**
19102 * Object that is responsible for verifying JavaScript text
19103 * @name eslint
19104 */
19105
19106 class Linter {
19107 /**
19108 * Initialize the Linter.
19109 * @param {Object} [config] the config object
19110 * @param {string} [config.cwd] path to a directory that should be considered as the current working directory, can be undefined.
19111 */
19112 constructor() {
19113 let {
19114 cwd
19115 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
19116 internalSlotsMap.set(this, {
19117 cwd: normalizeCwd(cwd),
19118 lastConfigArray: null,
19119 lastSourceCode: null,
19120 parserMap: new Map([["espree", espree]]),
19121 ruleMap: new Rules()
19122 });
19123 this.version = pkg.version;
19124 }
19125 /**
19126 * Getter for package version.
19127 * @static
19128 * @returns {string} The version from package.json.
19129 */
19130
19131
19132 static get version() {
19133 return pkg.version;
19134 }
19135 /**
19136 * Same as linter.verify, except without support for processors.
19137 * @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object.
19138 * @param {ConfigData} providedConfig An ESLintConfig instance to configure everything.
19139 * @param {VerifyOptions} [providedOptions] The optional filename of the file being checked.
19140 * @throws {Error} If during rule execution.
19141 * @returns {LintMessage[]} The results as an array of messages or an empty array if no messages.
19142 */
19143
19144
19145 _verifyWithoutProcessors(textOrSourceCode, providedConfig, providedOptions) {
19146 const slots = internalSlotsMap.get(this);
19147 const config = providedConfig || {};
19148 const options = normalizeVerifyOptions(providedOptions, config);
19149 let text; // evaluate arguments
19150
19151 if (typeof textOrSourceCode === "string") {
19152 slots.lastSourceCode = null;
19153 text = textOrSourceCode;
19154 } else {
19155 slots.lastSourceCode = textOrSourceCode;
19156 text = textOrSourceCode.text;
19157 } // Resolve parser.
19158
19159
19160 let parserName = DEFAULT_PARSER_NAME;
19161 let parser = espree;
19162
19163 if (typeof config.parser === "object" && config.parser !== null) {
19164 parserName = config.parser.filePath;
19165 parser = config.parser.definition;
19166 } else if (typeof config.parser === "string") {
19167 if (!slots.parserMap.has(config.parser)) {
19168 return [{
19169 ruleId: null,
19170 fatal: true,
19171 severity: 2,
19172 message: "Configured parser '".concat(config.parser, "' was not found."),
19173 line: 0,
19174 column: 0
19175 }];
19176 }
19177
19178 parserName = config.parser;
19179 parser = slots.parserMap.get(config.parser);
19180 } // search and apply "eslint-env *".
19181
19182
19183 const envInFile = options.allowInlineConfig && !options.warnInlineConfig ? findEslintEnv(text) : {};
19184 const resolvedEnvConfig = Object.assign({
19185 builtin: true
19186 }, config.env, envInFile);
19187 const enabledEnvs = Object.keys(resolvedEnvConfig).filter(envName => resolvedEnvConfig[envName]).map(envName => getEnv(slots, envName)).filter(env => env);
19188 const parserOptions = resolveParserOptions(parser, config.parserOptions || {}, enabledEnvs);
19189 const configuredGlobals = resolveGlobals(config.globals || {}, enabledEnvs);
19190 const settings = config.settings || {};
19191
19192 if (!slots.lastSourceCode) {
19193 const parseResult = parse(text, parser, parserOptions, options.filename);
19194
19195 if (!parseResult.success) {
19196 return [parseResult.error];
19197 }
19198
19199 slots.lastSourceCode = parseResult.sourceCode;
19200 } else {
19201 /*
19202 * If the given source code object as the first argument does not have scopeManager, analyze the scope.
19203 * This is for backward compatibility (SourceCode is frozen so it cannot rebind).
19204 */
19205 if (!slots.lastSourceCode.scopeManager) {
19206 slots.lastSourceCode = new SourceCode({
19207 text: slots.lastSourceCode.text,
19208 ast: slots.lastSourceCode.ast,
19209 parserServices: slots.lastSourceCode.parserServices,
19210 visitorKeys: slots.lastSourceCode.visitorKeys,
19211 scopeManager: analyzeScope(slots.lastSourceCode.ast, parserOptions)
19212 });
19213 }
19214 }
19215
19216 const sourceCode = slots.lastSourceCode;
19217 const commentDirectives = options.allowInlineConfig ? getDirectiveComments(options.filename, sourceCode.ast, ruleId => getRule(slots, ruleId), options.warnInlineConfig) : {
19218 configuredRules: {},
19219 enabledGlobals: {},
19220 exportedVariables: {},
19221 problems: [],
19222 disableDirectives: []
19223 }; // augment global scope with declared global variables
19224
19225 addDeclaredGlobals(sourceCode.scopeManager.scopes[0], configuredGlobals, {
19226 exportedVariables: commentDirectives.exportedVariables,
19227 enabledGlobals: commentDirectives.enabledGlobals
19228 });
19229 const configuredRules = Object.assign({}, config.rules, commentDirectives.configuredRules);
19230 let lintingProblems;
19231
19232 try {
19233 lintingProblems = runRules(sourceCode, configuredRules, ruleId => getRule(slots, ruleId), parserOptions, parserName, settings, options.filename, options.disableFixes, slots.cwd, providedOptions.physicalFilename);
19234 } catch (err) {
19235 err.message += "\nOccurred while linting ".concat(options.filename);
19236 debug("An error occurred while traversing");
19237 debug("Filename:", options.filename);
19238
19239 if (err.currentNode) {
19240 const {
19241 line
19242 } = err.currentNode.loc.start;
19243 debug("Line:", line);
19244 err.message += ":".concat(line);
19245 }
19246
19247 debug("Parser Options:", parserOptions);
19248 debug("Parser Path:", parserName);
19249 debug("Settings:", settings);
19250
19251 if (err.ruleId) {
19252 err.message += "\nRule: \"".concat(err.ruleId, "\"");
19253 }
19254
19255 throw err;
19256 }
19257
19258 return applyDisableDirectives({
19259 directives: commentDirectives.disableDirectives,
19260 disableFixes: options.disableFixes,
19261 problems: lintingProblems.concat(commentDirectives.problems).sort((problemA, problemB) => problemA.line - problemB.line || problemA.column - problemB.column),
19262 reportUnusedDisableDirectives: options.reportUnusedDisableDirectives
19263 });
19264 }
19265 /**
19266 * Verifies the text against the rules specified by the second argument.
19267 * @param {string|SourceCode} textOrSourceCode The text to parse or a SourceCode object.
19268 * @param {ConfigData|ConfigArray} config An ESLintConfig instance to configure everything.
19269 * @param {(string|(VerifyOptions&ProcessorOptions))} [filenameOrOptions] The optional filename of the file being checked.
19270 * If this is not set, the filename will default to '<input>' in the rule context. If
19271 * an object, then it has "filename", "allowInlineConfig", and some properties.
19272 * @returns {LintMessage[]} The results as an array of messages or an empty array if no messages.
19273 */
19274
19275
19276 verify(textOrSourceCode, config, filenameOrOptions) {
19277 debug("Verify");
19278 const options = typeof filenameOrOptions === "string" ? {
19279 filename: filenameOrOptions
19280 } : filenameOrOptions || {}; // CLIEngine passes a `ConfigArray` object.
19281
19282 if (config && typeof config.extractConfig === "function") {
19283 return this._verifyWithConfigArray(textOrSourceCode, config, options);
19284 }
19285 /*
19286 * `Linter` doesn't support `overrides` property in configuration.
19287 * So we cannot apply multiple processors.
19288 */
19289
19290
19291 if (options.preprocess || options.postprocess) {
19292 return this._verifyWithProcessor(textOrSourceCode, config, options);
19293 }
19294
19295 return this._verifyWithoutProcessors(textOrSourceCode, config, options);
19296 }
19297 /**
19298 * Verify a given code with `ConfigArray`.
19299 * @param {string|SourceCode} textOrSourceCode The source code.
19300 * @param {ConfigArray} configArray The config array.
19301 * @param {VerifyOptions&ProcessorOptions} options The options.
19302 * @returns {LintMessage[]} The found problems.
19303 */
19304
19305
19306 _verifyWithConfigArray(textOrSourceCode, configArray, options) {
19307 debug("With ConfigArray: %s", options.filename); // Store the config array in order to get plugin envs and rules later.
19308
19309 internalSlotsMap.get(this).lastConfigArray = configArray; // Extract the final config for this file.
19310
19311 const config = configArray.extractConfig(options.filename);
19312 const processor = config.processor && configArray.pluginProcessors.get(config.processor); // Verify.
19313
19314 if (processor) {
19315 debug("Apply the processor: %o", config.processor);
19316 const {
19317 preprocess,
19318 postprocess,
19319 supportsAutofix
19320 } = processor;
19321 const disableFixes = options.disableFixes || !supportsAutofix;
19322 return this._verifyWithProcessor(textOrSourceCode, config, { ...options,
19323 disableFixes,
19324 postprocess,
19325 preprocess
19326 }, configArray);
19327 }
19328
19329 return this._verifyWithoutProcessors(textOrSourceCode, config, options);
19330 }
19331 /**
19332 * Verify with a processor.
19333 * @param {string|SourceCode} textOrSourceCode The source code.
19334 * @param {ConfigData|ExtractedConfig} config The config array.
19335 * @param {VerifyOptions&ProcessorOptions} options The options.
19336 * @param {ConfigArray} [configForRecursive] The `ConfigArray` object to apply multiple processors recursively.
19337 * @returns {LintMessage[]} The found problems.
19338 */
19339
19340
19341 _verifyWithProcessor(textOrSourceCode, config, options, configForRecursive) {
19342 const filename = options.filename || "<input>";
19343 const filenameToExpose = normalizeFilename(filename);
19344 const physicalFilename = options.physicalFilename || filenameToExpose;
19345 const text = ensureText(textOrSourceCode);
19346
19347 const preprocess = options.preprocess || (rawText => [rawText]);
19348
19349 const postprocess = options.postprocess || (messagesList => messagesList.flat());
19350
19351 const filterCodeBlock = options.filterCodeBlock || (blockFilename => blockFilename.endsWith(".js"));
19352
19353 const originalExtname = path.extname(filename);
19354 const messageLists = preprocess(text, filenameToExpose).map((block, i) => {
19355 debug("A code block was found: %o", block.filename || "(unnamed)"); // Keep the legacy behavior.
19356
19357 if (typeof block === "string") {
19358 return this._verifyWithoutProcessors(block, config, options);
19359 }
19360
19361 const blockText = block.text;
19362 const blockName = path.join(filename, "".concat(i, "_").concat(block.filename)); // Skip this block if filtered.
19363
19364 if (!filterCodeBlock(blockName, blockText)) {
19365 debug("This code block was skipped.");
19366 return [];
19367 } // Resolve configuration again if the file content or extension was changed.
19368
19369
19370 if (configForRecursive && (text !== blockText || path.extname(blockName) !== originalExtname)) {
19371 debug("Resolving configuration again because the file content or extension was changed.");
19372 return this._verifyWithConfigArray(blockText, configForRecursive, { ...options,
19373 filename: blockName,
19374 physicalFilename
19375 });
19376 } // Does lint.
19377
19378
19379 return this._verifyWithoutProcessors(blockText, config, { ...options,
19380 filename: blockName,
19381 physicalFilename
19382 });
19383 });
19384 return postprocess(messageLists, filenameToExpose);
19385 }
19386 /**
19387 * Gets the SourceCode object representing the parsed source.
19388 * @returns {SourceCode} The SourceCode object.
19389 */
19390
19391
19392 getSourceCode() {
19393 return internalSlotsMap.get(this).lastSourceCode;
19394 }
19395 /**
19396 * Defines a new linting rule.
19397 * @param {string} ruleId A unique rule identifier
19398 * @param {Function | Rule} ruleModule Function from context to object mapping AST node types to event handlers
19399 * @returns {void}
19400 */
19401
19402
19403 defineRule(ruleId, ruleModule) {
19404 internalSlotsMap.get(this).ruleMap.define(ruleId, ruleModule);
19405 }
19406 /**
19407 * Defines many new linting rules.
19408 * @param {Record<string, Function | Rule>} rulesToDefine map from unique rule identifier to rule
19409 * @returns {void}
19410 */
19411
19412
19413 defineRules(rulesToDefine) {
19414 Object.getOwnPropertyNames(rulesToDefine).forEach(ruleId => {
19415 this.defineRule(ruleId, rulesToDefine[ruleId]);
19416 });
19417 }
19418 /**
19419 * Gets an object with all loaded rules.
19420 * @returns {Map<string, Rule>} All loaded rules
19421 */
19422
19423
19424 getRules() {
19425 const {
19426 lastConfigArray,
19427 ruleMap
19428 } = internalSlotsMap.get(this);
19429 return new Map(function* () {
19430 yield* ruleMap;
19431
19432 if (lastConfigArray) {
19433 yield* lastConfigArray.pluginRules;
19434 }
19435 }());
19436 }
19437 /**
19438 * Define a new parser module
19439 * @param {string} parserId Name of the parser
19440 * @param {Parser} parserModule The parser object
19441 * @returns {void}
19442 */
19443
19444
19445 defineParser(parserId, parserModule) {
19446 internalSlotsMap.get(this).parserMap.set(parserId, parserModule);
19447 }
19448 /**
19449 * Performs multiple autofix passes over the text until as many fixes as possible
19450 * have been applied.
19451 * @param {string} text The source text to apply fixes to.
19452 * @param {ConfigData|ConfigArray} config The ESLint config object to use.
19453 * @param {VerifyOptions&ProcessorOptions&FixOptions} options The ESLint options object to use.
19454 * @returns {{fixed:boolean,messages:LintMessage[],output:string}} The result of the fix operation as returned from the
19455 * SourceCodeFixer.
19456 */
19457
19458
19459 verifyAndFix(text, config, options) {
19460 let messages = [],
19461 fixedResult,
19462 fixed = false,
19463 passNumber = 0,
19464 currentText = text;
19465 const debugTextDescription = options && options.filename || "".concat(text.slice(0, 10), "...");
19466 const shouldFix = options && typeof options.fix !== "undefined" ? options.fix : true;
19467 /**
19468 * This loop continues until one of the following is true:
19469 *
19470 * 1. No more fixes have been applied.
19471 * 2. Ten passes have been made.
19472 *
19473 * That means anytime a fix is successfully applied, there will be another pass.
19474 * Essentially, guaranteeing a minimum of two passes.
19475 */
19476
19477 do {
19478 passNumber++;
19479 debug("Linting code for ".concat(debugTextDescription, " (pass ").concat(passNumber, ")"));
19480 messages = this.verify(currentText, config, options);
19481 debug("Generating fixed text for ".concat(debugTextDescription, " (pass ").concat(passNumber, ")"));
19482 fixedResult = SourceCodeFixer.applyFixes(currentText, messages, shouldFix);
19483 /*
19484 * stop if there are any syntax errors.
19485 * 'fixedResult.output' is a empty string.
19486 */
19487
19488 if (messages.length === 1 && messages[0].fatal) {
19489 break;
19490 } // keep track if any fixes were ever applied - important for return value
19491
19492
19493 fixed = fixed || fixedResult.fixed; // update to use the fixed output instead of the original text
19494
19495 currentText = fixedResult.output;
19496 } while (fixedResult.fixed && passNumber < MAX_AUTOFIX_PASSES);
19497 /*
19498 * If the last result had fixes, we need to lint again to be sure we have
19499 * the most up-to-date information.
19500 */
19501
19502
19503 if (fixedResult.fixed) {
19504 fixedResult.messages = this.verify(currentText, config, options);
19505 } // ensure the last result properly reflects if fixes were done
19506
19507
19508 fixedResult.fixed = fixed;
19509 fixedResult.output = currentText;
19510 return fixedResult;
19511 }
19512
19513 }
19514
19515 module.exports = {
19516 Linter,
19517
19518 /**
19519 * Get the internal slots of a given Linter instance for tests.
19520 * @param {Linter} instance The Linter instance to get.
19521 * @returns {LinterInternalSlots} The internal slots.
19522 */
19523 getLinterInternalSlots(instance) {
19524 return internalSlotsMap.get(instance);
19525 }
19526
19527 };
19528
19529 /***/ }),
19530 /* 429 */
19531 /***/ ((module) => {
19532
19533 "use strict";
19534 module.exports = require("path");
19535
19536 /***/ }),
19537 /* 430 */
19538 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
19539
19540 "use strict";
19541
19542
19543 Object.defineProperty(exports, "__esModule", ({ value: true }));
19544
19545 var assert = __webpack_require__(431);
19546 var estraverse = __webpack_require__(432);
19547 var esrecurse = __webpack_require__(433);
19548
19549 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19550
19551 var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
19552 var estraverse__default = /*#__PURE__*/_interopDefaultLegacy(estraverse);
19553 var esrecurse__default = /*#__PURE__*/_interopDefaultLegacy(esrecurse);
19554
19555 /*
19556 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
19557
19558 Redistribution and use in source and binary forms, with or without
19559 modification, are permitted provided that the following conditions are met:
19560
19561 * Redistributions of source code must retain the above copyright
19562 notice, this list of conditions and the following disclaimer.
19563 * Redistributions in binary form must reproduce the above copyright
19564 notice, this list of conditions and the following disclaimer in the
19565 documentation and/or other materials provided with the distribution.
19566
19567 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19568 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19569 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19570 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19571 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19572 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19573 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19574 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19575 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19576 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19577 */
19578
19579 const READ = 0x1;
19580 const WRITE = 0x2;
19581 const RW = READ | WRITE;
19582
19583 /**
19584 * A Reference represents a single occurrence of an identifier in code.
19585 * @constructor Reference
19586 */
19587 class Reference {
19588 constructor(ident, scope, flag, writeExpr, maybeImplicitGlobal, partial, init) {
19589
19590 /**
19591 * Identifier syntax node.
19592 * @member {espreeIdentifier} Reference#identifier
19593 */
19594 this.identifier = ident;
19595
19596 /**
19597 * Reference to the enclosing Scope.
19598 * @member {Scope} Reference#from
19599 */
19600 this.from = scope;
19601
19602 /**
19603 * Whether the reference comes from a dynamic scope (such as 'eval',
19604 * 'with', etc.), and may be trapped by dynamic scopes.
19605 * @member {boolean} Reference#tainted
19606 */
19607 this.tainted = false;
19608
19609 /**
19610 * The variable this reference is resolved with.
19611 * @member {Variable} Reference#resolved
19612 */
19613 this.resolved = null;
19614
19615 /**
19616 * The read-write mode of the reference. (Value is one of {@link
19617 * Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}).
19618 * @member {number} Reference#flag
19619 * @private
19620 */
19621 this.flag = flag;
19622 if (this.isWrite()) {
19623
19624 /**
19625 * If reference is writeable, this is the tree being written to it.
19626 * @member {espreeNode} Reference#writeExpr
19627 */
19628 this.writeExpr = writeExpr;
19629
19630 /**
19631 * Whether the Reference might refer to a partial value of writeExpr.
19632 * @member {boolean} Reference#partial
19633 */
19634 this.partial = partial;
19635
19636 /**
19637 * Whether the Reference is to write of initialization.
19638 * @member {boolean} Reference#init
19639 */
19640 this.init = init;
19641 }
19642 this.__maybeImplicitGlobal = maybeImplicitGlobal;
19643 }
19644
19645 /**
19646 * Whether the reference is static.
19647 * @function Reference#isStatic
19648 * @returns {boolean} static
19649 */
19650 isStatic() {
19651 return !this.tainted && this.resolved && this.resolved.scope.isStatic();
19652 }
19653
19654 /**
19655 * Whether the reference is writeable.
19656 * @function Reference#isWrite
19657 * @returns {boolean} write
19658 */
19659 isWrite() {
19660 return !!(this.flag & Reference.WRITE);
19661 }
19662
19663 /**
19664 * Whether the reference is readable.
19665 * @function Reference#isRead
19666 * @returns {boolean} read
19667 */
19668 isRead() {
19669 return !!(this.flag & Reference.READ);
19670 }
19671
19672 /**
19673 * Whether the reference is read-only.
19674 * @function Reference#isReadOnly
19675 * @returns {boolean} read only
19676 */
19677 isReadOnly() {
19678 return this.flag === Reference.READ;
19679 }
19680
19681 /**
19682 * Whether the reference is write-only.
19683 * @function Reference#isWriteOnly
19684 * @returns {boolean} write only
19685 */
19686 isWriteOnly() {
19687 return this.flag === Reference.WRITE;
19688 }
19689
19690 /**
19691 * Whether the reference is read-write.
19692 * @function Reference#isReadWrite
19693 * @returns {boolean} read write
19694 */
19695 isReadWrite() {
19696 return this.flag === Reference.RW;
19697 }
19698 }
19699
19700 /**
19701 * @constant Reference.READ
19702 * @private
19703 */
19704 Reference.READ = READ;
19705
19706 /**
19707 * @constant Reference.WRITE
19708 * @private
19709 */
19710 Reference.WRITE = WRITE;
19711
19712 /**
19713 * @constant Reference.RW
19714 * @private
19715 */
19716 Reference.RW = RW;
19717
19718 /* vim: set sw=4 ts=4 et tw=80 : */
19719
19720 /*
19721 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
19722
19723 Redistribution and use in source and binary forms, with or without
19724 modification, are permitted provided that the following conditions are met:
19725
19726 * Redistributions of source code must retain the above copyright
19727 notice, this list of conditions and the following disclaimer.
19728 * Redistributions in binary form must reproduce the above copyright
19729 notice, this list of conditions and the following disclaimer in the
19730 documentation and/or other materials provided with the distribution.
19731
19732 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19733 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19734 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19735 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19736 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19737 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19738 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19739 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19740 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19741 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19742 */
19743
19744 /**
19745 * A Variable represents a locally scoped identifier. These include arguments to
19746 * functions.
19747 * @constructor Variable
19748 */
19749 class Variable {
19750 constructor(name, scope) {
19751
19752 /**
19753 * The variable name, as given in the source code.
19754 * @member {string} Variable#name
19755 */
19756 this.name = name;
19757
19758 /**
19759 * List of defining occurrences of this variable (like in 'var ...'
19760 * statements or as parameter), as AST nodes.
19761 * @member {espree.Identifier[]} Variable#identifiers
19762 */
19763 this.identifiers = [];
19764
19765 /**
19766 * List of {@link Reference|references} of this variable (excluding parameter entries)
19767 * in its defining scope and all nested scopes. For defining
19768 * occurrences only see {@link Variable#defs}.
19769 * @member {Reference[]} Variable#references
19770 */
19771 this.references = [];
19772
19773 /**
19774 * List of defining occurrences of this variable (like in 'var ...'
19775 * statements or as parameter), as custom objects.
19776 * @member {Definition[]} Variable#defs
19777 */
19778 this.defs = [];
19779
19780 this.tainted = false;
19781
19782 /**
19783 * Whether this is a stack variable.
19784 * @member {boolean} Variable#stack
19785 */
19786 this.stack = true;
19787
19788 /**
19789 * Reference to the enclosing Scope.
19790 * @member {Scope} Variable#scope
19791 */
19792 this.scope = scope;
19793 }
19794 }
19795
19796 Variable.CatchClause = "CatchClause";
19797 Variable.Parameter = "Parameter";
19798 Variable.FunctionName = "FunctionName";
19799 Variable.ClassName = "ClassName";
19800 Variable.Variable = "Variable";
19801 Variable.ImportBinding = "ImportBinding";
19802 Variable.ImplicitGlobalVariable = "ImplicitGlobalVariable";
19803
19804 /* vim: set sw=4 ts=4 et tw=80 : */
19805
19806 /*
19807 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
19808
19809 Redistribution and use in source and binary forms, with or without
19810 modification, are permitted provided that the following conditions are met:
19811
19812 * Redistributions of source code must retain the above copyright
19813 notice, this list of conditions and the following disclaimer.
19814 * Redistributions in binary form must reproduce the above copyright
19815 notice, this list of conditions and the following disclaimer in the
19816 documentation and/or other materials provided with the distribution.
19817
19818 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19819 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19820 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19821 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19822 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19823 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19824 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19825 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19826 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19827 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19828 */
19829
19830 /**
19831 * @constructor Definition
19832 */
19833 class Definition {
19834 constructor(type, name, node, parent, index, kind) {
19835
19836 /**
19837 * @member {string} Definition#type - type of the occurrence (e.g. "Parameter", "Variable", ...).
19838 */
19839 this.type = type;
19840
19841 /**
19842 * @member {espree.Identifier} Definition#name - the identifier AST node of the occurrence.
19843 */
19844 this.name = name;
19845
19846 /**
19847 * @member {espree.Node} Definition#node - the enclosing node of the identifier.
19848 */
19849 this.node = node;
19850
19851 /**
19852 * @member {espree.Node?} Definition#parent - the enclosing statement node of the identifier.
19853 */
19854 this.parent = parent;
19855
19856 /**
19857 * @member {number?} Definition#index - the index in the declaration statement.
19858 */
19859 this.index = index;
19860
19861 /**
19862 * @member {string?} Definition#kind - the kind of the declaration statement.
19863 */
19864 this.kind = kind;
19865 }
19866 }
19867
19868 /**
19869 * @constructor ParameterDefinition
19870 */
19871 class ParameterDefinition extends Definition {
19872 constructor(name, node, index, rest) {
19873 super(Variable.Parameter, name, node, null, index, null);
19874
19875 /**
19876 * Whether the parameter definition is a part of a rest parameter.
19877 * @member {boolean} ParameterDefinition#rest
19878 */
19879 this.rest = rest;
19880 }
19881 }
19882
19883 /* vim: set sw=4 ts=4 et tw=80 : */
19884
19885 /*
19886 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
19887
19888 Redistribution and use in source and binary forms, with or without
19889 modification, are permitted provided that the following conditions are met:
19890
19891 * Redistributions of source code must retain the above copyright
19892 notice, this list of conditions and the following disclaimer.
19893 * Redistributions in binary form must reproduce the above copyright
19894 notice, this list of conditions and the following disclaimer in the
19895 documentation and/or other materials provided with the distribution.
19896
19897 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19898 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19899 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19900 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19901 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19902 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19903 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19904 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19905 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19906 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19907 */
19908
19909 const { Syntax: Syntax$2 } = estraverse__default["default"];
19910
19911 /**
19912 * Test if scope is struct
19913 * @param {Scope} scope scope
19914 * @param {Block} block block
19915 * @param {boolean} isMethodDefinition is method definition
19916 * @param {boolean} useDirective use directive
19917 * @returns {boolean} is strict scope
19918 */
19919 function isStrictScope(scope, block, isMethodDefinition, useDirective) {
19920 let body;
19921
19922 // When upper scope is exists and strict, inner scope is also strict.
19923 if (scope.upper && scope.upper.isStrict) {
19924 return true;
19925 }
19926
19927 if (isMethodDefinition) {
19928 return true;
19929 }
19930
19931 if (scope.type === "class" || scope.type === "module") {
19932 return true;
19933 }
19934
19935 if (scope.type === "block" || scope.type === "switch") {
19936 return false;
19937 }
19938
19939 if (scope.type === "function") {
19940 if (block.type === Syntax$2.ArrowFunctionExpression && block.body.type !== Syntax$2.BlockStatement) {
19941 return false;
19942 }
19943
19944 if (block.type === Syntax$2.Program) {
19945 body = block;
19946 } else {
19947 body = block.body;
19948 }
19949
19950 if (!body) {
19951 return false;
19952 }
19953 } else if (scope.type === "global") {
19954 body = block;
19955 } else {
19956 return false;
19957 }
19958
19959 // Search 'use strict' directive.
19960 if (useDirective) {
19961 for (let i = 0, iz = body.body.length; i < iz; ++i) {
19962 const stmt = body.body[i];
19963
19964 if (stmt.type !== Syntax$2.DirectiveStatement) {
19965 break;
19966 }
19967 if (stmt.raw === "\"use strict\"" || stmt.raw === "'use strict'") {
19968 return true;
19969 }
19970 }
19971 } else {
19972 for (let i = 0, iz = body.body.length; i < iz; ++i) {
19973 const stmt = body.body[i];
19974
19975 if (stmt.type !== Syntax$2.ExpressionStatement) {
19976 break;
19977 }
19978 const expr = stmt.expression;
19979
19980 if (expr.type !== Syntax$2.Literal || typeof expr.value !== "string") {
19981 break;
19982 }
19983 if (expr.raw !== null && expr.raw !== undefined) {
19984 if (expr.raw === "\"use strict\"" || expr.raw === "'use strict'") {
19985 return true;
19986 }
19987 } else {
19988 if (expr.value === "use strict") {
19989 return true;
19990 }
19991 }
19992 }
19993 }
19994 return false;
19995 }
19996
19997 /**
19998 * Register scope
19999 * @param {ScopeManager} scopeManager scope manager
20000 * @param {Scope} scope scope
20001 * @returns {void}
20002 */
20003 function registerScope(scopeManager, scope) {
20004 scopeManager.scopes.push(scope);
20005
20006 const scopes = scopeManager.__nodeToScope.get(scope.block);
20007
20008 if (scopes) {
20009 scopes.push(scope);
20010 } else {
20011 scopeManager.__nodeToScope.set(scope.block, [scope]);
20012 }
20013 }
20014
20015 /**
20016 * Should be statically
20017 * @param {Object} def def
20018 * @returns {boolean} should be statically
20019 */
20020 function shouldBeStatically(def) {
20021 return (
20022 (def.type === Variable.ClassName) ||
20023 (def.type === Variable.Variable && def.parent.kind !== "var")
20024 );
20025 }
20026
20027 /**
20028 * @constructor Scope
20029 */
20030 class Scope {
20031 constructor(scopeManager, type, upperScope, block, isMethodDefinition) {
20032
20033 /**
20034 * One of "global", "module", "function", "function-expression-name", "block", "switch", "catch", "with", "for",
20035 * "class", "class-field-initializer", "class-static-block".
20036 * @member {string} Scope#type
20037 */
20038 this.type = type;
20039
20040 /**
20041 * The scoped {@link Variable}s of this scope, as <code>{ Variable.name
20042 * : Variable }</code>.
20043 * @member {Map} Scope#set
20044 */
20045 this.set = new Map();
20046
20047 /**
20048 * The tainted variables of this scope, as <code>{ Variable.name :
20049 * boolean }</code>.
20050 * @member {Map} Scope#taints */
20051 this.taints = new Map();
20052
20053 /**
20054 * Generally, through the lexical scoping of JS you can always know
20055 * which variable an identifier in the source code refers to. There are
20056 * a few exceptions to this rule. With 'global' and 'with' scopes you
20057 * can only decide at runtime which variable a reference refers to.
20058 * Moreover, if 'eval()' is used in a scope, it might introduce new
20059 * bindings in this or its parent scopes.
20060 * All those scopes are considered 'dynamic'.
20061 * @member {boolean} Scope#dynamic
20062 */
20063 this.dynamic = this.type === "global" || this.type === "with";
20064
20065 /**
20066 * A reference to the scope-defining syntax node.
20067 * @member {espree.Node} Scope#block
20068 */
20069 this.block = block;
20070
20071 /**
20072 * The {@link Reference|references} that are not resolved with this scope.
20073 * @member {Reference[]} Scope#through
20074 */
20075 this.through = [];
20076
20077 /**
20078 * The scoped {@link Variable}s of this scope. In the case of a
20079 * 'function' scope this includes the automatic argument <em>arguments</em> as
20080 * its first element, as well as all further formal arguments.
20081 * @member {Variable[]} Scope#variables
20082 */
20083 this.variables = [];
20084
20085 /**
20086 * Any variable {@link Reference|reference} found in this scope. This
20087 * includes occurrences of local variables as well as variables from
20088 * parent scopes (including the global scope). For local variables
20089 * this also includes defining occurrences (like in a 'var' statement).
20090 * In a 'function' scope this does not include the occurrences of the
20091 * formal parameter in the parameter list.
20092 * @member {Reference[]} Scope#references
20093 */
20094 this.references = [];
20095
20096 /**
20097 * For 'global' and 'function' scopes, this is a self-reference. For
20098 * other scope types this is the <em>variableScope</em> value of the
20099 * parent scope.
20100 * @member {Scope} Scope#variableScope
20101 */
20102 this.variableScope =
20103 this.type === "global" ||
20104 this.type === "module" ||
20105 this.type === "function" ||
20106 this.type === "class-field-initializer" ||
20107 this.type === "class-static-block"
20108 ? this
20109 : upperScope.variableScope;
20110
20111 /**
20112 * Whether this scope is created by a FunctionExpression.
20113 * @member {boolean} Scope#functionExpressionScope
20114 */
20115 this.functionExpressionScope = false;
20116
20117 /**
20118 * Whether this is a scope that contains an 'eval()' invocation.
20119 * @member {boolean} Scope#directCallToEvalScope
20120 */
20121 this.directCallToEvalScope = false;
20122
20123 /**
20124 * @member {boolean} Scope#thisFound
20125 */
20126 this.thisFound = false;
20127
20128 this.__left = [];
20129
20130 /**
20131 * Reference to the parent {@link Scope|scope}.
20132 * @member {Scope} Scope#upper
20133 */
20134 this.upper = upperScope;
20135
20136 /**
20137 * Whether 'use strict' is in effect in this scope.
20138 * @member {boolean} Scope#isStrict
20139 */
20140 this.isStrict = isStrictScope(this, block, isMethodDefinition, scopeManager.__useDirective());
20141
20142 /**
20143 * List of nested {@link Scope}s.
20144 * @member {Scope[]} Scope#childScopes
20145 */
20146 this.childScopes = [];
20147 if (this.upper) {
20148 this.upper.childScopes.push(this);
20149 }
20150
20151 this.__declaredVariables = scopeManager.__declaredVariables;
20152
20153 registerScope(scopeManager, this);
20154 }
20155
20156 __shouldStaticallyClose(scopeManager) {
20157 return (!this.dynamic || scopeManager.__isOptimistic());
20158 }
20159
20160 __shouldStaticallyCloseForGlobal(ref) {
20161
20162 // On global scope, let/const/class declarations should be resolved statically.
20163 const name = ref.identifier.name;
20164
20165 if (!this.set.has(name)) {
20166 return false;
20167 }
20168
20169 const variable = this.set.get(name);
20170 const defs = variable.defs;
20171
20172 return defs.length > 0 && defs.every(shouldBeStatically);
20173 }
20174
20175 __staticCloseRef(ref) {
20176 if (!this.__resolve(ref)) {
20177 this.__delegateToUpperScope(ref);
20178 }
20179 }
20180
20181 __dynamicCloseRef(ref) {
20182
20183 // notify all names are through to global
20184 let current = this;
20185
20186 do {
20187 current.through.push(ref);
20188 current = current.upper;
20189 } while (current);
20190 }
20191
20192 __globalCloseRef(ref) {
20193
20194 // let/const/class declarations should be resolved statically.
20195 // others should be resolved dynamically.
20196 if (this.__shouldStaticallyCloseForGlobal(ref)) {
20197 this.__staticCloseRef(ref);
20198 } else {
20199 this.__dynamicCloseRef(ref);
20200 }
20201 }
20202
20203 __close(scopeManager) {
20204 let closeRef;
20205
20206 if (this.__shouldStaticallyClose(scopeManager)) {
20207 closeRef = this.__staticCloseRef;
20208 } else if (this.type !== "global") {
20209 closeRef = this.__dynamicCloseRef;
20210 } else {
20211 closeRef = this.__globalCloseRef;
20212 }
20213
20214 // Try Resolving all references in this scope.
20215 for (let i = 0, iz = this.__left.length; i < iz; ++i) {
20216 const ref = this.__left[i];
20217
20218 closeRef.call(this, ref);
20219 }
20220 this.__left = null;
20221
20222 return this.upper;
20223 }
20224
20225 // To override by function scopes.
20226 // References in default parameters isn't resolved to variables which are in their function body.
20227 __isValidResolution(ref, variable) { // eslint-disable-line class-methods-use-this, no-unused-vars
20228 return true;
20229 }
20230
20231 __resolve(ref) {
20232 const name = ref.identifier.name;
20233
20234 if (!this.set.has(name)) {
20235 return false;
20236 }
20237 const variable = this.set.get(name);
20238
20239 if (!this.__isValidResolution(ref, variable)) {
20240 return false;
20241 }
20242 variable.references.push(ref);
20243 variable.stack = variable.stack && ref.from.variableScope === this.variableScope;
20244 if (ref.tainted) {
20245 variable.tainted = true;
20246 this.taints.set(variable.name, true);
20247 }
20248 ref.resolved = variable;
20249
20250 return true;
20251 }
20252
20253 __delegateToUpperScope(ref) {
20254 if (this.upper) {
20255 this.upper.__left.push(ref);
20256 }
20257 this.through.push(ref);
20258 }
20259
20260 __addDeclaredVariablesOfNode(variable, node) {
20261 if (node === null || node === undefined) {
20262 return;
20263 }
20264
20265 let variables = this.__declaredVariables.get(node);
20266
20267 if (variables === null || variables === undefined) {
20268 variables = [];
20269 this.__declaredVariables.set(node, variables);
20270 }
20271 if (variables.indexOf(variable) === -1) {
20272 variables.push(variable);
20273 }
20274 }
20275
20276 __defineGeneric(name, set, variables, node, def) {
20277 let variable;
20278
20279 variable = set.get(name);
20280 if (!variable) {
20281 variable = new Variable(name, this);
20282 set.set(name, variable);
20283 variables.push(variable);
20284 }
20285
20286 if (def) {
20287 variable.defs.push(def);
20288 this.__addDeclaredVariablesOfNode(variable, def.node);
20289 this.__addDeclaredVariablesOfNode(variable, def.parent);
20290 }
20291 if (node) {
20292 variable.identifiers.push(node);
20293 }
20294 }
20295
20296 __define(node, def) {
20297 if (node && node.type === Syntax$2.Identifier) {
20298 this.__defineGeneric(
20299 node.name,
20300 this.set,
20301 this.variables,
20302 node,
20303 def
20304 );
20305 }
20306 }
20307
20308 __referencing(node, assign, writeExpr, maybeImplicitGlobal, partial, init) {
20309
20310 // because Array element may be null
20311 if (!node || node.type !== Syntax$2.Identifier) {
20312 return;
20313 }
20314
20315 // Specially handle like `this`.
20316 if (node.name === "super") {
20317 return;
20318 }
20319
20320 const ref = new Reference(node, this, assign || Reference.READ, writeExpr, maybeImplicitGlobal, !!partial, !!init);
20321
20322 this.references.push(ref);
20323 this.__left.push(ref);
20324 }
20325
20326 __detectEval() {
20327 let current = this;
20328
20329 this.directCallToEvalScope = true;
20330 do {
20331 current.dynamic = true;
20332 current = current.upper;
20333 } while (current);
20334 }
20335
20336 __detectThis() {
20337 this.thisFound = true;
20338 }
20339
20340 __isClosed() {
20341 return this.__left === null;
20342 }
20343
20344 /**
20345 * returns resolved {Reference}
20346 * @function Scope#resolve
20347 * @param {Espree.Identifier} ident identifier to be resolved.
20348 * @returns {Reference} reference
20349 */
20350 resolve(ident) {
20351 let ref, i, iz;
20352
20353 assert__default["default"](this.__isClosed(), "Scope should be closed.");
20354 assert__default["default"](ident.type === Syntax$2.Identifier, "Target should be identifier.");
20355 for (i = 0, iz = this.references.length; i < iz; ++i) {
20356 ref = this.references[i];
20357 if (ref.identifier === ident) {
20358 return ref;
20359 }
20360 }
20361 return null;
20362 }
20363
20364 /**
20365 * returns this scope is static
20366 * @function Scope#isStatic
20367 * @returns {boolean} static
20368 */
20369 isStatic() {
20370 return !this.dynamic;
20371 }
20372
20373 /**
20374 * returns this scope has materialized arguments
20375 * @function Scope#isArgumentsMaterialized
20376 * @returns {boolean} arguemnts materialized
20377 */
20378 isArgumentsMaterialized() { // eslint-disable-line class-methods-use-this
20379 return true;
20380 }
20381
20382 /**
20383 * returns this scope has materialized `this` reference
20384 * @function Scope#isThisMaterialized
20385 * @returns {boolean} this materialized
20386 */
20387 isThisMaterialized() { // eslint-disable-line class-methods-use-this
20388 return true;
20389 }
20390
20391 isUsedName(name) {
20392 if (this.set.has(name)) {
20393 return true;
20394 }
20395 for (let i = 0, iz = this.through.length; i < iz; ++i) {
20396 if (this.through[i].identifier.name === name) {
20397 return true;
20398 }
20399 }
20400 return false;
20401 }
20402 }
20403
20404 class GlobalScope extends Scope {
20405 constructor(scopeManager, block) {
20406 super(scopeManager, "global", null, block, false);
20407 this.implicit = {
20408 set: new Map(),
20409 variables: [],
20410
20411 /**
20412 * List of {@link Reference}s that are left to be resolved (i.e. which
20413 * need to be linked to the variable they refer to).
20414 * @member {Reference[]} Scope#implicit#left
20415 */
20416 left: []
20417 };
20418 }
20419
20420 __close(scopeManager) {
20421 const implicit = [];
20422
20423 for (let i = 0, iz = this.__left.length; i < iz; ++i) {
20424 const ref = this.__left[i];
20425
20426 if (ref.__maybeImplicitGlobal && !this.set.has(ref.identifier.name)) {
20427 implicit.push(ref.__maybeImplicitGlobal);
20428 }
20429 }
20430
20431 // create an implicit global variable from assignment expression
20432 for (let i = 0, iz = implicit.length; i < iz; ++i) {
20433 const info = implicit[i];
20434
20435 this.__defineImplicit(info.pattern,
20436 new Definition(
20437 Variable.ImplicitGlobalVariable,
20438 info.pattern,
20439 info.node,
20440 null,
20441 null,
20442 null
20443 ));
20444
20445 }
20446
20447 this.implicit.left = this.__left;
20448
20449 return super.__close(scopeManager);
20450 }
20451
20452 __defineImplicit(node, def) {
20453 if (node && node.type === Syntax$2.Identifier) {
20454 this.__defineGeneric(
20455 node.name,
20456 this.implicit.set,
20457 this.implicit.variables,
20458 node,
20459 def
20460 );
20461 }
20462 }
20463 }
20464
20465 class ModuleScope extends Scope {
20466 constructor(scopeManager, upperScope, block) {
20467 super(scopeManager, "module", upperScope, block, false);
20468 }
20469 }
20470
20471 class FunctionExpressionNameScope extends Scope {
20472 constructor(scopeManager, upperScope, block) {
20473 super(scopeManager, "function-expression-name", upperScope, block, false);
20474 this.__define(block.id,
20475 new Definition(
20476 Variable.FunctionName,
20477 block.id,
20478 block,
20479 null,
20480 null,
20481 null
20482 ));
20483 this.functionExpressionScope = true;
20484 }
20485 }
20486
20487 class CatchScope extends Scope {
20488 constructor(scopeManager, upperScope, block) {
20489 super(scopeManager, "catch", upperScope, block, false);
20490 }
20491 }
20492
20493 class WithScope extends Scope {
20494 constructor(scopeManager, upperScope, block) {
20495 super(scopeManager, "with", upperScope, block, false);
20496 }
20497
20498 __close(scopeManager) {
20499 if (this.__shouldStaticallyClose(scopeManager)) {
20500 return super.__close(scopeManager);
20501 }
20502
20503 for (let i = 0, iz = this.__left.length; i < iz; ++i) {
20504 const ref = this.__left[i];
20505
20506 ref.tainted = true;
20507 this.__delegateToUpperScope(ref);
20508 }
20509 this.__left = null;
20510
20511 return this.upper;
20512 }
20513 }
20514
20515 class BlockScope extends Scope {
20516 constructor(scopeManager, upperScope, block) {
20517 super(scopeManager, "block", upperScope, block, false);
20518 }
20519 }
20520
20521 class SwitchScope extends Scope {
20522 constructor(scopeManager, upperScope, block) {
20523 super(scopeManager, "switch", upperScope, block, false);
20524 }
20525 }
20526
20527 class FunctionScope extends Scope {
20528 constructor(scopeManager, upperScope, block, isMethodDefinition) {
20529 super(scopeManager, "function", upperScope, block, isMethodDefinition);
20530
20531 // section 9.2.13, FunctionDeclarationInstantiation.
20532 // NOTE Arrow functions never have an arguments objects.
20533 if (this.block.type !== Syntax$2.ArrowFunctionExpression) {
20534 this.__defineArguments();
20535 }
20536 }
20537
20538 isArgumentsMaterialized() {
20539
20540 // TODO(Constellation)
20541 // We can more aggressive on this condition like this.
20542 //
20543 // function t() {
20544 // // arguments of t is always hidden.
20545 // function arguments() {
20546 // }
20547 // }
20548 if (this.block.type === Syntax$2.ArrowFunctionExpression) {
20549 return false;
20550 }
20551
20552 if (!this.isStatic()) {
20553 return true;
20554 }
20555
20556 const variable = this.set.get("arguments");
20557
20558 assert__default["default"](variable, "Always have arguments variable.");
20559 return variable.tainted || variable.references.length !== 0;
20560 }
20561
20562 isThisMaterialized() {
20563 if (!this.isStatic()) {
20564 return true;
20565 }
20566 return this.thisFound;
20567 }
20568
20569 __defineArguments() {
20570 this.__defineGeneric(
20571 "arguments",
20572 this.set,
20573 this.variables,
20574 null,
20575 null
20576 );
20577 this.taints.set("arguments", true);
20578 }
20579
20580 // References in default parameters isn't resolved to variables which are in their function body.
20581 // const x = 1
20582 // function f(a = x) { // This `x` is resolved to the `x` in the outer scope.
20583 // const x = 2
20584 // console.log(a)
20585 // }
20586 __isValidResolution(ref, variable) {
20587
20588 // If `options.nodejsScope` is true, `this.block` becomes a Program node.
20589 if (this.block.type === "Program") {
20590 return true;
20591 }
20592
20593 const bodyStart = this.block.body.range[0];
20594
20595 // It's invalid resolution in the following case:
20596 return !(
20597 variable.scope === this &&
20598 ref.identifier.range[0] < bodyStart && // the reference is in the parameter part.
20599 variable.defs.every(d => d.name.range[0] >= bodyStart) // the variable is in the body.
20600 );
20601 }
20602 }
20603
20604 class ForScope extends Scope {
20605 constructor(scopeManager, upperScope, block) {
20606 super(scopeManager, "for", upperScope, block, false);
20607 }
20608 }
20609
20610 class ClassScope extends Scope {
20611 constructor(scopeManager, upperScope, block) {
20612 super(scopeManager, "class", upperScope, block, false);
20613 }
20614 }
20615
20616 class ClassFieldInitializerScope extends Scope {
20617 constructor(scopeManager, upperScope, block) {
20618 super(scopeManager, "class-field-initializer", upperScope, block, true);
20619 }
20620 }
20621
20622 class ClassStaticBlockScope extends Scope {
20623 constructor(scopeManager, upperScope, block) {
20624 super(scopeManager, "class-static-block", upperScope, block, true);
20625 }
20626 }
20627
20628 /* vim: set sw=4 ts=4 et tw=80 : */
20629
20630 /*
20631 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
20632
20633 Redistribution and use in source and binary forms, with or without
20634 modification, are permitted provided that the following conditions are met:
20635
20636 * Redistributions of source code must retain the above copyright
20637 notice, this list of conditions and the following disclaimer.
20638 * Redistributions in binary form must reproduce the above copyright
20639 notice, this list of conditions and the following disclaimer in the
20640 documentation and/or other materials provided with the distribution.
20641
20642 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20643 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20644 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20645 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20646 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20647 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20648 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20649 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20650 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20651 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20652 */
20653
20654 /**
20655 * @constructor ScopeManager
20656 */
20657 class ScopeManager {
20658 constructor(options) {
20659 this.scopes = [];
20660 this.globalScope = null;
20661 this.__nodeToScope = new WeakMap();
20662 this.__currentScope = null;
20663 this.__options = options;
20664 this.__declaredVariables = new WeakMap();
20665 }
20666
20667 __useDirective() {
20668 return this.__options.directive;
20669 }
20670
20671 __isOptimistic() {
20672 return this.__options.optimistic;
20673 }
20674
20675 __ignoreEval() {
20676 return this.__options.ignoreEval;
20677 }
20678
20679 __isNodejsScope() {
20680 return this.__options.nodejsScope || this.__options.sourceType === "commonjs";
20681 }
20682
20683 isModule() {
20684 return this.__options.sourceType === "module";
20685 }
20686
20687 isImpliedStrict() {
20688 return this.__options.impliedStrict;
20689 }
20690
20691 isStrictModeSupported() {
20692 return this.__options.ecmaVersion >= 5;
20693 }
20694
20695 // Returns appropriate scope for this node.
20696 __get(node) {
20697 return this.__nodeToScope.get(node);
20698 }
20699
20700 /**
20701 * Get variables that are declared by the node.
20702 *
20703 * "are declared by the node" means the node is same as `Variable.defs[].node` or `Variable.defs[].parent`.
20704 * If the node declares nothing, this method returns an empty array.
20705 * CAUTION: This API is experimental. See https://github.com/estools/escope/pull/69 for more details.
20706 * @param {Espree.Node} node a node to get.
20707 * @returns {Variable[]} variables that declared by the node.
20708 */
20709 getDeclaredVariables(node) {
20710 return this.__declaredVariables.get(node) || [];
20711 }
20712
20713 /**
20714 * acquire scope from node.
20715 * @function ScopeManager#acquire
20716 * @param {Espree.Node} node node for the acquired scope.
20717 * @param {?boolean} [inner=false] look up the most inner scope, default value is false.
20718 * @returns {Scope?} Scope from node
20719 */
20720 acquire(node, inner) {
20721
20722 /**
20723 * predicate
20724 * @param {Scope} testScope scope to test
20725 * @returns {boolean} predicate
20726 */
20727 function predicate(testScope) {
20728 if (testScope.type === "function" && testScope.functionExpressionScope) {
20729 return false;
20730 }
20731 return true;
20732 }
20733
20734 const scopes = this.__get(node);
20735
20736 if (!scopes || scopes.length === 0) {
20737 return null;
20738 }
20739
20740 // Heuristic selection from all scopes.
20741 // If you would like to get all scopes, please use ScopeManager#acquireAll.
20742 if (scopes.length === 1) {
20743 return scopes[0];
20744 }
20745
20746 if (inner) {
20747 for (let i = scopes.length - 1; i >= 0; --i) {
20748 const scope = scopes[i];
20749
20750 if (predicate(scope)) {
20751 return scope;
20752 }
20753 }
20754 } else {
20755 for (let i = 0, iz = scopes.length; i < iz; ++i) {
20756 const scope = scopes[i];
20757
20758 if (predicate(scope)) {
20759 return scope;
20760 }
20761 }
20762 }
20763
20764 return null;
20765 }
20766
20767 /**
20768 * acquire all scopes from node.
20769 * @function ScopeManager#acquireAll
20770 * @param {Espree.Node} node node for the acquired scope.
20771 * @returns {Scopes?} Scope array
20772 */
20773 acquireAll(node) {
20774 return this.__get(node);
20775 }
20776
20777 /**
20778 * release the node.
20779 * @function ScopeManager#release
20780 * @param {Espree.Node} node releasing node.
20781 * @param {?boolean} [inner=false] look up the most inner scope, default value is false.
20782 * @returns {Scope?} upper scope for the node.
20783 */
20784 release(node, inner) {
20785 const scopes = this.__get(node);
20786
20787 if (scopes && scopes.length) {
20788 const scope = scopes[0].upper;
20789
20790 if (!scope) {
20791 return null;
20792 }
20793 return this.acquire(scope.block, inner);
20794 }
20795 return null;
20796 }
20797
20798 attach() { } // eslint-disable-line class-methods-use-this
20799
20800 detach() { } // eslint-disable-line class-methods-use-this
20801
20802 __nestScope(scope) {
20803 if (scope instanceof GlobalScope) {
20804 assert__default["default"](this.__currentScope === null);
20805 this.globalScope = scope;
20806 }
20807 this.__currentScope = scope;
20808 return scope;
20809 }
20810
20811 __nestGlobalScope(node) {
20812 return this.__nestScope(new GlobalScope(this, node));
20813 }
20814
20815 __nestBlockScope(node) {
20816 return this.__nestScope(new BlockScope(this, this.__currentScope, node));
20817 }
20818
20819 __nestFunctionScope(node, isMethodDefinition) {
20820 return this.__nestScope(new FunctionScope(this, this.__currentScope, node, isMethodDefinition));
20821 }
20822
20823 __nestForScope(node) {
20824 return this.__nestScope(new ForScope(this, this.__currentScope, node));
20825 }
20826
20827 __nestCatchScope(node) {
20828 return this.__nestScope(new CatchScope(this, this.__currentScope, node));
20829 }
20830
20831 __nestWithScope(node) {
20832 return this.__nestScope(new WithScope(this, this.__currentScope, node));
20833 }
20834
20835 __nestClassScope(node) {
20836 return this.__nestScope(new ClassScope(this, this.__currentScope, node));
20837 }
20838
20839 __nestClassFieldInitializerScope(node) {
20840 return this.__nestScope(new ClassFieldInitializerScope(this, this.__currentScope, node));
20841 }
20842
20843 __nestClassStaticBlockScope(node) {
20844 return this.__nestScope(new ClassStaticBlockScope(this, this.__currentScope, node));
20845 }
20846
20847 __nestSwitchScope(node) {
20848 return this.__nestScope(new SwitchScope(this, this.__currentScope, node));
20849 }
20850
20851 __nestModuleScope(node) {
20852 return this.__nestScope(new ModuleScope(this, this.__currentScope, node));
20853 }
20854
20855 __nestFunctionExpressionNameScope(node) {
20856 return this.__nestScope(new FunctionExpressionNameScope(this, this.__currentScope, node));
20857 }
20858
20859 __isES6() {
20860 return this.__options.ecmaVersion >= 6;
20861 }
20862 }
20863
20864 /* vim: set sw=4 ts=4 et tw=80 : */
20865
20866 /*
20867 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
20868
20869 Redistribution and use in source and binary forms, with or without
20870 modification, are permitted provided that the following conditions are met:
20871
20872 * Redistributions of source code must retain the above copyright
20873 notice, this list of conditions and the following disclaimer.
20874 * Redistributions in binary form must reproduce the above copyright
20875 notice, this list of conditions and the following disclaimer in the
20876 documentation and/or other materials provided with the distribution.
20877
20878 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20879 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20880 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20881 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20882 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20883 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20884 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20885 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20886 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20887 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20888 */
20889
20890 const { Syntax: Syntax$1 } = estraverse__default["default"];
20891
20892 /**
20893 * Get last array element
20894 * @param {Array} xs array
20895 * @returns {any} Last elment
20896 */
20897 function getLast(xs) {
20898 return xs[xs.length - 1] || null;
20899 }
20900
20901 class PatternVisitor extends esrecurse__default["default"].Visitor {
20902 static isPattern(node) {
20903 const nodeType = node.type;
20904
20905 return (
20906 nodeType === Syntax$1.Identifier ||
20907 nodeType === Syntax$1.ObjectPattern ||
20908 nodeType === Syntax$1.ArrayPattern ||
20909 nodeType === Syntax$1.SpreadElement ||
20910 nodeType === Syntax$1.RestElement ||
20911 nodeType === Syntax$1.AssignmentPattern
20912 );
20913 }
20914
20915 constructor(options, rootPattern, callback) {
20916 super(null, options);
20917 this.rootPattern = rootPattern;
20918 this.callback = callback;
20919 this.assignments = [];
20920 this.rightHandNodes = [];
20921 this.restElements = [];
20922 }
20923
20924 Identifier(pattern) {
20925 const lastRestElement = getLast(this.restElements);
20926
20927 this.callback(pattern, {
20928 topLevel: pattern === this.rootPattern,
20929 rest: lastRestElement !== null && lastRestElement !== undefined && lastRestElement.argument === pattern,
20930 assignments: this.assignments
20931 });
20932 }
20933
20934 Property(property) {
20935
20936 // Computed property's key is a right hand node.
20937 if (property.computed) {
20938 this.rightHandNodes.push(property.key);
20939 }
20940
20941 // If it's shorthand, its key is same as its value.
20942 // If it's shorthand and has its default value, its key is same as its value.left (the value is AssignmentPattern).
20943 // If it's not shorthand, the name of new variable is its value's.
20944 this.visit(property.value);
20945 }
20946
20947 ArrayPattern(pattern) {
20948 for (let i = 0, iz = pattern.elements.length; i < iz; ++i) {
20949 const element = pattern.elements[i];
20950
20951 this.visit(element);
20952 }
20953 }
20954
20955 AssignmentPattern(pattern) {
20956 this.assignments.push(pattern);
20957 this.visit(pattern.left);
20958 this.rightHandNodes.push(pattern.right);
20959 this.assignments.pop();
20960 }
20961
20962 RestElement(pattern) {
20963 this.restElements.push(pattern);
20964 this.visit(pattern.argument);
20965 this.restElements.pop();
20966 }
20967
20968 MemberExpression(node) {
20969
20970 // Computed property's key is a right hand node.
20971 if (node.computed) {
20972 this.rightHandNodes.push(node.property);
20973 }
20974
20975 // the object is only read, write to its property.
20976 this.rightHandNodes.push(node.object);
20977 }
20978
20979 //
20980 // ForInStatement.left and AssignmentExpression.left are LeftHandSideExpression.
20981 // By spec, LeftHandSideExpression is Pattern or MemberExpression.
20982 // (see also: https://github.com/estree/estree/pull/20#issuecomment-74584758)
20983 // But espree 2.0 parses to ArrayExpression, ObjectExpression, etc...
20984 //
20985
20986 SpreadElement(node) {
20987 this.visit(node.argument);
20988 }
20989
20990 ArrayExpression(node) {
20991 node.elements.forEach(this.visit, this);
20992 }
20993
20994 AssignmentExpression(node) {
20995 this.assignments.push(node);
20996 this.visit(node.left);
20997 this.rightHandNodes.push(node.right);
20998 this.assignments.pop();
20999 }
21000
21001 CallExpression(node) {
21002
21003 // arguments are right hand nodes.
21004 node.arguments.forEach(a => {
21005 this.rightHandNodes.push(a);
21006 });
21007 this.visit(node.callee);
21008 }
21009 }
21010
21011 /* vim: set sw=4 ts=4 et tw=80 : */
21012
21013 /*
21014 Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
21015
21016 Redistribution and use in source and binary forms, with or without
21017 modification, are permitted provided that the following conditions are met:
21018
21019 * Redistributions of source code must retain the above copyright
21020 notice, this list of conditions and the following disclaimer.
21021 * Redistributions in binary form must reproduce the above copyright
21022 notice, this list of conditions and the following disclaimer in the
21023 documentation and/or other materials provided with the distribution.
21024
21025 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21026 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21027 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21028 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21029 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21030 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21031 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21032 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21033 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21034 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21035 */
21036
21037 const { Syntax } = estraverse__default["default"];
21038
21039 /**
21040 * Traverse identifier in pattern
21041 * @param {Object} options options
21042 * @param {pattern} rootPattern root pattern
21043 * @param {Refencer} referencer referencer
21044 * @param {callback} callback callback
21045 * @returns {void}
21046 */
21047 function traverseIdentifierInPattern(options, rootPattern, referencer, callback) {
21048
21049 // Call the callback at left hand identifier nodes, and Collect right hand nodes.
21050 const visitor = new PatternVisitor(options, rootPattern, callback);
21051
21052 visitor.visit(rootPattern);
21053
21054 // Process the right hand nodes recursively.
21055 if (referencer !== null && referencer !== undefined) {
21056 visitor.rightHandNodes.forEach(referencer.visit, referencer);
21057 }
21058 }
21059
21060 // Importing ImportDeclaration.
21061 // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-moduledeclarationinstantiation
21062 // https://github.com/estree/estree/blob/master/es6.md#importdeclaration
21063 // FIXME: Now, we don't create module environment, because the context is
21064 // implementation dependent.
21065
21066 class Importer extends esrecurse__default["default"].Visitor {
21067 constructor(declaration, referencer) {
21068 super(null, referencer.options);
21069 this.declaration = declaration;
21070 this.referencer = referencer;
21071 }
21072
21073 visitImport(id, specifier) {
21074 this.referencer.visitPattern(id, pattern => {
21075 this.referencer.currentScope().__define(pattern,
21076 new Definition(
21077 Variable.ImportBinding,
21078 pattern,
21079 specifier,
21080 this.declaration,
21081 null,
21082 null
21083 ));
21084 });
21085 }
21086
21087 ImportNamespaceSpecifier(node) {
21088 const local = (node.local || node.id);
21089
21090 if (local) {
21091 this.visitImport(local, node);
21092 }
21093 }
21094
21095 ImportDefaultSpecifier(node) {
21096 const local = (node.local || node.id);
21097
21098 this.visitImport(local, node);
21099 }
21100
21101 ImportSpecifier(node) {
21102 const local = (node.local || node.id);
21103
21104 if (node.name) {
21105 this.visitImport(node.name, node);
21106 } else {
21107 this.visitImport(local, node);
21108 }
21109 }
21110 }
21111
21112 // Referencing variables and creating bindings.
21113 class Referencer extends esrecurse__default["default"].Visitor {
21114 constructor(options, scopeManager) {
21115 super(null, options);
21116 this.options = options;
21117 this.scopeManager = scopeManager;
21118 this.parent = null;
21119 this.isInnerMethodDefinition = false;
21120 }
21121
21122 currentScope() {
21123 return this.scopeManager.__currentScope;
21124 }
21125
21126 close(node) {
21127 while (this.currentScope() && node === this.currentScope().block) {
21128 this.scopeManager.__currentScope = this.currentScope().__close(this.scopeManager);
21129 }
21130 }
21131
21132 pushInnerMethodDefinition(isInnerMethodDefinition) {
21133 const previous = this.isInnerMethodDefinition;
21134
21135 this.isInnerMethodDefinition = isInnerMethodDefinition;
21136 return previous;
21137 }
21138
21139 popInnerMethodDefinition(isInnerMethodDefinition) {
21140 this.isInnerMethodDefinition = isInnerMethodDefinition;
21141 }
21142
21143 referencingDefaultValue(pattern, assignments, maybeImplicitGlobal, init) {
21144 const scope = this.currentScope();
21145
21146 assignments.forEach(assignment => {
21147 scope.__referencing(
21148 pattern,
21149 Reference.WRITE,
21150 assignment.right,
21151 maybeImplicitGlobal,
21152 pattern !== assignment.left,
21153 init
21154 );
21155 });
21156 }
21157
21158 visitPattern(node, options, callback) {
21159 let visitPatternOptions = options;
21160 let visitPatternCallback = callback;
21161
21162 if (typeof options === "function") {
21163 visitPatternCallback = options;
21164 visitPatternOptions = { processRightHandNodes: false };
21165 }
21166
21167 traverseIdentifierInPattern(
21168 this.options,
21169 node,
21170 visitPatternOptions.processRightHandNodes ? this : null,
21171 visitPatternCallback
21172 );
21173 }
21174
21175 visitFunction(node) {
21176 let i, iz;
21177
21178 // FunctionDeclaration name is defined in upper scope
21179 // NOTE: Not referring variableScope. It is intended.
21180 // Since
21181 // in ES5, FunctionDeclaration should be in FunctionBody.
21182 // in ES6, FunctionDeclaration should be block scoped.
21183
21184 if (node.type === Syntax.FunctionDeclaration) {
21185
21186 // id is defined in upper scope
21187 this.currentScope().__define(node.id,
21188 new Definition(
21189 Variable.FunctionName,
21190 node.id,
21191 node,
21192 null,
21193 null,
21194 null
21195 ));
21196 }
21197
21198 // FunctionExpression with name creates its special scope;
21199 // FunctionExpressionNameScope.
21200 if (node.type === Syntax.FunctionExpression && node.id) {
21201 this.scopeManager.__nestFunctionExpressionNameScope(node);
21202 }
21203
21204 // Consider this function is in the MethodDefinition.
21205 this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
21206
21207 const that = this;
21208
21209 /**
21210 * Visit pattern callback
21211 * @param {pattern} pattern pattern
21212 * @param {Object} info info
21213 * @returns {void}
21214 */
21215 function visitPatternCallback(pattern, info) {
21216 that.currentScope().__define(pattern,
21217 new ParameterDefinition(
21218 pattern,
21219 node,
21220 i,
21221 info.rest
21222 ));
21223
21224 that.referencingDefaultValue(pattern, info.assignments, null, true);
21225 }
21226
21227 // Process parameter declarations.
21228 for (i = 0, iz = node.params.length; i < iz; ++i) {
21229 this.visitPattern(node.params[i], { processRightHandNodes: true }, visitPatternCallback);
21230 }
21231
21232 // if there's a rest argument, add that
21233 if (node.rest) {
21234 this.visitPattern({
21235 type: "RestElement",
21236 argument: node.rest
21237 }, pattern => {
21238 this.currentScope().__define(pattern,
21239 new ParameterDefinition(
21240 pattern,
21241 node,
21242 node.params.length,
21243 true
21244 ));
21245 });
21246 }
21247
21248 // In TypeScript there are a number of function-like constructs which have no body,
21249 // so check it exists before traversing
21250 if (node.body) {
21251
21252 // Skip BlockStatement to prevent creating BlockStatement scope.
21253 if (node.body.type === Syntax.BlockStatement) {
21254 this.visitChildren(node.body);
21255 } else {
21256 this.visit(node.body);
21257 }
21258 }
21259
21260 this.close(node);
21261 }
21262
21263 visitClass(node) {
21264 if (node.type === Syntax.ClassDeclaration) {
21265 this.currentScope().__define(node.id,
21266 new Definition(
21267 Variable.ClassName,
21268 node.id,
21269 node,
21270 null,
21271 null,
21272 null
21273 ));
21274 }
21275
21276 this.visit(node.superClass);
21277
21278 this.scopeManager.__nestClassScope(node);
21279
21280 if (node.id) {
21281 this.currentScope().__define(node.id,
21282 new Definition(
21283 Variable.ClassName,
21284 node.id,
21285 node
21286 ));
21287 }
21288 this.visit(node.body);
21289
21290 this.close(node);
21291 }
21292
21293 visitProperty(node) {
21294 let previous;
21295
21296 if (node.computed) {
21297 this.visit(node.key);
21298 }
21299
21300 const isMethodDefinition = node.type === Syntax.MethodDefinition;
21301
21302 if (isMethodDefinition) {
21303 previous = this.pushInnerMethodDefinition(true);
21304 }
21305 this.visit(node.value);
21306 if (isMethodDefinition) {
21307 this.popInnerMethodDefinition(previous);
21308 }
21309 }
21310
21311 visitForIn(node) {
21312 if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
21313 this.scopeManager.__nestForScope(node);
21314 }
21315
21316 if (node.left.type === Syntax.VariableDeclaration) {
21317 this.visit(node.left);
21318 this.visitPattern(node.left.declarations[0].id, pattern => {
21319 this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
21320 });
21321 } else {
21322 this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
21323 let maybeImplicitGlobal = null;
21324
21325 if (!this.currentScope().isStrict) {
21326 maybeImplicitGlobal = {
21327 pattern,
21328 node
21329 };
21330 }
21331 this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
21332 this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false);
21333 });
21334 }
21335 this.visit(node.right);
21336 this.visit(node.body);
21337
21338 this.close(node);
21339 }
21340
21341 visitVariableDeclaration(variableTargetScope, type, node, index) {
21342
21343 const decl = node.declarations[index];
21344 const init = decl.init;
21345
21346 this.visitPattern(decl.id, { processRightHandNodes: true }, (pattern, info) => {
21347 variableTargetScope.__define(
21348 pattern,
21349 new Definition(
21350 type,
21351 pattern,
21352 decl,
21353 node,
21354 index,
21355 node.kind
21356 )
21357 );
21358
21359 this.referencingDefaultValue(pattern, info.assignments, null, true);
21360 if (init) {
21361 this.currentScope().__referencing(pattern, Reference.WRITE, init, null, !info.topLevel, true);
21362 }
21363 });
21364 }
21365
21366 AssignmentExpression(node) {
21367 if (PatternVisitor.isPattern(node.left)) {
21368 if (node.operator === "=") {
21369 this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
21370 let maybeImplicitGlobal = null;
21371
21372 if (!this.currentScope().isStrict) {
21373 maybeImplicitGlobal = {
21374 pattern,
21375 node
21376 };
21377 }
21378 this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
21379 this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, !info.topLevel, false);
21380 });
21381 } else {
21382 this.currentScope().__referencing(node.left, Reference.RW, node.right);
21383 }
21384 } else {
21385 this.visit(node.left);
21386 }
21387 this.visit(node.right);
21388 }
21389
21390 CatchClause(node) {
21391 this.scopeManager.__nestCatchScope(node);
21392
21393 this.visitPattern(node.param, { processRightHandNodes: true }, (pattern, info) => {
21394 this.currentScope().__define(pattern,
21395 new Definition(
21396 Variable.CatchClause,
21397 node.param,
21398 node,
21399 null,
21400 null,
21401 null
21402 ));
21403 this.referencingDefaultValue(pattern, info.assignments, null, true);
21404 });
21405 this.visit(node.body);
21406
21407 this.close(node);
21408 }
21409
21410 Program(node) {
21411 this.scopeManager.__nestGlobalScope(node);
21412
21413 if (this.scopeManager.__isNodejsScope()) {
21414
21415 // Force strictness of GlobalScope to false when using node.js scope.
21416 this.currentScope().isStrict = false;
21417 this.scopeManager.__nestFunctionScope(node, false);
21418 }
21419
21420 if (this.scopeManager.__isES6() && this.scopeManager.isModule()) {
21421 this.scopeManager.__nestModuleScope(node);
21422 }
21423
21424 if (this.scopeManager.isStrictModeSupported() && this.scopeManager.isImpliedStrict()) {
21425 this.currentScope().isStrict = true;
21426 }
21427
21428 this.visitChildren(node);
21429 this.close(node);
21430 }
21431
21432 Identifier(node) {
21433 this.currentScope().__referencing(node);
21434 }
21435
21436 // eslint-disable-next-line class-methods-use-this
21437 PrivateIdentifier() {
21438
21439 // Do nothing.
21440 }
21441
21442 UpdateExpression(node) {
21443 if (PatternVisitor.isPattern(node.argument)) {
21444 this.currentScope().__referencing(node.argument, Reference.RW, null);
21445 } else {
21446 this.visitChildren(node);
21447 }
21448 }
21449
21450 MemberExpression(node) {
21451 this.visit(node.object);
21452 if (node.computed) {
21453 this.visit(node.property);
21454 }
21455 }
21456
21457 Property(node) {
21458 this.visitProperty(node);
21459 }
21460
21461 PropertyDefinition(node) {
21462 const { computed, key, value } = node;
21463
21464 if (computed) {
21465 this.visit(key);
21466 }
21467 if (value) {
21468 this.scopeManager.__nestClassFieldInitializerScope(value);
21469 this.visit(value);
21470 this.close(value);
21471 }
21472 }
21473
21474 StaticBlock(node) {
21475 this.scopeManager.__nestClassStaticBlockScope(node);
21476
21477 this.visitChildren(node);
21478
21479 this.close(node);
21480 }
21481
21482 MethodDefinition(node) {
21483 this.visitProperty(node);
21484 }
21485
21486 BreakStatement() {} // eslint-disable-line class-methods-use-this
21487
21488 ContinueStatement() {} // eslint-disable-line class-methods-use-this
21489
21490 LabeledStatement(node) {
21491 this.visit(node.body);
21492 }
21493
21494 ForStatement(node) {
21495
21496 // Create ForStatement declaration.
21497 // NOTE: In ES6, ForStatement dynamically generates
21498 // per iteration environment. However, escope is
21499 // a static analyzer, we only generate one scope for ForStatement.
21500 if (node.init && node.init.type === Syntax.VariableDeclaration && node.init.kind !== "var") {
21501 this.scopeManager.__nestForScope(node);
21502 }
21503
21504 this.visitChildren(node);
21505
21506 this.close(node);
21507 }
21508
21509 ClassExpression(node) {
21510 this.visitClass(node);
21511 }
21512
21513 ClassDeclaration(node) {
21514 this.visitClass(node);
21515 }
21516
21517 CallExpression(node) {
21518
21519 // Check this is direct call to eval
21520 if (!this.scopeManager.__ignoreEval() && node.callee.type === Syntax.Identifier && node.callee.name === "eval") {
21521
21522 // NOTE: This should be `variableScope`. Since direct eval call always creates Lexical environment and
21523 // let / const should be enclosed into it. Only VariableDeclaration affects on the caller's environment.
21524 this.currentScope().variableScope.__detectEval();
21525 }
21526 this.visitChildren(node);
21527 }
21528
21529 BlockStatement(node) {
21530 if (this.scopeManager.__isES6()) {
21531 this.scopeManager.__nestBlockScope(node);
21532 }
21533
21534 this.visitChildren(node);
21535
21536 this.close(node);
21537 }
21538
21539 ThisExpression() {
21540 this.currentScope().variableScope.__detectThis();
21541 }
21542
21543 WithStatement(node) {
21544 this.visit(node.object);
21545
21546 // Then nest scope for WithStatement.
21547 this.scopeManager.__nestWithScope(node);
21548
21549 this.visit(node.body);
21550
21551 this.close(node);
21552 }
21553
21554 VariableDeclaration(node) {
21555 const variableTargetScope = (node.kind === "var") ? this.currentScope().variableScope : this.currentScope();
21556
21557 for (let i = 0, iz = node.declarations.length; i < iz; ++i) {
21558 const decl = node.declarations[i];
21559
21560 this.visitVariableDeclaration(variableTargetScope, Variable.Variable, node, i);
21561 if (decl.init) {
21562 this.visit(decl.init);
21563 }
21564 }
21565 }
21566
21567 // sec 13.11.8
21568 SwitchStatement(node) {
21569 this.visit(node.discriminant);
21570
21571 if (this.scopeManager.__isES6()) {
21572 this.scopeManager.__nestSwitchScope(node);
21573 }
21574
21575 for (let i = 0, iz = node.cases.length; i < iz; ++i) {
21576 this.visit(node.cases[i]);
21577 }
21578
21579 this.close(node);
21580 }
21581
21582 FunctionDeclaration(node) {
21583 this.visitFunction(node);
21584 }
21585
21586 FunctionExpression(node) {
21587 this.visitFunction(node);
21588 }
21589
21590 ForOfStatement(node) {
21591 this.visitForIn(node);
21592 }
21593
21594 ForInStatement(node) {
21595 this.visitForIn(node);
21596 }
21597
21598 ArrowFunctionExpression(node) {
21599 this.visitFunction(node);
21600 }
21601
21602 ImportDeclaration(node) {
21603 assert__default["default"](this.scopeManager.__isES6() && this.scopeManager.isModule(), "ImportDeclaration should appear when the mode is ES6 and in the module context.");
21604
21605 const importer = new Importer(node, this);
21606
21607 importer.visit(node);
21608 }
21609
21610 visitExportDeclaration(node) {
21611 if (node.source) {
21612 return;
21613 }
21614 if (node.declaration) {
21615 this.visit(node.declaration);
21616 return;
21617 }
21618
21619 this.visitChildren(node);
21620 }
21621
21622 // TODO: ExportDeclaration doesn't exist. for bc?
21623 ExportDeclaration(node) {
21624 this.visitExportDeclaration(node);
21625 }
21626
21627 ExportAllDeclaration(node) {
21628 this.visitExportDeclaration(node);
21629 }
21630
21631 ExportDefaultDeclaration(node) {
21632 this.visitExportDeclaration(node);
21633 }
21634
21635 ExportNamedDeclaration(node) {
21636 this.visitExportDeclaration(node);
21637 }
21638
21639 ExportSpecifier(node) {
21640
21641 // TODO: `node.id` doesn't exist. for bc?
21642 const local = (node.id || node.local);
21643
21644 this.visit(local);
21645 }
21646
21647 MetaProperty() { // eslint-disable-line class-methods-use-this
21648
21649 // do nothing.
21650 }
21651 }
21652
21653 /* vim: set sw=4 ts=4 et tw=80 : */
21654
21655 const version = "7.1.0";
21656
21657 /*
21658 Copyright (C) 2012-2014 Yusuke Suzuki <utatane.tea@gmail.com>
21659 Copyright (C) 2013 Alex Seville <hi@alexanderseville.com>
21660 Copyright (C) 2014 Thiago de Arruda <tpadilha84@gmail.com>
21661
21662 Redistribution and use in source and binary forms, with or without
21663 modification, are permitted provided that the following conditions are met:
21664
21665 * Redistributions of source code must retain the above copyright
21666 notice, this list of conditions and the following disclaimer.
21667 * Redistributions in binary form must reproduce the above copyright
21668 notice, this list of conditions and the following disclaimer in the
21669 documentation and/or other materials provided with the distribution.
21670
21671 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21672 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21673 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21674 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21675 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21676 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21677 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21678 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21679 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21680 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21681 */
21682
21683 /**
21684 * Set the default options
21685 * @returns {Object} options
21686 */
21687 function defaultOptions() {
21688 return {
21689 optimistic: false,
21690 directive: false,
21691 nodejsScope: false,
21692 impliedStrict: false,
21693 sourceType: "script", // one of ['script', 'module', 'commonjs']
21694 ecmaVersion: 5,
21695 childVisitorKeys: null,
21696 fallback: "iteration"
21697 };
21698 }
21699
21700 /**
21701 * Preform deep update on option object
21702 * @param {Object} target Options
21703 * @param {Object} override Updates
21704 * @returns {Object} Updated options
21705 */
21706 function updateDeeply(target, override) {
21707
21708 /**
21709 * Is hash object
21710 * @param {Object} value Test value
21711 * @returns {boolean} Result
21712 */
21713 function isHashObject(value) {
21714 return typeof value === "object" && value instanceof Object && !(value instanceof Array) && !(value instanceof RegExp);
21715 }
21716
21717 for (const key in override) {
21718 if (Object.prototype.hasOwnProperty.call(override, key)) {
21719 const val = override[key];
21720
21721 if (isHashObject(val)) {
21722 if (isHashObject(target[key])) {
21723 updateDeeply(target[key], val);
21724 } else {
21725 target[key] = updateDeeply({}, val);
21726 }
21727 } else {
21728 target[key] = val;
21729 }
21730 }
21731 }
21732 return target;
21733 }
21734
21735 /**
21736 * Main interface function. Takes an Espree syntax tree and returns the
21737 * analyzed scopes.
21738 * @function analyze
21739 * @param {espree.Tree} tree Abstract Syntax Tree
21740 * @param {Object} providedOptions Options that tailor the scope analysis
21741 * @param {boolean} [providedOptions.optimistic=false] the optimistic flag
21742 * @param {boolean} [providedOptions.directive=false] the directive flag
21743 * @param {boolean} [providedOptions.ignoreEval=false] whether to check 'eval()' calls
21744 * @param {boolean} [providedOptions.nodejsScope=false] whether the whole
21745 * script is executed under node.js environment. When enabled, escope adds
21746 * a function scope immediately following the global scope.
21747 * @param {boolean} [providedOptions.impliedStrict=false] implied strict mode
21748 * (if ecmaVersion >= 5).
21749 * @param {string} [providedOptions.sourceType='script'] the source type of the script. one of 'script', 'module', and 'commonjs'
21750 * @param {number} [providedOptions.ecmaVersion=5] which ECMAScript version is considered
21751 * @param {Object} [providedOptions.childVisitorKeys=null] Additional known visitor keys. See [esrecurse](https://github.com/estools/esrecurse)'s the `childVisitorKeys` option.
21752 * @param {string} [providedOptions.fallback='iteration'] A kind of the fallback in order to encounter with unknown node. See [esrecurse](https://github.com/estools/esrecurse)'s the `fallback` option.
21753 * @returns {ScopeManager} ScopeManager
21754 */
21755 function analyze(tree, providedOptions) {
21756 const options = updateDeeply(defaultOptions(), providedOptions);
21757 const scopeManager = new ScopeManager(options);
21758 const referencer = new Referencer(options, scopeManager);
21759
21760 referencer.visit(tree);
21761
21762 assert__default["default"](scopeManager.__currentScope === null, "currentScope should be null.");
21763
21764 return scopeManager;
21765 }
21766
21767 /* vim: set sw=4 ts=4 et tw=80 : */
21768
21769 exports.Definition = Definition;
21770 exports.PatternVisitor = PatternVisitor;
21771 exports.Reference = Reference;
21772 exports.Referencer = Referencer;
21773 exports.Scope = Scope;
21774 exports.ScopeManager = ScopeManager;
21775 exports.Variable = Variable;
21776 exports.analyze = analyze;
21777 exports.version = version;
21778 //# sourceMappingURL=eslint-scope.cjs.map
21779
21780
21781 /***/ }),
21782 /* 431 */
21783 /***/ ((module) => {
21784
21785 "use strict";
21786 module.exports = require("assert");
21787
21788 /***/ }),
21789 /* 432 */
21790 /***/ ((__unused_webpack_module, exports) => {
21791
21792 /*
21793 Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com>
21794 Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
21795
21796 Redistribution and use in source and binary forms, with or without
21797 modification, are permitted provided that the following conditions are met:
21798
21799 * Redistributions of source code must retain the above copyright
21800 notice, this list of conditions and the following disclaimer.
21801 * Redistributions in binary form must reproduce the above copyright
21802 notice, this list of conditions and the following disclaimer in the
21803 documentation and/or other materials provided with the distribution.
21804
21805 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21806 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21807 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21808 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21809 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21810 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21811 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21812 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21813 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21814 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21815 */
21816
21817 /*jslint vars:false, bitwise:true*/
21818
21819 /*jshint indent:4*/
21820
21821 /*global exports:true*/
21822 (function clone(exports) {
21823 'use strict';
21824
21825 var Syntax, VisitorOption, VisitorKeys, BREAK, SKIP, REMOVE;
21826
21827 function deepCopy(obj) {
21828 var ret = {},
21829 key,
21830 val;
21831
21832 for (key in obj) {
21833 if (obj.hasOwnProperty(key)) {
21834 val = obj[key];
21835
21836 if (typeof val === 'object' && val !== null) {
21837 ret[key] = deepCopy(val);
21838 } else {
21839 ret[key] = val;
21840 }
21841 }
21842 }
21843
21844 return ret;
21845 } // based on LLVM libc++ upper_bound / lower_bound
21846 // MIT License
21847
21848
21849 function upperBound(array, func) {
21850 var diff, len, i, current;
21851 len = array.length;
21852 i = 0;
21853
21854 while (len) {
21855 diff = len >>> 1;
21856 current = i + diff;
21857
21858 if (func(array[current])) {
21859 len = diff;
21860 } else {
21861 i = current + 1;
21862 len -= diff + 1;
21863 }
21864 }
21865
21866 return i;
21867 }
21868
21869 Syntax = {
21870 AssignmentExpression: 'AssignmentExpression',
21871 AssignmentPattern: 'AssignmentPattern',
21872 ArrayExpression: 'ArrayExpression',
21873 ArrayPattern: 'ArrayPattern',
21874 ArrowFunctionExpression: 'ArrowFunctionExpression',
21875 AwaitExpression: 'AwaitExpression',
21876 // CAUTION: It's deferred to ES7.
21877 BlockStatement: 'BlockStatement',
21878 BinaryExpression: 'BinaryExpression',
21879 BreakStatement: 'BreakStatement',
21880 CallExpression: 'CallExpression',
21881 CatchClause: 'CatchClause',
21882 ChainExpression: 'ChainExpression',
21883 ClassBody: 'ClassBody',
21884 ClassDeclaration: 'ClassDeclaration',
21885 ClassExpression: 'ClassExpression',
21886 ComprehensionBlock: 'ComprehensionBlock',
21887 // CAUTION: It's deferred to ES7.
21888 ComprehensionExpression: 'ComprehensionExpression',
21889 // CAUTION: It's deferred to ES7.
21890 ConditionalExpression: 'ConditionalExpression',
21891 ContinueStatement: 'ContinueStatement',
21892 DebuggerStatement: 'DebuggerStatement',
21893 DirectiveStatement: 'DirectiveStatement',
21894 DoWhileStatement: 'DoWhileStatement',
21895 EmptyStatement: 'EmptyStatement',
21896 ExportAllDeclaration: 'ExportAllDeclaration',
21897 ExportDefaultDeclaration: 'ExportDefaultDeclaration',
21898 ExportNamedDeclaration: 'ExportNamedDeclaration',
21899 ExportSpecifier: 'ExportSpecifier',
21900 ExpressionStatement: 'ExpressionStatement',
21901 ForStatement: 'ForStatement',
21902 ForInStatement: 'ForInStatement',
21903 ForOfStatement: 'ForOfStatement',
21904 FunctionDeclaration: 'FunctionDeclaration',
21905 FunctionExpression: 'FunctionExpression',
21906 GeneratorExpression: 'GeneratorExpression',
21907 // CAUTION: It's deferred to ES7.
21908 Identifier: 'Identifier',
21909 IfStatement: 'IfStatement',
21910 ImportExpression: 'ImportExpression',
21911 ImportDeclaration: 'ImportDeclaration',
21912 ImportDefaultSpecifier: 'ImportDefaultSpecifier',
21913 ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
21914 ImportSpecifier: 'ImportSpecifier',
21915 Literal: 'Literal',
21916 LabeledStatement: 'LabeledStatement',
21917 LogicalExpression: 'LogicalExpression',
21918 MemberExpression: 'MemberExpression',
21919 MetaProperty: 'MetaProperty',
21920 MethodDefinition: 'MethodDefinition',
21921 ModuleSpecifier: 'ModuleSpecifier',
21922 NewExpression: 'NewExpression',
21923 ObjectExpression: 'ObjectExpression',
21924 ObjectPattern: 'ObjectPattern',
21925 PrivateIdentifier: 'PrivateIdentifier',
21926 Program: 'Program',
21927 Property: 'Property',
21928 PropertyDefinition: 'PropertyDefinition',
21929 RestElement: 'RestElement',
21930 ReturnStatement: 'ReturnStatement',
21931 SequenceExpression: 'SequenceExpression',
21932 SpreadElement: 'SpreadElement',
21933 Super: 'Super',
21934 SwitchStatement: 'SwitchStatement',
21935 SwitchCase: 'SwitchCase',
21936 TaggedTemplateExpression: 'TaggedTemplateExpression',
21937 TemplateElement: 'TemplateElement',
21938 TemplateLiteral: 'TemplateLiteral',
21939 ThisExpression: 'ThisExpression',
21940 ThrowStatement: 'ThrowStatement',
21941 TryStatement: 'TryStatement',
21942 UnaryExpression: 'UnaryExpression',
21943 UpdateExpression: 'UpdateExpression',
21944 VariableDeclaration: 'VariableDeclaration',
21945 VariableDeclarator: 'VariableDeclarator',
21946 WhileStatement: 'WhileStatement',
21947 WithStatement: 'WithStatement',
21948 YieldExpression: 'YieldExpression'
21949 };
21950 VisitorKeys = {
21951 AssignmentExpression: ['left', 'right'],
21952 AssignmentPattern: ['left', 'right'],
21953 ArrayExpression: ['elements'],
21954 ArrayPattern: ['elements'],
21955 ArrowFunctionExpression: ['params', 'body'],
21956 AwaitExpression: ['argument'],
21957 // CAUTION: It's deferred to ES7.
21958 BlockStatement: ['body'],
21959 BinaryExpression: ['left', 'right'],
21960 BreakStatement: ['label'],
21961 CallExpression: ['callee', 'arguments'],
21962 CatchClause: ['param', 'body'],
21963 ChainExpression: ['expression'],
21964 ClassBody: ['body'],
21965 ClassDeclaration: ['id', 'superClass', 'body'],
21966 ClassExpression: ['id', 'superClass', 'body'],
21967 ComprehensionBlock: ['left', 'right'],
21968 // CAUTION: It's deferred to ES7.
21969 ComprehensionExpression: ['blocks', 'filter', 'body'],
21970 // CAUTION: It's deferred to ES7.
21971 ConditionalExpression: ['test', 'consequent', 'alternate'],
21972 ContinueStatement: ['label'],
21973 DebuggerStatement: [],
21974 DirectiveStatement: [],
21975 DoWhileStatement: ['body', 'test'],
21976 EmptyStatement: [],
21977 ExportAllDeclaration: ['source'],
21978 ExportDefaultDeclaration: ['declaration'],
21979 ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
21980 ExportSpecifier: ['exported', 'local'],
21981 ExpressionStatement: ['expression'],
21982 ForStatement: ['init', 'test', 'update', 'body'],
21983 ForInStatement: ['left', 'right', 'body'],
21984 ForOfStatement: ['left', 'right', 'body'],
21985 FunctionDeclaration: ['id', 'params', 'body'],
21986 FunctionExpression: ['id', 'params', 'body'],
21987 GeneratorExpression: ['blocks', 'filter', 'body'],
21988 // CAUTION: It's deferred to ES7.
21989 Identifier: [],
21990 IfStatement: ['test', 'consequent', 'alternate'],
21991 ImportExpression: ['source'],
21992 ImportDeclaration: ['specifiers', 'source'],
21993 ImportDefaultSpecifier: ['local'],
21994 ImportNamespaceSpecifier: ['local'],
21995 ImportSpecifier: ['imported', 'local'],
21996 Literal: [],
21997 LabeledStatement: ['label', 'body'],
21998 LogicalExpression: ['left', 'right'],
21999 MemberExpression: ['object', 'property'],
22000 MetaProperty: ['meta', 'property'],
22001 MethodDefinition: ['key', 'value'],
22002 ModuleSpecifier: [],
22003 NewExpression: ['callee', 'arguments'],
22004 ObjectExpression: ['properties'],
22005 ObjectPattern: ['properties'],
22006 PrivateIdentifier: [],
22007 Program: ['body'],
22008 Property: ['key', 'value'],
22009 PropertyDefinition: ['key', 'value'],
22010 RestElement: ['argument'],
22011 ReturnStatement: ['argument'],
22012 SequenceExpression: ['expressions'],
22013 SpreadElement: ['argument'],
22014 Super: [],
22015 SwitchStatement: ['discriminant', 'cases'],
22016 SwitchCase: ['test', 'consequent'],
22017 TaggedTemplateExpression: ['tag', 'quasi'],
22018 TemplateElement: [],
22019 TemplateLiteral: ['quasis', 'expressions'],
22020 ThisExpression: [],
22021 ThrowStatement: ['argument'],
22022 TryStatement: ['block', 'handler', 'finalizer'],
22023 UnaryExpression: ['argument'],
22024 UpdateExpression: ['argument'],
22025 VariableDeclaration: ['declarations'],
22026 VariableDeclarator: ['id', 'init'],
22027 WhileStatement: ['test', 'body'],
22028 WithStatement: ['object', 'body'],
22029 YieldExpression: ['argument']
22030 }; // unique id
22031
22032 BREAK = {};
22033 SKIP = {};
22034 REMOVE = {};
22035 VisitorOption = {
22036 Break: BREAK,
22037 Skip: SKIP,
22038 Remove: REMOVE
22039 };
22040
22041 function Reference(parent, key) {
22042 this.parent = parent;
22043 this.key = key;
22044 }
22045
22046 Reference.prototype.replace = function replace(node) {
22047 this.parent[this.key] = node;
22048 };
22049
22050 Reference.prototype.remove = function remove() {
22051 if (Array.isArray(this.parent)) {
22052 this.parent.splice(this.key, 1);
22053 return true;
22054 } else {
22055 this.replace(null);
22056 return false;
22057 }
22058 };
22059
22060 function Element(node, path, wrap, ref) {
22061 this.node = node;
22062 this.path = path;
22063 this.wrap = wrap;
22064 this.ref = ref;
22065 }
22066
22067 function Controller() {} // API:
22068 // return property path array from root to current node
22069
22070
22071 Controller.prototype.path = function path() {
22072 var i, iz, j, jz, result, element;
22073
22074 function addToPath(result, path) {
22075 if (Array.isArray(path)) {
22076 for (j = 0, jz = path.length; j < jz; ++j) {
22077 result.push(path[j]);
22078 }
22079 } else {
22080 result.push(path);
22081 }
22082 } // root node
22083
22084
22085 if (!this.__current.path) {
22086 return null;
22087 } // first node is sentinel, second node is root element
22088
22089
22090 result = [];
22091
22092 for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
22093 element = this.__leavelist[i];
22094 addToPath(result, element.path);
22095 }
22096
22097 addToPath(result, this.__current.path);
22098 return result;
22099 }; // API:
22100 // return type of current node
22101
22102
22103 Controller.prototype.type = function () {
22104 var node = this.current();
22105 return node.type || this.__current.wrap;
22106 }; // API:
22107 // return array of parent elements
22108
22109
22110 Controller.prototype.parents = function parents() {
22111 var i, iz, result; // first node is sentinel
22112
22113 result = [];
22114
22115 for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
22116 result.push(this.__leavelist[i].node);
22117 }
22118
22119 return result;
22120 }; // API:
22121 // return current node
22122
22123
22124 Controller.prototype.current = function current() {
22125 return this.__current.node;
22126 };
22127
22128 Controller.prototype.__execute = function __execute(callback, element) {
22129 var previous, result;
22130 result = undefined;
22131 previous = this.__current;
22132 this.__current = element;
22133 this.__state = null;
22134
22135 if (callback) {
22136 result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
22137 }
22138
22139 this.__current = previous;
22140 return result;
22141 }; // API:
22142 // notify control skip / break
22143
22144
22145 Controller.prototype.notify = function notify(flag) {
22146 this.__state = flag;
22147 }; // API:
22148 // skip child nodes of current node
22149
22150
22151 Controller.prototype.skip = function () {
22152 this.notify(SKIP);
22153 }; // API:
22154 // break traversals
22155
22156
22157 Controller.prototype['break'] = function () {
22158 this.notify(BREAK);
22159 }; // API:
22160 // remove node
22161
22162
22163 Controller.prototype.remove = function () {
22164 this.notify(REMOVE);
22165 };
22166
22167 Controller.prototype.__initialize = function (root, visitor) {
22168 this.visitor = visitor;
22169 this.root = root;
22170 this.__worklist = [];
22171 this.__leavelist = [];
22172 this.__current = null;
22173 this.__state = null;
22174 this.__fallback = null;
22175
22176 if (visitor.fallback === 'iteration') {
22177 this.__fallback = Object.keys;
22178 } else if (typeof visitor.fallback === 'function') {
22179 this.__fallback = visitor.fallback;
22180 }
22181
22182 this.__keys = VisitorKeys;
22183
22184 if (visitor.keys) {
22185 this.__keys = Object.assign(Object.create(this.__keys), visitor.keys);
22186 }
22187 };
22188
22189 function isNode(node) {
22190 if (node == null) {
22191 return false;
22192 }
22193
22194 return typeof node === 'object' && typeof node.type === 'string';
22195 }
22196
22197 function isProperty(nodeType, key) {
22198 return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
22199 }
22200
22201 function candidateExistsInLeaveList(leavelist, candidate) {
22202 for (var i = leavelist.length - 1; i >= 0; --i) {
22203 if (leavelist[i].node === candidate) {
22204 return true;
22205 }
22206 }
22207
22208 return false;
22209 }
22210
22211 Controller.prototype.traverse = function traverse(root, visitor) {
22212 var worklist, leavelist, element, node, nodeType, ret, key, current, current2, candidates, candidate, sentinel;
22213
22214 this.__initialize(root, visitor);
22215
22216 sentinel = {}; // reference
22217
22218 worklist = this.__worklist;
22219 leavelist = this.__leavelist; // initialize
22220
22221 worklist.push(new Element(root, null, null, null));
22222 leavelist.push(new Element(null, null, null, null));
22223
22224 while (worklist.length) {
22225 element = worklist.pop();
22226
22227 if (element === sentinel) {
22228 element = leavelist.pop();
22229 ret = this.__execute(visitor.leave, element);
22230
22231 if (this.__state === BREAK || ret === BREAK) {
22232 return;
22233 }
22234
22235 continue;
22236 }
22237
22238 if (element.node) {
22239 ret = this.__execute(visitor.enter, element);
22240
22241 if (this.__state === BREAK || ret === BREAK) {
22242 return;
22243 }
22244
22245 worklist.push(sentinel);
22246 leavelist.push(element);
22247
22248 if (this.__state === SKIP || ret === SKIP) {
22249 continue;
22250 }
22251
22252 node = element.node;
22253 nodeType = node.type || element.wrap;
22254 candidates = this.__keys[nodeType];
22255
22256 if (!candidates) {
22257 if (this.__fallback) {
22258 candidates = this.__fallback(node);
22259 } else {
22260 throw new Error('Unknown node type ' + nodeType + '.');
22261 }
22262 }
22263
22264 current = candidates.length;
22265
22266 while ((current -= 1) >= 0) {
22267 key = candidates[current];
22268 candidate = node[key];
22269
22270 if (!candidate) {
22271 continue;
22272 }
22273
22274 if (Array.isArray(candidate)) {
22275 current2 = candidate.length;
22276
22277 while ((current2 -= 1) >= 0) {
22278 if (!candidate[current2]) {
22279 continue;
22280 }
22281
22282 if (candidateExistsInLeaveList(leavelist, candidate[current2])) {
22283 continue;
22284 }
22285
22286 if (isProperty(nodeType, candidates[current])) {
22287 element = new Element(candidate[current2], [key, current2], 'Property', null);
22288 } else if (isNode(candidate[current2])) {
22289 element = new Element(candidate[current2], [key, current2], null, null);
22290 } else {
22291 continue;
22292 }
22293
22294 worklist.push(element);
22295 }
22296 } else if (isNode(candidate)) {
22297 if (candidateExistsInLeaveList(leavelist, candidate)) {
22298 continue;
22299 }
22300
22301 worklist.push(new Element(candidate, key, null, null));
22302 }
22303 }
22304 }
22305 }
22306 };
22307
22308 Controller.prototype.replace = function replace(root, visitor) {
22309 var worklist, leavelist, node, nodeType, target, element, current, current2, candidates, candidate, sentinel, outer, key;
22310
22311 function removeElem(element) {
22312 var i, key, nextElem, parent;
22313
22314 if (element.ref.remove()) {
22315 // When the reference is an element of an array.
22316 key = element.ref.key;
22317 parent = element.ref.parent; // If removed from array, then decrease following items' keys.
22318
22319 i = worklist.length;
22320
22321 while (i--) {
22322 nextElem = worklist[i];
22323
22324 if (nextElem.ref && nextElem.ref.parent === parent) {
22325 if (nextElem.ref.key < key) {
22326 break;
22327 }
22328
22329 --nextElem.ref.key;
22330 }
22331 }
22332 }
22333 }
22334
22335 this.__initialize(root, visitor);
22336
22337 sentinel = {}; // reference
22338
22339 worklist = this.__worklist;
22340 leavelist = this.__leavelist; // initialize
22341
22342 outer = {
22343 root: root
22344 };
22345 element = new Element(root, null, null, new Reference(outer, 'root'));
22346 worklist.push(element);
22347 leavelist.push(element);
22348
22349 while (worklist.length) {
22350 element = worklist.pop();
22351
22352 if (element === sentinel) {
22353 element = leavelist.pop();
22354 target = this.__execute(visitor.leave, element); // node may be replaced with null,
22355 // so distinguish between undefined and null in this place
22356
22357 if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
22358 // replace
22359 element.ref.replace(target);
22360 }
22361
22362 if (this.__state === REMOVE || target === REMOVE) {
22363 removeElem(element);
22364 }
22365
22366 if (this.__state === BREAK || target === BREAK) {
22367 return outer.root;
22368 }
22369
22370 continue;
22371 }
22372
22373 target = this.__execute(visitor.enter, element); // node may be replaced with null,
22374 // so distinguish between undefined and null in this place
22375
22376 if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
22377 // replace
22378 element.ref.replace(target);
22379 element.node = target;
22380 }
22381
22382 if (this.__state === REMOVE || target === REMOVE) {
22383 removeElem(element);
22384 element.node = null;
22385 }
22386
22387 if (this.__state === BREAK || target === BREAK) {
22388 return outer.root;
22389 } // node may be null
22390
22391
22392 node = element.node;
22393
22394 if (!node) {
22395 continue;
22396 }
22397
22398 worklist.push(sentinel);
22399 leavelist.push(element);
22400
22401 if (this.__state === SKIP || target === SKIP) {
22402 continue;
22403 }
22404
22405 nodeType = node.type || element.wrap;
22406 candidates = this.__keys[nodeType];
22407
22408 if (!candidates) {
22409 if (this.__fallback) {
22410 candidates = this.__fallback(node);
22411 } else {
22412 throw new Error('Unknown node type ' + nodeType + '.');
22413 }
22414 }
22415
22416 current = candidates.length;
22417
22418 while ((current -= 1) >= 0) {
22419 key = candidates[current];
22420 candidate = node[key];
22421
22422 if (!candidate) {
22423 continue;
22424 }
22425
22426 if (Array.isArray(candidate)) {
22427 current2 = candidate.length;
22428
22429 while ((current2 -= 1) >= 0) {
22430 if (!candidate[current2]) {
22431 continue;
22432 }
22433
22434 if (isProperty(nodeType, candidates[current])) {
22435 element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
22436 } else if (isNode(candidate[current2])) {
22437 element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
22438 } else {
22439 continue;
22440 }
22441
22442 worklist.push(element);
22443 }
22444 } else if (isNode(candidate)) {
22445 worklist.push(new Element(candidate, key, null, new Reference(node, key)));
22446 }
22447 }
22448 }
22449
22450 return outer.root;
22451 };
22452
22453 function traverse(root, visitor) {
22454 var controller = new Controller();
22455 return controller.traverse(root, visitor);
22456 }
22457
22458 function replace(root, visitor) {
22459 var controller = new Controller();
22460 return controller.replace(root, visitor);
22461 }
22462
22463 function extendCommentRange(comment, tokens) {
22464 var target;
22465 target = upperBound(tokens, function search(token) {
22466 return token.range[0] > comment.range[0];
22467 });
22468 comment.extendedRange = [comment.range[0], comment.range[1]];
22469
22470 if (target !== tokens.length) {
22471 comment.extendedRange[1] = tokens[target].range[0];
22472 }
22473
22474 target -= 1;
22475
22476 if (target >= 0) {
22477 comment.extendedRange[0] = tokens[target].range[1];
22478 }
22479
22480 return comment;
22481 }
22482
22483 function attachComments(tree, providedComments, tokens) {
22484 // At first, we should calculate extended comment ranges.
22485 var comments = [],
22486 comment,
22487 len,
22488 i,
22489 cursor;
22490
22491 if (!tree.range) {
22492 throw new Error('attachComments needs range information');
22493 } // tokens array is empty, we attach comments to tree as 'leadingComments'
22494
22495
22496 if (!tokens.length) {
22497 if (providedComments.length) {
22498 for (i = 0, len = providedComments.length; i < len; i += 1) {
22499 comment = deepCopy(providedComments[i]);
22500 comment.extendedRange = [0, tree.range[0]];
22501 comments.push(comment);
22502 }
22503
22504 tree.leadingComments = comments;
22505 }
22506
22507 return tree;
22508 }
22509
22510 for (i = 0, len = providedComments.length; i < len; i += 1) {
22511 comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
22512 } // This is based on John Freeman's implementation.
22513
22514
22515 cursor = 0;
22516 traverse(tree, {
22517 enter: function (node) {
22518 var comment;
22519
22520 while (cursor < comments.length) {
22521 comment = comments[cursor];
22522
22523 if (comment.extendedRange[1] > node.range[0]) {
22524 break;
22525 }
22526
22527 if (comment.extendedRange[1] === node.range[0]) {
22528 if (!node.leadingComments) {
22529 node.leadingComments = [];
22530 }
22531
22532 node.leadingComments.push(comment);
22533 comments.splice(cursor, 1);
22534 } else {
22535 cursor += 1;
22536 }
22537 } // already out of owned node
22538
22539
22540 if (cursor === comments.length) {
22541 return VisitorOption.Break;
22542 }
22543
22544 if (comments[cursor].extendedRange[0] > node.range[1]) {
22545 return VisitorOption.Skip;
22546 }
22547 }
22548 });
22549 cursor = 0;
22550 traverse(tree, {
22551 leave: function (node) {
22552 var comment;
22553
22554 while (cursor < comments.length) {
22555 comment = comments[cursor];
22556
22557 if (node.range[1] < comment.extendedRange[0]) {
22558 break;
22559 }
22560
22561 if (node.range[1] === comment.extendedRange[0]) {
22562 if (!node.trailingComments) {
22563 node.trailingComments = [];
22564 }
22565
22566 node.trailingComments.push(comment);
22567 comments.splice(cursor, 1);
22568 } else {
22569 cursor += 1;
22570 }
22571 } // already out of owned node
22572
22573
22574 if (cursor === comments.length) {
22575 return VisitorOption.Break;
22576 }
22577
22578 if (comments[cursor].extendedRange[0] > node.range[1]) {
22579 return VisitorOption.Skip;
22580 }
22581 }
22582 });
22583 return tree;
22584 }
22585
22586 exports.Syntax = Syntax;
22587 exports.traverse = traverse;
22588 exports.replace = replace;
22589 exports.attachComments = attachComments;
22590 exports.VisitorKeys = VisitorKeys;
22591 exports.VisitorOption = VisitorOption;
22592 exports.Controller = Controller;
22593
22594 exports.cloneEnvironment = function () {
22595 return clone({});
22596 };
22597
22598 return exports;
22599 })(exports);
22600 /* vim: set sw=4 ts=4 et tw=80 : */
22601
22602 /***/ }),
22603 /* 433 */
22604 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
22605
22606 /*
22607 Copyright (C) 2014 Yusuke Suzuki <utatane.tea@gmail.com>
22608
22609 Redistribution and use in source and binary forms, with or without
22610 modification, are permitted provided that the following conditions are met:
22611
22612 * Redistributions of source code must retain the above copyright
22613 notice, this list of conditions and the following disclaimer.
22614 * Redistributions in binary form must reproduce the above copyright
22615 notice, this list of conditions and the following disclaimer in the
22616 documentation and/or other materials provided with the distribution.
22617
22618 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22619 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22620 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22621 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
22622 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22623 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22624 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22625 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22626 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22627 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22628 */
22629 (function () {
22630 'use strict';
22631
22632 var estraverse = __webpack_require__(432);
22633
22634 function isNode(node) {
22635 if (node == null) {
22636 return false;
22637 }
22638
22639 return typeof node === 'object' && typeof node.type === 'string';
22640 }
22641
22642 function isProperty(nodeType, key) {
22643 return (nodeType === estraverse.Syntax.ObjectExpression || nodeType === estraverse.Syntax.ObjectPattern) && key === 'properties';
22644 }
22645
22646 function Visitor(visitor, options) {
22647 options = options || {};
22648 this.__visitor = visitor || this;
22649 this.__childVisitorKeys = options.childVisitorKeys ? Object.assign({}, estraverse.VisitorKeys, options.childVisitorKeys) : estraverse.VisitorKeys;
22650
22651 if (options.fallback === 'iteration') {
22652 this.__fallback = Object.keys;
22653 } else if (typeof options.fallback === 'function') {
22654 this.__fallback = options.fallback;
22655 }
22656 }
22657 /* Default method for visiting children.
22658 * When you need to call default visiting operation inside custom visiting
22659 * operation, you can use it with `this.visitChildren(node)`.
22660 */
22661
22662
22663 Visitor.prototype.visitChildren = function (node) {
22664 var type, children, i, iz, j, jz, child;
22665
22666 if (node == null) {
22667 return;
22668 }
22669
22670 type = node.type || estraverse.Syntax.Property;
22671 children = this.__childVisitorKeys[type];
22672
22673 if (!children) {
22674 if (this.__fallback) {
22675 children = this.__fallback(node);
22676 } else {
22677 throw new Error('Unknown node type ' + type + '.');
22678 }
22679 }
22680
22681 for (i = 0, iz = children.length; i < iz; ++i) {
22682 child = node[children[i]];
22683
22684 if (child) {
22685 if (Array.isArray(child)) {
22686 for (j = 0, jz = child.length; j < jz; ++j) {
22687 if (child[j]) {
22688 if (isNode(child[j]) || isProperty(type, children[i])) {
22689 this.visit(child[j]);
22690 }
22691 }
22692 }
22693 } else if (isNode(child)) {
22694 this.visit(child);
22695 }
22696 }
22697 }
22698 };
22699 /* Dispatching node. */
22700
22701
22702 Visitor.prototype.visit = function (node) {
22703 var type;
22704
22705 if (node == null) {
22706 return;
22707 }
22708
22709 type = node.type || estraverse.Syntax.Property;
22710
22711 if (this.__visitor[type]) {
22712 this.__visitor[type].call(this, node);
22713
22714 return;
22715 }
22716
22717 this.visitChildren(node);
22718 };
22719
22720 exports.version = __webpack_require__(434).version;
22721 exports.Visitor = Visitor;
22722
22723 exports.visit = function (node, visitor, options) {
22724 var v = new Visitor(visitor, options);
22725 v.visit(node);
22726 };
22727 })();
22728 /* vim: set sw=4 ts=4 et tw=80 : */
22729
22730 /***/ }),
22731 /* 434 */
22732 /***/ ((module) => {
22733
22734 "use strict";
22735 module.exports = JSON.parse('{"name":"esrecurse","description":"ECMAScript AST recursive visitor","homepage":"https://github.com/estools/esrecurse","main":"esrecurse.js","version":"4.3.0","engines":{"node":">=4.0"},"maintainers":[{"name":"Yusuke Suzuki","email":"utatane.tea@gmail.com","web":"https://github.com/Constellation"}],"repository":{"type":"git","url":"https://github.com/estools/esrecurse.git"},"dependencies":{"estraverse":"^5.2.0"},"devDependencies":{"babel-cli":"^6.24.1","babel-eslint":"^7.2.3","babel-preset-es2015":"^6.24.1","babel-register":"^6.24.1","chai":"^4.0.2","esprima":"^4.0.0","gulp":"^3.9.0","gulp-bump":"^2.7.0","gulp-eslint":"^4.0.0","gulp-filter":"^5.0.0","gulp-git":"^2.4.1","gulp-mocha":"^4.3.1","gulp-tag-version":"^1.2.1","jsdoc":"^3.3.0-alpha10","minimist":"^1.1.0"},"license":"BSD-2-Clause","scripts":{"test":"gulp travis","unit-test":"gulp test","lint":"gulp lint"},"babel":{"presets":["es2015"]}}');
22736
22737 /***/ }),
22738 /* 435 */
22739 /***/ ((__unused_webpack_module, exports) => {
22740
22741 "use strict";
22742
22743
22744 Object.defineProperty(exports, "__esModule", ({ value: true }));
22745
22746 const KEYS = {
22747 AssignmentExpression: [
22748 "left",
22749 "right"
22750 ],
22751 AssignmentPattern: [
22752 "left",
22753 "right"
22754 ],
22755 ArrayExpression: [
22756 "elements"
22757 ],
22758 ArrayPattern: [
22759 "elements"
22760 ],
22761 ArrowFunctionExpression: [
22762 "params",
22763 "body"
22764 ],
22765 AwaitExpression: [
22766 "argument"
22767 ],
22768 BlockStatement: [
22769 "body"
22770 ],
22771 BinaryExpression: [
22772 "left",
22773 "right"
22774 ],
22775 BreakStatement: [
22776 "label"
22777 ],
22778 CallExpression: [
22779 "callee",
22780 "arguments"
22781 ],
22782 CatchClause: [
22783 "param",
22784 "body"
22785 ],
22786 ChainExpression: [
22787 "expression"
22788 ],
22789 ClassBody: [
22790 "body"
22791 ],
22792 ClassDeclaration: [
22793 "id",
22794 "superClass",
22795 "body"
22796 ],
22797 ClassExpression: [
22798 "id",
22799 "superClass",
22800 "body"
22801 ],
22802 ConditionalExpression: [
22803 "test",
22804 "consequent",
22805 "alternate"
22806 ],
22807 ContinueStatement: [
22808 "label"
22809 ],
22810 DebuggerStatement: [],
22811 DoWhileStatement: [
22812 "body",
22813 "test"
22814 ],
22815 EmptyStatement: [],
22816 ExportAllDeclaration: [
22817 "exported",
22818 "source"
22819 ],
22820 ExportDefaultDeclaration: [
22821 "declaration"
22822 ],
22823 ExportNamedDeclaration: [
22824 "declaration",
22825 "specifiers",
22826 "source"
22827 ],
22828 ExportSpecifier: [
22829 "exported",
22830 "local"
22831 ],
22832 ExpressionStatement: [
22833 "expression"
22834 ],
22835 ExperimentalRestProperty: [
22836 "argument"
22837 ],
22838 ExperimentalSpreadProperty: [
22839 "argument"
22840 ],
22841 ForStatement: [
22842 "init",
22843 "test",
22844 "update",
22845 "body"
22846 ],
22847 ForInStatement: [
22848 "left",
22849 "right",
22850 "body"
22851 ],
22852 ForOfStatement: [
22853 "left",
22854 "right",
22855 "body"
22856 ],
22857 FunctionDeclaration: [
22858 "id",
22859 "params",
22860 "body"
22861 ],
22862 FunctionExpression: [
22863 "id",
22864 "params",
22865 "body"
22866 ],
22867 Identifier: [],
22868 IfStatement: [
22869 "test",
22870 "consequent",
22871 "alternate"
22872 ],
22873 ImportDeclaration: [
22874 "specifiers",
22875 "source"
22876 ],
22877 ImportDefaultSpecifier: [
22878 "local"
22879 ],
22880 ImportExpression: [
22881 "source"
22882 ],
22883 ImportNamespaceSpecifier: [
22884 "local"
22885 ],
22886 ImportSpecifier: [
22887 "imported",
22888 "local"
22889 ],
22890 JSXAttribute: [
22891 "name",
22892 "value"
22893 ],
22894 JSXClosingElement: [
22895 "name"
22896 ],
22897 JSXElement: [
22898 "openingElement",
22899 "children",
22900 "closingElement"
22901 ],
22902 JSXEmptyExpression: [],
22903 JSXExpressionContainer: [
22904 "expression"
22905 ],
22906 JSXIdentifier: [],
22907 JSXMemberExpression: [
22908 "object",
22909 "property"
22910 ],
22911 JSXNamespacedName: [
22912 "namespace",
22913 "name"
22914 ],
22915 JSXOpeningElement: [
22916 "name",
22917 "attributes"
22918 ],
22919 JSXSpreadAttribute: [
22920 "argument"
22921 ],
22922 JSXText: [],
22923 JSXFragment: [
22924 "openingFragment",
22925 "children",
22926 "closingFragment"
22927 ],
22928 Literal: [],
22929 LabeledStatement: [
22930 "label",
22931 "body"
22932 ],
22933 LogicalExpression: [
22934 "left",
22935 "right"
22936 ],
22937 MemberExpression: [
22938 "object",
22939 "property"
22940 ],
22941 MetaProperty: [
22942 "meta",
22943 "property"
22944 ],
22945 MethodDefinition: [
22946 "key",
22947 "value"
22948 ],
22949 NewExpression: [
22950 "callee",
22951 "arguments"
22952 ],
22953 ObjectExpression: [
22954 "properties"
22955 ],
22956 ObjectPattern: [
22957 "properties"
22958 ],
22959 PrivateIdentifier: [],
22960 Program: [
22961 "body"
22962 ],
22963 Property: [
22964 "key",
22965 "value"
22966 ],
22967 PropertyDefinition: [
22968 "key",
22969 "value"
22970 ],
22971 RestElement: [
22972 "argument"
22973 ],
22974 ReturnStatement: [
22975 "argument"
22976 ],
22977 SequenceExpression: [
22978 "expressions"
22979 ],
22980 SpreadElement: [
22981 "argument"
22982 ],
22983 StaticBlock: [
22984 "body"
22985 ],
22986 Super: [],
22987 SwitchStatement: [
22988 "discriminant",
22989 "cases"
22990 ],
22991 SwitchCase: [
22992 "test",
22993 "consequent"
22994 ],
22995 TaggedTemplateExpression: [
22996 "tag",
22997 "quasi"
22998 ],
22999 TemplateElement: [],
23000 TemplateLiteral: [
23001 "quasis",
23002 "expressions"
23003 ],
23004 ThisExpression: [],
23005 ThrowStatement: [
23006 "argument"
23007 ],
23008 TryStatement: [
23009 "block",
23010 "handler",
23011 "finalizer"
23012 ],
23013 UnaryExpression: [
23014 "argument"
23015 ],
23016 UpdateExpression: [
23017 "argument"
23018 ],
23019 VariableDeclaration: [
23020 "declarations"
23021 ],
23022 VariableDeclarator: [
23023 "id",
23024 "init"
23025 ],
23026 WhileStatement: [
23027 "test",
23028 "body"
23029 ],
23030 WithStatement: [
23031 "object",
23032 "body"
23033 ],
23034 YieldExpression: [
23035 "argument"
23036 ]
23037 };
23038
23039 // Types.
23040 const NODE_TYPES = Object.keys(KEYS);
23041
23042 // Freeze the keys.
23043 for (const type of NODE_TYPES) {
23044 Object.freeze(KEYS[type]);
23045 }
23046 Object.freeze(KEYS);
23047
23048 /**
23049 * @author Toru Nagashima <https://github.com/mysticatea>
23050 * See LICENSE file in root directory for full license.
23051 */
23052
23053 // List to ignore keys.
23054 const KEY_BLACKLIST = new Set([
23055 "parent",
23056 "leadingComments",
23057 "trailingComments"
23058 ]);
23059
23060 /**
23061 * Check whether a given key should be used or not.
23062 * @param {string} key The key to check.
23063 * @returns {boolean} `true` if the key should be used.
23064 */
23065 function filterKey(key) {
23066 return !KEY_BLACKLIST.has(key) && key[0] !== "_";
23067 }
23068
23069 /**
23070 * Get visitor keys of a given node.
23071 * @param {Object} node The AST node to get keys.
23072 * @returns {string[]} Visitor keys of the node.
23073 */
23074 function getKeys(node) {
23075 return Object.keys(node).filter(filterKey);
23076 }
23077
23078 // Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
23079 // eslint-disable-next-line valid-jsdoc
23080 /**
23081 * Make the union set with `KEYS` and given keys.
23082 * @param {Object} additionalKeys The additional keys.
23083 * @returns {{ [type: string]: string[] | undefined }} The union set.
23084 */
23085 function unionWith(additionalKeys) {
23086 const retv = Object.assign({}, KEYS);
23087
23088 for (const type of Object.keys(additionalKeys)) {
23089 if (Object.prototype.hasOwnProperty.call(retv, type)) {
23090 const keys = new Set(additionalKeys[type]);
23091
23092 for (const key of retv[type]) {
23093 keys.add(key);
23094 }
23095
23096 retv[type] = Object.freeze(Array.from(keys));
23097 } else {
23098 retv[type] = Object.freeze(Array.from(additionalKeys[type]));
23099 }
23100 }
23101
23102 return Object.freeze(retv);
23103 }
23104
23105 exports.KEYS = KEYS;
23106 exports.getKeys = getKeys;
23107 exports.unionWith = unionWith;
23108 //# sourceMappingURL=eslint-visitor-keys.cjs.map
23109
23110
23111 /***/ }),
23112 /* 436 */
23113 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
23114
23115 "use strict";
23116
23117
23118 Object.defineProperty(exports, "__esModule", ({ value: true }));
23119
23120 var acorn = __webpack_require__(437);
23121 var jsx = __webpack_require__(440);
23122 var visitorKeys = __webpack_require__(435);
23123
23124 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
23125
23126 function _interopNamespace(e) {
23127 if (e && e.__esModule) return e;
23128 var n = Object.create(null);
23129 if (e) {
23130 Object.keys(e).forEach(function (k) {
23131 if (k !== 'default') {
23132 var d = Object.getOwnPropertyDescriptor(e, k);
23133 Object.defineProperty(n, k, d.get ? d : {
23134 enumerable: true,
23135 get: function () { return e[k]; }
23136 });
23137 }
23138 });
23139 }
23140 n["default"] = e;
23141 return Object.freeze(n);
23142 }
23143
23144 var acorn__namespace = /*#__PURE__*/_interopNamespace(acorn);
23145 var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx);
23146 var visitorKeys__namespace = /*#__PURE__*/_interopNamespace(visitorKeys);
23147
23148 /**
23149 * @fileoverview The AST node types produced by the parser.
23150 * @author Nicholas C. Zakas
23151 */
23152
23153 //------------------------------------------------------------------------------
23154 // Requirements
23155 //------------------------------------------------------------------------------
23156
23157 // None!
23158
23159 //------------------------------------------------------------------------------
23160 // Public
23161 //------------------------------------------------------------------------------
23162
23163 var astNodeTypes = {
23164 AssignmentExpression: "AssignmentExpression",
23165 AssignmentPattern: "AssignmentPattern",
23166 ArrayExpression: "ArrayExpression",
23167 ArrayPattern: "ArrayPattern",
23168 ArrowFunctionExpression: "ArrowFunctionExpression",
23169 AwaitExpression: "AwaitExpression",
23170 BlockStatement: "BlockStatement",
23171 BinaryExpression: "BinaryExpression",
23172 BreakStatement: "BreakStatement",
23173 CallExpression: "CallExpression",
23174 CatchClause: "CatchClause",
23175 ClassBody: "ClassBody",
23176 ClassDeclaration: "ClassDeclaration",
23177 ClassExpression: "ClassExpression",
23178 ConditionalExpression: "ConditionalExpression",
23179 ContinueStatement: "ContinueStatement",
23180 DoWhileStatement: "DoWhileStatement",
23181 DebuggerStatement: "DebuggerStatement",
23182 EmptyStatement: "EmptyStatement",
23183 ExpressionStatement: "ExpressionStatement",
23184 ForStatement: "ForStatement",
23185 ForInStatement: "ForInStatement",
23186 ForOfStatement: "ForOfStatement",
23187 FunctionDeclaration: "FunctionDeclaration",
23188 FunctionExpression: "FunctionExpression",
23189 Identifier: "Identifier",
23190 IfStatement: "IfStatement",
23191 Literal: "Literal",
23192 LabeledStatement: "LabeledStatement",
23193 LogicalExpression: "LogicalExpression",
23194 MemberExpression: "MemberExpression",
23195 MetaProperty: "MetaProperty",
23196 MethodDefinition: "MethodDefinition",
23197 NewExpression: "NewExpression",
23198 ObjectExpression: "ObjectExpression",
23199 ObjectPattern: "ObjectPattern",
23200 Program: "Program",
23201 Property: "Property",
23202 RestElement: "RestElement",
23203 ReturnStatement: "ReturnStatement",
23204 SequenceExpression: "SequenceExpression",
23205 SpreadElement: "SpreadElement",
23206 Super: "Super",
23207 SwitchCase: "SwitchCase",
23208 SwitchStatement: "SwitchStatement",
23209 TaggedTemplateExpression: "TaggedTemplateExpression",
23210 TemplateElement: "TemplateElement",
23211 TemplateLiteral: "TemplateLiteral",
23212 ThisExpression: "ThisExpression",
23213 ThrowStatement: "ThrowStatement",
23214 TryStatement: "TryStatement",
23215 UnaryExpression: "UnaryExpression",
23216 UpdateExpression: "UpdateExpression",
23217 VariableDeclaration: "VariableDeclaration",
23218 VariableDeclarator: "VariableDeclarator",
23219 WhileStatement: "WhileStatement",
23220 WithStatement: "WithStatement",
23221 YieldExpression: "YieldExpression",
23222 JSXIdentifier: "JSXIdentifier",
23223 JSXNamespacedName: "JSXNamespacedName",
23224 JSXMemberExpression: "JSXMemberExpression",
23225 JSXEmptyExpression: "JSXEmptyExpression",
23226 JSXExpressionContainer: "JSXExpressionContainer",
23227 JSXElement: "JSXElement",
23228 JSXClosingElement: "JSXClosingElement",
23229 JSXOpeningElement: "JSXOpeningElement",
23230 JSXAttribute: "JSXAttribute",
23231 JSXSpreadAttribute: "JSXSpreadAttribute",
23232 JSXText: "JSXText",
23233 ExportDefaultDeclaration: "ExportDefaultDeclaration",
23234 ExportNamedDeclaration: "ExportNamedDeclaration",
23235 ExportAllDeclaration: "ExportAllDeclaration",
23236 ExportSpecifier: "ExportSpecifier",
23237 ImportDeclaration: "ImportDeclaration",
23238 ImportSpecifier: "ImportSpecifier",
23239 ImportDefaultSpecifier: "ImportDefaultSpecifier",
23240 ImportNamespaceSpecifier: "ImportNamespaceSpecifier"
23241 };
23242
23243 /**
23244 * @fileoverview Translates tokens between Acorn format and Esprima format.
23245 * @author Nicholas C. Zakas
23246 */
23247 /* eslint no-underscore-dangle: 0 */
23248
23249 //------------------------------------------------------------------------------
23250 // Requirements
23251 //------------------------------------------------------------------------------
23252
23253 // none!
23254
23255 //------------------------------------------------------------------------------
23256 // Private
23257 //------------------------------------------------------------------------------
23258
23259
23260 // Esprima Token Types
23261 const Token = {
23262 Boolean: "Boolean",
23263 EOF: "<end>",
23264 Identifier: "Identifier",
23265 PrivateIdentifier: "PrivateIdentifier",
23266 Keyword: "Keyword",
23267 Null: "Null",
23268 Numeric: "Numeric",
23269 Punctuator: "Punctuator",
23270 String: "String",
23271 RegularExpression: "RegularExpression",
23272 Template: "Template",
23273 JSXIdentifier: "JSXIdentifier",
23274 JSXText: "JSXText"
23275 };
23276
23277 /**
23278 * Converts part of a template into an Esprima token.
23279 * @param {AcornToken[]} tokens The Acorn tokens representing the template.
23280 * @param {string} code The source code.
23281 * @returns {EsprimaToken} The Esprima equivalent of the template token.
23282 * @private
23283 */
23284 function convertTemplatePart(tokens, code) {
23285 const firstToken = tokens[0],
23286 lastTemplateToken = tokens[tokens.length - 1];
23287
23288 const token = {
23289 type: Token.Template,
23290 value: code.slice(firstToken.start, lastTemplateToken.end)
23291 };
23292
23293 if (firstToken.loc) {
23294 token.loc = {
23295 start: firstToken.loc.start,
23296 end: lastTemplateToken.loc.end
23297 };
23298 }
23299
23300 if (firstToken.range) {
23301 token.start = firstToken.range[0];
23302 token.end = lastTemplateToken.range[1];
23303 token.range = [token.start, token.end];
23304 }
23305
23306 return token;
23307 }
23308
23309 /**
23310 * Contains logic to translate Acorn tokens into Esprima tokens.
23311 * @param {Object} acornTokTypes The Acorn token types.
23312 * @param {string} code The source code Acorn is parsing. This is necessary
23313 * to correct the "value" property of some tokens.
23314 * @constructor
23315 */
23316 function TokenTranslator(acornTokTypes, code) {
23317
23318 // token types
23319 this._acornTokTypes = acornTokTypes;
23320
23321 // token buffer for templates
23322 this._tokens = [];
23323
23324 // track the last curly brace
23325 this._curlyBrace = null;
23326
23327 // the source code
23328 this._code = code;
23329
23330 }
23331
23332 TokenTranslator.prototype = {
23333 constructor: TokenTranslator,
23334
23335 /**
23336 * Translates a single Esprima token to a single Acorn token. This may be
23337 * inaccurate due to how templates are handled differently in Esprima and
23338 * Acorn, but should be accurate for all other tokens.
23339 * @param {AcornToken} token The Acorn token to translate.
23340 * @param {Object} extra Espree extra object.
23341 * @returns {EsprimaToken} The Esprima version of the token.
23342 */
23343 translate(token, extra) {
23344
23345 const type = token.type,
23346 tt = this._acornTokTypes;
23347
23348 if (type === tt.name) {
23349 token.type = Token.Identifier;
23350
23351 // TODO: See if this is an Acorn bug
23352 if (token.value === "static") {
23353 token.type = Token.Keyword;
23354 }
23355
23356 if (extra.ecmaVersion > 5 && (token.value === "yield" || token.value === "let")) {
23357 token.type = Token.Keyword;
23358 }
23359
23360 } else if (type === tt.privateId) {
23361 token.type = Token.PrivateIdentifier;
23362
23363 } else if (type === tt.semi || type === tt.comma ||
23364 type === tt.parenL || type === tt.parenR ||
23365 type === tt.braceL || type === tt.braceR ||
23366 type === tt.dot || type === tt.bracketL ||
23367 type === tt.colon || type === tt.question ||
23368 type === tt.bracketR || type === tt.ellipsis ||
23369 type === tt.arrow || type === tt.jsxTagStart ||
23370 type === tt.incDec || type === tt.starstar ||
23371 type === tt.jsxTagEnd || type === tt.prefix ||
23372 type === tt.questionDot ||
23373 (type.binop && !type.keyword) ||
23374 type.isAssign) {
23375
23376 token.type = Token.Punctuator;
23377 token.value = this._code.slice(token.start, token.end);
23378 } else if (type === tt.jsxName) {
23379 token.type = Token.JSXIdentifier;
23380 } else if (type.label === "jsxText" || type === tt.jsxAttrValueToken) {
23381 token.type = Token.JSXText;
23382 } else if (type.keyword) {
23383 if (type.keyword === "true" || type.keyword === "false") {
23384 token.type = Token.Boolean;
23385 } else if (type.keyword === "null") {
23386 token.type = Token.Null;
23387 } else {
23388 token.type = Token.Keyword;
23389 }
23390 } else if (type === tt.num) {
23391 token.type = Token.Numeric;
23392 token.value = this._code.slice(token.start, token.end);
23393 } else if (type === tt.string) {
23394
23395 if (extra.jsxAttrValueToken) {
23396 extra.jsxAttrValueToken = false;
23397 token.type = Token.JSXText;
23398 } else {
23399 token.type = Token.String;
23400 }
23401
23402 token.value = this._code.slice(token.start, token.end);
23403 } else if (type === tt.regexp) {
23404 token.type = Token.RegularExpression;
23405 const value = token.value;
23406
23407 token.regex = {
23408 flags: value.flags,
23409 pattern: value.pattern
23410 };
23411 token.value = `/${value.pattern}/${value.flags}`;
23412 }
23413
23414 return token;
23415 },
23416
23417 /**
23418 * Function to call during Acorn's onToken handler.
23419 * @param {AcornToken} token The Acorn token.
23420 * @param {Object} extra The Espree extra object.
23421 * @returns {void}
23422 */
23423 onToken(token, extra) {
23424
23425 const that = this,
23426 tt = this._acornTokTypes,
23427 tokens = extra.tokens,
23428 templateTokens = this._tokens;
23429
23430 /**
23431 * Flushes the buffered template tokens and resets the template
23432 * tracking.
23433 * @returns {void}
23434 * @private
23435 */
23436 function translateTemplateTokens() {
23437 tokens.push(convertTemplatePart(that._tokens, that._code));
23438 that._tokens = [];
23439 }
23440
23441 if (token.type === tt.eof) {
23442
23443 // might be one last curlyBrace
23444 if (this._curlyBrace) {
23445 tokens.push(this.translate(this._curlyBrace, extra));
23446 }
23447
23448 return;
23449 }
23450
23451 if (token.type === tt.backQuote) {
23452
23453 // if there's already a curly, it's not part of the template
23454 if (this._curlyBrace) {
23455 tokens.push(this.translate(this._curlyBrace, extra));
23456 this._curlyBrace = null;
23457 }
23458
23459 templateTokens.push(token);
23460
23461 // it's the end
23462 if (templateTokens.length > 1) {
23463 translateTemplateTokens();
23464 }
23465
23466 return;
23467 }
23468 if (token.type === tt.dollarBraceL) {
23469 templateTokens.push(token);
23470 translateTemplateTokens();
23471 return;
23472 }
23473 if (token.type === tt.braceR) {
23474
23475 // if there's already a curly, it's not part of the template
23476 if (this._curlyBrace) {
23477 tokens.push(this.translate(this._curlyBrace, extra));
23478 }
23479
23480 // store new curly for later
23481 this._curlyBrace = token;
23482 return;
23483 }
23484 if (token.type === tt.template || token.type === tt.invalidTemplate) {
23485 if (this._curlyBrace) {
23486 templateTokens.push(this._curlyBrace);
23487 this._curlyBrace = null;
23488 }
23489
23490 templateTokens.push(token);
23491 return;
23492 }
23493
23494 if (this._curlyBrace) {
23495 tokens.push(this.translate(this._curlyBrace, extra));
23496 this._curlyBrace = null;
23497 }
23498
23499 tokens.push(this.translate(token, extra));
23500 }
23501 };
23502
23503 /**
23504 * @fileoverview A collection of methods for processing Espree's options.
23505 * @author Kai Cataldo
23506 */
23507
23508 //------------------------------------------------------------------------------
23509 // Helpers
23510 //------------------------------------------------------------------------------
23511
23512 const SUPPORTED_VERSIONS = [
23513 3,
23514 5,
23515 6,
23516 7,
23517 8,
23518 9,
23519 10,
23520 11,
23521 12,
23522 13
23523 ];
23524
23525 /**
23526 * Get the latest ECMAScript version supported by Espree.
23527 * @returns {number} The latest ECMAScript version.
23528 */
23529 function getLatestEcmaVersion() {
23530 return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1];
23531 }
23532
23533 /**
23534 * Get the list of ECMAScript versions supported by Espree.
23535 * @returns {number[]} An array containing the supported ECMAScript versions.
23536 */
23537 function getSupportedEcmaVersions() {
23538 return [...SUPPORTED_VERSIONS];
23539 }
23540
23541 /**
23542 * Normalize ECMAScript version from the initial config
23543 * @param {(number|"latest")} ecmaVersion ECMAScript version from the initial config
23544 * @throws {Error} throws an error if the ecmaVersion is invalid.
23545 * @returns {number} normalized ECMAScript version
23546 */
23547 function normalizeEcmaVersion(ecmaVersion = 5) {
23548
23549 let version = ecmaVersion === "latest" ? getLatestEcmaVersion() : ecmaVersion;
23550
23551 if (typeof version !== "number") {
23552 throw new Error(`ecmaVersion must be a number or "latest". Received value of type ${typeof ecmaVersion} instead.`);
23553 }
23554
23555 // Calculate ECMAScript edition number from official year version starting with
23556 // ES2015, which corresponds with ES6 (or a difference of 2009).
23557 if (version >= 2015) {
23558 version -= 2009;
23559 }
23560
23561 if (!SUPPORTED_VERSIONS.includes(version)) {
23562 throw new Error("Invalid ecmaVersion.");
23563 }
23564
23565 return version;
23566 }
23567
23568 /**
23569 * Normalize sourceType from the initial config
23570 * @param {string} sourceType to normalize
23571 * @throws {Error} throw an error if sourceType is invalid
23572 * @returns {string} normalized sourceType
23573 */
23574 function normalizeSourceType(sourceType = "script") {
23575 if (sourceType === "script" || sourceType === "module") {
23576 return sourceType;
23577 }
23578
23579 if (sourceType === "commonjs") {
23580 return "script";
23581 }
23582
23583 throw new Error("Invalid sourceType.");
23584 }
23585
23586 /**
23587 * Normalize parserOptions
23588 * @param {Object} options the parser options to normalize
23589 * @throws {Error} throw an error if found invalid option.
23590 * @returns {Object} normalized options
23591 */
23592 function normalizeOptions(options) {
23593 const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion);
23594 const sourceType = normalizeSourceType(options.sourceType);
23595 const ranges = options.range === true;
23596 const locations = options.loc === true;
23597 const allowReserved = ecmaVersion === 3 ? "never" : false;
23598 const ecmaFeatures = options.ecmaFeatures || {};
23599 const allowReturnOutsideFunction = options.sourceType === "commonjs" ||
23600 Boolean(ecmaFeatures.globalReturn);
23601
23602 if (sourceType === "module" && ecmaVersion < 6) {
23603 throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options.");
23604 }
23605
23606 return Object.assign({}, options, {
23607 ecmaVersion,
23608 sourceType,
23609 ranges,
23610 locations,
23611 allowReserved,
23612 allowReturnOutsideFunction
23613 });
23614 }
23615
23616 /* eslint-disable no-param-reassign*/
23617
23618
23619 const STATE = Symbol("espree's internal state");
23620 const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode");
23621
23622
23623 /**
23624 * Converts an Acorn comment to a Esprima comment.
23625 * @param {boolean} block True if it's a block comment, false if not.
23626 * @param {string} text The text of the comment.
23627 * @param {int} start The index at which the comment starts.
23628 * @param {int} end The index at which the comment ends.
23629 * @param {Location} startLoc The location at which the comment starts.
23630 * @param {Location} endLoc The location at which the comment ends.
23631 * @returns {Object} The comment object.
23632 * @private
23633 */
23634 function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc) {
23635 const comment = {
23636 type: block ? "Block" : "Line",
23637 value: text
23638 };
23639
23640 if (typeof start === "number") {
23641 comment.start = start;
23642 comment.end = end;
23643 comment.range = [start, end];
23644 }
23645
23646 if (typeof startLoc === "object") {
23647 comment.loc = {
23648 start: startLoc,
23649 end: endLoc
23650 };
23651 }
23652
23653 return comment;
23654 }
23655
23656 var espree = () => Parser => {
23657 const tokTypes = Object.assign({}, Parser.acorn.tokTypes);
23658
23659 if (Parser.acornJsx) {
23660 Object.assign(tokTypes, Parser.acornJsx.tokTypes);
23661 }
23662
23663 return class Espree extends Parser {
23664 constructor(opts, code) {
23665 if (typeof opts !== "object" || opts === null) {
23666 opts = {};
23667 }
23668 if (typeof code !== "string" && !(code instanceof String)) {
23669 code = String(code);
23670 }
23671
23672 // save original source type in case of commonjs
23673 const originalSourceType = opts.sourceType;
23674 const options = normalizeOptions(opts);
23675 const ecmaFeatures = options.ecmaFeatures || {};
23676 const tokenTranslator =
23677 options.tokens === true
23678 ? new TokenTranslator(tokTypes, code)
23679 : null;
23680
23681 // Initialize acorn parser.
23682 super({
23683
23684 // do not use spread, because we don't want to pass any unknown options to acorn
23685 ecmaVersion: options.ecmaVersion,
23686 sourceType: options.sourceType,
23687 ranges: options.ranges,
23688 locations: options.locations,
23689 allowReserved: options.allowReserved,
23690
23691 // Truthy value is true for backward compatibility.
23692 allowReturnOutsideFunction: options.allowReturnOutsideFunction,
23693
23694 // Collect tokens
23695 onToken: token => {
23696 if (tokenTranslator) {
23697
23698 // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.
23699 tokenTranslator.onToken(token, this[STATE]);
23700 }
23701 if (token.type !== tokTypes.eof) {
23702 this[STATE].lastToken = token;
23703 }
23704 },
23705
23706 // Collect comments
23707 onComment: (block, text, start, end, startLoc, endLoc) => {
23708 if (this[STATE].comments) {
23709 const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc);
23710
23711 this[STATE].comments.push(comment);
23712 }
23713 }
23714 }, code);
23715
23716 /*
23717 * Data that is unique to Espree and is not represented internally in
23718 * Acorn. We put all of this data into a symbol property as a way to
23719 * avoid potential naming conflicts with future versions of Acorn.
23720 */
23721 this[STATE] = {
23722 originalSourceType: originalSourceType || options.sourceType,
23723 tokens: tokenTranslator ? [] : null,
23724 comments: options.comment === true ? [] : null,
23725 impliedStrict: ecmaFeatures.impliedStrict === true && this.options.ecmaVersion >= 5,
23726 ecmaVersion: this.options.ecmaVersion,
23727 jsxAttrValueToken: false,
23728 lastToken: null,
23729 templateElements: []
23730 };
23731 }
23732
23733 tokenize() {
23734 do {
23735 this.next();
23736 } while (this.type !== tokTypes.eof);
23737
23738 // Consume the final eof token
23739 this.next();
23740
23741 const extra = this[STATE];
23742 const tokens = extra.tokens;
23743
23744 if (extra.comments) {
23745 tokens.comments = extra.comments;
23746 }
23747
23748 return tokens;
23749 }
23750
23751 finishNode(...args) {
23752 const result = super.finishNode(...args);
23753
23754 return this[ESPRIMA_FINISH_NODE](result);
23755 }
23756
23757 finishNodeAt(...args) {
23758 const result = super.finishNodeAt(...args);
23759
23760 return this[ESPRIMA_FINISH_NODE](result);
23761 }
23762
23763 parse() {
23764 const extra = this[STATE];
23765 const program = super.parse();
23766
23767 program.sourceType = extra.originalSourceType;
23768
23769 if (extra.comments) {
23770 program.comments = extra.comments;
23771 }
23772 if (extra.tokens) {
23773 program.tokens = extra.tokens;
23774 }
23775
23776 /*
23777 * Adjust opening and closing position of program to match Esprima.
23778 * Acorn always starts programs at range 0 whereas Esprima starts at the
23779 * first AST node's start (the only real difference is when there's leading
23780 * whitespace or leading comments). Acorn also counts trailing whitespace
23781 * as part of the program whereas Esprima only counts up to the last token.
23782 */
23783 if (program.body.length) {
23784 const [firstNode] = program.body;
23785
23786 if (program.range) {
23787 program.range[0] = firstNode.range[0];
23788 }
23789 if (program.loc) {
23790 program.loc.start = firstNode.loc.start;
23791 }
23792 program.start = firstNode.start;
23793 }
23794 if (extra.lastToken) {
23795 if (program.range) {
23796 program.range[1] = extra.lastToken.range[1];
23797 }
23798 if (program.loc) {
23799 program.loc.end = extra.lastToken.loc.end;
23800 }
23801 program.end = extra.lastToken.end;
23802 }
23803
23804
23805 /*
23806 * https://github.com/eslint/espree/issues/349
23807 * Ensure that template elements have correct range information.
23808 * This is one location where Acorn produces a different value
23809 * for its start and end properties vs. the values present in the
23810 * range property. In order to avoid confusion, we set the start
23811 * and end properties to the values that are present in range.
23812 * This is done here, instead of in finishNode(), because Acorn
23813 * uses the values of start and end internally while parsing, making
23814 * it dangerous to change those values while parsing is ongoing.
23815 * By waiting until the end of parsing, we can safely change these
23816 * values without affect any other part of the process.
23817 */
23818 this[STATE].templateElements.forEach(templateElement => {
23819 const startOffset = -1;
23820 const endOffset = templateElement.tail ? 1 : 2;
23821
23822 templateElement.start += startOffset;
23823 templateElement.end += endOffset;
23824
23825 if (templateElement.range) {
23826 templateElement.range[0] += startOffset;
23827 templateElement.range[1] += endOffset;
23828 }
23829
23830 if (templateElement.loc) {
23831 templateElement.loc.start.column += startOffset;
23832 templateElement.loc.end.column += endOffset;
23833 }
23834 });
23835
23836 return program;
23837 }
23838
23839 parseTopLevel(node) {
23840 if (this[STATE].impliedStrict) {
23841 this.strict = true;
23842 }
23843 return super.parseTopLevel(node);
23844 }
23845
23846 /**
23847 * Overwrites the default raise method to throw Esprima-style errors.
23848 * @param {int} pos The position of the error.
23849 * @param {string} message The error message.
23850 * @throws {SyntaxError} A syntax error.
23851 * @returns {void}
23852 */
23853 raise(pos, message) {
23854 const loc = Parser.acorn.getLineInfo(this.input, pos);
23855 const err = new SyntaxError(message);
23856
23857 err.index = pos;
23858 err.lineNumber = loc.line;
23859 err.column = loc.column + 1; // acorn uses 0-based columns
23860 throw err;
23861 }
23862
23863 /**
23864 * Overwrites the default raise method to throw Esprima-style errors.
23865 * @param {int} pos The position of the error.
23866 * @param {string} message The error message.
23867 * @throws {SyntaxError} A syntax error.
23868 * @returns {void}
23869 */
23870 raiseRecoverable(pos, message) {
23871 this.raise(pos, message);
23872 }
23873
23874 /**
23875 * Overwrites the default unexpected method to throw Esprima-style errors.
23876 * @param {int} pos The position of the error.
23877 * @throws {SyntaxError} A syntax error.
23878 * @returns {void}
23879 */
23880 unexpected(pos) {
23881 let message = "Unexpected token";
23882
23883 if (pos !== null && pos !== void 0) {
23884 this.pos = pos;
23885
23886 if (this.options.locations) {
23887 while (this.pos < this.lineStart) {
23888 this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
23889 --this.curLine;
23890 }
23891 }
23892
23893 this.nextToken();
23894 }
23895
23896 if (this.end > this.start) {
23897 message += ` ${this.input.slice(this.start, this.end)}`;
23898 }
23899
23900 this.raise(this.start, message);
23901 }
23902
23903 /*
23904 * Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX
23905 * uses regular tt.string without any distinction between this and regular JS
23906 * strings. As such, we intercept an attempt to read a JSX string and set a flag
23907 * on extra so that when tokens are converted, the next token will be switched
23908 * to JSXText via onToken.
23909 */
23910 jsx_readString(quote) { // eslint-disable-line camelcase
23911 const result = super.jsx_readString(quote);
23912
23913 if (this.type === tokTypes.string) {
23914 this[STATE].jsxAttrValueToken = true;
23915 }
23916 return result;
23917 }
23918
23919 /**
23920 * Performs last-minute Esprima-specific compatibility checks and fixes.
23921 * @param {ASTNode} result The node to check.
23922 * @returns {ASTNode} The finished node.
23923 */
23924 [ESPRIMA_FINISH_NODE](result) {
23925
23926 // Acorn doesn't count the opening and closing backticks as part of templates
23927 // so we have to adjust ranges/locations appropriately.
23928 if (result.type === "TemplateElement") {
23929
23930 // save template element references to fix start/end later
23931 this[STATE].templateElements.push(result);
23932 }
23933
23934 if (result.type.includes("Function") && !result.generator) {
23935 result.generator = false;
23936 }
23937
23938 return result;
23939 }
23940 };
23941 };
23942
23943 const version$1 = "9.1.0";
23944
23945 /**
23946 * @fileoverview Main Espree file that converts Acorn into Esprima output.
23947 *
23948 * This file contains code from the following MIT-licensed projects:
23949 * 1. Acorn
23950 * 2. Babylon
23951 * 3. Babel-ESLint
23952 *
23953 * This file also contains code from Esprima, which is BSD licensed.
23954 *
23955 * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS)
23956 * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS)
23957 * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie <sebmck@gmail.com>
23958 *
23959 * Redistribution and use in source and binary forms, with or without
23960 * modification, are permitted provided that the following conditions are met:
23961 *
23962 * * Redistributions of source code must retain the above copyright
23963 * notice, this list of conditions and the following disclaimer.
23964 * * Redistributions in binary form must reproduce the above copyright
23965 * notice, this list of conditions and the following disclaimer in the
23966 * documentation and/or other materials provided with the distribution.
23967 *
23968 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23969 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23970 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23971 * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
23972 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23973 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23974 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23975 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23976 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23977 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23978 *
23979 * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.
23980 *
23981 * Redistribution and use in source and binary forms, with or without
23982 * modification, are permitted provided that the following conditions are met:
23983 *
23984 * * Redistributions of source code must retain the above copyright
23985 * notice, this list of conditions and the following disclaimer.
23986 * * Redistributions in binary form must reproduce the above copyright
23987 * notice, this list of conditions and the following disclaimer in the
23988 * documentation and/or other materials provided with the distribution.
23989 *
23990 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23991 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23992 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23993 * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
23994 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23995 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23996 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23997 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23998 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23999 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24000 */
24001
24002
24003 // To initialize lazily.
24004 const parsers = {
24005 _regular: null,
24006 _jsx: null,
24007
24008 get regular() {
24009 if (this._regular === null) {
24010 this._regular = acorn__namespace.Parser.extend(espree());
24011 }
24012 return this._regular;
24013 },
24014
24015 get jsx() {
24016 if (this._jsx === null) {
24017 this._jsx = acorn__namespace.Parser.extend(jsx__default["default"](), espree());
24018 }
24019 return this._jsx;
24020 },
24021
24022 get(options) {
24023 const useJsx = Boolean(
24024 options &&
24025 options.ecmaFeatures &&
24026 options.ecmaFeatures.jsx
24027 );
24028
24029 return useJsx ? this.jsx : this.regular;
24030 }
24031 };
24032
24033 //------------------------------------------------------------------------------
24034 // Tokenizer
24035 //------------------------------------------------------------------------------
24036
24037 /**
24038 * Tokenizes the given code.
24039 * @param {string} code The code to tokenize.
24040 * @param {Object} options Options defining how to tokenize.
24041 * @returns {Token[]} An array of tokens.
24042 * @throws {SyntaxError} If the input code is invalid.
24043 * @private
24044 */
24045 function tokenize(code, options) {
24046 const Parser = parsers.get(options);
24047
24048 // Ensure to collect tokens.
24049 if (!options || options.tokens !== true) {
24050 options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign
24051 }
24052
24053 return new Parser(options, code).tokenize();
24054 }
24055
24056 //------------------------------------------------------------------------------
24057 // Parser
24058 //------------------------------------------------------------------------------
24059
24060 /**
24061 * Parses the given code.
24062 * @param {string} code The code to tokenize.
24063 * @param {Object} options Options defining how to tokenize.
24064 * @returns {ASTNode} The "Program" AST node.
24065 * @throws {SyntaxError} If the input code is invalid.
24066 */
24067 function parse(code, options) {
24068 const Parser = parsers.get(options);
24069
24070 return new Parser(options, code).parse();
24071 }
24072
24073 //------------------------------------------------------------------------------
24074 // Public
24075 //------------------------------------------------------------------------------
24076
24077 const version = version$1;
24078
24079
24080 // Deep copy.
24081 /* istanbul ignore next */
24082 const Syntax = (function() {
24083 let name,
24084 types = {};
24085
24086 if (typeof Object.create === "function") {
24087 types = Object.create(null);
24088 }
24089
24090 for (name in astNodeTypes) {
24091 if (Object.hasOwnProperty.call(astNodeTypes, name)) {
24092 types[name] = astNodeTypes[name];
24093 }
24094 }
24095
24096 if (typeof Object.freeze === "function") {
24097 Object.freeze(types);
24098 }
24099
24100 return types;
24101 }());
24102
24103 /* istanbul ignore next */
24104 const VisitorKeys = (function() {
24105 return visitorKeys__namespace.KEYS;
24106 }());
24107
24108 const latestEcmaVersion = getLatestEcmaVersion();
24109
24110 const supportedEcmaVersions = getSupportedEcmaVersions();
24111
24112 exports.Syntax = Syntax;
24113 exports.VisitorKeys = VisitorKeys;
24114 exports.latestEcmaVersion = latestEcmaVersion;
24115 exports.parse = parse;
24116 exports.supportedEcmaVersions = supportedEcmaVersions;
24117 exports.tokenize = tokenize;
24118 exports.version = version;
24119 //# sourceMappingURL=espree.cjs.map
24120
24121
24122 /***/ }),
24123 /* 437 */
24124 /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
24125
24126 /* provided dependency */ var console = __webpack_require__(438);
24127 (function (global, factory) {
24128 true ? factory(exports) : 0;
24129 })(this, function (exports) {
24130 'use strict'; // Reserved word lists for various dialects of the language
24131
24132 var reservedWords = {
24133 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",
24134 5: "class enum extends super const export import",
24135 6: "enum",
24136 strict: "implements interface let package private protected public static yield",
24137 strictBind: "eval arguments"
24138 }; // And the keywords
24139
24140 var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
24141 var keywords$1 = {
24142 5: ecma5AndLessKeywords,
24143 "5module": ecma5AndLessKeywords + " export import",
24144 6: ecma5AndLessKeywords + " const class extends export import super"
24145 };
24146 var keywordRelationalOperator = /^in(stanceof)?$/; // ## Character categories
24147 // Big ugly regular expressions that match characters in the
24148 // whitespace, identifier, and identifier-start categories. These
24149 // are only applied when a character is found to actually have a
24150 // code point above 128.
24151 // Generated by `bin/generate-identifier-regex.js`.
24152
24153 var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
24154 var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
24155 var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
24156 var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
24157 nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; // These are a run-length and offset encoded representation of the
24158 // >0xffff code points that are a valid part of identifiers. The
24159 // offset starts at 0x10000, and each pair of numbers represents an
24160 // offset to the next range, and then a size of the range. They were
24161 // generated by bin/generate-identifier-regex.js
24162 // eslint-disable-next-line comma-spacing
24163
24164 var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 107, 20, 28, 22, 13, 52, 76, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 230, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 35, 56, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 190, 0, 80, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8952, 286, 50, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 2357, 44, 11, 6, 17, 0, 370, 43, 1301, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42717, 35, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938]; // eslint-disable-next-line comma-spacing
24165
24166 var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 135, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 419, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; // This has a complexity linear to the value of the code. The
24167 // assumption is that looking up astral identifier characters is
24168 // rare.
24169
24170 function isInAstralSet(code, set) {
24171 var pos = 0x10000;
24172
24173 for (var i = 0; i < set.length; i += 2) {
24174 pos += set[i];
24175
24176 if (pos > code) {
24177 return false;
24178 }
24179
24180 pos += set[i + 1];
24181
24182 if (pos >= code) {
24183 return true;
24184 }
24185 }
24186 } // Test whether a given character code starts an identifier.
24187
24188
24189 function isIdentifierStart(code, astral) {
24190 if (code < 65) {
24191 return code === 36;
24192 }
24193
24194 if (code < 91) {
24195 return true;
24196 }
24197
24198 if (code < 97) {
24199 return code === 95;
24200 }
24201
24202 if (code < 123) {
24203 return true;
24204 }
24205
24206 if (code <= 0xffff) {
24207 return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
24208 }
24209
24210 if (astral === false) {
24211 return false;
24212 }
24213
24214 return isInAstralSet(code, astralIdentifierStartCodes);
24215 } // Test whether a given character is part of an identifier.
24216
24217
24218 function isIdentifierChar(code, astral) {
24219 if (code < 48) {
24220 return code === 36;
24221 }
24222
24223 if (code < 58) {
24224 return true;
24225 }
24226
24227 if (code < 65) {
24228 return false;
24229 }
24230
24231 if (code < 91) {
24232 return true;
24233 }
24234
24235 if (code < 97) {
24236 return code === 95;
24237 }
24238
24239 if (code < 123) {
24240 return true;
24241 }
24242
24243 if (code <= 0xffff) {
24244 return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
24245 }
24246
24247 if (astral === false) {
24248 return false;
24249 }
24250
24251 return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
24252 } // ## Token types
24253 // The assignment of fine-grained, information-carrying type objects
24254 // allows the tokenizer to store the information it has about a
24255 // token in a way that is very cheap for the parser to look up.
24256 // All token type variables start with an underscore, to make them
24257 // easy to recognize.
24258 // The `beforeExpr` property is used to disambiguate between regular
24259 // expressions and divisions. It is set on all token types that can
24260 // be followed by an expression (thus, a slash after them would be a
24261 // regular expression).
24262 //
24263 // The `startsExpr` property is used to check if the token ends a
24264 // `yield` expression. It is set on all token types that either can
24265 // directly start an expression (like a quotation mark) or can
24266 // continue an expression (like the body of a string).
24267 //
24268 // `isLoop` marks a keyword as starting a loop, which is important
24269 // to know when parsing a label, in order to allow or disallow
24270 // continue jumps to that label.
24271
24272
24273 var TokenType = function TokenType(label, conf) {
24274 if (conf === void 0) conf = {};
24275 this.label = label;
24276 this.keyword = conf.keyword;
24277 this.beforeExpr = !!conf.beforeExpr;
24278 this.startsExpr = !!conf.startsExpr;
24279 this.isLoop = !!conf.isLoop;
24280 this.isAssign = !!conf.isAssign;
24281 this.prefix = !!conf.prefix;
24282 this.postfix = !!conf.postfix;
24283 this.binop = conf.binop || null;
24284 this.updateContext = null;
24285 };
24286
24287 function binop(name, prec) {
24288 return new TokenType(name, {
24289 beforeExpr: true,
24290 binop: prec
24291 });
24292 }
24293
24294 var beforeExpr = {
24295 beforeExpr: true
24296 },
24297 startsExpr = {
24298 startsExpr: true
24299 }; // Map keyword names to token types.
24300
24301 var keywords = {}; // Succinct definitions of keyword token types
24302
24303 function kw(name, options) {
24304 if (options === void 0) options = {};
24305 options.keyword = name;
24306 return keywords[name] = new TokenType(name, options);
24307 }
24308
24309 var types$1 = {
24310 num: new TokenType("num", startsExpr),
24311 regexp: new TokenType("regexp", startsExpr),
24312 string: new TokenType("string", startsExpr),
24313 name: new TokenType("name", startsExpr),
24314 privateId: new TokenType("privateId", startsExpr),
24315 eof: new TokenType("eof"),
24316 // Punctuation token types.
24317 bracketL: new TokenType("[", {
24318 beforeExpr: true,
24319 startsExpr: true
24320 }),
24321 bracketR: new TokenType("]"),
24322 braceL: new TokenType("{", {
24323 beforeExpr: true,
24324 startsExpr: true
24325 }),
24326 braceR: new TokenType("}"),
24327 parenL: new TokenType("(", {
24328 beforeExpr: true,
24329 startsExpr: true
24330 }),
24331 parenR: new TokenType(")"),
24332 comma: new TokenType(",", beforeExpr),
24333 semi: new TokenType(";", beforeExpr),
24334 colon: new TokenType(":", beforeExpr),
24335 dot: new TokenType("."),
24336 question: new TokenType("?", beforeExpr),
24337 questionDot: new TokenType("?."),
24338 arrow: new TokenType("=>", beforeExpr),
24339 template: new TokenType("template"),
24340 invalidTemplate: new TokenType("invalidTemplate"),
24341 ellipsis: new TokenType("...", beforeExpr),
24342 backQuote: new TokenType("`", startsExpr),
24343 dollarBraceL: new TokenType("${", {
24344 beforeExpr: true,
24345 startsExpr: true
24346 }),
24347 // Operators. These carry several kinds of properties to help the
24348 // parser use them properly (the presence of these properties is
24349 // what categorizes them as operators).
24350 //
24351 // `binop`, when present, specifies that this operator is a binary
24352 // operator, and will refer to its precedence.
24353 //
24354 // `prefix` and `postfix` mark the operator as a prefix or postfix
24355 // unary operator.
24356 //
24357 // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
24358 // binary operators with a very low precedence, that should result
24359 // in AssignmentExpression nodes.
24360 eq: new TokenType("=", {
24361 beforeExpr: true,
24362 isAssign: true
24363 }),
24364 assign: new TokenType("_=", {
24365 beforeExpr: true,
24366 isAssign: true
24367 }),
24368 incDec: new TokenType("++/--", {
24369 prefix: true,
24370 postfix: true,
24371 startsExpr: true
24372 }),
24373 prefix: new TokenType("!/~", {
24374 beforeExpr: true,
24375 prefix: true,
24376 startsExpr: true
24377 }),
24378 logicalOR: binop("||", 1),
24379 logicalAND: binop("&&", 2),
24380 bitwiseOR: binop("|", 3),
24381 bitwiseXOR: binop("^", 4),
24382 bitwiseAND: binop("&", 5),
24383 equality: binop("==/!=/===/!==", 6),
24384 relational: binop("</>/<=/>=", 7),
24385 bitShift: binop("<</>>/>>>", 8),
24386 plusMin: new TokenType("+/-", {
24387 beforeExpr: true,
24388 binop: 9,
24389 prefix: true,
24390 startsExpr: true
24391 }),
24392 modulo: binop("%", 10),
24393 star: binop("*", 10),
24394 slash: binop("/", 10),
24395 starstar: new TokenType("**", {
24396 beforeExpr: true
24397 }),
24398 coalesce: binop("??", 1),
24399 // Keyword token types.
24400 _break: kw("break"),
24401 _case: kw("case", beforeExpr),
24402 _catch: kw("catch"),
24403 _continue: kw("continue"),
24404 _debugger: kw("debugger"),
24405 _default: kw("default", beforeExpr),
24406 _do: kw("do", {
24407 isLoop: true,
24408 beforeExpr: true
24409 }),
24410 _else: kw("else", beforeExpr),
24411 _finally: kw("finally"),
24412 _for: kw("for", {
24413 isLoop: true
24414 }),
24415 _function: kw("function", startsExpr),
24416 _if: kw("if"),
24417 _return: kw("return", beforeExpr),
24418 _switch: kw("switch"),
24419 _throw: kw("throw", beforeExpr),
24420 _try: kw("try"),
24421 _var: kw("var"),
24422 _const: kw("const"),
24423 _while: kw("while", {
24424 isLoop: true
24425 }),
24426 _with: kw("with"),
24427 _new: kw("new", {
24428 beforeExpr: true,
24429 startsExpr: true
24430 }),
24431 _this: kw("this", startsExpr),
24432 _super: kw("super", startsExpr),
24433 _class: kw("class", startsExpr),
24434 _extends: kw("extends", beforeExpr),
24435 _export: kw("export"),
24436 _import: kw("import", startsExpr),
24437 _null: kw("null", startsExpr),
24438 _true: kw("true", startsExpr),
24439 _false: kw("false", startsExpr),
24440 _in: kw("in", {
24441 beforeExpr: true,
24442 binop: 7
24443 }),
24444 _instanceof: kw("instanceof", {
24445 beforeExpr: true,
24446 binop: 7
24447 }),
24448 _typeof: kw("typeof", {
24449 beforeExpr: true,
24450 prefix: true,
24451 startsExpr: true
24452 }),
24453 _void: kw("void", {
24454 beforeExpr: true,
24455 prefix: true,
24456 startsExpr: true
24457 }),
24458 _delete: kw("delete", {
24459 beforeExpr: true,
24460 prefix: true,
24461 startsExpr: true
24462 })
24463 }; // Matches a whole line break (where CRLF is considered a single
24464 // line break). Used to count lines.
24465
24466 var lineBreak = /\r\n?|\n|\u2028|\u2029/;
24467 var lineBreakG = new RegExp(lineBreak.source, "g");
24468
24469 function isNewLine(code) {
24470 return code === 10 || code === 13 || code === 0x2028 || code === 0x2029;
24471 }
24472
24473 var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
24474 var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
24475 var ref = Object.prototype;
24476 var hasOwnProperty = ref.hasOwnProperty;
24477 var toString = ref.toString; // Checks if an object has a property.
24478
24479 function has(obj, propName) {
24480 return hasOwnProperty.call(obj, propName);
24481 }
24482
24483 var isArray = Array.isArray || function (obj) {
24484 return toString.call(obj) === "[object Array]";
24485 };
24486
24487 function wordsRegexp(words) {
24488 return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$");
24489 } // These are used when `options.locations` is on, for the
24490 // `startLoc` and `endLoc` properties.
24491
24492
24493 var Position = function Position(line, col) {
24494 this.line = line;
24495 this.column = col;
24496 };
24497
24498 Position.prototype.offset = function offset(n) {
24499 return new Position(this.line, this.column + n);
24500 };
24501
24502 var SourceLocation = function SourceLocation(p, start, end) {
24503 this.start = start;
24504 this.end = end;
24505
24506 if (p.sourceFile !== null) {
24507 this.source = p.sourceFile;
24508 }
24509 }; // The `getLineInfo` function is mostly useful when the
24510 // `locations` option is off (for performance reasons) and you
24511 // want to find the line/column position for a given character
24512 // offset. `input` should be the code string that the offset refers
24513 // into.
24514
24515
24516 function getLineInfo(input, offset) {
24517 for (var line = 1, cur = 0;;) {
24518 lineBreakG.lastIndex = cur;
24519 var match = lineBreakG.exec(input);
24520
24521 if (match && match.index < offset) {
24522 ++line;
24523 cur = match.index + match[0].length;
24524 } else {
24525 return new Position(line, offset - cur);
24526 }
24527 }
24528 } // A second argument must be given to configure the parser process.
24529 // These options are recognized (only `ecmaVersion` is required):
24530
24531
24532 var defaultOptions = {
24533 // `ecmaVersion` indicates the ECMAScript version to parse. Must be
24534 // either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
24535 // (2019), 11 (2020), 12 (2021), 13 (2022), or `"latest"` (the
24536 // latest version the library supports). This influences support
24537 // for strict mode, the set of reserved words, and support for
24538 // new syntax features.
24539 ecmaVersion: null,
24540 // `sourceType` indicates the mode the code should be parsed in.
24541 // Can be either `"script"` or `"module"`. This influences global
24542 // strict mode and parsing of `import` and `export` declarations.
24543 sourceType: "script",
24544 // `onInsertedSemicolon` can be a callback that will be called
24545 // when a semicolon is automatically inserted. It will be passed
24546 // the position of the comma as an offset, and if `locations` is
24547 // enabled, it is given the location as a `{line, column}` object
24548 // as second argument.
24549 onInsertedSemicolon: null,
24550 // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
24551 // trailing commas.
24552 onTrailingComma: null,
24553 // By default, reserved words are only enforced if ecmaVersion >= 5.
24554 // Set `allowReserved` to a boolean value to explicitly turn this on
24555 // an off. When this option has the value "never", reserved words
24556 // and keywords can also not be used as property names.
24557 allowReserved: null,
24558 // When enabled, a return at the top level is not considered an
24559 // error.
24560 allowReturnOutsideFunction: false,
24561 // When enabled, import/export statements are not constrained to
24562 // appearing at the top of the program, and an import.meta expression
24563 // in a script isn't considered an error.
24564 allowImportExportEverywhere: false,
24565 // By default, await identifiers are allowed to appear at the top-level scope only if ecmaVersion >= 2022.
24566 // When enabled, await identifiers are allowed to appear at the top-level scope,
24567 // but they are still not allowed in non-async functions.
24568 allowAwaitOutsideFunction: null,
24569 // When enabled, super identifiers are not constrained to
24570 // appearing in methods and do not raise an error when they appear elsewhere.
24571 allowSuperOutsideMethod: null,
24572 // When enabled, hashbang directive in the beginning of file
24573 // is allowed and treated as a line comment.
24574 allowHashBang: false,
24575 // When `locations` is on, `loc` properties holding objects with
24576 // `start` and `end` properties in `{line, column}` form (with
24577 // line being 1-based and column 0-based) will be attached to the
24578 // nodes.
24579 locations: false,
24580 // A function can be passed as `onToken` option, which will
24581 // cause Acorn to call that function with object in the same
24582 // format as tokens returned from `tokenizer().getToken()`. Note
24583 // that you are not allowed to call the parser from the
24584 // callback—that will corrupt its internal state.
24585 onToken: null,
24586 // A function can be passed as `onComment` option, which will
24587 // cause Acorn to call that function with `(block, text, start,
24588 // end)` parameters whenever a comment is skipped. `block` is a
24589 // boolean indicating whether this is a block (`/* */`) comment,
24590 // `text` is the content of the comment, and `start` and `end` are
24591 // character offsets that denote the start and end of the comment.
24592 // When the `locations` option is on, two more parameters are
24593 // passed, the full `{line, column}` locations of the start and
24594 // end of the comments. Note that you are not allowed to call the
24595 // parser from the callback—that will corrupt its internal state.
24596 onComment: null,
24597 // Nodes have their start and end characters offsets recorded in
24598 // `start` and `end` properties (directly on the node, rather than
24599 // the `loc` object, which holds line/column data. To also add a
24600 // [semi-standardized][range] `range` property holding a `[start,
24601 // end]` array with the same numbers, set the `ranges` option to
24602 // `true`.
24603 //
24604 // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
24605 ranges: false,
24606 // It is possible to parse multiple files into a single AST by
24607 // passing the tree produced by parsing the first file as
24608 // `program` option in subsequent parses. This will add the
24609 // toplevel forms of the parsed file to the `Program` (top) node
24610 // of an existing parse tree.
24611 program: null,
24612 // When `locations` is on, you can pass this to record the source
24613 // file in every node's `loc` object.
24614 sourceFile: null,
24615 // This value, if given, is stored in every node, whether
24616 // `locations` is on or off.
24617 directSourceFile: null,
24618 // When enabled, parenthesized expressions are represented by
24619 // (non-standard) ParenthesizedExpression nodes
24620 preserveParens: false
24621 }; // Interpret and default an options object
24622
24623 var warnedAboutEcmaVersion = false;
24624
24625 function getOptions(opts) {
24626 var options = {};
24627
24628 for (var opt in defaultOptions) {
24629 options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt];
24630 }
24631
24632 if (options.ecmaVersion === "latest") {
24633 options.ecmaVersion = 1e8;
24634 } else if (options.ecmaVersion == null) {
24635 if (!warnedAboutEcmaVersion && typeof console === "object" && console.warn) {
24636 warnedAboutEcmaVersion = true;
24637 console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.");
24638 }
24639
24640 options.ecmaVersion = 11;
24641 } else if (options.ecmaVersion >= 2015) {
24642 options.ecmaVersion -= 2009;
24643 }
24644
24645 if (options.allowReserved == null) {
24646 options.allowReserved = options.ecmaVersion < 5;
24647 }
24648
24649 if (isArray(options.onToken)) {
24650 var tokens = options.onToken;
24651
24652 options.onToken = function (token) {
24653 return tokens.push(token);
24654 };
24655 }
24656
24657 if (isArray(options.onComment)) {
24658 options.onComment = pushComment(options, options.onComment);
24659 }
24660
24661 return options;
24662 }
24663
24664 function pushComment(options, array) {
24665 return function (block, text, start, end, startLoc, endLoc) {
24666 var comment = {
24667 type: block ? "Block" : "Line",
24668 value: text,
24669 start: start,
24670 end: end
24671 };
24672
24673 if (options.locations) {
24674 comment.loc = new SourceLocation(this, startLoc, endLoc);
24675 }
24676
24677 if (options.ranges) {
24678 comment.range = [start, end];
24679 }
24680
24681 array.push(comment);
24682 };
24683 } // Each scope gets a bitset that may contain these flags
24684
24685
24686 var SCOPE_TOP = 1,
24687 SCOPE_FUNCTION = 2,
24688 SCOPE_ASYNC = 4,
24689 SCOPE_GENERATOR = 8,
24690 SCOPE_ARROW = 16,
24691 SCOPE_SIMPLE_CATCH = 32,
24692 SCOPE_SUPER = 64,
24693 SCOPE_DIRECT_SUPER = 128,
24694 SCOPE_CLASS_STATIC_BLOCK = 256,
24695 SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
24696
24697 function functionFlags(async, generator) {
24698 return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0);
24699 } // Used in checkLVal* and declareName to determine the type of a binding
24700
24701
24702 var BIND_NONE = 0,
24703 // Not a binding
24704 BIND_VAR = 1,
24705 // Var-style binding
24706 BIND_LEXICAL = 2,
24707 // Let- or const-style binding
24708 BIND_FUNCTION = 3,
24709 // Function declaration
24710 BIND_SIMPLE_CATCH = 4,
24711 // Simple (identifier pattern) catch binding
24712 BIND_OUTSIDE = 5; // Special case for function names as bound inside the function
24713
24714 var Parser = function Parser(options, input, startPos) {
24715 this.options = options = getOptions(options);
24716 this.sourceFile = options.sourceFile;
24717 this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
24718 var reserved = "";
24719
24720 if (options.allowReserved !== true) {
24721 reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3];
24722
24723 if (options.sourceType === "module") {
24724 reserved += " await";
24725 }
24726 }
24727
24728 this.reservedWords = wordsRegexp(reserved);
24729 var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
24730 this.reservedWordsStrict = wordsRegexp(reservedStrict);
24731 this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind);
24732 this.input = String(input); // Used to signal to callers of `readWord1` whether the word
24733 // contained any escape sequences. This is needed because words with
24734 // escape sequences must not be interpreted as keywords.
24735
24736 this.containsEsc = false; // Set up token state
24737 // The current position of the tokenizer in the input.
24738
24739 if (startPos) {
24740 this.pos = startPos;
24741 this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
24742 this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
24743 } else {
24744 this.pos = this.lineStart = 0;
24745 this.curLine = 1;
24746 } // Properties of the current token:
24747 // Its type
24748
24749
24750 this.type = types$1.eof; // For tokens that include more information than their type, the value
24751
24752 this.value = null; // Its start and end offset
24753
24754 this.start = this.end = this.pos; // And, if locations are used, the {line, column} object
24755 // corresponding to those offsets
24756
24757 this.startLoc = this.endLoc = this.curPosition(); // Position information for the previous token
24758
24759 this.lastTokEndLoc = this.lastTokStartLoc = null;
24760 this.lastTokStart = this.lastTokEnd = this.pos; // The context stack is used to superficially track syntactic
24761 // context to predict whether a regular expression is allowed in a
24762 // given position.
24763
24764 this.context = this.initialContext();
24765 this.exprAllowed = true; // Figure out if it's a module code.
24766
24767 this.inModule = options.sourceType === "module";
24768 this.strict = this.inModule || this.strictDirective(this.pos); // Used to signify the start of a potential arrow function
24769
24770 this.potentialArrowAt = -1;
24771 this.potentialArrowInForAwait = false; // Positions to delayed-check that yield/await does not exist in default parameters.
24772
24773 this.yieldPos = this.awaitPos = this.awaitIdentPos = 0; // Labels in scope.
24774
24775 this.labels = []; // Thus-far undefined exports.
24776
24777 this.undefinedExports = Object.create(null); // If enabled, skip leading hashbang line.
24778
24779 if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!") {
24780 this.skipLineComment(2);
24781 } // Scope tracking for duplicate variable names (see scope.js)
24782
24783
24784 this.scopeStack = [];
24785 this.enterScope(SCOPE_TOP); // For RegExp validation
24786
24787 this.regexpState = null; // The stack of private names.
24788 // Each element has two properties: 'declared' and 'used'.
24789 // When it exited from the outermost class definition, all used private names must be declared.
24790
24791 this.privateNameStack = [];
24792 };
24793
24794 var prototypeAccessors = {
24795 inFunction: {
24796 configurable: true
24797 },
24798 inGenerator: {
24799 configurable: true
24800 },
24801 inAsync: {
24802 configurable: true
24803 },
24804 canAwait: {
24805 configurable: true
24806 },
24807 allowSuper: {
24808 configurable: true
24809 },
24810 allowDirectSuper: {
24811 configurable: true
24812 },
24813 treatFunctionsAsVar: {
24814 configurable: true
24815 },
24816 allowNewDotTarget: {
24817 configurable: true
24818 },
24819 inClassStaticBlock: {
24820 configurable: true
24821 }
24822 };
24823
24824 Parser.prototype.parse = function parse() {
24825 var node = this.options.program || this.startNode();
24826 this.nextToken();
24827 return this.parseTopLevel(node);
24828 };
24829
24830 prototypeAccessors.inFunction.get = function () {
24831 return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
24832 };
24833
24834 prototypeAccessors.inGenerator.get = function () {
24835 return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit;
24836 };
24837
24838 prototypeAccessors.inAsync.get = function () {
24839 return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit;
24840 };
24841
24842 prototypeAccessors.canAwait.get = function () {
24843 for (var i = this.scopeStack.length - 1; i >= 0; i--) {
24844 var scope = this.scopeStack[i];
24845
24846 if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) {
24847 return false;
24848 }
24849
24850 if (scope.flags & SCOPE_FUNCTION) {
24851 return (scope.flags & SCOPE_ASYNC) > 0;
24852 }
24853 }
24854
24855 return this.inModule && this.options.ecmaVersion >= 13 || this.options.allowAwaitOutsideFunction;
24856 };
24857
24858 prototypeAccessors.allowSuper.get = function () {
24859 var ref = this.currentThisScope();
24860 var flags = ref.flags;
24861 var inClassFieldInit = ref.inClassFieldInit;
24862 return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod;
24863 };
24864
24865 prototypeAccessors.allowDirectSuper.get = function () {
24866 return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0;
24867 };
24868
24869 prototypeAccessors.treatFunctionsAsVar.get = function () {
24870 return this.treatFunctionsAsVarInScope(this.currentScope());
24871 };
24872
24873 prototypeAccessors.allowNewDotTarget.get = function () {
24874 var ref = this.currentThisScope();
24875 var flags = ref.flags;
24876 var inClassFieldInit = ref.inClassFieldInit;
24877 return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit;
24878 };
24879
24880 prototypeAccessors.inClassStaticBlock.get = function () {
24881 return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0;
24882 };
24883
24884 Parser.extend = function extend() {
24885 var plugins = [],
24886 len = arguments.length;
24887
24888 while (len--) plugins[len] = arguments[len];
24889
24890 var cls = this;
24891
24892 for (var i = 0; i < plugins.length; i++) {
24893 cls = plugins[i](cls);
24894 }
24895
24896 return cls;
24897 };
24898
24899 Parser.parse = function parse(input, options) {
24900 return new this(options, input).parse();
24901 };
24902
24903 Parser.parseExpressionAt = function parseExpressionAt(input, pos, options) {
24904 var parser = new this(options, input, pos);
24905 parser.nextToken();
24906 return parser.parseExpression();
24907 };
24908
24909 Parser.tokenizer = function tokenizer(input, options) {
24910 return new this(options, input);
24911 };
24912
24913 Object.defineProperties(Parser.prototype, prototypeAccessors);
24914 var pp$9 = Parser.prototype; // ## Parser utilities
24915
24916 var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
24917
24918 pp$9.strictDirective = function (start) {
24919 for (;;) {
24920 // Try to find string literal.
24921 skipWhiteSpace.lastIndex = start;
24922 start += skipWhiteSpace.exec(this.input)[0].length;
24923 var match = literal.exec(this.input.slice(start));
24924
24925 if (!match) {
24926 return false;
24927 }
24928
24929 if ((match[1] || match[2]) === "use strict") {
24930 skipWhiteSpace.lastIndex = start + match[0].length;
24931 var spaceAfter = skipWhiteSpace.exec(this.input),
24932 end = spaceAfter.index + spaceAfter[0].length;
24933 var next = this.input.charAt(end);
24934 return next === ";" || next === "}" || lineBreak.test(spaceAfter[0]) && !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "=");
24935 }
24936
24937 start += match[0].length; // Skip semicolon, if any.
24938
24939 skipWhiteSpace.lastIndex = start;
24940 start += skipWhiteSpace.exec(this.input)[0].length;
24941
24942 if (this.input[start] === ";") {
24943 start++;
24944 }
24945 }
24946 }; // Predicate that tests whether the next token is of the given
24947 // type, and if yes, consumes it as a side effect.
24948
24949
24950 pp$9.eat = function (type) {
24951 if (this.type === type) {
24952 this.next();
24953 return true;
24954 } else {
24955 return false;
24956 }
24957 }; // Tests whether parsed token is a contextual keyword.
24958
24959
24960 pp$9.isContextual = function (name) {
24961 return this.type === types$1.name && this.value === name && !this.containsEsc;
24962 }; // Consumes contextual keyword if possible.
24963
24964
24965 pp$9.eatContextual = function (name) {
24966 if (!this.isContextual(name)) {
24967 return false;
24968 }
24969
24970 this.next();
24971 return true;
24972 }; // Asserts that following token is given contextual keyword.
24973
24974
24975 pp$9.expectContextual = function (name) {
24976 if (!this.eatContextual(name)) {
24977 this.unexpected();
24978 }
24979 }; // Test whether a semicolon can be inserted at the current position.
24980
24981
24982 pp$9.canInsertSemicolon = function () {
24983 return this.type === types$1.eof || this.type === types$1.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
24984 };
24985
24986 pp$9.insertSemicolon = function () {
24987 if (this.canInsertSemicolon()) {
24988 if (this.options.onInsertedSemicolon) {
24989 this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);
24990 }
24991
24992 return true;
24993 }
24994 }; // Consume a semicolon, or, failing that, see if we are allowed to
24995 // pretend that there is a semicolon at this position.
24996
24997
24998 pp$9.semicolon = function () {
24999 if (!this.eat(types$1.semi) && !this.insertSemicolon()) {
25000 this.unexpected();
25001 }
25002 };
25003
25004 pp$9.afterTrailingComma = function (tokType, notNext) {
25005 if (this.type === tokType) {
25006 if (this.options.onTrailingComma) {
25007 this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);
25008 }
25009
25010 if (!notNext) {
25011 this.next();
25012 }
25013
25014 return true;
25015 }
25016 }; // Expect a token of a given type. If found, consume it, otherwise,
25017 // raise an unexpected token error.
25018
25019
25020 pp$9.expect = function (type) {
25021 this.eat(type) || this.unexpected();
25022 }; // Raise an unexpected token error.
25023
25024
25025 pp$9.unexpected = function (pos) {
25026 this.raise(pos != null ? pos : this.start, "Unexpected token");
25027 };
25028
25029 function DestructuringErrors() {
25030 this.shorthandAssign = this.trailingComma = this.parenthesizedAssign = this.parenthesizedBind = this.doubleProto = -1;
25031 }
25032
25033 pp$9.checkPatternErrors = function (refDestructuringErrors, isAssign) {
25034 if (!refDestructuringErrors) {
25035 return;
25036 }
25037
25038 if (refDestructuringErrors.trailingComma > -1) {
25039 this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element");
25040 }
25041
25042 var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
25043
25044 if (parens > -1) {
25045 this.raiseRecoverable(parens, "Parenthesized pattern");
25046 }
25047 };
25048
25049 pp$9.checkExpressionErrors = function (refDestructuringErrors, andThrow) {
25050 if (!refDestructuringErrors) {
25051 return false;
25052 }
25053
25054 var shorthandAssign = refDestructuringErrors.shorthandAssign;
25055 var doubleProto = refDestructuringErrors.doubleProto;
25056
25057 if (!andThrow) {
25058 return shorthandAssign >= 0 || doubleProto >= 0;
25059 }
25060
25061 if (shorthandAssign >= 0) {
25062 this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns");
25063 }
25064
25065 if (doubleProto >= 0) {
25066 this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property");
25067 }
25068 };
25069
25070 pp$9.checkYieldAwaitInDefaultParams = function () {
25071 if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos)) {
25072 this.raise(this.yieldPos, "Yield expression cannot be a default value");
25073 }
25074
25075 if (this.awaitPos) {
25076 this.raise(this.awaitPos, "Await expression cannot be a default value");
25077 }
25078 };
25079
25080 pp$9.isSimpleAssignTarget = function (expr) {
25081 if (expr.type === "ParenthesizedExpression") {
25082 return this.isSimpleAssignTarget(expr.expression);
25083 }
25084
25085 return expr.type === "Identifier" || expr.type === "MemberExpression";
25086 };
25087
25088 var pp$8 = Parser.prototype; // ### Statement parsing
25089 // Parse a program. Initializes the parser, reads any number of
25090 // statements, and wraps them in a Program node. Optionally takes a
25091 // `program` argument. If present, the statements will be appended
25092 // to its body instead of creating a new node.
25093
25094 pp$8.parseTopLevel = function (node) {
25095 var exports = Object.create(null);
25096
25097 if (!node.body) {
25098 node.body = [];
25099 }
25100
25101 while (this.type !== types$1.eof) {
25102 var stmt = this.parseStatement(null, true, exports);
25103 node.body.push(stmt);
25104 }
25105
25106 if (this.inModule) {
25107 for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1) {
25108 var name = list[i];
25109 this.raiseRecoverable(this.undefinedExports[name].start, "Export '" + name + "' is not defined");
25110 }
25111 }
25112
25113 this.adaptDirectivePrologue(node.body);
25114 this.next();
25115 node.sourceType = this.options.sourceType;
25116 return this.finishNode(node, "Program");
25117 };
25118
25119 var loopLabel = {
25120 kind: "loop"
25121 },
25122 switchLabel = {
25123 kind: "switch"
25124 };
25125
25126 pp$8.isLet = function (context) {
25127 if (this.options.ecmaVersion < 6 || !this.isContextual("let")) {
25128 return false;
25129 }
25130
25131 skipWhiteSpace.lastIndex = this.pos;
25132 var skip = skipWhiteSpace.exec(this.input);
25133 var next = this.pos + skip[0].length,
25134 nextCh = this.input.charCodeAt(next); // For ambiguous cases, determine if a LexicalDeclaration (or only a
25135 // Statement) is allowed here. If context is not empty then only a Statement
25136 // is allowed. However, `let [` is an explicit negative lookahead for
25137 // ExpressionStatement, so special-case it first.
25138
25139 if (nextCh === 91 || nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) {
25140 return true;
25141 } // '[', '/', astral
25142
25143
25144 if (context) {
25145 return false;
25146 }
25147
25148 if (nextCh === 123) {
25149 return true;
25150 } // '{'
25151
25152
25153 if (isIdentifierStart(nextCh, true)) {
25154 var pos = next + 1;
25155
25156 while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) {
25157 ++pos;
25158 }
25159
25160 if (nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) {
25161 return true;
25162 }
25163
25164 var ident = this.input.slice(next, pos);
25165
25166 if (!keywordRelationalOperator.test(ident)) {
25167 return true;
25168 }
25169 }
25170
25171 return false;
25172 }; // check 'async [no LineTerminator here] function'
25173 // - 'async /*foo*/ function' is OK.
25174 // - 'async /*\n*/ function' is invalid.
25175
25176
25177 pp$8.isAsyncFunction = function () {
25178 if (this.options.ecmaVersion < 8 || !this.isContextual("async")) {
25179 return false;
25180 }
25181
25182 skipWhiteSpace.lastIndex = this.pos;
25183 var skip = skipWhiteSpace.exec(this.input);
25184 var next = this.pos + skip[0].length,
25185 after;
25186 return !lineBreak.test(this.input.slice(this.pos, next)) && this.input.slice(next, next + 8) === "function" && (next + 8 === this.input.length || !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00));
25187 }; // Parse a single statement.
25188 //
25189 // If expecting a statement and finding a slash operator, parse a
25190 // regular expression literal. This is to handle cases like
25191 // `if (foo) /blah/.exec(foo)`, where looking at the previous token
25192 // does not help.
25193
25194
25195 pp$8.parseStatement = function (context, topLevel, exports) {
25196 var starttype = this.type,
25197 node = this.startNode(),
25198 kind;
25199
25200 if (this.isLet(context)) {
25201 starttype = types$1._var;
25202 kind = "let";
25203 } // Most types of statements are recognized by the keyword they
25204 // start with. Many are trivial to parse, some require a bit of
25205 // complexity.
25206
25207
25208 switch (starttype) {
25209 case types$1._break:
25210 case types$1._continue:
25211 return this.parseBreakContinueStatement(node, starttype.keyword);
25212
25213 case types$1._debugger:
25214 return this.parseDebuggerStatement(node);
25215
25216 case types$1._do:
25217 return this.parseDoStatement(node);
25218
25219 case types$1._for:
25220 return this.parseForStatement(node);
25221
25222 case types$1._function:
25223 // Function as sole body of either an if statement or a labeled statement
25224 // works, but not when it is part of a labeled statement that is the sole
25225 // body of an if statement.
25226 if (context && (this.strict || context !== "if" && context !== "label") && this.options.ecmaVersion >= 6) {
25227 this.unexpected();
25228 }
25229
25230 return this.parseFunctionStatement(node, false, !context);
25231
25232 case types$1._class:
25233 if (context) {
25234 this.unexpected();
25235 }
25236
25237 return this.parseClass(node, true);
25238
25239 case types$1._if:
25240 return this.parseIfStatement(node);
25241
25242 case types$1._return:
25243 return this.parseReturnStatement(node);
25244
25245 case types$1._switch:
25246 return this.parseSwitchStatement(node);
25247
25248 case types$1._throw:
25249 return this.parseThrowStatement(node);
25250
25251 case types$1._try:
25252 return this.parseTryStatement(node);
25253
25254 case types$1._const:
25255 case types$1._var:
25256 kind = kind || this.value;
25257
25258 if (context && kind !== "var") {
25259 this.unexpected();
25260 }
25261
25262 return this.parseVarStatement(node, kind);
25263
25264 case types$1._while:
25265 return this.parseWhileStatement(node);
25266
25267 case types$1._with:
25268 return this.parseWithStatement(node);
25269
25270 case types$1.braceL:
25271 return this.parseBlock(true, node);
25272
25273 case types$1.semi:
25274 return this.parseEmptyStatement(node);
25275
25276 case types$1._export:
25277 case types$1._import:
25278 if (this.options.ecmaVersion > 10 && starttype === types$1._import) {
25279 skipWhiteSpace.lastIndex = this.pos;
25280 var skip = skipWhiteSpace.exec(this.input);
25281 var next = this.pos + skip[0].length,
25282 nextCh = this.input.charCodeAt(next);
25283
25284 if (nextCh === 40 || nextCh === 46) // '(' or '.'
25285 {
25286 return this.parseExpressionStatement(node, this.parseExpression());
25287 }
25288 }
25289
25290 if (!this.options.allowImportExportEverywhere) {
25291 if (!topLevel) {
25292 this.raise(this.start, "'import' and 'export' may only appear at the top level");
25293 }
25294
25295 if (!this.inModule) {
25296 this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
25297 }
25298 }
25299
25300 return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports);
25301 // If the statement does not start with a statement keyword or a
25302 // brace, it's an ExpressionStatement or LabeledStatement. We
25303 // simply start parsing an expression, and afterwards, if the
25304 // next token is a colon and the expression was a simple
25305 // Identifier node, we switch to interpreting it as a label.
25306
25307 default:
25308 if (this.isAsyncFunction()) {
25309 if (context) {
25310 this.unexpected();
25311 }
25312
25313 this.next();
25314 return this.parseFunctionStatement(node, true, !context);
25315 }
25316
25317 var maybeName = this.value,
25318 expr = this.parseExpression();
25319
25320 if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon)) {
25321 return this.parseLabeledStatement(node, maybeName, expr, context);
25322 } else {
25323 return this.parseExpressionStatement(node, expr);
25324 }
25325
25326 }
25327 };
25328
25329 pp$8.parseBreakContinueStatement = function (node, keyword) {
25330 var isBreak = keyword === "break";
25331 this.next();
25332
25333 if (this.eat(types$1.semi) || this.insertSemicolon()) {
25334 node.label = null;
25335 } else if (this.type !== types$1.name) {
25336 this.unexpected();
25337 } else {
25338 node.label = this.parseIdent();
25339 this.semicolon();
25340 } // Verify that there is an actual destination to break or
25341 // continue to.
25342
25343
25344 var i = 0;
25345
25346 for (; i < this.labels.length; ++i) {
25347 var lab = this.labels[i];
25348
25349 if (node.label == null || lab.name === node.label.name) {
25350 if (lab.kind != null && (isBreak || lab.kind === "loop")) {
25351 break;
25352 }
25353
25354 if (node.label && isBreak) {
25355 break;
25356 }
25357 }
25358 }
25359
25360 if (i === this.labels.length) {
25361 this.raise(node.start, "Unsyntactic " + keyword);
25362 }
25363
25364 return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
25365 };
25366
25367 pp$8.parseDebuggerStatement = function (node) {
25368 this.next();
25369 this.semicolon();
25370 return this.finishNode(node, "DebuggerStatement");
25371 };
25372
25373 pp$8.parseDoStatement = function (node) {
25374 this.next();
25375 this.labels.push(loopLabel);
25376 node.body = this.parseStatement("do");
25377 this.labels.pop();
25378 this.expect(types$1._while);
25379 node.test = this.parseParenExpression();
25380
25381 if (this.options.ecmaVersion >= 6) {
25382 this.eat(types$1.semi);
25383 } else {
25384 this.semicolon();
25385 }
25386
25387 return this.finishNode(node, "DoWhileStatement");
25388 }; // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
25389 // loop is non-trivial. Basically, we have to parse the init `var`
25390 // statement or expression, disallowing the `in` operator (see
25391 // the second parameter to `parseExpression`), and then check
25392 // whether the next token is `in` or `of`. When there is no init
25393 // part (semicolon immediately after the opening parenthesis), it
25394 // is a regular `for` loop.
25395
25396
25397 pp$8.parseForStatement = function (node) {
25398 this.next();
25399 var awaitAt = this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await") ? this.lastTokStart : -1;
25400 this.labels.push(loopLabel);
25401 this.enterScope(0);
25402 this.expect(types$1.parenL);
25403
25404 if (this.type === types$1.semi) {
25405 if (awaitAt > -1) {
25406 this.unexpected(awaitAt);
25407 }
25408
25409 return this.parseFor(node, null);
25410 }
25411
25412 var isLet = this.isLet();
25413
25414 if (this.type === types$1._var || this.type === types$1._const || isLet) {
25415 var init$1 = this.startNode(),
25416 kind = isLet ? "let" : this.value;
25417 this.next();
25418 this.parseVar(init$1, true, kind);
25419 this.finishNode(init$1, "VariableDeclaration");
25420
25421 if ((this.type === types$1._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && init$1.declarations.length === 1) {
25422 if (this.options.ecmaVersion >= 9) {
25423 if (this.type === types$1._in) {
25424 if (awaitAt > -1) {
25425 this.unexpected(awaitAt);
25426 }
25427 } else {
25428 node.await = awaitAt > -1;
25429 }
25430 }
25431
25432 return this.parseForIn(node, init$1);
25433 }
25434
25435 if (awaitAt > -1) {
25436 this.unexpected(awaitAt);
25437 }
25438
25439 return this.parseFor(node, init$1);
25440 }
25441
25442 var startsWithLet = this.isContextual("let"),
25443 isForOf = false;
25444 var refDestructuringErrors = new DestructuringErrors();
25445 var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
25446
25447 if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
25448 if (this.options.ecmaVersion >= 9) {
25449 if (this.type === types$1._in) {
25450 if (awaitAt > -1) {
25451 this.unexpected(awaitAt);
25452 }
25453 } else {
25454 node.await = awaitAt > -1;
25455 }
25456 }
25457
25458 if (startsWithLet && isForOf) {
25459 this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'.");
25460 }
25461
25462 this.toAssignable(init, false, refDestructuringErrors);
25463 this.checkLValPattern(init);
25464 return this.parseForIn(node, init);
25465 } else {
25466 this.checkExpressionErrors(refDestructuringErrors, true);
25467 }
25468
25469 if (awaitAt > -1) {
25470 this.unexpected(awaitAt);
25471 }
25472
25473 return this.parseFor(node, init);
25474 };
25475
25476 pp$8.parseFunctionStatement = function (node, isAsync, declarationPosition) {
25477 this.next();
25478 return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync);
25479 };
25480
25481 pp$8.parseIfStatement = function (node) {
25482 this.next();
25483 node.test = this.parseParenExpression(); // allow function declarations in branches, but only in non-strict mode
25484
25485 node.consequent = this.parseStatement("if");
25486 node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null;
25487 return this.finishNode(node, "IfStatement");
25488 };
25489
25490 pp$8.parseReturnStatement = function (node) {
25491 if (!this.inFunction && !this.options.allowReturnOutsideFunction) {
25492 this.raise(this.start, "'return' outside of function");
25493 }
25494
25495 this.next(); // In `return` (and `break`/`continue`), the keywords with
25496 // optional arguments, we eagerly look for a semicolon or the
25497 // possibility to insert one.
25498
25499 if (this.eat(types$1.semi) || this.insertSemicolon()) {
25500 node.argument = null;
25501 } else {
25502 node.argument = this.parseExpression();
25503 this.semicolon();
25504 }
25505
25506 return this.finishNode(node, "ReturnStatement");
25507 };
25508
25509 pp$8.parseSwitchStatement = function (node) {
25510 this.next();
25511 node.discriminant = this.parseParenExpression();
25512 node.cases = [];
25513 this.expect(types$1.braceL);
25514 this.labels.push(switchLabel);
25515 this.enterScope(0); // Statements under must be grouped (by label) in SwitchCase
25516 // nodes. `cur` is used to keep the node that we are currently
25517 // adding statements to.
25518
25519 var cur;
25520
25521 for (var sawDefault = false; this.type !== types$1.braceR;) {
25522 if (this.type === types$1._case || this.type === types$1._default) {
25523 var isCase = this.type === types$1._case;
25524
25525 if (cur) {
25526 this.finishNode(cur, "SwitchCase");
25527 }
25528
25529 node.cases.push(cur = this.startNode());
25530 cur.consequent = [];
25531 this.next();
25532
25533 if (isCase) {
25534 cur.test = this.parseExpression();
25535 } else {
25536 if (sawDefault) {
25537 this.raiseRecoverable(this.lastTokStart, "Multiple default clauses");
25538 }
25539
25540 sawDefault = true;
25541 cur.test = null;
25542 }
25543
25544 this.expect(types$1.colon);
25545 } else {
25546 if (!cur) {
25547 this.unexpected();
25548 }
25549
25550 cur.consequent.push(this.parseStatement(null));
25551 }
25552 }
25553
25554 this.exitScope();
25555
25556 if (cur) {
25557 this.finishNode(cur, "SwitchCase");
25558 }
25559
25560 this.next(); // Closing brace
25561
25562 this.labels.pop();
25563 return this.finishNode(node, "SwitchStatement");
25564 };
25565
25566 pp$8.parseThrowStatement = function (node) {
25567 this.next();
25568
25569 if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) {
25570 this.raise(this.lastTokEnd, "Illegal newline after throw");
25571 }
25572
25573 node.argument = this.parseExpression();
25574 this.semicolon();
25575 return this.finishNode(node, "ThrowStatement");
25576 }; // Reused empty array added for node fields that are always empty.
25577
25578
25579 var empty$1 = [];
25580
25581 pp$8.parseTryStatement = function (node) {
25582 this.next();
25583 node.block = this.parseBlock();
25584 node.handler = null;
25585
25586 if (this.type === types$1._catch) {
25587 var clause = this.startNode();
25588 this.next();
25589
25590 if (this.eat(types$1.parenL)) {
25591 clause.param = this.parseBindingAtom();
25592 var simple = clause.param.type === "Identifier";
25593 this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
25594 this.checkLValPattern(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
25595 this.expect(types$1.parenR);
25596 } else {
25597 if (this.options.ecmaVersion < 10) {
25598 this.unexpected();
25599 }
25600
25601 clause.param = null;
25602 this.enterScope(0);
25603 }
25604
25605 clause.body = this.parseBlock(false);
25606 this.exitScope();
25607 node.handler = this.finishNode(clause, "CatchClause");
25608 }
25609
25610 node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null;
25611
25612 if (!node.handler && !node.finalizer) {
25613 this.raise(node.start, "Missing catch or finally clause");
25614 }
25615
25616 return this.finishNode(node, "TryStatement");
25617 };
25618
25619 pp$8.parseVarStatement = function (node, kind) {
25620 this.next();
25621 this.parseVar(node, false, kind);
25622 this.semicolon();
25623 return this.finishNode(node, "VariableDeclaration");
25624 };
25625
25626 pp$8.parseWhileStatement = function (node) {
25627 this.next();
25628 node.test = this.parseParenExpression();
25629 this.labels.push(loopLabel);
25630 node.body = this.parseStatement("while");
25631 this.labels.pop();
25632 return this.finishNode(node, "WhileStatement");
25633 };
25634
25635 pp$8.parseWithStatement = function (node) {
25636 if (this.strict) {
25637 this.raise(this.start, "'with' in strict mode");
25638 }
25639
25640 this.next();
25641 node.object = this.parseParenExpression();
25642 node.body = this.parseStatement("with");
25643 return this.finishNode(node, "WithStatement");
25644 };
25645
25646 pp$8.parseEmptyStatement = function (node) {
25647 this.next();
25648 return this.finishNode(node, "EmptyStatement");
25649 };
25650
25651 pp$8.parseLabeledStatement = function (node, maybeName, expr, context) {
25652 for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1) {
25653 var label = list[i$1];
25654
25655 if (label.name === maybeName) {
25656 this.raise(expr.start, "Label '" + maybeName + "' is already declared");
25657 }
25658 }
25659
25660 var kind = this.type.isLoop ? "loop" : this.type === types$1._switch ? "switch" : null;
25661
25662 for (var i = this.labels.length - 1; i >= 0; i--) {
25663 var label$1 = this.labels[i];
25664
25665 if (label$1.statementStart === node.start) {
25666 // Update information about previous labels on this node
25667 label$1.statementStart = this.start;
25668 label$1.kind = kind;
25669 } else {
25670 break;
25671 }
25672 }
25673
25674 this.labels.push({
25675 name: maybeName,
25676 kind: kind,
25677 statementStart: this.start
25678 });
25679 node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
25680 this.labels.pop();
25681 node.label = expr;
25682 return this.finishNode(node, "LabeledStatement");
25683 };
25684
25685 pp$8.parseExpressionStatement = function (node, expr) {
25686 node.expression = expr;
25687 this.semicolon();
25688 return this.finishNode(node, "ExpressionStatement");
25689 }; // Parse a semicolon-enclosed block of statements, handling `"use
25690 // strict"` declarations when `allowStrict` is true (used for
25691 // function bodies).
25692
25693
25694 pp$8.parseBlock = function (createNewLexicalScope, node, exitStrict) {
25695 if (createNewLexicalScope === void 0) createNewLexicalScope = true;
25696 if (node === void 0) node = this.startNode();
25697 node.body = [];
25698 this.expect(types$1.braceL);
25699
25700 if (createNewLexicalScope) {
25701 this.enterScope(0);
25702 }
25703
25704 while (this.type !== types$1.braceR) {
25705 var stmt = this.parseStatement(null);
25706 node.body.push(stmt);
25707 }
25708
25709 if (exitStrict) {
25710 this.strict = false;
25711 }
25712
25713 this.next();
25714
25715 if (createNewLexicalScope) {
25716 this.exitScope();
25717 }
25718
25719 return this.finishNode(node, "BlockStatement");
25720 }; // Parse a regular `for` loop. The disambiguation code in
25721 // `parseStatement` will already have parsed the init statement or
25722 // expression.
25723
25724
25725 pp$8.parseFor = function (node, init) {
25726 node.init = init;
25727 this.expect(types$1.semi);
25728 node.test = this.type === types$1.semi ? null : this.parseExpression();
25729 this.expect(types$1.semi);
25730 node.update = this.type === types$1.parenR ? null : this.parseExpression();
25731 this.expect(types$1.parenR);
25732 node.body = this.parseStatement("for");
25733 this.exitScope();
25734 this.labels.pop();
25735 return this.finishNode(node, "ForStatement");
25736 }; // Parse a `for`/`in` and `for`/`of` loop, which are almost
25737 // same from parser's perspective.
25738
25739
25740 pp$8.parseForIn = function (node, init) {
25741 var isForIn = this.type === types$1._in;
25742 this.next();
25743
25744 if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.options.ecmaVersion < 8 || this.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
25745 this.raise(init.start, (isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer");
25746 }
25747
25748 node.left = init;
25749 node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
25750 this.expect(types$1.parenR);
25751 node.body = this.parseStatement("for");
25752 this.exitScope();
25753 this.labels.pop();
25754 return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
25755 }; // Parse a list of variable declarations.
25756
25757
25758 pp$8.parseVar = function (node, isFor, kind) {
25759 node.declarations = [];
25760 node.kind = kind;
25761
25762 for (;;) {
25763 var decl = this.startNode();
25764 this.parseVarId(decl, kind);
25765
25766 if (this.eat(types$1.eq)) {
25767 decl.init = this.parseMaybeAssign(isFor);
25768 } else if (kind === "const" && !(this.type === types$1._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
25769 this.unexpected();
25770 } else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
25771 this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
25772 } else {
25773 decl.init = null;
25774 }
25775
25776 node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
25777
25778 if (!this.eat(types$1.comma)) {
25779 break;
25780 }
25781 }
25782
25783 return node;
25784 };
25785
25786 pp$8.parseVarId = function (decl, kind) {
25787 decl.id = this.parseBindingAtom();
25788 this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
25789 };
25790
25791 var FUNC_STATEMENT = 1,
25792 FUNC_HANGING_STATEMENT = 2,
25793 FUNC_NULLABLE_ID = 4; // Parse a function declaration or literal (depending on the
25794 // `statement & FUNC_STATEMENT`).
25795 // Remove `allowExpressionBody` for 7.0.0, as it is only called with false
25796
25797 pp$8.parseFunction = function (node, statement, allowExpressionBody, isAsync, forInit) {
25798 this.initFunction(node);
25799
25800 if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
25801 if (this.type === types$1.star && statement & FUNC_HANGING_STATEMENT) {
25802 this.unexpected();
25803 }
25804
25805 node.generator = this.eat(types$1.star);
25806 }
25807
25808 if (this.options.ecmaVersion >= 8) {
25809 node.async = !!isAsync;
25810 }
25811
25812 if (statement & FUNC_STATEMENT) {
25813 node.id = statement & FUNC_NULLABLE_ID && this.type !== types$1.name ? null : this.parseIdent();
25814
25815 if (node.id && !(statement & FUNC_HANGING_STATEMENT)) // If it is a regular function declaration in sloppy mode, then it is
25816 // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
25817 // mode depends on properties of the current scope (see
25818 // treatFunctionsAsVar).
25819 {
25820 this.checkLValSimple(node.id, this.strict || node.generator || node.async ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION);
25821 }
25822 }
25823
25824 var oldYieldPos = this.yieldPos,
25825 oldAwaitPos = this.awaitPos,
25826 oldAwaitIdentPos = this.awaitIdentPos;
25827 this.yieldPos = 0;
25828 this.awaitPos = 0;
25829 this.awaitIdentPos = 0;
25830 this.enterScope(functionFlags(node.async, node.generator));
25831
25832 if (!(statement & FUNC_STATEMENT)) {
25833 node.id = this.type === types$1.name ? this.parseIdent() : null;
25834 }
25835
25836 this.parseFunctionParams(node);
25837 this.parseFunctionBody(node, allowExpressionBody, false, forInit);
25838 this.yieldPos = oldYieldPos;
25839 this.awaitPos = oldAwaitPos;
25840 this.awaitIdentPos = oldAwaitIdentPos;
25841 return this.finishNode(node, statement & FUNC_STATEMENT ? "FunctionDeclaration" : "FunctionExpression");
25842 };
25843
25844 pp$8.parseFunctionParams = function (node) {
25845 this.expect(types$1.parenL);
25846 node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
25847 this.checkYieldAwaitInDefaultParams();
25848 }; // Parse a class declaration or literal (depending on the
25849 // `isStatement` parameter).
25850
25851
25852 pp$8.parseClass = function (node, isStatement) {
25853 this.next(); // ecma-262 14.6 Class Definitions
25854 // A class definition is always strict mode code.
25855
25856 var oldStrict = this.strict;
25857 this.strict = true;
25858 this.parseClassId(node, isStatement);
25859 this.parseClassSuper(node);
25860 var privateNameMap = this.enterClassBody();
25861 var classBody = this.startNode();
25862 var hadConstructor = false;
25863 classBody.body = [];
25864 this.expect(types$1.braceL);
25865
25866 while (this.type !== types$1.braceR) {
25867 var element = this.parseClassElement(node.superClass !== null);
25868
25869 if (element) {
25870 classBody.body.push(element);
25871
25872 if (element.type === "MethodDefinition" && element.kind === "constructor") {
25873 if (hadConstructor) {
25874 this.raise(element.start, "Duplicate constructor in the same class");
25875 }
25876
25877 hadConstructor = true;
25878 } else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
25879 this.raiseRecoverable(element.key.start, "Identifier '#" + element.key.name + "' has already been declared");
25880 }
25881 }
25882 }
25883
25884 this.strict = oldStrict;
25885 this.next();
25886 node.body = this.finishNode(classBody, "ClassBody");
25887 this.exitClassBody();
25888 return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
25889 };
25890
25891 pp$8.parseClassElement = function (constructorAllowsSuper) {
25892 if (this.eat(types$1.semi)) {
25893 return null;
25894 }
25895
25896 var ecmaVersion = this.options.ecmaVersion;
25897 var node = this.startNode();
25898 var keyName = "";
25899 var isGenerator = false;
25900 var isAsync = false;
25901 var kind = "method";
25902 var isStatic = false;
25903
25904 if (this.eatContextual("static")) {
25905 // Parse static init block
25906 if (ecmaVersion >= 13 && this.eat(types$1.braceL)) {
25907 this.parseClassStaticBlock(node);
25908 return node;
25909 }
25910
25911 if (this.isClassElementNameStart() || this.type === types$1.star) {
25912 isStatic = true;
25913 } else {
25914 keyName = "static";
25915 }
25916 }
25917
25918 node.static = isStatic;
25919
25920 if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) {
25921 if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) {
25922 isAsync = true;
25923 } else {
25924 keyName = "async";
25925 }
25926 }
25927
25928 if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) {
25929 isGenerator = true;
25930 }
25931
25932 if (!keyName && !isAsync && !isGenerator) {
25933 var lastValue = this.value;
25934
25935 if (this.eatContextual("get") || this.eatContextual("set")) {
25936 if (this.isClassElementNameStart()) {
25937 kind = lastValue;
25938 } else {
25939 keyName = lastValue;
25940 }
25941 }
25942 } // Parse element name
25943
25944
25945 if (keyName) {
25946 // 'async', 'get', 'set', or 'static' were not a keyword contextually.
25947 // The last token is any of those. Make it the element name.
25948 node.computed = false;
25949 node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc);
25950 node.key.name = keyName;
25951 this.finishNode(node.key, "Identifier");
25952 } else {
25953 this.parseClassElementName(node);
25954 } // Parse element value
25955
25956
25957 if (ecmaVersion < 13 || this.type === types$1.parenL || kind !== "method" || isGenerator || isAsync) {
25958 var isConstructor = !node.static && checkKeyName(node, "constructor");
25959 var allowsDirectSuper = isConstructor && constructorAllowsSuper; // Couldn't move this check into the 'parseClassMethod' method for backward compatibility.
25960
25961 if (isConstructor && kind !== "method") {
25962 this.raise(node.key.start, "Constructor can't have get/set modifier");
25963 }
25964
25965 node.kind = isConstructor ? "constructor" : kind;
25966 this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper);
25967 } else {
25968 this.parseClassField(node);
25969 }
25970
25971 return node;
25972 };
25973
25974 pp$8.isClassElementNameStart = function () {
25975 return this.type === types$1.name || this.type === types$1.privateId || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword;
25976 };
25977
25978 pp$8.parseClassElementName = function (element) {
25979 if (this.type === types$1.privateId) {
25980 if (this.value === "constructor") {
25981 this.raise(this.start, "Classes can't have an element named '#constructor'");
25982 }
25983
25984 element.computed = false;
25985 element.key = this.parsePrivateIdent();
25986 } else {
25987 this.parsePropertyName(element);
25988 }
25989 };
25990
25991 pp$8.parseClassMethod = function (method, isGenerator, isAsync, allowsDirectSuper) {
25992 // Check key and flags
25993 var key = method.key;
25994
25995 if (method.kind === "constructor") {
25996 if (isGenerator) {
25997 this.raise(key.start, "Constructor can't be a generator");
25998 }
25999
26000 if (isAsync) {
26001 this.raise(key.start, "Constructor can't be an async method");
26002 }
26003 } else if (method.static && checkKeyName(method, "prototype")) {
26004 this.raise(key.start, "Classes may not have a static property named prototype");
26005 } // Parse value
26006
26007
26008 var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper); // Check value
26009
26010 if (method.kind === "get" && value.params.length !== 0) {
26011 this.raiseRecoverable(value.start, "getter should have no params");
26012 }
26013
26014 if (method.kind === "set" && value.params.length !== 1) {
26015 this.raiseRecoverable(value.start, "setter should have exactly one param");
26016 }
26017
26018 if (method.kind === "set" && value.params[0].type === "RestElement") {
26019 this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params");
26020 }
26021
26022 return this.finishNode(method, "MethodDefinition");
26023 };
26024
26025 pp$8.parseClassField = function (field) {
26026 if (checkKeyName(field, "constructor")) {
26027 this.raise(field.key.start, "Classes can't have a field named 'constructor'");
26028 } else if (field.static && checkKeyName(field, "prototype")) {
26029 this.raise(field.key.start, "Classes can't have a static field named 'prototype'");
26030 }
26031
26032 if (this.eat(types$1.eq)) {
26033 // To raise SyntaxError if 'arguments' exists in the initializer.
26034 var scope = this.currentThisScope();
26035 var inClassFieldInit = scope.inClassFieldInit;
26036 scope.inClassFieldInit = true;
26037 field.value = this.parseMaybeAssign();
26038 scope.inClassFieldInit = inClassFieldInit;
26039 } else {
26040 field.value = null;
26041 }
26042
26043 this.semicolon();
26044 return this.finishNode(field, "PropertyDefinition");
26045 };
26046
26047 pp$8.parseClassStaticBlock = function (node) {
26048 node.body = [];
26049 var oldLabels = this.labels;
26050 this.labels = [];
26051 this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER);
26052
26053 while (this.type !== types$1.braceR) {
26054 var stmt = this.parseStatement(null);
26055 node.body.push(stmt);
26056 }
26057
26058 this.next();
26059 this.exitScope();
26060 this.labels = oldLabels;
26061 return this.finishNode(node, "StaticBlock");
26062 };
26063
26064 pp$8.parseClassId = function (node, isStatement) {
26065 if (this.type === types$1.name) {
26066 node.id = this.parseIdent();
26067
26068 if (isStatement) {
26069 this.checkLValSimple(node.id, BIND_LEXICAL, false);
26070 }
26071 } else {
26072 if (isStatement === true) {
26073 this.unexpected();
26074 }
26075
26076 node.id = null;
26077 }
26078 };
26079
26080 pp$8.parseClassSuper = function (node) {
26081 node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(false) : null;
26082 };
26083
26084 pp$8.enterClassBody = function () {
26085 var element = {
26086 declared: Object.create(null),
26087 used: []
26088 };
26089 this.privateNameStack.push(element);
26090 return element.declared;
26091 };
26092
26093 pp$8.exitClassBody = function () {
26094 var ref = this.privateNameStack.pop();
26095 var declared = ref.declared;
26096 var used = ref.used;
26097 var len = this.privateNameStack.length;
26098 var parent = len === 0 ? null : this.privateNameStack[len - 1];
26099
26100 for (var i = 0; i < used.length; ++i) {
26101 var id = used[i];
26102
26103 if (!has(declared, id.name)) {
26104 if (parent) {
26105 parent.used.push(id);
26106 } else {
26107 this.raiseRecoverable(id.start, "Private field '#" + id.name + "' must be declared in an enclosing class");
26108 }
26109 }
26110 }
26111 };
26112
26113 function isPrivateNameConflicted(privateNameMap, element) {
26114 var name = element.key.name;
26115 var curr = privateNameMap[name];
26116 var next = "true";
26117
26118 if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) {
26119 next = (element.static ? "s" : "i") + element.kind;
26120 } // `class { get #a(){}; static set #a(_){} }` is also conflict.
26121
26122
26123 if (curr === "iget" && next === "iset" || curr === "iset" && next === "iget" || curr === "sget" && next === "sset" || curr === "sset" && next === "sget") {
26124 privateNameMap[name] = "true";
26125 return false;
26126 } else if (!curr) {
26127 privateNameMap[name] = next;
26128 return false;
26129 } else {
26130 return true;
26131 }
26132 }
26133
26134 function checkKeyName(node, name) {
26135 var computed = node.computed;
26136 var key = node.key;
26137 return !computed && (key.type === "Identifier" && key.name === name || key.type === "Literal" && key.value === name);
26138 } // Parses module export declaration.
26139
26140
26141 pp$8.parseExport = function (node, exports) {
26142 this.next(); // export * from '...'
26143
26144 if (this.eat(types$1.star)) {
26145 if (this.options.ecmaVersion >= 11) {
26146 if (this.eatContextual("as")) {
26147 node.exported = this.parseIdent(true);
26148 this.checkExport(exports, node.exported.name, this.lastTokStart);
26149 } else {
26150 node.exported = null;
26151 }
26152 }
26153
26154 this.expectContextual("from");
26155
26156 if (this.type !== types$1.string) {
26157 this.unexpected();
26158 }
26159
26160 node.source = this.parseExprAtom();
26161 this.semicolon();
26162 return this.finishNode(node, "ExportAllDeclaration");
26163 }
26164
26165 if (this.eat(types$1._default)) {
26166 // export default ...
26167 this.checkExport(exports, "default", this.lastTokStart);
26168 var isAsync;
26169
26170 if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
26171 var fNode = this.startNode();
26172 this.next();
26173
26174 if (isAsync) {
26175 this.next();
26176 }
26177
26178 node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
26179 } else if (this.type === types$1._class) {
26180 var cNode = this.startNode();
26181 node.declaration = this.parseClass(cNode, "nullableID");
26182 } else {
26183 node.declaration = this.parseMaybeAssign();
26184 this.semicolon();
26185 }
26186
26187 return this.finishNode(node, "ExportDefaultDeclaration");
26188 } // export var|const|let|function|class ...
26189
26190
26191 if (this.shouldParseExportStatement()) {
26192 node.declaration = this.parseStatement(null);
26193
26194 if (node.declaration.type === "VariableDeclaration") {
26195 this.checkVariableExport(exports, node.declaration.declarations);
26196 } else {
26197 this.checkExport(exports, node.declaration.id.name, node.declaration.id.start);
26198 }
26199
26200 node.specifiers = [];
26201 node.source = null;
26202 } else {
26203 // export { x, y as z } [from '...']
26204 node.declaration = null;
26205 node.specifiers = this.parseExportSpecifiers(exports);
26206
26207 if (this.eatContextual("from")) {
26208 if (this.type !== types$1.string) {
26209 this.unexpected();
26210 }
26211
26212 node.source = this.parseExprAtom();
26213 } else {
26214 for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
26215 // check for keywords used as local names
26216 var spec = list[i];
26217 this.checkUnreserved(spec.local); // check if export is defined
26218
26219 this.checkLocalExport(spec.local);
26220 }
26221
26222 node.source = null;
26223 }
26224
26225 this.semicolon();
26226 }
26227
26228 return this.finishNode(node, "ExportNamedDeclaration");
26229 };
26230
26231 pp$8.checkExport = function (exports, name, pos) {
26232 if (!exports) {
26233 return;
26234 }
26235
26236 if (has(exports, name)) {
26237 this.raiseRecoverable(pos, "Duplicate export '" + name + "'");
26238 }
26239
26240 exports[name] = true;
26241 };
26242
26243 pp$8.checkPatternExport = function (exports, pat) {
26244 var type = pat.type;
26245
26246 if (type === "Identifier") {
26247 this.checkExport(exports, pat.name, pat.start);
26248 } else if (type === "ObjectPattern") {
26249 for (var i = 0, list = pat.properties; i < list.length; i += 1) {
26250 var prop = list[i];
26251 this.checkPatternExport(exports, prop);
26252 }
26253 } else if (type === "ArrayPattern") {
26254 for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
26255 var elt = list$1[i$1];
26256
26257 if (elt) {
26258 this.checkPatternExport(exports, elt);
26259 }
26260 }
26261 } else if (type === "Property") {
26262 this.checkPatternExport(exports, pat.value);
26263 } else if (type === "AssignmentPattern") {
26264 this.checkPatternExport(exports, pat.left);
26265 } else if (type === "RestElement") {
26266 this.checkPatternExport(exports, pat.argument);
26267 } else if (type === "ParenthesizedExpression") {
26268 this.checkPatternExport(exports, pat.expression);
26269 }
26270 };
26271
26272 pp$8.checkVariableExport = function (exports, decls) {
26273 if (!exports) {
26274 return;
26275 }
26276
26277 for (var i = 0, list = decls; i < list.length; i += 1) {
26278 var decl = list[i];
26279 this.checkPatternExport(exports, decl.id);
26280 }
26281 };
26282
26283 pp$8.shouldParseExportStatement = function () {
26284 return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
26285 }; // Parses a comma-separated list of module exports.
26286
26287
26288 pp$8.parseExportSpecifiers = function (exports) {
26289 var nodes = [],
26290 first = true; // export { x, y as z } [from '...']
26291
26292 this.expect(types$1.braceL);
26293
26294 while (!this.eat(types$1.braceR)) {
26295 if (!first) {
26296 this.expect(types$1.comma);
26297
26298 if (this.afterTrailingComma(types$1.braceR)) {
26299 break;
26300 }
26301 } else {
26302 first = false;
26303 }
26304
26305 var node = this.startNode();
26306 node.local = this.parseIdent(true);
26307 node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;
26308 this.checkExport(exports, node.exported.name, node.exported.start);
26309 nodes.push(this.finishNode(node, "ExportSpecifier"));
26310 }
26311
26312 return nodes;
26313 }; // Parses import declaration.
26314
26315
26316 pp$8.parseImport = function (node) {
26317 this.next(); // import '...'
26318
26319 if (this.type === types$1.string) {
26320 node.specifiers = empty$1;
26321 node.source = this.parseExprAtom();
26322 } else {
26323 node.specifiers = this.parseImportSpecifiers();
26324 this.expectContextual("from");
26325 node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected();
26326 }
26327
26328 this.semicolon();
26329 return this.finishNode(node, "ImportDeclaration");
26330 }; // Parses a comma-separated list of module imports.
26331
26332
26333 pp$8.parseImportSpecifiers = function () {
26334 var nodes = [],
26335 first = true;
26336
26337 if (this.type === types$1.name) {
26338 // import defaultObj, { x, y as z } from '...'
26339 var node = this.startNode();
26340 node.local = this.parseIdent();
26341 this.checkLValSimple(node.local, BIND_LEXICAL);
26342 nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
26343
26344 if (!this.eat(types$1.comma)) {
26345 return nodes;
26346 }
26347 }
26348
26349 if (this.type === types$1.star) {
26350 var node$1 = this.startNode();
26351 this.next();
26352 this.expectContextual("as");
26353 node$1.local = this.parseIdent();
26354 this.checkLValSimple(node$1.local, BIND_LEXICAL);
26355 nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
26356 return nodes;
26357 }
26358
26359 this.expect(types$1.braceL);
26360
26361 while (!this.eat(types$1.braceR)) {
26362 if (!first) {
26363 this.expect(types$1.comma);
26364
26365 if (this.afterTrailingComma(types$1.braceR)) {
26366 break;
26367 }
26368 } else {
26369 first = false;
26370 }
26371
26372 var node$2 = this.startNode();
26373 node$2.imported = this.parseIdent(true);
26374
26375 if (this.eatContextual("as")) {
26376 node$2.local = this.parseIdent();
26377 } else {
26378 this.checkUnreserved(node$2.imported);
26379 node$2.local = node$2.imported;
26380 }
26381
26382 this.checkLValSimple(node$2.local, BIND_LEXICAL);
26383 nodes.push(this.finishNode(node$2, "ImportSpecifier"));
26384 }
26385
26386 return nodes;
26387 }; // Set `ExpressionStatement#directive` property for directive prologues.
26388
26389
26390 pp$8.adaptDirectivePrologue = function (statements) {
26391 for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
26392 statements[i].directive = statements[i].expression.raw.slice(1, -1);
26393 }
26394 };
26395
26396 pp$8.isDirectiveCandidate = function (statement) {
26397 return statement.type === "ExpressionStatement" && statement.expression.type === "Literal" && typeof statement.expression.value === "string" && ( // Reject parenthesized strings.
26398 this.input[statement.start] === "\"" || this.input[statement.start] === "'");
26399 };
26400
26401 var pp$7 = Parser.prototype; // Convert existing expression atom to assignable pattern
26402 // if possible.
26403
26404 pp$7.toAssignable = function (node, isBinding, refDestructuringErrors) {
26405 if (this.options.ecmaVersion >= 6 && node) {
26406 switch (node.type) {
26407 case "Identifier":
26408 if (this.inAsync && node.name === "await") {
26409 this.raise(node.start, "Cannot use 'await' as identifier inside an async function");
26410 }
26411
26412 break;
26413
26414 case "ObjectPattern":
26415 case "ArrayPattern":
26416 case "AssignmentPattern":
26417 case "RestElement":
26418 break;
26419
26420 case "ObjectExpression":
26421 node.type = "ObjectPattern";
26422
26423 if (refDestructuringErrors) {
26424 this.checkPatternErrors(refDestructuringErrors, true);
26425 }
26426
26427 for (var i = 0, list = node.properties; i < list.length; i += 1) {
26428 var prop = list[i];
26429 this.toAssignable(prop, isBinding); // Early error:
26430 // AssignmentRestProperty[Yield, Await] :
26431 // `...` DestructuringAssignmentTarget[Yield, Await]
26432 //
26433 // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.
26434
26435 if (prop.type === "RestElement" && (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")) {
26436 this.raise(prop.argument.start, "Unexpected token");
26437 }
26438 }
26439
26440 break;
26441
26442 case "Property":
26443 // AssignmentProperty has type === "Property"
26444 if (node.kind !== "init") {
26445 this.raise(node.key.start, "Object pattern can't contain getter or setter");
26446 }
26447
26448 this.toAssignable(node.value, isBinding);
26449 break;
26450
26451 case "ArrayExpression":
26452 node.type = "ArrayPattern";
26453
26454 if (refDestructuringErrors) {
26455 this.checkPatternErrors(refDestructuringErrors, true);
26456 }
26457
26458 this.toAssignableList(node.elements, isBinding);
26459 break;
26460
26461 case "SpreadElement":
26462 node.type = "RestElement";
26463 this.toAssignable(node.argument, isBinding);
26464
26465 if (node.argument.type === "AssignmentPattern") {
26466 this.raise(node.argument.start, "Rest elements cannot have a default value");
26467 }
26468
26469 break;
26470
26471 case "AssignmentExpression":
26472 if (node.operator !== "=") {
26473 this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");
26474 }
26475
26476 node.type = "AssignmentPattern";
26477 delete node.operator;
26478 this.toAssignable(node.left, isBinding);
26479 break;
26480
26481 case "ParenthesizedExpression":
26482 this.toAssignable(node.expression, isBinding, refDestructuringErrors);
26483 break;
26484
26485 case "ChainExpression":
26486 this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
26487 break;
26488
26489 case "MemberExpression":
26490 if (!isBinding) {
26491 break;
26492 }
26493
26494 default:
26495 this.raise(node.start, "Assigning to rvalue");
26496 }
26497 } else if (refDestructuringErrors) {
26498 this.checkPatternErrors(refDestructuringErrors, true);
26499 }
26500
26501 return node;
26502 }; // Convert list of expression atoms to binding list.
26503
26504
26505 pp$7.toAssignableList = function (exprList, isBinding) {
26506 var end = exprList.length;
26507
26508 for (var i = 0; i < end; i++) {
26509 var elt = exprList[i];
26510
26511 if (elt) {
26512 this.toAssignable(elt, isBinding);
26513 }
26514 }
26515
26516 if (end) {
26517 var last = exprList[end - 1];
26518
26519 if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier") {
26520 this.unexpected(last.argument.start);
26521 }
26522 }
26523
26524 return exprList;
26525 }; // Parses spread element.
26526
26527
26528 pp$7.parseSpread = function (refDestructuringErrors) {
26529 var node = this.startNode();
26530 this.next();
26531 node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
26532 return this.finishNode(node, "SpreadElement");
26533 };
26534
26535 pp$7.parseRestBinding = function () {
26536 var node = this.startNode();
26537 this.next(); // RestElement inside of a function parameter must be an identifier
26538
26539 if (this.options.ecmaVersion === 6 && this.type !== types$1.name) {
26540 this.unexpected();
26541 }
26542
26543 node.argument = this.parseBindingAtom();
26544 return this.finishNode(node, "RestElement");
26545 }; // Parses lvalue (assignable) atom.
26546
26547
26548 pp$7.parseBindingAtom = function () {
26549 if (this.options.ecmaVersion >= 6) {
26550 switch (this.type) {
26551 case types$1.bracketL:
26552 var node = this.startNode();
26553 this.next();
26554 node.elements = this.parseBindingList(types$1.bracketR, true, true);
26555 return this.finishNode(node, "ArrayPattern");
26556
26557 case types$1.braceL:
26558 return this.parseObj(true);
26559 }
26560 }
26561
26562 return this.parseIdent();
26563 };
26564
26565 pp$7.parseBindingList = function (close, allowEmpty, allowTrailingComma) {
26566 var elts = [],
26567 first = true;
26568
26569 while (!this.eat(close)) {
26570 if (first) {
26571 first = false;
26572 } else {
26573 this.expect(types$1.comma);
26574 }
26575
26576 if (allowEmpty && this.type === types$1.comma) {
26577 elts.push(null);
26578 } else if (allowTrailingComma && this.afterTrailingComma(close)) {
26579 break;
26580 } else if (this.type === types$1.ellipsis) {
26581 var rest = this.parseRestBinding();
26582 this.parseBindingListItem(rest);
26583 elts.push(rest);
26584
26585 if (this.type === types$1.comma) {
26586 this.raise(this.start, "Comma is not permitted after the rest element");
26587 }
26588
26589 this.expect(close);
26590 break;
26591 } else {
26592 var elem = this.parseMaybeDefault(this.start, this.startLoc);
26593 this.parseBindingListItem(elem);
26594 elts.push(elem);
26595 }
26596 }
26597
26598 return elts;
26599 };
26600
26601 pp$7.parseBindingListItem = function (param) {
26602 return param;
26603 }; // Parses assignment pattern around given atom if possible.
26604
26605
26606 pp$7.parseMaybeDefault = function (startPos, startLoc, left) {
26607 left = left || this.parseBindingAtom();
26608
26609 if (this.options.ecmaVersion < 6 || !this.eat(types$1.eq)) {
26610 return left;
26611 }
26612
26613 var node = this.startNodeAt(startPos, startLoc);
26614 node.left = left;
26615 node.right = this.parseMaybeAssign();
26616 return this.finishNode(node, "AssignmentPattern");
26617 }; // The following three functions all verify that a node is an lvalue —
26618 // something that can be bound, or assigned to. In order to do so, they perform
26619 // a variety of checks:
26620 //
26621 // - Check that none of the bound/assigned-to identifiers are reserved words.
26622 // - Record name declarations for bindings in the appropriate scope.
26623 // - Check duplicate argument names, if checkClashes is set.
26624 //
26625 // If a complex binding pattern is encountered (e.g., object and array
26626 // destructuring), the entire pattern is recursively checked.
26627 //
26628 // There are three versions of checkLVal*() appropriate for different
26629 // circumstances:
26630 //
26631 // - checkLValSimple() shall be used if the syntactic construct supports
26632 // nothing other than identifiers and member expressions. Parenthesized
26633 // expressions are also correctly handled. This is generally appropriate for
26634 // constructs for which the spec says
26635 //
26636 // > It is a Syntax Error if AssignmentTargetType of [the production] is not
26637 // > simple.
26638 //
26639 // It is also appropriate for checking if an identifier is valid and not
26640 // defined elsewhere, like import declarations or function/class identifiers.
26641 //
26642 // Examples where this is used include:
26643 // a += …;
26644 // import a from '…';
26645 // where a is the node to be checked.
26646 //
26647 // - checkLValPattern() shall be used if the syntactic construct supports
26648 // anything checkLValSimple() supports, as well as object and array
26649 // destructuring patterns. This is generally appropriate for constructs for
26650 // which the spec says
26651 //
26652 // > It is a Syntax Error if [the production] is neither an ObjectLiteral nor
26653 // > an ArrayLiteral and AssignmentTargetType of [the production] is not
26654 // > simple.
26655 //
26656 // Examples where this is used include:
26657 // (a = …);
26658 // const a = …;
26659 // try { … } catch (a) { … }
26660 // where a is the node to be checked.
26661 //
26662 // - checkLValInnerPattern() shall be used if the syntactic construct supports
26663 // anything checkLValPattern() supports, as well as default assignment
26664 // patterns, rest elements, and other constructs that may appear within an
26665 // object or array destructuring pattern.
26666 //
26667 // As a special case, function parameters also use checkLValInnerPattern(),
26668 // as they also support defaults and rest constructs.
26669 //
26670 // These functions deliberately support both assignment and binding constructs,
26671 // as the logic for both is exceedingly similar. If the node is the target of
26672 // an assignment, then bindingType should be set to BIND_NONE. Otherwise, it
26673 // should be set to the appropriate BIND_* constant, like BIND_VAR or
26674 // BIND_LEXICAL.
26675 //
26676 // If the function is called with a non-BIND_NONE bindingType, then
26677 // additionally a checkClashes object may be specified to allow checking for
26678 // duplicate argument names. checkClashes is ignored if the provided construct
26679 // is an assignment (i.e., bindingType is BIND_NONE).
26680
26681
26682 pp$7.checkLValSimple = function (expr, bindingType, checkClashes) {
26683 if (bindingType === void 0) bindingType = BIND_NONE;
26684 var isBind = bindingType !== BIND_NONE;
26685
26686 switch (expr.type) {
26687 case "Identifier":
26688 if (this.strict && this.reservedWordsStrictBind.test(expr.name)) {
26689 this.raiseRecoverable(expr.start, (isBind ? "Binding " : "Assigning to ") + expr.name + " in strict mode");
26690 }
26691
26692 if (isBind) {
26693 if (bindingType === BIND_LEXICAL && expr.name === "let") {
26694 this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name");
26695 }
26696
26697 if (checkClashes) {
26698 if (has(checkClashes, expr.name)) {
26699 this.raiseRecoverable(expr.start, "Argument name clash");
26700 }
26701
26702 checkClashes[expr.name] = true;
26703 }
26704
26705 if (bindingType !== BIND_OUTSIDE) {
26706 this.declareName(expr.name, bindingType, expr.start);
26707 }
26708 }
26709
26710 break;
26711
26712 case "ChainExpression":
26713 this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side");
26714 break;
26715
26716 case "MemberExpression":
26717 if (isBind) {
26718 this.raiseRecoverable(expr.start, "Binding member expression");
26719 }
26720
26721 break;
26722
26723 case "ParenthesizedExpression":
26724 if (isBind) {
26725 this.raiseRecoverable(expr.start, "Binding parenthesized expression");
26726 }
26727
26728 return this.checkLValSimple(expr.expression, bindingType, checkClashes);
26729
26730 default:
26731 this.raise(expr.start, (isBind ? "Binding" : "Assigning to") + " rvalue");
26732 }
26733 };
26734
26735 pp$7.checkLValPattern = function (expr, bindingType, checkClashes) {
26736 if (bindingType === void 0) bindingType = BIND_NONE;
26737
26738 switch (expr.type) {
26739 case "ObjectPattern":
26740 for (var i = 0, list = expr.properties; i < list.length; i += 1) {
26741 var prop = list[i];
26742 this.checkLValInnerPattern(prop, bindingType, checkClashes);
26743 }
26744
26745 break;
26746
26747 case "ArrayPattern":
26748 for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
26749 var elem = list$1[i$1];
26750
26751 if (elem) {
26752 this.checkLValInnerPattern(elem, bindingType, checkClashes);
26753 }
26754 }
26755
26756 break;
26757
26758 default:
26759 this.checkLValSimple(expr, bindingType, checkClashes);
26760 }
26761 };
26762
26763 pp$7.checkLValInnerPattern = function (expr, bindingType, checkClashes) {
26764 if (bindingType === void 0) bindingType = BIND_NONE;
26765
26766 switch (expr.type) {
26767 case "Property":
26768 // AssignmentProperty has type === "Property"
26769 this.checkLValInnerPattern(expr.value, bindingType, checkClashes);
26770 break;
26771
26772 case "AssignmentPattern":
26773 this.checkLValPattern(expr.left, bindingType, checkClashes);
26774 break;
26775
26776 case "RestElement":
26777 this.checkLValPattern(expr.argument, bindingType, checkClashes);
26778 break;
26779
26780 default:
26781 this.checkLValPattern(expr, bindingType, checkClashes);
26782 }
26783 }; // The algorithm used to determine whether a regexp can appear at a
26784
26785
26786 var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
26787 this.token = token;
26788 this.isExpr = !!isExpr;
26789 this.preserveSpace = !!preserveSpace;
26790 this.override = override;
26791 this.generator = !!generator;
26792 };
26793
26794 var types = {
26795 b_stat: new TokContext("{", false),
26796 b_expr: new TokContext("{", true),
26797 b_tmpl: new TokContext("${", false),
26798 p_stat: new TokContext("(", false),
26799 p_expr: new TokContext("(", true),
26800 q_tmpl: new TokContext("`", true, true, function (p) {
26801 return p.tryReadTemplateToken();
26802 }),
26803 f_stat: new TokContext("function", false),
26804 f_expr: new TokContext("function", true),
26805 f_expr_gen: new TokContext("function", true, false, null, true),
26806 f_gen: new TokContext("function", false, false, null, true)
26807 };
26808 var pp$6 = Parser.prototype;
26809
26810 pp$6.initialContext = function () {
26811 return [types.b_stat];
26812 };
26813
26814 pp$6.curContext = function () {
26815 return this.context[this.context.length - 1];
26816 };
26817
26818 pp$6.braceIsBlock = function (prevType) {
26819 var parent = this.curContext();
26820
26821 if (parent === types.f_expr || parent === types.f_stat) {
26822 return true;
26823 }
26824
26825 if (prevType === types$1.colon && (parent === types.b_stat || parent === types.b_expr)) {
26826 return !parent.isExpr;
26827 } // The check for `tt.name && exprAllowed` detects whether we are
26828 // after a `yield` or `of` construct. See the `updateContext` for
26829 // `tt.name`.
26830
26831
26832 if (prevType === types$1._return || prevType === types$1.name && this.exprAllowed) {
26833 return lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
26834 }
26835
26836 if (prevType === types$1._else || prevType === types$1.semi || prevType === types$1.eof || prevType === types$1.parenR || prevType === types$1.arrow) {
26837 return true;
26838 }
26839
26840 if (prevType === types$1.braceL) {
26841 return parent === types.b_stat;
26842 }
26843
26844 if (prevType === types$1._var || prevType === types$1._const || prevType === types$1.name) {
26845 return false;
26846 }
26847
26848 return !this.exprAllowed;
26849 };
26850
26851 pp$6.inGeneratorContext = function () {
26852 for (var i = this.context.length - 1; i >= 1; i--) {
26853 var context = this.context[i];
26854
26855 if (context.token === "function") {
26856 return context.generator;
26857 }
26858 }
26859
26860 return false;
26861 };
26862
26863 pp$6.updateContext = function (prevType) {
26864 var update,
26865 type = this.type;
26866
26867 if (type.keyword && prevType === types$1.dot) {
26868 this.exprAllowed = false;
26869 } else if (update = type.updateContext) {
26870 update.call(this, prevType);
26871 } else {
26872 this.exprAllowed = type.beforeExpr;
26873 }
26874 }; // Used to handle egde case when token context could not be inferred correctly in tokenize phase
26875
26876
26877 pp$6.overrideContext = function (tokenCtx) {
26878 if (this.curContext() !== tokenCtx) {
26879 this.context[this.context.length - 1] = tokenCtx;
26880 }
26881 }; // Token-specific context update code
26882
26883
26884 types$1.parenR.updateContext = types$1.braceR.updateContext = function () {
26885 if (this.context.length === 1) {
26886 this.exprAllowed = true;
26887 return;
26888 }
26889
26890 var out = this.context.pop();
26891
26892 if (out === types.b_stat && this.curContext().token === "function") {
26893 out = this.context.pop();
26894 }
26895
26896 this.exprAllowed = !out.isExpr;
26897 };
26898
26899 types$1.braceL.updateContext = function (prevType) {
26900 this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
26901 this.exprAllowed = true;
26902 };
26903
26904 types$1.dollarBraceL.updateContext = function () {
26905 this.context.push(types.b_tmpl);
26906 this.exprAllowed = true;
26907 };
26908
26909 types$1.parenL.updateContext = function (prevType) {
26910 var statementParens = prevType === types$1._if || prevType === types$1._for || prevType === types$1._with || prevType === types$1._while;
26911 this.context.push(statementParens ? types.p_stat : types.p_expr);
26912 this.exprAllowed = true;
26913 };
26914
26915 types$1.incDec.updateContext = function () {// tokExprAllowed stays unchanged
26916 };
26917
26918 types$1._function.updateContext = types$1._class.updateContext = function (prevType) {
26919 if (prevType.beforeExpr && prevType !== types$1._else && !(prevType === types$1.semi && this.curContext() !== types.p_stat) && !(prevType === types$1._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) && !((prevType === types$1.colon || prevType === types$1.braceL) && this.curContext() === types.b_stat)) {
26920 this.context.push(types.f_expr);
26921 } else {
26922 this.context.push(types.f_stat);
26923 }
26924
26925 this.exprAllowed = false;
26926 };
26927
26928 types$1.backQuote.updateContext = function () {
26929 if (this.curContext() === types.q_tmpl) {
26930 this.context.pop();
26931 } else {
26932 this.context.push(types.q_tmpl);
26933 }
26934
26935 this.exprAllowed = false;
26936 };
26937
26938 types$1.star.updateContext = function (prevType) {
26939 if (prevType === types$1._function) {
26940 var index = this.context.length - 1;
26941
26942 if (this.context[index] === types.f_expr) {
26943 this.context[index] = types.f_expr_gen;
26944 } else {
26945 this.context[index] = types.f_gen;
26946 }
26947 }
26948
26949 this.exprAllowed = true;
26950 };
26951
26952 types$1.name.updateContext = function (prevType) {
26953 var allowed = false;
26954
26955 if (this.options.ecmaVersion >= 6 && prevType !== types$1.dot) {
26956 if (this.value === "of" && !this.exprAllowed || this.value === "yield" && this.inGeneratorContext()) {
26957 allowed = true;
26958 }
26959 }
26960
26961 this.exprAllowed = allowed;
26962 }; // A recursive descent parser operates by defining functions for all
26963
26964
26965 var pp$5 = Parser.prototype; // Check if property name clashes with already added.
26966 // Object/class getters and setters are not allowed to clash —
26967 // either with each other or with an init property — and in
26968 // strict mode, init properties are also not allowed to be repeated.
26969
26970 pp$5.checkPropClash = function (prop, propHash, refDestructuringErrors) {
26971 if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement") {
26972 return;
26973 }
26974
26975 if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) {
26976 return;
26977 }
26978
26979 var key = prop.key;
26980 var name;
26981
26982 switch (key.type) {
26983 case "Identifier":
26984 name = key.name;
26985 break;
26986
26987 case "Literal":
26988 name = String(key.value);
26989 break;
26990
26991 default:
26992 return;
26993 }
26994
26995 var kind = prop.kind;
26996
26997 if (this.options.ecmaVersion >= 6) {
26998 if (name === "__proto__" && kind === "init") {
26999 if (propHash.proto) {
27000 if (refDestructuringErrors) {
27001 if (refDestructuringErrors.doubleProto < 0) {
27002 refDestructuringErrors.doubleProto = key.start;
27003 }
27004 } else {
27005 this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
27006 }
27007 }
27008
27009 propHash.proto = true;
27010 }
27011
27012 return;
27013 }
27014
27015 name = "$" + name;
27016 var other = propHash[name];
27017
27018 if (other) {
27019 var redefinition;
27020
27021 if (kind === "init") {
27022 redefinition = this.strict && other.init || other.get || other.set;
27023 } else {
27024 redefinition = other.init || other[kind];
27025 }
27026
27027 if (redefinition) {
27028 this.raiseRecoverable(key.start, "Redefinition of property");
27029 }
27030 } else {
27031 other = propHash[name] = {
27032 init: false,
27033 get: false,
27034 set: false
27035 };
27036 }
27037
27038 other[kind] = true;
27039 }; // ### Expression parsing
27040 // These nest, from the most general expression type at the top to
27041 // 'atomic', nondivisible expression types at the bottom. Most of
27042 // the functions will simply let the function(s) below them parse,
27043 // and, *if* the syntactic construct they handle is present, wrap
27044 // the AST node that the inner parser gave them in another node.
27045 // Parse a full expression. The optional arguments are used to
27046 // forbid the `in` operator (in for loops initalization expressions)
27047 // and provide reference for storing '=' operator inside shorthand
27048 // property assignment in contexts where both object expression
27049 // and object pattern might appear (so it's possible to raise
27050 // delayed syntax error at correct position).
27051
27052
27053 pp$5.parseExpression = function (forInit, refDestructuringErrors) {
27054 var startPos = this.start,
27055 startLoc = this.startLoc;
27056 var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
27057
27058 if (this.type === types$1.comma) {
27059 var node = this.startNodeAt(startPos, startLoc);
27060 node.expressions = [expr];
27061
27062 while (this.eat(types$1.comma)) {
27063 node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors));
27064 }
27065
27066 return this.finishNode(node, "SequenceExpression");
27067 }
27068
27069 return expr;
27070 }; // Parse an assignment expression. This includes applications of
27071 // operators like `+=`.
27072
27073
27074 pp$5.parseMaybeAssign = function (forInit, refDestructuringErrors, afterLeftParse) {
27075 if (this.isContextual("yield")) {
27076 if (this.inGenerator) {
27077 return this.parseYield(forInit);
27078 } // The tokenizer will assume an expression is allowed after
27079 // `yield`, but this isn't that kind of yield
27080 else {
27081 this.exprAllowed = false;
27082 }
27083 }
27084
27085 var ownDestructuringErrors = false,
27086 oldParenAssign = -1,
27087 oldTrailingComma = -1,
27088 oldDoubleProto = -1;
27089
27090 if (refDestructuringErrors) {
27091 oldParenAssign = refDestructuringErrors.parenthesizedAssign;
27092 oldTrailingComma = refDestructuringErrors.trailingComma;
27093 oldDoubleProto = refDestructuringErrors.doubleProto;
27094 refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
27095 } else {
27096 refDestructuringErrors = new DestructuringErrors();
27097 ownDestructuringErrors = true;
27098 }
27099
27100 var startPos = this.start,
27101 startLoc = this.startLoc;
27102
27103 if (this.type === types$1.parenL || this.type === types$1.name) {
27104 this.potentialArrowAt = this.start;
27105 this.potentialArrowInForAwait = forInit === "await";
27106 }
27107
27108 var left = this.parseMaybeConditional(forInit, refDestructuringErrors);
27109
27110 if (afterLeftParse) {
27111 left = afterLeftParse.call(this, left, startPos, startLoc);
27112 }
27113
27114 if (this.type.isAssign) {
27115 var node = this.startNodeAt(startPos, startLoc);
27116 node.operator = this.value;
27117
27118 if (this.type === types$1.eq) {
27119 left = this.toAssignable(left, false, refDestructuringErrors);
27120 }
27121
27122 if (!ownDestructuringErrors) {
27123 refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
27124 }
27125
27126 if (refDestructuringErrors.shorthandAssign >= left.start) {
27127 refDestructuringErrors.shorthandAssign = -1;
27128 } // reset because shorthand default was used correctly
27129
27130
27131 if (this.type === types$1.eq) {
27132 this.checkLValPattern(left);
27133 } else {
27134 this.checkLValSimple(left);
27135 }
27136
27137 node.left = left;
27138 this.next();
27139 node.right = this.parseMaybeAssign(forInit);
27140
27141 if (oldDoubleProto > -1) {
27142 refDestructuringErrors.doubleProto = oldDoubleProto;
27143 }
27144
27145 return this.finishNode(node, "AssignmentExpression");
27146 } else {
27147 if (ownDestructuringErrors) {
27148 this.checkExpressionErrors(refDestructuringErrors, true);
27149 }
27150 }
27151
27152 if (oldParenAssign > -1) {
27153 refDestructuringErrors.parenthesizedAssign = oldParenAssign;
27154 }
27155
27156 if (oldTrailingComma > -1) {
27157 refDestructuringErrors.trailingComma = oldTrailingComma;
27158 }
27159
27160 return left;
27161 }; // Parse a ternary conditional (`?:`) operator.
27162
27163
27164 pp$5.parseMaybeConditional = function (forInit, refDestructuringErrors) {
27165 var startPos = this.start,
27166 startLoc = this.startLoc;
27167 var expr = this.parseExprOps(forInit, refDestructuringErrors);
27168
27169 if (this.checkExpressionErrors(refDestructuringErrors)) {
27170 return expr;
27171 }
27172
27173 if (this.eat(types$1.question)) {
27174 var node = this.startNodeAt(startPos, startLoc);
27175 node.test = expr;
27176 node.consequent = this.parseMaybeAssign();
27177 this.expect(types$1.colon);
27178 node.alternate = this.parseMaybeAssign(forInit);
27179 return this.finishNode(node, "ConditionalExpression");
27180 }
27181
27182 return expr;
27183 }; // Start the precedence parser.
27184
27185
27186 pp$5.parseExprOps = function (forInit, refDestructuringErrors) {
27187 var startPos = this.start,
27188 startLoc = this.startLoc;
27189 var expr = this.parseMaybeUnary(refDestructuringErrors, false, false, forInit);
27190
27191 if (this.checkExpressionErrors(refDestructuringErrors)) {
27192 return expr;
27193 }
27194
27195 return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit);
27196 }; // Parse binary operators with the operator precedence parsing
27197 // algorithm. `left` is the left-hand side of the operator.
27198 // `minPrec` provides context that allows the function to stop and
27199 // defer further parser to one of its callers when it encounters an
27200 // operator that has a lower precedence than the set it is parsing.
27201
27202
27203 pp$5.parseExprOp = function (left, leftStartPos, leftStartLoc, minPrec, forInit) {
27204 var prec = this.type.binop;
27205
27206 if (prec != null && (!forInit || this.type !== types$1._in)) {
27207 if (prec > minPrec) {
27208 var logical = this.type === types$1.logicalOR || this.type === types$1.logicalAND;
27209 var coalesce = this.type === types$1.coalesce;
27210
27211 if (coalesce) {
27212 // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.
27213 // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.
27214 prec = types$1.logicalAND.binop;
27215 }
27216
27217 var op = this.value;
27218 this.next();
27219 var startPos = this.start,
27220 startLoc = this.startLoc;
27221 var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit);
27222 var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
27223
27224 if (logical && this.type === types$1.coalesce || coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND)) {
27225 this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
27226 }
27227
27228 return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit);
27229 }
27230 }
27231
27232 return left;
27233 };
27234
27235 pp$5.buildBinary = function (startPos, startLoc, left, right, op, logical) {
27236 if (right.type === "PrivateIdentifier") {
27237 this.raise(right.start, "Private identifier can only be left side of binary expression");
27238 }
27239
27240 var node = this.startNodeAt(startPos, startLoc);
27241 node.left = left;
27242 node.operator = op;
27243 node.right = right;
27244 return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression");
27245 }; // Parse unary operators, both prefix and postfix.
27246
27247
27248 pp$5.parseMaybeUnary = function (refDestructuringErrors, sawUnary, incDec, forInit) {
27249 var startPos = this.start,
27250 startLoc = this.startLoc,
27251 expr;
27252
27253 if (this.isContextual("await") && this.canAwait) {
27254 expr = this.parseAwait(forInit);
27255 sawUnary = true;
27256 } else if (this.type.prefix) {
27257 var node = this.startNode(),
27258 update = this.type === types$1.incDec;
27259 node.operator = this.value;
27260 node.prefix = true;
27261 this.next();
27262 node.argument = this.parseMaybeUnary(null, true, update, forInit);
27263 this.checkExpressionErrors(refDestructuringErrors, true);
27264
27265 if (update) {
27266 this.checkLValSimple(node.argument);
27267 } else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") {
27268 this.raiseRecoverable(node.start, "Deleting local variable in strict mode");
27269 } else if (node.operator === "delete" && isPrivateFieldAccess(node.argument)) {
27270 this.raiseRecoverable(node.start, "Private fields can not be deleted");
27271 } else {
27272 sawUnary = true;
27273 }
27274
27275 expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
27276 } else if (!sawUnary && this.type === types$1.privateId) {
27277 if (forInit || this.privateNameStack.length === 0) {
27278 this.unexpected();
27279 }
27280
27281 expr = this.parsePrivateIdent(); // only could be private fields in 'in', such as #x in obj
27282
27283 if (this.type !== types$1._in) {
27284 this.unexpected();
27285 }
27286 } else {
27287 expr = this.parseExprSubscripts(refDestructuringErrors, forInit);
27288
27289 if (this.checkExpressionErrors(refDestructuringErrors)) {
27290 return expr;
27291 }
27292
27293 while (this.type.postfix && !this.canInsertSemicolon()) {
27294 var node$1 = this.startNodeAt(startPos, startLoc);
27295 node$1.operator = this.value;
27296 node$1.prefix = false;
27297 node$1.argument = expr;
27298 this.checkLValSimple(expr);
27299 this.next();
27300 expr = this.finishNode(node$1, "UpdateExpression");
27301 }
27302 }
27303
27304 if (!incDec && this.eat(types$1.starstar)) {
27305 if (sawUnary) {
27306 this.unexpected(this.lastTokStart);
27307 } else {
27308 return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false);
27309 }
27310 } else {
27311 return expr;
27312 }
27313 };
27314
27315 function isPrivateFieldAccess(node) {
27316 return node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" || node.type === "ChainExpression" && isPrivateFieldAccess(node.expression);
27317 } // Parse call, dot, and `[]`-subscript expressions.
27318
27319
27320 pp$5.parseExprSubscripts = function (refDestructuringErrors, forInit) {
27321 var startPos = this.start,
27322 startLoc = this.startLoc;
27323 var expr = this.parseExprAtom(refDestructuringErrors, forInit);
27324
27325 if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")") {
27326 return expr;
27327 }
27328
27329 var result = this.parseSubscripts(expr, startPos, startLoc, false, forInit);
27330
27331 if (refDestructuringErrors && result.type === "MemberExpression") {
27332 if (refDestructuringErrors.parenthesizedAssign >= result.start) {
27333 refDestructuringErrors.parenthesizedAssign = -1;
27334 }
27335
27336 if (refDestructuringErrors.parenthesizedBind >= result.start) {
27337 refDestructuringErrors.parenthesizedBind = -1;
27338 }
27339
27340 if (refDestructuringErrors.trailingComma >= result.start) {
27341 refDestructuringErrors.trailingComma = -1;
27342 }
27343 }
27344
27345 return result;
27346 };
27347
27348 pp$5.parseSubscripts = function (base, startPos, startLoc, noCalls, forInit) {
27349 var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && this.potentialArrowAt === base.start;
27350 var optionalChained = false;
27351
27352 while (true) {
27353 var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit);
27354
27355 if (element.optional) {
27356 optionalChained = true;
27357 }
27358
27359 if (element === base || element.type === "ArrowFunctionExpression") {
27360 if (optionalChained) {
27361 var chainNode = this.startNodeAt(startPos, startLoc);
27362 chainNode.expression = element;
27363 element = this.finishNode(chainNode, "ChainExpression");
27364 }
27365
27366 return element;
27367 }
27368
27369 base = element;
27370 }
27371 };
27372
27373 pp$5.parseSubscript = function (base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {
27374 var optionalSupported = this.options.ecmaVersion >= 11;
27375 var optional = optionalSupported && this.eat(types$1.questionDot);
27376
27377 if (noCalls && optional) {
27378 this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions");
27379 }
27380
27381 var computed = this.eat(types$1.bracketL);
27382
27383 if (computed || optional && this.type !== types$1.parenL && this.type !== types$1.backQuote || this.eat(types$1.dot)) {
27384 var node = this.startNodeAt(startPos, startLoc);
27385 node.object = base;
27386
27387 if (computed) {
27388 node.property = this.parseExpression();
27389 this.expect(types$1.bracketR);
27390 } else if (this.type === types$1.privateId && base.type !== "Super") {
27391 node.property = this.parsePrivateIdent();
27392 } else {
27393 node.property = this.parseIdent(this.options.allowReserved !== "never");
27394 }
27395
27396 node.computed = !!computed;
27397
27398 if (optionalSupported) {
27399 node.optional = optional;
27400 }
27401
27402 base = this.finishNode(node, "MemberExpression");
27403 } else if (!noCalls && this.eat(types$1.parenL)) {
27404 var refDestructuringErrors = new DestructuringErrors(),
27405 oldYieldPos = this.yieldPos,
27406 oldAwaitPos = this.awaitPos,
27407 oldAwaitIdentPos = this.awaitIdentPos;
27408 this.yieldPos = 0;
27409 this.awaitPos = 0;
27410 this.awaitIdentPos = 0;
27411 var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
27412
27413 if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {
27414 this.checkPatternErrors(refDestructuringErrors, false);
27415 this.checkYieldAwaitInDefaultParams();
27416
27417 if (this.awaitIdentPos > 0) {
27418 this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function");
27419 }
27420
27421 this.yieldPos = oldYieldPos;
27422 this.awaitPos = oldAwaitPos;
27423 this.awaitIdentPos = oldAwaitIdentPos;
27424 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit);
27425 }
27426
27427 this.checkExpressionErrors(refDestructuringErrors, true);
27428 this.yieldPos = oldYieldPos || this.yieldPos;
27429 this.awaitPos = oldAwaitPos || this.awaitPos;
27430 this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;
27431 var node$1 = this.startNodeAt(startPos, startLoc);
27432 node$1.callee = base;
27433 node$1.arguments = exprList;
27434
27435 if (optionalSupported) {
27436 node$1.optional = optional;
27437 }
27438
27439 base = this.finishNode(node$1, "CallExpression");
27440 } else if (this.type === types$1.backQuote) {
27441 if (optional || optionalChained) {
27442 this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
27443 }
27444
27445 var node$2 = this.startNodeAt(startPos, startLoc);
27446 node$2.tag = base;
27447 node$2.quasi = this.parseTemplate({
27448 isTagged: true
27449 });
27450 base = this.finishNode(node$2, "TaggedTemplateExpression");
27451 }
27452
27453 return base;
27454 }; // Parse an atomic expression — either a single token that is an
27455 // expression, an expression started by a keyword like `function` or
27456 // `new`, or an expression wrapped in punctuation like `()`, `[]`,
27457 // or `{}`.
27458
27459
27460 pp$5.parseExprAtom = function (refDestructuringErrors, forInit) {
27461 // If a division operator appears in an expression position, the
27462 // tokenizer got confused, and we force it to read a regexp instead.
27463 if (this.type === types$1.slash) {
27464 this.readRegexp();
27465 }
27466
27467 var node,
27468 canBeArrow = this.potentialArrowAt === this.start;
27469
27470 switch (this.type) {
27471 case types$1._super:
27472 if (!this.allowSuper) {
27473 this.raise(this.start, "'super' keyword outside a method");
27474 }
27475
27476 node = this.startNode();
27477 this.next();
27478
27479 if (this.type === types$1.parenL && !this.allowDirectSuper) {
27480 this.raise(node.start, "super() call outside constructor of a subclass");
27481 } // The `super` keyword can appear at below:
27482 // SuperProperty:
27483 // super [ Expression ]
27484 // super . IdentifierName
27485 // SuperCall:
27486 // super ( Arguments )
27487
27488
27489 if (this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL) {
27490 this.unexpected();
27491 }
27492
27493 return this.finishNode(node, "Super");
27494
27495 case types$1._this:
27496 node = this.startNode();
27497 this.next();
27498 return this.finishNode(node, "ThisExpression");
27499
27500 case types$1.name:
27501 var startPos = this.start,
27502 startLoc = this.startLoc,
27503 containsEsc = this.containsEsc;
27504 var id = this.parseIdent(false);
27505
27506 if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types$1._function)) {
27507 this.overrideContext(types.f_expr);
27508 return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true, forInit);
27509 }
27510
27511 if (canBeArrow && !this.canInsertSemicolon()) {
27512 if (this.eat(types$1.arrow)) {
27513 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false, forInit);
27514 }
27515
27516 if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types$1.name && !containsEsc && (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) {
27517 id = this.parseIdent(false);
27518
27519 if (this.canInsertSemicolon() || !this.eat(types$1.arrow)) {
27520 this.unexpected();
27521 }
27522
27523 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true, forInit);
27524 }
27525 }
27526
27527 return id;
27528
27529 case types$1.regexp:
27530 var value = this.value;
27531 node = this.parseLiteral(value.value);
27532 node.regex = {
27533 pattern: value.pattern,
27534 flags: value.flags
27535 };
27536 return node;
27537
27538 case types$1.num:
27539 case types$1.string:
27540 return this.parseLiteral(this.value);
27541
27542 case types$1._null:
27543 case types$1._true:
27544 case types$1._false:
27545 node = this.startNode();
27546 node.value = this.type === types$1._null ? null : this.type === types$1._true;
27547 node.raw = this.type.keyword;
27548 this.next();
27549 return this.finishNode(node, "Literal");
27550
27551 case types$1.parenL:
27552 var start = this.start,
27553 expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit);
27554
27555 if (refDestructuringErrors) {
27556 if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr)) {
27557 refDestructuringErrors.parenthesizedAssign = start;
27558 }
27559
27560 if (refDestructuringErrors.parenthesizedBind < 0) {
27561 refDestructuringErrors.parenthesizedBind = start;
27562 }
27563 }
27564
27565 return expr;
27566
27567 case types$1.bracketL:
27568 node = this.startNode();
27569 this.next();
27570 node.elements = this.parseExprList(types$1.bracketR, true, true, refDestructuringErrors);
27571 return this.finishNode(node, "ArrayExpression");
27572
27573 case types$1.braceL:
27574 this.overrideContext(types.b_expr);
27575 return this.parseObj(false, refDestructuringErrors);
27576
27577 case types$1._function:
27578 node = this.startNode();
27579 this.next();
27580 return this.parseFunction(node, 0);
27581
27582 case types$1._class:
27583 return this.parseClass(this.startNode(), false);
27584
27585 case types$1._new:
27586 return this.parseNew();
27587
27588 case types$1.backQuote:
27589 return this.parseTemplate();
27590
27591 case types$1._import:
27592 if (this.options.ecmaVersion >= 11) {
27593 return this.parseExprImport();
27594 } else {
27595 return this.unexpected();
27596 }
27597
27598 default:
27599 this.unexpected();
27600 }
27601 };
27602
27603 pp$5.parseExprImport = function () {
27604 var node = this.startNode(); // Consume `import` as an identifier for `import.meta`.
27605 // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.
27606
27607 if (this.containsEsc) {
27608 this.raiseRecoverable(this.start, "Escape sequence in keyword import");
27609 }
27610
27611 var meta = this.parseIdent(true);
27612
27613 switch (this.type) {
27614 case types$1.parenL:
27615 return this.parseDynamicImport(node);
27616
27617 case types$1.dot:
27618 node.meta = meta;
27619 return this.parseImportMeta(node);
27620
27621 default:
27622 this.unexpected();
27623 }
27624 };
27625
27626 pp$5.parseDynamicImport = function (node) {
27627 this.next(); // skip `(`
27628 // Parse node.source.
27629
27630 node.source = this.parseMaybeAssign(); // Verify ending.
27631
27632 if (!this.eat(types$1.parenR)) {
27633 var errorPos = this.start;
27634
27635 if (this.eat(types$1.comma) && this.eat(types$1.parenR)) {
27636 this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
27637 } else {
27638 this.unexpected(errorPos);
27639 }
27640 }
27641
27642 return this.finishNode(node, "ImportExpression");
27643 };
27644
27645 pp$5.parseImportMeta = function (node) {
27646 this.next(); // skip `.`
27647
27648 var containsEsc = this.containsEsc;
27649 node.property = this.parseIdent(true);
27650
27651 if (node.property.name !== "meta") {
27652 this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'");
27653 }
27654
27655 if (containsEsc) {
27656 this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters");
27657 }
27658
27659 if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere) {
27660 this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module");
27661 }
27662
27663 return this.finishNode(node, "MetaProperty");
27664 };
27665
27666 pp$5.parseLiteral = function (value) {
27667 var node = this.startNode();
27668 node.value = value;
27669 node.raw = this.input.slice(this.start, this.end);
27670
27671 if (node.raw.charCodeAt(node.raw.length - 1) === 110) {
27672 node.bigint = node.raw.slice(0, -1).replace(/_/g, "");
27673 }
27674
27675 this.next();
27676 return this.finishNode(node, "Literal");
27677 };
27678
27679 pp$5.parseParenExpression = function () {
27680 this.expect(types$1.parenL);
27681 var val = this.parseExpression();
27682 this.expect(types$1.parenR);
27683 return val;
27684 };
27685
27686 pp$5.parseParenAndDistinguishExpression = function (canBeArrow, forInit) {
27687 var startPos = this.start,
27688 startLoc = this.startLoc,
27689 val,
27690 allowTrailingComma = this.options.ecmaVersion >= 8;
27691
27692 if (this.options.ecmaVersion >= 6) {
27693 this.next();
27694 var innerStartPos = this.start,
27695 innerStartLoc = this.startLoc;
27696 var exprList = [],
27697 first = true,
27698 lastIsComma = false;
27699 var refDestructuringErrors = new DestructuringErrors(),
27700 oldYieldPos = this.yieldPos,
27701 oldAwaitPos = this.awaitPos,
27702 spreadStart;
27703 this.yieldPos = 0;
27704 this.awaitPos = 0; // Do not save awaitIdentPos to allow checking awaits nested in parameters
27705
27706 while (this.type !== types$1.parenR) {
27707 first ? first = false : this.expect(types$1.comma);
27708
27709 if (allowTrailingComma && this.afterTrailingComma(types$1.parenR, true)) {
27710 lastIsComma = true;
27711 break;
27712 } else if (this.type === types$1.ellipsis) {
27713 spreadStart = this.start;
27714 exprList.push(this.parseParenItem(this.parseRestBinding()));
27715
27716 if (this.type === types$1.comma) {
27717 this.raise(this.start, "Comma is not permitted after the rest element");
27718 }
27719
27720 break;
27721 } else {
27722 exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
27723 }
27724 }
27725
27726 var innerEndPos = this.lastTokEnd,
27727 innerEndLoc = this.lastTokEndLoc;
27728 this.expect(types$1.parenR);
27729
27730 if (canBeArrow && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {
27731 this.checkPatternErrors(refDestructuringErrors, false);
27732 this.checkYieldAwaitInDefaultParams();
27733 this.yieldPos = oldYieldPos;
27734 this.awaitPos = oldAwaitPos;
27735 return this.parseParenArrowList(startPos, startLoc, exprList, forInit);
27736 }
27737
27738 if (!exprList.length || lastIsComma) {
27739 this.unexpected(this.lastTokStart);
27740 }
27741
27742 if (spreadStart) {
27743 this.unexpected(spreadStart);
27744 }
27745
27746 this.checkExpressionErrors(refDestructuringErrors, true);
27747 this.yieldPos = oldYieldPos || this.yieldPos;
27748 this.awaitPos = oldAwaitPos || this.awaitPos;
27749
27750 if (exprList.length > 1) {
27751 val = this.startNodeAt(innerStartPos, innerStartLoc);
27752 val.expressions = exprList;
27753 this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
27754 } else {
27755 val = exprList[0];
27756 }
27757 } else {
27758 val = this.parseParenExpression();
27759 }
27760
27761 if (this.options.preserveParens) {
27762 var par = this.startNodeAt(startPos, startLoc);
27763 par.expression = val;
27764 return this.finishNode(par, "ParenthesizedExpression");
27765 } else {
27766 return val;
27767 }
27768 };
27769
27770 pp$5.parseParenItem = function (item) {
27771 return item;
27772 };
27773
27774 pp$5.parseParenArrowList = function (startPos, startLoc, exprList, forInit) {
27775 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, false, forInit);
27776 }; // New's precedence is slightly tricky. It must allow its argument to
27777 // be a `[]` or dot subscript expression, but not a call — at least,
27778 // not without wrapping it in parentheses. Thus, it uses the noCalls
27779 // argument to parseSubscripts to prevent it from consuming the
27780 // argument list.
27781
27782
27783 var empty = [];
27784
27785 pp$5.parseNew = function () {
27786 if (this.containsEsc) {
27787 this.raiseRecoverable(this.start, "Escape sequence in keyword new");
27788 }
27789
27790 var node = this.startNode();
27791 var meta = this.parseIdent(true);
27792
27793 if (this.options.ecmaVersion >= 6 && this.eat(types$1.dot)) {
27794 node.meta = meta;
27795 var containsEsc = this.containsEsc;
27796 node.property = this.parseIdent(true);
27797
27798 if (node.property.name !== "target") {
27799 this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'");
27800 }
27801
27802 if (containsEsc) {
27803 this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters");
27804 }
27805
27806 if (!this.allowNewDotTarget) {
27807 this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block");
27808 }
27809
27810 return this.finishNode(node, "MetaProperty");
27811 }
27812
27813 var startPos = this.start,
27814 startLoc = this.startLoc,
27815 isImport = this.type === types$1._import;
27816 node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true, false);
27817
27818 if (isImport && node.callee.type === "ImportExpression") {
27819 this.raise(startPos, "Cannot use new with import()");
27820 }
27821
27822 if (this.eat(types$1.parenL)) {
27823 node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false);
27824 } else {
27825 node.arguments = empty;
27826 }
27827
27828 return this.finishNode(node, "NewExpression");
27829 }; // Parse template expression.
27830
27831
27832 pp$5.parseTemplateElement = function (ref) {
27833 var isTagged = ref.isTagged;
27834 var elem = this.startNode();
27835
27836 if (this.type === types$1.invalidTemplate) {
27837 if (!isTagged) {
27838 this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
27839 }
27840
27841 elem.value = {
27842 raw: this.value,
27843 cooked: null
27844 };
27845 } else {
27846 elem.value = {
27847 raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
27848 cooked: this.value
27849 };
27850 }
27851
27852 this.next();
27853 elem.tail = this.type === types$1.backQuote;
27854 return this.finishNode(elem, "TemplateElement");
27855 };
27856
27857 pp$5.parseTemplate = function (ref) {
27858 if (ref === void 0) ref = {};
27859 var isTagged = ref.isTagged;
27860 if (isTagged === void 0) isTagged = false;
27861 var node = this.startNode();
27862 this.next();
27863 node.expressions = [];
27864 var curElt = this.parseTemplateElement({
27865 isTagged: isTagged
27866 });
27867 node.quasis = [curElt];
27868
27869 while (!curElt.tail) {
27870 if (this.type === types$1.eof) {
27871 this.raise(this.pos, "Unterminated template literal");
27872 }
27873
27874 this.expect(types$1.dollarBraceL);
27875 node.expressions.push(this.parseExpression());
27876 this.expect(types$1.braceR);
27877 node.quasis.push(curElt = this.parseTemplateElement({
27878 isTagged: isTagged
27879 }));
27880 }
27881
27882 this.next();
27883 return this.finishNode(node, "TemplateLiteral");
27884 };
27885
27886 pp$5.isAsyncProp = function (prop) {
27887 return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && (this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || this.options.ecmaVersion >= 9 && this.type === types$1.star) && !lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
27888 }; // Parse an object literal or binding pattern.
27889
27890
27891 pp$5.parseObj = function (isPattern, refDestructuringErrors) {
27892 var node = this.startNode(),
27893 first = true,
27894 propHash = {};
27895 node.properties = [];
27896 this.next();
27897
27898 while (!this.eat(types$1.braceR)) {
27899 if (!first) {
27900 this.expect(types$1.comma);
27901
27902 if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types$1.braceR)) {
27903 break;
27904 }
27905 } else {
27906 first = false;
27907 }
27908
27909 var prop = this.parseProperty(isPattern, refDestructuringErrors);
27910
27911 if (!isPattern) {
27912 this.checkPropClash(prop, propHash, refDestructuringErrors);
27913 }
27914
27915 node.properties.push(prop);
27916 }
27917
27918 return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");
27919 };
27920
27921 pp$5.parseProperty = function (isPattern, refDestructuringErrors) {
27922 var prop = this.startNode(),
27923 isGenerator,
27924 isAsync,
27925 startPos,
27926 startLoc;
27927
27928 if (this.options.ecmaVersion >= 9 && this.eat(types$1.ellipsis)) {
27929 if (isPattern) {
27930 prop.argument = this.parseIdent(false);
27931
27932 if (this.type === types$1.comma) {
27933 this.raise(this.start, "Comma is not permitted after the rest element");
27934 }
27935
27936 return this.finishNode(prop, "RestElement");
27937 } // To disallow parenthesized identifier via `this.toAssignable()`.
27938
27939
27940 if (this.type === types$1.parenL && refDestructuringErrors) {
27941 if (refDestructuringErrors.parenthesizedAssign < 0) {
27942 refDestructuringErrors.parenthesizedAssign = this.start;
27943 }
27944
27945 if (refDestructuringErrors.parenthesizedBind < 0) {
27946 refDestructuringErrors.parenthesizedBind = this.start;
27947 }
27948 } // Parse argument.
27949
27950
27951 prop.argument = this.parseMaybeAssign(false, refDestructuringErrors); // To disallow trailing comma via `this.toAssignable()`.
27952
27953 if (this.type === types$1.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
27954 refDestructuringErrors.trailingComma = this.start;
27955 } // Finish
27956
27957
27958 return this.finishNode(prop, "SpreadElement");
27959 }
27960
27961 if (this.options.ecmaVersion >= 6) {
27962 prop.method = false;
27963 prop.shorthand = false;
27964
27965 if (isPattern || refDestructuringErrors) {
27966 startPos = this.start;
27967 startLoc = this.startLoc;
27968 }
27969
27970 if (!isPattern) {
27971 isGenerator = this.eat(types$1.star);
27972 }
27973 }
27974
27975 var containsEsc = this.containsEsc;
27976 this.parsePropertyName(prop);
27977
27978 if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
27979 isAsync = true;
27980 isGenerator = this.options.ecmaVersion >= 9 && this.eat(types$1.star);
27981 this.parsePropertyName(prop, refDestructuringErrors);
27982 } else {
27983 isAsync = false;
27984 }
27985
27986 this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
27987 return this.finishNode(prop, "Property");
27988 };
27989
27990 pp$5.parsePropertyValue = function (prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
27991 if ((isGenerator || isAsync) && this.type === types$1.colon) {
27992 this.unexpected();
27993 }
27994
27995 if (this.eat(types$1.colon)) {
27996 prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
27997 prop.kind = "init";
27998 } else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) {
27999 if (isPattern) {
28000 this.unexpected();
28001 }
28002
28003 prop.kind = "init";
28004 prop.method = true;
28005 prop.value = this.parseMethod(isGenerator, isAsync);
28006 } else if (!isPattern && !containsEsc && this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq) {
28007 if (isGenerator || isAsync) {
28008 this.unexpected();
28009 }
28010
28011 prop.kind = prop.key.name;
28012 this.parsePropertyName(prop);
28013 prop.value = this.parseMethod(false);
28014 var paramCount = prop.kind === "get" ? 0 : 1;
28015
28016 if (prop.value.params.length !== paramCount) {
28017 var start = prop.value.start;
28018
28019 if (prop.kind === "get") {
28020 this.raiseRecoverable(start, "getter should have no params");
28021 } else {
28022 this.raiseRecoverable(start, "setter should have exactly one param");
28023 }
28024 } else {
28025 if (prop.kind === "set" && prop.value.params[0].type === "RestElement") {
28026 this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params");
28027 }
28028 }
28029 } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
28030 if (isGenerator || isAsync) {
28031 this.unexpected();
28032 }
28033
28034 this.checkUnreserved(prop.key);
28035
28036 if (prop.key.name === "await" && !this.awaitIdentPos) {
28037 this.awaitIdentPos = startPos;
28038 }
28039
28040 prop.kind = "init";
28041
28042 if (isPattern) {
28043 prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
28044 } else if (this.type === types$1.eq && refDestructuringErrors) {
28045 if (refDestructuringErrors.shorthandAssign < 0) {
28046 refDestructuringErrors.shorthandAssign = this.start;
28047 }
28048
28049 prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
28050 } else {
28051 prop.value = this.copyNode(prop.key);
28052 }
28053
28054 prop.shorthand = true;
28055 } else {
28056 this.unexpected();
28057 }
28058 };
28059
28060 pp$5.parsePropertyName = function (prop) {
28061 if (this.options.ecmaVersion >= 6) {
28062 if (this.eat(types$1.bracketL)) {
28063 prop.computed = true;
28064 prop.key = this.parseMaybeAssign();
28065 this.expect(types$1.bracketR);
28066 return prop.key;
28067 } else {
28068 prop.computed = false;
28069 }
28070 }
28071
28072 return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never");
28073 }; // Initialize empty function node.
28074
28075
28076 pp$5.initFunction = function (node) {
28077 node.id = null;
28078
28079 if (this.options.ecmaVersion >= 6) {
28080 node.generator = node.expression = false;
28081 }
28082
28083 if (this.options.ecmaVersion >= 8) {
28084 node.async = false;
28085 }
28086 }; // Parse object or class method.
28087
28088
28089 pp$5.parseMethod = function (isGenerator, isAsync, allowDirectSuper) {
28090 var node = this.startNode(),
28091 oldYieldPos = this.yieldPos,
28092 oldAwaitPos = this.awaitPos,
28093 oldAwaitIdentPos = this.awaitIdentPos;
28094 this.initFunction(node);
28095
28096 if (this.options.ecmaVersion >= 6) {
28097 node.generator = isGenerator;
28098 }
28099
28100 if (this.options.ecmaVersion >= 8) {
28101 node.async = !!isAsync;
28102 }
28103
28104 this.yieldPos = 0;
28105 this.awaitPos = 0;
28106 this.awaitIdentPos = 0;
28107 this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
28108 this.expect(types$1.parenL);
28109 node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
28110 this.checkYieldAwaitInDefaultParams();
28111 this.parseFunctionBody(node, false, true, false);
28112 this.yieldPos = oldYieldPos;
28113 this.awaitPos = oldAwaitPos;
28114 this.awaitIdentPos = oldAwaitIdentPos;
28115 return this.finishNode(node, "FunctionExpression");
28116 }; // Parse arrow function expression with given parameters.
28117
28118
28119 pp$5.parseArrowExpression = function (node, params, isAsync, forInit) {
28120 var oldYieldPos = this.yieldPos,
28121 oldAwaitPos = this.awaitPos,
28122 oldAwaitIdentPos = this.awaitIdentPos;
28123 this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
28124 this.initFunction(node);
28125
28126 if (this.options.ecmaVersion >= 8) {
28127 node.async = !!isAsync;
28128 }
28129
28130 this.yieldPos = 0;
28131 this.awaitPos = 0;
28132 this.awaitIdentPos = 0;
28133 node.params = this.toAssignableList(params, true);
28134 this.parseFunctionBody(node, true, false, forInit);
28135 this.yieldPos = oldYieldPos;
28136 this.awaitPos = oldAwaitPos;
28137 this.awaitIdentPos = oldAwaitIdentPos;
28138 return this.finishNode(node, "ArrowFunctionExpression");
28139 }; // Parse function body and check parameters.
28140
28141
28142 pp$5.parseFunctionBody = function (node, isArrowFunction, isMethod, forInit) {
28143 var isExpression = isArrowFunction && this.type !== types$1.braceL;
28144 var oldStrict = this.strict,
28145 useStrict = false;
28146
28147 if (isExpression) {
28148 node.body = this.parseMaybeAssign(forInit);
28149 node.expression = true;
28150 this.checkParams(node, false);
28151 } else {
28152 var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
28153
28154 if (!oldStrict || nonSimple) {
28155 useStrict = this.strictDirective(this.end); // If this is a strict mode function, verify that argument names
28156 // are not repeated, and it does not try to bind the words `eval`
28157 // or `arguments`.
28158
28159 if (useStrict && nonSimple) {
28160 this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list");
28161 }
28162 } // Start a new scope with regard to labels and the `inFunction`
28163 // flag (restore them to their old value afterwards).
28164
28165
28166 var oldLabels = this.labels;
28167 this.labels = [];
28168
28169 if (useStrict) {
28170 this.strict = true;
28171 } // Add the params to varDeclaredNames to ensure that an error is thrown
28172 // if a let/const declaration in the function clashes with one of the params.
28173
28174
28175 this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params)); // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
28176
28177 if (this.strict && node.id) {
28178 this.checkLValSimple(node.id, BIND_OUTSIDE);
28179 }
28180
28181 node.body = this.parseBlock(false, undefined, useStrict && !oldStrict);
28182 node.expression = false;
28183 this.adaptDirectivePrologue(node.body.body);
28184 this.labels = oldLabels;
28185 }
28186
28187 this.exitScope();
28188 };
28189
28190 pp$5.isSimpleParamList = function (params) {
28191 for (var i = 0, list = params; i < list.length; i += 1) {
28192 var param = list[i];
28193
28194 if (param.type !== "Identifier") {
28195 return false;
28196 }
28197 }
28198
28199 return true;
28200 }; // Checks function params for various disallowed patterns such as using "eval"
28201 // or "arguments" and duplicate parameters.
28202
28203
28204 pp$5.checkParams = function (node, allowDuplicates) {
28205 var nameHash = Object.create(null);
28206
28207 for (var i = 0, list = node.params; i < list.length; i += 1) {
28208 var param = list[i];
28209 this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash);
28210 }
28211 }; // Parses a comma-separated list of expressions, and returns them as
28212 // an array. `close` is the token type that ends the list, and
28213 // `allowEmpty` can be turned on to allow subsequent commas with
28214 // nothing in between them to be parsed as `null` (which is needed
28215 // for array literals).
28216
28217
28218 pp$5.parseExprList = function (close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
28219 var elts = [],
28220 first = true;
28221
28222 while (!this.eat(close)) {
28223 if (!first) {
28224 this.expect(types$1.comma);
28225
28226 if (allowTrailingComma && this.afterTrailingComma(close)) {
28227 break;
28228 }
28229 } else {
28230 first = false;
28231 }
28232
28233 var elt = void 0;
28234
28235 if (allowEmpty && this.type === types$1.comma) {
28236 elt = null;
28237 } else if (this.type === types$1.ellipsis) {
28238 elt = this.parseSpread(refDestructuringErrors);
28239
28240 if (refDestructuringErrors && this.type === types$1.comma && refDestructuringErrors.trailingComma < 0) {
28241 refDestructuringErrors.trailingComma = this.start;
28242 }
28243 } else {
28244 elt = this.parseMaybeAssign(false, refDestructuringErrors);
28245 }
28246
28247 elts.push(elt);
28248 }
28249
28250 return elts;
28251 };
28252
28253 pp$5.checkUnreserved = function (ref) {
28254 var start = ref.start;
28255 var end = ref.end;
28256 var name = ref.name;
28257
28258 if (this.inGenerator && name === "yield") {
28259 this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator");
28260 }
28261
28262 if (this.inAsync && name === "await") {
28263 this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function");
28264 }
28265
28266 if (this.currentThisScope().inClassFieldInit && name === "arguments") {
28267 this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer");
28268 }
28269
28270 if (this.inClassStaticBlock && (name === "arguments" || name === "await")) {
28271 this.raise(start, "Cannot use " + name + " in class static initialization block");
28272 }
28273
28274 if (this.keywords.test(name)) {
28275 this.raise(start, "Unexpected keyword '" + name + "'");
28276 }
28277
28278 if (this.options.ecmaVersion < 6 && this.input.slice(start, end).indexOf("\\") !== -1) {
28279 return;
28280 }
28281
28282 var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
28283
28284 if (re.test(name)) {
28285 if (!this.inAsync && name === "await") {
28286 this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function");
28287 }
28288
28289 this.raiseRecoverable(start, "The keyword '" + name + "' is reserved");
28290 }
28291 }; // Parse the next token as an identifier. If `liberal` is true (used
28292 // when parsing properties), it will also convert keywords into
28293 // identifiers.
28294
28295
28296 pp$5.parseIdent = function (liberal, isBinding) {
28297 var node = this.startNode();
28298
28299 if (this.type === types$1.name) {
28300 node.name = this.value;
28301 } else if (this.type.keyword) {
28302 node.name = this.type.keyword; // To fix https://github.com/acornjs/acorn/issues/575
28303 // `class` and `function` keywords push new context into this.context.
28304 // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
28305 // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
28306
28307 if ((node.name === "class" || node.name === "function") && (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
28308 this.context.pop();
28309 }
28310 } else {
28311 this.unexpected();
28312 }
28313
28314 this.next(!!liberal);
28315 this.finishNode(node, "Identifier");
28316
28317 if (!liberal) {
28318 this.checkUnreserved(node);
28319
28320 if (node.name === "await" && !this.awaitIdentPos) {
28321 this.awaitIdentPos = node.start;
28322 }
28323 }
28324
28325 return node;
28326 };
28327
28328 pp$5.parsePrivateIdent = function () {
28329 var node = this.startNode();
28330
28331 if (this.type === types$1.privateId) {
28332 node.name = this.value;
28333 } else {
28334 this.unexpected();
28335 }
28336
28337 this.next();
28338 this.finishNode(node, "PrivateIdentifier"); // For validating existence
28339
28340 if (this.privateNameStack.length === 0) {
28341 this.raise(node.start, "Private field '#" + node.name + "' must be declared in an enclosing class");
28342 } else {
28343 this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
28344 }
28345
28346 return node;
28347 }; // Parses yield expression inside generator.
28348
28349
28350 pp$5.parseYield = function (forInit) {
28351 if (!this.yieldPos) {
28352 this.yieldPos = this.start;
28353 }
28354
28355 var node = this.startNode();
28356 this.next();
28357
28358 if (this.type === types$1.semi || this.canInsertSemicolon() || this.type !== types$1.star && !this.type.startsExpr) {
28359 node.delegate = false;
28360 node.argument = null;
28361 } else {
28362 node.delegate = this.eat(types$1.star);
28363 node.argument = this.parseMaybeAssign(forInit);
28364 }
28365
28366 return this.finishNode(node, "YieldExpression");
28367 };
28368
28369 pp$5.parseAwait = function (forInit) {
28370 if (!this.awaitPos) {
28371 this.awaitPos = this.start;
28372 }
28373
28374 var node = this.startNode();
28375 this.next();
28376 node.argument = this.parseMaybeUnary(null, true, false, forInit);
28377 return this.finishNode(node, "AwaitExpression");
28378 };
28379
28380 var pp$4 = Parser.prototype; // This function is used to raise exceptions on parse errors. It
28381 // takes an offset integer (into the current `input`) to indicate
28382 // the location of the error, attaches the position to the end
28383 // of the error message, and then raises a `SyntaxError` with that
28384 // message.
28385
28386 pp$4.raise = function (pos, message) {
28387 var loc = getLineInfo(this.input, pos);
28388 message += " (" + loc.line + ":" + loc.column + ")";
28389 var err = new SyntaxError(message);
28390 err.pos = pos;
28391 err.loc = loc;
28392 err.raisedAt = this.pos;
28393 throw err;
28394 };
28395
28396 pp$4.raiseRecoverable = pp$4.raise;
28397
28398 pp$4.curPosition = function () {
28399 if (this.options.locations) {
28400 return new Position(this.curLine, this.pos - this.lineStart);
28401 }
28402 };
28403
28404 var pp$3 = Parser.prototype;
28405
28406 var Scope = function Scope(flags) {
28407 this.flags = flags; // A list of var-declared names in the current lexical scope
28408
28409 this.var = []; // A list of lexically-declared names in the current lexical scope
28410
28411 this.lexical = []; // A list of lexically-declared FunctionDeclaration names in the current lexical scope
28412
28413 this.functions = []; // A switch to disallow the identifier reference 'arguments'
28414
28415 this.inClassFieldInit = false;
28416 }; // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
28417
28418
28419 pp$3.enterScope = function (flags) {
28420 this.scopeStack.push(new Scope(flags));
28421 };
28422
28423 pp$3.exitScope = function () {
28424 this.scopeStack.pop();
28425 }; // The spec says:
28426 // > At the top level of a function, or script, function declarations are
28427 // > treated like var declarations rather than like lexical declarations.
28428
28429
28430 pp$3.treatFunctionsAsVarInScope = function (scope) {
28431 return scope.flags & SCOPE_FUNCTION || !this.inModule && scope.flags & SCOPE_TOP;
28432 };
28433
28434 pp$3.declareName = function (name, bindingType, pos) {
28435 var redeclared = false;
28436
28437 if (bindingType === BIND_LEXICAL) {
28438 var scope = this.currentScope();
28439 redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
28440 scope.lexical.push(name);
28441
28442 if (this.inModule && scope.flags & SCOPE_TOP) {
28443 delete this.undefinedExports[name];
28444 }
28445 } else if (bindingType === BIND_SIMPLE_CATCH) {
28446 var scope$1 = this.currentScope();
28447 scope$1.lexical.push(name);
28448 } else if (bindingType === BIND_FUNCTION) {
28449 var scope$2 = this.currentScope();
28450
28451 if (this.treatFunctionsAsVar) {
28452 redeclared = scope$2.lexical.indexOf(name) > -1;
28453 } else {
28454 redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1;
28455 }
28456
28457 scope$2.functions.push(name);
28458 } else {
28459 for (var i = this.scopeStack.length - 1; i >= 0; --i) {
28460 var scope$3 = this.scopeStack[i];
28461
28462 if (scope$3.lexical.indexOf(name) > -1 && !(scope$3.flags & SCOPE_SIMPLE_CATCH && scope$3.lexical[0] === name) || !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) {
28463 redeclared = true;
28464 break;
28465 }
28466
28467 scope$3.var.push(name);
28468
28469 if (this.inModule && scope$3.flags & SCOPE_TOP) {
28470 delete this.undefinedExports[name];
28471 }
28472
28473 if (scope$3.flags & SCOPE_VAR) {
28474 break;
28475 }
28476 }
28477 }
28478
28479 if (redeclared) {
28480 this.raiseRecoverable(pos, "Identifier '" + name + "' has already been declared");
28481 }
28482 };
28483
28484 pp$3.checkLocalExport = function (id) {
28485 // scope.functions must be empty as Module code is always strict.
28486 if (this.scopeStack[0].lexical.indexOf(id.name) === -1 && this.scopeStack[0].var.indexOf(id.name) === -1) {
28487 this.undefinedExports[id.name] = id;
28488 }
28489 };
28490
28491 pp$3.currentScope = function () {
28492 return this.scopeStack[this.scopeStack.length - 1];
28493 };
28494
28495 pp$3.currentVarScope = function () {
28496 for (var i = this.scopeStack.length - 1;; i--) {
28497 var scope = this.scopeStack[i];
28498
28499 if (scope.flags & SCOPE_VAR) {
28500 return scope;
28501 }
28502 }
28503 }; // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
28504
28505
28506 pp$3.currentThisScope = function () {
28507 for (var i = this.scopeStack.length - 1;; i--) {
28508 var scope = this.scopeStack[i];
28509
28510 if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) {
28511 return scope;
28512 }
28513 }
28514 };
28515
28516 var Node = function Node(parser, pos, loc) {
28517 this.type = "";
28518 this.start = pos;
28519 this.end = 0;
28520
28521 if (parser.options.locations) {
28522 this.loc = new SourceLocation(parser, loc);
28523 }
28524
28525 if (parser.options.directSourceFile) {
28526 this.sourceFile = parser.options.directSourceFile;
28527 }
28528
28529 if (parser.options.ranges) {
28530 this.range = [pos, 0];
28531 }
28532 }; // Start an AST node, attaching a start offset.
28533
28534
28535 var pp$2 = Parser.prototype;
28536
28537 pp$2.startNode = function () {
28538 return new Node(this, this.start, this.startLoc);
28539 };
28540
28541 pp$2.startNodeAt = function (pos, loc) {
28542 return new Node(this, pos, loc);
28543 }; // Finish an AST node, adding `type` and `end` properties.
28544
28545
28546 function finishNodeAt(node, type, pos, loc) {
28547 node.type = type;
28548 node.end = pos;
28549
28550 if (this.options.locations) {
28551 node.loc.end = loc;
28552 }
28553
28554 if (this.options.ranges) {
28555 node.range[1] = pos;
28556 }
28557
28558 return node;
28559 }
28560
28561 pp$2.finishNode = function (node, type) {
28562 return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc);
28563 }; // Finish node at given position
28564
28565
28566 pp$2.finishNodeAt = function (node, type, pos, loc) {
28567 return finishNodeAt.call(this, node, type, pos, loc);
28568 };
28569
28570 pp$2.copyNode = function (node) {
28571 var newNode = new Node(this, node.start, this.startLoc);
28572
28573 for (var prop in node) {
28574 newNode[prop] = node[prop];
28575 }
28576
28577 return newNode;
28578 }; // This file contains Unicode properties extracted from the ECMAScript
28579 // specification. The lists are extracted like so:
28580 // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
28581 // #table-binary-unicode-properties
28582
28583
28584 var ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS";
28585 var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic";
28586 var ecma11BinaryProperties = ecma10BinaryProperties;
28587 var ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict";
28588 var unicodeBinaryProperties = {
28589 9: ecma9BinaryProperties,
28590 10: ecma10BinaryProperties,
28591 11: ecma11BinaryProperties,
28592 12: ecma12BinaryProperties
28593 }; // #table-unicode-general-category-values
28594
28595 var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu"; // #table-unicode-script-values
28596
28597 var ecma9ScriptValues = "Adlam Adlm Ahom Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb";
28598 var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd";
28599 var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
28600 var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
28601 var unicodeScriptValues = {
28602 9: ecma9ScriptValues,
28603 10: ecma10ScriptValues,
28604 11: ecma11ScriptValues,
28605 12: ecma12ScriptValues
28606 };
28607 var data = {};
28608
28609 function buildUnicodeData(ecmaVersion) {
28610 var d = data[ecmaVersion] = {
28611 binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
28612 nonBinary: {
28613 General_Category: wordsRegexp(unicodeGeneralCategoryValues),
28614 Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
28615 }
28616 };
28617 d.nonBinary.Script_Extensions = d.nonBinary.Script;
28618 d.nonBinary.gc = d.nonBinary.General_Category;
28619 d.nonBinary.sc = d.nonBinary.Script;
28620 d.nonBinary.scx = d.nonBinary.Script_Extensions;
28621 }
28622
28623 buildUnicodeData(9);
28624 buildUnicodeData(10);
28625 buildUnicodeData(11);
28626 buildUnicodeData(12);
28627 var pp$1 = Parser.prototype;
28628
28629 var RegExpValidationState = function RegExpValidationState(parser) {
28630 this.parser = parser;
28631 this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "");
28632 this.unicodeProperties = data[parser.options.ecmaVersion >= 12 ? 12 : parser.options.ecmaVersion];
28633 this.source = "";
28634 this.flags = "";
28635 this.start = 0;
28636 this.switchU = false;
28637 this.switchN = false;
28638 this.pos = 0;
28639 this.lastIntValue = 0;
28640 this.lastStringValue = "";
28641 this.lastAssertionIsQuantifiable = false;
28642 this.numCapturingParens = 0;
28643 this.maxBackReference = 0;
28644 this.groupNames = [];
28645 this.backReferenceNames = [];
28646 };
28647
28648 RegExpValidationState.prototype.reset = function reset(start, pattern, flags) {
28649 var unicode = flags.indexOf("u") !== -1;
28650 this.start = start | 0;
28651 this.source = pattern + "";
28652 this.flags = flags;
28653 this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
28654 this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
28655 };
28656
28657 RegExpValidationState.prototype.raise = function raise(message) {
28658 this.parser.raiseRecoverable(this.start, "Invalid regular expression: /" + this.source + "/: " + message);
28659 }; // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
28660 // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
28661
28662
28663 RegExpValidationState.prototype.at = function at(i, forceU) {
28664 if (forceU === void 0) forceU = false;
28665 var s = this.source;
28666 var l = s.length;
28667
28668 if (i >= l) {
28669 return -1;
28670 }
28671
28672 var c = s.charCodeAt(i);
28673
28674 if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
28675 return c;
28676 }
28677
28678 var next = s.charCodeAt(i + 1);
28679 return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c;
28680 };
28681
28682 RegExpValidationState.prototype.nextIndex = function nextIndex(i, forceU) {
28683 if (forceU === void 0) forceU = false;
28684 var s = this.source;
28685 var l = s.length;
28686
28687 if (i >= l) {
28688 return l;
28689 }
28690
28691 var c = s.charCodeAt(i),
28692 next;
28693
28694 if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {
28695 return i + 1;
28696 }
28697
28698 return i + 2;
28699 };
28700
28701 RegExpValidationState.prototype.current = function current(forceU) {
28702 if (forceU === void 0) forceU = false;
28703 return this.at(this.pos, forceU);
28704 };
28705
28706 RegExpValidationState.prototype.lookahead = function lookahead(forceU) {
28707 if (forceU === void 0) forceU = false;
28708 return this.at(this.nextIndex(this.pos, forceU), forceU);
28709 };
28710
28711 RegExpValidationState.prototype.advance = function advance(forceU) {
28712 if (forceU === void 0) forceU = false;
28713 this.pos = this.nextIndex(this.pos, forceU);
28714 };
28715
28716 RegExpValidationState.prototype.eat = function eat(ch, forceU) {
28717 if (forceU === void 0) forceU = false;
28718
28719 if (this.current(forceU) === ch) {
28720 this.advance(forceU);
28721 return true;
28722 }
28723
28724 return false;
28725 };
28726
28727 function codePointToString$1(ch) {
28728 if (ch <= 0xFFFF) {
28729 return String.fromCharCode(ch);
28730 }
28731
28732 ch -= 0x10000;
28733 return String.fromCharCode((ch >> 10) + 0xD800, (ch & 0x03FF) + 0xDC00);
28734 }
28735 /**
28736 * Validate the flags part of a given RegExpLiteral.
28737 *
28738 * @param {RegExpValidationState} state The state to validate RegExp.
28739 * @returns {void}
28740 */
28741
28742
28743 pp$1.validateRegExpFlags = function (state) {
28744 var validFlags = state.validFlags;
28745 var flags = state.flags;
28746
28747 for (var i = 0; i < flags.length; i++) {
28748 var flag = flags.charAt(i);
28749
28750 if (validFlags.indexOf(flag) === -1) {
28751 this.raise(state.start, "Invalid regular expression flag");
28752 }
28753
28754 if (flags.indexOf(flag, i + 1) > -1) {
28755 this.raise(state.start, "Duplicate regular expression flag");
28756 }
28757 }
28758 };
28759 /**
28760 * Validate the pattern part of a given RegExpLiteral.
28761 *
28762 * @param {RegExpValidationState} state The state to validate RegExp.
28763 * @returns {void}
28764 */
28765
28766
28767 pp$1.validateRegExpPattern = function (state) {
28768 this.regexp_pattern(state); // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
28769 // parsing contains a |GroupName|, reparse with the goal symbol
28770 // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
28771 // exception if _P_ did not conform to the grammar, if any elements of _P_
28772 // were not matched by the parse, or if any Early Error conditions exist.
28773
28774 if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
28775 state.switchN = true;
28776 this.regexp_pattern(state);
28777 }
28778 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
28779
28780
28781 pp$1.regexp_pattern = function (state) {
28782 state.pos = 0;
28783 state.lastIntValue = 0;
28784 state.lastStringValue = "";
28785 state.lastAssertionIsQuantifiable = false;
28786 state.numCapturingParens = 0;
28787 state.maxBackReference = 0;
28788 state.groupNames.length = 0;
28789 state.backReferenceNames.length = 0;
28790 this.regexp_disjunction(state);
28791
28792 if (state.pos !== state.source.length) {
28793 // Make the same messages as V8.
28794 if (state.eat(0x29
28795 /* ) */
28796 )) {
28797 state.raise("Unmatched ')'");
28798 }
28799
28800 if (state.eat(0x5D
28801 /* ] */
28802 ) || state.eat(0x7D
28803 /* } */
28804 )) {
28805 state.raise("Lone quantifier brackets");
28806 }
28807 }
28808
28809 if (state.maxBackReference > state.numCapturingParens) {
28810 state.raise("Invalid escape");
28811 }
28812
28813 for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
28814 var name = list[i];
28815
28816 if (state.groupNames.indexOf(name) === -1) {
28817 state.raise("Invalid named capture referenced");
28818 }
28819 }
28820 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
28821
28822
28823 pp$1.regexp_disjunction = function (state) {
28824 this.regexp_alternative(state);
28825
28826 while (state.eat(0x7C
28827 /* | */
28828 )) {
28829 this.regexp_alternative(state);
28830 } // Make the same message as V8.
28831
28832
28833 if (this.regexp_eatQuantifier(state, true)) {
28834 state.raise("Nothing to repeat");
28835 }
28836
28837 if (state.eat(0x7B
28838 /* { */
28839 )) {
28840 state.raise("Lone quantifier brackets");
28841 }
28842 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
28843
28844
28845 pp$1.regexp_alternative = function (state) {
28846 while (state.pos < state.source.length && this.regexp_eatTerm(state)) {}
28847 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
28848
28849
28850 pp$1.regexp_eatTerm = function (state) {
28851 if (this.regexp_eatAssertion(state)) {
28852 // Handle `QuantifiableAssertion Quantifier` alternative.
28853 // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
28854 // is a QuantifiableAssertion.
28855 if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
28856 // Make the same message as V8.
28857 if (state.switchU) {
28858 state.raise("Invalid quantifier");
28859 }
28860 }
28861
28862 return true;
28863 }
28864
28865 if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
28866 this.regexp_eatQuantifier(state);
28867 return true;
28868 }
28869
28870 return false;
28871 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
28872
28873
28874 pp$1.regexp_eatAssertion = function (state) {
28875 var start = state.pos;
28876 state.lastAssertionIsQuantifiable = false; // ^, $
28877
28878 if (state.eat(0x5E
28879 /* ^ */
28880 ) || state.eat(0x24
28881 /* $ */
28882 )) {
28883 return true;
28884 } // \b \B
28885
28886
28887 if (state.eat(0x5C
28888 /* \ */
28889 )) {
28890 if (state.eat(0x42
28891 /* B */
28892 ) || state.eat(0x62
28893 /* b */
28894 )) {
28895 return true;
28896 }
28897
28898 state.pos = start;
28899 } // Lookahead / Lookbehind
28900
28901
28902 if (state.eat(0x28
28903 /* ( */
28904 ) && state.eat(0x3F
28905 /* ? */
28906 )) {
28907 var lookbehind = false;
28908
28909 if (this.options.ecmaVersion >= 9) {
28910 lookbehind = state.eat(0x3C
28911 /* < */
28912 );
28913 }
28914
28915 if (state.eat(0x3D
28916 /* = */
28917 ) || state.eat(0x21
28918 /* ! */
28919 )) {
28920 this.regexp_disjunction(state);
28921
28922 if (!state.eat(0x29
28923 /* ) */
28924 )) {
28925 state.raise("Unterminated group");
28926 }
28927
28928 state.lastAssertionIsQuantifiable = !lookbehind;
28929 return true;
28930 }
28931 }
28932
28933 state.pos = start;
28934 return false;
28935 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
28936
28937
28938 pp$1.regexp_eatQuantifier = function (state, noError) {
28939 if (noError === void 0) noError = false;
28940
28941 if (this.regexp_eatQuantifierPrefix(state, noError)) {
28942 state.eat(0x3F
28943 /* ? */
28944 );
28945 return true;
28946 }
28947
28948 return false;
28949 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
28950
28951
28952 pp$1.regexp_eatQuantifierPrefix = function (state, noError) {
28953 return state.eat(0x2A
28954 /* * */
28955 ) || state.eat(0x2B
28956 /* + */
28957 ) || state.eat(0x3F
28958 /* ? */
28959 ) || this.regexp_eatBracedQuantifier(state, noError);
28960 };
28961
28962 pp$1.regexp_eatBracedQuantifier = function (state, noError) {
28963 var start = state.pos;
28964
28965 if (state.eat(0x7B
28966 /* { */
28967 )) {
28968 var min = 0,
28969 max = -1;
28970
28971 if (this.regexp_eatDecimalDigits(state)) {
28972 min = state.lastIntValue;
28973
28974 if (state.eat(0x2C
28975 /* , */
28976 ) && this.regexp_eatDecimalDigits(state)) {
28977 max = state.lastIntValue;
28978 }
28979
28980 if (state.eat(0x7D
28981 /* } */
28982 )) {
28983 // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term
28984 if (max !== -1 && max < min && !noError) {
28985 state.raise("numbers out of order in {} quantifier");
28986 }
28987
28988 return true;
28989 }
28990 }
28991
28992 if (state.switchU && !noError) {
28993 state.raise("Incomplete quantifier");
28994 }
28995
28996 state.pos = start;
28997 }
28998
28999 return false;
29000 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
29001
29002
29003 pp$1.regexp_eatAtom = function (state) {
29004 return this.regexp_eatPatternCharacters(state) || state.eat(0x2E
29005 /* . */
29006 ) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state);
29007 };
29008
29009 pp$1.regexp_eatReverseSolidusAtomEscape = function (state) {
29010 var start = state.pos;
29011
29012 if (state.eat(0x5C
29013 /* \ */
29014 )) {
29015 if (this.regexp_eatAtomEscape(state)) {
29016 return true;
29017 }
29018
29019 state.pos = start;
29020 }
29021
29022 return false;
29023 };
29024
29025 pp$1.regexp_eatUncapturingGroup = function (state) {
29026 var start = state.pos;
29027
29028 if (state.eat(0x28
29029 /* ( */
29030 )) {
29031 if (state.eat(0x3F
29032 /* ? */
29033 ) && state.eat(0x3A
29034 /* : */
29035 )) {
29036 this.regexp_disjunction(state);
29037
29038 if (state.eat(0x29
29039 /* ) */
29040 )) {
29041 return true;
29042 }
29043
29044 state.raise("Unterminated group");
29045 }
29046
29047 state.pos = start;
29048 }
29049
29050 return false;
29051 };
29052
29053 pp$1.regexp_eatCapturingGroup = function (state) {
29054 if (state.eat(0x28
29055 /* ( */
29056 )) {
29057 if (this.options.ecmaVersion >= 9) {
29058 this.regexp_groupSpecifier(state);
29059 } else if (state.current() === 0x3F
29060 /* ? */
29061 ) {
29062 state.raise("Invalid group");
29063 }
29064
29065 this.regexp_disjunction(state);
29066
29067 if (state.eat(0x29
29068 /* ) */
29069 )) {
29070 state.numCapturingParens += 1;
29071 return true;
29072 }
29073
29074 state.raise("Unterminated group");
29075 }
29076
29077 return false;
29078 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
29079
29080
29081 pp$1.regexp_eatExtendedAtom = function (state) {
29082 return state.eat(0x2E
29083 /* . */
29084 ) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state) || this.regexp_eatInvalidBracedQuantifier(state) || this.regexp_eatExtendedPatternCharacter(state);
29085 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
29086
29087
29088 pp$1.regexp_eatInvalidBracedQuantifier = function (state) {
29089 if (this.regexp_eatBracedQuantifier(state, true)) {
29090 state.raise("Nothing to repeat");
29091 }
29092
29093 return false;
29094 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
29095
29096
29097 pp$1.regexp_eatSyntaxCharacter = function (state) {
29098 var ch = state.current();
29099
29100 if (isSyntaxCharacter(ch)) {
29101 state.lastIntValue = ch;
29102 state.advance();
29103 return true;
29104 }
29105
29106 return false;
29107 };
29108
29109 function isSyntaxCharacter(ch) {
29110 return ch === 0x24
29111 /* $ */
29112 || ch >= 0x28
29113 /* ( */
29114 && ch <= 0x2B
29115 /* + */
29116 || ch === 0x2E
29117 /* . */
29118 || ch === 0x3F
29119 /* ? */
29120 || ch >= 0x5B
29121 /* [ */
29122 && ch <= 0x5E
29123 /* ^ */
29124 || ch >= 0x7B
29125 /* { */
29126 && ch <= 0x7D
29127 /* } */
29128 ;
29129 } // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
29130 // But eat eager.
29131
29132
29133 pp$1.regexp_eatPatternCharacters = function (state) {
29134 var start = state.pos;
29135 var ch = 0;
29136
29137 while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
29138 state.advance();
29139 }
29140
29141 return state.pos !== start;
29142 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
29143
29144
29145 pp$1.regexp_eatExtendedPatternCharacter = function (state) {
29146 var ch = state.current();
29147
29148 if (ch !== -1 && ch !== 0x24
29149 /* $ */
29150 && !(ch >= 0x28
29151 /* ( */
29152 && ch <= 0x2B
29153 /* + */
29154 ) && ch !== 0x2E
29155 /* . */
29156 && ch !== 0x3F
29157 /* ? */
29158 && ch !== 0x5B
29159 /* [ */
29160 && ch !== 0x5E
29161 /* ^ */
29162 && ch !== 0x7C
29163 /* | */
29164 ) {
29165 state.advance();
29166 return true;
29167 }
29168
29169 return false;
29170 }; // GroupSpecifier ::
29171 // [empty]
29172 // `?` GroupName
29173
29174
29175 pp$1.regexp_groupSpecifier = function (state) {
29176 if (state.eat(0x3F
29177 /* ? */
29178 )) {
29179 if (this.regexp_eatGroupName(state)) {
29180 if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
29181 state.raise("Duplicate capture group name");
29182 }
29183
29184 state.groupNames.push(state.lastStringValue);
29185 return;
29186 }
29187
29188 state.raise("Invalid group");
29189 }
29190 }; // GroupName ::
29191 // `<` RegExpIdentifierName `>`
29192 // Note: this updates `state.lastStringValue` property with the eaten name.
29193
29194
29195 pp$1.regexp_eatGroupName = function (state) {
29196 state.lastStringValue = "";
29197
29198 if (state.eat(0x3C
29199 /* < */
29200 )) {
29201 if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E
29202 /* > */
29203 )) {
29204 return true;
29205 }
29206
29207 state.raise("Invalid capture group name");
29208 }
29209
29210 return false;
29211 }; // RegExpIdentifierName ::
29212 // RegExpIdentifierStart
29213 // RegExpIdentifierName RegExpIdentifierPart
29214 // Note: this updates `state.lastStringValue` property with the eaten name.
29215
29216
29217 pp$1.regexp_eatRegExpIdentifierName = function (state) {
29218 state.lastStringValue = "";
29219
29220 if (this.regexp_eatRegExpIdentifierStart(state)) {
29221 state.lastStringValue += codePointToString$1(state.lastIntValue);
29222
29223 while (this.regexp_eatRegExpIdentifierPart(state)) {
29224 state.lastStringValue += codePointToString$1(state.lastIntValue);
29225 }
29226
29227 return true;
29228 }
29229
29230 return false;
29231 }; // RegExpIdentifierStart ::
29232 // UnicodeIDStart
29233 // `$`
29234 // `_`
29235 // `\` RegExpUnicodeEscapeSequence[+U]
29236
29237
29238 pp$1.regexp_eatRegExpIdentifierStart = function (state) {
29239 var start = state.pos;
29240 var forceU = this.options.ecmaVersion >= 11;
29241 var ch = state.current(forceU);
29242 state.advance(forceU);
29243
29244 if (ch === 0x5C
29245 /* \ */
29246 && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
29247 ch = state.lastIntValue;
29248 }
29249
29250 if (isRegExpIdentifierStart(ch)) {
29251 state.lastIntValue = ch;
29252 return true;
29253 }
29254
29255 state.pos = start;
29256 return false;
29257 };
29258
29259 function isRegExpIdentifierStart(ch) {
29260 return isIdentifierStart(ch, true) || ch === 0x24
29261 /* $ */
29262 || ch === 0x5F;
29263 /* _ */
29264 } // RegExpIdentifierPart ::
29265 // UnicodeIDContinue
29266 // `$`
29267 // `_`
29268 // `\` RegExpUnicodeEscapeSequence[+U]
29269 // <ZWNJ>
29270 // <ZWJ>
29271
29272
29273 pp$1.regexp_eatRegExpIdentifierPart = function (state) {
29274 var start = state.pos;
29275 var forceU = this.options.ecmaVersion >= 11;
29276 var ch = state.current(forceU);
29277 state.advance(forceU);
29278
29279 if (ch === 0x5C
29280 /* \ */
29281 && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
29282 ch = state.lastIntValue;
29283 }
29284
29285 if (isRegExpIdentifierPart(ch)) {
29286 state.lastIntValue = ch;
29287 return true;
29288 }
29289
29290 state.pos = start;
29291 return false;
29292 };
29293
29294 function isRegExpIdentifierPart(ch) {
29295 return isIdentifierChar(ch, true) || ch === 0x24
29296 /* $ */
29297 || ch === 0x5F
29298 /* _ */
29299 || ch === 0x200C
29300 /* <ZWNJ> */
29301 || ch === 0x200D;
29302 /* <ZWJ> */
29303 } // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
29304
29305
29306 pp$1.regexp_eatAtomEscape = function (state) {
29307 if (this.regexp_eatBackReference(state) || this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state) || state.switchN && this.regexp_eatKGroupName(state)) {
29308 return true;
29309 }
29310
29311 if (state.switchU) {
29312 // Make the same message as V8.
29313 if (state.current() === 0x63
29314 /* c */
29315 ) {
29316 state.raise("Invalid unicode escape");
29317 }
29318
29319 state.raise("Invalid escape");
29320 }
29321
29322 return false;
29323 };
29324
29325 pp$1.regexp_eatBackReference = function (state) {
29326 var start = state.pos;
29327
29328 if (this.regexp_eatDecimalEscape(state)) {
29329 var n = state.lastIntValue;
29330
29331 if (state.switchU) {
29332 // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape
29333 if (n > state.maxBackReference) {
29334 state.maxBackReference = n;
29335 }
29336
29337 return true;
29338 }
29339
29340 if (n <= state.numCapturingParens) {
29341 return true;
29342 }
29343
29344 state.pos = start;
29345 }
29346
29347 return false;
29348 };
29349
29350 pp$1.regexp_eatKGroupName = function (state) {
29351 if (state.eat(0x6B
29352 /* k */
29353 )) {
29354 if (this.regexp_eatGroupName(state)) {
29355 state.backReferenceNames.push(state.lastStringValue);
29356 return true;
29357 }
29358
29359 state.raise("Invalid named reference");
29360 }
29361
29362 return false;
29363 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
29364
29365
29366 pp$1.regexp_eatCharacterEscape = function (state) {
29367 return this.regexp_eatControlEscape(state) || this.regexp_eatCControlLetter(state) || this.regexp_eatZero(state) || this.regexp_eatHexEscapeSequence(state) || this.regexp_eatRegExpUnicodeEscapeSequence(state, false) || !state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state) || this.regexp_eatIdentityEscape(state);
29368 };
29369
29370 pp$1.regexp_eatCControlLetter = function (state) {
29371 var start = state.pos;
29372
29373 if (state.eat(0x63
29374 /* c */
29375 )) {
29376 if (this.regexp_eatControlLetter(state)) {
29377 return true;
29378 }
29379
29380 state.pos = start;
29381 }
29382
29383 return false;
29384 };
29385
29386 pp$1.regexp_eatZero = function (state) {
29387 if (state.current() === 0x30
29388 /* 0 */
29389 && !isDecimalDigit(state.lookahead())) {
29390 state.lastIntValue = 0;
29391 state.advance();
29392 return true;
29393 }
29394
29395 return false;
29396 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
29397
29398
29399 pp$1.regexp_eatControlEscape = function (state) {
29400 var ch = state.current();
29401
29402 if (ch === 0x74
29403 /* t */
29404 ) {
29405 state.lastIntValue = 0x09;
29406 /* \t */
29407
29408 state.advance();
29409 return true;
29410 }
29411
29412 if (ch === 0x6E
29413 /* n */
29414 ) {
29415 state.lastIntValue = 0x0A;
29416 /* \n */
29417
29418 state.advance();
29419 return true;
29420 }
29421
29422 if (ch === 0x76
29423 /* v */
29424 ) {
29425 state.lastIntValue = 0x0B;
29426 /* \v */
29427
29428 state.advance();
29429 return true;
29430 }
29431
29432 if (ch === 0x66
29433 /* f */
29434 ) {
29435 state.lastIntValue = 0x0C;
29436 /* \f */
29437
29438 state.advance();
29439 return true;
29440 }
29441
29442 if (ch === 0x72
29443 /* r */
29444 ) {
29445 state.lastIntValue = 0x0D;
29446 /* \r */
29447
29448 state.advance();
29449 return true;
29450 }
29451
29452 return false;
29453 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
29454
29455
29456 pp$1.regexp_eatControlLetter = function (state) {
29457 var ch = state.current();
29458
29459 if (isControlLetter(ch)) {
29460 state.lastIntValue = ch % 0x20;
29461 state.advance();
29462 return true;
29463 }
29464
29465 return false;
29466 };
29467
29468 function isControlLetter(ch) {
29469 return ch >= 0x41
29470 /* A */
29471 && ch <= 0x5A
29472 /* Z */
29473 || ch >= 0x61
29474 /* a */
29475 && ch <= 0x7A
29476 /* z */
29477 ;
29478 } // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
29479
29480
29481 pp$1.regexp_eatRegExpUnicodeEscapeSequence = function (state, forceU) {
29482 if (forceU === void 0) forceU = false;
29483 var start = state.pos;
29484 var switchU = forceU || state.switchU;
29485
29486 if (state.eat(0x75
29487 /* u */
29488 )) {
29489 if (this.regexp_eatFixedHexDigits(state, 4)) {
29490 var lead = state.lastIntValue;
29491
29492 if (switchU && lead >= 0xD800 && lead <= 0xDBFF) {
29493 var leadSurrogateEnd = state.pos;
29494
29495 if (state.eat(0x5C
29496 /* \ */
29497 ) && state.eat(0x75
29498 /* u */
29499 ) && this.regexp_eatFixedHexDigits(state, 4)) {
29500 var trail = state.lastIntValue;
29501
29502 if (trail >= 0xDC00 && trail <= 0xDFFF) {
29503 state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
29504 return true;
29505 }
29506 }
29507
29508 state.pos = leadSurrogateEnd;
29509 state.lastIntValue = lead;
29510 }
29511
29512 return true;
29513 }
29514
29515 if (switchU && state.eat(0x7B
29516 /* { */
29517 ) && this.regexp_eatHexDigits(state) && state.eat(0x7D
29518 /* } */
29519 ) && isValidUnicode(state.lastIntValue)) {
29520 return true;
29521 }
29522
29523 if (switchU) {
29524 state.raise("Invalid unicode escape");
29525 }
29526
29527 state.pos = start;
29528 }
29529
29530 return false;
29531 };
29532
29533 function isValidUnicode(ch) {
29534 return ch >= 0 && ch <= 0x10FFFF;
29535 } // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
29536
29537
29538 pp$1.regexp_eatIdentityEscape = function (state) {
29539 if (state.switchU) {
29540 if (this.regexp_eatSyntaxCharacter(state)) {
29541 return true;
29542 }
29543
29544 if (state.eat(0x2F
29545 /* / */
29546 )) {
29547 state.lastIntValue = 0x2F;
29548 /* / */
29549
29550 return true;
29551 }
29552
29553 return false;
29554 }
29555
29556 var ch = state.current();
29557
29558 if (ch !== 0x63
29559 /* c */
29560 && (!state.switchN || ch !== 0x6B
29561 /* k */
29562 )) {
29563 state.lastIntValue = ch;
29564 state.advance();
29565 return true;
29566 }
29567
29568 return false;
29569 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
29570
29571
29572 pp$1.regexp_eatDecimalEscape = function (state) {
29573 state.lastIntValue = 0;
29574 var ch = state.current();
29575
29576 if (ch >= 0x31
29577 /* 1 */
29578 && ch <= 0x39
29579 /* 9 */
29580 ) {
29581 do {
29582 state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30
29583 /* 0 */
29584 );
29585 state.advance();
29586 } while ((ch = state.current()) >= 0x30
29587 /* 0 */
29588 && ch <= 0x39
29589 /* 9 */
29590 );
29591
29592 return true;
29593 }
29594
29595 return false;
29596 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
29597
29598
29599 pp$1.regexp_eatCharacterClassEscape = function (state) {
29600 var ch = state.current();
29601
29602 if (isCharacterClassEscape(ch)) {
29603 state.lastIntValue = -1;
29604 state.advance();
29605 return true;
29606 }
29607
29608 if (state.switchU && this.options.ecmaVersion >= 9 && (ch === 0x50
29609 /* P */
29610 || ch === 0x70
29611 /* p */
29612 )) {
29613 state.lastIntValue = -1;
29614 state.advance();
29615
29616 if (state.eat(0x7B
29617 /* { */
29618 ) && this.regexp_eatUnicodePropertyValueExpression(state) && state.eat(0x7D
29619 /* } */
29620 )) {
29621 return true;
29622 }
29623
29624 state.raise("Invalid property name");
29625 }
29626
29627 return false;
29628 };
29629
29630 function isCharacterClassEscape(ch) {
29631 return ch === 0x64
29632 /* d */
29633 || ch === 0x44
29634 /* D */
29635 || ch === 0x73
29636 /* s */
29637 || ch === 0x53
29638 /* S */
29639 || ch === 0x77
29640 /* w */
29641 || ch === 0x57
29642 /* W */
29643 ;
29644 } // UnicodePropertyValueExpression ::
29645 // UnicodePropertyName `=` UnicodePropertyValue
29646 // LoneUnicodePropertyNameOrValue
29647
29648
29649 pp$1.regexp_eatUnicodePropertyValueExpression = function (state) {
29650 var start = state.pos; // UnicodePropertyName `=` UnicodePropertyValue
29651
29652 if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D
29653 /* = */
29654 )) {
29655 var name = state.lastStringValue;
29656
29657 if (this.regexp_eatUnicodePropertyValue(state)) {
29658 var value = state.lastStringValue;
29659 this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
29660 return true;
29661 }
29662 }
29663
29664 state.pos = start; // LoneUnicodePropertyNameOrValue
29665
29666 if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
29667 var nameOrValue = state.lastStringValue;
29668 this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
29669 return true;
29670 }
29671
29672 return false;
29673 };
29674
29675 pp$1.regexp_validateUnicodePropertyNameAndValue = function (state, name, value) {
29676 if (!has(state.unicodeProperties.nonBinary, name)) {
29677 state.raise("Invalid property name");
29678 }
29679
29680 if (!state.unicodeProperties.nonBinary[name].test(value)) {
29681 state.raise("Invalid property value");
29682 }
29683 };
29684
29685 pp$1.regexp_validateUnicodePropertyNameOrValue = function (state, nameOrValue) {
29686 if (!state.unicodeProperties.binary.test(nameOrValue)) {
29687 state.raise("Invalid property name");
29688 }
29689 }; // UnicodePropertyName ::
29690 // UnicodePropertyNameCharacters
29691
29692
29693 pp$1.regexp_eatUnicodePropertyName = function (state) {
29694 var ch = 0;
29695 state.lastStringValue = "";
29696
29697 while (isUnicodePropertyNameCharacter(ch = state.current())) {
29698 state.lastStringValue += codePointToString$1(ch);
29699 state.advance();
29700 }
29701
29702 return state.lastStringValue !== "";
29703 };
29704
29705 function isUnicodePropertyNameCharacter(ch) {
29706 return isControlLetter(ch) || ch === 0x5F;
29707 /* _ */
29708 } // UnicodePropertyValue ::
29709 // UnicodePropertyValueCharacters
29710
29711
29712 pp$1.regexp_eatUnicodePropertyValue = function (state) {
29713 var ch = 0;
29714 state.lastStringValue = "";
29715
29716 while (isUnicodePropertyValueCharacter(ch = state.current())) {
29717 state.lastStringValue += codePointToString$1(ch);
29718 state.advance();
29719 }
29720
29721 return state.lastStringValue !== "";
29722 };
29723
29724 function isUnicodePropertyValueCharacter(ch) {
29725 return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch);
29726 } // LoneUnicodePropertyNameOrValue ::
29727 // UnicodePropertyValueCharacters
29728
29729
29730 pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function (state) {
29731 return this.regexp_eatUnicodePropertyValue(state);
29732 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
29733
29734
29735 pp$1.regexp_eatCharacterClass = function (state) {
29736 if (state.eat(0x5B
29737 /* [ */
29738 )) {
29739 state.eat(0x5E
29740 /* ^ */
29741 );
29742 this.regexp_classRanges(state);
29743
29744 if (state.eat(0x5D
29745 /* ] */
29746 )) {
29747 return true;
29748 } // Unreachable since it threw "unterminated regular expression" error before.
29749
29750
29751 state.raise("Unterminated character class");
29752 }
29753
29754 return false;
29755 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
29756 // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
29757 // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
29758
29759
29760 pp$1.regexp_classRanges = function (state) {
29761 while (this.regexp_eatClassAtom(state)) {
29762 var left = state.lastIntValue;
29763
29764 if (state.eat(0x2D
29765 /* - */
29766 ) && this.regexp_eatClassAtom(state)) {
29767 var right = state.lastIntValue;
29768
29769 if (state.switchU && (left === -1 || right === -1)) {
29770 state.raise("Invalid character class");
29771 }
29772
29773 if (left !== -1 && right !== -1 && left > right) {
29774 state.raise("Range out of order in character class");
29775 }
29776 }
29777 }
29778 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
29779 // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
29780
29781
29782 pp$1.regexp_eatClassAtom = function (state) {
29783 var start = state.pos;
29784
29785 if (state.eat(0x5C
29786 /* \ */
29787 )) {
29788 if (this.regexp_eatClassEscape(state)) {
29789 return true;
29790 }
29791
29792 if (state.switchU) {
29793 // Make the same message as V8.
29794 var ch$1 = state.current();
29795
29796 if (ch$1 === 0x63
29797 /* c */
29798 || isOctalDigit(ch$1)) {
29799 state.raise("Invalid class escape");
29800 }
29801
29802 state.raise("Invalid escape");
29803 }
29804
29805 state.pos = start;
29806 }
29807
29808 var ch = state.current();
29809
29810 if (ch !== 0x5D
29811 /* ] */
29812 ) {
29813 state.lastIntValue = ch;
29814 state.advance();
29815 return true;
29816 }
29817
29818 return false;
29819 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
29820
29821
29822 pp$1.regexp_eatClassEscape = function (state) {
29823 var start = state.pos;
29824
29825 if (state.eat(0x62
29826 /* b */
29827 )) {
29828 state.lastIntValue = 0x08;
29829 /* <BS> */
29830
29831 return true;
29832 }
29833
29834 if (state.switchU && state.eat(0x2D
29835 /* - */
29836 )) {
29837 state.lastIntValue = 0x2D;
29838 /* - */
29839
29840 return true;
29841 }
29842
29843 if (!state.switchU && state.eat(0x63
29844 /* c */
29845 )) {
29846 if (this.regexp_eatClassControlLetter(state)) {
29847 return true;
29848 }
29849
29850 state.pos = start;
29851 }
29852
29853 return this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state);
29854 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
29855
29856
29857 pp$1.regexp_eatClassControlLetter = function (state) {
29858 var ch = state.current();
29859
29860 if (isDecimalDigit(ch) || ch === 0x5F
29861 /* _ */
29862 ) {
29863 state.lastIntValue = ch % 0x20;
29864 state.advance();
29865 return true;
29866 }
29867
29868 return false;
29869 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
29870
29871
29872 pp$1.regexp_eatHexEscapeSequence = function (state) {
29873 var start = state.pos;
29874
29875 if (state.eat(0x78
29876 /* x */
29877 )) {
29878 if (this.regexp_eatFixedHexDigits(state, 2)) {
29879 return true;
29880 }
29881
29882 if (state.switchU) {
29883 state.raise("Invalid escape");
29884 }
29885
29886 state.pos = start;
29887 }
29888
29889 return false;
29890 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
29891
29892
29893 pp$1.regexp_eatDecimalDigits = function (state) {
29894 var start = state.pos;
29895 var ch = 0;
29896 state.lastIntValue = 0;
29897
29898 while (isDecimalDigit(ch = state.current())) {
29899 state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30
29900 /* 0 */
29901 );
29902 state.advance();
29903 }
29904
29905 return state.pos !== start;
29906 };
29907
29908 function isDecimalDigit(ch) {
29909 return ch >= 0x30
29910 /* 0 */
29911 && ch <= 0x39;
29912 /* 9 */
29913 } // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
29914
29915
29916 pp$1.regexp_eatHexDigits = function (state) {
29917 var start = state.pos;
29918 var ch = 0;
29919 state.lastIntValue = 0;
29920
29921 while (isHexDigit(ch = state.current())) {
29922 state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
29923 state.advance();
29924 }
29925
29926 return state.pos !== start;
29927 };
29928
29929 function isHexDigit(ch) {
29930 return ch >= 0x30
29931 /* 0 */
29932 && ch <= 0x39
29933 /* 9 */
29934 || ch >= 0x41
29935 /* A */
29936 && ch <= 0x46
29937 /* F */
29938 || ch >= 0x61
29939 /* a */
29940 && ch <= 0x66
29941 /* f */
29942 ;
29943 }
29944
29945 function hexToInt(ch) {
29946 if (ch >= 0x41
29947 /* A */
29948 && ch <= 0x46
29949 /* F */
29950 ) {
29951 return 10 + (ch - 0x41
29952 /* A */
29953 );
29954 }
29955
29956 if (ch >= 0x61
29957 /* a */
29958 && ch <= 0x66
29959 /* f */
29960 ) {
29961 return 10 + (ch - 0x61
29962 /* a */
29963 );
29964 }
29965
29966 return ch - 0x30;
29967 /* 0 */
29968 } // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
29969 // Allows only 0-377(octal) i.e. 0-255(decimal).
29970
29971
29972 pp$1.regexp_eatLegacyOctalEscapeSequence = function (state) {
29973 if (this.regexp_eatOctalDigit(state)) {
29974 var n1 = state.lastIntValue;
29975
29976 if (this.regexp_eatOctalDigit(state)) {
29977 var n2 = state.lastIntValue;
29978
29979 if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
29980 state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
29981 } else {
29982 state.lastIntValue = n1 * 8 + n2;
29983 }
29984 } else {
29985 state.lastIntValue = n1;
29986 }
29987
29988 return true;
29989 }
29990
29991 return false;
29992 }; // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
29993
29994
29995 pp$1.regexp_eatOctalDigit = function (state) {
29996 var ch = state.current();
29997
29998 if (isOctalDigit(ch)) {
29999 state.lastIntValue = ch - 0x30;
30000 /* 0 */
30001
30002 state.advance();
30003 return true;
30004 }
30005
30006 state.lastIntValue = 0;
30007 return false;
30008 };
30009
30010 function isOctalDigit(ch) {
30011 return ch >= 0x30
30012 /* 0 */
30013 && ch <= 0x37;
30014 /* 7 */
30015 } // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
30016 // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
30017 // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
30018
30019
30020 pp$1.regexp_eatFixedHexDigits = function (state, length) {
30021 var start = state.pos;
30022 state.lastIntValue = 0;
30023
30024 for (var i = 0; i < length; ++i) {
30025 var ch = state.current();
30026
30027 if (!isHexDigit(ch)) {
30028 state.pos = start;
30029 return false;
30030 }
30031
30032 state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
30033 state.advance();
30034 }
30035
30036 return true;
30037 }; // Object type used to represent tokens. Note that normally, tokens
30038 // simply exist as properties on the parser object. This is only
30039 // used for the onToken callback and the external tokenizer.
30040
30041
30042 var Token = function Token(p) {
30043 this.type = p.type;
30044 this.value = p.value;
30045 this.start = p.start;
30046 this.end = p.end;
30047
30048 if (p.options.locations) {
30049 this.loc = new SourceLocation(p, p.startLoc, p.endLoc);
30050 }
30051
30052 if (p.options.ranges) {
30053 this.range = [p.start, p.end];
30054 }
30055 }; // ## Tokenizer
30056
30057
30058 var pp = Parser.prototype; // Move to the next token
30059
30060 pp.next = function (ignoreEscapeSequenceInKeyword) {
30061 if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc) {
30062 this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword);
30063 }
30064
30065 if (this.options.onToken) {
30066 this.options.onToken(new Token(this));
30067 }
30068
30069 this.lastTokEnd = this.end;
30070 this.lastTokStart = this.start;
30071 this.lastTokEndLoc = this.endLoc;
30072 this.lastTokStartLoc = this.startLoc;
30073 this.nextToken();
30074 };
30075
30076 pp.getToken = function () {
30077 this.next();
30078 return new Token(this);
30079 }; // If we're in an ES6 environment, make parsers iterable
30080
30081
30082 if (typeof Symbol !== "undefined") {
30083 pp[Symbol.iterator] = function () {
30084 var this$1$1 = this;
30085 return {
30086 next: function () {
30087 var token = this$1$1.getToken();
30088 return {
30089 done: token.type === types$1.eof,
30090 value: token
30091 };
30092 }
30093 };
30094 };
30095 } // Toggle strict mode. Re-reads the next number or string to please
30096 // pedantic tests (`"use strict"; 010;` should fail).
30097 // Read a single token, updating the parser object's token-related
30098 // properties.
30099
30100
30101 pp.nextToken = function () {
30102 var curContext = this.curContext();
30103
30104 if (!curContext || !curContext.preserveSpace) {
30105 this.skipSpace();
30106 }
30107
30108 this.start = this.pos;
30109
30110 if (this.options.locations) {
30111 this.startLoc = this.curPosition();
30112 }
30113
30114 if (this.pos >= this.input.length) {
30115 return this.finishToken(types$1.eof);
30116 }
30117
30118 if (curContext.override) {
30119 return curContext.override(this);
30120 } else {
30121 this.readToken(this.fullCharCodeAtPos());
30122 }
30123 };
30124
30125 pp.readToken = function (code) {
30126 // Identifier or keyword. '\uXXXX' sequences are allowed in
30127 // identifiers, so '\' also dispatches to that.
30128 if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92
30129 /* '\' */
30130 ) {
30131 return this.readWord();
30132 }
30133
30134 return this.getTokenFromCode(code);
30135 };
30136
30137 pp.fullCharCodeAtPos = function () {
30138 var code = this.input.charCodeAt(this.pos);
30139
30140 if (code <= 0xd7ff || code >= 0xdc00) {
30141 return code;
30142 }
30143
30144 var next = this.input.charCodeAt(this.pos + 1);
30145 return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00;
30146 };
30147
30148 pp.skipBlockComment = function () {
30149 var startLoc = this.options.onComment && this.curPosition();
30150 var start = this.pos,
30151 end = this.input.indexOf("*/", this.pos += 2);
30152
30153 if (end === -1) {
30154 this.raise(this.pos - 2, "Unterminated comment");
30155 }
30156
30157 this.pos = end + 2;
30158
30159 if (this.options.locations) {
30160 lineBreakG.lastIndex = start;
30161 var match;
30162
30163 while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
30164 ++this.curLine;
30165 this.lineStart = match.index + match[0].length;
30166 }
30167 }
30168
30169 if (this.options.onComment) {
30170 this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, startLoc, this.curPosition());
30171 }
30172 };
30173
30174 pp.skipLineComment = function (startSkip) {
30175 var start = this.pos;
30176 var startLoc = this.options.onComment && this.curPosition();
30177 var ch = this.input.charCodeAt(this.pos += startSkip);
30178
30179 while (this.pos < this.input.length && !isNewLine(ch)) {
30180 ch = this.input.charCodeAt(++this.pos);
30181 }
30182
30183 if (this.options.onComment) {
30184 this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, startLoc, this.curPosition());
30185 }
30186 }; // Called at the start of the parse and after every token. Skips
30187 // whitespace and comments, and.
30188
30189
30190 pp.skipSpace = function () {
30191 loop: while (this.pos < this.input.length) {
30192 var ch = this.input.charCodeAt(this.pos);
30193
30194 switch (ch) {
30195 case 32:
30196 case 160:
30197 // ' '
30198 ++this.pos;
30199 break;
30200
30201 case 13:
30202 if (this.input.charCodeAt(this.pos + 1) === 10) {
30203 ++this.pos;
30204 }
30205
30206 case 10:
30207 case 8232:
30208 case 8233:
30209 ++this.pos;
30210
30211 if (this.options.locations) {
30212 ++this.curLine;
30213 this.lineStart = this.pos;
30214 }
30215
30216 break;
30217
30218 case 47:
30219 // '/'
30220 switch (this.input.charCodeAt(this.pos + 1)) {
30221 case 42:
30222 // '*'
30223 this.skipBlockComment();
30224 break;
30225
30226 case 47:
30227 this.skipLineComment(2);
30228 break;
30229
30230 default:
30231 break loop;
30232 }
30233
30234 break;
30235
30236 default:
30237 if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
30238 ++this.pos;
30239 } else {
30240 break loop;
30241 }
30242
30243 }
30244 }
30245 }; // Called at the end of every token. Sets `end`, `val`, and
30246 // maintains `context` and `exprAllowed`, and skips the space after
30247 // the token, so that the next one's `start` will point at the
30248 // right position.
30249
30250
30251 pp.finishToken = function (type, val) {
30252 this.end = this.pos;
30253
30254 if (this.options.locations) {
30255 this.endLoc = this.curPosition();
30256 }
30257
30258 var prevType = this.type;
30259 this.type = type;
30260 this.value = val;
30261 this.updateContext(prevType);
30262 }; // ### Token reading
30263 // This is the function that is called to fetch the next token. It
30264 // is somewhat obscure, because it works in character codes rather
30265 // than characters, and because operator parsing has been inlined
30266 // into it.
30267 //
30268 // All in the name of speed.
30269 //
30270
30271
30272 pp.readToken_dot = function () {
30273 var next = this.input.charCodeAt(this.pos + 1);
30274
30275 if (next >= 48 && next <= 57) {
30276 return this.readNumber(true);
30277 }
30278
30279 var next2 = this.input.charCodeAt(this.pos + 2);
30280
30281 if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) {
30282 // 46 = dot '.'
30283 this.pos += 3;
30284 return this.finishToken(types$1.ellipsis);
30285 } else {
30286 ++this.pos;
30287 return this.finishToken(types$1.dot);
30288 }
30289 };
30290
30291 pp.readToken_slash = function () {
30292 // '/'
30293 var next = this.input.charCodeAt(this.pos + 1);
30294
30295 if (this.exprAllowed) {
30296 ++this.pos;
30297 return this.readRegexp();
30298 }
30299
30300 if (next === 61) {
30301 return this.finishOp(types$1.assign, 2);
30302 }
30303
30304 return this.finishOp(types$1.slash, 1);
30305 };
30306
30307 pp.readToken_mult_modulo_exp = function (code) {
30308 // '%*'
30309 var next = this.input.charCodeAt(this.pos + 1);
30310 var size = 1;
30311 var tokentype = code === 42 ? types$1.star : types$1.modulo; // exponentiation operator ** and **=
30312
30313 if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
30314 ++size;
30315 tokentype = types$1.starstar;
30316 next = this.input.charCodeAt(this.pos + 2);
30317 }
30318
30319 if (next === 61) {
30320 return this.finishOp(types$1.assign, size + 1);
30321 }
30322
30323 return this.finishOp(tokentype, size);
30324 };
30325
30326 pp.readToken_pipe_amp = function (code) {
30327 // '|&'
30328 var next = this.input.charCodeAt(this.pos + 1);
30329
30330 if (next === code) {
30331 if (this.options.ecmaVersion >= 12) {
30332 var next2 = this.input.charCodeAt(this.pos + 2);
30333
30334 if (next2 === 61) {
30335 return this.finishOp(types$1.assign, 3);
30336 }
30337 }
30338
30339 return this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2);
30340 }
30341
30342 if (next === 61) {
30343 return this.finishOp(types$1.assign, 2);
30344 }
30345
30346 return this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1);
30347 };
30348
30349 pp.readToken_caret = function () {
30350 // '^'
30351 var next = this.input.charCodeAt(this.pos + 1);
30352
30353 if (next === 61) {
30354 return this.finishOp(types$1.assign, 2);
30355 }
30356
30357 return this.finishOp(types$1.bitwiseXOR, 1);
30358 };
30359
30360 pp.readToken_plus_min = function (code) {
30361 // '+-'
30362 var next = this.input.charCodeAt(this.pos + 1);
30363
30364 if (next === code) {
30365 if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 && (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
30366 // A `-->` line comment
30367 this.skipLineComment(3);
30368 this.skipSpace();
30369 return this.nextToken();
30370 }
30371
30372 return this.finishOp(types$1.incDec, 2);
30373 }
30374
30375 if (next === 61) {
30376 return this.finishOp(types$1.assign, 2);
30377 }
30378
30379 return this.finishOp(types$1.plusMin, 1);
30380 };
30381
30382 pp.readToken_lt_gt = function (code) {
30383 // '<>'
30384 var next = this.input.charCodeAt(this.pos + 1);
30385 var size = 1;
30386
30387 if (next === code) {
30388 size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
30389
30390 if (this.input.charCodeAt(this.pos + size) === 61) {
30391 return this.finishOp(types$1.assign, size + 1);
30392 }
30393
30394 return this.finishOp(types$1.bitShift, size);
30395 }
30396
30397 if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 && this.input.charCodeAt(this.pos + 3) === 45) {
30398 // `<!--`, an XML-style comment that should be interpreted as a line comment
30399 this.skipLineComment(4);
30400 this.skipSpace();
30401 return this.nextToken();
30402 }
30403
30404 if (next === 61) {
30405 size = 2;
30406 }
30407
30408 return this.finishOp(types$1.relational, size);
30409 };
30410
30411 pp.readToken_eq_excl = function (code) {
30412 // '=!'
30413 var next = this.input.charCodeAt(this.pos + 1);
30414
30415 if (next === 61) {
30416 return this.finishOp(types$1.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2);
30417 }
30418
30419 if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) {
30420 // '=>'
30421 this.pos += 2;
30422 return this.finishToken(types$1.arrow);
30423 }
30424
30425 return this.finishOp(code === 61 ? types$1.eq : types$1.prefix, 1);
30426 };
30427
30428 pp.readToken_question = function () {
30429 // '?'
30430 var ecmaVersion = this.options.ecmaVersion;
30431
30432 if (ecmaVersion >= 11) {
30433 var next = this.input.charCodeAt(this.pos + 1);
30434
30435 if (next === 46) {
30436 var next2 = this.input.charCodeAt(this.pos + 2);
30437
30438 if (next2 < 48 || next2 > 57) {
30439 return this.finishOp(types$1.questionDot, 2);
30440 }
30441 }
30442
30443 if (next === 63) {
30444 if (ecmaVersion >= 12) {
30445 var next2$1 = this.input.charCodeAt(this.pos + 2);
30446
30447 if (next2$1 === 61) {
30448 return this.finishOp(types$1.assign, 3);
30449 }
30450 }
30451
30452 return this.finishOp(types$1.coalesce, 2);
30453 }
30454 }
30455
30456 return this.finishOp(types$1.question, 1);
30457 };
30458
30459 pp.readToken_numberSign = function () {
30460 // '#'
30461 var ecmaVersion = this.options.ecmaVersion;
30462 var code = 35; // '#'
30463
30464 if (ecmaVersion >= 13) {
30465 ++this.pos;
30466 code = this.fullCharCodeAtPos();
30467
30468 if (isIdentifierStart(code, true) || code === 92
30469 /* '\' */
30470 ) {
30471 return this.finishToken(types$1.privateId, this.readWord1());
30472 }
30473 }
30474
30475 this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
30476 };
30477
30478 pp.getTokenFromCode = function (code) {
30479 switch (code) {
30480 // The interpretation of a dot depends on whether it is followed
30481 // by a digit or another two dots.
30482 case 46:
30483 // '.'
30484 return this.readToken_dot();
30485 // Punctuation tokens.
30486
30487 case 40:
30488 ++this.pos;
30489 return this.finishToken(types$1.parenL);
30490
30491 case 41:
30492 ++this.pos;
30493 return this.finishToken(types$1.parenR);
30494
30495 case 59:
30496 ++this.pos;
30497 return this.finishToken(types$1.semi);
30498
30499 case 44:
30500 ++this.pos;
30501 return this.finishToken(types$1.comma);
30502
30503 case 91:
30504 ++this.pos;
30505 return this.finishToken(types$1.bracketL);
30506
30507 case 93:
30508 ++this.pos;
30509 return this.finishToken(types$1.bracketR);
30510
30511 case 123:
30512 ++this.pos;
30513 return this.finishToken(types$1.braceL);
30514
30515 case 125:
30516 ++this.pos;
30517 return this.finishToken(types$1.braceR);
30518
30519 case 58:
30520 ++this.pos;
30521 return this.finishToken(types$1.colon);
30522
30523 case 96:
30524 // '`'
30525 if (this.options.ecmaVersion < 6) {
30526 break;
30527 }
30528
30529 ++this.pos;
30530 return this.finishToken(types$1.backQuote);
30531
30532 case 48:
30533 // '0'
30534 var next = this.input.charCodeAt(this.pos + 1);
30535
30536 if (next === 120 || next === 88) {
30537 return this.readRadixNumber(16);
30538 } // '0x', '0X' - hex number
30539
30540
30541 if (this.options.ecmaVersion >= 6) {
30542 if (next === 111 || next === 79) {
30543 return this.readRadixNumber(8);
30544 } // '0o', '0O' - octal number
30545
30546
30547 if (next === 98 || next === 66) {
30548 return this.readRadixNumber(2);
30549 } // '0b', '0B' - binary number
30550
30551 }
30552
30553 // Anything else beginning with a digit is an integer, octal
30554 // number, or float.
30555
30556 case 49:
30557 case 50:
30558 case 51:
30559 case 52:
30560 case 53:
30561 case 54:
30562 case 55:
30563 case 56:
30564 case 57:
30565 // 1-9
30566 return this.readNumber(false);
30567 // Quotes produce strings.
30568
30569 case 34:
30570 case 39:
30571 // '"', "'"
30572 return this.readString(code);
30573 // Operators are parsed inline in tiny state machines. '=' (61) is
30574 // often referred to. `finishOp` simply skips the amount of
30575 // characters it is given as second argument, and returns a token
30576 // of the type given by its first argument.
30577
30578 case 47:
30579 // '/'
30580 return this.readToken_slash();
30581
30582 case 37:
30583 case 42:
30584 // '%*'
30585 return this.readToken_mult_modulo_exp(code);
30586
30587 case 124:
30588 case 38:
30589 // '|&'
30590 return this.readToken_pipe_amp(code);
30591
30592 case 94:
30593 // '^'
30594 return this.readToken_caret();
30595
30596 case 43:
30597 case 45:
30598 // '+-'
30599 return this.readToken_plus_min(code);
30600
30601 case 60:
30602 case 62:
30603 // '<>'
30604 return this.readToken_lt_gt(code);
30605
30606 case 61:
30607 case 33:
30608 // '=!'
30609 return this.readToken_eq_excl(code);
30610
30611 case 63:
30612 // '?'
30613 return this.readToken_question();
30614
30615 case 126:
30616 // '~'
30617 return this.finishOp(types$1.prefix, 1);
30618
30619 case 35:
30620 // '#'
30621 return this.readToken_numberSign();
30622 }
30623
30624 this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
30625 };
30626
30627 pp.finishOp = function (type, size) {
30628 var str = this.input.slice(this.pos, this.pos + size);
30629 this.pos += size;
30630 return this.finishToken(type, str);
30631 };
30632
30633 pp.readRegexp = function () {
30634 var escaped,
30635 inClass,
30636 start = this.pos;
30637
30638 for (;;) {
30639 if (this.pos >= this.input.length) {
30640 this.raise(start, "Unterminated regular expression");
30641 }
30642
30643 var ch = this.input.charAt(this.pos);
30644
30645 if (lineBreak.test(ch)) {
30646 this.raise(start, "Unterminated regular expression");
30647 }
30648
30649 if (!escaped) {
30650 if (ch === "[") {
30651 inClass = true;
30652 } else if (ch === "]" && inClass) {
30653 inClass = false;
30654 } else if (ch === "/" && !inClass) {
30655 break;
30656 }
30657
30658 escaped = ch === "\\";
30659 } else {
30660 escaped = false;
30661 }
30662
30663 ++this.pos;
30664 }
30665
30666 var pattern = this.input.slice(start, this.pos);
30667 ++this.pos;
30668 var flagsStart = this.pos;
30669 var flags = this.readWord1();
30670
30671 if (this.containsEsc) {
30672 this.unexpected(flagsStart);
30673 } // Validate pattern
30674
30675
30676 var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
30677 state.reset(start, pattern, flags);
30678 this.validateRegExpFlags(state);
30679 this.validateRegExpPattern(state); // Create Literal#value property value.
30680
30681 var value = null;
30682
30683 try {
30684 value = new RegExp(pattern, flags);
30685 } catch (e) {// ESTree requires null if it failed to instantiate RegExp object.
30686 // https://github.com/estree/estree/blob/a27003adf4fd7bfad44de9cef372a2eacd527b1c/es5.md#regexpliteral
30687 }
30688
30689 return this.finishToken(types$1.regexp, {
30690 pattern: pattern,
30691 flags: flags,
30692 value: value
30693 });
30694 }; // Read an integer in the given radix. Return null if zero digits
30695 // were read, the integer value otherwise. When `len` is given, this
30696 // will return `null` unless the integer has exactly `len` digits.
30697
30698
30699 pp.readInt = function (radix, len, maybeLegacyOctalNumericLiteral) {
30700 // `len` is used for character escape sequences. In that case, disallow separators.
30701 var allowSeparators = this.options.ecmaVersion >= 12 && len === undefined; // `maybeLegacyOctalNumericLiteral` is true if it doesn't have prefix (0x,0o,0b)
30702 // and isn't fraction part nor exponent part. In that case, if the first digit
30703 // is zero then disallow separators.
30704
30705 var isLegacyOctalNumericLiteral = maybeLegacyOctalNumericLiteral && this.input.charCodeAt(this.pos) === 48;
30706 var start = this.pos,
30707 total = 0,
30708 lastCode = 0;
30709
30710 for (var i = 0, e = len == null ? Infinity : len; i < e; ++i, ++this.pos) {
30711 var code = this.input.charCodeAt(this.pos),
30712 val = void 0;
30713
30714 if (allowSeparators && code === 95) {
30715 if (isLegacyOctalNumericLiteral) {
30716 this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals");
30717 }
30718
30719 if (lastCode === 95) {
30720 this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore");
30721 }
30722
30723 if (i === 0) {
30724 this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits");
30725 }
30726
30727 lastCode = code;
30728 continue;
30729 }
30730
30731 if (code >= 97) {
30732 val = code - 97 + 10;
30733 } // a
30734 else if (code >= 65) {
30735 val = code - 65 + 10;
30736 } // A
30737 else if (code >= 48 && code <= 57) {
30738 val = code - 48;
30739 } // 0-9
30740 else {
30741 val = Infinity;
30742 }
30743
30744 if (val >= radix) {
30745 break;
30746 }
30747
30748 lastCode = code;
30749 total = total * radix + val;
30750 }
30751
30752 if (allowSeparators && lastCode === 95) {
30753 this.raiseRecoverable(this.pos - 1, "Numeric separator is not allowed at the last of digits");
30754 }
30755
30756 if (this.pos === start || len != null && this.pos - start !== len) {
30757 return null;
30758 }
30759
30760 return total;
30761 };
30762
30763 function stringToNumber(str, isLegacyOctalNumericLiteral) {
30764 if (isLegacyOctalNumericLiteral) {
30765 return parseInt(str, 8);
30766 } // `parseFloat(value)` stops parsing at the first numeric separator then returns a wrong value.
30767
30768
30769 return parseFloat(str.replace(/_/g, ""));
30770 }
30771
30772 function stringToBigInt(str) {
30773 if (typeof BigInt !== "function") {
30774 return null;
30775 } // `BigInt(value)` throws syntax error if the string contains numeric separators.
30776
30777
30778 return BigInt(str.replace(/_/g, ""));
30779 }
30780
30781 pp.readRadixNumber = function (radix) {
30782 var start = this.pos;
30783 this.pos += 2; // 0x
30784
30785 var val = this.readInt(radix);
30786
30787 if (val == null) {
30788 this.raise(this.start + 2, "Expected number in radix " + radix);
30789 }
30790
30791 if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
30792 val = stringToBigInt(this.input.slice(start, this.pos));
30793 ++this.pos;
30794 } else if (isIdentifierStart(this.fullCharCodeAtPos())) {
30795 this.raise(this.pos, "Identifier directly after number");
30796 }
30797
30798 return this.finishToken(types$1.num, val);
30799 }; // Read an integer, octal integer, or floating-point number.
30800
30801
30802 pp.readNumber = function (startsWithDot) {
30803 var start = this.pos;
30804
30805 if (!startsWithDot && this.readInt(10, undefined, true) === null) {
30806 this.raise(start, "Invalid number");
30807 }
30808
30809 var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
30810
30811 if (octal && this.strict) {
30812 this.raise(start, "Invalid number");
30813 }
30814
30815 var next = this.input.charCodeAt(this.pos);
30816
30817 if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
30818 var val$1 = stringToBigInt(this.input.slice(start, this.pos));
30819 ++this.pos;
30820
30821 if (isIdentifierStart(this.fullCharCodeAtPos())) {
30822 this.raise(this.pos, "Identifier directly after number");
30823 }
30824
30825 return this.finishToken(types$1.num, val$1);
30826 }
30827
30828 if (octal && /[89]/.test(this.input.slice(start, this.pos))) {
30829 octal = false;
30830 }
30831
30832 if (next === 46 && !octal) {
30833 // '.'
30834 ++this.pos;
30835 this.readInt(10);
30836 next = this.input.charCodeAt(this.pos);
30837 }
30838
30839 if ((next === 69 || next === 101) && !octal) {
30840 // 'eE'
30841 next = this.input.charCodeAt(++this.pos);
30842
30843 if (next === 43 || next === 45) {
30844 ++this.pos;
30845 } // '+-'
30846
30847
30848 if (this.readInt(10) === null) {
30849 this.raise(start, "Invalid number");
30850 }
30851 }
30852
30853 if (isIdentifierStart(this.fullCharCodeAtPos())) {
30854 this.raise(this.pos, "Identifier directly after number");
30855 }
30856
30857 var val = stringToNumber(this.input.slice(start, this.pos), octal);
30858 return this.finishToken(types$1.num, val);
30859 }; // Read a string value, interpreting backslash-escapes.
30860
30861
30862 pp.readCodePoint = function () {
30863 var ch = this.input.charCodeAt(this.pos),
30864 code;
30865
30866 if (ch === 123) {
30867 // '{'
30868 if (this.options.ecmaVersion < 6) {
30869 this.unexpected();
30870 }
30871
30872 var codePos = ++this.pos;
30873 code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
30874 ++this.pos;
30875
30876 if (code > 0x10FFFF) {
30877 this.invalidStringToken(codePos, "Code point out of bounds");
30878 }
30879 } else {
30880 code = this.readHexChar(4);
30881 }
30882
30883 return code;
30884 };
30885
30886 function codePointToString(code) {
30887 // UTF-16 Decoding
30888 if (code <= 0xFFFF) {
30889 return String.fromCharCode(code);
30890 }
30891
30892 code -= 0x10000;
30893 return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00);
30894 }
30895
30896 pp.readString = function (quote) {
30897 var out = "",
30898 chunkStart = ++this.pos;
30899
30900 for (;;) {
30901 if (this.pos >= this.input.length) {
30902 this.raise(this.start, "Unterminated string constant");
30903 }
30904
30905 var ch = this.input.charCodeAt(this.pos);
30906
30907 if (ch === quote) {
30908 break;
30909 }
30910
30911 if (ch === 92) {
30912 // '\'
30913 out += this.input.slice(chunkStart, this.pos);
30914 out += this.readEscapedChar(false);
30915 chunkStart = this.pos;
30916 } else if (ch === 0x2028 || ch === 0x2029) {
30917 if (this.options.ecmaVersion < 10) {
30918 this.raise(this.start, "Unterminated string constant");
30919 }
30920
30921 ++this.pos;
30922
30923 if (this.options.locations) {
30924 this.curLine++;
30925 this.lineStart = this.pos;
30926 }
30927 } else {
30928 if (isNewLine(ch)) {
30929 this.raise(this.start, "Unterminated string constant");
30930 }
30931
30932 ++this.pos;
30933 }
30934 }
30935
30936 out += this.input.slice(chunkStart, this.pos++);
30937 return this.finishToken(types$1.string, out);
30938 }; // Reads template string tokens.
30939
30940
30941 var INVALID_TEMPLATE_ESCAPE_ERROR = {};
30942
30943 pp.tryReadTemplateToken = function () {
30944 this.inTemplateElement = true;
30945
30946 try {
30947 this.readTmplToken();
30948 } catch (err) {
30949 if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
30950 this.readInvalidTemplateToken();
30951 } else {
30952 throw err;
30953 }
30954 }
30955
30956 this.inTemplateElement = false;
30957 };
30958
30959 pp.invalidStringToken = function (position, message) {
30960 if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
30961 throw INVALID_TEMPLATE_ESCAPE_ERROR;
30962 } else {
30963 this.raise(position, message);
30964 }
30965 };
30966
30967 pp.readTmplToken = function () {
30968 var out = "",
30969 chunkStart = this.pos;
30970
30971 for (;;) {
30972 if (this.pos >= this.input.length) {
30973 this.raise(this.start, "Unterminated template");
30974 }
30975
30976 var ch = this.input.charCodeAt(this.pos);
30977
30978 if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) {
30979 // '`', '${'
30980 if (this.pos === this.start && (this.type === types$1.template || this.type === types$1.invalidTemplate)) {
30981 if (ch === 36) {
30982 this.pos += 2;
30983 return this.finishToken(types$1.dollarBraceL);
30984 } else {
30985 ++this.pos;
30986 return this.finishToken(types$1.backQuote);
30987 }
30988 }
30989
30990 out += this.input.slice(chunkStart, this.pos);
30991 return this.finishToken(types$1.template, out);
30992 }
30993
30994 if (ch === 92) {
30995 // '\'
30996 out += this.input.slice(chunkStart, this.pos);
30997 out += this.readEscapedChar(true);
30998 chunkStart = this.pos;
30999 } else if (isNewLine(ch)) {
31000 out += this.input.slice(chunkStart, this.pos);
31001 ++this.pos;
31002
31003 switch (ch) {
31004 case 13:
31005 if (this.input.charCodeAt(this.pos) === 10) {
31006 ++this.pos;
31007 }
31008
31009 case 10:
31010 out += "\n";
31011 break;
31012
31013 default:
31014 out += String.fromCharCode(ch);
31015 break;
31016 }
31017
31018 if (this.options.locations) {
31019 ++this.curLine;
31020 this.lineStart = this.pos;
31021 }
31022
31023 chunkStart = this.pos;
31024 } else {
31025 ++this.pos;
31026 }
31027 }
31028 }; // Reads a template token to search for the end, without validating any escape sequences
31029
31030
31031 pp.readInvalidTemplateToken = function () {
31032 for (; this.pos < this.input.length; this.pos++) {
31033 switch (this.input[this.pos]) {
31034 case "\\":
31035 ++this.pos;
31036 break;
31037
31038 case "$":
31039 if (this.input[this.pos + 1] !== "{") {
31040 break;
31041 }
31042
31043 // falls through
31044
31045 case "`":
31046 return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos));
31047 // no default
31048 }
31049 }
31050
31051 this.raise(this.start, "Unterminated template");
31052 }; // Used to read escaped characters
31053
31054
31055 pp.readEscapedChar = function (inTemplate) {
31056 var ch = this.input.charCodeAt(++this.pos);
31057 ++this.pos;
31058
31059 switch (ch) {
31060 case 110:
31061 return "\n";
31062 // 'n' -> '\n'
31063
31064 case 114:
31065 return "\r";
31066 // 'r' -> '\r'
31067
31068 case 120:
31069 return String.fromCharCode(this.readHexChar(2));
31070 // 'x'
31071
31072 case 117:
31073 return codePointToString(this.readCodePoint());
31074 // 'u'
31075
31076 case 116:
31077 return "\t";
31078 // 't' -> '\t'
31079
31080 case 98:
31081 return "\b";
31082 // 'b' -> '\b'
31083
31084 case 118:
31085 return "\u000b";
31086 // 'v' -> '\u000b'
31087
31088 case 102:
31089 return "\f";
31090 // 'f' -> '\f'
31091
31092 case 13:
31093 if (this.input.charCodeAt(this.pos) === 10) {
31094 ++this.pos;
31095 }
31096
31097 // '\r\n'
31098
31099 case 10:
31100 // ' \n'
31101 if (this.options.locations) {
31102 this.lineStart = this.pos;
31103 ++this.curLine;
31104 }
31105
31106 return "";
31107
31108 case 56:
31109 case 57:
31110 if (this.strict) {
31111 this.invalidStringToken(this.pos - 1, "Invalid escape sequence");
31112 }
31113
31114 if (inTemplate) {
31115 var codePos = this.pos - 1;
31116 this.invalidStringToken(codePos, "Invalid escape sequence in template string");
31117 return null;
31118 }
31119
31120 default:
31121 if (ch >= 48 && ch <= 55) {
31122 var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
31123 var octal = parseInt(octalStr, 8);
31124
31125 if (octal > 255) {
31126 octalStr = octalStr.slice(0, -1);
31127 octal = parseInt(octalStr, 8);
31128 }
31129
31130 this.pos += octalStr.length - 1;
31131 ch = this.input.charCodeAt(this.pos);
31132
31133 if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) {
31134 this.invalidStringToken(this.pos - 1 - octalStr.length, inTemplate ? "Octal literal in template string" : "Octal literal in strict mode");
31135 }
31136
31137 return String.fromCharCode(octal);
31138 }
31139
31140 if (isNewLine(ch)) {
31141 // Unicode new line characters after \ get removed from output in both
31142 // template literals and strings
31143 return "";
31144 }
31145
31146 return String.fromCharCode(ch);
31147 }
31148 }; // Used to read character escape sequences ('\x', '\u', '\U').
31149
31150
31151 pp.readHexChar = function (len) {
31152 var codePos = this.pos;
31153 var n = this.readInt(16, len);
31154
31155 if (n === null) {
31156 this.invalidStringToken(codePos, "Bad character escape sequence");
31157 }
31158
31159 return n;
31160 }; // Read an identifier, and return it as a string. Sets `this.containsEsc`
31161 // to whether the word contained a '\u' escape.
31162 //
31163 // Incrementally adds only escaped chars, adding other chunks as-is
31164 // as a micro-optimization.
31165
31166
31167 pp.readWord1 = function () {
31168 this.containsEsc = false;
31169 var word = "",
31170 first = true,
31171 chunkStart = this.pos;
31172 var astral = this.options.ecmaVersion >= 6;
31173
31174 while (this.pos < this.input.length) {
31175 var ch = this.fullCharCodeAtPos();
31176
31177 if (isIdentifierChar(ch, astral)) {
31178 this.pos += ch <= 0xffff ? 1 : 2;
31179 } else if (ch === 92) {
31180 // "\"
31181 this.containsEsc = true;
31182 word += this.input.slice(chunkStart, this.pos);
31183 var escStart = this.pos;
31184
31185 if (this.input.charCodeAt(++this.pos) !== 117) // "u"
31186 {
31187 this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX");
31188 }
31189
31190 ++this.pos;
31191 var esc = this.readCodePoint();
31192
31193 if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral)) {
31194 this.invalidStringToken(escStart, "Invalid Unicode escape");
31195 }
31196
31197 word += codePointToString(esc);
31198 chunkStart = this.pos;
31199 } else {
31200 break;
31201 }
31202
31203 first = false;
31204 }
31205
31206 return word + this.input.slice(chunkStart, this.pos);
31207 }; // Read an identifier or keyword token. Will check for reserved
31208 // words when necessary.
31209
31210
31211 pp.readWord = function () {
31212 var word = this.readWord1();
31213 var type = types$1.name;
31214
31215 if (this.keywords.test(word)) {
31216 type = keywords[word];
31217 }
31218
31219 return this.finishToken(type, word);
31220 }; // Acorn is a tiny, fast JavaScript parser written in JavaScript.
31221
31222
31223 var version = "8.6.0";
31224 Parser.acorn = {
31225 Parser: Parser,
31226 version: version,
31227 defaultOptions: defaultOptions,
31228 Position: Position,
31229 SourceLocation: SourceLocation,
31230 getLineInfo: getLineInfo,
31231 Node: Node,
31232 TokenType: TokenType,
31233 tokTypes: types$1,
31234 keywordTypes: keywords,
31235 TokContext: TokContext,
31236 tokContexts: types,
31237 isIdentifierChar: isIdentifierChar,
31238 isIdentifierStart: isIdentifierStart,
31239 Token: Token,
31240 isNewLine: isNewLine,
31241 lineBreak: lineBreak,
31242 lineBreakG: lineBreakG,
31243 nonASCIIwhitespace: nonASCIIwhitespace
31244 }; // The main exported interface (under `self.acorn` when in the
31245 // browser) is a `parse` function that takes a code string and
31246 // returns an abstract syntax tree as specified by [Mozilla parser
31247 // API][api].
31248 //
31249 // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
31250
31251 function parse(input, options) {
31252 return Parser.parse(input, options);
31253 } // This function tries to parse a single expression at a given
31254 // offset in a string. Useful for parsing mixed-language formats
31255 // that embed JavaScript expressions.
31256
31257
31258 function parseExpressionAt(input, pos, options) {
31259 return Parser.parseExpressionAt(input, pos, options);
31260 } // Acorn is organized as a tokenizer and a recursive-descent parser.
31261 // The `tokenizer` export provides an interface to the tokenizer.
31262
31263
31264 function tokenizer(input, options) {
31265 return Parser.tokenizer(input, options);
31266 }
31267
31268 exports.Node = Node;
31269 exports.Parser = Parser;
31270 exports.Position = Position;
31271 exports.SourceLocation = SourceLocation;
31272 exports.TokContext = TokContext;
31273 exports.Token = Token;
31274 exports.TokenType = TokenType;
31275 exports.defaultOptions = defaultOptions;
31276 exports.getLineInfo = getLineInfo;
31277 exports.isIdentifierChar = isIdentifierChar;
31278 exports.isIdentifierStart = isIdentifierStart;
31279 exports.isNewLine = isNewLine;
31280 exports.keywordTypes = keywords;
31281 exports.lineBreak = lineBreak;
31282 exports.lineBreakG = lineBreakG;
31283 exports.nonASCIIwhitespace = nonASCIIwhitespace;
31284 exports.parse = parse;
31285 exports.parseExpressionAt = parseExpressionAt;
31286 exports.tokContexts = types;
31287 exports.tokTypes = types$1;
31288 exports.tokenizer = tokenizer;
31289 exports.version = version;
31290 Object.defineProperty(exports, '__esModule', {
31291 value: true
31292 });
31293 });
31294
31295 /***/ }),
31296 /* 438 */
31297 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
31298
31299 /*global window, global*/
31300 var util = __webpack_require__(439);
31301
31302 var assert = __webpack_require__(431);
31303
31304 function now() {
31305 return new Date().getTime();
31306 }
31307
31308 var slice = Array.prototype.slice;
31309 var console;
31310 var times = {};
31311
31312 if (typeof global !== "undefined" && global.console) {
31313 console = global.console;
31314 } else if (typeof window !== "undefined" && window.console) {
31315 console = window.console;
31316 } else {
31317 console = {};
31318 }
31319
31320 var functions = [[log, "log"], [info, "info"], [warn, "warn"], [error, "error"], [time, "time"], [timeEnd, "timeEnd"], [trace, "trace"], [dir, "dir"], [consoleAssert, "assert"]];
31321
31322 for (var i = 0; i < functions.length; i++) {
31323 var tuple = functions[i];
31324 var f = tuple[0];
31325 var name = tuple[1];
31326
31327 if (!console[name]) {
31328 console[name] = f;
31329 }
31330 }
31331
31332 module.exports = console;
31333
31334 function log() {}
31335
31336 function info() {
31337 console.log.apply(console, arguments);
31338 }
31339
31340 function warn() {
31341 console.log.apply(console, arguments);
31342 }
31343
31344 function error() {
31345 console.warn.apply(console, arguments);
31346 }
31347
31348 function time(label) {
31349 times[label] = now();
31350 }
31351
31352 function timeEnd(label) {
31353 var time = times[label];
31354
31355 if (!time) {
31356 throw new Error("No such label: " + label);
31357 }
31358
31359 delete times[label];
31360 var duration = now() - time;
31361 console.log(label + ": " + duration + "ms");
31362 }
31363
31364 function trace() {
31365 var err = new Error();
31366 err.name = "Trace";
31367 err.message = util.format.apply(null, arguments);
31368 console.error(err.stack);
31369 }
31370
31371 function dir(object) {
31372 console.log(util.inspect(object) + "\n");
31373 }
31374
31375 function consoleAssert(expression) {
31376 if (!expression) {
31377 var arr = slice.call(arguments, 1);
31378 assert.ok(false, util.format.apply(null, arr));
31379 }
31380 }
31381
31382 /***/ }),
31383 /* 439 */
31384 /***/ ((module) => {
31385
31386 "use strict";
31387 module.exports = require("util");
31388
31389 /***/ }),
31390 /* 440 */
31391 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
31392
31393 "use strict";
31394
31395
31396 const XHTMLEntities = __webpack_require__(441);
31397
31398 const hexNumber = /^[\da-fA-F]+$/;
31399 const decimalNumber = /^\d+$/; // The map to `acorn-jsx` tokens from `acorn` namespace objects.
31400
31401 const acornJsxMap = new WeakMap(); // Get the original tokens for the given `acorn` namespace object.
31402
31403 function getJsxTokens(acorn) {
31404 acorn = acorn.Parser.acorn || acorn;
31405 let acornJsx = acornJsxMap.get(acorn);
31406
31407 if (!acornJsx) {
31408 const tt = acorn.tokTypes;
31409 const TokContext = acorn.TokContext;
31410 const TokenType = acorn.TokenType;
31411 const tc_oTag = new TokContext('<tag', false);
31412 const tc_cTag = new TokContext('</tag', false);
31413 const tc_expr = new TokContext('<tag>...</tag>', true, true);
31414 const tokContexts = {
31415 tc_oTag: tc_oTag,
31416 tc_cTag: tc_cTag,
31417 tc_expr: tc_expr
31418 };
31419 const tokTypes = {
31420 jsxName: new TokenType('jsxName'),
31421 jsxText: new TokenType('jsxText', {
31422 beforeExpr: true
31423 }),
31424 jsxTagStart: new TokenType('jsxTagStart', {
31425 startsExpr: true
31426 }),
31427 jsxTagEnd: new TokenType('jsxTagEnd')
31428 };
31429
31430 tokTypes.jsxTagStart.updateContext = function () {
31431 this.context.push(tc_expr); // treat as beginning of JSX expression
31432
31433 this.context.push(tc_oTag); // start opening tag context
31434
31435 this.exprAllowed = false;
31436 };
31437
31438 tokTypes.jsxTagEnd.updateContext = function (prevType) {
31439 let out = this.context.pop();
31440
31441 if (out === tc_oTag && prevType === tt.slash || out === tc_cTag) {
31442 this.context.pop();
31443 this.exprAllowed = this.curContext() === tc_expr;
31444 } else {
31445 this.exprAllowed = true;
31446 }
31447 };
31448
31449 acornJsx = {
31450 tokContexts: tokContexts,
31451 tokTypes: tokTypes
31452 };
31453 acornJsxMap.set(acorn, acornJsx);
31454 }
31455
31456 return acornJsx;
31457 } // Transforms JSX element name to string.
31458
31459
31460 function getQualifiedJSXName(object) {
31461 if (!object) return object;
31462 if (object.type === 'JSXIdentifier') return object.name;
31463 if (object.type === 'JSXNamespacedName') return object.namespace.name + ':' + object.name.name;
31464 if (object.type === 'JSXMemberExpression') return getQualifiedJSXName(object.object) + '.' + getQualifiedJSXName(object.property);
31465 }
31466
31467 module.exports = function (options) {
31468 options = options || {};
31469 return function (Parser) {
31470 return plugin({
31471 allowNamespaces: options.allowNamespaces !== false,
31472 allowNamespacedObjects: !!options.allowNamespacedObjects
31473 }, Parser);
31474 };
31475 }; // This is `tokTypes` of the peer dep.
31476 // This can be different instances from the actual `tokTypes` this plugin uses.
31477
31478
31479 Object.defineProperty(module.exports, "tokTypes", ({
31480 get: function get_tokTypes() {
31481 return getJsxTokens(__webpack_require__(437)).tokTypes;
31482 },
31483 configurable: true,
31484 enumerable: true
31485 }));
31486
31487 function plugin(options, Parser) {
31488 const acorn = Parser.acorn || __webpack_require__(437);
31489
31490 const acornJsx = getJsxTokens(acorn);
31491 const tt = acorn.tokTypes;
31492 const tok = acornJsx.tokTypes;
31493 const tokContexts = acorn.tokContexts;
31494 const tc_oTag = acornJsx.tokContexts.tc_oTag;
31495 const tc_cTag = acornJsx.tokContexts.tc_cTag;
31496 const tc_expr = acornJsx.tokContexts.tc_expr;
31497 const isNewLine = acorn.isNewLine;
31498 const isIdentifierStart = acorn.isIdentifierStart;
31499 const isIdentifierChar = acorn.isIdentifierChar;
31500 return class extends Parser {
31501 // Expose actual `tokTypes` and `tokContexts` to other plugins.
31502 static get acornJsx() {
31503 return acornJsx;
31504 } // Reads inline JSX contents token.
31505
31506
31507 jsx_readToken() {
31508 let out = '',
31509 chunkStart = this.pos;
31510
31511 for (;;) {
31512 if (this.pos >= this.input.length) this.raise(this.start, 'Unterminated JSX contents');
31513 let ch = this.input.charCodeAt(this.pos);
31514
31515 switch (ch) {
31516 case 60: // '<'
31517
31518 case 123:
31519 // '{'
31520 if (this.pos === this.start) {
31521 if (ch === 60 && this.exprAllowed) {
31522 ++this.pos;
31523 return this.finishToken(tok.jsxTagStart);
31524 }
31525
31526 return this.getTokenFromCode(ch);
31527 }
31528
31529 out += this.input.slice(chunkStart, this.pos);
31530 return this.finishToken(tok.jsxText, out);
31531
31532 case 38:
31533 // '&'
31534 out += this.input.slice(chunkStart, this.pos);
31535 out += this.jsx_readEntity();
31536 chunkStart = this.pos;
31537 break;
31538
31539 case 62: // '>'
31540
31541 case 125:
31542 // '}'
31543 this.raise(this.pos, "Unexpected token `" + this.input[this.pos] + "`. Did you mean `" + (ch === 62 ? "&gt;" : "&rbrace;") + "` or " + "`{\"" + this.input[this.pos] + "\"}" + "`?");
31544
31545 default:
31546 if (isNewLine(ch)) {
31547 out += this.input.slice(chunkStart, this.pos);
31548 out += this.jsx_readNewLine(true);
31549 chunkStart = this.pos;
31550 } else {
31551 ++this.pos;
31552 }
31553
31554 }
31555 }
31556 }
31557
31558 jsx_readNewLine(normalizeCRLF) {
31559 let ch = this.input.charCodeAt(this.pos);
31560 let out;
31561 ++this.pos;
31562
31563 if (ch === 13 && this.input.charCodeAt(this.pos) === 10) {
31564 ++this.pos;
31565 out = normalizeCRLF ? '\n' : '\r\n';
31566 } else {
31567 out = String.fromCharCode(ch);
31568 }
31569
31570 if (this.options.locations) {
31571 ++this.curLine;
31572 this.lineStart = this.pos;
31573 }
31574
31575 return out;
31576 }
31577
31578 jsx_readString(quote) {
31579 let out = '',
31580 chunkStart = ++this.pos;
31581
31582 for (;;) {
31583 if (this.pos >= this.input.length) this.raise(this.start, 'Unterminated string constant');
31584 let ch = this.input.charCodeAt(this.pos);
31585 if (ch === quote) break;
31586
31587 if (ch === 38) {
31588 // '&'
31589 out += this.input.slice(chunkStart, this.pos);
31590 out += this.jsx_readEntity();
31591 chunkStart = this.pos;
31592 } else if (isNewLine(ch)) {
31593 out += this.input.slice(chunkStart, this.pos);
31594 out += this.jsx_readNewLine(false);
31595 chunkStart = this.pos;
31596 } else {
31597 ++this.pos;
31598 }
31599 }
31600
31601 out += this.input.slice(chunkStart, this.pos++);
31602 return this.finishToken(tt.string, out);
31603 }
31604
31605 jsx_readEntity() {
31606 let str = '',
31607 count = 0,
31608 entity;
31609 let ch = this.input[this.pos];
31610 if (ch !== '&') this.raise(this.pos, 'Entity must start with an ampersand');
31611 let startPos = ++this.pos;
31612
31613 while (this.pos < this.input.length && count++ < 10) {
31614 ch = this.input[this.pos++];
31615
31616 if (ch === ';') {
31617 if (str[0] === '#') {
31618 if (str[1] === 'x') {
31619 str = str.substr(2);
31620 if (hexNumber.test(str)) entity = String.fromCharCode(parseInt(str, 16));
31621 } else {
31622 str = str.substr(1);
31623 if (decimalNumber.test(str)) entity = String.fromCharCode(parseInt(str, 10));
31624 }
31625 } else {
31626 entity = XHTMLEntities[str];
31627 }
31628
31629 break;
31630 }
31631
31632 str += ch;
31633 }
31634
31635 if (!entity) {
31636 this.pos = startPos;
31637 return '&';
31638 }
31639
31640 return entity;
31641 } // Read a JSX identifier (valid tag or attribute name).
31642 //
31643 // Optimized version since JSX identifiers can't contain
31644 // escape characters and so can be read as single slice.
31645 // Also assumes that first character was already checked
31646 // by isIdentifierStart in readToken.
31647
31648
31649 jsx_readWord() {
31650 let ch,
31651 start = this.pos;
31652
31653 do {
31654 ch = this.input.charCodeAt(++this.pos);
31655 } while (isIdentifierChar(ch) || ch === 45); // '-'
31656
31657
31658 return this.finishToken(tok.jsxName, this.input.slice(start, this.pos));
31659 } // Parse next token as JSX identifier
31660
31661
31662 jsx_parseIdentifier() {
31663 let node = this.startNode();
31664 if (this.type === tok.jsxName) node.name = this.value;else if (this.type.keyword) node.name = this.type.keyword;else this.unexpected();
31665 this.next();
31666 return this.finishNode(node, 'JSXIdentifier');
31667 } // Parse namespaced identifier.
31668
31669
31670 jsx_parseNamespacedName() {
31671 let startPos = this.start,
31672 startLoc = this.startLoc;
31673 let name = this.jsx_parseIdentifier();
31674 if (!options.allowNamespaces || !this.eat(tt.colon)) return name;
31675 var node = this.startNodeAt(startPos, startLoc);
31676 node.namespace = name;
31677 node.name = this.jsx_parseIdentifier();
31678 return this.finishNode(node, 'JSXNamespacedName');
31679 } // Parses element name in any form - namespaced, member
31680 // or single identifier.
31681
31682
31683 jsx_parseElementName() {
31684 if (this.type === tok.jsxTagEnd) return '';
31685 let startPos = this.start,
31686 startLoc = this.startLoc;
31687 let node = this.jsx_parseNamespacedName();
31688
31689 if (this.type === tt.dot && node.type === 'JSXNamespacedName' && !options.allowNamespacedObjects) {
31690 this.unexpected();
31691 }
31692
31693 while (this.eat(tt.dot)) {
31694 let newNode = this.startNodeAt(startPos, startLoc);
31695 newNode.object = node;
31696 newNode.property = this.jsx_parseIdentifier();
31697 node = this.finishNode(newNode, 'JSXMemberExpression');
31698 }
31699
31700 return node;
31701 } // Parses any type of JSX attribute value.
31702
31703
31704 jsx_parseAttributeValue() {
31705 switch (this.type) {
31706 case tt.braceL:
31707 let node = this.jsx_parseExpressionContainer();
31708 if (node.expression.type === 'JSXEmptyExpression') this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression');
31709 return node;
31710
31711 case tok.jsxTagStart:
31712 case tt.string:
31713 return this.parseExprAtom();
31714
31715 default:
31716 this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text');
31717 }
31718 } // JSXEmptyExpression is unique type since it doesn't actually parse anything,
31719 // and so it should start at the end of last read token (left brace) and finish
31720 // at the beginning of the next one (right brace).
31721
31722
31723 jsx_parseEmptyExpression() {
31724 let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc);
31725 return this.finishNodeAt(node, 'JSXEmptyExpression', this.start, this.startLoc);
31726 } // Parses JSX expression enclosed into curly brackets.
31727
31728
31729 jsx_parseExpressionContainer() {
31730 let node = this.startNode();
31731 this.next();
31732 node.expression = this.type === tt.braceR ? this.jsx_parseEmptyExpression() : this.parseExpression();
31733 this.expect(tt.braceR);
31734 return this.finishNode(node, 'JSXExpressionContainer');
31735 } // Parses following JSX attribute name-value pair.
31736
31737
31738 jsx_parseAttribute() {
31739 let node = this.startNode();
31740
31741 if (this.eat(tt.braceL)) {
31742 this.expect(tt.ellipsis);
31743 node.argument = this.parseMaybeAssign();
31744 this.expect(tt.braceR);
31745 return this.finishNode(node, 'JSXSpreadAttribute');
31746 }
31747
31748 node.name = this.jsx_parseNamespacedName();
31749 node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null;
31750 return this.finishNode(node, 'JSXAttribute');
31751 } // Parses JSX opening tag starting after '<'.
31752
31753
31754 jsx_parseOpeningElementAt(startPos, startLoc) {
31755 let node = this.startNodeAt(startPos, startLoc);
31756 node.attributes = [];
31757 let nodeName = this.jsx_parseElementName();
31758 if (nodeName) node.name = nodeName;
31759
31760 while (this.type !== tt.slash && this.type !== tok.jsxTagEnd) node.attributes.push(this.jsx_parseAttribute());
31761
31762 node.selfClosing = this.eat(tt.slash);
31763 this.expect(tok.jsxTagEnd);
31764 return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment');
31765 } // Parses JSX closing tag starting after '</'.
31766
31767
31768 jsx_parseClosingElementAt(startPos, startLoc) {
31769 let node = this.startNodeAt(startPos, startLoc);
31770 let nodeName = this.jsx_parseElementName();
31771 if (nodeName) node.name = nodeName;
31772 this.expect(tok.jsxTagEnd);
31773 return this.finishNode(node, nodeName ? 'JSXClosingElement' : 'JSXClosingFragment');
31774 } // Parses entire JSX element, including it's opening tag
31775 // (starting after '<'), attributes, contents and closing tag.
31776
31777
31778 jsx_parseElementAt(startPos, startLoc) {
31779 let node = this.startNodeAt(startPos, startLoc);
31780 let children = [];
31781 let openingElement = this.jsx_parseOpeningElementAt(startPos, startLoc);
31782 let closingElement = null;
31783
31784 if (!openingElement.selfClosing) {
31785 contents: for (;;) {
31786 switch (this.type) {
31787 case tok.jsxTagStart:
31788 startPos = this.start;
31789 startLoc = this.startLoc;
31790 this.next();
31791
31792 if (this.eat(tt.slash)) {
31793 closingElement = this.jsx_parseClosingElementAt(startPos, startLoc);
31794 break contents;
31795 }
31796
31797 children.push(this.jsx_parseElementAt(startPos, startLoc));
31798 break;
31799
31800 case tok.jsxText:
31801 children.push(this.parseExprAtom());
31802 break;
31803
31804 case tt.braceL:
31805 children.push(this.jsx_parseExpressionContainer());
31806 break;
31807
31808 default:
31809 this.unexpected();
31810 }
31811 }
31812
31813 if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
31814 this.raise(closingElement.start, 'Expected corresponding JSX closing tag for <' + getQualifiedJSXName(openingElement.name) + '>');
31815 }
31816 }
31817
31818 let fragmentOrElement = openingElement.name ? 'Element' : 'Fragment';
31819 node['opening' + fragmentOrElement] = openingElement;
31820 node['closing' + fragmentOrElement] = closingElement;
31821 node.children = children;
31822
31823 if (this.type === tt.relational && this.value === "<") {
31824 this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag");
31825 }
31826
31827 return this.finishNode(node, 'JSX' + fragmentOrElement);
31828 } // Parse JSX text
31829
31830
31831 jsx_parseText() {
31832 let node = this.parseLiteral(this.value);
31833 node.type = "JSXText";
31834 return node;
31835 } // Parses entire JSX element from current position.
31836
31837
31838 jsx_parseElement() {
31839 let startPos = this.start,
31840 startLoc = this.startLoc;
31841 this.next();
31842 return this.jsx_parseElementAt(startPos, startLoc);
31843 }
31844
31845 parseExprAtom(refShortHandDefaultPos) {
31846 if (this.type === tok.jsxText) return this.jsx_parseText();else if (this.type === tok.jsxTagStart) return this.jsx_parseElement();else return super.parseExprAtom(refShortHandDefaultPos);
31847 }
31848
31849 readToken(code) {
31850 let context = this.curContext();
31851 if (context === tc_expr) return this.jsx_readToken();
31852
31853 if (context === tc_oTag || context === tc_cTag) {
31854 if (isIdentifierStart(code)) return this.jsx_readWord();
31855
31856 if (code == 62) {
31857 ++this.pos;
31858 return this.finishToken(tok.jsxTagEnd);
31859 }
31860
31861 if ((code === 34 || code === 39) && context == tc_oTag) return this.jsx_readString(code);
31862 }
31863
31864 if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) {
31865 ++this.pos;
31866 return this.finishToken(tok.jsxTagStart);
31867 }
31868
31869 return super.readToken(code);
31870 }
31871
31872 updateContext(prevType) {
31873 if (this.type == tt.braceL) {
31874 var curContext = this.curContext();
31875 if (curContext == tc_oTag) this.context.push(tokContexts.b_expr);else if (curContext == tc_expr) this.context.push(tokContexts.b_tmpl);else super.updateContext(prevType);
31876 this.exprAllowed = true;
31877 } else if (this.type === tt.slash && prevType === tok.jsxTagStart) {
31878 this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore
31879
31880 this.context.push(tc_cTag); // reconsider as closing tag context
31881
31882 this.exprAllowed = false;
31883 } else {
31884 return super.updateContext(prevType);
31885 }
31886 }
31887
31888 };
31889 }
31890
31891 /***/ }),
31892 /* 441 */
31893 /***/ ((module) => {
31894
31895 module.exports = {
31896 quot: '\u0022',
31897 amp: '&',
31898 apos: '\u0027',
31899 lt: '<',
31900 gt: '>',
31901 nbsp: '\u00A0',
31902 iexcl: '\u00A1',
31903 cent: '\u00A2',
31904 pound: '\u00A3',
31905 curren: '\u00A4',
31906 yen: '\u00A5',
31907 brvbar: '\u00A6',
31908 sect: '\u00A7',
31909 uml: '\u00A8',
31910 copy: '\u00A9',
31911 ordf: '\u00AA',
31912 laquo: '\u00AB',
31913 not: '\u00AC',
31914 shy: '\u00AD',
31915 reg: '\u00AE',
31916 macr: '\u00AF',
31917 deg: '\u00B0',
31918 plusmn: '\u00B1',
31919 sup2: '\u00B2',
31920 sup3: '\u00B3',
31921 acute: '\u00B4',
31922 micro: '\u00B5',
31923 para: '\u00B6',
31924 middot: '\u00B7',
31925 cedil: '\u00B8',
31926 sup1: '\u00B9',
31927 ordm: '\u00BA',
31928 raquo: '\u00BB',
31929 frac14: '\u00BC',
31930 frac12: '\u00BD',
31931 frac34: '\u00BE',
31932 iquest: '\u00BF',
31933 Agrave: '\u00C0',
31934 Aacute: '\u00C1',
31935 Acirc: '\u00C2',
31936 Atilde: '\u00C3',
31937 Auml: '\u00C4',
31938 Aring: '\u00C5',
31939 AElig: '\u00C6',
31940 Ccedil: '\u00C7',
31941 Egrave: '\u00C8',
31942 Eacute: '\u00C9',
31943 Ecirc: '\u00CA',
31944 Euml: '\u00CB',
31945 Igrave: '\u00CC',
31946 Iacute: '\u00CD',
31947 Icirc: '\u00CE',
31948 Iuml: '\u00CF',
31949 ETH: '\u00D0',
31950 Ntilde: '\u00D1',
31951 Ograve: '\u00D2',
31952 Oacute: '\u00D3',
31953 Ocirc: '\u00D4',
31954 Otilde: '\u00D5',
31955 Ouml: '\u00D6',
31956 times: '\u00D7',
31957 Oslash: '\u00D8',
31958 Ugrave: '\u00D9',
31959 Uacute: '\u00DA',
31960 Ucirc: '\u00DB',
31961 Uuml: '\u00DC',
31962 Yacute: '\u00DD',
31963 THORN: '\u00DE',
31964 szlig: '\u00DF',
31965 agrave: '\u00E0',
31966 aacute: '\u00E1',
31967 acirc: '\u00E2',
31968 atilde: '\u00E3',
31969 auml: '\u00E4',
31970 aring: '\u00E5',
31971 aelig: '\u00E6',
31972 ccedil: '\u00E7',
31973 egrave: '\u00E8',
31974 eacute: '\u00E9',
31975 ecirc: '\u00EA',
31976 euml: '\u00EB',
31977 igrave: '\u00EC',
31978 iacute: '\u00ED',
31979 icirc: '\u00EE',
31980 iuml: '\u00EF',
31981 eth: '\u00F0',
31982 ntilde: '\u00F1',
31983 ograve: '\u00F2',
31984 oacute: '\u00F3',
31985 ocirc: '\u00F4',
31986 otilde: '\u00F5',
31987 ouml: '\u00F6',
31988 divide: '\u00F7',
31989 oslash: '\u00F8',
31990 ugrave: '\u00F9',
31991 uacute: '\u00FA',
31992 ucirc: '\u00FB',
31993 uuml: '\u00FC',
31994 yacute: '\u00FD',
31995 thorn: '\u00FE',
31996 yuml: '\u00FF',
31997 OElig: '\u0152',
31998 oelig: '\u0153',
31999 Scaron: '\u0160',
32000 scaron: '\u0161',
32001 Yuml: '\u0178',
32002 fnof: '\u0192',
32003 circ: '\u02C6',
32004 tilde: '\u02DC',
32005 Alpha: '\u0391',
32006 Beta: '\u0392',
32007 Gamma: '\u0393',
32008 Delta: '\u0394',
32009 Epsilon: '\u0395',
32010 Zeta: '\u0396',
32011 Eta: '\u0397',
32012 Theta: '\u0398',
32013 Iota: '\u0399',
32014 Kappa: '\u039A',
32015 Lambda: '\u039B',
32016 Mu: '\u039C',
32017 Nu: '\u039D',
32018 Xi: '\u039E',
32019 Omicron: '\u039F',
32020 Pi: '\u03A0',
32021 Rho: '\u03A1',
32022 Sigma: '\u03A3',
32023 Tau: '\u03A4',
32024 Upsilon: '\u03A5',
32025 Phi: '\u03A6',
32026 Chi: '\u03A7',
32027 Psi: '\u03A8',
32028 Omega: '\u03A9',
32029 alpha: '\u03B1',
32030 beta: '\u03B2',
32031 gamma: '\u03B3',
32032 delta: '\u03B4',
32033 epsilon: '\u03B5',
32034 zeta: '\u03B6',
32035 eta: '\u03B7',
32036 theta: '\u03B8',
32037 iota: '\u03B9',
32038 kappa: '\u03BA',
32039 lambda: '\u03BB',
32040 mu: '\u03BC',
32041 nu: '\u03BD',
32042 xi: '\u03BE',
32043 omicron: '\u03BF',
32044 pi: '\u03C0',
32045 rho: '\u03C1',
32046 sigmaf: '\u03C2',
32047 sigma: '\u03C3',
32048 tau: '\u03C4',
32049 upsilon: '\u03C5',
32050 phi: '\u03C6',
32051 chi: '\u03C7',
32052 psi: '\u03C8',
32053 omega: '\u03C9',
32054 thetasym: '\u03D1',
32055 upsih: '\u03D2',
32056 piv: '\u03D6',
32057 ensp: '\u2002',
32058 emsp: '\u2003',
32059 thinsp: '\u2009',
32060 zwnj: '\u200C',
32061 zwj: '\u200D',
32062 lrm: '\u200E',
32063 rlm: '\u200F',
32064 ndash: '\u2013',
32065 mdash: '\u2014',
32066 lsquo: '\u2018',
32067 rsquo: '\u2019',
32068 sbquo: '\u201A',
32069 ldquo: '\u201C',
32070 rdquo: '\u201D',
32071 bdquo: '\u201E',
32072 dagger: '\u2020',
32073 Dagger: '\u2021',
32074 bull: '\u2022',
32075 hellip: '\u2026',
32076 permil: '\u2030',
32077 prime: '\u2032',
32078 Prime: '\u2033',
32079 lsaquo: '\u2039',
32080 rsaquo: '\u203A',
32081 oline: '\u203E',
32082 frasl: '\u2044',
32083 euro: '\u20AC',
32084 image: '\u2111',
32085 weierp: '\u2118',
32086 real: '\u211C',
32087 trade: '\u2122',
32088 alefsym: '\u2135',
32089 larr: '\u2190',
32090 uarr: '\u2191',
32091 rarr: '\u2192',
32092 darr: '\u2193',
32093 harr: '\u2194',
32094 crarr: '\u21B5',
32095 lArr: '\u21D0',
32096 uArr: '\u21D1',
32097 rArr: '\u21D2',
32098 dArr: '\u21D3',
32099 hArr: '\u21D4',
32100 forall: '\u2200',
32101 part: '\u2202',
32102 exist: '\u2203',
32103 empty: '\u2205',
32104 nabla: '\u2207',
32105 isin: '\u2208',
32106 notin: '\u2209',
32107 ni: '\u220B',
32108 prod: '\u220F',
32109 sum: '\u2211',
32110 minus: '\u2212',
32111 lowast: '\u2217',
32112 radic: '\u221A',
32113 prop: '\u221D',
32114 infin: '\u221E',
32115 ang: '\u2220',
32116 and: '\u2227',
32117 or: '\u2228',
32118 cap: '\u2229',
32119 cup: '\u222A',
32120 'int': '\u222B',
32121 there4: '\u2234',
32122 sim: '\u223C',
32123 cong: '\u2245',
32124 asymp: '\u2248',
32125 ne: '\u2260',
32126 equiv: '\u2261',
32127 le: '\u2264',
32128 ge: '\u2265',
32129 sub: '\u2282',
32130 sup: '\u2283',
32131 nsub: '\u2284',
32132 sube: '\u2286',
32133 supe: '\u2287',
32134 oplus: '\u2295',
32135 otimes: '\u2297',
32136 perp: '\u22A5',
32137 sdot: '\u22C5',
32138 lceil: '\u2308',
32139 rceil: '\u2309',
32140 lfloor: '\u230A',
32141 rfloor: '\u230B',
32142 lang: '\u2329',
32143 rang: '\u232A',
32144 loz: '\u25CA',
32145 spades: '\u2660',
32146 clubs: '\u2663',
32147 hearts: '\u2665',
32148 diams: '\u2666'
32149 };
32150
32151 /***/ }),
32152 /* 442 */
32153 /***/ ((module, exports, __webpack_require__) => {
32154
32155 /* module decorator */ module = __webpack_require__.nmd(module);
32156 /**
32157 * Lodash (Custom Build) <https://lodash.com/>
32158 * Build: `lodash modularize exports="npm" -o ./`
32159 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
32160 * Released under MIT license <https://lodash.com/license>
32161 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
32162 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
32163 */
32164
32165 /** Used as the size to enable large array optimizations. */
32166 var LARGE_ARRAY_SIZE = 200;
32167 /** Used to stand-in for `undefined` hash values. */
32168
32169 var HASH_UNDEFINED = '__lodash_hash_undefined__';
32170 /** Used to detect hot functions by number of calls within a span of milliseconds. */
32171
32172 var HOT_COUNT = 800,
32173 HOT_SPAN = 16;
32174 /** Used as references for various `Number` constants. */
32175
32176 var MAX_SAFE_INTEGER = 9007199254740991;
32177 /** `Object#toString` result references. */
32178
32179 var argsTag = '[object Arguments]',
32180 arrayTag = '[object Array]',
32181 asyncTag = '[object AsyncFunction]',
32182 boolTag = '[object Boolean]',
32183 dateTag = '[object Date]',
32184 errorTag = '[object Error]',
32185 funcTag = '[object Function]',
32186 genTag = '[object GeneratorFunction]',
32187 mapTag = '[object Map]',
32188 numberTag = '[object Number]',
32189 nullTag = '[object Null]',
32190 objectTag = '[object Object]',
32191 proxyTag = '[object Proxy]',
32192 regexpTag = '[object RegExp]',
32193 setTag = '[object Set]',
32194 stringTag = '[object String]',
32195 undefinedTag = '[object Undefined]',
32196 weakMapTag = '[object WeakMap]';
32197 var arrayBufferTag = '[object ArrayBuffer]',
32198 dataViewTag = '[object DataView]',
32199 float32Tag = '[object Float32Array]',
32200 float64Tag = '[object Float64Array]',
32201 int8Tag = '[object Int8Array]',
32202 int16Tag = '[object Int16Array]',
32203 int32Tag = '[object Int32Array]',
32204 uint8Tag = '[object Uint8Array]',
32205 uint8ClampedTag = '[object Uint8ClampedArray]',
32206 uint16Tag = '[object Uint16Array]',
32207 uint32Tag = '[object Uint32Array]';
32208 /**
32209 * Used to match `RegExp`
32210 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
32211 */
32212
32213 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
32214 /** Used to detect host constructors (Safari). */
32215
32216 var reIsHostCtor = /^\[object .+?Constructor\]$/;
32217 /** Used to detect unsigned integer values. */
32218
32219 var reIsUint = /^(?:0|[1-9]\d*)$/;
32220 /** Used to identify `toStringTag` values of typed arrays. */
32221
32222 var typedArrayTags = {};
32223 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
32224 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
32225 /** Detect free variable `global` from Node.js. */
32226
32227 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
32228 /** Detect free variable `self`. */
32229
32230 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
32231 /** Used as a reference to the global object. */
32232
32233 var root = freeGlobal || freeSelf || Function('return this')();
32234 /** Detect free variable `exports`. */
32235
32236 var freeExports = true && exports && !exports.nodeType && exports;
32237 /** Detect free variable `module`. */
32238
32239 var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
32240 /** Detect the popular CommonJS extension `module.exports`. */
32241
32242 var moduleExports = freeModule && freeModule.exports === freeExports;
32243 /** Detect free variable `process` from Node.js. */
32244
32245 var freeProcess = moduleExports && freeGlobal.process;
32246 /** Used to access faster Node.js helpers. */
32247
32248 var nodeUtil = function () {
32249 try {
32250 // Use `util.types` for Node.js 10+.
32251 var types = freeModule && freeModule.require && freeModule.require('util').types;
32252
32253 if (types) {
32254 return types;
32255 } // Legacy `process.binding('util')` for Node.js < 10.
32256
32257
32258 return freeProcess && freeProcess.binding && freeProcess.binding('util');
32259 } catch (e) {}
32260 }();
32261 /* Node.js helper references. */
32262
32263
32264 var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
32265 /**
32266 * A faster alternative to `Function#apply`, this function invokes `func`
32267 * with the `this` binding of `thisArg` and the arguments of `args`.
32268 *
32269 * @private
32270 * @param {Function} func The function to invoke.
32271 * @param {*} thisArg The `this` binding of `func`.
32272 * @param {Array} args The arguments to invoke `func` with.
32273 * @returns {*} Returns the result of `func`.
32274 */
32275
32276 function apply(func, thisArg, args) {
32277 switch (args.length) {
32278 case 0:
32279 return func.call(thisArg);
32280
32281 case 1:
32282 return func.call(thisArg, args[0]);
32283
32284 case 2:
32285 return func.call(thisArg, args[0], args[1]);
32286
32287 case 3:
32288 return func.call(thisArg, args[0], args[1], args[2]);
32289 }
32290
32291 return func.apply(thisArg, args);
32292 }
32293 /**
32294 * The base implementation of `_.times` without support for iteratee shorthands
32295 * or max array length checks.
32296 *
32297 * @private
32298 * @param {number} n The number of times to invoke `iteratee`.
32299 * @param {Function} iteratee The function invoked per iteration.
32300 * @returns {Array} Returns the array of results.
32301 */
32302
32303
32304 function baseTimes(n, iteratee) {
32305 var index = -1,
32306 result = Array(n);
32307
32308 while (++index < n) {
32309 result[index] = iteratee(index);
32310 }
32311
32312 return result;
32313 }
32314 /**
32315 * The base implementation of `_.unary` without support for storing metadata.
32316 *
32317 * @private
32318 * @param {Function} func The function to cap arguments for.
32319 * @returns {Function} Returns the new capped function.
32320 */
32321
32322
32323 function baseUnary(func) {
32324 return function (value) {
32325 return func(value);
32326 };
32327 }
32328 /**
32329 * Gets the value at `key` of `object`.
32330 *
32331 * @private
32332 * @param {Object} [object] The object to query.
32333 * @param {string} key The key of the property to get.
32334 * @returns {*} Returns the property value.
32335 */
32336
32337
32338 function getValue(object, key) {
32339 return object == null ? undefined : object[key];
32340 }
32341 /**
32342 * Creates a unary function that invokes `func` with its argument transformed.
32343 *
32344 * @private
32345 * @param {Function} func The function to wrap.
32346 * @param {Function} transform The argument transform.
32347 * @returns {Function} Returns the new function.
32348 */
32349
32350
32351 function overArg(func, transform) {
32352 return function (arg) {
32353 return func(transform(arg));
32354 };
32355 }
32356 /** Used for built-in method references. */
32357
32358
32359 var arrayProto = Array.prototype,
32360 funcProto = Function.prototype,
32361 objectProto = Object.prototype;
32362 /** Used to detect overreaching core-js shims. */
32363
32364 var coreJsData = root['__core-js_shared__'];
32365 /** Used to resolve the decompiled source of functions. */
32366
32367 var funcToString = funcProto.toString;
32368 /** Used to check objects for own properties. */
32369
32370 var hasOwnProperty = objectProto.hasOwnProperty;
32371 /** Used to detect methods masquerading as native. */
32372
32373 var maskSrcKey = function () {
32374 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
32375 return uid ? 'Symbol(src)_1.' + uid : '';
32376 }();
32377 /**
32378 * Used to resolve the
32379 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
32380 * of values.
32381 */
32382
32383
32384 var nativeObjectToString = objectProto.toString;
32385 /** Used to infer the `Object` constructor. */
32386
32387 var objectCtorString = funcToString.call(Object);
32388 /** Used to detect if a method is native. */
32389
32390 var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
32391 /** Built-in value references. */
32392
32393 var Buffer = moduleExports ? root.Buffer : undefined,
32394 Symbol = root.Symbol,
32395 Uint8Array = root.Uint8Array,
32396 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
32397 getPrototype = overArg(Object.getPrototypeOf, Object),
32398 objectCreate = Object.create,
32399 propertyIsEnumerable = objectProto.propertyIsEnumerable,
32400 splice = arrayProto.splice,
32401 symToStringTag = Symbol ? Symbol.toStringTag : undefined;
32402
32403 var defineProperty = function () {
32404 try {
32405 var func = getNative(Object, 'defineProperty');
32406 func({}, '', {});
32407 return func;
32408 } catch (e) {}
32409 }();
32410 /* Built-in method references for those with the same name as other `lodash` methods. */
32411
32412
32413 var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
32414 nativeMax = Math.max,
32415 nativeNow = Date.now;
32416 /* Built-in method references that are verified to be native. */
32417
32418 var Map = getNative(root, 'Map'),
32419 nativeCreate = getNative(Object, 'create');
32420 /**
32421 * The base implementation of `_.create` without support for assigning
32422 * properties to the created object.
32423 *
32424 * @private
32425 * @param {Object} proto The object to inherit from.
32426 * @returns {Object} Returns the new object.
32427 */
32428
32429 var baseCreate = function () {
32430 function object() {}
32431
32432 return function (proto) {
32433 if (!isObject(proto)) {
32434 return {};
32435 }
32436
32437 if (objectCreate) {
32438 return objectCreate(proto);
32439 }
32440
32441 object.prototype = proto;
32442 var result = new object();
32443 object.prototype = undefined;
32444 return result;
32445 };
32446 }();
32447 /**
32448 * Creates a hash object.
32449 *
32450 * @private
32451 * @constructor
32452 * @param {Array} [entries] The key-value pairs to cache.
32453 */
32454
32455
32456 function Hash(entries) {
32457 var index = -1,
32458 length = entries == null ? 0 : entries.length;
32459 this.clear();
32460
32461 while (++index < length) {
32462 var entry = entries[index];
32463 this.set(entry[0], entry[1]);
32464 }
32465 }
32466 /**
32467 * Removes all key-value entries from the hash.
32468 *
32469 * @private
32470 * @name clear
32471 * @memberOf Hash
32472 */
32473
32474
32475 function hashClear() {
32476 this.__data__ = nativeCreate ? nativeCreate(null) : {};
32477 this.size = 0;
32478 }
32479 /**
32480 * Removes `key` and its value from the hash.
32481 *
32482 * @private
32483 * @name delete
32484 * @memberOf Hash
32485 * @param {Object} hash The hash to modify.
32486 * @param {string} key The key of the value to remove.
32487 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
32488 */
32489
32490
32491 function hashDelete(key) {
32492 var result = this.has(key) && delete this.__data__[key];
32493 this.size -= result ? 1 : 0;
32494 return result;
32495 }
32496 /**
32497 * Gets the hash value for `key`.
32498 *
32499 * @private
32500 * @name get
32501 * @memberOf Hash
32502 * @param {string} key The key of the value to get.
32503 * @returns {*} Returns the entry value.
32504 */
32505
32506
32507 function hashGet(key) {
32508 var data = this.__data__;
32509
32510 if (nativeCreate) {
32511 var result = data[key];
32512 return result === HASH_UNDEFINED ? undefined : result;
32513 }
32514
32515 return hasOwnProperty.call(data, key) ? data[key] : undefined;
32516 }
32517 /**
32518 * Checks if a hash value for `key` exists.
32519 *
32520 * @private
32521 * @name has
32522 * @memberOf Hash
32523 * @param {string} key The key of the entry to check.
32524 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
32525 */
32526
32527
32528 function hashHas(key) {
32529 var data = this.__data__;
32530 return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
32531 }
32532 /**
32533 * Sets the hash `key` to `value`.
32534 *
32535 * @private
32536 * @name set
32537 * @memberOf Hash
32538 * @param {string} key The key of the value to set.
32539 * @param {*} value The value to set.
32540 * @returns {Object} Returns the hash instance.
32541 */
32542
32543
32544 function hashSet(key, value) {
32545 var data = this.__data__;
32546 this.size += this.has(key) ? 0 : 1;
32547 data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
32548 return this;
32549 } // Add methods to `Hash`.
32550
32551
32552 Hash.prototype.clear = hashClear;
32553 Hash.prototype['delete'] = hashDelete;
32554 Hash.prototype.get = hashGet;
32555 Hash.prototype.has = hashHas;
32556 Hash.prototype.set = hashSet;
32557 /**
32558 * Creates an list cache object.
32559 *
32560 * @private
32561 * @constructor
32562 * @param {Array} [entries] The key-value pairs to cache.
32563 */
32564
32565 function ListCache(entries) {
32566 var index = -1,
32567 length = entries == null ? 0 : entries.length;
32568 this.clear();
32569
32570 while (++index < length) {
32571 var entry = entries[index];
32572 this.set(entry[0], entry[1]);
32573 }
32574 }
32575 /**
32576 * Removes all key-value entries from the list cache.
32577 *
32578 * @private
32579 * @name clear
32580 * @memberOf ListCache
32581 */
32582
32583
32584 function listCacheClear() {
32585 this.__data__ = [];
32586 this.size = 0;
32587 }
32588 /**
32589 * Removes `key` and its value from the list cache.
32590 *
32591 * @private
32592 * @name delete
32593 * @memberOf ListCache
32594 * @param {string} key The key of the value to remove.
32595 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
32596 */
32597
32598
32599 function listCacheDelete(key) {
32600 var data = this.__data__,
32601 index = assocIndexOf(data, key);
32602
32603 if (index < 0) {
32604 return false;
32605 }
32606
32607 var lastIndex = data.length - 1;
32608
32609 if (index == lastIndex) {
32610 data.pop();
32611 } else {
32612 splice.call(data, index, 1);
32613 }
32614
32615 --this.size;
32616 return true;
32617 }
32618 /**
32619 * Gets the list cache value for `key`.
32620 *
32621 * @private
32622 * @name get
32623 * @memberOf ListCache
32624 * @param {string} key The key of the value to get.
32625 * @returns {*} Returns the entry value.
32626 */
32627
32628
32629 function listCacheGet(key) {
32630 var data = this.__data__,
32631 index = assocIndexOf(data, key);
32632 return index < 0 ? undefined : data[index][1];
32633 }
32634 /**
32635 * Checks if a list cache value for `key` exists.
32636 *
32637 * @private
32638 * @name has
32639 * @memberOf ListCache
32640 * @param {string} key The key of the entry to check.
32641 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
32642 */
32643
32644
32645 function listCacheHas(key) {
32646 return assocIndexOf(this.__data__, key) > -1;
32647 }
32648 /**
32649 * Sets the list cache `key` to `value`.
32650 *
32651 * @private
32652 * @name set
32653 * @memberOf ListCache
32654 * @param {string} key The key of the value to set.
32655 * @param {*} value The value to set.
32656 * @returns {Object} Returns the list cache instance.
32657 */
32658
32659
32660 function listCacheSet(key, value) {
32661 var data = this.__data__,
32662 index = assocIndexOf(data, key);
32663
32664 if (index < 0) {
32665 ++this.size;
32666 data.push([key, value]);
32667 } else {
32668 data[index][1] = value;
32669 }
32670
32671 return this;
32672 } // Add methods to `ListCache`.
32673
32674
32675 ListCache.prototype.clear = listCacheClear;
32676 ListCache.prototype['delete'] = listCacheDelete;
32677 ListCache.prototype.get = listCacheGet;
32678 ListCache.prototype.has = listCacheHas;
32679 ListCache.prototype.set = listCacheSet;
32680 /**
32681 * Creates a map cache object to store key-value pairs.
32682 *
32683 * @private
32684 * @constructor
32685 * @param {Array} [entries] The key-value pairs to cache.
32686 */
32687
32688 function MapCache(entries) {
32689 var index = -1,
32690 length = entries == null ? 0 : entries.length;
32691 this.clear();
32692
32693 while (++index < length) {
32694 var entry = entries[index];
32695 this.set(entry[0], entry[1]);
32696 }
32697 }
32698 /**
32699 * Removes all key-value entries from the map.
32700 *
32701 * @private
32702 * @name clear
32703 * @memberOf MapCache
32704 */
32705
32706
32707 function mapCacheClear() {
32708 this.size = 0;
32709 this.__data__ = {
32710 'hash': new Hash(),
32711 'map': new (Map || ListCache)(),
32712 'string': new Hash()
32713 };
32714 }
32715 /**
32716 * Removes `key` and its value from the map.
32717 *
32718 * @private
32719 * @name delete
32720 * @memberOf MapCache
32721 * @param {string} key The key of the value to remove.
32722 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
32723 */
32724
32725
32726 function mapCacheDelete(key) {
32727 var result = getMapData(this, key)['delete'](key);
32728 this.size -= result ? 1 : 0;
32729 return result;
32730 }
32731 /**
32732 * Gets the map value for `key`.
32733 *
32734 * @private
32735 * @name get
32736 * @memberOf MapCache
32737 * @param {string} key The key of the value to get.
32738 * @returns {*} Returns the entry value.
32739 */
32740
32741
32742 function mapCacheGet(key) {
32743 return getMapData(this, key).get(key);
32744 }
32745 /**
32746 * Checks if a map value for `key` exists.
32747 *
32748 * @private
32749 * @name has
32750 * @memberOf MapCache
32751 * @param {string} key The key of the entry to check.
32752 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
32753 */
32754
32755
32756 function mapCacheHas(key) {
32757 return getMapData(this, key).has(key);
32758 }
32759 /**
32760 * Sets the map `key` to `value`.
32761 *
32762 * @private
32763 * @name set
32764 * @memberOf MapCache
32765 * @param {string} key The key of the value to set.
32766 * @param {*} value The value to set.
32767 * @returns {Object} Returns the map cache instance.
32768 */
32769
32770
32771 function mapCacheSet(key, value) {
32772 var data = getMapData(this, key),
32773 size = data.size;
32774 data.set(key, value);
32775 this.size += data.size == size ? 0 : 1;
32776 return this;
32777 } // Add methods to `MapCache`.
32778
32779
32780 MapCache.prototype.clear = mapCacheClear;
32781 MapCache.prototype['delete'] = mapCacheDelete;
32782 MapCache.prototype.get = mapCacheGet;
32783 MapCache.prototype.has = mapCacheHas;
32784 MapCache.prototype.set = mapCacheSet;
32785 /**
32786 * Creates a stack cache object to store key-value pairs.
32787 *
32788 * @private
32789 * @constructor
32790 * @param {Array} [entries] The key-value pairs to cache.
32791 */
32792
32793 function Stack(entries) {
32794 var data = this.__data__ = new ListCache(entries);
32795 this.size = data.size;
32796 }
32797 /**
32798 * Removes all key-value entries from the stack.
32799 *
32800 * @private
32801 * @name clear
32802 * @memberOf Stack
32803 */
32804
32805
32806 function stackClear() {
32807 this.__data__ = new ListCache();
32808 this.size = 0;
32809 }
32810 /**
32811 * Removes `key` and its value from the stack.
32812 *
32813 * @private
32814 * @name delete
32815 * @memberOf Stack
32816 * @param {string} key The key of the value to remove.
32817 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
32818 */
32819
32820
32821 function stackDelete(key) {
32822 var data = this.__data__,
32823 result = data['delete'](key);
32824 this.size = data.size;
32825 return result;
32826 }
32827 /**
32828 * Gets the stack value for `key`.
32829 *
32830 * @private
32831 * @name get
32832 * @memberOf Stack
32833 * @param {string} key The key of the value to get.
32834 * @returns {*} Returns the entry value.
32835 */
32836
32837
32838 function stackGet(key) {
32839 return this.__data__.get(key);
32840 }
32841 /**
32842 * Checks if a stack value for `key` exists.
32843 *
32844 * @private
32845 * @name has
32846 * @memberOf Stack
32847 * @param {string} key The key of the entry to check.
32848 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
32849 */
32850
32851
32852 function stackHas(key) {
32853 return this.__data__.has(key);
32854 }
32855 /**
32856 * Sets the stack `key` to `value`.
32857 *
32858 * @private
32859 * @name set
32860 * @memberOf Stack
32861 * @param {string} key The key of the value to set.
32862 * @param {*} value The value to set.
32863 * @returns {Object} Returns the stack cache instance.
32864 */
32865
32866
32867 function stackSet(key, value) {
32868 var data = this.__data__;
32869
32870 if (data instanceof ListCache) {
32871 var pairs = data.__data__;
32872
32873 if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
32874 pairs.push([key, value]);
32875 this.size = ++data.size;
32876 return this;
32877 }
32878
32879 data = this.__data__ = new MapCache(pairs);
32880 }
32881
32882 data.set(key, value);
32883 this.size = data.size;
32884 return this;
32885 } // Add methods to `Stack`.
32886
32887
32888 Stack.prototype.clear = stackClear;
32889 Stack.prototype['delete'] = stackDelete;
32890 Stack.prototype.get = stackGet;
32891 Stack.prototype.has = stackHas;
32892 Stack.prototype.set = stackSet;
32893 /**
32894 * Creates an array of the enumerable property names of the array-like `value`.
32895 *
32896 * @private
32897 * @param {*} value The value to query.
32898 * @param {boolean} inherited Specify returning inherited property names.
32899 * @returns {Array} Returns the array of property names.
32900 */
32901
32902 function arrayLikeKeys(value, inherited) {
32903 var isArr = isArray(value),
32904 isArg = !isArr && isArguments(value),
32905 isBuff = !isArr && !isArg && isBuffer(value),
32906 isType = !isArr && !isArg && !isBuff && isTypedArray(value),
32907 skipIndexes = isArr || isArg || isBuff || isType,
32908 result = skipIndexes ? baseTimes(value.length, String) : [],
32909 length = result.length;
32910
32911 for (var key in value) {
32912 if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode.
32913 key == 'length' || // Node.js 0.10 has enumerable non-index properties on buffers.
32914 isBuff && (key == 'offset' || key == 'parent') || // PhantomJS 2 has enumerable non-index properties on typed arrays.
32915 isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || // Skip index properties.
32916 isIndex(key, length)))) {
32917 result.push(key);
32918 }
32919 }
32920
32921 return result;
32922 }
32923 /**
32924 * This function is like `assignValue` except that it doesn't assign
32925 * `undefined` values.
32926 *
32927 * @private
32928 * @param {Object} object The object to modify.
32929 * @param {string} key The key of the property to assign.
32930 * @param {*} value The value to assign.
32931 */
32932
32933
32934 function assignMergeValue(object, key, value) {
32935 if (value !== undefined && !eq(object[key], value) || value === undefined && !(key in object)) {
32936 baseAssignValue(object, key, value);
32937 }
32938 }
32939 /**
32940 * Assigns `value` to `key` of `object` if the existing value is not equivalent
32941 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
32942 * for equality comparisons.
32943 *
32944 * @private
32945 * @param {Object} object The object to modify.
32946 * @param {string} key The key of the property to assign.
32947 * @param {*} value The value to assign.
32948 */
32949
32950
32951 function assignValue(object, key, value) {
32952 var objValue = object[key];
32953
32954 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) {
32955 baseAssignValue(object, key, value);
32956 }
32957 }
32958 /**
32959 * Gets the index at which the `key` is found in `array` of key-value pairs.
32960 *
32961 * @private
32962 * @param {Array} array The array to inspect.
32963 * @param {*} key The key to search for.
32964 * @returns {number} Returns the index of the matched value, else `-1`.
32965 */
32966
32967
32968 function assocIndexOf(array, key) {
32969 var length = array.length;
32970
32971 while (length--) {
32972 if (eq(array[length][0], key)) {
32973 return length;
32974 }
32975 }
32976
32977 return -1;
32978 }
32979 /**
32980 * The base implementation of `assignValue` and `assignMergeValue` without
32981 * value checks.
32982 *
32983 * @private
32984 * @param {Object} object The object to modify.
32985 * @param {string} key The key of the property to assign.
32986 * @param {*} value The value to assign.
32987 */
32988
32989
32990 function baseAssignValue(object, key, value) {
32991 if (key == '__proto__' && defineProperty) {
32992 defineProperty(object, key, {
32993 'configurable': true,
32994 'enumerable': true,
32995 'value': value,
32996 'writable': true
32997 });
32998 } else {
32999 object[key] = value;
33000 }
33001 }
33002 /**
33003 * The base implementation of `baseForOwn` which iterates over `object`
33004 * properties returned by `keysFunc` and invokes `iteratee` for each property.
33005 * Iteratee functions may exit iteration early by explicitly returning `false`.
33006 *
33007 * @private
33008 * @param {Object} object The object to iterate over.
33009 * @param {Function} iteratee The function invoked per iteration.
33010 * @param {Function} keysFunc The function to get the keys of `object`.
33011 * @returns {Object} Returns `object`.
33012 */
33013
33014
33015 var baseFor = createBaseFor();
33016 /**
33017 * The base implementation of `getTag` without fallbacks for buggy environments.
33018 *
33019 * @private
33020 * @param {*} value The value to query.
33021 * @returns {string} Returns the `toStringTag`.
33022 */
33023
33024 function baseGetTag(value) {
33025 if (value == null) {
33026 return value === undefined ? undefinedTag : nullTag;
33027 }
33028
33029 return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
33030 }
33031 /**
33032 * The base implementation of `_.isArguments`.
33033 *
33034 * @private
33035 * @param {*} value The value to check.
33036 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
33037 */
33038
33039
33040 function baseIsArguments(value) {
33041 return isObjectLike(value) && baseGetTag(value) == argsTag;
33042 }
33043 /**
33044 * The base implementation of `_.isNative` without bad shim checks.
33045 *
33046 * @private
33047 * @param {*} value The value to check.
33048 * @returns {boolean} Returns `true` if `value` is a native function,
33049 * else `false`.
33050 */
33051
33052
33053 function baseIsNative(value) {
33054 if (!isObject(value) || isMasked(value)) {
33055 return false;
33056 }
33057
33058 var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
33059 return pattern.test(toSource(value));
33060 }
33061 /**
33062 * The base implementation of `_.isTypedArray` without Node.js optimizations.
33063 *
33064 * @private
33065 * @param {*} value The value to check.
33066 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
33067 */
33068
33069
33070 function baseIsTypedArray(value) {
33071 return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
33072 }
33073 /**
33074 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
33075 *
33076 * @private
33077 * @param {Object} object The object to query.
33078 * @returns {Array} Returns the array of property names.
33079 */
33080
33081
33082 function baseKeysIn(object) {
33083 if (!isObject(object)) {
33084 return nativeKeysIn(object);
33085 }
33086
33087 var isProto = isPrototype(object),
33088 result = [];
33089
33090 for (var key in object) {
33091 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
33092 result.push(key);
33093 }
33094 }
33095
33096 return result;
33097 }
33098 /**
33099 * The base implementation of `_.merge` without support for multiple sources.
33100 *
33101 * @private
33102 * @param {Object} object The destination object.
33103 * @param {Object} source The source object.
33104 * @param {number} srcIndex The index of `source`.
33105 * @param {Function} [customizer] The function to customize merged values.
33106 * @param {Object} [stack] Tracks traversed source values and their merged
33107 * counterparts.
33108 */
33109
33110
33111 function baseMerge(object, source, srcIndex, customizer, stack) {
33112 if (object === source) {
33113 return;
33114 }
33115
33116 baseFor(source, function (srcValue, key) {
33117 stack || (stack = new Stack());
33118
33119 if (isObject(srcValue)) {
33120 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
33121 } else {
33122 var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + '', object, source, stack) : undefined;
33123
33124 if (newValue === undefined) {
33125 newValue = srcValue;
33126 }
33127
33128 assignMergeValue(object, key, newValue);
33129 }
33130 }, keysIn);
33131 }
33132 /**
33133 * A specialized version of `baseMerge` for arrays and objects which performs
33134 * deep merges and tracks traversed objects enabling objects with circular
33135 * references to be merged.
33136 *
33137 * @private
33138 * @param {Object} object The destination object.
33139 * @param {Object} source The source object.
33140 * @param {string} key The key of the value to merge.
33141 * @param {number} srcIndex The index of `source`.
33142 * @param {Function} mergeFunc The function to merge values.
33143 * @param {Function} [customizer] The function to customize assigned values.
33144 * @param {Object} [stack] Tracks traversed source values and their merged
33145 * counterparts.
33146 */
33147
33148
33149 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
33150 var objValue = safeGet(object, key),
33151 srcValue = safeGet(source, key),
33152 stacked = stack.get(srcValue);
33153
33154 if (stacked) {
33155 assignMergeValue(object, key, stacked);
33156 return;
33157 }
33158
33159 var newValue = customizer ? customizer(objValue, srcValue, key + '', object, source, stack) : undefined;
33160 var isCommon = newValue === undefined;
33161
33162 if (isCommon) {
33163 var isArr = isArray(srcValue),
33164 isBuff = !isArr && isBuffer(srcValue),
33165 isTyped = !isArr && !isBuff && isTypedArray(srcValue);
33166 newValue = srcValue;
33167
33168 if (isArr || isBuff || isTyped) {
33169 if (isArray(objValue)) {
33170 newValue = objValue;
33171 } else if (isArrayLikeObject(objValue)) {
33172 newValue = copyArray(objValue);
33173 } else if (isBuff) {
33174 isCommon = false;
33175 newValue = cloneBuffer(srcValue, true);
33176 } else if (isTyped) {
33177 isCommon = false;
33178 newValue = cloneTypedArray(srcValue, true);
33179 } else {
33180 newValue = [];
33181 }
33182 } else if (isPlainObject(srcValue) || isArguments(srcValue)) {
33183 newValue = objValue;
33184
33185 if (isArguments(objValue)) {
33186 newValue = toPlainObject(objValue);
33187 } else if (!isObject(objValue) || isFunction(objValue)) {
33188 newValue = initCloneObject(srcValue);
33189 }
33190 } else {
33191 isCommon = false;
33192 }
33193 }
33194
33195 if (isCommon) {
33196 // Recursively merge objects and arrays (susceptible to call stack limits).
33197 stack.set(srcValue, newValue);
33198 mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
33199 stack['delete'](srcValue);
33200 }
33201
33202 assignMergeValue(object, key, newValue);
33203 }
33204 /**
33205 * The base implementation of `_.rest` which doesn't validate or coerce arguments.
33206 *
33207 * @private
33208 * @param {Function} func The function to apply a rest parameter to.
33209 * @param {number} [start=func.length-1] The start position of the rest parameter.
33210 * @returns {Function} Returns the new function.
33211 */
33212
33213
33214 function baseRest(func, start) {
33215 return setToString(overRest(func, start, identity), func + '');
33216 }
33217 /**
33218 * The base implementation of `setToString` without support for hot loop shorting.
33219 *
33220 * @private
33221 * @param {Function} func The function to modify.
33222 * @param {Function} string The `toString` result.
33223 * @returns {Function} Returns `func`.
33224 */
33225
33226
33227 var baseSetToString = !defineProperty ? identity : function (func, string) {
33228 return defineProperty(func, 'toString', {
33229 'configurable': true,
33230 'enumerable': false,
33231 'value': constant(string),
33232 'writable': true
33233 });
33234 };
33235 /**
33236 * Creates a clone of `buffer`.
33237 *
33238 * @private
33239 * @param {Buffer} buffer The buffer to clone.
33240 * @param {boolean} [isDeep] Specify a deep clone.
33241 * @returns {Buffer} Returns the cloned buffer.
33242 */
33243
33244 function cloneBuffer(buffer, isDeep) {
33245 if (isDeep) {
33246 return buffer.slice();
33247 }
33248
33249 var length = buffer.length,
33250 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
33251 buffer.copy(result);
33252 return result;
33253 }
33254 /**
33255 * Creates a clone of `arrayBuffer`.
33256 *
33257 * @private
33258 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
33259 * @returns {ArrayBuffer} Returns the cloned array buffer.
33260 */
33261
33262
33263 function cloneArrayBuffer(arrayBuffer) {
33264 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
33265 new Uint8Array(result).set(new Uint8Array(arrayBuffer));
33266 return result;
33267 }
33268 /**
33269 * Creates a clone of `typedArray`.
33270 *
33271 * @private
33272 * @param {Object} typedArray The typed array to clone.
33273 * @param {boolean} [isDeep] Specify a deep clone.
33274 * @returns {Object} Returns the cloned typed array.
33275 */
33276
33277
33278 function cloneTypedArray(typedArray, isDeep) {
33279 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
33280 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
33281 }
33282 /**
33283 * Copies the values of `source` to `array`.
33284 *
33285 * @private
33286 * @param {Array} source The array to copy values from.
33287 * @param {Array} [array=[]] The array to copy values to.
33288 * @returns {Array} Returns `array`.
33289 */
33290
33291
33292 function copyArray(source, array) {
33293 var index = -1,
33294 length = source.length;
33295 array || (array = Array(length));
33296
33297 while (++index < length) {
33298 array[index] = source[index];
33299 }
33300
33301 return array;
33302 }
33303 /**
33304 * Copies properties of `source` to `object`.
33305 *
33306 * @private
33307 * @param {Object} source The object to copy properties from.
33308 * @param {Array} props The property identifiers to copy.
33309 * @param {Object} [object={}] The object to copy properties to.
33310 * @param {Function} [customizer] The function to customize copied values.
33311 * @returns {Object} Returns `object`.
33312 */
33313
33314
33315 function copyObject(source, props, object, customizer) {
33316 var isNew = !object;
33317 object || (object = {});
33318 var index = -1,
33319 length = props.length;
33320
33321 while (++index < length) {
33322 var key = props[index];
33323 var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined;
33324
33325 if (newValue === undefined) {
33326 newValue = source[key];
33327 }
33328
33329 if (isNew) {
33330 baseAssignValue(object, key, newValue);
33331 } else {
33332 assignValue(object, key, newValue);
33333 }
33334 }
33335
33336 return object;
33337 }
33338 /**
33339 * Creates a function like `_.assign`.
33340 *
33341 * @private
33342 * @param {Function} assigner The function to assign values.
33343 * @returns {Function} Returns the new assigner function.
33344 */
33345
33346
33347 function createAssigner(assigner) {
33348 return baseRest(function (object, sources) {
33349 var index = -1,
33350 length = sources.length,
33351 customizer = length > 1 ? sources[length - 1] : undefined,
33352 guard = length > 2 ? sources[2] : undefined;
33353 customizer = assigner.length > 3 && typeof customizer == 'function' ? (length--, customizer) : undefined;
33354
33355 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
33356 customizer = length < 3 ? undefined : customizer;
33357 length = 1;
33358 }
33359
33360 object = Object(object);
33361
33362 while (++index < length) {
33363 var source = sources[index];
33364
33365 if (source) {
33366 assigner(object, source, index, customizer);
33367 }
33368 }
33369
33370 return object;
33371 });
33372 }
33373 /**
33374 * Creates a base function for methods like `_.forIn` and `_.forOwn`.
33375 *
33376 * @private
33377 * @param {boolean} [fromRight] Specify iterating from right to left.
33378 * @returns {Function} Returns the new base function.
33379 */
33380
33381
33382 function createBaseFor(fromRight) {
33383 return function (object, iteratee, keysFunc) {
33384 var index = -1,
33385 iterable = Object(object),
33386 props = keysFunc(object),
33387 length = props.length;
33388
33389 while (length--) {
33390 var key = props[fromRight ? length : ++index];
33391
33392 if (iteratee(iterable[key], key, iterable) === false) {
33393 break;
33394 }
33395 }
33396
33397 return object;
33398 };
33399 }
33400 /**
33401 * Gets the data for `map`.
33402 *
33403 * @private
33404 * @param {Object} map The map to query.
33405 * @param {string} key The reference key.
33406 * @returns {*} Returns the map data.
33407 */
33408
33409
33410 function getMapData(map, key) {
33411 var data = map.__data__;
33412 return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
33413 }
33414 /**
33415 * Gets the native function at `key` of `object`.
33416 *
33417 * @private
33418 * @param {Object} object The object to query.
33419 * @param {string} key The key of the method to get.
33420 * @returns {*} Returns the function if it's native, else `undefined`.
33421 */
33422
33423
33424 function getNative(object, key) {
33425 var value = getValue(object, key);
33426 return baseIsNative(value) ? value : undefined;
33427 }
33428 /**
33429 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
33430 *
33431 * @private
33432 * @param {*} value The value to query.
33433 * @returns {string} Returns the raw `toStringTag`.
33434 */
33435
33436
33437 function getRawTag(value) {
33438 var isOwn = hasOwnProperty.call(value, symToStringTag),
33439 tag = value[symToStringTag];
33440
33441 try {
33442 value[symToStringTag] = undefined;
33443 var unmasked = true;
33444 } catch (e) {}
33445
33446 var result = nativeObjectToString.call(value);
33447
33448 if (unmasked) {
33449 if (isOwn) {
33450 value[symToStringTag] = tag;
33451 } else {
33452 delete value[symToStringTag];
33453 }
33454 }
33455
33456 return result;
33457 }
33458 /**
33459 * Initializes an object clone.
33460 *
33461 * @private
33462 * @param {Object} object The object to clone.
33463 * @returns {Object} Returns the initialized clone.
33464 */
33465
33466
33467 function initCloneObject(object) {
33468 return typeof object.constructor == 'function' && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
33469 }
33470 /**
33471 * Checks if `value` is a valid array-like index.
33472 *
33473 * @private
33474 * @param {*} value The value to check.
33475 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
33476 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
33477 */
33478
33479
33480 function isIndex(value, length) {
33481 var type = typeof value;
33482 length = length == null ? MAX_SAFE_INTEGER : length;
33483 return !!length && (type == 'number' || type != 'symbol' && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
33484 }
33485 /**
33486 * Checks if the given arguments are from an iteratee call.
33487 *
33488 * @private
33489 * @param {*} value The potential iteratee value argument.
33490 * @param {*} index The potential iteratee index or key argument.
33491 * @param {*} object The potential iteratee object argument.
33492 * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
33493 * else `false`.
33494 */
33495
33496
33497 function isIterateeCall(value, index, object) {
33498 if (!isObject(object)) {
33499 return false;
33500 }
33501
33502 var type = typeof index;
33503
33504 if (type == 'number' ? isArrayLike(object) && isIndex(index, object.length) : type == 'string' && index in object) {
33505 return eq(object[index], value);
33506 }
33507
33508 return false;
33509 }
33510 /**
33511 * Checks if `value` is suitable for use as unique object key.
33512 *
33513 * @private
33514 * @param {*} value The value to check.
33515 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
33516 */
33517
33518
33519 function isKeyable(value) {
33520 var type = typeof value;
33521 return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
33522 }
33523 /**
33524 * Checks if `func` has its source masked.
33525 *
33526 * @private
33527 * @param {Function} func The function to check.
33528 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
33529 */
33530
33531
33532 function isMasked(func) {
33533 return !!maskSrcKey && maskSrcKey in func;
33534 }
33535 /**
33536 * Checks if `value` is likely a prototype object.
33537 *
33538 * @private
33539 * @param {*} value The value to check.
33540 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
33541 */
33542
33543
33544 function isPrototype(value) {
33545 var Ctor = value && value.constructor,
33546 proto = typeof Ctor == 'function' && Ctor.prototype || objectProto;
33547 return value === proto;
33548 }
33549 /**
33550 * This function is like
33551 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
33552 * except that it includes inherited enumerable properties.
33553 *
33554 * @private
33555 * @param {Object} object The object to query.
33556 * @returns {Array} Returns the array of property names.
33557 */
33558
33559
33560 function nativeKeysIn(object) {
33561 var result = [];
33562
33563 if (object != null) {
33564 for (var key in Object(object)) {
33565 result.push(key);
33566 }
33567 }
33568
33569 return result;
33570 }
33571 /**
33572 * Converts `value` to a string using `Object.prototype.toString`.
33573 *
33574 * @private
33575 * @param {*} value The value to convert.
33576 * @returns {string} Returns the converted string.
33577 */
33578
33579
33580 function objectToString(value) {
33581 return nativeObjectToString.call(value);
33582 }
33583 /**
33584 * A specialized version of `baseRest` which transforms the rest array.
33585 *
33586 * @private
33587 * @param {Function} func The function to apply a rest parameter to.
33588 * @param {number} [start=func.length-1] The start position of the rest parameter.
33589 * @param {Function} transform The rest array transform.
33590 * @returns {Function} Returns the new function.
33591 */
33592
33593
33594 function overRest(func, start, transform) {
33595 start = nativeMax(start === undefined ? func.length - 1 : start, 0);
33596 return function () {
33597 var args = arguments,
33598 index = -1,
33599 length = nativeMax(args.length - start, 0),
33600 array = Array(length);
33601
33602 while (++index < length) {
33603 array[index] = args[start + index];
33604 }
33605
33606 index = -1;
33607 var otherArgs = Array(start + 1);
33608
33609 while (++index < start) {
33610 otherArgs[index] = args[index];
33611 }
33612
33613 otherArgs[start] = transform(array);
33614 return apply(func, this, otherArgs);
33615 };
33616 }
33617 /**
33618 * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
33619 *
33620 * @private
33621 * @param {Object} object The object to query.
33622 * @param {string} key The key of the property to get.
33623 * @returns {*} Returns the property value.
33624 */
33625
33626
33627 function safeGet(object, key) {
33628 if (key === 'constructor' && typeof object[key] === 'function') {
33629 return;
33630 }
33631
33632 if (key == '__proto__') {
33633 return;
33634 }
33635
33636 return object[key];
33637 }
33638 /**
33639 * Sets the `toString` method of `func` to return `string`.
33640 *
33641 * @private
33642 * @param {Function} func The function to modify.
33643 * @param {Function} string The `toString` result.
33644 * @returns {Function} Returns `func`.
33645 */
33646
33647
33648 var setToString = shortOut(baseSetToString);
33649 /**
33650 * Creates a function that'll short out and invoke `identity` instead
33651 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
33652 * milliseconds.
33653 *
33654 * @private
33655 * @param {Function} func The function to restrict.
33656 * @returns {Function} Returns the new shortable function.
33657 */
33658
33659 function shortOut(func) {
33660 var count = 0,
33661 lastCalled = 0;
33662 return function () {
33663 var stamp = nativeNow(),
33664 remaining = HOT_SPAN - (stamp - lastCalled);
33665 lastCalled = stamp;
33666
33667 if (remaining > 0) {
33668 if (++count >= HOT_COUNT) {
33669 return arguments[0];
33670 }
33671 } else {
33672 count = 0;
33673 }
33674
33675 return func.apply(undefined, arguments);
33676 };
33677 }
33678 /**
33679 * Converts `func` to its source code.
33680 *
33681 * @private
33682 * @param {Function} func The function to convert.
33683 * @returns {string} Returns the source code.
33684 */
33685
33686
33687 function toSource(func) {
33688 if (func != null) {
33689 try {
33690 return funcToString.call(func);
33691 } catch (e) {}
33692
33693 try {
33694 return func + '';
33695 } catch (e) {}
33696 }
33697
33698 return '';
33699 }
33700 /**
33701 * Performs a
33702 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
33703 * comparison between two values to determine if they are equivalent.
33704 *
33705 * @static
33706 * @memberOf _
33707 * @since 4.0.0
33708 * @category Lang
33709 * @param {*} value The value to compare.
33710 * @param {*} other The other value to compare.
33711 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
33712 * @example
33713 *
33714 * var object = { 'a': 1 };
33715 * var other = { 'a': 1 };
33716 *
33717 * _.eq(object, object);
33718 * // => true
33719 *
33720 * _.eq(object, other);
33721 * // => false
33722 *
33723 * _.eq('a', 'a');
33724 * // => true
33725 *
33726 * _.eq('a', Object('a'));
33727 * // => false
33728 *
33729 * _.eq(NaN, NaN);
33730 * // => true
33731 */
33732
33733
33734 function eq(value, other) {
33735 return value === other || value !== value && other !== other;
33736 }
33737 /**
33738 * Checks if `value` is likely an `arguments` object.
33739 *
33740 * @static
33741 * @memberOf _
33742 * @since 0.1.0
33743 * @category Lang
33744 * @param {*} value The value to check.
33745 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
33746 * else `false`.
33747 * @example
33748 *
33749 * _.isArguments(function() { return arguments; }());
33750 * // => true
33751 *
33752 * _.isArguments([1, 2, 3]);
33753 * // => false
33754 */
33755
33756
33757 var isArguments = baseIsArguments(function () {
33758 return arguments;
33759 }()) ? baseIsArguments : function (value) {
33760 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
33761 };
33762 /**
33763 * Checks if `value` is classified as an `Array` object.
33764 *
33765 * @static
33766 * @memberOf _
33767 * @since 0.1.0
33768 * @category Lang
33769 * @param {*} value The value to check.
33770 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
33771 * @example
33772 *
33773 * _.isArray([1, 2, 3]);
33774 * // => true
33775 *
33776 * _.isArray(document.body.children);
33777 * // => false
33778 *
33779 * _.isArray('abc');
33780 * // => false
33781 *
33782 * _.isArray(_.noop);
33783 * // => false
33784 */
33785
33786 var isArray = Array.isArray;
33787 /**
33788 * Checks if `value` is array-like. A value is considered array-like if it's
33789 * not a function and has a `value.length` that's an integer greater than or
33790 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
33791 *
33792 * @static
33793 * @memberOf _
33794 * @since 4.0.0
33795 * @category Lang
33796 * @param {*} value The value to check.
33797 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
33798 * @example
33799 *
33800 * _.isArrayLike([1, 2, 3]);
33801 * // => true
33802 *
33803 * _.isArrayLike(document.body.children);
33804 * // => true
33805 *
33806 * _.isArrayLike('abc');
33807 * // => true
33808 *
33809 * _.isArrayLike(_.noop);
33810 * // => false
33811 */
33812
33813 function isArrayLike(value) {
33814 return value != null && isLength(value.length) && !isFunction(value);
33815 }
33816 /**
33817 * This method is like `_.isArrayLike` except that it also checks if `value`
33818 * is an object.
33819 *
33820 * @static
33821 * @memberOf _
33822 * @since 4.0.0
33823 * @category Lang
33824 * @param {*} value The value to check.
33825 * @returns {boolean} Returns `true` if `value` is an array-like object,
33826 * else `false`.
33827 * @example
33828 *
33829 * _.isArrayLikeObject([1, 2, 3]);
33830 * // => true
33831 *
33832 * _.isArrayLikeObject(document.body.children);
33833 * // => true
33834 *
33835 * _.isArrayLikeObject('abc');
33836 * // => false
33837 *
33838 * _.isArrayLikeObject(_.noop);
33839 * // => false
33840 */
33841
33842
33843 function isArrayLikeObject(value) {
33844 return isObjectLike(value) && isArrayLike(value);
33845 }
33846 /**
33847 * Checks if `value` is a buffer.
33848 *
33849 * @static
33850 * @memberOf _
33851 * @since 4.3.0
33852 * @category Lang
33853 * @param {*} value The value to check.
33854 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
33855 * @example
33856 *
33857 * _.isBuffer(new Buffer(2));
33858 * // => true
33859 *
33860 * _.isBuffer(new Uint8Array(2));
33861 * // => false
33862 */
33863
33864
33865 var isBuffer = nativeIsBuffer || stubFalse;
33866 /**
33867 * Checks if `value` is classified as a `Function` object.
33868 *
33869 * @static
33870 * @memberOf _
33871 * @since 0.1.0
33872 * @category Lang
33873 * @param {*} value The value to check.
33874 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
33875 * @example
33876 *
33877 * _.isFunction(_);
33878 * // => true
33879 *
33880 * _.isFunction(/abc/);
33881 * // => false
33882 */
33883
33884 function isFunction(value) {
33885 if (!isObject(value)) {
33886 return false;
33887 } // The use of `Object#toString` avoids issues with the `typeof` operator
33888 // in Safari 9 which returns 'object' for typed arrays and other constructors.
33889
33890
33891 var tag = baseGetTag(value);
33892 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
33893 }
33894 /**
33895 * Checks if `value` is a valid array-like length.
33896 *
33897 * **Note:** This method is loosely based on
33898 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
33899 *
33900 * @static
33901 * @memberOf _
33902 * @since 4.0.0
33903 * @category Lang
33904 * @param {*} value The value to check.
33905 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
33906 * @example
33907 *
33908 * _.isLength(3);
33909 * // => true
33910 *
33911 * _.isLength(Number.MIN_VALUE);
33912 * // => false
33913 *
33914 * _.isLength(Infinity);
33915 * // => false
33916 *
33917 * _.isLength('3');
33918 * // => false
33919 */
33920
33921
33922 function isLength(value) {
33923 return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
33924 }
33925 /**
33926 * Checks if `value` is the
33927 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
33928 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
33929 *
33930 * @static
33931 * @memberOf _
33932 * @since 0.1.0
33933 * @category Lang
33934 * @param {*} value The value to check.
33935 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
33936 * @example
33937 *
33938 * _.isObject({});
33939 * // => true
33940 *
33941 * _.isObject([1, 2, 3]);
33942 * // => true
33943 *
33944 * _.isObject(_.noop);
33945 * // => true
33946 *
33947 * _.isObject(null);
33948 * // => false
33949 */
33950
33951
33952 function isObject(value) {
33953 var type = typeof value;
33954 return value != null && (type == 'object' || type == 'function');
33955 }
33956 /**
33957 * Checks if `value` is object-like. A value is object-like if it's not `null`
33958 * and has a `typeof` result of "object".
33959 *
33960 * @static
33961 * @memberOf _
33962 * @since 4.0.0
33963 * @category Lang
33964 * @param {*} value The value to check.
33965 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
33966 * @example
33967 *
33968 * _.isObjectLike({});
33969 * // => true
33970 *
33971 * _.isObjectLike([1, 2, 3]);
33972 * // => true
33973 *
33974 * _.isObjectLike(_.noop);
33975 * // => false
33976 *
33977 * _.isObjectLike(null);
33978 * // => false
33979 */
33980
33981
33982 function isObjectLike(value) {
33983 return value != null && typeof value == 'object';
33984 }
33985 /**
33986 * Checks if `value` is a plain object, that is, an object created by the
33987 * `Object` constructor or one with a `[[Prototype]]` of `null`.
33988 *
33989 * @static
33990 * @memberOf _
33991 * @since 0.8.0
33992 * @category Lang
33993 * @param {*} value The value to check.
33994 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
33995 * @example
33996 *
33997 * function Foo() {
33998 * this.a = 1;
33999 * }
34000 *
34001 * _.isPlainObject(new Foo);
34002 * // => false
34003 *
34004 * _.isPlainObject([1, 2, 3]);
34005 * // => false
34006 *
34007 * _.isPlainObject({ 'x': 0, 'y': 0 });
34008 * // => true
34009 *
34010 * _.isPlainObject(Object.create(null));
34011 * // => true
34012 */
34013
34014
34015 function isPlainObject(value) {
34016 if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
34017 return false;
34018 }
34019
34020 var proto = getPrototype(value);
34021
34022 if (proto === null) {
34023 return true;
34024 }
34025
34026 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
34027 return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
34028 }
34029 /**
34030 * Checks if `value` is classified as a typed array.
34031 *
34032 * @static
34033 * @memberOf _
34034 * @since 3.0.0
34035 * @category Lang
34036 * @param {*} value The value to check.
34037 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
34038 * @example
34039 *
34040 * _.isTypedArray(new Uint8Array);
34041 * // => true
34042 *
34043 * _.isTypedArray([]);
34044 * // => false
34045 */
34046
34047
34048 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
34049 /**
34050 * Converts `value` to a plain object flattening inherited enumerable string
34051 * keyed properties of `value` to own properties of the plain object.
34052 *
34053 * @static
34054 * @memberOf _
34055 * @since 3.0.0
34056 * @category Lang
34057 * @param {*} value The value to convert.
34058 * @returns {Object} Returns the converted plain object.
34059 * @example
34060 *
34061 * function Foo() {
34062 * this.b = 2;
34063 * }
34064 *
34065 * Foo.prototype.c = 3;
34066 *
34067 * _.assign({ 'a': 1 }, new Foo);
34068 * // => { 'a': 1, 'b': 2 }
34069 *
34070 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
34071 * // => { 'a': 1, 'b': 2, 'c': 3 }
34072 */
34073
34074 function toPlainObject(value) {
34075 return copyObject(value, keysIn(value));
34076 }
34077 /**
34078 * Creates an array of the own and inherited enumerable property names of `object`.
34079 *
34080 * **Note:** Non-object values are coerced to objects.
34081 *
34082 * @static
34083 * @memberOf _
34084 * @since 3.0.0
34085 * @category Object
34086 * @param {Object} object The object to query.
34087 * @returns {Array} Returns the array of property names.
34088 * @example
34089 *
34090 * function Foo() {
34091 * this.a = 1;
34092 * this.b = 2;
34093 * }
34094 *
34095 * Foo.prototype.c = 3;
34096 *
34097 * _.keysIn(new Foo);
34098 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
34099 */
34100
34101
34102 function keysIn(object) {
34103 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
34104 }
34105 /**
34106 * This method is like `_.assign` except that it recursively merges own and
34107 * inherited enumerable string keyed properties of source objects into the
34108 * destination object. Source properties that resolve to `undefined` are
34109 * skipped if a destination value exists. Array and plain object properties
34110 * are merged recursively. Other objects and value types are overridden by
34111 * assignment. Source objects are applied from left to right. Subsequent
34112 * sources overwrite property assignments of previous sources.
34113 *
34114 * **Note:** This method mutates `object`.
34115 *
34116 * @static
34117 * @memberOf _
34118 * @since 0.5.0
34119 * @category Object
34120 * @param {Object} object The destination object.
34121 * @param {...Object} [sources] The source objects.
34122 * @returns {Object} Returns `object`.
34123 * @example
34124 *
34125 * var object = {
34126 * 'a': [{ 'b': 2 }, { 'd': 4 }]
34127 * };
34128 *
34129 * var other = {
34130 * 'a': [{ 'c': 3 }, { 'e': 5 }]
34131 * };
34132 *
34133 * _.merge(object, other);
34134 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
34135 */
34136
34137
34138 var merge = createAssigner(function (object, source, srcIndex) {
34139 baseMerge(object, source, srcIndex);
34140 });
34141 /**
34142 * Creates a function that returns `value`.
34143 *
34144 * @static
34145 * @memberOf _
34146 * @since 2.4.0
34147 * @category Util
34148 * @param {*} value The value to return from the new function.
34149 * @returns {Function} Returns the new constant function.
34150 * @example
34151 *
34152 * var objects = _.times(2, _.constant({ 'a': 1 }));
34153 *
34154 * console.log(objects);
34155 * // => [{ 'a': 1 }, { 'a': 1 }]
34156 *
34157 * console.log(objects[0] === objects[1]);
34158 * // => true
34159 */
34160
34161 function constant(value) {
34162 return function () {
34163 return value;
34164 };
34165 }
34166 /**
34167 * This method returns the first argument it receives.
34168 *
34169 * @static
34170 * @since 0.1.0
34171 * @memberOf _
34172 * @category Util
34173 * @param {*} value Any value.
34174 * @returns {*} Returns `value`.
34175 * @example
34176 *
34177 * var object = { 'a': 1 };
34178 *
34179 * console.log(_.identity(object) === object);
34180 * // => true
34181 */
34182
34183
34184 function identity(value) {
34185 return value;
34186 }
34187 /**
34188 * This method returns `false`.
34189 *
34190 * @static
34191 * @memberOf _
34192 * @since 4.13.0
34193 * @category Util
34194 * @returns {boolean} Returns `false`.
34195 * @example
34196 *
34197 * _.times(2, _.stubFalse);
34198 * // => [false, false]
34199 */
34200
34201
34202 function stubFalse() {
34203 return false;
34204 }
34205
34206 module.exports = merge;
34207
34208 /***/ }),
34209 /* 443 */
34210 /***/ ((module) => {
34211
34212 "use strict";
34213 module.exports = JSON.parse('{"name":"eslint","version":"8.3.0","author":"Nicholas C. Zakas <nicholas+npm@nczconsulting.com>","description":"An AST-based pattern checker for JavaScript.","bin":{"eslint":"./bin/eslint.js"},"main":"./lib/api.js","exports":{"./package.json":"./package.json",".":"./lib/api.js","./use-at-your-own-risk":"./lib/unsupported-api.js"},"scripts":{"test":"node Makefile.js test","test:cli":"mocha","lint":"node Makefile.js lint","fix":"node Makefile.js lint -- fix","fuzz":"node Makefile.js fuzz","generate-release":"node Makefile.js generateRelease","generate-alpharelease":"node Makefile.js generatePrerelease -- alpha","generate-betarelease":"node Makefile.js generatePrerelease -- beta","generate-rcrelease":"node Makefile.js generatePrerelease -- rc","publish-release":"node Makefile.js publishRelease","gensite":"node Makefile.js gensite","webpack":"node Makefile.js webpack","perf":"node Makefile.js perf"},"gitHooks":{"pre-commit":"lint-staged"},"lint-staged":{"*.js":"eslint --fix","*.md":"markdownlint"},"files":["LICENSE","README.md","bin","conf","lib","messages"],"repository":"eslint/eslint","funding":"https://opencollective.com/eslint","homepage":"https://eslint.org","bugs":"https://github.com/eslint/eslint/issues/","dependencies":{"@eslint/eslintrc":"^1.0.4","@humanwhocodes/config-array":"^0.6.0","ajv":"^6.10.0","chalk":"^4.0.0","cross-spawn":"^7.0.2","debug":"^4.3.2","doctrine":"^3.0.0","enquirer":"^2.3.5","escape-string-regexp":"^4.0.0","eslint-scope":"^7.1.0","eslint-utils":"^3.0.0","eslint-visitor-keys":"^3.1.0","espree":"^9.1.0","esquery":"^1.4.0","esutils":"^2.0.2","fast-deep-equal":"^3.1.3","file-entry-cache":"^6.0.1","functional-red-black-tree":"^1.0.1","glob-parent":"^6.0.1","globals":"^13.6.0","ignore":"^4.0.6","import-fresh":"^3.0.0","imurmurhash":"^0.1.4","is-glob":"^4.0.0","js-yaml":"^4.1.0","json-stable-stringify-without-jsonify":"^1.0.1","levn":"^0.4.1","lodash.merge":"^4.6.2","minimatch":"^3.0.4","natural-compare":"^1.4.0","optionator":"^0.9.1","progress":"^2.0.0","regexpp":"^3.2.0","semver":"^7.2.1","strip-ansi":"^6.0.1","strip-json-comments":"^3.1.0","text-table":"^0.2.0","v8-compile-cache":"^2.0.3"},"devDependencies":{"@babel/core":"^7.4.3","@babel/preset-env":"^7.4.3","babel-loader":"^8.0.5","chai":"^4.0.1","cheerio":"^0.22.0","common-tags":"^1.8.0","core-js":"^3.1.3","dateformat":"^4.5.1","ejs":"^3.0.2","eslint":"file:.","eslint-config-eslint":"file:packages/eslint-config-eslint","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-eslint-plugin":"^4.0.1","eslint-plugin-internal-rules":"file:tools/internal-rules","eslint-plugin-jsdoc":"^37.0.0","eslint-plugin-node":"^11.1.0","eslint-release":"^3.2.0","eslump":"^3.0.0","esprima":"^4.0.1","fs-teardown":"^0.1.3","glob":"^7.1.6","jsdoc":"^3.5.5","karma":"^6.1.1","karma-chrome-launcher":"^3.1.0","karma-mocha":"^2.0.1","karma-mocha-reporter":"^2.2.5","karma-webpack":"^5.0.0","lint-staged":"^11.0.0","load-perf":"^0.2.0","markdownlint":"^0.23.1","markdownlint-cli":"^0.28.1","memfs":"^3.0.1","mocha":"^8.3.2","mocha-junit-reporter":"^2.0.0","node-polyfill-webpack-plugin":"^1.0.3","npm-license":"^0.3.3","nyc":"^15.0.1","proxyquire":"^2.0.1","puppeteer":"^9.1.1","recast":"^0.20.4","regenerator-runtime":"^0.13.2","shelljs":"^0.8.2","sinon":"^11.0.0","temp":"^0.9.0","webpack":"^5.23.0","webpack-cli":"^4.5.0","yorkie":"^2.0.0"},"keywords":["ast","lint","javascript","ecmascript","espree"],"license":"MIT","engines":{"node":"^12.22.0 || ^14.17.0 || >=16.0.0"}}');
34214
34215 /***/ }),
34216 /* 444 */
34217 /***/ ((module) => {
34218
34219 "use strict";
34220 /**
34221 * @fileoverview Common utils for AST.
34222 *
34223 * This file contains only shared items for core and rules.
34224 * If you make a utility for rules, please see `../rules/utils/ast-utils.js`.
34225 *
34226 * @author Toru Nagashima <https://github.com/mysticatea>
34227 */
34228
34229
34230 const breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/u;
34231 const lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u;
34232 const shebangPattern = /^#!([^\r\n]+)/u;
34233 /**
34234 * Creates a version of the `lineBreakPattern` regex with the global flag.
34235 * Global regexes are mutable, so this needs to be a function instead of a constant.
34236 * @returns {RegExp} A global regular expression that matches line terminators
34237 */
34238
34239 function createGlobalLinebreakMatcher() {
34240 return new RegExp(lineBreakPattern.source, "gu");
34241 }
34242
34243 module.exports = {
34244 breakableTypePattern,
34245 lineBreakPattern,
34246 createGlobalLinebreakMatcher,
34247 shebangPattern
34248 };
34249
34250 /***/ }),
34251 /* 445 */
34252 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
34253
34254 "use strict";
34255 /* provided dependency */ var process = __webpack_require__(494);
34256
34257
34258 Object.defineProperty(exports, "__esModule", ({ value: true }));
34259
34260 var util = __webpack_require__(439);
34261 var path = __webpack_require__(429);
34262 var Ajv = __webpack_require__(446);
34263 var globals = __webpack_require__(492);
34264
34265 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
34266
34267 var util__default = /*#__PURE__*/_interopDefaultLegacy(util);
34268 var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
34269 var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);
34270 var globals__default = /*#__PURE__*/_interopDefaultLegacy(globals);
34271
34272 /**
34273 * @fileoverview Config file operations. This file must be usable in the browser,
34274 * so no Node-specific code can be here.
34275 * @author Nicholas C. Zakas
34276 */
34277
34278 //------------------------------------------------------------------------------
34279 // Private
34280 //------------------------------------------------------------------------------
34281
34282 const RULE_SEVERITY_STRINGS = ["off", "warn", "error"],
34283 RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce((map, value, index) => {
34284 map[value] = index;
34285 return map;
34286 }, {}),
34287 VALID_SEVERITIES = [0, 1, 2, "off", "warn", "error"];
34288
34289 //------------------------------------------------------------------------------
34290 // Public Interface
34291 //------------------------------------------------------------------------------
34292
34293 /**
34294 * Normalizes the severity value of a rule's configuration to a number
34295 * @param {(number|string|[number, ...*]|[string, ...*])} ruleConfig A rule's configuration value, generally
34296 * received from the user. A valid config value is either 0, 1, 2, the string "off" (treated the same as 0),
34297 * the string "warn" (treated the same as 1), the string "error" (treated the same as 2), or an array
34298 * whose first element is one of the above values. Strings are matched case-insensitively.
34299 * @returns {(0|1|2)} The numeric severity value if the config value was valid, otherwise 0.
34300 */
34301 function getRuleSeverity(ruleConfig) {
34302 const severityValue = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
34303
34304 if (severityValue === 0 || severityValue === 1 || severityValue === 2) {
34305 return severityValue;
34306 }
34307
34308 if (typeof severityValue === "string") {
34309 return RULE_SEVERITY[severityValue.toLowerCase()] || 0;
34310 }
34311
34312 return 0;
34313 }
34314
34315 /**
34316 * Converts old-style severity settings (0, 1, 2) into new-style
34317 * severity settings (off, warn, error) for all rules. Assumption is that severity
34318 * values have already been validated as correct.
34319 * @param {Object} config The config object to normalize.
34320 * @returns {void}
34321 */
34322 function normalizeToStrings(config) {
34323
34324 if (config.rules) {
34325 Object.keys(config.rules).forEach(ruleId => {
34326 const ruleConfig = config.rules[ruleId];
34327
34328 if (typeof ruleConfig === "number") {
34329 config.rules[ruleId] = RULE_SEVERITY_STRINGS[ruleConfig] || RULE_SEVERITY_STRINGS[0];
34330 } else if (Array.isArray(ruleConfig) && typeof ruleConfig[0] === "number") {
34331 ruleConfig[0] = RULE_SEVERITY_STRINGS[ruleConfig[0]] || RULE_SEVERITY_STRINGS[0];
34332 }
34333 });
34334 }
34335 }
34336
34337 /**
34338 * Determines if the severity for the given rule configuration represents an error.
34339 * @param {int|string|Array} ruleConfig The configuration for an individual rule.
34340 * @returns {boolean} True if the rule represents an error, false if not.
34341 */
34342 function isErrorSeverity(ruleConfig) {
34343 return getRuleSeverity(ruleConfig) === 2;
34344 }
34345
34346 /**
34347 * Checks whether a given config has valid severity or not.
34348 * @param {number|string|Array} ruleConfig The configuration for an individual rule.
34349 * @returns {boolean} `true` if the configuration has valid severity.
34350 */
34351 function isValidSeverity(ruleConfig) {
34352 let severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
34353
34354 if (typeof severity === "string") {
34355 severity = severity.toLowerCase();
34356 }
34357 return VALID_SEVERITIES.indexOf(severity) !== -1;
34358 }
34359
34360 /**
34361 * Checks whether every rule of a given config has valid severity or not.
34362 * @param {Object} config The configuration for rules.
34363 * @returns {boolean} `true` if the configuration has valid severity.
34364 */
34365 function isEverySeverityValid(config) {
34366 return Object.keys(config).every(ruleId => isValidSeverity(config[ruleId]));
34367 }
34368
34369 /**
34370 * Normalizes a value for a global in a config
34371 * @param {(boolean|string|null)} configuredValue The value given for a global in configuration or in
34372 * a global directive comment
34373 * @returns {("readable"|"writeable"|"off")} The value normalized as a string
34374 * @throws Error if global value is invalid
34375 */
34376 function normalizeConfigGlobal(configuredValue) {
34377 switch (configuredValue) {
34378 case "off":
34379 return "off";
34380
34381 case true:
34382 case "true":
34383 case "writeable":
34384 case "writable":
34385 return "writable";
34386
34387 case null:
34388 case false:
34389 case "false":
34390 case "readable":
34391 case "readonly":
34392 return "readonly";
34393
34394 default:
34395 throw new Error(`'${configuredValue}' is not a valid configuration for a global (use 'readonly', 'writable', or 'off')`);
34396 }
34397 }
34398
34399 var ConfigOps = {
34400 __proto__: null,
34401 getRuleSeverity: getRuleSeverity,
34402 normalizeToStrings: normalizeToStrings,
34403 isErrorSeverity: isErrorSeverity,
34404 isValidSeverity: isValidSeverity,
34405 isEverySeverityValid: isEverySeverityValid,
34406 normalizeConfigGlobal: normalizeConfigGlobal
34407 };
34408
34409 /**
34410 * @fileoverview Provide the function that emits deprecation warnings.
34411 * @author Toru Nagashima <http://github.com/mysticatea>
34412 */
34413
34414 //------------------------------------------------------------------------------
34415 // Private
34416 //------------------------------------------------------------------------------
34417
34418 // Defitions for deprecation warnings.
34419 const deprecationWarningMessages = {
34420 ESLINT_LEGACY_ECMAFEATURES:
34421 "The 'ecmaFeatures' config file property is deprecated and has no effect.",
34422 ESLINT_PERSONAL_CONFIG_LOAD:
34423 "'~/.eslintrc.*' config files have been deprecated. " +
34424 "Please use a config file per project or the '--config' option.",
34425 ESLINT_PERSONAL_CONFIG_SUPPRESS:
34426 "'~/.eslintrc.*' config files have been deprecated. " +
34427 "Please remove it or add 'root:true' to the config files in your " +
34428 "projects in order to avoid loading '~/.eslintrc.*' accidentally."
34429 };
34430
34431 const sourceFileErrorCache = new Set();
34432
34433 /**
34434 * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted
34435 * for each unique file path, but repeated invocations with the same file path have no effect.
34436 * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active.
34437 * @param {string} source The name of the configuration source to report the warning for.
34438 * @param {string} errorCode The warning message to show.
34439 * @returns {void}
34440 */
34441 function emitDeprecationWarning(source, errorCode) {
34442 const cacheKey = JSON.stringify({ source, errorCode });
34443
34444 if (sourceFileErrorCache.has(cacheKey)) {
34445 return;
34446 }
34447 sourceFileErrorCache.add(cacheKey);
34448
34449 const rel = path__default["default"].relative(process.cwd(), source);
34450 const message = deprecationWarningMessages[errorCode];
34451
34452 process.emitWarning(
34453 `${message} (found in "${rel}")`,
34454 "DeprecationWarning",
34455 errorCode
34456 );
34457 }
34458
34459 /**
34460 * @fileoverview The instance of Ajv validator.
34461 * @author Evgeny Poberezkin
34462 */
34463
34464 //-----------------------------------------------------------------------------
34465 // Helpers
34466 //-----------------------------------------------------------------------------
34467
34468 /*
34469 * Copied from ajv/lib/refs/json-schema-draft-04.json
34470 * The MIT License (MIT)
34471 * Copyright (c) 2015-2017 Evgeny Poberezkin
34472 */
34473 const metaSchema = {
34474 id: "http://json-schema.org/draft-04/schema#",
34475 $schema: "http://json-schema.org/draft-04/schema#",
34476 description: "Core schema meta-schema",
34477 definitions: {
34478 schemaArray: {
34479 type: "array",
34480 minItems: 1,
34481 items: { $ref: "#" }
34482 },
34483 positiveInteger: {
34484 type: "integer",
34485 minimum: 0
34486 },
34487 positiveIntegerDefault0: {
34488 allOf: [{ $ref: "#/definitions/positiveInteger" }, { default: 0 }]
34489 },
34490 simpleTypes: {
34491 enum: ["array", "boolean", "integer", "null", "number", "object", "string"]
34492 },
34493 stringArray: {
34494 type: "array",
34495 items: { type: "string" },
34496 minItems: 1,
34497 uniqueItems: true
34498 }
34499 },
34500 type: "object",
34501 properties: {
34502 id: {
34503 type: "string"
34504 },
34505 $schema: {
34506 type: "string"
34507 },
34508 title: {
34509 type: "string"
34510 },
34511 description: {
34512 type: "string"
34513 },
34514 default: { },
34515 multipleOf: {
34516 type: "number",
34517 minimum: 0,
34518 exclusiveMinimum: true
34519 },
34520 maximum: {
34521 type: "number"
34522 },
34523 exclusiveMaximum: {
34524 type: "boolean",
34525 default: false
34526 },
34527 minimum: {
34528 type: "number"
34529 },
34530 exclusiveMinimum: {
34531 type: "boolean",
34532 default: false
34533 },
34534 maxLength: { $ref: "#/definitions/positiveInteger" },
34535 minLength: { $ref: "#/definitions/positiveIntegerDefault0" },
34536 pattern: {
34537 type: "string",
34538 format: "regex"
34539 },
34540 additionalItems: {
34541 anyOf: [
34542 { type: "boolean" },
34543 { $ref: "#" }
34544 ],
34545 default: { }
34546 },
34547 items: {
34548 anyOf: [
34549 { $ref: "#" },
34550 { $ref: "#/definitions/schemaArray" }
34551 ],
34552 default: { }
34553 },
34554 maxItems: { $ref: "#/definitions/positiveInteger" },
34555 minItems: { $ref: "#/definitions/positiveIntegerDefault0" },
34556 uniqueItems: {
34557 type: "boolean",
34558 default: false
34559 },
34560 maxProperties: { $ref: "#/definitions/positiveInteger" },
34561 minProperties: { $ref: "#/definitions/positiveIntegerDefault0" },
34562 required: { $ref: "#/definitions/stringArray" },
34563 additionalProperties: {
34564 anyOf: [
34565 { type: "boolean" },
34566 { $ref: "#" }
34567 ],
34568 default: { }
34569 },
34570 definitions: {
34571 type: "object",
34572 additionalProperties: { $ref: "#" },
34573 default: { }
34574 },
34575 properties: {
34576 type: "object",
34577 additionalProperties: { $ref: "#" },
34578 default: { }
34579 },
34580 patternProperties: {
34581 type: "object",
34582 additionalProperties: { $ref: "#" },
34583 default: { }
34584 },
34585 dependencies: {
34586 type: "object",
34587 additionalProperties: {
34588 anyOf: [
34589 { $ref: "#" },
34590 { $ref: "#/definitions/stringArray" }
34591 ]
34592 }
34593 },
34594 enum: {
34595 type: "array",
34596 minItems: 1,
34597 uniqueItems: true
34598 },
34599 type: {
34600 anyOf: [
34601 { $ref: "#/definitions/simpleTypes" },
34602 {
34603 type: "array",
34604 items: { $ref: "#/definitions/simpleTypes" },
34605 minItems: 1,
34606 uniqueItems: true
34607 }
34608 ]
34609 },
34610 format: { type: "string" },
34611 allOf: { $ref: "#/definitions/schemaArray" },
34612 anyOf: { $ref: "#/definitions/schemaArray" },
34613 oneOf: { $ref: "#/definitions/schemaArray" },
34614 not: { $ref: "#" }
34615 },
34616 dependencies: {
34617 exclusiveMaximum: ["maximum"],
34618 exclusiveMinimum: ["minimum"]
34619 },
34620 default: { }
34621 };
34622
34623 //------------------------------------------------------------------------------
34624 // Public Interface
34625 //------------------------------------------------------------------------------
34626
34627 var ajvOrig = (additionalOptions = {}) => {
34628 const ajv = new Ajv__default["default"]({
34629 meta: false,
34630 useDefaults: true,
34631 validateSchema: false,
34632 missingRefs: "ignore",
34633 verbose: true,
34634 schemaId: "auto",
34635 ...additionalOptions
34636 });
34637
34638 ajv.addMetaSchema(metaSchema);
34639 // eslint-disable-next-line no-underscore-dangle
34640 ajv._opts.defaultMeta = metaSchema.id;
34641
34642 return ajv;
34643 };
34644
34645 /**
34646 * @fileoverview Defines a schema for configs.
34647 * @author Sylvan Mably
34648 */
34649
34650 const baseConfigProperties = {
34651 $schema: { type: "string" },
34652 env: { type: "object" },
34653 extends: { $ref: "#/definitions/stringOrStrings" },
34654 globals: { type: "object" },
34655 overrides: {
34656 type: "array",
34657 items: { $ref: "#/definitions/overrideConfig" },
34658 additionalItems: false
34659 },
34660 parser: { type: ["string", "null"] },
34661 parserOptions: { type: "object" },
34662 plugins: { type: "array" },
34663 processor: { type: "string" },
34664 rules: { type: "object" },
34665 settings: { type: "object" },
34666 noInlineConfig: { type: "boolean" },
34667 reportUnusedDisableDirectives: { type: "boolean" },
34668
34669 ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
34670 };
34671
34672 const configSchema = {
34673 definitions: {
34674 stringOrStrings: {
34675 oneOf: [
34676 { type: "string" },
34677 {
34678 type: "array",
34679 items: { type: "string" },
34680 additionalItems: false
34681 }
34682 ]
34683 },
34684 stringOrStringsRequired: {
34685 oneOf: [
34686 { type: "string" },
34687 {
34688 type: "array",
34689 items: { type: "string" },
34690 additionalItems: false,
34691 minItems: 1
34692 }
34693 ]
34694 },
34695
34696 // Config at top-level.
34697 objectConfig: {
34698 type: "object",
34699 properties: {
34700 root: { type: "boolean" },
34701 ignorePatterns: { $ref: "#/definitions/stringOrStrings" },
34702 ...baseConfigProperties
34703 },
34704 additionalProperties: false
34705 },
34706
34707 // Config in `overrides`.
34708 overrideConfig: {
34709 type: "object",
34710 properties: {
34711 excludedFiles: { $ref: "#/definitions/stringOrStrings" },
34712 files: { $ref: "#/definitions/stringOrStringsRequired" },
34713 ...baseConfigProperties
34714 },
34715 required: ["files"],
34716 additionalProperties: false
34717 }
34718 },
34719
34720 $ref: "#/definitions/objectConfig"
34721 };
34722
34723 /**
34724 * @fileoverview Defines environment settings and globals.
34725 * @author Elan Shanker
34726 */
34727
34728 //------------------------------------------------------------------------------
34729 // Helpers
34730 //------------------------------------------------------------------------------
34731
34732 /**
34733 * Get the object that has difference.
34734 * @param {Record<string,boolean>} current The newer object.
34735 * @param {Record<string,boolean>} prev The older object.
34736 * @returns {Record<string,boolean>} The difference object.
34737 */
34738 function getDiff(current, prev) {
34739 const retv = {};
34740
34741 for (const [key, value] of Object.entries(current)) {
34742 if (!Object.hasOwnProperty.call(prev, key)) {
34743 retv[key] = value;
34744 }
34745 }
34746
34747 return retv;
34748 }
34749
34750 const newGlobals2015 = getDiff(globals__default["default"].es2015, globals__default["default"].es5); // 19 variables such as Promise, Map, ...
34751 const newGlobals2017 = {
34752 Atomics: false,
34753 SharedArrayBuffer: false
34754 };
34755 const newGlobals2020 = {
34756 BigInt: false,
34757 BigInt64Array: false,
34758 BigUint64Array: false,
34759 globalThis: false
34760 };
34761
34762 const newGlobals2021 = {
34763 AggregateError: false,
34764 FinalizationRegistry: false,
34765 WeakRef: false
34766 };
34767
34768 //------------------------------------------------------------------------------
34769 // Public Interface
34770 //------------------------------------------------------------------------------
34771
34772 /** @type {Map<string, import("../lib/shared/types").Environment>} */
34773 var environments = new Map(Object.entries({
34774
34775 // Language
34776 builtin: {
34777 globals: globals__default["default"].es5
34778 },
34779 es6: {
34780 globals: newGlobals2015,
34781 parserOptions: {
34782 ecmaVersion: 6
34783 }
34784 },
34785 es2015: {
34786 globals: newGlobals2015,
34787 parserOptions: {
34788 ecmaVersion: 6
34789 }
34790 },
34791 es2017: {
34792 globals: { ...newGlobals2015, ...newGlobals2017 },
34793 parserOptions: {
34794 ecmaVersion: 8
34795 }
34796 },
34797 es2020: {
34798 globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020 },
34799 parserOptions: {
34800 ecmaVersion: 11
34801 }
34802 },
34803 es2021: {
34804 globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 },
34805 parserOptions: {
34806 ecmaVersion: 12
34807 }
34808 },
34809
34810 // Platforms
34811 browser: {
34812 globals: globals__default["default"].browser
34813 },
34814 node: {
34815 globals: globals__default["default"].node,
34816 parserOptions: {
34817 ecmaFeatures: {
34818 globalReturn: true
34819 }
34820 }
34821 },
34822 "shared-node-browser": {
34823 globals: globals__default["default"]["shared-node-browser"]
34824 },
34825 worker: {
34826 globals: globals__default["default"].worker
34827 },
34828 serviceworker: {
34829 globals: globals__default["default"].serviceworker
34830 },
34831
34832 // Frameworks
34833 commonjs: {
34834 globals: globals__default["default"].commonjs,
34835 parserOptions: {
34836 ecmaFeatures: {
34837 globalReturn: true
34838 }
34839 }
34840 },
34841 amd: {
34842 globals: globals__default["default"].amd
34843 },
34844 mocha: {
34845 globals: globals__default["default"].mocha
34846 },
34847 jasmine: {
34848 globals: globals__default["default"].jasmine
34849 },
34850 jest: {
34851 globals: globals__default["default"].jest
34852 },
34853 phantomjs: {
34854 globals: globals__default["default"].phantomjs
34855 },
34856 jquery: {
34857 globals: globals__default["default"].jquery
34858 },
34859 qunit: {
34860 globals: globals__default["default"].qunit
34861 },
34862 prototypejs: {
34863 globals: globals__default["default"].prototypejs
34864 },
34865 shelljs: {
34866 globals: globals__default["default"].shelljs
34867 },
34868 meteor: {
34869 globals: globals__default["default"].meteor
34870 },
34871 mongo: {
34872 globals: globals__default["default"].mongo
34873 },
34874 protractor: {
34875 globals: globals__default["default"].protractor
34876 },
34877 applescript: {
34878 globals: globals__default["default"].applescript
34879 },
34880 nashorn: {
34881 globals: globals__default["default"].nashorn
34882 },
34883 atomtest: {
34884 globals: globals__default["default"].atomtest
34885 },
34886 embertest: {
34887 globals: globals__default["default"].embertest
34888 },
34889 webextensions: {
34890 globals: globals__default["default"].webextensions
34891 },
34892 greasemonkey: {
34893 globals: globals__default["default"].greasemonkey
34894 }
34895 }));
34896
34897 /**
34898 * @fileoverview Validates configs.
34899 * @author Brandon Mills
34900 */
34901
34902 const ajv = ajvOrig();
34903
34904 const ruleValidators = new WeakMap();
34905 const noop = Function.prototype;
34906
34907 //------------------------------------------------------------------------------
34908 // Private
34909 //------------------------------------------------------------------------------
34910 let validateSchema;
34911 const severityMap = {
34912 error: 2,
34913 warn: 1,
34914 off: 0
34915 };
34916
34917 const validated = new WeakSet();
34918
34919 //-----------------------------------------------------------------------------
34920 // Exports
34921 //-----------------------------------------------------------------------------
34922
34923 class ConfigValidator {
34924 constructor({ builtInRules = new Map() } = {}) {
34925 this.builtInRules = builtInRules;
34926 }
34927
34928 /**
34929 * Gets a complete options schema for a rule.
34930 * @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
34931 * @returns {Object} JSON Schema for the rule's options.
34932 */
34933 getRuleOptionsSchema(rule) {
34934 if (!rule) {
34935 return null;
34936 }
34937
34938 const schema = rule.schema || rule.meta && rule.meta.schema;
34939
34940 // Given a tuple of schemas, insert warning level at the beginning
34941 if (Array.isArray(schema)) {
34942 if (schema.length) {
34943 return {
34944 type: "array",
34945 items: schema,
34946 minItems: 0,
34947 maxItems: schema.length
34948 };
34949 }
34950 return {
34951 type: "array",
34952 minItems: 0,
34953 maxItems: 0
34954 };
34955
34956 }
34957
34958 // Given a full schema, leave it alone
34959 return schema || null;
34960 }
34961
34962 /**
34963 * Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
34964 * @param {options} options The given options for the rule.
34965 * @returns {number|string} The rule's severity value
34966 */
34967 validateRuleSeverity(options) {
34968 const severity = Array.isArray(options) ? options[0] : options;
34969 const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity;
34970
34971 if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) {
34972 return normSeverity;
34973 }
34974
34975 throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util__default["default"].inspect(severity).replace(/'/gu, "\"").replace(/\n/gu, "")}').\n`);
34976
34977 }
34978
34979 /**
34980 * Validates the non-severity options passed to a rule, based on its schema.
34981 * @param {{create: Function}} rule The rule to validate
34982 * @param {Array} localOptions The options for the rule, excluding severity
34983 * @returns {void}
34984 */
34985 validateRuleSchema(rule, localOptions) {
34986 if (!ruleValidators.has(rule)) {
34987 const schema = this.getRuleOptionsSchema(rule);
34988
34989 if (schema) {
34990 ruleValidators.set(rule, ajv.compile(schema));
34991 }
34992 }
34993
34994 const validateRule = ruleValidators.get(rule);
34995
34996 if (validateRule) {
34997 validateRule(localOptions);
34998 if (validateRule.errors) {
34999 throw new Error(validateRule.errors.map(
35000 error => `\tValue ${JSON.stringify(error.data)} ${error.message}.\n`
35001 ).join(""));
35002 }
35003 }
35004 }
35005
35006 /**
35007 * Validates a rule's options against its schema.
35008 * @param {{create: Function}|null} rule The rule that the config is being validated for
35009 * @param {string} ruleId The rule's unique name.
35010 * @param {Array|number} options The given options for the rule.
35011 * @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
35012 * no source is prepended to the message.
35013 * @returns {void}
35014 */
35015 validateRuleOptions(rule, ruleId, options, source = null) {
35016 try {
35017 const severity = this.validateRuleSeverity(options);
35018
35019 if (severity !== 0) {
35020 this.validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
35021 }
35022 } catch (err) {
35023 const enhancedMessage = `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
35024
35025 if (typeof source === "string") {
35026 throw new Error(`${source}:\n\t${enhancedMessage}`);
35027 } else {
35028 throw new Error(enhancedMessage);
35029 }
35030 }
35031 }
35032
35033 /**
35034 * Validates an environment object
35035 * @param {Object} environment The environment config object to validate.
35036 * @param {string} source The name of the configuration source to report in any errors.
35037 * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments.
35038 * @returns {void}
35039 */
35040 validateEnvironment(
35041 environment,
35042 source,
35043 getAdditionalEnv = noop
35044 ) {
35045
35046 // not having an environment is ok
35047 if (!environment) {
35048 return;
35049 }
35050
35051 Object.keys(environment).forEach(id => {
35052 const env = getAdditionalEnv(id) || environments.get(id) || null;
35053
35054 if (!env) {
35055 const message = `${source}:\n\tEnvironment key "${id}" is unknown\n`;
35056
35057 throw new Error(message);
35058 }
35059 });
35060 }
35061
35062 /**
35063 * Validates a rules config object
35064 * @param {Object} rulesConfig The rules config object to validate.
35065 * @param {string} source The name of the configuration source to report in any errors.
35066 * @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules
35067 * @returns {void}
35068 */
35069 validateRules(
35070 rulesConfig,
35071 source,
35072 getAdditionalRule = noop
35073 ) {
35074 if (!rulesConfig) {
35075 return;
35076 }
35077
35078 Object.keys(rulesConfig).forEach(id => {
35079 const rule = getAdditionalRule(id) || this.builtInRules.get(id) || null;
35080
35081 this.validateRuleOptions(rule, id, rulesConfig[id], source);
35082 });
35083 }
35084
35085 /**
35086 * Validates a `globals` section of a config file
35087 * @param {Object} globalsConfig The `globals` section
35088 * @param {string|null} source The name of the configuration source to report in the event of an error.
35089 * @returns {void}
35090 */
35091 validateGlobals(globalsConfig, source = null) {
35092 if (!globalsConfig) {
35093 return;
35094 }
35095
35096 Object.entries(globalsConfig)
35097 .forEach(([configuredGlobal, configuredValue]) => {
35098 try {
35099 normalizeConfigGlobal(configuredValue);
35100 } catch (err) {
35101 throw new Error(`ESLint configuration of global '${configuredGlobal}' in ${source} is invalid:\n${err.message}`);
35102 }
35103 });
35104 }
35105
35106 /**
35107 * Validate `processor` configuration.
35108 * @param {string|undefined} processorName The processor name.
35109 * @param {string} source The name of config file.
35110 * @param {function(id:string): Processor} getProcessor The getter of defined processors.
35111 * @returns {void}
35112 */
35113 validateProcessor(processorName, source, getProcessor) {
35114 if (processorName && !getProcessor(processorName)) {
35115 throw new Error(`ESLint configuration of processor in '${source}' is invalid: '${processorName}' was not found.`);
35116 }
35117 }
35118
35119 /**
35120 * Formats an array of schema validation errors.
35121 * @param {Array} errors An array of error messages to format.
35122 * @returns {string} Formatted error message
35123 */
35124 formatErrors(errors) {
35125 return errors.map(error => {
35126 if (error.keyword === "additionalProperties") {
35127 const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty;
35128
35129 return `Unexpected top-level property "${formattedPropertyPath}"`;
35130 }
35131 if (error.keyword === "type") {
35132 const formattedField = error.dataPath.slice(1);
35133 const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema;
35134 const formattedValue = JSON.stringify(error.data);
35135
35136 return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`;
35137 }
35138
35139 const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath;
35140
35141 return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`;
35142 }).map(message => `\t- ${message}.\n`).join("");
35143 }
35144
35145 /**
35146 * Validates the top level properties of the config object.
35147 * @param {Object} config The config object to validate.
35148 * @param {string} source The name of the configuration source to report in any errors.
35149 * @returns {void}
35150 */
35151 validateConfigSchema(config, source = null) {
35152 validateSchema = validateSchema || ajv.compile(configSchema);
35153
35154 if (!validateSchema(config)) {
35155 throw new Error(`ESLint configuration in ${source} is invalid:\n${this.formatErrors(validateSchema.errors)}`);
35156 }
35157
35158 if (Object.hasOwnProperty.call(config, "ecmaFeatures")) {
35159 emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES");
35160 }
35161 }
35162
35163 /**
35164 * Validates an entire config object.
35165 * @param {Object} config The config object to validate.
35166 * @param {string} source The name of the configuration source to report in any errors.
35167 * @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules.
35168 * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs.
35169 * @returns {void}
35170 */
35171 validate(config, source, getAdditionalRule, getAdditionalEnv) {
35172 this.validateConfigSchema(config, source);
35173 this.validateRules(config.rules, source, getAdditionalRule);
35174 this.validateEnvironment(config.env, source, getAdditionalEnv);
35175 this.validateGlobals(config.globals, source);
35176
35177 for (const override of config.overrides || []) {
35178 this.validateRules(override.rules, source, getAdditionalRule);
35179 this.validateEnvironment(override.env, source, getAdditionalEnv);
35180 this.validateGlobals(config.globals, source);
35181 }
35182 }
35183
35184 /**
35185 * Validate config array object.
35186 * @param {ConfigArray} configArray The config array to validate.
35187 * @returns {void}
35188 */
35189 validateConfigArray(configArray) {
35190 const getPluginEnv = Map.prototype.get.bind(configArray.pluginEnvironments);
35191 const getPluginProcessor = Map.prototype.get.bind(configArray.pluginProcessors);
35192 const getPluginRule = Map.prototype.get.bind(configArray.pluginRules);
35193
35194 // Validate.
35195 for (const element of configArray) {
35196 if (validated.has(element)) {
35197 continue;
35198 }
35199 validated.add(element);
35200
35201 this.validateEnvironment(element.env, element.name, getPluginEnv);
35202 this.validateGlobals(element.globals, element.name);
35203 this.validateProcessor(element.processor, element.name, getPluginProcessor);
35204 this.validateRules(element.rules, element.name, getPluginRule);
35205 }
35206 }
35207
35208 }
35209
35210 /**
35211 * @fileoverview Common helpers for naming of plugins, formatters and configs
35212 */
35213
35214 const NAMESPACE_REGEX = /^@.*\//iu;
35215
35216 /**
35217 * Brings package name to correct format based on prefix
35218 * @param {string} name The name of the package.
35219 * @param {string} prefix Can be either "eslint-plugin", "eslint-config" or "eslint-formatter"
35220 * @returns {string} Normalized name of the package
35221 * @private
35222 */
35223 function normalizePackageName(name, prefix) {
35224 let normalizedName = name;
35225
35226 /**
35227 * On Windows, name can come in with Windows slashes instead of Unix slashes.
35228 * Normalize to Unix first to avoid errors later on.
35229 * https://github.com/eslint/eslint/issues/5644
35230 */
35231 if (normalizedName.includes("\\")) {
35232 normalizedName = normalizedName.replace(/\\/gu, "/");
35233 }
35234
35235 if (normalizedName.charAt(0) === "@") {
35236
35237 /**
35238 * it's a scoped package
35239 * package name is the prefix, or just a username
35240 */
35241 const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, "u"),
35242 scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`, "u");
35243
35244 if (scopedPackageShortcutRegex.test(normalizedName)) {
35245 normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`);
35246 } else if (!scopedPackageNameRegex.test(normalizedName.split("/")[1])) {
35247
35248 /**
35249 * for scoped packages, insert the prefix after the first / unless
35250 * the path is already @scope/eslint or @scope/eslint-xxx-yyy
35251 */
35252 normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, `@$1/${prefix}-$2`);
35253 }
35254 } else if (!normalizedName.startsWith(`${prefix}-`)) {
35255 normalizedName = `${prefix}-${normalizedName}`;
35256 }
35257
35258 return normalizedName;
35259 }
35260
35261 /**
35262 * Removes the prefix from a fullname.
35263 * @param {string} fullname The term which may have the prefix.
35264 * @param {string} prefix The prefix to remove.
35265 * @returns {string} The term without prefix.
35266 */
35267 function getShorthandName(fullname, prefix) {
35268 if (fullname[0] === "@") {
35269 let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, "u").exec(fullname);
35270
35271 if (matchResult) {
35272 return matchResult[1];
35273 }
35274
35275 matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`, "u").exec(fullname);
35276 if (matchResult) {
35277 return `${matchResult[1]}/${matchResult[2]}`;
35278 }
35279 } else if (fullname.startsWith(`${prefix}-`)) {
35280 return fullname.slice(prefix.length + 1);
35281 }
35282
35283 return fullname;
35284 }
35285
35286 /**
35287 * Gets the scope (namespace) of a term.
35288 * @param {string} term The term which may have the namespace.
35289 * @returns {string} The namespace of the term if it has one.
35290 */
35291 function getNamespaceFromTerm(term) {
35292 const match = term.match(NAMESPACE_REGEX);
35293
35294 return match ? match[0] : "";
35295 }
35296
35297 var naming = {
35298 __proto__: null,
35299 normalizePackageName: normalizePackageName,
35300 getShorthandName: getShorthandName,
35301 getNamespaceFromTerm: getNamespaceFromTerm
35302 };
35303
35304 /**
35305 * @fileoverview Package exports for @eslint/eslintrc
35306 * @author Nicholas C. Zakas
35307 */
35308
35309 //-----------------------------------------------------------------------------
35310 // Exports
35311 //-----------------------------------------------------------------------------
35312
35313 const Legacy = {
35314 environments,
35315
35316 // shared
35317 ConfigOps,
35318 ConfigValidator,
35319 naming
35320 };
35321
35322 exports.Legacy = Legacy;
35323 //# sourceMappingURL=eslintrc-universal.cjs.map
35324
35325
35326 /***/ }),
35327 /* 446 */
35328 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
35329
35330 "use strict";
35331 /* provided dependency */ var console = __webpack_require__(438);
35332
35333
35334 var compileSchema = __webpack_require__(447),
35335 resolve = __webpack_require__(448),
35336 Cache = __webpack_require__(458),
35337 SchemaObject = __webpack_require__(453),
35338 stableStringify = __webpack_require__(456),
35339 formats = __webpack_require__(459),
35340 rules = __webpack_require__(460),
35341 $dataMetaSchema = __webpack_require__(485),
35342 util = __webpack_require__(451);
35343
35344 module.exports = Ajv;
35345 Ajv.prototype.validate = validate;
35346 Ajv.prototype.compile = compile;
35347 Ajv.prototype.addSchema = addSchema;
35348 Ajv.prototype.addMetaSchema = addMetaSchema;
35349 Ajv.prototype.validateSchema = validateSchema;
35350 Ajv.prototype.getSchema = getSchema;
35351 Ajv.prototype.removeSchema = removeSchema;
35352 Ajv.prototype.addFormat = addFormat;
35353 Ajv.prototype.errorsText = errorsText;
35354 Ajv.prototype._addSchema = _addSchema;
35355 Ajv.prototype._compile = _compile;
35356 Ajv.prototype.compileAsync = __webpack_require__(486);
35357
35358 var customKeyword = __webpack_require__(487);
35359
35360 Ajv.prototype.addKeyword = customKeyword.add;
35361 Ajv.prototype.getKeyword = customKeyword.get;
35362 Ajv.prototype.removeKeyword = customKeyword.remove;
35363 Ajv.prototype.validateKeyword = customKeyword.validate;
35364
35365 var errorClasses = __webpack_require__(455);
35366
35367 Ajv.ValidationError = errorClasses.Validation;
35368 Ajv.MissingRefError = errorClasses.MissingRef;
35369 Ajv.$dataMetaSchema = $dataMetaSchema;
35370 var META_SCHEMA_ID = 'http://json-schema.org/draft-07/schema';
35371 var META_IGNORE_OPTIONS = ['removeAdditional', 'useDefaults', 'coerceTypes', 'strictDefaults'];
35372 var META_SUPPORT_DATA = ['/properties'];
35373 /**
35374 * Creates validator instance.
35375 * Usage: `Ajv(opts)`
35376 * @param {Object} opts optional options
35377 * @return {Object} ajv instance
35378 */
35379
35380 function Ajv(opts) {
35381 if (!(this instanceof Ajv)) return new Ajv(opts);
35382 opts = this._opts = util.copy(opts) || {};
35383 setLogger(this);
35384 this._schemas = {};
35385 this._refs = {};
35386 this._fragments = {};
35387 this._formats = formats(opts.format);
35388 this._cache = opts.cache || new Cache();
35389 this._loadingSchemas = {};
35390 this._compilations = [];
35391 this.RULES = rules();
35392 this._getId = chooseGetId(opts);
35393 opts.loopRequired = opts.loopRequired || Infinity;
35394 if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true;
35395 if (opts.serialize === undefined) opts.serialize = stableStringify;
35396 this._metaOpts = getMetaSchemaOptions(this);
35397 if (opts.formats) addInitialFormats(this);
35398 if (opts.keywords) addInitialKeywords(this);
35399 addDefaultMetaSchema(this);
35400 if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
35401 if (opts.nullable) this.addKeyword('nullable', {
35402 metaSchema: {
35403 type: 'boolean'
35404 }
35405 });
35406 addInitialSchemas(this);
35407 }
35408 /**
35409 * Validate data using schema
35410 * Schema will be compiled and cached (using serialized JSON as key. [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize.
35411 * @this Ajv
35412 * @param {String|Object} schemaKeyRef key, ref or schema object
35413 * @param {Any} data to be validated
35414 * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
35415 */
35416
35417
35418 function validate(schemaKeyRef, data) {
35419 var v;
35420
35421 if (typeof schemaKeyRef == 'string') {
35422 v = this.getSchema(schemaKeyRef);
35423 if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
35424 } else {
35425 var schemaObj = this._addSchema(schemaKeyRef);
35426
35427 v = schemaObj.validate || this._compile(schemaObj);
35428 }
35429
35430 var valid = v(data);
35431 if (v.$async !== true) this.errors = v.errors;
35432 return valid;
35433 }
35434 /**
35435 * Create validating function for passed schema.
35436 * @this Ajv
35437 * @param {Object} schema schema object
35438 * @param {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords.
35439 * @return {Function} validating function
35440 */
35441
35442
35443 function compile(schema, _meta) {
35444 var schemaObj = this._addSchema(schema, undefined, _meta);
35445
35446 return schemaObj.validate || this._compile(schemaObj);
35447 }
35448 /**
35449 * Adds schema to the instance.
35450 * @this Ajv
35451 * @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
35452 * @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
35453 * @param {Boolean} _skipValidation true to skip schema validation. Used internally, option validateSchema should be used instead.
35454 * @param {Boolean} _meta true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
35455 * @return {Ajv} this for method chaining
35456 */
35457
35458
35459 function addSchema(schema, key, _skipValidation, _meta) {
35460 if (Array.isArray(schema)) {
35461 for (var i = 0; i < schema.length; i++) this.addSchema(schema[i], undefined, _skipValidation, _meta);
35462
35463 return this;
35464 }
35465
35466 var id = this._getId(schema);
35467
35468 if (id !== undefined && typeof id != 'string') throw new Error('schema id must be string');
35469 key = resolve.normalizeId(key || id);
35470 checkUnique(this, key);
35471 this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
35472 return this;
35473 }
35474 /**
35475 * Add schema that will be used to validate other schemas
35476 * options in META_IGNORE_OPTIONS are alway set to false
35477 * @this Ajv
35478 * @param {Object} schema schema object
35479 * @param {String} key optional schema key
35480 * @param {Boolean} skipValidation true to skip schema validation, can be used to override validateSchema option for meta-schema
35481 * @return {Ajv} this for method chaining
35482 */
35483
35484
35485 function addMetaSchema(schema, key, skipValidation) {
35486 this.addSchema(schema, key, skipValidation, true);
35487 return this;
35488 }
35489 /**
35490 * Validate schema
35491 * @this Ajv
35492 * @param {Object} schema schema to validate
35493 * @param {Boolean} throwOrLogError pass true to throw (or log) an error if invalid
35494 * @return {Boolean} true if schema is valid
35495 */
35496
35497
35498 function validateSchema(schema, throwOrLogError) {
35499 var $schema = schema.$schema;
35500 if ($schema !== undefined && typeof $schema != 'string') throw new Error('$schema must be a string');
35501 $schema = $schema || this._opts.defaultMeta || defaultMeta(this);
35502
35503 if (!$schema) {
35504 this.logger.warn('meta-schema not available');
35505 this.errors = null;
35506 return true;
35507 }
35508
35509 var valid = this.validate($schema, schema);
35510
35511 if (!valid && throwOrLogError) {
35512 var message = 'schema is invalid: ' + this.errorsText();
35513 if (this._opts.validateSchema == 'log') this.logger.error(message);else throw new Error(message);
35514 }
35515
35516 return valid;
35517 }
35518
35519 function defaultMeta(self) {
35520 var meta = self._opts.meta;
35521 self._opts.defaultMeta = typeof meta == 'object' ? self._getId(meta) || meta : self.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined;
35522 return self._opts.defaultMeta;
35523 }
35524 /**
35525 * Get compiled schema from the instance by `key` or `ref`.
35526 * @this Ajv
35527 * @param {String} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
35528 * @return {Function} schema validating function (with property `schema`).
35529 */
35530
35531
35532 function getSchema(keyRef) {
35533 var schemaObj = _getSchemaObj(this, keyRef);
35534
35535 switch (typeof schemaObj) {
35536 case 'object':
35537 return schemaObj.validate || this._compile(schemaObj);
35538
35539 case 'string':
35540 return this.getSchema(schemaObj);
35541
35542 case 'undefined':
35543 return _getSchemaFragment(this, keyRef);
35544 }
35545 }
35546
35547 function _getSchemaFragment(self, ref) {
35548 var res = resolve.schema.call(self, {
35549 schema: {}
35550 }, ref);
35551
35552 if (res) {
35553 var schema = res.schema,
35554 root = res.root,
35555 baseId = res.baseId;
35556 var v = compileSchema.call(self, schema, root, undefined, baseId);
35557 self._fragments[ref] = new SchemaObject({
35558 ref: ref,
35559 fragment: true,
35560 schema: schema,
35561 root: root,
35562 baseId: baseId,
35563 validate: v
35564 });
35565 return v;
35566 }
35567 }
35568
35569 function _getSchemaObj(self, keyRef) {
35570 keyRef = resolve.normalizeId(keyRef);
35571 return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
35572 }
35573 /**
35574 * Remove cached schema(s).
35575 * If no parameter is passed all schemas but meta-schemas are removed.
35576 * If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
35577 * Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
35578 * @this Ajv
35579 * @param {String|Object|RegExp} schemaKeyRef key, ref, pattern to match key/ref or schema object
35580 * @return {Ajv} this for method chaining
35581 */
35582
35583
35584 function removeSchema(schemaKeyRef) {
35585 if (schemaKeyRef instanceof RegExp) {
35586 _removeAllSchemas(this, this._schemas, schemaKeyRef);
35587
35588 _removeAllSchemas(this, this._refs, schemaKeyRef);
35589
35590 return this;
35591 }
35592
35593 switch (typeof schemaKeyRef) {
35594 case 'undefined':
35595 _removeAllSchemas(this, this._schemas);
35596
35597 _removeAllSchemas(this, this._refs);
35598
35599 this._cache.clear();
35600
35601 return this;
35602
35603 case 'string':
35604 var schemaObj = _getSchemaObj(this, schemaKeyRef);
35605
35606 if (schemaObj) this._cache.del(schemaObj.cacheKey);
35607 delete this._schemas[schemaKeyRef];
35608 delete this._refs[schemaKeyRef];
35609 return this;
35610
35611 case 'object':
35612 var serialize = this._opts.serialize;
35613 var cacheKey = serialize ? serialize(schemaKeyRef) : schemaKeyRef;
35614
35615 this._cache.del(cacheKey);
35616
35617 var id = this._getId(schemaKeyRef);
35618
35619 if (id) {
35620 id = resolve.normalizeId(id);
35621 delete this._schemas[id];
35622 delete this._refs[id];
35623 }
35624
35625 }
35626
35627 return this;
35628 }
35629
35630 function _removeAllSchemas(self, schemas, regex) {
35631 for (var keyRef in schemas) {
35632 var schemaObj = schemas[keyRef];
35633
35634 if (!schemaObj.meta && (!regex || regex.test(keyRef))) {
35635 self._cache.del(schemaObj.cacheKey);
35636
35637 delete schemas[keyRef];
35638 }
35639 }
35640 }
35641 /* @this Ajv */
35642
35643
35644 function _addSchema(schema, skipValidation, meta, shouldAddSchema) {
35645 if (typeof schema != 'object' && typeof schema != 'boolean') throw new Error('schema should be object or boolean');
35646 var serialize = this._opts.serialize;
35647 var cacheKey = serialize ? serialize(schema) : schema;
35648
35649 var cached = this._cache.get(cacheKey);
35650
35651 if (cached) return cached;
35652 shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
35653 var id = resolve.normalizeId(this._getId(schema));
35654 if (id && shouldAddSchema) checkUnique(this, id);
35655 var willValidate = this._opts.validateSchema !== false && !skipValidation;
35656 var recursiveMeta;
35657 if (willValidate && !(recursiveMeta = id && id == resolve.normalizeId(schema.$schema))) this.validateSchema(schema, true);
35658 var localRefs = resolve.ids.call(this, schema);
35659 var schemaObj = new SchemaObject({
35660 id: id,
35661 schema: schema,
35662 localRefs: localRefs,
35663 cacheKey: cacheKey,
35664 meta: meta
35665 });
35666 if (id[0] != '#' && shouldAddSchema) this._refs[id] = schemaObj;
35667
35668 this._cache.put(cacheKey, schemaObj);
35669
35670 if (willValidate && recursiveMeta) this.validateSchema(schema, true);
35671 return schemaObj;
35672 }
35673 /* @this Ajv */
35674
35675
35676 function _compile(schemaObj, root) {
35677 if (schemaObj.compiling) {
35678 schemaObj.validate = callValidate;
35679 callValidate.schema = schemaObj.schema;
35680 callValidate.errors = null;
35681 callValidate.root = root ? root : callValidate;
35682 if (schemaObj.schema.$async === true) callValidate.$async = true;
35683 return callValidate;
35684 }
35685
35686 schemaObj.compiling = true;
35687 var currentOpts;
35688
35689 if (schemaObj.meta) {
35690 currentOpts = this._opts;
35691 this._opts = this._metaOpts;
35692 }
35693
35694 var v;
35695
35696 try {
35697 v = compileSchema.call(this, schemaObj.schema, root, schemaObj.localRefs);
35698 } catch (e) {
35699 delete schemaObj.validate;
35700 throw e;
35701 } finally {
35702 schemaObj.compiling = false;
35703 if (schemaObj.meta) this._opts = currentOpts;
35704 }
35705
35706 schemaObj.validate = v;
35707 schemaObj.refs = v.refs;
35708 schemaObj.refVal = v.refVal;
35709 schemaObj.root = v.root;
35710 return v;
35711 /* @this {*} - custom context, see passContext option */
35712
35713 function callValidate() {
35714 /* jshint validthis: true */
35715 var _validate = schemaObj.validate;
35716
35717 var result = _validate.apply(this, arguments);
35718
35719 callValidate.errors = _validate.errors;
35720 return result;
35721 }
35722 }
35723
35724 function chooseGetId(opts) {
35725 switch (opts.schemaId) {
35726 case 'auto':
35727 return _get$IdOrId;
35728
35729 case 'id':
35730 return _getId;
35731
35732 default:
35733 return _get$Id;
35734 }
35735 }
35736 /* @this Ajv */
35737
35738
35739 function _getId(schema) {
35740 if (schema.$id) this.logger.warn('schema $id ignored', schema.$id);
35741 return schema.id;
35742 }
35743 /* @this Ajv */
35744
35745
35746 function _get$Id(schema) {
35747 if (schema.id) this.logger.warn('schema id ignored', schema.id);
35748 return schema.$id;
35749 }
35750
35751 function _get$IdOrId(schema) {
35752 if (schema.$id && schema.id && schema.$id != schema.id) throw new Error('schema $id is different from id');
35753 return schema.$id || schema.id;
35754 }
35755 /**
35756 * Convert array of error message objects to string
35757 * @this Ajv
35758 * @param {Array<Object>} errors optional array of validation errors, if not passed errors from the instance are used.
35759 * @param {Object} options optional options with properties `separator` and `dataVar`.
35760 * @return {String} human readable string with all errors descriptions
35761 */
35762
35763
35764 function errorsText(errors, options) {
35765 errors = errors || this.errors;
35766 if (!errors) return 'No errors';
35767 options = options || {};
35768 var separator = options.separator === undefined ? ', ' : options.separator;
35769 var dataVar = options.dataVar === undefined ? 'data' : options.dataVar;
35770 var text = '';
35771
35772 for (var i = 0; i < errors.length; i++) {
35773 var e = errors[i];
35774 if (e) text += dataVar + e.dataPath + ' ' + e.message + separator;
35775 }
35776
35777 return text.slice(0, -separator.length);
35778 }
35779 /**
35780 * Add custom format
35781 * @this Ajv
35782 * @param {String} name format name
35783 * @param {String|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid)
35784 * @return {Ajv} this for method chaining
35785 */
35786
35787
35788 function addFormat(name, format) {
35789 if (typeof format == 'string') format = new RegExp(format);
35790 this._formats[name] = format;
35791 return this;
35792 }
35793
35794 function addDefaultMetaSchema(self) {
35795 var $dataSchema;
35796
35797 if (self._opts.$data) {
35798 $dataSchema = __webpack_require__(491);
35799 self.addMetaSchema($dataSchema, $dataSchema.$id, true);
35800 }
35801
35802 if (self._opts.meta === false) return;
35803
35804 var metaSchema = __webpack_require__(490);
35805
35806 if (self._opts.$data) metaSchema = $dataMetaSchema(metaSchema, META_SUPPORT_DATA);
35807 self.addMetaSchema(metaSchema, META_SCHEMA_ID, true);
35808 self._refs['http://json-schema.org/schema'] = META_SCHEMA_ID;
35809 }
35810
35811 function addInitialSchemas(self) {
35812 var optsSchemas = self._opts.schemas;
35813 if (!optsSchemas) return;
35814 if (Array.isArray(optsSchemas)) self.addSchema(optsSchemas);else for (var key in optsSchemas) self.addSchema(optsSchemas[key], key);
35815 }
35816
35817 function addInitialFormats(self) {
35818 for (var name in self._opts.formats) {
35819 var format = self._opts.formats[name];
35820 self.addFormat(name, format);
35821 }
35822 }
35823
35824 function addInitialKeywords(self) {
35825 for (var name in self._opts.keywords) {
35826 var keyword = self._opts.keywords[name];
35827 self.addKeyword(name, keyword);
35828 }
35829 }
35830
35831 function checkUnique(self, id) {
35832 if (self._schemas[id] || self._refs[id]) throw new Error('schema with key or id "' + id + '" already exists');
35833 }
35834
35835 function getMetaSchemaOptions(self) {
35836 var metaOpts = util.copy(self._opts);
35837
35838 for (var i = 0; i < META_IGNORE_OPTIONS.length; i++) delete metaOpts[META_IGNORE_OPTIONS[i]];
35839
35840 return metaOpts;
35841 }
35842
35843 function setLogger(self) {
35844 var logger = self._opts.logger;
35845
35846 if (logger === false) {
35847 self.logger = {
35848 log: noop,
35849 warn: noop,
35850 error: noop
35851 };
35852 } else {
35853 if (logger === undefined) logger = console;
35854 if (!(typeof logger == 'object' && logger.log && logger.warn && logger.error)) throw new Error('logger must implement log, warn and error methods');
35855 self.logger = logger;
35856 }
35857 }
35858
35859 function noop() {}
35860
35861 /***/ }),
35862 /* 447 */
35863 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
35864
35865 "use strict";
35866
35867
35868 var resolve = __webpack_require__(448),
35869 util = __webpack_require__(451),
35870 errorClasses = __webpack_require__(455),
35871 stableStringify = __webpack_require__(456);
35872
35873 var validateGenerator = __webpack_require__(457);
35874 /**
35875 * Functions below are used inside compiled validations function
35876 */
35877
35878
35879 var ucs2length = util.ucs2length;
35880
35881 var equal = __webpack_require__(450); // this error is thrown by async schemas to return validation errors via exception
35882
35883
35884 var ValidationError = errorClasses.Validation;
35885 module.exports = compile;
35886 /**
35887 * Compiles schema to validation function
35888 * @this Ajv
35889 * @param {Object} schema schema object
35890 * @param {Object} root object with information about the root schema for this schema
35891 * @param {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution
35892 * @param {String} baseId base ID for IDs in the schema
35893 * @return {Function} validation function
35894 */
35895
35896 function compile(schema, root, localRefs, baseId) {
35897 /* jshint validthis: true, evil: true */
35898
35899 /* eslint no-shadow: 0 */
35900 var self = this,
35901 opts = this._opts,
35902 refVal = [undefined],
35903 refs = {},
35904 patterns = [],
35905 patternsHash = {},
35906 defaults = [],
35907 defaultsHash = {},
35908 customRules = [];
35909 root = root || {
35910 schema: schema,
35911 refVal: refVal,
35912 refs: refs
35913 };
35914 var c = checkCompiling.call(this, schema, root, baseId);
35915 var compilation = this._compilations[c.index];
35916 if (c.compiling) return compilation.callValidate = callValidate;
35917 var formats = this._formats;
35918 var RULES = this.RULES;
35919
35920 try {
35921 var v = localCompile(schema, root, localRefs, baseId);
35922 compilation.validate = v;
35923 var cv = compilation.callValidate;
35924
35925 if (cv) {
35926 cv.schema = v.schema;
35927 cv.errors = null;
35928 cv.refs = v.refs;
35929 cv.refVal = v.refVal;
35930 cv.root = v.root;
35931 cv.$async = v.$async;
35932 if (opts.sourceCode) cv.source = v.source;
35933 }
35934
35935 return v;
35936 } finally {
35937 endCompiling.call(this, schema, root, baseId);
35938 }
35939 /* @this {*} - custom context, see passContext option */
35940
35941
35942 function callValidate() {
35943 /* jshint validthis: true */
35944 var validate = compilation.validate;
35945 var result = validate.apply(this, arguments);
35946 callValidate.errors = validate.errors;
35947 return result;
35948 }
35949
35950 function localCompile(_schema, _root, localRefs, baseId) {
35951 var isRoot = !_root || _root && _root.schema == _schema;
35952 if (_root.schema != root.schema) return compile.call(self, _schema, _root, localRefs, baseId);
35953 var $async = _schema.$async === true;
35954 var sourceCode = validateGenerator({
35955 isTop: true,
35956 schema: _schema,
35957 isRoot: isRoot,
35958 baseId: baseId,
35959 root: _root,
35960 schemaPath: '',
35961 errSchemaPath: '#',
35962 errorPath: '""',
35963 MissingRefError: errorClasses.MissingRef,
35964 RULES: RULES,
35965 validate: validateGenerator,
35966 util: util,
35967 resolve: resolve,
35968 resolveRef: resolveRef,
35969 usePattern: usePattern,
35970 useDefault: useDefault,
35971 useCustomRule: useCustomRule,
35972 opts: opts,
35973 formats: formats,
35974 logger: self.logger,
35975 self: self
35976 });
35977 sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode) + vars(defaults, defaultCode) + vars(customRules, customRuleCode) + sourceCode;
35978 if (opts.processCode) sourceCode = opts.processCode(sourceCode, _schema); // console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
35979
35980 var validate;
35981
35982 try {
35983 var makeValidate = new Function('self', 'RULES', 'formats', 'root', 'refVal', 'defaults', 'customRules', 'equal', 'ucs2length', 'ValidationError', sourceCode);
35984 validate = makeValidate(self, RULES, formats, root, refVal, defaults, customRules, equal, ucs2length, ValidationError);
35985 refVal[0] = validate;
35986 } catch (e) {
35987 self.logger.error('Error compiling schema, function code:', sourceCode);
35988 throw e;
35989 }
35990
35991 validate.schema = _schema;
35992 validate.errors = null;
35993 validate.refs = refs;
35994 validate.refVal = refVal;
35995 validate.root = isRoot ? validate : _root;
35996 if ($async) validate.$async = true;
35997
35998 if (opts.sourceCode === true) {
35999 validate.source = {
36000 code: sourceCode,
36001 patterns: patterns,
36002 defaults: defaults
36003 };
36004 }
36005
36006 return validate;
36007 }
36008
36009 function resolveRef(baseId, ref, isRoot) {
36010 ref = resolve.url(baseId, ref);
36011 var refIndex = refs[ref];
36012
36013 var _refVal, refCode;
36014
36015 if (refIndex !== undefined) {
36016 _refVal = refVal[refIndex];
36017 refCode = 'refVal[' + refIndex + ']';
36018 return resolvedRef(_refVal, refCode);
36019 }
36020
36021 if (!isRoot && root.refs) {
36022 var rootRefId = root.refs[ref];
36023
36024 if (rootRefId !== undefined) {
36025 _refVal = root.refVal[rootRefId];
36026 refCode = addLocalRef(ref, _refVal);
36027 return resolvedRef(_refVal, refCode);
36028 }
36029 }
36030
36031 refCode = addLocalRef(ref);
36032 var v = resolve.call(self, localCompile, root, ref);
36033
36034 if (v === undefined) {
36035 var localSchema = localRefs && localRefs[ref];
36036
36037 if (localSchema) {
36038 v = resolve.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self, localSchema, root, localRefs, baseId);
36039 }
36040 }
36041
36042 if (v === undefined) {
36043 removeLocalRef(ref);
36044 } else {
36045 replaceLocalRef(ref, v);
36046 return resolvedRef(v, refCode);
36047 }
36048 }
36049
36050 function addLocalRef(ref, v) {
36051 var refId = refVal.length;
36052 refVal[refId] = v;
36053 refs[ref] = refId;
36054 return 'refVal' + refId;
36055 }
36056
36057 function removeLocalRef(ref) {
36058 delete refs[ref];
36059 }
36060
36061 function replaceLocalRef(ref, v) {
36062 var refId = refs[ref];
36063 refVal[refId] = v;
36064 }
36065
36066 function resolvedRef(refVal, code) {
36067 return typeof refVal == 'object' || typeof refVal == 'boolean' ? {
36068 code: code,
36069 schema: refVal,
36070 inline: true
36071 } : {
36072 code: code,
36073 $async: refVal && !!refVal.$async
36074 };
36075 }
36076
36077 function usePattern(regexStr) {
36078 var index = patternsHash[regexStr];
36079
36080 if (index === undefined) {
36081 index = patternsHash[regexStr] = patterns.length;
36082 patterns[index] = regexStr;
36083 }
36084
36085 return 'pattern' + index;
36086 }
36087
36088 function useDefault(value) {
36089 switch (typeof value) {
36090 case 'boolean':
36091 case 'number':
36092 return '' + value;
36093
36094 case 'string':
36095 return util.toQuotedString(value);
36096
36097 case 'object':
36098 if (value === null) return 'null';
36099 var valueStr = stableStringify(value);
36100 var index = defaultsHash[valueStr];
36101
36102 if (index === undefined) {
36103 index = defaultsHash[valueStr] = defaults.length;
36104 defaults[index] = value;
36105 }
36106
36107 return 'default' + index;
36108 }
36109 }
36110
36111 function useCustomRule(rule, schema, parentSchema, it) {
36112 if (self._opts.validateSchema !== false) {
36113 var deps = rule.definition.dependencies;
36114 if (deps && !deps.every(function (keyword) {
36115 return Object.prototype.hasOwnProperty.call(parentSchema, keyword);
36116 })) throw new Error('parent schema must have all required keywords: ' + deps.join(','));
36117 var validateSchema = rule.definition.validateSchema;
36118
36119 if (validateSchema) {
36120 var valid = validateSchema(schema);
36121
36122 if (!valid) {
36123 var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors);
36124 if (self._opts.validateSchema == 'log') self.logger.error(message);else throw new Error(message);
36125 }
36126 }
36127 }
36128
36129 var compile = rule.definition.compile,
36130 inline = rule.definition.inline,
36131 macro = rule.definition.macro;
36132 var validate;
36133
36134 if (compile) {
36135 validate = compile.call(self, schema, parentSchema, it);
36136 } else if (macro) {
36137 validate = macro.call(self, schema, parentSchema, it);
36138 if (opts.validateSchema !== false) self.validateSchema(validate, true);
36139 } else if (inline) {
36140 validate = inline.call(self, it, rule.keyword, schema, parentSchema);
36141 } else {
36142 validate = rule.definition.validate;
36143 if (!validate) return;
36144 }
36145
36146 if (validate === undefined) throw new Error('custom keyword "' + rule.keyword + '"failed to compile');
36147 var index = customRules.length;
36148 customRules[index] = validate;
36149 return {
36150 code: 'customRule' + index,
36151 validate: validate
36152 };
36153 }
36154 }
36155 /**
36156 * Checks if the schema is currently compiled
36157 * @this Ajv
36158 * @param {Object} schema schema to compile
36159 * @param {Object} root root object
36160 * @param {String} baseId base schema ID
36161 * @return {Object} object with properties "index" (compilation index) and "compiling" (boolean)
36162 */
36163
36164
36165 function checkCompiling(schema, root, baseId) {
36166 /* jshint validthis: true */
36167 var index = compIndex.call(this, schema, root, baseId);
36168 if (index >= 0) return {
36169 index: index,
36170 compiling: true
36171 };
36172 index = this._compilations.length;
36173 this._compilations[index] = {
36174 schema: schema,
36175 root: root,
36176 baseId: baseId
36177 };
36178 return {
36179 index: index,
36180 compiling: false
36181 };
36182 }
36183 /**
36184 * Removes the schema from the currently compiled list
36185 * @this Ajv
36186 * @param {Object} schema schema to compile
36187 * @param {Object} root root object
36188 * @param {String} baseId base schema ID
36189 */
36190
36191
36192 function endCompiling(schema, root, baseId) {
36193 /* jshint validthis: true */
36194 var i = compIndex.call(this, schema, root, baseId);
36195 if (i >= 0) this._compilations.splice(i, 1);
36196 }
36197 /**
36198 * Index of schema compilation in the currently compiled list
36199 * @this Ajv
36200 * @param {Object} schema schema to compile
36201 * @param {Object} root root object
36202 * @param {String} baseId base schema ID
36203 * @return {Integer} compilation index
36204 */
36205
36206
36207 function compIndex(schema, root, baseId) {
36208 /* jshint validthis: true */
36209 for (var i = 0; i < this._compilations.length; i++) {
36210 var c = this._compilations[i];
36211 if (c.schema == schema && c.root == root && c.baseId == baseId) return i;
36212 }
36213
36214 return -1;
36215 }
36216
36217 function patternCode(i, patterns) {
36218 return 'var pattern' + i + ' = new RegExp(' + util.toQuotedString(patterns[i]) + ');';
36219 }
36220
36221 function defaultCode(i) {
36222 return 'var default' + i + ' = defaults[' + i + '];';
36223 }
36224
36225 function refValCode(i, refVal) {
36226 return refVal[i] === undefined ? '' : 'var refVal' + i + ' = refVal[' + i + '];';
36227 }
36228
36229 function customRuleCode(i) {
36230 return 'var customRule' + i + ' = customRules[' + i + '];';
36231 }
36232
36233 function vars(arr, statement) {
36234 if (!arr.length) return '';
36235 var code = '';
36236
36237 for (var i = 0; i < arr.length; i++) code += statement(i, arr);
36238
36239 return code;
36240 }
36241
36242 /***/ }),
36243 /* 448 */
36244 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
36245
36246 "use strict";
36247
36248
36249 var URI = __webpack_require__(449),
36250 equal = __webpack_require__(450),
36251 util = __webpack_require__(451),
36252 SchemaObject = __webpack_require__(453),
36253 traverse = __webpack_require__(454);
36254
36255 module.exports = resolve;
36256 resolve.normalizeId = normalizeId;
36257 resolve.fullPath = getFullPath;
36258 resolve.url = resolveUrl;
36259 resolve.ids = resolveIds;
36260 resolve.inlineRef = inlineRef;
36261 resolve.schema = resolveSchema;
36262 /**
36263 * [resolve and compile the references ($ref)]
36264 * @this Ajv
36265 * @param {Function} compile reference to schema compilation funciton (localCompile)
36266 * @param {Object} root object with information about the root schema for the current schema
36267 * @param {String} ref reference to resolve
36268 * @return {Object|Function} schema object (if the schema can be inlined) or validation function
36269 */
36270
36271 function resolve(compile, root, ref) {
36272 /* jshint validthis: true */
36273 var refVal = this._refs[ref];
36274
36275 if (typeof refVal == 'string') {
36276 if (this._refs[refVal]) refVal = this._refs[refVal];else return resolve.call(this, compile, root, refVal);
36277 }
36278
36279 refVal = refVal || this._schemas[ref];
36280
36281 if (refVal instanceof SchemaObject) {
36282 return inlineRef(refVal.schema, this._opts.inlineRefs) ? refVal.schema : refVal.validate || this._compile(refVal);
36283 }
36284
36285 var res = resolveSchema.call(this, root, ref);
36286 var schema, v, baseId;
36287
36288 if (res) {
36289 schema = res.schema;
36290 root = res.root;
36291 baseId = res.baseId;
36292 }
36293
36294 if (schema instanceof SchemaObject) {
36295 v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
36296 } else if (schema !== undefined) {
36297 v = inlineRef(schema, this._opts.inlineRefs) ? schema : compile.call(this, schema, root, undefined, baseId);
36298 }
36299
36300 return v;
36301 }
36302 /**
36303 * Resolve schema, its root and baseId
36304 * @this Ajv
36305 * @param {Object} root root object with properties schema, refVal, refs
36306 * @param {String} ref reference to resolve
36307 * @return {Object} object with properties schema, root, baseId
36308 */
36309
36310
36311 function resolveSchema(root, ref) {
36312 /* jshint validthis: true */
36313 var p = URI.parse(ref),
36314 refPath = _getFullPath(p),
36315 baseId = getFullPath(this._getId(root.schema));
36316
36317 if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
36318 var id = normalizeId(refPath);
36319 var refVal = this._refs[id];
36320
36321 if (typeof refVal == 'string') {
36322 return resolveRecursive.call(this, root, refVal, p);
36323 } else if (refVal instanceof SchemaObject) {
36324 if (!refVal.validate) this._compile(refVal);
36325 root = refVal;
36326 } else {
36327 refVal = this._schemas[id];
36328
36329 if (refVal instanceof SchemaObject) {
36330 if (!refVal.validate) this._compile(refVal);
36331 if (id == normalizeId(ref)) return {
36332 schema: refVal,
36333 root: root,
36334 baseId: baseId
36335 };
36336 root = refVal;
36337 } else {
36338 return;
36339 }
36340 }
36341
36342 if (!root.schema) return;
36343 baseId = getFullPath(this._getId(root.schema));
36344 }
36345
36346 return getJsonPointer.call(this, p, baseId, root.schema, root);
36347 }
36348 /* @this Ajv */
36349
36350
36351 function resolveRecursive(root, ref, parsedRef) {
36352 /* jshint validthis: true */
36353 var res = resolveSchema.call(this, root, ref);
36354
36355 if (res) {
36356 var schema = res.schema;
36357 var baseId = res.baseId;
36358 root = res.root;
36359
36360 var id = this._getId(schema);
36361
36362 if (id) baseId = resolveUrl(baseId, id);
36363 return getJsonPointer.call(this, parsedRef, baseId, schema, root);
36364 }
36365 }
36366
36367 var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
36368 /* @this Ajv */
36369
36370 function getJsonPointer(parsedRef, baseId, schema, root) {
36371 /* jshint validthis: true */
36372 parsedRef.fragment = parsedRef.fragment || '';
36373 if (parsedRef.fragment.slice(0, 1) != '/') return;
36374 var parts = parsedRef.fragment.split('/');
36375
36376 for (var i = 1; i < parts.length; i++) {
36377 var part = parts[i];
36378
36379 if (part) {
36380 part = util.unescapeFragment(part);
36381 schema = schema[part];
36382 if (schema === undefined) break;
36383 var id;
36384
36385 if (!PREVENT_SCOPE_CHANGE[part]) {
36386 id = this._getId(schema);
36387 if (id) baseId = resolveUrl(baseId, id);
36388
36389 if (schema.$ref) {
36390 var $ref = resolveUrl(baseId, schema.$ref);
36391 var res = resolveSchema.call(this, root, $ref);
36392
36393 if (res) {
36394 schema = res.schema;
36395 root = res.root;
36396 baseId = res.baseId;
36397 }
36398 }
36399 }
36400 }
36401 }
36402
36403 if (schema !== undefined && schema !== root.schema) return {
36404 schema: schema,
36405 root: root,
36406 baseId: baseId
36407 };
36408 }
36409
36410 var SIMPLE_INLINED = util.toHash(['type', 'format', 'pattern', 'maxLength', 'minLength', 'maxProperties', 'minProperties', 'maxItems', 'minItems', 'maximum', 'minimum', 'uniqueItems', 'multipleOf', 'required', 'enum']);
36411
36412 function inlineRef(schema, limit) {
36413 if (limit === false) return false;
36414 if (limit === undefined || limit === true) return checkNoRef(schema);else if (limit) return countKeys(schema) <= limit;
36415 }
36416
36417 function checkNoRef(schema) {
36418 var item;
36419
36420 if (Array.isArray(schema)) {
36421 for (var i = 0; i < schema.length; i++) {
36422 item = schema[i];
36423 if (typeof item == 'object' && !checkNoRef(item)) return false;
36424 }
36425 } else {
36426 for (var key in schema) {
36427 if (key == '$ref') return false;
36428 item = schema[key];
36429 if (typeof item == 'object' && !checkNoRef(item)) return false;
36430 }
36431 }
36432
36433 return true;
36434 }
36435
36436 function countKeys(schema) {
36437 var count = 0,
36438 item;
36439
36440 if (Array.isArray(schema)) {
36441 for (var i = 0; i < schema.length; i++) {
36442 item = schema[i];
36443 if (typeof item == 'object') count += countKeys(item);
36444 if (count == Infinity) return Infinity;
36445 }
36446 } else {
36447 for (var key in schema) {
36448 if (key == '$ref') return Infinity;
36449
36450 if (SIMPLE_INLINED[key]) {
36451 count++;
36452 } else {
36453 item = schema[key];
36454 if (typeof item == 'object') count += countKeys(item) + 1;
36455 if (count == Infinity) return Infinity;
36456 }
36457 }
36458 }
36459
36460 return count;
36461 }
36462
36463 function getFullPath(id, normalize) {
36464 if (normalize !== false) id = normalizeId(id);
36465 var p = URI.parse(id);
36466 return _getFullPath(p);
36467 }
36468
36469 function _getFullPath(p) {
36470 return URI.serialize(p).split('#')[0] + '#';
36471 }
36472
36473 var TRAILING_SLASH_HASH = /#\/?$/;
36474
36475 function normalizeId(id) {
36476 return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
36477 }
36478
36479 function resolveUrl(baseId, id) {
36480 id = normalizeId(id);
36481 return URI.resolve(baseId, id);
36482 }
36483 /* @this Ajv */
36484
36485
36486 function resolveIds(schema) {
36487 var schemaId = normalizeId(this._getId(schema));
36488 var baseIds = {
36489 '': schemaId
36490 };
36491 var fullPaths = {
36492 '': getFullPath(schemaId, false)
36493 };
36494 var localRefs = {};
36495 var self = this;
36496 traverse(schema, {
36497 allKeys: true
36498 }, function (sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
36499 if (jsonPtr === '') return;
36500
36501 var id = self._getId(sch);
36502
36503 var baseId = baseIds[parentJsonPtr];
36504 var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
36505 if (keyIndex !== undefined) fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
36506
36507 if (typeof id == 'string') {
36508 id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
36509 var refVal = self._refs[id];
36510 if (typeof refVal == 'string') refVal = self._refs[refVal];
36511
36512 if (refVal && refVal.schema) {
36513 if (!equal(sch, refVal.schema)) throw new Error('id "' + id + '" resolves to more than one schema');
36514 } else if (id != normalizeId(fullPath)) {
36515 if (id[0] == '#') {
36516 if (localRefs[id] && !equal(sch, localRefs[id])) throw new Error('id "' + id + '" resolves to more than one schema');
36517 localRefs[id] = sch;
36518 } else {
36519 self._refs[id] = fullPath;
36520 }
36521 }
36522 }
36523
36524 baseIds[jsonPtr] = baseId;
36525 fullPaths[jsonPtr] = fullPath;
36526 });
36527 return localRefs;
36528 }
36529
36530 /***/ }),
36531 /* 449 */
36532 /***/ (function(__unused_webpack_module, exports) {
36533
36534 /** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
36535 (function (global, factory) {
36536 true ? factory(exports) : 0;
36537 })(this, function (exports) {
36538 'use strict';
36539
36540 function merge() {
36541 for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) {
36542 sets[_key] = arguments[_key];
36543 }
36544
36545 if (sets.length > 1) {
36546 sets[0] = sets[0].slice(0, -1);
36547 var xl = sets.length - 1;
36548
36549 for (var x = 1; x < xl; ++x) {
36550 sets[x] = sets[x].slice(1, -1);
36551 }
36552
36553 sets[xl] = sets[xl].slice(1);
36554 return sets.join('');
36555 } else {
36556 return sets[0];
36557 }
36558 }
36559
36560 function subexp(str) {
36561 return "(?:" + str + ")";
36562 }
36563
36564 function typeOf(o) {
36565 return o === undefined ? "undefined" : o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase();
36566 }
36567
36568 function toUpperCase(str) {
36569 return str.toUpperCase();
36570 }
36571
36572 function toArray(obj) {
36573 return obj !== undefined && obj !== null ? obj instanceof Array ? obj : typeof obj.length !== "number" || obj.split || obj.setInterval || obj.call ? [obj] : Array.prototype.slice.call(obj) : [];
36574 }
36575
36576 function assign(target, source) {
36577 var obj = target;
36578
36579 if (source) {
36580 for (var key in source) {
36581 obj[key] = source[key];
36582 }
36583 }
36584
36585 return obj;
36586 }
36587
36588 function buildExps(isIRI) {
36589 var ALPHA$$ = "[A-Za-z]",
36590 CR$ = "[\\x0D]",
36591 DIGIT$$ = "[0-9]",
36592 DQUOTE$$ = "[\\x22]",
36593 HEXDIG$$ = merge(DIGIT$$, "[A-Fa-f]"),
36594 //case-insensitive
36595 LF$$ = "[\\x0A]",
36596 SP$$ = "[\\x20]",
36597 PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)),
36598 //expanded
36599 GEN_DELIMS$$ = "[\\:\\/\\?\\#\\[\\]\\@]",
36600 SUB_DELIMS$$ = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",
36601 RESERVED$$ = merge(GEN_DELIMS$$, SUB_DELIMS$$),
36602 UCSCHAR$$ = isIRI ? "[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]" : "[]",
36603 //subset, excludes bidi control characters
36604 IPRIVATE$$ = isIRI ? "[\\uE000-\\uF8FF]" : "[]",
36605 //subset
36606 UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$),
36607 SCHEME$ = subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"),
36608 USERINFO$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*"),
36609 DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$),
36610 DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$),
36611 //relaxed parsing rules
36612 IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$),
36613 H16$ = subexp(HEXDIG$$ + "{1,4}"),
36614 LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$),
36615 IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$),
36616 // 6( h16 ":" ) ls32
36617 IPV6ADDRESS2$ = subexp("\\:\\:" + subexp(H16$ + "\\:") + "{5}" + LS32$),
36618 // "::" 5( h16 ":" ) ls32
36619 IPV6ADDRESS3$ = subexp(subexp(H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{4}" + LS32$),
36620 //[ h16 ] "::" 4( h16 ":" ) ls32
36621 IPV6ADDRESS4$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,1}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{3}" + LS32$),
36622 //[ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
36623 IPV6ADDRESS5$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,2}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{2}" + LS32$),
36624 //[ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
36625 IPV6ADDRESS6$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,3}" + H16$) + "?\\:\\:" + H16$ + "\\:" + LS32$),
36626 //[ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
36627 IPV6ADDRESS7$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,4}" + H16$) + "?\\:\\:" + LS32$),
36628 //[ *4( h16 ":" ) h16 ] "::" ls32
36629 IPV6ADDRESS8$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,5}" + H16$) + "?\\:\\:" + H16$),
36630 //[ *5( h16 ":" ) h16 ] "::" h16
36631 IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"),
36632 //[ *6( h16 ":" ) h16 ] "::"
36633 IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")),
36634 ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+"),
36635 //RFC 6874
36636 IPV6ADDRZ$ = subexp(IPV6ADDRESS$ + "\\%25" + ZONEID$),
36637 //RFC 6874
36638 IPV6ADDRZ_RELAXED$ = subexp(IPV6ADDRESS$ + subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + ZONEID$),
36639 //RFC 6874, with relaxed parsing rules
36640 IPVFUTURE$ = subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"),
36641 IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRZ_RELAXED$ + "|" + IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"),
36642 //RFC 6874
36643 REG_NAME$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"),
36644 HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$),
36645 PORT$ = subexp(DIGIT$$ + "*"),
36646 AUTHORITY$ = subexp(subexp(USERINFO$ + "@") + "?" + HOST$ + subexp("\\:" + PORT$) + "?"),
36647 PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]")),
36648 SEGMENT$ = subexp(PCHAR$ + "*"),
36649 SEGMENT_NZ$ = subexp(PCHAR$ + "+"),
36650 SEGMENT_NZ_NC$ = subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+"),
36651 PATH_ABEMPTY$ = subexp(subexp("\\/" + SEGMENT$) + "*"),
36652 PATH_ABSOLUTE$ = subexp("\\/" + subexp(SEGMENT_NZ$ + PATH_ABEMPTY$) + "?"),
36653 //simplified
36654 PATH_NOSCHEME$ = subexp(SEGMENT_NZ_NC$ + PATH_ABEMPTY$),
36655 //simplified
36656 PATH_ROOTLESS$ = subexp(SEGMENT_NZ$ + PATH_ABEMPTY$),
36657 //simplified
36658 PATH_EMPTY$ = "(?!" + PCHAR$ + ")",
36659 PATH$ = subexp(PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
36660 QUERY$ = subexp(subexp(PCHAR$ + "|" + merge("[\\/\\?]", IPRIVATE$$)) + "*"),
36661 FRAGMENT$ = subexp(subexp(PCHAR$ + "|[\\/\\?]") + "*"),
36662 HIER_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$),
36663 URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
36664 RELATIVE_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$),
36665 RELATIVE$ = subexp(RELATIVE_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"),
36666 URI_REFERENCE$ = subexp(URI$ + "|" + RELATIVE$),
36667 ABSOLUTE_URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?"),
36668 GENERIC_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
36669 RELATIVE_REF$ = "^(){0}" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
36670 ABSOLUTE_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?$",
36671 SAMEDOC_REF$ = "^" + subexp("\\#(" + FRAGMENT$ + ")") + "?$",
36672 AUTHORITY_REF$ = "^" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?$";
36673 return {
36674 NOT_SCHEME: new RegExp(merge("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"),
36675 NOT_USERINFO: new RegExp(merge("[^\\%\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
36676 NOT_HOST: new RegExp(merge("[^\\%\\[\\]\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"),
36677 NOT_PATH: new RegExp(merge("[^\\%\\/\\:\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
36678 NOT_PATH_NOSCHEME: new RegExp(merge("[^\\%\\/\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"),
36679 NOT_QUERY: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]", IPRIVATE$$), "g"),
36680 NOT_FRAGMENT: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]"), "g"),
36681 ESCAPE: new RegExp(merge("[^]", UNRESERVED$$, SUB_DELIMS$$), "g"),
36682 UNRESERVED: new RegExp(UNRESERVED$$, "g"),
36683 OTHER_CHARS: new RegExp(merge("[^\\%]", UNRESERVED$$, RESERVED$$), "g"),
36684 PCT_ENCODED: new RegExp(PCT_ENCODED$, "g"),
36685 IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"),
36686 IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules
36687
36688 };
36689 }
36690
36691 var URI_PROTOCOL = buildExps(false);
36692 var IRI_PROTOCOL = buildExps(true);
36693
36694 var slicedToArray = function () {
36695 function sliceIterator(arr, i) {
36696 var _arr = [];
36697 var _n = true;
36698 var _d = false;
36699 var _e = undefined;
36700
36701 try {
36702 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
36703 _arr.push(_s.value);
36704
36705 if (i && _arr.length === i) break;
36706 }
36707 } catch (err) {
36708 _d = true;
36709 _e = err;
36710 } finally {
36711 try {
36712 if (!_n && _i["return"]) _i["return"]();
36713 } finally {
36714 if (_d) throw _e;
36715 }
36716 }
36717
36718 return _arr;
36719 }
36720
36721 return function (arr, i) {
36722 if (Array.isArray(arr)) {
36723 return arr;
36724 } else if (Symbol.iterator in Object(arr)) {
36725 return sliceIterator(arr, i);
36726 } else {
36727 throw new TypeError("Invalid attempt to destructure non-iterable instance");
36728 }
36729 };
36730 }();
36731
36732 var toConsumableArray = function (arr) {
36733 if (Array.isArray(arr)) {
36734 for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
36735
36736 return arr2;
36737 } else {
36738 return Array.from(arr);
36739 }
36740 };
36741 /** Highest positive signed 32-bit float value */
36742
36743
36744 var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
36745
36746 /** Bootstring parameters */
36747
36748 var base = 36;
36749 var tMin = 1;
36750 var tMax = 26;
36751 var skew = 38;
36752 var damp = 700;
36753 var initialBias = 72;
36754 var initialN = 128; // 0x80
36755
36756 var delimiter = '-'; // '\x2D'
36757
36758 /** Regular expressions */
36759
36760 var regexPunycode = /^xn--/;
36761 var regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars
36762
36763 var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
36764
36765 /** Error messages */
36766
36767 var errors = {
36768 'overflow': 'Overflow: input needs wider integers to process',
36769 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
36770 'invalid-input': 'Invalid input'
36771 };
36772 /** Convenience shortcuts */
36773
36774 var baseMinusTMin = base - tMin;
36775 var floor = Math.floor;
36776 var stringFromCharCode = String.fromCharCode;
36777 /*--------------------------------------------------------------------------*/
36778
36779 /**
36780 * A generic error utility function.
36781 * @private
36782 * @param {String} type The error type.
36783 * @returns {Error} Throws a `RangeError` with the applicable error message.
36784 */
36785
36786 function error$1(type) {
36787 throw new RangeError(errors[type]);
36788 }
36789 /**
36790 * A generic `Array#map` utility function.
36791 * @private
36792 * @param {Array} array The array to iterate over.
36793 * @param {Function} callback The function that gets called for every array
36794 * item.
36795 * @returns {Array} A new array of values returned by the callback function.
36796 */
36797
36798
36799 function map(array, fn) {
36800 var result = [];
36801 var length = array.length;
36802
36803 while (length--) {
36804 result[length] = fn(array[length]);
36805 }
36806
36807 return result;
36808 }
36809 /**
36810 * A simple `Array#map`-like wrapper to work with domain name strings or email
36811 * addresses.
36812 * @private
36813 * @param {String} domain The domain name or email address.
36814 * @param {Function} callback The function that gets called for every
36815 * character.
36816 * @returns {Array} A new string of characters returned by the callback
36817 * function.
36818 */
36819
36820
36821 function mapDomain(string, fn) {
36822 var parts = string.split('@');
36823 var result = '';
36824
36825 if (parts.length > 1) {
36826 // In email addresses, only the domain name should be punycoded. Leave
36827 // the local part (i.e. everything up to `@`) intact.
36828 result = parts[0] + '@';
36829 string = parts[1];
36830 } // Avoid `split(regex)` for IE8 compatibility. See #17.
36831
36832
36833 string = string.replace(regexSeparators, '\x2E');
36834 var labels = string.split('.');
36835 var encoded = map(labels, fn).join('.');
36836 return result + encoded;
36837 }
36838 /**
36839 * Creates an array containing the numeric code points of each Unicode
36840 * character in the string. While JavaScript uses UCS-2 internally,
36841 * this function will convert a pair of surrogate halves (each of which
36842 * UCS-2 exposes as separate characters) into a single code point,
36843 * matching UTF-16.
36844 * @see `punycode.ucs2.encode`
36845 * @see <https://mathiasbynens.be/notes/javascript-encoding>
36846 * @memberOf punycode.ucs2
36847 * @name decode
36848 * @param {String} string The Unicode input string (UCS-2).
36849 * @returns {Array} The new array of code points.
36850 */
36851
36852
36853 function ucs2decode(string) {
36854 var output = [];
36855 var counter = 0;
36856 var length = string.length;
36857
36858 while (counter < length) {
36859 var value = string.charCodeAt(counter++);
36860
36861 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
36862 // It's a high surrogate, and there is a next character.
36863 var extra = string.charCodeAt(counter++);
36864
36865 if ((extra & 0xFC00) == 0xDC00) {
36866 // Low surrogate.
36867 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
36868 } else {
36869 // It's an unmatched surrogate; only append this code unit, in case the
36870 // next code unit is the high surrogate of a surrogate pair.
36871 output.push(value);
36872 counter--;
36873 }
36874 } else {
36875 output.push(value);
36876 }
36877 }
36878
36879 return output;
36880 }
36881 /**
36882 * Creates a string based on an array of numeric code points.
36883 * @see `punycode.ucs2.decode`
36884 * @memberOf punycode.ucs2
36885 * @name encode
36886 * @param {Array} codePoints The array of numeric code points.
36887 * @returns {String} The new Unicode string (UCS-2).
36888 */
36889
36890
36891 var ucs2encode = function ucs2encode(array) {
36892 return String.fromCodePoint.apply(String, toConsumableArray(array));
36893 };
36894 /**
36895 * Converts a basic code point into a digit/integer.
36896 * @see `digitToBasic()`
36897 * @private
36898 * @param {Number} codePoint The basic numeric code point value.
36899 * @returns {Number} The numeric value of a basic code point (for use in
36900 * representing integers) in the range `0` to `base - 1`, or `base` if
36901 * the code point does not represent a value.
36902 */
36903
36904
36905 var basicToDigit = function basicToDigit(codePoint) {
36906 if (codePoint - 0x30 < 0x0A) {
36907 return codePoint - 0x16;
36908 }
36909
36910 if (codePoint - 0x41 < 0x1A) {
36911 return codePoint - 0x41;
36912 }
36913
36914 if (codePoint - 0x61 < 0x1A) {
36915 return codePoint - 0x61;
36916 }
36917
36918 return base;
36919 };
36920 /**
36921 * Converts a digit/integer into a basic code point.
36922 * @see `basicToDigit()`
36923 * @private
36924 * @param {Number} digit The numeric value of a basic code point.
36925 * @returns {Number} The basic code point whose value (when used for
36926 * representing integers) is `digit`, which needs to be in the range
36927 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
36928 * used; else, the lowercase form is used. The behavior is undefined
36929 * if `flag` is non-zero and `digit` has no uppercase form.
36930 */
36931
36932
36933 var digitToBasic = function digitToBasic(digit, flag) {
36934 // 0..25 map to ASCII a..z or A..Z
36935 // 26..35 map to ASCII 0..9
36936 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
36937 };
36938 /**
36939 * Bias adaptation function as per section 3.4 of RFC 3492.
36940 * https://tools.ietf.org/html/rfc3492#section-3.4
36941 * @private
36942 */
36943
36944
36945 var adapt = function adapt(delta, numPoints, firstTime) {
36946 var k = 0;
36947 delta = firstTime ? floor(delta / damp) : delta >> 1;
36948 delta += floor(delta / numPoints);
36949
36950 for (;
36951 /* no initialization */
36952 delta > baseMinusTMin * tMax >> 1; k += base) {
36953 delta = floor(delta / baseMinusTMin);
36954 }
36955
36956 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
36957 };
36958 /**
36959 * Converts a Punycode string of ASCII-only symbols to a string of Unicode
36960 * symbols.
36961 * @memberOf punycode
36962 * @param {String} input The Punycode string of ASCII-only symbols.
36963 * @returns {String} The resulting string of Unicode symbols.
36964 */
36965
36966
36967 var decode = function decode(input) {
36968 // Don't use UCS-2.
36969 var output = [];
36970 var inputLength = input.length;
36971 var i = 0;
36972 var n = initialN;
36973 var bias = initialBias; // Handle the basic code points: let `basic` be the number of input code
36974 // points before the last delimiter, or `0` if there is none, then copy
36975 // the first basic code points to the output.
36976
36977 var basic = input.lastIndexOf(delimiter);
36978
36979 if (basic < 0) {
36980 basic = 0;
36981 }
36982
36983 for (var j = 0; j < basic; ++j) {
36984 // if it's not a basic code point
36985 if (input.charCodeAt(j) >= 0x80) {
36986 error$1('not-basic');
36987 }
36988
36989 output.push(input.charCodeAt(j));
36990 } // Main decoding loop: start just after the last delimiter if any basic code
36991 // points were copied; start at the beginning otherwise.
36992
36993
36994 for (var index = basic > 0 ? basic + 1 : 0; index < inputLength;)
36995 /* no final expression */
36996 {
36997 // `index` is the index of the next character to be consumed.
36998 // Decode a generalized variable-length integer into `delta`,
36999 // which gets added to `i`. The overflow checking is easier
37000 // if we increase `i` as we go, then subtract off its starting
37001 // value at the end to obtain `delta`.
37002 var oldi = i;
37003
37004 for (var w = 1, k = base;;
37005 /* no condition */
37006 k += base) {
37007 if (index >= inputLength) {
37008 error$1('invalid-input');
37009 }
37010
37011 var digit = basicToDigit(input.charCodeAt(index++));
37012
37013 if (digit >= base || digit > floor((maxInt - i) / w)) {
37014 error$1('overflow');
37015 }
37016
37017 i += digit * w;
37018 var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
37019
37020 if (digit < t) {
37021 break;
37022 }
37023
37024 var baseMinusT = base - t;
37025
37026 if (w > floor(maxInt / baseMinusT)) {
37027 error$1('overflow');
37028 }
37029
37030 w *= baseMinusT;
37031 }
37032
37033 var out = output.length + 1;
37034 bias = adapt(i - oldi, out, oldi == 0); // `i` was supposed to wrap around from `out` to `0`,
37035 // incrementing `n` each time, so we'll fix that now:
37036
37037 if (floor(i / out) > maxInt - n) {
37038 error$1('overflow');
37039 }
37040
37041 n += floor(i / out);
37042 i %= out; // Insert `n` at position `i` of the output.
37043
37044 output.splice(i++, 0, n);
37045 }
37046
37047 return String.fromCodePoint.apply(String, output);
37048 };
37049 /**
37050 * Converts a string of Unicode symbols (e.g. a domain name label) to a
37051 * Punycode string of ASCII-only symbols.
37052 * @memberOf punycode
37053 * @param {String} input The string of Unicode symbols.
37054 * @returns {String} The resulting Punycode string of ASCII-only symbols.
37055 */
37056
37057
37058 var encode = function encode(input) {
37059 var output = []; // Convert the input in UCS-2 to an array of Unicode code points.
37060
37061 input = ucs2decode(input); // Cache the length.
37062
37063 var inputLength = input.length; // Initialize the state.
37064
37065 var n = initialN;
37066 var delta = 0;
37067 var bias = initialBias; // Handle the basic code points.
37068
37069 var _iteratorNormalCompletion = true;
37070 var _didIteratorError = false;
37071 var _iteratorError = undefined;
37072
37073 try {
37074 for (var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
37075 var _currentValue2 = _step.value;
37076
37077 if (_currentValue2 < 0x80) {
37078 output.push(stringFromCharCode(_currentValue2));
37079 }
37080 }
37081 } catch (err) {
37082 _didIteratorError = true;
37083 _iteratorError = err;
37084 } finally {
37085 try {
37086 if (!_iteratorNormalCompletion && _iterator.return) {
37087 _iterator.return();
37088 }
37089 } finally {
37090 if (_didIteratorError) {
37091 throw _iteratorError;
37092 }
37093 }
37094 }
37095
37096 var basicLength = output.length;
37097 var handledCPCount = basicLength; // `handledCPCount` is the number of code points that have been handled;
37098 // `basicLength` is the number of basic code points.
37099 // Finish the basic string with a delimiter unless it's empty.
37100
37101 if (basicLength) {
37102 output.push(delimiter);
37103 } // Main encoding loop:
37104
37105
37106 while (handledCPCount < inputLength) {
37107 // All non-basic code points < n have been handled already. Find the next
37108 // larger one:
37109 var m = maxInt;
37110 var _iteratorNormalCompletion2 = true;
37111 var _didIteratorError2 = false;
37112 var _iteratorError2 = undefined;
37113
37114 try {
37115 for (var _iterator2 = input[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
37116 var currentValue = _step2.value;
37117
37118 if (currentValue >= n && currentValue < m) {
37119 m = currentValue;
37120 }
37121 } // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
37122 // but guard against overflow.
37123
37124 } catch (err) {
37125 _didIteratorError2 = true;
37126 _iteratorError2 = err;
37127 } finally {
37128 try {
37129 if (!_iteratorNormalCompletion2 && _iterator2.return) {
37130 _iterator2.return();
37131 }
37132 } finally {
37133 if (_didIteratorError2) {
37134 throw _iteratorError2;
37135 }
37136 }
37137 }
37138
37139 var handledCPCountPlusOne = handledCPCount + 1;
37140
37141 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
37142 error$1('overflow');
37143 }
37144
37145 delta += (m - n) * handledCPCountPlusOne;
37146 n = m;
37147 var _iteratorNormalCompletion3 = true;
37148 var _didIteratorError3 = false;
37149 var _iteratorError3 = undefined;
37150
37151 try {
37152 for (var _iterator3 = input[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
37153 var _currentValue = _step3.value;
37154
37155 if (_currentValue < n && ++delta > maxInt) {
37156 error$1('overflow');
37157 }
37158
37159 if (_currentValue == n) {
37160 // Represent delta as a generalized variable-length integer.
37161 var q = delta;
37162
37163 for (var k = base;;
37164 /* no condition */
37165 k += base) {
37166 var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
37167
37168 if (q < t) {
37169 break;
37170 }
37171
37172 var qMinusT = q - t;
37173 var baseMinusT = base - t;
37174 output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
37175 q = floor(qMinusT / baseMinusT);
37176 }
37177
37178 output.push(stringFromCharCode(digitToBasic(q, 0)));
37179 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
37180 delta = 0;
37181 ++handledCPCount;
37182 }
37183 }
37184 } catch (err) {
37185 _didIteratorError3 = true;
37186 _iteratorError3 = err;
37187 } finally {
37188 try {
37189 if (!_iteratorNormalCompletion3 && _iterator3.return) {
37190 _iterator3.return();
37191 }
37192 } finally {
37193 if (_didIteratorError3) {
37194 throw _iteratorError3;
37195 }
37196 }
37197 }
37198
37199 ++delta;
37200 ++n;
37201 }
37202
37203 return output.join('');
37204 };
37205 /**
37206 * Converts a Punycode string representing a domain name or an email address
37207 * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
37208 * it doesn't matter if you call it on a string that has already been
37209 * converted to Unicode.
37210 * @memberOf punycode
37211 * @param {String} input The Punycoded domain name or email address to
37212 * convert to Unicode.
37213 * @returns {String} The Unicode representation of the given Punycode
37214 * string.
37215 */
37216
37217
37218 var toUnicode = function toUnicode(input) {
37219 return mapDomain(input, function (string) {
37220 return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
37221 });
37222 };
37223 /**
37224 * Converts a Unicode string representing a domain name or an email address to
37225 * Punycode. Only the non-ASCII parts of the domain name will be converted,
37226 * i.e. it doesn't matter if you call it with a domain that's already in
37227 * ASCII.
37228 * @memberOf punycode
37229 * @param {String} input The domain name or email address to convert, as a
37230 * Unicode string.
37231 * @returns {String} The Punycode representation of the given domain name or
37232 * email address.
37233 */
37234
37235
37236 var toASCII = function toASCII(input) {
37237 return mapDomain(input, function (string) {
37238 return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;
37239 });
37240 };
37241 /*--------------------------------------------------------------------------*/
37242
37243 /** Define the public API */
37244
37245
37246 var punycode = {
37247 /**
37248 * A string representing the current Punycode.js version number.
37249 * @memberOf punycode
37250 * @type String
37251 */
37252 'version': '2.1.0',
37253
37254 /**
37255 * An object of methods to convert from JavaScript's internal character
37256 * representation (UCS-2) to Unicode code points, and back.
37257 * @see <https://mathiasbynens.be/notes/javascript-encoding>
37258 * @memberOf punycode
37259 * @type Object
37260 */
37261 'ucs2': {
37262 'decode': ucs2decode,
37263 'encode': ucs2encode
37264 },
37265 'decode': decode,
37266 'encode': encode,
37267 'toASCII': toASCII,
37268 'toUnicode': toUnicode
37269 };
37270 /**
37271 * URI.js
37272 *
37273 * @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/validating/resolving library for JavaScript.
37274 * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
37275 * @see http://github.com/garycourt/uri-js
37276 */
37277
37278 /**
37279 * Copyright 2011 Gary Court. All rights reserved.
37280 *
37281 * Redistribution and use in source and binary forms, with or without modification, are
37282 * permitted provided that the following conditions are met:
37283 *
37284 * 1. Redistributions of source code must retain the above copyright notice, this list of
37285 * conditions and the following disclaimer.
37286 *
37287 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
37288 * of conditions and the following disclaimer in the documentation and/or other materials
37289 * provided with the distribution.
37290 *
37291 * THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED
37292 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
37293 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR
37294 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37295 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
37296 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
37297 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
37298 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
37299 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37300 *
37301 * The views and conclusions contained in the software and documentation are those of the
37302 * authors and should not be interpreted as representing official policies, either expressed
37303 * or implied, of Gary Court.
37304 */
37305
37306 var SCHEMES = {};
37307
37308 function pctEncChar(chr) {
37309 var c = chr.charCodeAt(0);
37310 var e = void 0;
37311 if (c < 16) e = "%0" + c.toString(16).toUpperCase();else if (c < 128) e = "%" + c.toString(16).toUpperCase();else if (c < 2048) e = "%" + (c >> 6 | 192).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();else e = "%" + (c >> 12 | 224).toString(16).toUpperCase() + "%" + (c >> 6 & 63 | 128).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();
37312 return e;
37313 }
37314
37315 function pctDecChars(str) {
37316 var newStr = "";
37317 var i = 0;
37318 var il = str.length;
37319
37320 while (i < il) {
37321 var c = parseInt(str.substr(i + 1, 2), 16);
37322
37323 if (c < 128) {
37324 newStr += String.fromCharCode(c);
37325 i += 3;
37326 } else if (c >= 194 && c < 224) {
37327 if (il - i >= 6) {
37328 var c2 = parseInt(str.substr(i + 4, 2), 16);
37329 newStr += String.fromCharCode((c & 31) << 6 | c2 & 63);
37330 } else {
37331 newStr += str.substr(i, 6);
37332 }
37333
37334 i += 6;
37335 } else if (c >= 224) {
37336 if (il - i >= 9) {
37337 var _c = parseInt(str.substr(i + 4, 2), 16);
37338
37339 var c3 = parseInt(str.substr(i + 7, 2), 16);
37340 newStr += String.fromCharCode((c & 15) << 12 | (_c & 63) << 6 | c3 & 63);
37341 } else {
37342 newStr += str.substr(i, 9);
37343 }
37344
37345 i += 9;
37346 } else {
37347 newStr += str.substr(i, 3);
37348 i += 3;
37349 }
37350 }
37351
37352 return newStr;
37353 }
37354
37355 function _normalizeComponentEncoding(components, protocol) {
37356 function decodeUnreserved(str) {
37357 var decStr = pctDecChars(str);
37358 return !decStr.match(protocol.UNRESERVED) ? str : decStr;
37359 }
37360
37361 if (components.scheme) components.scheme = String(components.scheme).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_SCHEME, "");
37362 if (components.userinfo !== undefined) components.userinfo = String(components.userinfo).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_USERINFO, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
37363 if (components.host !== undefined) components.host = String(components.host).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_HOST, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
37364 if (components.path !== undefined) components.path = String(components.path).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(components.scheme ? protocol.NOT_PATH : protocol.NOT_PATH_NOSCHEME, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
37365 if (components.query !== undefined) components.query = String(components.query).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_QUERY, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
37366 if (components.fragment !== undefined) components.fragment = String(components.fragment).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_FRAGMENT, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
37367 return components;
37368 }
37369
37370 function _stripLeadingZeros(str) {
37371 return str.replace(/^0*(.*)/, "$1") || "0";
37372 }
37373
37374 function _normalizeIPv4(host, protocol) {
37375 var matches = host.match(protocol.IPV4ADDRESS) || [];
37376
37377 var _matches = slicedToArray(matches, 2),
37378 address = _matches[1];
37379
37380 if (address) {
37381 return address.split(".").map(_stripLeadingZeros).join(".");
37382 } else {
37383 return host;
37384 }
37385 }
37386
37387 function _normalizeIPv6(host, protocol) {
37388 var matches = host.match(protocol.IPV6ADDRESS) || [];
37389
37390 var _matches2 = slicedToArray(matches, 3),
37391 address = _matches2[1],
37392 zone = _matches2[2];
37393
37394 if (address) {
37395 var _address$toLowerCase$ = address.toLowerCase().split('::').reverse(),
37396 _address$toLowerCase$2 = slicedToArray(_address$toLowerCase$, 2),
37397 last = _address$toLowerCase$2[0],
37398 first = _address$toLowerCase$2[1];
37399
37400 var firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
37401 var lastFields = last.split(":").map(_stripLeadingZeros);
37402 var isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
37403 var fieldCount = isLastFieldIPv4Address ? 7 : 8;
37404 var lastFieldsStart = lastFields.length - fieldCount;
37405 var fields = Array(fieldCount);
37406
37407 for (var x = 0; x < fieldCount; ++x) {
37408 fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || '';
37409 }
37410
37411 if (isLastFieldIPv4Address) {
37412 fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
37413 }
37414
37415 var allZeroFields = fields.reduce(function (acc, field, index) {
37416 if (!field || field === "0") {
37417 var lastLongest = acc[acc.length - 1];
37418
37419 if (lastLongest && lastLongest.index + lastLongest.length === index) {
37420 lastLongest.length++;
37421 } else {
37422 acc.push({
37423 index: index,
37424 length: 1
37425 });
37426 }
37427 }
37428
37429 return acc;
37430 }, []);
37431 var longestZeroFields = allZeroFields.sort(function (a, b) {
37432 return b.length - a.length;
37433 })[0];
37434 var newHost = void 0;
37435
37436 if (longestZeroFields && longestZeroFields.length > 1) {
37437 var newFirst = fields.slice(0, longestZeroFields.index);
37438 var newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
37439 newHost = newFirst.join(":") + "::" + newLast.join(":");
37440 } else {
37441 newHost = fields.join(":");
37442 }
37443
37444 if (zone) {
37445 newHost += "%" + zone;
37446 }
37447
37448 return newHost;
37449 } else {
37450 return host;
37451 }
37452 }
37453
37454 var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
37455 var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined;
37456
37457 function parse(uriString) {
37458 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
37459 var components = {};
37460 var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
37461 if (options.reference === "suffix") uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString;
37462 var matches = uriString.match(URI_PARSE);
37463
37464 if (matches) {
37465 if (NO_MATCH_IS_UNDEFINED) {
37466 //store each component
37467 components.scheme = matches[1];
37468 components.userinfo = matches[3];
37469 components.host = matches[4];
37470 components.port = parseInt(matches[5], 10);
37471 components.path = matches[6] || "";
37472 components.query = matches[7];
37473 components.fragment = matches[8]; //fix port number
37474
37475 if (isNaN(components.port)) {
37476 components.port = matches[5];
37477 }
37478 } else {
37479 //IE FIX for improper RegExp matching
37480 //store each component
37481 components.scheme = matches[1] || undefined;
37482 components.userinfo = uriString.indexOf("@") !== -1 ? matches[3] : undefined;
37483 components.host = uriString.indexOf("//") !== -1 ? matches[4] : undefined;
37484 components.port = parseInt(matches[5], 10);
37485 components.path = matches[6] || "";
37486 components.query = uriString.indexOf("?") !== -1 ? matches[7] : undefined;
37487 components.fragment = uriString.indexOf("#") !== -1 ? matches[8] : undefined; //fix port number
37488
37489 if (isNaN(components.port)) {
37490 components.port = uriString.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined;
37491 }
37492 }
37493
37494 if (components.host) {
37495 //normalize IP hosts
37496 components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
37497 } //determine reference type
37498
37499
37500 if (components.scheme === undefined && components.userinfo === undefined && components.host === undefined && components.port === undefined && !components.path && components.query === undefined) {
37501 components.reference = "same-document";
37502 } else if (components.scheme === undefined) {
37503 components.reference = "relative";
37504 } else if (components.fragment === undefined) {
37505 components.reference = "absolute";
37506 } else {
37507 components.reference = "uri";
37508 } //check for reference errors
37509
37510
37511 if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) {
37512 components.error = components.error || "URI is not a " + options.reference + " reference.";
37513 } //find scheme handler
37514
37515
37516 var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()]; //check if scheme can't handle IRIs
37517
37518 if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
37519 //if host component is a domain name
37520 if (components.host && (options.domainHost || schemeHandler && schemeHandler.domainHost)) {
37521 //convert Unicode IDN -> ASCII IDN
37522 try {
37523 components.host = punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase());
37524 } catch (e) {
37525 components.error = components.error || "Host's domain name can not be converted to ASCII via punycode: " + e;
37526 }
37527 } //convert IRI -> URI
37528
37529
37530 _normalizeComponentEncoding(components, URI_PROTOCOL);
37531 } else {
37532 //normalize encodings
37533 _normalizeComponentEncoding(components, protocol);
37534 } //perform scheme specific parsing
37535
37536
37537 if (schemeHandler && schemeHandler.parse) {
37538 schemeHandler.parse(components, options);
37539 }
37540 } else {
37541 components.error = components.error || "URI can not be parsed.";
37542 }
37543
37544 return components;
37545 }
37546
37547 function _recomposeAuthority(components, options) {
37548 var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
37549 var uriTokens = [];
37550
37551 if (components.userinfo !== undefined) {
37552 uriTokens.push(components.userinfo);
37553 uriTokens.push("@");
37554 }
37555
37556 if (components.host !== undefined) {
37557 //normalize IP hosts, add brackets and escape zone separator for IPv6
37558 uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function (_, $1, $2) {
37559 return "[" + $1 + ($2 ? "%25" + $2 : "") + "]";
37560 }));
37561 }
37562
37563 if (typeof components.port === "number" || typeof components.port === "string") {
37564 uriTokens.push(":");
37565 uriTokens.push(String(components.port));
37566 }
37567
37568 return uriTokens.length ? uriTokens.join("") : undefined;
37569 }
37570
37571 var RDS1 = /^\.\.?\//;
37572 var RDS2 = /^\/\.(\/|$)/;
37573 var RDS3 = /^\/\.\.(\/|$)/;
37574 var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
37575
37576 function removeDotSegments(input) {
37577 var output = [];
37578
37579 while (input.length) {
37580 if (input.match(RDS1)) {
37581 input = input.replace(RDS1, "");
37582 } else if (input.match(RDS2)) {
37583 input = input.replace(RDS2, "/");
37584 } else if (input.match(RDS3)) {
37585 input = input.replace(RDS3, "/");
37586 output.pop();
37587 } else if (input === "." || input === "..") {
37588 input = "";
37589 } else {
37590 var im = input.match(RDS5);
37591
37592 if (im) {
37593 var s = im[0];
37594 input = input.slice(s.length);
37595 output.push(s);
37596 } else {
37597 throw new Error("Unexpected dot segment condition");
37598 }
37599 }
37600 }
37601
37602 return output.join("");
37603 }
37604
37605 function serialize(components) {
37606 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
37607 var protocol = options.iri ? IRI_PROTOCOL : URI_PROTOCOL;
37608 var uriTokens = []; //find scheme handler
37609
37610 var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()]; //perform scheme specific serialization
37611
37612 if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options);
37613
37614 if (components.host) {
37615 //if host component is an IPv6 address
37616 if (protocol.IPV6ADDRESS.test(components.host)) {} //TODO: normalize IPv6 address as per RFC 5952
37617 //if host component is a domain name
37618 else if (options.domainHost || schemeHandler && schemeHandler.domainHost) {
37619 //convert IDN via punycode
37620 try {
37621 components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host);
37622 } catch (e) {
37623 components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
37624 }
37625 }
37626 } //normalize encoding
37627
37628
37629 _normalizeComponentEncoding(components, protocol);
37630
37631 if (options.reference !== "suffix" && components.scheme) {
37632 uriTokens.push(components.scheme);
37633 uriTokens.push(":");
37634 }
37635
37636 var authority = _recomposeAuthority(components, options);
37637
37638 if (authority !== undefined) {
37639 if (options.reference !== "suffix") {
37640 uriTokens.push("//");
37641 }
37642
37643 uriTokens.push(authority);
37644
37645 if (components.path && components.path.charAt(0) !== "/") {
37646 uriTokens.push("/");
37647 }
37648 }
37649
37650 if (components.path !== undefined) {
37651 var s = components.path;
37652
37653 if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
37654 s = removeDotSegments(s);
37655 }
37656
37657 if (authority === undefined) {
37658 s = s.replace(/^\/\//, "/%2F"); //don't allow the path to start with "//"
37659 }
37660
37661 uriTokens.push(s);
37662 }
37663
37664 if (components.query !== undefined) {
37665 uriTokens.push("?");
37666 uriTokens.push(components.query);
37667 }
37668
37669 if (components.fragment !== undefined) {
37670 uriTokens.push("#");
37671 uriTokens.push(components.fragment);
37672 }
37673
37674 return uriTokens.join(""); //merge tokens into a string
37675 }
37676
37677 function resolveComponents(base, relative) {
37678 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
37679 var skipNormalization = arguments[3];
37680 var target = {};
37681
37682 if (!skipNormalization) {
37683 base = parse(serialize(base, options), options); //normalize base components
37684
37685 relative = parse(serialize(relative, options), options); //normalize relative components
37686 }
37687
37688 options = options || {};
37689
37690 if (!options.tolerant && relative.scheme) {
37691 target.scheme = relative.scheme; //target.authority = relative.authority;
37692
37693 target.userinfo = relative.userinfo;
37694 target.host = relative.host;
37695 target.port = relative.port;
37696 target.path = removeDotSegments(relative.path || "");
37697 target.query = relative.query;
37698 } else {
37699 if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
37700 //target.authority = relative.authority;
37701 target.userinfo = relative.userinfo;
37702 target.host = relative.host;
37703 target.port = relative.port;
37704 target.path = removeDotSegments(relative.path || "");
37705 target.query = relative.query;
37706 } else {
37707 if (!relative.path) {
37708 target.path = base.path;
37709
37710 if (relative.query !== undefined) {
37711 target.query = relative.query;
37712 } else {
37713 target.query = base.query;
37714 }
37715 } else {
37716 if (relative.path.charAt(0) === "/") {
37717 target.path = removeDotSegments(relative.path);
37718 } else {
37719 if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) {
37720 target.path = "/" + relative.path;
37721 } else if (!base.path) {
37722 target.path = relative.path;
37723 } else {
37724 target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
37725 }
37726
37727 target.path = removeDotSegments(target.path);
37728 }
37729
37730 target.query = relative.query;
37731 } //target.authority = base.authority;
37732
37733
37734 target.userinfo = base.userinfo;
37735 target.host = base.host;
37736 target.port = base.port;
37737 }
37738
37739 target.scheme = base.scheme;
37740 }
37741
37742 target.fragment = relative.fragment;
37743 return target;
37744 }
37745
37746 function resolve(baseURI, relativeURI, options) {
37747 var schemelessOptions = assign({
37748 scheme: 'null'
37749 }, options);
37750 return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
37751 }
37752
37753 function normalize(uri, options) {
37754 if (typeof uri === "string") {
37755 uri = serialize(parse(uri, options), options);
37756 } else if (typeOf(uri) === "object") {
37757 uri = parse(serialize(uri, options), options);
37758 }
37759
37760 return uri;
37761 }
37762
37763 function equal(uriA, uriB, options) {
37764 if (typeof uriA === "string") {
37765 uriA = serialize(parse(uriA, options), options);
37766 } else if (typeOf(uriA) === "object") {
37767 uriA = serialize(uriA, options);
37768 }
37769
37770 if (typeof uriB === "string") {
37771 uriB = serialize(parse(uriB, options), options);
37772 } else if (typeOf(uriB) === "object") {
37773 uriB = serialize(uriB, options);
37774 }
37775
37776 return uriA === uriB;
37777 }
37778
37779 function escapeComponent(str, options) {
37780 return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.ESCAPE : IRI_PROTOCOL.ESCAPE, pctEncChar);
37781 }
37782
37783 function unescapeComponent(str, options) {
37784 return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.PCT_ENCODED : IRI_PROTOCOL.PCT_ENCODED, pctDecChars);
37785 }
37786
37787 var handler = {
37788 scheme: "http",
37789 domainHost: true,
37790 parse: function parse(components, options) {
37791 //report missing host
37792 if (!components.host) {
37793 components.error = components.error || "HTTP URIs must have a host.";
37794 }
37795
37796 return components;
37797 },
37798 serialize: function serialize(components, options) {
37799 var secure = String(components.scheme).toLowerCase() === "https"; //normalize the default port
37800
37801 if (components.port === (secure ? 443 : 80) || components.port === "") {
37802 components.port = undefined;
37803 } //normalize the empty path
37804
37805
37806 if (!components.path) {
37807 components.path = "/";
37808 } //NOTE: We do not parse query strings for HTTP URIs
37809 //as WWW Form Url Encoded query strings are part of the HTML4+ spec,
37810 //and not the HTTP spec.
37811
37812
37813 return components;
37814 }
37815 };
37816 var handler$1 = {
37817 scheme: "https",
37818 domainHost: handler.domainHost,
37819 parse: handler.parse,
37820 serialize: handler.serialize
37821 };
37822
37823 function isSecure(wsComponents) {
37824 return typeof wsComponents.secure === 'boolean' ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
37825 } //RFC 6455
37826
37827
37828 var handler$2 = {
37829 scheme: "ws",
37830 domainHost: true,
37831 parse: function parse(components, options) {
37832 var wsComponents = components; //indicate if the secure flag is set
37833
37834 wsComponents.secure = isSecure(wsComponents); //construct resouce name
37835
37836 wsComponents.resourceName = (wsComponents.path || '/') + (wsComponents.query ? '?' + wsComponents.query : '');
37837 wsComponents.path = undefined;
37838 wsComponents.query = undefined;
37839 return wsComponents;
37840 },
37841 serialize: function serialize(wsComponents, options) {
37842 //normalize the default port
37843 if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
37844 wsComponents.port = undefined;
37845 } //ensure scheme matches secure flag
37846
37847
37848 if (typeof wsComponents.secure === 'boolean') {
37849 wsComponents.scheme = wsComponents.secure ? 'wss' : 'ws';
37850 wsComponents.secure = undefined;
37851 } //reconstruct path from resource name
37852
37853
37854 if (wsComponents.resourceName) {
37855 var _wsComponents$resourc = wsComponents.resourceName.split('?'),
37856 _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2),
37857 path = _wsComponents$resourc2[0],
37858 query = _wsComponents$resourc2[1];
37859
37860 wsComponents.path = path && path !== '/' ? path : undefined;
37861 wsComponents.query = query;
37862 wsComponents.resourceName = undefined;
37863 } //forbid fragment component
37864
37865
37866 wsComponents.fragment = undefined;
37867 return wsComponents;
37868 }
37869 };
37870 var handler$3 = {
37871 scheme: "wss",
37872 domainHost: handler$2.domainHost,
37873 parse: handler$2.parse,
37874 serialize: handler$2.serialize
37875 };
37876 var O = {};
37877 var isIRI = true; //RFC 3986
37878
37879 var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + (isIRI ? "\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF" : "") + "]";
37880 var HEXDIG$$ = "[0-9A-Fa-f]"; //case-insensitive
37881
37882 var PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)); //expanded
37883 //RFC 5322, except these symbols as per RFC 6068: @ : / ? # [ ] & ; =
37884 //const ATEXT$$ = "[A-Za-z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]";
37885 //const WSP$$ = "[\\x20\\x09]";
37886 //const OBS_QTEXT$$ = "[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]"; //(%d1-8 / %d11-12 / %d14-31 / %d127)
37887 //const QTEXT$$ = merge("[\\x21\\x23-\\x5B\\x5D-\\x7E]", OBS_QTEXT$$); //%d33 / %d35-91 / %d93-126 / obs-qtext
37888 //const VCHAR$$ = "[\\x21-\\x7E]";
37889 //const WSP$$ = "[\\x20\\x09]";
37890 //const OBS_QP$ = subexp("\\\\" + merge("[\\x00\\x0D\\x0A]", OBS_QTEXT$$)); //%d0 / CR / LF / obs-qtext
37891 //const FWS$ = subexp(subexp(WSP$$ + "*" + "\\x0D\\x0A") + "?" + WSP$$ + "+");
37892 //const QUOTED_PAIR$ = subexp(subexp("\\\\" + subexp(VCHAR$$ + "|" + WSP$$)) + "|" + OBS_QP$);
37893 //const QUOTED_STRING$ = subexp('\\"' + subexp(FWS$ + "?" + QCONTENT$) + "*" + FWS$ + "?" + '\\"');
37894
37895 var ATEXT$$ = "[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]";
37896 var QTEXT$$ = "[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]";
37897 var VCHAR$$ = merge(QTEXT$$, "[\\\"\\\\]");
37898 var SOME_DELIMS$$ = "[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]";
37899 var UNRESERVED = new RegExp(UNRESERVED$$, "g");
37900 var PCT_ENCODED = new RegExp(PCT_ENCODED$, "g");
37901 var NOT_LOCAL_PART = new RegExp(merge("[^]", ATEXT$$, "[\\.]", '[\\"]', VCHAR$$), "g");
37902 var NOT_HFNAME = new RegExp(merge("[^]", UNRESERVED$$, SOME_DELIMS$$), "g");
37903 var NOT_HFVALUE = NOT_HFNAME;
37904
37905 function decodeUnreserved(str) {
37906 var decStr = pctDecChars(str);
37907 return !decStr.match(UNRESERVED) ? str : decStr;
37908 }
37909
37910 var handler$4 = {
37911 scheme: "mailto",
37912 parse: function parse$$1(components, options) {
37913 var mailtoComponents = components;
37914 var to = mailtoComponents.to = mailtoComponents.path ? mailtoComponents.path.split(",") : [];
37915 mailtoComponents.path = undefined;
37916
37917 if (mailtoComponents.query) {
37918 var unknownHeaders = false;
37919 var headers = {};
37920 var hfields = mailtoComponents.query.split("&");
37921
37922 for (var x = 0, xl = hfields.length; x < xl; ++x) {
37923 var hfield = hfields[x].split("=");
37924
37925 switch (hfield[0]) {
37926 case "to":
37927 var toAddrs = hfield[1].split(",");
37928
37929 for (var _x = 0, _xl = toAddrs.length; _x < _xl; ++_x) {
37930 to.push(toAddrs[_x]);
37931 }
37932
37933 break;
37934
37935 case "subject":
37936 mailtoComponents.subject = unescapeComponent(hfield[1], options);
37937 break;
37938
37939 case "body":
37940 mailtoComponents.body = unescapeComponent(hfield[1], options);
37941 break;
37942
37943 default:
37944 unknownHeaders = true;
37945 headers[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options);
37946 break;
37947 }
37948 }
37949
37950 if (unknownHeaders) mailtoComponents.headers = headers;
37951 }
37952
37953 mailtoComponents.query = undefined;
37954
37955 for (var _x2 = 0, _xl2 = to.length; _x2 < _xl2; ++_x2) {
37956 var addr = to[_x2].split("@");
37957
37958 addr[0] = unescapeComponent(addr[0]);
37959
37960 if (!options.unicodeSupport) {
37961 //convert Unicode IDN -> ASCII IDN
37962 try {
37963 addr[1] = punycode.toASCII(unescapeComponent(addr[1], options).toLowerCase());
37964 } catch (e) {
37965 mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
37966 }
37967 } else {
37968 addr[1] = unescapeComponent(addr[1], options).toLowerCase();
37969 }
37970
37971 to[_x2] = addr.join("@");
37972 }
37973
37974 return mailtoComponents;
37975 },
37976 serialize: function serialize$$1(mailtoComponents, options) {
37977 var components = mailtoComponents;
37978 var to = toArray(mailtoComponents.to);
37979
37980 if (to) {
37981 for (var x = 0, xl = to.length; x < xl; ++x) {
37982 var toAddr = String(to[x]);
37983 var atIdx = toAddr.lastIndexOf("@");
37984 var localPart = toAddr.slice(0, atIdx).replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_LOCAL_PART, pctEncChar);
37985 var domain = toAddr.slice(atIdx + 1); //convert IDN via punycode
37986
37987 try {
37988 domain = !options.iri ? punycode.toASCII(unescapeComponent(domain, options).toLowerCase()) : punycode.toUnicode(domain);
37989 } catch (e) {
37990 components.error = components.error || "Email address's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
37991 }
37992
37993 to[x] = localPart + "@" + domain;
37994 }
37995
37996 components.path = to.join(",");
37997 }
37998
37999 var headers = mailtoComponents.headers = mailtoComponents.headers || {};
38000 if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject;
38001 if (mailtoComponents.body) headers["body"] = mailtoComponents.body;
38002 var fields = [];
38003
38004 for (var name in headers) {
38005 if (headers[name] !== O[name]) {
38006 fields.push(name.replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFNAME, pctEncChar) + "=" + headers[name].replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFVALUE, pctEncChar));
38007 }
38008 }
38009
38010 if (fields.length) {
38011 components.query = fields.join("&");
38012 }
38013
38014 return components;
38015 }
38016 };
38017 var URN_PARSE = /^([^\:]+)\:(.*)/; //RFC 2141
38018
38019 var handler$5 = {
38020 scheme: "urn",
38021 parse: function parse$$1(components, options) {
38022 var matches = components.path && components.path.match(URN_PARSE);
38023 var urnComponents = components;
38024
38025 if (matches) {
38026 var scheme = options.scheme || urnComponents.scheme || "urn";
38027 var nid = matches[1].toLowerCase();
38028 var nss = matches[2];
38029 var urnScheme = scheme + ":" + (options.nid || nid);
38030 var schemeHandler = SCHEMES[urnScheme];
38031 urnComponents.nid = nid;
38032 urnComponents.nss = nss;
38033 urnComponents.path = undefined;
38034
38035 if (schemeHandler) {
38036 urnComponents = schemeHandler.parse(urnComponents, options);
38037 }
38038 } else {
38039 urnComponents.error = urnComponents.error || "URN can not be parsed.";
38040 }
38041
38042 return urnComponents;
38043 },
38044 serialize: function serialize$$1(urnComponents, options) {
38045 var scheme = options.scheme || urnComponents.scheme || "urn";
38046 var nid = urnComponents.nid;
38047 var urnScheme = scheme + ":" + (options.nid || nid);
38048 var schemeHandler = SCHEMES[urnScheme];
38049
38050 if (schemeHandler) {
38051 urnComponents = schemeHandler.serialize(urnComponents, options);
38052 }
38053
38054 var uriComponents = urnComponents;
38055 var nss = urnComponents.nss;
38056 uriComponents.path = (nid || options.nid) + ":" + nss;
38057 return uriComponents;
38058 }
38059 };
38060 var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/; //RFC 4122
38061
38062 var handler$6 = {
38063 scheme: "urn:uuid",
38064 parse: function parse(urnComponents, options) {
38065 var uuidComponents = urnComponents;
38066 uuidComponents.uuid = uuidComponents.nss;
38067 uuidComponents.nss = undefined;
38068
38069 if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) {
38070 uuidComponents.error = uuidComponents.error || "UUID is not valid.";
38071 }
38072
38073 return uuidComponents;
38074 },
38075 serialize: function serialize(uuidComponents, options) {
38076 var urnComponents = uuidComponents; //normalize UUID
38077
38078 urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
38079 return urnComponents;
38080 }
38081 };
38082 SCHEMES[handler.scheme] = handler;
38083 SCHEMES[handler$1.scheme] = handler$1;
38084 SCHEMES[handler$2.scheme] = handler$2;
38085 SCHEMES[handler$3.scheme] = handler$3;
38086 SCHEMES[handler$4.scheme] = handler$4;
38087 SCHEMES[handler$5.scheme] = handler$5;
38088 SCHEMES[handler$6.scheme] = handler$6;
38089 exports.SCHEMES = SCHEMES;
38090 exports.pctEncChar = pctEncChar;
38091 exports.pctDecChars = pctDecChars;
38092 exports.parse = parse;
38093 exports.removeDotSegments = removeDotSegments;
38094 exports.serialize = serialize;
38095 exports.resolveComponents = resolveComponents;
38096 exports.resolve = resolve;
38097 exports.normalize = normalize;
38098 exports.equal = equal;
38099 exports.escapeComponent = escapeComponent;
38100 exports.unescapeComponent = unescapeComponent;
38101 Object.defineProperty(exports, '__esModule', {
38102 value: true
38103 });
38104 });
38105
38106 /***/ }),
38107 /* 450 */
38108 /***/ ((module) => {
38109
38110 "use strict";
38111 // do not edit .js files directly - edit src/index.jst
38112
38113 module.exports = function equal(a, b) {
38114 if (a === b) return true;
38115
38116 if (a && b && typeof a == 'object' && typeof b == 'object') {
38117 if (a.constructor !== b.constructor) return false;
38118 var length, i, keys;
38119
38120 if (Array.isArray(a)) {
38121 length = a.length;
38122 if (length != b.length) return false;
38123
38124 for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false;
38125
38126 return true;
38127 }
38128
38129 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
38130 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
38131 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
38132 keys = Object.keys(a);
38133 length = keys.length;
38134 if (length !== Object.keys(b).length) return false;
38135
38136 for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
38137
38138 for (i = length; i-- !== 0;) {
38139 var key = keys[i];
38140 if (!equal(a[key], b[key])) return false;
38141 }
38142
38143 return true;
38144 } // true if both NaN, false otherwise
38145
38146
38147 return a !== a && b !== b;
38148 };
38149
38150 /***/ }),
38151 /* 451 */
38152 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
38153
38154 "use strict";
38155
38156
38157 module.exports = {
38158 copy: copy,
38159 checkDataType: checkDataType,
38160 checkDataTypes: checkDataTypes,
38161 coerceToTypes: coerceToTypes,
38162 toHash: toHash,
38163 getProperty: getProperty,
38164 escapeQuotes: escapeQuotes,
38165 equal: __webpack_require__(450),
38166 ucs2length: __webpack_require__(452),
38167 varOccurences: varOccurences,
38168 varReplace: varReplace,
38169 schemaHasRules: schemaHasRules,
38170 schemaHasRulesExcept: schemaHasRulesExcept,
38171 schemaUnknownRules: schemaUnknownRules,
38172 toQuotedString: toQuotedString,
38173 getPathExpr: getPathExpr,
38174 getPath: getPath,
38175 getData: getData,
38176 unescapeFragment: unescapeFragment,
38177 unescapeJsonPointer: unescapeJsonPointer,
38178 escapeFragment: escapeFragment,
38179 escapeJsonPointer: escapeJsonPointer
38180 };
38181
38182 function copy(o, to) {
38183 to = to || {};
38184
38185 for (var key in o) to[key] = o[key];
38186
38187 return to;
38188 }
38189
38190 function checkDataType(dataType, data, strictNumbers, negate) {
38191 var EQUAL = negate ? ' !== ' : ' === ',
38192 AND = negate ? ' || ' : ' && ',
38193 OK = negate ? '!' : '',
38194 NOT = negate ? '' : '!';
38195
38196 switch (dataType) {
38197 case 'null':
38198 return data + EQUAL + 'null';
38199
38200 case 'array':
38201 return OK + 'Array.isArray(' + data + ')';
38202
38203 case 'object':
38204 return '(' + OK + data + AND + 'typeof ' + data + EQUAL + '"object"' + AND + NOT + 'Array.isArray(' + data + '))';
38205
38206 case 'integer':
38207 return '(typeof ' + data + EQUAL + '"number"' + AND + NOT + '(' + data + ' % 1)' + AND + data + EQUAL + data + (strictNumbers ? AND + OK + 'isFinite(' + data + ')' : '') + ')';
38208
38209 case 'number':
38210 return '(typeof ' + data + EQUAL + '"' + dataType + '"' + (strictNumbers ? AND + OK + 'isFinite(' + data + ')' : '') + ')';
38211
38212 default:
38213 return 'typeof ' + data + EQUAL + '"' + dataType + '"';
38214 }
38215 }
38216
38217 function checkDataTypes(dataTypes, data, strictNumbers) {
38218 switch (dataTypes.length) {
38219 case 1:
38220 return checkDataType(dataTypes[0], data, strictNumbers, true);
38221
38222 default:
38223 var code = '';
38224 var types = toHash(dataTypes);
38225
38226 if (types.array && types.object) {
38227 code = types.null ? '(' : '(!' + data + ' || ';
38228 code += 'typeof ' + data + ' !== "object")';
38229 delete types.null;
38230 delete types.array;
38231 delete types.object;
38232 }
38233
38234 if (types.number) delete types.integer;
38235
38236 for (var t in types) code += (code ? ' && ' : '') + checkDataType(t, data, strictNumbers, true);
38237
38238 return code;
38239 }
38240 }
38241
38242 var COERCE_TO_TYPES = toHash(['string', 'number', 'integer', 'boolean', 'null']);
38243
38244 function coerceToTypes(optionCoerceTypes, dataTypes) {
38245 if (Array.isArray(dataTypes)) {
38246 var types = [];
38247
38248 for (var i = 0; i < dataTypes.length; i++) {
38249 var t = dataTypes[i];
38250 if (COERCE_TO_TYPES[t]) types[types.length] = t;else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
38251 }
38252
38253 if (types.length) return types;
38254 } else if (COERCE_TO_TYPES[dataTypes]) {
38255 return [dataTypes];
38256 } else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
38257 return ['array'];
38258 }
38259 }
38260
38261 function toHash(arr) {
38262 var hash = {};
38263
38264 for (var i = 0; i < arr.length; i++) hash[arr[i]] = true;
38265
38266 return hash;
38267 }
38268
38269 var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
38270 var SINGLE_QUOTE = /'|\\/g;
38271
38272 function getProperty(key) {
38273 return typeof key == 'number' ? '[' + key + ']' : IDENTIFIER.test(key) ? '.' + key : "['" + escapeQuotes(key) + "']";
38274 }
38275
38276 function escapeQuotes(str) {
38277 return str.replace(SINGLE_QUOTE, '\\$&').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\f/g, '\\f').replace(/\t/g, '\\t');
38278 }
38279
38280 function varOccurences(str, dataVar) {
38281 dataVar += '[^0-9]';
38282 var matches = str.match(new RegExp(dataVar, 'g'));
38283 return matches ? matches.length : 0;
38284 }
38285
38286 function varReplace(str, dataVar, expr) {
38287 dataVar += '([^0-9])';
38288 expr = expr.replace(/\$/g, '$$$$');
38289 return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
38290 }
38291
38292 function schemaHasRules(schema, rules) {
38293 if (typeof schema == 'boolean') return !schema;
38294
38295 for (var key in schema) if (rules[key]) return true;
38296 }
38297
38298 function schemaHasRulesExcept(schema, rules, exceptKeyword) {
38299 if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not';
38300
38301 for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
38302 }
38303
38304 function schemaUnknownRules(schema, rules) {
38305 if (typeof schema == 'boolean') return;
38306
38307 for (var key in schema) if (!rules[key]) return key;
38308 }
38309
38310 function toQuotedString(str) {
38311 return '\'' + escapeQuotes(str) + '\'';
38312 }
38313
38314 function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
38315 var path = jsonPointers // false by default
38316 ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')') : isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'';
38317 return joinPaths(currentPath, path);
38318 }
38319
38320 function getPath(currentPath, prop, jsonPointers) {
38321 var path = jsonPointers // false by default
38322 ? toQuotedString('/' + escapeJsonPointer(prop)) : toQuotedString(getProperty(prop));
38323 return joinPaths(currentPath, path);
38324 }
38325
38326 var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
38327 var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
38328
38329 function getData($data, lvl, paths) {
38330 var up, jsonPointer, data, matches;
38331 if ($data === '') return 'rootData';
38332
38333 if ($data[0] == '/') {
38334 if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
38335 jsonPointer = $data;
38336 data = 'rootData';
38337 } else {
38338 matches = $data.match(RELATIVE_JSON_POINTER);
38339 if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
38340 up = +matches[1];
38341 jsonPointer = matches[2];
38342
38343 if (jsonPointer == '#') {
38344 if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
38345 return paths[lvl - up];
38346 }
38347
38348 if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
38349 data = 'data' + (lvl - up || '');
38350 if (!jsonPointer) return data;
38351 }
38352
38353 var expr = data;
38354 var segments = jsonPointer.split('/');
38355
38356 for (var i = 0; i < segments.length; i++) {
38357 var segment = segments[i];
38358
38359 if (segment) {
38360 data += getProperty(unescapeJsonPointer(segment));
38361 expr += ' && ' + data;
38362 }
38363 }
38364
38365 return expr;
38366 }
38367
38368 function joinPaths(a, b) {
38369 if (a == '""') return b;
38370 return (a + ' + ' + b).replace(/([^\\])' \+ '/g, '$1');
38371 }
38372
38373 function unescapeFragment(str) {
38374 return unescapeJsonPointer(decodeURIComponent(str));
38375 }
38376
38377 function escapeFragment(str) {
38378 return encodeURIComponent(escapeJsonPointer(str));
38379 }
38380
38381 function escapeJsonPointer(str) {
38382 return str.replace(/~/g, '~0').replace(/\//g, '~1');
38383 }
38384
38385 function unescapeJsonPointer(str) {
38386 return str.replace(/~1/g, '/').replace(/~0/g, '~');
38387 }
38388
38389 /***/ }),
38390 /* 452 */
38391 /***/ ((module) => {
38392
38393 "use strict";
38394 // https://mathiasbynens.be/notes/javascript-encoding
38395 // https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
38396
38397 module.exports = function ucs2length(str) {
38398 var length = 0,
38399 len = str.length,
38400 pos = 0,
38401 value;
38402
38403 while (pos < len) {
38404 length++;
38405 value = str.charCodeAt(pos++);
38406
38407 if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
38408 // high surrogate, and there is a next character
38409 value = str.charCodeAt(pos);
38410 if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
38411 }
38412 }
38413
38414 return length;
38415 };
38416
38417 /***/ }),
38418 /* 453 */
38419 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
38420
38421 "use strict";
38422
38423
38424 var util = __webpack_require__(451);
38425
38426 module.exports = SchemaObject;
38427
38428 function SchemaObject(obj) {
38429 util.copy(obj, this);
38430 }
38431
38432 /***/ }),
38433 /* 454 */
38434 /***/ ((module) => {
38435
38436 "use strict";
38437
38438
38439 var traverse = module.exports = function (schema, opts, cb) {
38440 // Legacy support for v0.3.1 and earlier.
38441 if (typeof opts == 'function') {
38442 cb = opts;
38443 opts = {};
38444 }
38445
38446 cb = opts.cb || cb;
38447 var pre = typeof cb == 'function' ? cb : cb.pre || function () {};
38448
38449 var post = cb.post || function () {};
38450
38451 _traverse(opts, pre, post, schema, '', schema);
38452 };
38453
38454 traverse.keywords = {
38455 additionalItems: true,
38456 items: true,
38457 contains: true,
38458 additionalProperties: true,
38459 propertyNames: true,
38460 not: true
38461 };
38462 traverse.arrayKeywords = {
38463 items: true,
38464 allOf: true,
38465 anyOf: true,
38466 oneOf: true
38467 };
38468 traverse.propsKeywords = {
38469 definitions: true,
38470 properties: true,
38471 patternProperties: true,
38472 dependencies: true
38473 };
38474 traverse.skipKeywords = {
38475 default: true,
38476 enum: true,
38477 const: true,
38478 required: true,
38479 maximum: true,
38480 minimum: true,
38481 exclusiveMaximum: true,
38482 exclusiveMinimum: true,
38483 multipleOf: true,
38484 maxLength: true,
38485 minLength: true,
38486 pattern: true,
38487 format: true,
38488 maxItems: true,
38489 minItems: true,
38490 uniqueItems: true,
38491 maxProperties: true,
38492 minProperties: true
38493 };
38494
38495 function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
38496 if (schema && typeof schema == 'object' && !Array.isArray(schema)) {
38497 pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
38498
38499 for (var key in schema) {
38500 var sch = schema[key];
38501
38502 if (Array.isArray(sch)) {
38503 if (key in traverse.arrayKeywords) {
38504 for (var i = 0; i < sch.length; i++) _traverse(opts, pre, post, sch[i], jsonPtr + '/' + key + '/' + i, rootSchema, jsonPtr, key, schema, i);
38505 }
38506 } else if (key in traverse.propsKeywords) {
38507 if (sch && typeof sch == 'object') {
38508 for (var prop in sch) _traverse(opts, pre, post, sch[prop], jsonPtr + '/' + key + '/' + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
38509 }
38510 } else if (key in traverse.keywords || opts.allKeys && !(key in traverse.skipKeywords)) {
38511 _traverse(opts, pre, post, sch, jsonPtr + '/' + key, rootSchema, jsonPtr, key, schema);
38512 }
38513 }
38514
38515 post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
38516 }
38517 }
38518
38519 function escapeJsonPtr(str) {
38520 return str.replace(/~/g, '~0').replace(/\//g, '~1');
38521 }
38522
38523 /***/ }),
38524 /* 455 */
38525 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
38526
38527 "use strict";
38528
38529
38530 var resolve = __webpack_require__(448);
38531
38532 module.exports = {
38533 Validation: errorSubclass(ValidationError),
38534 MissingRef: errorSubclass(MissingRefError)
38535 };
38536
38537 function ValidationError(errors) {
38538 this.message = 'validation failed';
38539 this.errors = errors;
38540 this.ajv = this.validation = true;
38541 }
38542
38543 MissingRefError.message = function (baseId, ref) {
38544 return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
38545 };
38546
38547 function MissingRefError(baseId, ref, message) {
38548 this.message = message || MissingRefError.message(baseId, ref);
38549 this.missingRef = resolve.url(baseId, ref);
38550 this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
38551 }
38552
38553 function errorSubclass(Subclass) {
38554 Subclass.prototype = Object.create(Error.prototype);
38555 Subclass.prototype.constructor = Subclass;
38556 return Subclass;
38557 }
38558
38559 /***/ }),
38560 /* 456 */
38561 /***/ ((module) => {
38562
38563 "use strict";
38564
38565
38566 module.exports = function (data, opts) {
38567 if (!opts) opts = {};
38568 if (typeof opts === 'function') opts = {
38569 cmp: opts
38570 };
38571 var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false;
38572
38573 var cmp = opts.cmp && function (f) {
38574 return function (node) {
38575 return function (a, b) {
38576 var aobj = {
38577 key: a,
38578 value: node[a]
38579 };
38580 var bobj = {
38581 key: b,
38582 value: node[b]
38583 };
38584 return f(aobj, bobj);
38585 };
38586 };
38587 }(opts.cmp);
38588
38589 var seen = [];
38590 return function stringify(node) {
38591 if (node && node.toJSON && typeof node.toJSON === 'function') {
38592 node = node.toJSON();
38593 }
38594
38595 if (node === undefined) return;
38596 if (typeof node == 'number') return isFinite(node) ? '' + node : 'null';
38597 if (typeof node !== 'object') return JSON.stringify(node);
38598 var i, out;
38599
38600 if (Array.isArray(node)) {
38601 out = '[';
38602
38603 for (i = 0; i < node.length; i++) {
38604 if (i) out += ',';
38605 out += stringify(node[i]) || 'null';
38606 }
38607
38608 return out + ']';
38609 }
38610
38611 if (node === null) return 'null';
38612
38613 if (seen.indexOf(node) !== -1) {
38614 if (cycles) return JSON.stringify('__cycle__');
38615 throw new TypeError('Converting circular structure to JSON');
38616 }
38617
38618 var seenIndex = seen.push(node) - 1;
38619 var keys = Object.keys(node).sort(cmp && cmp(node));
38620 out = '';
38621
38622 for (i = 0; i < keys.length; i++) {
38623 var key = keys[i];
38624 var value = stringify(node[key]);
38625 if (!value) continue;
38626 if (out) out += ',';
38627 out += JSON.stringify(key) + ':' + value;
38628 }
38629
38630 seen.splice(seenIndex, 1);
38631 return '{' + out + '}';
38632 }(data);
38633 };
38634
38635 /***/ }),
38636 /* 457 */
38637 /***/ ((module) => {
38638
38639 "use strict";
38640
38641
38642 module.exports = function generate_validate(it, $keyword, $ruleType) {
38643 var out = '';
38644
38645 var $async = it.schema.$async === true,
38646 $refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref'),
38647 $id = it.self._getId(it.schema);
38648
38649 if (it.opts.strictKeywords) {
38650 var $unknownKwd = it.util.schemaUnknownRules(it.schema, it.RULES.keywords);
38651
38652 if ($unknownKwd) {
38653 var $keywordsMsg = 'unknown keyword: ' + $unknownKwd;
38654 if (it.opts.strictKeywords === 'log') it.logger.warn($keywordsMsg);else throw new Error($keywordsMsg);
38655 }
38656 }
38657
38658 if (it.isTop) {
38659 out += ' var validate = ';
38660
38661 if ($async) {
38662 it.async = true;
38663 out += 'async ';
38664 }
38665
38666 out += 'function(data, dataPath, parentData, parentDataProperty, rootData) { \'use strict\'; ';
38667
38668 if ($id && (it.opts.sourceCode || it.opts.processCode)) {
38669 out += ' ' + ('/\*# sourceURL=' + $id + ' */') + ' ';
38670 }
38671 }
38672
38673 if (typeof it.schema == 'boolean' || !($refKeywords || it.schema.$ref)) {
38674 var $keyword = 'false schema';
38675 var $lvl = it.level;
38676 var $dataLvl = it.dataLevel;
38677 var $schema = it.schema[$keyword];
38678 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
38679 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
38680 var $breakOnError = !it.opts.allErrors;
38681 var $errorKeyword;
38682 var $data = 'data' + ($dataLvl || '');
38683 var $valid = 'valid' + $lvl;
38684
38685 if (it.schema === false) {
38686 if (it.isTop) {
38687 $breakOnError = true;
38688 } else {
38689 out += ' var ' + $valid + ' = false; ';
38690 }
38691
38692 var $$outStack = $$outStack || [];
38693 $$outStack.push(out);
38694 out = '';
38695 /* istanbul ignore else */
38696
38697 if (it.createErrors !== false) {
38698 out += ' { keyword: \'' + ($errorKeyword || 'false schema') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
38699
38700 if (it.opts.messages !== false) {
38701 out += ' , message: \'boolean schema is false\' ';
38702 }
38703
38704 if (it.opts.verbose) {
38705 out += ' , schema: false , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
38706 }
38707
38708 out += ' } ';
38709 } else {
38710 out += ' {} ';
38711 }
38712
38713 var __err = out;
38714 out = $$outStack.pop();
38715
38716 if (!it.compositeRule && $breakOnError) {
38717 /* istanbul ignore if */
38718 if (it.async) {
38719 out += ' throw new ValidationError([' + __err + ']); ';
38720 } else {
38721 out += ' validate.errors = [' + __err + ']; return false; ';
38722 }
38723 } else {
38724 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
38725 }
38726 } else {
38727 if (it.isTop) {
38728 if ($async) {
38729 out += ' return data; ';
38730 } else {
38731 out += ' validate.errors = null; return true; ';
38732 }
38733 } else {
38734 out += ' var ' + $valid + ' = true; ';
38735 }
38736 }
38737
38738 if (it.isTop) {
38739 out += ' }; return validate; ';
38740 }
38741
38742 return out;
38743 }
38744
38745 if (it.isTop) {
38746 var $top = it.isTop,
38747 $lvl = it.level = 0,
38748 $dataLvl = it.dataLevel = 0,
38749 $data = 'data';
38750 it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema));
38751 it.baseId = it.baseId || it.rootId;
38752 delete it.isTop;
38753 it.dataPathArr = [""];
38754
38755 if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) {
38756 var $defaultMsg = 'default is ignored in the schema root';
38757 if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);else throw new Error($defaultMsg);
38758 }
38759
38760 out += ' var vErrors = null; ';
38761 out += ' var errors = 0; ';
38762 out += ' if (rootData === undefined) rootData = data; ';
38763 } else {
38764 var $lvl = it.level,
38765 $dataLvl = it.dataLevel,
38766 $data = 'data' + ($dataLvl || '');
38767 if ($id) it.baseId = it.resolve.url(it.baseId, $id);
38768 if ($async && !it.async) throw new Error('async schema in sync schema');
38769 out += ' var errs_' + $lvl + ' = errors;';
38770 }
38771
38772 var $valid = 'valid' + $lvl,
38773 $breakOnError = !it.opts.allErrors,
38774 $closingBraces1 = '',
38775 $closingBraces2 = '';
38776 var $errorKeyword;
38777 var $typeSchema = it.schema.type,
38778 $typeIsArray = Array.isArray($typeSchema);
38779
38780 if ($typeSchema && it.opts.nullable && it.schema.nullable === true) {
38781 if ($typeIsArray) {
38782 if ($typeSchema.indexOf('null') == -1) $typeSchema = $typeSchema.concat('null');
38783 } else if ($typeSchema != 'null') {
38784 $typeSchema = [$typeSchema, 'null'];
38785 $typeIsArray = true;
38786 }
38787 }
38788
38789 if ($typeIsArray && $typeSchema.length == 1) {
38790 $typeSchema = $typeSchema[0];
38791 $typeIsArray = false;
38792 }
38793
38794 if (it.schema.$ref && $refKeywords) {
38795 if (it.opts.extendRefs == 'fail') {
38796 throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)');
38797 } else if (it.opts.extendRefs !== true) {
38798 $refKeywords = false;
38799 it.logger.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
38800 }
38801 }
38802
38803 if (it.schema.$comment && it.opts.$comment) {
38804 out += ' ' + it.RULES.all.$comment.code(it, '$comment');
38805 }
38806
38807 if ($typeSchema) {
38808 if (it.opts.coerceTypes) {
38809 var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema);
38810 }
38811
38812 var $rulesGroup = it.RULES.types[$typeSchema];
38813
38814 if ($coerceToTypes || $typeIsArray || $rulesGroup === true || $rulesGroup && !$shouldUseGroup($rulesGroup)) {
38815 var $schemaPath = it.schemaPath + '.type',
38816 $errSchemaPath = it.errSchemaPath + '/type';
38817 var $schemaPath = it.schemaPath + '.type',
38818 $errSchemaPath = it.errSchemaPath + '/type',
38819 $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
38820 out += ' if (' + it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true) + ') { ';
38821
38822 if ($coerceToTypes) {
38823 var $dataType = 'dataType' + $lvl,
38824 $coerced = 'coerced' + $lvl;
38825 out += ' var ' + $dataType + ' = typeof ' + $data + '; var ' + $coerced + ' = undefined; ';
38826
38827 if (it.opts.coerceTypes == 'array') {
38828 out += ' if (' + $dataType + ' == \'object\' && Array.isArray(' + $data + ') && ' + $data + '.length == 1) { ' + $data + ' = ' + $data + '[0]; ' + $dataType + ' = typeof ' + $data + '; if (' + it.util.checkDataType(it.schema.type, $data, it.opts.strictNumbers) + ') ' + $coerced + ' = ' + $data + '; } ';
38829 }
38830
38831 out += ' if (' + $coerced + ' !== undefined) ; ';
38832 var arr1 = $coerceToTypes;
38833
38834 if (arr1) {
38835 var $type,
38836 $i = -1,
38837 l1 = arr1.length - 1;
38838
38839 while ($i < l1) {
38840 $type = arr1[$i += 1];
38841
38842 if ($type == 'string') {
38843 out += ' else if (' + $dataType + ' == \'number\' || ' + $dataType + ' == \'boolean\') ' + $coerced + ' = \'\' + ' + $data + '; else if (' + $data + ' === null) ' + $coerced + ' = \'\'; ';
38844 } else if ($type == 'number' || $type == 'integer') {
38845 out += ' else if (' + $dataType + ' == \'boolean\' || ' + $data + ' === null || (' + $dataType + ' == \'string\' && ' + $data + ' && ' + $data + ' == +' + $data + ' ';
38846
38847 if ($type == 'integer') {
38848 out += ' && !(' + $data + ' % 1)';
38849 }
38850
38851 out += ')) ' + $coerced + ' = +' + $data + '; ';
38852 } else if ($type == 'boolean') {
38853 out += ' else if (' + $data + ' === \'false\' || ' + $data + ' === 0 || ' + $data + ' === null) ' + $coerced + ' = false; else if (' + $data + ' === \'true\' || ' + $data + ' === 1) ' + $coerced + ' = true; ';
38854 } else if ($type == 'null') {
38855 out += ' else if (' + $data + ' === \'\' || ' + $data + ' === 0 || ' + $data + ' === false) ' + $coerced + ' = null; ';
38856 } else if (it.opts.coerceTypes == 'array' && $type == 'array') {
38857 out += ' else if (' + $dataType + ' == \'string\' || ' + $dataType + ' == \'number\' || ' + $dataType + ' == \'boolean\' || ' + $data + ' == null) ' + $coerced + ' = [' + $data + ']; ';
38858 }
38859 }
38860 }
38861
38862 out += ' else { ';
38863 var $$outStack = $$outStack || [];
38864 $$outStack.push(out);
38865 out = '';
38866 /* istanbul ignore else */
38867
38868 if (it.createErrors !== false) {
38869 out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { type: \'';
38870
38871 if ($typeIsArray) {
38872 out += '' + $typeSchema.join(",");
38873 } else {
38874 out += '' + $typeSchema;
38875 }
38876
38877 out += '\' } ';
38878
38879 if (it.opts.messages !== false) {
38880 out += ' , message: \'should be ';
38881
38882 if ($typeIsArray) {
38883 out += '' + $typeSchema.join(",");
38884 } else {
38885 out += '' + $typeSchema;
38886 }
38887
38888 out += '\' ';
38889 }
38890
38891 if (it.opts.verbose) {
38892 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
38893 }
38894
38895 out += ' } ';
38896 } else {
38897 out += ' {} ';
38898 }
38899
38900 var __err = out;
38901 out = $$outStack.pop();
38902
38903 if (!it.compositeRule && $breakOnError) {
38904 /* istanbul ignore if */
38905 if (it.async) {
38906 out += ' throw new ValidationError([' + __err + ']); ';
38907 } else {
38908 out += ' validate.errors = [' + __err + ']; return false; ';
38909 }
38910 } else {
38911 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
38912 }
38913
38914 out += ' } if (' + $coerced + ' !== undefined) { ';
38915 var $parentData = $dataLvl ? 'data' + ($dataLvl - 1 || '') : 'parentData',
38916 $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
38917 out += ' ' + $data + ' = ' + $coerced + '; ';
38918
38919 if (!$dataLvl) {
38920 out += 'if (' + $parentData + ' !== undefined)';
38921 }
38922
38923 out += ' ' + $parentData + '[' + $parentDataProperty + '] = ' + $coerced + '; } ';
38924 } else {
38925 var $$outStack = $$outStack || [];
38926 $$outStack.push(out);
38927 out = '';
38928 /* istanbul ignore else */
38929
38930 if (it.createErrors !== false) {
38931 out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { type: \'';
38932
38933 if ($typeIsArray) {
38934 out += '' + $typeSchema.join(",");
38935 } else {
38936 out += '' + $typeSchema;
38937 }
38938
38939 out += '\' } ';
38940
38941 if (it.opts.messages !== false) {
38942 out += ' , message: \'should be ';
38943
38944 if ($typeIsArray) {
38945 out += '' + $typeSchema.join(",");
38946 } else {
38947 out += '' + $typeSchema;
38948 }
38949
38950 out += '\' ';
38951 }
38952
38953 if (it.opts.verbose) {
38954 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
38955 }
38956
38957 out += ' } ';
38958 } else {
38959 out += ' {} ';
38960 }
38961
38962 var __err = out;
38963 out = $$outStack.pop();
38964
38965 if (!it.compositeRule && $breakOnError) {
38966 /* istanbul ignore if */
38967 if (it.async) {
38968 out += ' throw new ValidationError([' + __err + ']); ';
38969 } else {
38970 out += ' validate.errors = [' + __err + ']; return false; ';
38971 }
38972 } else {
38973 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
38974 }
38975 }
38976
38977 out += ' } ';
38978 }
38979 }
38980
38981 if (it.schema.$ref && !$refKeywords) {
38982 out += ' ' + it.RULES.all.$ref.code(it, '$ref') + ' ';
38983
38984 if ($breakOnError) {
38985 out += ' } if (errors === ';
38986
38987 if ($top) {
38988 out += '0';
38989 } else {
38990 out += 'errs_' + $lvl;
38991 }
38992
38993 out += ') { ';
38994 $closingBraces2 += '}';
38995 }
38996 } else {
38997 var arr2 = it.RULES;
38998
38999 if (arr2) {
39000 var $rulesGroup,
39001 i2 = -1,
39002 l2 = arr2.length - 1;
39003
39004 while (i2 < l2) {
39005 $rulesGroup = arr2[i2 += 1];
39006
39007 if ($shouldUseGroup($rulesGroup)) {
39008 if ($rulesGroup.type) {
39009 out += ' if (' + it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers) + ') { ';
39010 }
39011
39012 if (it.opts.useDefaults) {
39013 if ($rulesGroup.type == 'object' && it.schema.properties) {
39014 var $schema = it.schema.properties,
39015 $schemaKeys = Object.keys($schema);
39016 var arr3 = $schemaKeys;
39017
39018 if (arr3) {
39019 var $propertyKey,
39020 i3 = -1,
39021 l3 = arr3.length - 1;
39022
39023 while (i3 < l3) {
39024 $propertyKey = arr3[i3 += 1];
39025 var $sch = $schema[$propertyKey];
39026
39027 if ($sch.default !== undefined) {
39028 var $passData = $data + it.util.getProperty($propertyKey);
39029
39030 if (it.compositeRule) {
39031 if (it.opts.strictDefaults) {
39032 var $defaultMsg = 'default is ignored for: ' + $passData;
39033 if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);else throw new Error($defaultMsg);
39034 }
39035 } else {
39036 out += ' if (' + $passData + ' === undefined ';
39037
39038 if (it.opts.useDefaults == 'empty') {
39039 out += ' || ' + $passData + ' === null || ' + $passData + ' === \'\' ';
39040 }
39041
39042 out += ' ) ' + $passData + ' = ';
39043
39044 if (it.opts.useDefaults == 'shared') {
39045 out += ' ' + it.useDefault($sch.default) + ' ';
39046 } else {
39047 out += ' ' + JSON.stringify($sch.default) + ' ';
39048 }
39049
39050 out += '; ';
39051 }
39052 }
39053 }
39054 }
39055 } else if ($rulesGroup.type == 'array' && Array.isArray(it.schema.items)) {
39056 var arr4 = it.schema.items;
39057
39058 if (arr4) {
39059 var $sch,
39060 $i = -1,
39061 l4 = arr4.length - 1;
39062
39063 while ($i < l4) {
39064 $sch = arr4[$i += 1];
39065
39066 if ($sch.default !== undefined) {
39067 var $passData = $data + '[' + $i + ']';
39068
39069 if (it.compositeRule) {
39070 if (it.opts.strictDefaults) {
39071 var $defaultMsg = 'default is ignored for: ' + $passData;
39072 if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg);else throw new Error($defaultMsg);
39073 }
39074 } else {
39075 out += ' if (' + $passData + ' === undefined ';
39076
39077 if (it.opts.useDefaults == 'empty') {
39078 out += ' || ' + $passData + ' === null || ' + $passData + ' === \'\' ';
39079 }
39080
39081 out += ' ) ' + $passData + ' = ';
39082
39083 if (it.opts.useDefaults == 'shared') {
39084 out += ' ' + it.useDefault($sch.default) + ' ';
39085 } else {
39086 out += ' ' + JSON.stringify($sch.default) + ' ';
39087 }
39088
39089 out += '; ';
39090 }
39091 }
39092 }
39093 }
39094 }
39095 }
39096
39097 var arr5 = $rulesGroup.rules;
39098
39099 if (arr5) {
39100 var $rule,
39101 i5 = -1,
39102 l5 = arr5.length - 1;
39103
39104 while (i5 < l5) {
39105 $rule = arr5[i5 += 1];
39106
39107 if ($shouldUseRule($rule)) {
39108 var $code = $rule.code(it, $rule.keyword, $rulesGroup.type);
39109
39110 if ($code) {
39111 out += ' ' + $code + ' ';
39112
39113 if ($breakOnError) {
39114 $closingBraces1 += '}';
39115 }
39116 }
39117 }
39118 }
39119 }
39120
39121 if ($breakOnError) {
39122 out += ' ' + $closingBraces1 + ' ';
39123 $closingBraces1 = '';
39124 }
39125
39126 if ($rulesGroup.type) {
39127 out += ' } ';
39128
39129 if ($typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes) {
39130 out += ' else { ';
39131 var $schemaPath = it.schemaPath + '.type',
39132 $errSchemaPath = it.errSchemaPath + '/type';
39133 var $$outStack = $$outStack || [];
39134 $$outStack.push(out);
39135 out = '';
39136 /* istanbul ignore else */
39137
39138 if (it.createErrors !== false) {
39139 out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { type: \'';
39140
39141 if ($typeIsArray) {
39142 out += '' + $typeSchema.join(",");
39143 } else {
39144 out += '' + $typeSchema;
39145 }
39146
39147 out += '\' } ';
39148
39149 if (it.opts.messages !== false) {
39150 out += ' , message: \'should be ';
39151
39152 if ($typeIsArray) {
39153 out += '' + $typeSchema.join(",");
39154 } else {
39155 out += '' + $typeSchema;
39156 }
39157
39158 out += '\' ';
39159 }
39160
39161 if (it.opts.verbose) {
39162 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
39163 }
39164
39165 out += ' } ';
39166 } else {
39167 out += ' {} ';
39168 }
39169
39170 var __err = out;
39171 out = $$outStack.pop();
39172
39173 if (!it.compositeRule && $breakOnError) {
39174 /* istanbul ignore if */
39175 if (it.async) {
39176 out += ' throw new ValidationError([' + __err + ']); ';
39177 } else {
39178 out += ' validate.errors = [' + __err + ']; return false; ';
39179 }
39180 } else {
39181 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
39182 }
39183
39184 out += ' } ';
39185 }
39186 }
39187
39188 if ($breakOnError) {
39189 out += ' if (errors === ';
39190
39191 if ($top) {
39192 out += '0';
39193 } else {
39194 out += 'errs_' + $lvl;
39195 }
39196
39197 out += ') { ';
39198 $closingBraces2 += '}';
39199 }
39200 }
39201 }
39202 }
39203 }
39204
39205 if ($breakOnError) {
39206 out += ' ' + $closingBraces2 + ' ';
39207 }
39208
39209 if ($top) {
39210 if ($async) {
39211 out += ' if (errors === 0) return data; ';
39212 out += ' else throw new ValidationError(vErrors); ';
39213 } else {
39214 out += ' validate.errors = vErrors; ';
39215 out += ' return errors === 0; ';
39216 }
39217
39218 out += ' }; return validate;';
39219 } else {
39220 out += ' var ' + $valid + ' = errors === errs_' + $lvl + ';';
39221 }
39222
39223 function $shouldUseGroup($rulesGroup) {
39224 var rules = $rulesGroup.rules;
39225
39226 for (var i = 0; i < rules.length; i++) if ($shouldUseRule(rules[i])) return true;
39227 }
39228
39229 function $shouldUseRule($rule) {
39230 return it.schema[$rule.keyword] !== undefined || $rule.implements && $ruleImplementsSomeKeyword($rule);
39231 }
39232
39233 function $ruleImplementsSomeKeyword($rule) {
39234 var impl = $rule.implements;
39235
39236 for (var i = 0; i < impl.length; i++) if (it.schema[impl[i]] !== undefined) return true;
39237 }
39238
39239 return out;
39240 };
39241
39242 /***/ }),
39243 /* 458 */
39244 /***/ ((module) => {
39245
39246 "use strict";
39247
39248
39249 var Cache = module.exports = function Cache() {
39250 this._cache = {};
39251 };
39252
39253 Cache.prototype.put = function Cache_put(key, value) {
39254 this._cache[key] = value;
39255 };
39256
39257 Cache.prototype.get = function Cache_get(key) {
39258 return this._cache[key];
39259 };
39260
39261 Cache.prototype.del = function Cache_del(key) {
39262 delete this._cache[key];
39263 };
39264
39265 Cache.prototype.clear = function Cache_clear() {
39266 this._cache = {};
39267 };
39268
39269 /***/ }),
39270 /* 459 */
39271 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
39272
39273 "use strict";
39274
39275
39276 var util = __webpack_require__(451);
39277
39278 var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
39279 var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
39280 var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
39281 var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
39282 var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
39283 var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i; // uri-template: https://tools.ietf.org/html/rfc6570
39284
39285 var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i; // For the source: https://gist.github.com/dperini/729294
39286 // For test cases: https://mathiasbynens.be/demo/url-regex
39287 // @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983.
39288 // var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
39289
39290 var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
39291 var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
39292 var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
39293 var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
39294 var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
39295 module.exports = formats;
39296
39297 function formats(mode) {
39298 mode = mode == 'full' ? 'full' : 'fast';
39299 return util.copy(formats[mode]);
39300 }
39301
39302 formats.fast = {
39303 // date: http://tools.ietf.org/html/rfc3339#section-5.6
39304 date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
39305 // date-time: http://tools.ietf.org/html/rfc3339#section-5.6
39306 time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,
39307 'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,
39308 // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
39309 uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
39310 'uri-reference': /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
39311 'uri-template': URITEMPLATE,
39312 url: URL,
39313 // email (sources from jsen validator):
39314 // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
39315 // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
39316 email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
39317 hostname: HOSTNAME,
39318 // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
39319 ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
39320 // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
39321 ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
39322 regex: regex,
39323 // uuid: http://tools.ietf.org/html/rfc4122
39324 uuid: UUID,
39325 // JSON-pointer: https://tools.ietf.org/html/rfc6901
39326 // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
39327 'json-pointer': JSON_POINTER,
39328 'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
39329 // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
39330 'relative-json-pointer': RELATIVE_JSON_POINTER
39331 };
39332 formats.full = {
39333 date: date,
39334 time: time,
39335 'date-time': date_time,
39336 uri: uri,
39337 'uri-reference': URIREF,
39338 'uri-template': URITEMPLATE,
39339 url: URL,
39340 email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
39341 hostname: HOSTNAME,
39342 ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
39343 ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
39344 regex: regex,
39345 uuid: UUID,
39346 'json-pointer': JSON_POINTER,
39347 'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
39348 'relative-json-pointer': RELATIVE_JSON_POINTER
39349 };
39350
39351 function isLeapYear(year) {
39352 // https://tools.ietf.org/html/rfc3339#appendix-C
39353 return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
39354 }
39355
39356 function date(str) {
39357 // full-date from http://tools.ietf.org/html/rfc3339#section-5.6
39358 var matches = str.match(DATE);
39359 if (!matches) return false;
39360 var year = +matches[1];
39361 var month = +matches[2];
39362 var day = +matches[3];
39363 return month >= 1 && month <= 12 && day >= 1 && day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]);
39364 }
39365
39366 function time(str, full) {
39367 var matches = str.match(TIME);
39368 if (!matches) return false;
39369 var hour = matches[1];
39370 var minute = matches[2];
39371 var second = matches[3];
39372 var timeZone = matches[5];
39373 return (hour <= 23 && minute <= 59 && second <= 59 || hour == 23 && minute == 59 && second == 60) && (!full || timeZone);
39374 }
39375
39376 var DATE_TIME_SEPARATOR = /t|\s/i;
39377
39378 function date_time(str) {
39379 // http://tools.ietf.org/html/rfc3339#section-5.6
39380 var dateTime = str.split(DATE_TIME_SEPARATOR);
39381 return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true);
39382 }
39383
39384 var NOT_URI_FRAGMENT = /\/|:/;
39385
39386 function uri(str) {
39387 // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
39388 return NOT_URI_FRAGMENT.test(str) && URI.test(str);
39389 }
39390
39391 var Z_ANCHOR = /[^\\]\\Z/;
39392
39393 function regex(str) {
39394 if (Z_ANCHOR.test(str)) return false;
39395
39396 try {
39397 new RegExp(str);
39398 return true;
39399 } catch (e) {
39400 return false;
39401 }
39402 }
39403
39404 /***/ }),
39405 /* 460 */
39406 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
39407
39408 "use strict";
39409
39410
39411 var ruleModules = __webpack_require__(461),
39412 toHash = (__webpack_require__(451).toHash);
39413
39414 module.exports = function rules() {
39415 var RULES = [{
39416 type: 'number',
39417 rules: [{
39418 'maximum': ['exclusiveMaximum']
39419 }, {
39420 'minimum': ['exclusiveMinimum']
39421 }, 'multipleOf', 'format']
39422 }, {
39423 type: 'string',
39424 rules: ['maxLength', 'minLength', 'pattern', 'format']
39425 }, {
39426 type: 'array',
39427 rules: ['maxItems', 'minItems', 'items', 'contains', 'uniqueItems']
39428 }, {
39429 type: 'object',
39430 rules: ['maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames', {
39431 'properties': ['additionalProperties', 'patternProperties']
39432 }]
39433 }, {
39434 rules: ['$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if']
39435 }];
39436 var ALL = ['type', '$comment'];
39437 var KEYWORDS = ['$schema', '$id', 'id', '$data', '$async', 'title', 'description', 'default', 'definitions', 'examples', 'readOnly', 'writeOnly', 'contentMediaType', 'contentEncoding', 'additionalItems', 'then', 'else'];
39438 var TYPES = ['number', 'integer', 'string', 'array', 'object', 'boolean', 'null'];
39439 RULES.all = toHash(ALL);
39440 RULES.types = toHash(TYPES);
39441 RULES.forEach(function (group) {
39442 group.rules = group.rules.map(function (keyword) {
39443 var implKeywords;
39444
39445 if (typeof keyword == 'object') {
39446 var key = Object.keys(keyword)[0];
39447 implKeywords = keyword[key];
39448 keyword = key;
39449 implKeywords.forEach(function (k) {
39450 ALL.push(k);
39451 RULES.all[k] = true;
39452 });
39453 }
39454
39455 ALL.push(keyword);
39456 var rule = RULES.all[keyword] = {
39457 keyword: keyword,
39458 code: ruleModules[keyword],
39459 implements: implKeywords
39460 };
39461 return rule;
39462 });
39463 RULES.all.$comment = {
39464 keyword: '$comment',
39465 code: ruleModules.$comment
39466 };
39467 if (group.type) RULES.types[group.type] = group;
39468 });
39469 RULES.keywords = toHash(ALL.concat(KEYWORDS));
39470 RULES.custom = {};
39471 return RULES;
39472 };
39473
39474 /***/ }),
39475 /* 461 */
39476 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
39477
39478 "use strict";
39479 //all requires must be explicit because browserify won't work with dynamic requires
39480
39481 module.exports = {
39482 '$ref': __webpack_require__(462),
39483 allOf: __webpack_require__(463),
39484 anyOf: __webpack_require__(464),
39485 '$comment': __webpack_require__(465),
39486 const: __webpack_require__(466),
39487 contains: __webpack_require__(467),
39488 dependencies: __webpack_require__(468),
39489 'enum': __webpack_require__(469),
39490 format: __webpack_require__(470),
39491 'if': __webpack_require__(471),
39492 items: __webpack_require__(472),
39493 maximum: __webpack_require__(473),
39494 minimum: __webpack_require__(473),
39495 maxItems: __webpack_require__(474),
39496 minItems: __webpack_require__(474),
39497 maxLength: __webpack_require__(475),
39498 minLength: __webpack_require__(475),
39499 maxProperties: __webpack_require__(476),
39500 minProperties: __webpack_require__(476),
39501 multipleOf: __webpack_require__(477),
39502 not: __webpack_require__(478),
39503 oneOf: __webpack_require__(479),
39504 pattern: __webpack_require__(480),
39505 properties: __webpack_require__(481),
39506 propertyNames: __webpack_require__(482),
39507 required: __webpack_require__(483),
39508 uniqueItems: __webpack_require__(484),
39509 validate: __webpack_require__(457)
39510 };
39511
39512 /***/ }),
39513 /* 462 */
39514 /***/ ((module) => {
39515
39516 "use strict";
39517
39518
39519 module.exports = function generate_ref(it, $keyword, $ruleType) {
39520 var out = ' ';
39521 var $lvl = it.level;
39522 var $dataLvl = it.dataLevel;
39523 var $schema = it.schema[$keyword];
39524 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
39525 var $breakOnError = !it.opts.allErrors;
39526 var $data = 'data' + ($dataLvl || '');
39527 var $valid = 'valid' + $lvl;
39528 var $async, $refCode;
39529
39530 if ($schema == '#' || $schema == '#/') {
39531 if (it.isRoot) {
39532 $async = it.async;
39533 $refCode = 'validate';
39534 } else {
39535 $async = it.root.schema.$async === true;
39536 $refCode = 'root.refVal[0]';
39537 }
39538 } else {
39539 var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot);
39540
39541 if ($refVal === undefined) {
39542 var $message = it.MissingRefError.message(it.baseId, $schema);
39543
39544 if (it.opts.missingRefs == 'fail') {
39545 it.logger.error($message);
39546 var $$outStack = $$outStack || [];
39547 $$outStack.push(out);
39548 out = '';
39549 /* istanbul ignore else */
39550
39551 if (it.createErrors !== false) {
39552 out += ' { keyword: \'' + '$ref' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { ref: \'' + it.util.escapeQuotes($schema) + '\' } ';
39553
39554 if (it.opts.messages !== false) {
39555 out += ' , message: \'can\\\'t resolve reference ' + it.util.escapeQuotes($schema) + '\' ';
39556 }
39557
39558 if (it.opts.verbose) {
39559 out += ' , schema: ' + it.util.toQuotedString($schema) + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
39560 }
39561
39562 out += ' } ';
39563 } else {
39564 out += ' {} ';
39565 }
39566
39567 var __err = out;
39568 out = $$outStack.pop();
39569
39570 if (!it.compositeRule && $breakOnError) {
39571 /* istanbul ignore if */
39572 if (it.async) {
39573 out += ' throw new ValidationError([' + __err + ']); ';
39574 } else {
39575 out += ' validate.errors = [' + __err + ']; return false; ';
39576 }
39577 } else {
39578 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
39579 }
39580
39581 if ($breakOnError) {
39582 out += ' if (false) { ';
39583 }
39584 } else if (it.opts.missingRefs == 'ignore') {
39585 it.logger.warn($message);
39586
39587 if ($breakOnError) {
39588 out += ' if (true) { ';
39589 }
39590 } else {
39591 throw new it.MissingRefError(it.baseId, $schema, $message);
39592 }
39593 } else if ($refVal.inline) {
39594 var $it = it.util.copy(it);
39595 $it.level++;
39596 var $nextValid = 'valid' + $it.level;
39597 $it.schema = $refVal.schema;
39598 $it.schemaPath = '';
39599 $it.errSchemaPath = $schema;
39600 var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code);
39601 out += ' ' + $code + ' ';
39602
39603 if ($breakOnError) {
39604 out += ' if (' + $nextValid + ') { ';
39605 }
39606 } else {
39607 $async = $refVal.$async === true || it.async && $refVal.$async !== false;
39608 $refCode = $refVal.code;
39609 }
39610 }
39611
39612 if ($refCode) {
39613 var $$outStack = $$outStack || [];
39614 $$outStack.push(out);
39615 out = '';
39616
39617 if (it.opts.passContext) {
39618 out += ' ' + $refCode + '.call(this, ';
39619 } else {
39620 out += ' ' + $refCode + '( ';
39621 }
39622
39623 out += ' ' + $data + ', (dataPath || \'\')';
39624
39625 if (it.errorPath != '""') {
39626 out += ' + ' + it.errorPath;
39627 }
39628
39629 var $parentData = $dataLvl ? 'data' + ($dataLvl - 1 || '') : 'parentData',
39630 $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
39631 out += ' , ' + $parentData + ' , ' + $parentDataProperty + ', rootData) ';
39632 var __callValidate = out;
39633 out = $$outStack.pop();
39634
39635 if ($async) {
39636 if (!it.async) throw new Error('async schema referenced by sync schema');
39637
39638 if ($breakOnError) {
39639 out += ' var ' + $valid + '; ';
39640 }
39641
39642 out += ' try { await ' + __callValidate + '; ';
39643
39644 if ($breakOnError) {
39645 out += ' ' + $valid + ' = true; ';
39646 }
39647
39648 out += ' } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ';
39649
39650 if ($breakOnError) {
39651 out += ' ' + $valid + ' = false; ';
39652 }
39653
39654 out += ' } ';
39655
39656 if ($breakOnError) {
39657 out += ' if (' + $valid + ') { ';
39658 }
39659 } else {
39660 out += ' if (!' + __callValidate + ') { if (vErrors === null) vErrors = ' + $refCode + '.errors; else vErrors = vErrors.concat(' + $refCode + '.errors); errors = vErrors.length; } ';
39661
39662 if ($breakOnError) {
39663 out += ' else { ';
39664 }
39665 }
39666 }
39667
39668 return out;
39669 };
39670
39671 /***/ }),
39672 /* 463 */
39673 /***/ ((module) => {
39674
39675 "use strict";
39676
39677
39678 module.exports = function generate_allOf(it, $keyword, $ruleType) {
39679 var out = ' ';
39680 var $schema = it.schema[$keyword];
39681 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
39682 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
39683 var $breakOnError = !it.opts.allErrors;
39684 var $it = it.util.copy(it);
39685 var $closingBraces = '';
39686 $it.level++;
39687 var $nextValid = 'valid' + $it.level;
39688 var $currentBaseId = $it.baseId,
39689 $allSchemasEmpty = true;
39690 var arr1 = $schema;
39691
39692 if (arr1) {
39693 var $sch,
39694 $i = -1,
39695 l1 = arr1.length - 1;
39696
39697 while ($i < l1) {
39698 $sch = arr1[$i += 1];
39699
39700 if (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)) {
39701 $allSchemasEmpty = false;
39702 $it.schema = $sch;
39703 $it.schemaPath = $schemaPath + '[' + $i + ']';
39704 $it.errSchemaPath = $errSchemaPath + '/' + $i;
39705 out += ' ' + it.validate($it) + ' ';
39706 $it.baseId = $currentBaseId;
39707
39708 if ($breakOnError) {
39709 out += ' if (' + $nextValid + ') { ';
39710 $closingBraces += '}';
39711 }
39712 }
39713 }
39714 }
39715
39716 if ($breakOnError) {
39717 if ($allSchemasEmpty) {
39718 out += ' if (true) { ';
39719 } else {
39720 out += ' ' + $closingBraces.slice(0, -1) + ' ';
39721 }
39722 }
39723
39724 return out;
39725 };
39726
39727 /***/ }),
39728 /* 464 */
39729 /***/ ((module) => {
39730
39731 "use strict";
39732
39733
39734 module.exports = function generate_anyOf(it, $keyword, $ruleType) {
39735 var out = ' ';
39736 var $lvl = it.level;
39737 var $dataLvl = it.dataLevel;
39738 var $schema = it.schema[$keyword];
39739 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
39740 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
39741 var $breakOnError = !it.opts.allErrors;
39742 var $data = 'data' + ($dataLvl || '');
39743 var $valid = 'valid' + $lvl;
39744 var $errs = 'errs__' + $lvl;
39745 var $it = it.util.copy(it);
39746 var $closingBraces = '';
39747 $it.level++;
39748 var $nextValid = 'valid' + $it.level;
39749 var $noEmptySchema = $schema.every(function ($sch) {
39750 return it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all);
39751 });
39752
39753 if ($noEmptySchema) {
39754 var $currentBaseId = $it.baseId;
39755 out += ' var ' + $errs + ' = errors; var ' + $valid + ' = false; ';
39756 var $wasComposite = it.compositeRule;
39757 it.compositeRule = $it.compositeRule = true;
39758 var arr1 = $schema;
39759
39760 if (arr1) {
39761 var $sch,
39762 $i = -1,
39763 l1 = arr1.length - 1;
39764
39765 while ($i < l1) {
39766 $sch = arr1[$i += 1];
39767 $it.schema = $sch;
39768 $it.schemaPath = $schemaPath + '[' + $i + ']';
39769 $it.errSchemaPath = $errSchemaPath + '/' + $i;
39770 out += ' ' + it.validate($it) + ' ';
39771 $it.baseId = $currentBaseId;
39772 out += ' ' + $valid + ' = ' + $valid + ' || ' + $nextValid + '; if (!' + $valid + ') { ';
39773 $closingBraces += '}';
39774 }
39775 }
39776
39777 it.compositeRule = $it.compositeRule = $wasComposite;
39778 out += ' ' + $closingBraces + ' if (!' + $valid + ') { var err = ';
39779 /* istanbul ignore else */
39780
39781 if (it.createErrors !== false) {
39782 out += ' { keyword: \'' + 'anyOf' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
39783
39784 if (it.opts.messages !== false) {
39785 out += ' , message: \'should match some schema in anyOf\' ';
39786 }
39787
39788 if (it.opts.verbose) {
39789 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
39790 }
39791
39792 out += ' } ';
39793 } else {
39794 out += ' {} ';
39795 }
39796
39797 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
39798
39799 if (!it.compositeRule && $breakOnError) {
39800 /* istanbul ignore if */
39801 if (it.async) {
39802 out += ' throw new ValidationError(vErrors); ';
39803 } else {
39804 out += ' validate.errors = vErrors; return false; ';
39805 }
39806 }
39807
39808 out += ' } else { errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; } ';
39809
39810 if (it.opts.allErrors) {
39811 out += ' } ';
39812 }
39813 } else {
39814 if ($breakOnError) {
39815 out += ' if (true) { ';
39816 }
39817 }
39818
39819 return out;
39820 };
39821
39822 /***/ }),
39823 /* 465 */
39824 /***/ ((module) => {
39825
39826 "use strict";
39827
39828
39829 module.exports = function generate_comment(it, $keyword, $ruleType) {
39830 var out = ' ';
39831 var $schema = it.schema[$keyword];
39832 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
39833 var $breakOnError = !it.opts.allErrors;
39834 var $comment = it.util.toQuotedString($schema);
39835
39836 if (it.opts.$comment === true) {
39837 out += ' console.log(' + $comment + ');';
39838 } else if (typeof it.opts.$comment == 'function') {
39839 out += ' self._opts.$comment(' + $comment + ', ' + it.util.toQuotedString($errSchemaPath) + ', validate.root.schema);';
39840 }
39841
39842 return out;
39843 };
39844
39845 /***/ }),
39846 /* 466 */
39847 /***/ ((module) => {
39848
39849 "use strict";
39850
39851
39852 module.exports = function generate_const(it, $keyword, $ruleType) {
39853 var out = ' ';
39854 var $lvl = it.level;
39855 var $dataLvl = it.dataLevel;
39856 var $schema = it.schema[$keyword];
39857 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
39858 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
39859 var $breakOnError = !it.opts.allErrors;
39860 var $data = 'data' + ($dataLvl || '');
39861 var $valid = 'valid' + $lvl;
39862 var $isData = it.opts.$data && $schema && $schema.$data,
39863 $schemaValue;
39864
39865 if ($isData) {
39866 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
39867 $schemaValue = 'schema' + $lvl;
39868 } else {
39869 $schemaValue = $schema;
39870 }
39871
39872 if (!$isData) {
39873 out += ' var schema' + $lvl + ' = validate.schema' + $schemaPath + ';';
39874 }
39875
39876 out += 'var ' + $valid + ' = equal(' + $data + ', schema' + $lvl + '); if (!' + $valid + ') { ';
39877 var $$outStack = $$outStack || [];
39878 $$outStack.push(out);
39879 out = '';
39880 /* istanbul ignore else */
39881
39882 if (it.createErrors !== false) {
39883 out += ' { keyword: \'' + 'const' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { allowedValue: schema' + $lvl + ' } ';
39884
39885 if (it.opts.messages !== false) {
39886 out += ' , message: \'should be equal to constant\' ';
39887 }
39888
39889 if (it.opts.verbose) {
39890 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
39891 }
39892
39893 out += ' } ';
39894 } else {
39895 out += ' {} ';
39896 }
39897
39898 var __err = out;
39899 out = $$outStack.pop();
39900
39901 if (!it.compositeRule && $breakOnError) {
39902 /* istanbul ignore if */
39903 if (it.async) {
39904 out += ' throw new ValidationError([' + __err + ']); ';
39905 } else {
39906 out += ' validate.errors = [' + __err + ']; return false; ';
39907 }
39908 } else {
39909 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
39910 }
39911
39912 out += ' }';
39913
39914 if ($breakOnError) {
39915 out += ' else { ';
39916 }
39917
39918 return out;
39919 };
39920
39921 /***/ }),
39922 /* 467 */
39923 /***/ ((module) => {
39924
39925 "use strict";
39926
39927
39928 module.exports = function generate_contains(it, $keyword, $ruleType) {
39929 var out = ' ';
39930 var $lvl = it.level;
39931 var $dataLvl = it.dataLevel;
39932 var $schema = it.schema[$keyword];
39933 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
39934 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
39935 var $breakOnError = !it.opts.allErrors;
39936 var $data = 'data' + ($dataLvl || '');
39937 var $valid = 'valid' + $lvl;
39938 var $errs = 'errs__' + $lvl;
39939 var $it = it.util.copy(it);
39940 var $closingBraces = '';
39941 $it.level++;
39942 var $nextValid = 'valid' + $it.level;
39943 var $idx = 'i' + $lvl,
39944 $dataNxt = $it.dataLevel = it.dataLevel + 1,
39945 $nextData = 'data' + $dataNxt,
39946 $currentBaseId = it.baseId,
39947 $nonEmptySchema = it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 || $schema === false : it.util.schemaHasRules($schema, it.RULES.all);
39948 out += 'var ' + $errs + ' = errors;var ' + $valid + ';';
39949
39950 if ($nonEmptySchema) {
39951 var $wasComposite = it.compositeRule;
39952 it.compositeRule = $it.compositeRule = true;
39953 $it.schema = $schema;
39954 $it.schemaPath = $schemaPath;
39955 $it.errSchemaPath = $errSchemaPath;
39956 out += ' var ' + $nextValid + ' = false; for (var ' + $idx + ' = 0; ' + $idx + ' < ' + $data + '.length; ' + $idx + '++) { ';
39957 $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
39958 var $passData = $data + '[' + $idx + ']';
39959 $it.dataPathArr[$dataNxt] = $idx;
39960 var $code = it.validate($it);
39961 $it.baseId = $currentBaseId;
39962
39963 if (it.util.varOccurences($code, $nextData) < 2) {
39964 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
39965 } else {
39966 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
39967 }
39968
39969 out += ' if (' + $nextValid + ') break; } ';
39970 it.compositeRule = $it.compositeRule = $wasComposite;
39971 out += ' ' + $closingBraces + ' if (!' + $nextValid + ') {';
39972 } else {
39973 out += ' if (' + $data + '.length == 0) {';
39974 }
39975
39976 var $$outStack = $$outStack || [];
39977 $$outStack.push(out);
39978 out = '';
39979 /* istanbul ignore else */
39980
39981 if (it.createErrors !== false) {
39982 out += ' { keyword: \'' + 'contains' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
39983
39984 if (it.opts.messages !== false) {
39985 out += ' , message: \'should contain a valid item\' ';
39986 }
39987
39988 if (it.opts.verbose) {
39989 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
39990 }
39991
39992 out += ' } ';
39993 } else {
39994 out += ' {} ';
39995 }
39996
39997 var __err = out;
39998 out = $$outStack.pop();
39999
40000 if (!it.compositeRule && $breakOnError) {
40001 /* istanbul ignore if */
40002 if (it.async) {
40003 out += ' throw new ValidationError([' + __err + ']); ';
40004 } else {
40005 out += ' validate.errors = [' + __err + ']; return false; ';
40006 }
40007 } else {
40008 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
40009 }
40010
40011 out += ' } else { ';
40012
40013 if ($nonEmptySchema) {
40014 out += ' errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; } ';
40015 }
40016
40017 if (it.opts.allErrors) {
40018 out += ' } ';
40019 }
40020
40021 return out;
40022 };
40023
40024 /***/ }),
40025 /* 468 */
40026 /***/ ((module) => {
40027
40028 "use strict";
40029
40030
40031 module.exports = function generate_dependencies(it, $keyword, $ruleType) {
40032 var out = ' ';
40033 var $lvl = it.level;
40034 var $dataLvl = it.dataLevel;
40035 var $schema = it.schema[$keyword];
40036 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
40037 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
40038 var $breakOnError = !it.opts.allErrors;
40039 var $data = 'data' + ($dataLvl || '');
40040 var $errs = 'errs__' + $lvl;
40041 var $it = it.util.copy(it);
40042 var $closingBraces = '';
40043 $it.level++;
40044 var $nextValid = 'valid' + $it.level;
40045 var $schemaDeps = {},
40046 $propertyDeps = {},
40047 $ownProperties = it.opts.ownProperties;
40048
40049 for ($property in $schema) {
40050 if ($property == '__proto__') continue;
40051 var $sch = $schema[$property];
40052 var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
40053 $deps[$property] = $sch;
40054 }
40055
40056 out += 'var ' + $errs + ' = errors;';
40057 var $currentErrorPath = it.errorPath;
40058 out += 'var missing' + $lvl + ';';
40059
40060 for (var $property in $propertyDeps) {
40061 $deps = $propertyDeps[$property];
40062
40063 if ($deps.length) {
40064 out += ' if ( ' + $data + it.util.getProperty($property) + ' !== undefined ';
40065
40066 if ($ownProperties) {
40067 out += ' && Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($property) + '\') ';
40068 }
40069
40070 if ($breakOnError) {
40071 out += ' && ( ';
40072 var arr1 = $deps;
40073
40074 if (arr1) {
40075 var $propertyKey,
40076 $i = -1,
40077 l1 = arr1.length - 1;
40078
40079 while ($i < l1) {
40080 $propertyKey = arr1[$i += 1];
40081
40082 if ($i) {
40083 out += ' || ';
40084 }
40085
40086 var $prop = it.util.getProperty($propertyKey),
40087 $useData = $data + $prop;
40088 out += ' ( ( ' + $useData + ' === undefined ';
40089
40090 if ($ownProperties) {
40091 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
40092 }
40093
40094 out += ') && (missing' + $lvl + ' = ' + it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop) + ') ) ';
40095 }
40096 }
40097
40098 out += ')) { ';
40099 var $propertyPath = 'missing' + $lvl,
40100 $missingProperty = '\' + ' + $propertyPath + ' + \'';
40101
40102 if (it.opts._errorDataPathProperty) {
40103 it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
40104 }
40105
40106 var $$outStack = $$outStack || [];
40107 $$outStack.push(out);
40108 out = '';
40109 /* istanbul ignore else */
40110
40111 if (it.createErrors !== false) {
40112 out += ' { keyword: \'' + 'dependencies' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { property: \'' + it.util.escapeQuotes($property) + '\', missingProperty: \'' + $missingProperty + '\', depsCount: ' + $deps.length + ', deps: \'' + it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", ")) + '\' } ';
40113
40114 if (it.opts.messages !== false) {
40115 out += ' , message: \'should have ';
40116
40117 if ($deps.length == 1) {
40118 out += 'property ' + it.util.escapeQuotes($deps[0]);
40119 } else {
40120 out += 'properties ' + it.util.escapeQuotes($deps.join(", "));
40121 }
40122
40123 out += ' when property ' + it.util.escapeQuotes($property) + ' is present\' ';
40124 }
40125
40126 if (it.opts.verbose) {
40127 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
40128 }
40129
40130 out += ' } ';
40131 } else {
40132 out += ' {} ';
40133 }
40134
40135 var __err = out;
40136 out = $$outStack.pop();
40137
40138 if (!it.compositeRule && $breakOnError) {
40139 /* istanbul ignore if */
40140 if (it.async) {
40141 out += ' throw new ValidationError([' + __err + ']); ';
40142 } else {
40143 out += ' validate.errors = [' + __err + ']; return false; ';
40144 }
40145 } else {
40146 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
40147 }
40148 } else {
40149 out += ' ) { ';
40150 var arr2 = $deps;
40151
40152 if (arr2) {
40153 var $propertyKey,
40154 i2 = -1,
40155 l2 = arr2.length - 1;
40156
40157 while (i2 < l2) {
40158 $propertyKey = arr2[i2 += 1];
40159 var $prop = it.util.getProperty($propertyKey),
40160 $missingProperty = it.util.escapeQuotes($propertyKey),
40161 $useData = $data + $prop;
40162
40163 if (it.opts._errorDataPathProperty) {
40164 it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
40165 }
40166
40167 out += ' if ( ' + $useData + ' === undefined ';
40168
40169 if ($ownProperties) {
40170 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
40171 }
40172
40173 out += ') { var err = ';
40174 /* istanbul ignore else */
40175
40176 if (it.createErrors !== false) {
40177 out += ' { keyword: \'' + 'dependencies' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { property: \'' + it.util.escapeQuotes($property) + '\', missingProperty: \'' + $missingProperty + '\', depsCount: ' + $deps.length + ', deps: \'' + it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", ")) + '\' } ';
40178
40179 if (it.opts.messages !== false) {
40180 out += ' , message: \'should have ';
40181
40182 if ($deps.length == 1) {
40183 out += 'property ' + it.util.escapeQuotes($deps[0]);
40184 } else {
40185 out += 'properties ' + it.util.escapeQuotes($deps.join(", "));
40186 }
40187
40188 out += ' when property ' + it.util.escapeQuotes($property) + ' is present\' ';
40189 }
40190
40191 if (it.opts.verbose) {
40192 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
40193 }
40194
40195 out += ' } ';
40196 } else {
40197 out += ' {} ';
40198 }
40199
40200 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
40201 }
40202 }
40203 }
40204
40205 out += ' } ';
40206
40207 if ($breakOnError) {
40208 $closingBraces += '}';
40209 out += ' else { ';
40210 }
40211 }
40212 }
40213
40214 it.errorPath = $currentErrorPath;
40215 var $currentBaseId = $it.baseId;
40216
40217 for (var $property in $schemaDeps) {
40218 var $sch = $schemaDeps[$property];
40219
40220 if (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)) {
40221 out += ' ' + $nextValid + ' = true; if ( ' + $data + it.util.getProperty($property) + ' !== undefined ';
40222
40223 if ($ownProperties) {
40224 out += ' && Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($property) + '\') ';
40225 }
40226
40227 out += ') { ';
40228 $it.schema = $sch;
40229 $it.schemaPath = $schemaPath + it.util.getProperty($property);
40230 $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
40231 out += ' ' + it.validate($it) + ' ';
40232 $it.baseId = $currentBaseId;
40233 out += ' } ';
40234
40235 if ($breakOnError) {
40236 out += ' if (' + $nextValid + ') { ';
40237 $closingBraces += '}';
40238 }
40239 }
40240 }
40241
40242 if ($breakOnError) {
40243 out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {';
40244 }
40245
40246 return out;
40247 };
40248
40249 /***/ }),
40250 /* 469 */
40251 /***/ ((module) => {
40252
40253 "use strict";
40254
40255
40256 module.exports = function generate_enum(it, $keyword, $ruleType) {
40257 var out = ' ';
40258 var $lvl = it.level;
40259 var $dataLvl = it.dataLevel;
40260 var $schema = it.schema[$keyword];
40261 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
40262 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
40263 var $breakOnError = !it.opts.allErrors;
40264 var $data = 'data' + ($dataLvl || '');
40265 var $valid = 'valid' + $lvl;
40266 var $isData = it.opts.$data && $schema && $schema.$data,
40267 $schemaValue;
40268
40269 if ($isData) {
40270 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
40271 $schemaValue = 'schema' + $lvl;
40272 } else {
40273 $schemaValue = $schema;
40274 }
40275
40276 var $i = 'i' + $lvl,
40277 $vSchema = 'schema' + $lvl;
40278
40279 if (!$isData) {
40280 out += ' var ' + $vSchema + ' = validate.schema' + $schemaPath + ';';
40281 }
40282
40283 out += 'var ' + $valid + ';';
40284
40285 if ($isData) {
40286 out += ' if (schema' + $lvl + ' === undefined) ' + $valid + ' = true; else if (!Array.isArray(schema' + $lvl + ')) ' + $valid + ' = false; else {';
40287 }
40288
40289 out += '' + $valid + ' = false;for (var ' + $i + '=0; ' + $i + '<' + $vSchema + '.length; ' + $i + '++) if (equal(' + $data + ', ' + $vSchema + '[' + $i + '])) { ' + $valid + ' = true; break; }';
40290
40291 if ($isData) {
40292 out += ' } ';
40293 }
40294
40295 out += ' if (!' + $valid + ') { ';
40296 var $$outStack = $$outStack || [];
40297 $$outStack.push(out);
40298 out = '';
40299 /* istanbul ignore else */
40300
40301 if (it.createErrors !== false) {
40302 out += ' { keyword: \'' + 'enum' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { allowedValues: schema' + $lvl + ' } ';
40303
40304 if (it.opts.messages !== false) {
40305 out += ' , message: \'should be equal to one of the allowed values\' ';
40306 }
40307
40308 if (it.opts.verbose) {
40309 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
40310 }
40311
40312 out += ' } ';
40313 } else {
40314 out += ' {} ';
40315 }
40316
40317 var __err = out;
40318 out = $$outStack.pop();
40319
40320 if (!it.compositeRule && $breakOnError) {
40321 /* istanbul ignore if */
40322 if (it.async) {
40323 out += ' throw new ValidationError([' + __err + ']); ';
40324 } else {
40325 out += ' validate.errors = [' + __err + ']; return false; ';
40326 }
40327 } else {
40328 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
40329 }
40330
40331 out += ' }';
40332
40333 if ($breakOnError) {
40334 out += ' else { ';
40335 }
40336
40337 return out;
40338 };
40339
40340 /***/ }),
40341 /* 470 */
40342 /***/ ((module) => {
40343
40344 "use strict";
40345
40346
40347 module.exports = function generate_format(it, $keyword, $ruleType) {
40348 var out = ' ';
40349 var $lvl = it.level;
40350 var $dataLvl = it.dataLevel;
40351 var $schema = it.schema[$keyword];
40352 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
40353 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
40354 var $breakOnError = !it.opts.allErrors;
40355 var $data = 'data' + ($dataLvl || '');
40356
40357 if (it.opts.format === false) {
40358 if ($breakOnError) {
40359 out += ' if (true) { ';
40360 }
40361
40362 return out;
40363 }
40364
40365 var $isData = it.opts.$data && $schema && $schema.$data,
40366 $schemaValue;
40367
40368 if ($isData) {
40369 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
40370 $schemaValue = 'schema' + $lvl;
40371 } else {
40372 $schemaValue = $schema;
40373 }
40374
40375 var $unknownFormats = it.opts.unknownFormats,
40376 $allowUnknown = Array.isArray($unknownFormats);
40377
40378 if ($isData) {
40379 var $format = 'format' + $lvl,
40380 $isObject = 'isObject' + $lvl,
40381 $formatType = 'formatType' + $lvl;
40382 out += ' var ' + $format + ' = formats[' + $schemaValue + ']; var ' + $isObject + ' = typeof ' + $format + ' == \'object\' && !(' + $format + ' instanceof RegExp) && ' + $format + '.validate; var ' + $formatType + ' = ' + $isObject + ' && ' + $format + '.type || \'string\'; if (' + $isObject + ') { ';
40383
40384 if (it.async) {
40385 out += ' var async' + $lvl + ' = ' + $format + '.async; ';
40386 }
40387
40388 out += ' ' + $format + ' = ' + $format + '.validate; } if ( ';
40389
40390 if ($isData) {
40391 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'string\') || ';
40392 }
40393
40394 out += ' (';
40395
40396 if ($unknownFormats != 'ignore') {
40397 out += ' (' + $schemaValue + ' && !' + $format + ' ';
40398
40399 if ($allowUnknown) {
40400 out += ' && self._opts.unknownFormats.indexOf(' + $schemaValue + ') == -1 ';
40401 }
40402
40403 out += ') || ';
40404 }
40405
40406 out += ' (' + $format + ' && ' + $formatType + ' == \'' + $ruleType + '\' && !(typeof ' + $format + ' == \'function\' ? ';
40407
40408 if (it.async) {
40409 out += ' (async' + $lvl + ' ? await ' + $format + '(' + $data + ') : ' + $format + '(' + $data + ')) ';
40410 } else {
40411 out += ' ' + $format + '(' + $data + ') ';
40412 }
40413
40414 out += ' : ' + $format + '.test(' + $data + '))))) {';
40415 } else {
40416 var $format = it.formats[$schema];
40417
40418 if (!$format) {
40419 if ($unknownFormats == 'ignore') {
40420 it.logger.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"');
40421
40422 if ($breakOnError) {
40423 out += ' if (true) { ';
40424 }
40425
40426 return out;
40427 } else if ($allowUnknown && $unknownFormats.indexOf($schema) >= 0) {
40428 if ($breakOnError) {
40429 out += ' if (true) { ';
40430 }
40431
40432 return out;
40433 } else {
40434 throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"');
40435 }
40436 }
40437
40438 var $isObject = typeof $format == 'object' && !($format instanceof RegExp) && $format.validate;
40439 var $formatType = $isObject && $format.type || 'string';
40440
40441 if ($isObject) {
40442 var $async = $format.async === true;
40443 $format = $format.validate;
40444 }
40445
40446 if ($formatType != $ruleType) {
40447 if ($breakOnError) {
40448 out += ' if (true) { ';
40449 }
40450
40451 return out;
40452 }
40453
40454 if ($async) {
40455 if (!it.async) throw new Error('async format in sync schema');
40456 var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate';
40457 out += ' if (!(await ' + $formatRef + '(' + $data + '))) { ';
40458 } else {
40459 out += ' if (! ';
40460 var $formatRef = 'formats' + it.util.getProperty($schema);
40461 if ($isObject) $formatRef += '.validate';
40462
40463 if (typeof $format == 'function') {
40464 out += ' ' + $formatRef + '(' + $data + ') ';
40465 } else {
40466 out += ' ' + $formatRef + '.test(' + $data + ') ';
40467 }
40468
40469 out += ') { ';
40470 }
40471 }
40472
40473 var $$outStack = $$outStack || [];
40474 $$outStack.push(out);
40475 out = '';
40476 /* istanbul ignore else */
40477
40478 if (it.createErrors !== false) {
40479 out += ' { keyword: \'' + 'format' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { format: ';
40480
40481 if ($isData) {
40482 out += '' + $schemaValue;
40483 } else {
40484 out += '' + it.util.toQuotedString($schema);
40485 }
40486
40487 out += ' } ';
40488
40489 if (it.opts.messages !== false) {
40490 out += ' , message: \'should match format "';
40491
40492 if ($isData) {
40493 out += '\' + ' + $schemaValue + ' + \'';
40494 } else {
40495 out += '' + it.util.escapeQuotes($schema);
40496 }
40497
40498 out += '"\' ';
40499 }
40500
40501 if (it.opts.verbose) {
40502 out += ' , schema: ';
40503
40504 if ($isData) {
40505 out += 'validate.schema' + $schemaPath;
40506 } else {
40507 out += '' + it.util.toQuotedString($schema);
40508 }
40509
40510 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
40511 }
40512
40513 out += ' } ';
40514 } else {
40515 out += ' {} ';
40516 }
40517
40518 var __err = out;
40519 out = $$outStack.pop();
40520
40521 if (!it.compositeRule && $breakOnError) {
40522 /* istanbul ignore if */
40523 if (it.async) {
40524 out += ' throw new ValidationError([' + __err + ']); ';
40525 } else {
40526 out += ' validate.errors = [' + __err + ']; return false; ';
40527 }
40528 } else {
40529 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
40530 }
40531
40532 out += ' } ';
40533
40534 if ($breakOnError) {
40535 out += ' else { ';
40536 }
40537
40538 return out;
40539 };
40540
40541 /***/ }),
40542 /* 471 */
40543 /***/ ((module) => {
40544
40545 "use strict";
40546
40547
40548 module.exports = function generate_if(it, $keyword, $ruleType) {
40549 var out = ' ';
40550 var $lvl = it.level;
40551 var $dataLvl = it.dataLevel;
40552 var $schema = it.schema[$keyword];
40553 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
40554 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
40555 var $breakOnError = !it.opts.allErrors;
40556 var $data = 'data' + ($dataLvl || '');
40557 var $valid = 'valid' + $lvl;
40558 var $errs = 'errs__' + $lvl;
40559 var $it = it.util.copy(it);
40560 $it.level++;
40561 var $nextValid = 'valid' + $it.level;
40562 var $thenSch = it.schema['then'],
40563 $elseSch = it.schema['else'],
40564 $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? typeof $thenSch == 'object' && Object.keys($thenSch).length > 0 || $thenSch === false : it.util.schemaHasRules($thenSch, it.RULES.all)),
40565 $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? typeof $elseSch == 'object' && Object.keys($elseSch).length > 0 || $elseSch === false : it.util.schemaHasRules($elseSch, it.RULES.all)),
40566 $currentBaseId = $it.baseId;
40567
40568 if ($thenPresent || $elsePresent) {
40569 var $ifClause;
40570 $it.createErrors = false;
40571 $it.schema = $schema;
40572 $it.schemaPath = $schemaPath;
40573 $it.errSchemaPath = $errSchemaPath;
40574 out += ' var ' + $errs + ' = errors; var ' + $valid + ' = true; ';
40575 var $wasComposite = it.compositeRule;
40576 it.compositeRule = $it.compositeRule = true;
40577 out += ' ' + it.validate($it) + ' ';
40578 $it.baseId = $currentBaseId;
40579 $it.createErrors = true;
40580 out += ' errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; } ';
40581 it.compositeRule = $it.compositeRule = $wasComposite;
40582
40583 if ($thenPresent) {
40584 out += ' if (' + $nextValid + ') { ';
40585 $it.schema = it.schema['then'];
40586 $it.schemaPath = it.schemaPath + '.then';
40587 $it.errSchemaPath = it.errSchemaPath + '/then';
40588 out += ' ' + it.validate($it) + ' ';
40589 $it.baseId = $currentBaseId;
40590 out += ' ' + $valid + ' = ' + $nextValid + '; ';
40591
40592 if ($thenPresent && $elsePresent) {
40593 $ifClause = 'ifClause' + $lvl;
40594 out += ' var ' + $ifClause + ' = \'then\'; ';
40595 } else {
40596 $ifClause = '\'then\'';
40597 }
40598
40599 out += ' } ';
40600
40601 if ($elsePresent) {
40602 out += ' else { ';
40603 }
40604 } else {
40605 out += ' if (!' + $nextValid + ') { ';
40606 }
40607
40608 if ($elsePresent) {
40609 $it.schema = it.schema['else'];
40610 $it.schemaPath = it.schemaPath + '.else';
40611 $it.errSchemaPath = it.errSchemaPath + '/else';
40612 out += ' ' + it.validate($it) + ' ';
40613 $it.baseId = $currentBaseId;
40614 out += ' ' + $valid + ' = ' + $nextValid + '; ';
40615
40616 if ($thenPresent && $elsePresent) {
40617 $ifClause = 'ifClause' + $lvl;
40618 out += ' var ' + $ifClause + ' = \'else\'; ';
40619 } else {
40620 $ifClause = '\'else\'';
40621 }
40622
40623 out += ' } ';
40624 }
40625
40626 out += ' if (!' + $valid + ') { var err = ';
40627 /* istanbul ignore else */
40628
40629 if (it.createErrors !== false) {
40630 out += ' { keyword: \'' + 'if' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { failingKeyword: ' + $ifClause + ' } ';
40631
40632 if (it.opts.messages !== false) {
40633 out += ' , message: \'should match "\' + ' + $ifClause + ' + \'" schema\' ';
40634 }
40635
40636 if (it.opts.verbose) {
40637 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
40638 }
40639
40640 out += ' } ';
40641 } else {
40642 out += ' {} ';
40643 }
40644
40645 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
40646
40647 if (!it.compositeRule && $breakOnError) {
40648 /* istanbul ignore if */
40649 if (it.async) {
40650 out += ' throw new ValidationError(vErrors); ';
40651 } else {
40652 out += ' validate.errors = vErrors; return false; ';
40653 }
40654 }
40655
40656 out += ' } ';
40657
40658 if ($breakOnError) {
40659 out += ' else { ';
40660 }
40661 } else {
40662 if ($breakOnError) {
40663 out += ' if (true) { ';
40664 }
40665 }
40666
40667 return out;
40668 };
40669
40670 /***/ }),
40671 /* 472 */
40672 /***/ ((module) => {
40673
40674 "use strict";
40675
40676
40677 module.exports = function generate_items(it, $keyword, $ruleType) {
40678 var out = ' ';
40679 var $lvl = it.level;
40680 var $dataLvl = it.dataLevel;
40681 var $schema = it.schema[$keyword];
40682 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
40683 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
40684 var $breakOnError = !it.opts.allErrors;
40685 var $data = 'data' + ($dataLvl || '');
40686 var $valid = 'valid' + $lvl;
40687 var $errs = 'errs__' + $lvl;
40688 var $it = it.util.copy(it);
40689 var $closingBraces = '';
40690 $it.level++;
40691 var $nextValid = 'valid' + $it.level;
40692 var $idx = 'i' + $lvl,
40693 $dataNxt = $it.dataLevel = it.dataLevel + 1,
40694 $nextData = 'data' + $dataNxt,
40695 $currentBaseId = it.baseId;
40696 out += 'var ' + $errs + ' = errors;var ' + $valid + ';';
40697
40698 if (Array.isArray($schema)) {
40699 var $additionalItems = it.schema.additionalItems;
40700
40701 if ($additionalItems === false) {
40702 out += ' ' + $valid + ' = ' + $data + '.length <= ' + $schema.length + '; ';
40703 var $currErrSchemaPath = $errSchemaPath;
40704 $errSchemaPath = it.errSchemaPath + '/additionalItems';
40705 out += ' if (!' + $valid + ') { ';
40706 var $$outStack = $$outStack || [];
40707 $$outStack.push(out);
40708 out = '';
40709 /* istanbul ignore else */
40710
40711 if (it.createErrors !== false) {
40712 out += ' { keyword: \'' + 'additionalItems' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { limit: ' + $schema.length + ' } ';
40713
40714 if (it.opts.messages !== false) {
40715 out += ' , message: \'should NOT have more than ' + $schema.length + ' items\' ';
40716 }
40717
40718 if (it.opts.verbose) {
40719 out += ' , schema: false , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
40720 }
40721
40722 out += ' } ';
40723 } else {
40724 out += ' {} ';
40725 }
40726
40727 var __err = out;
40728 out = $$outStack.pop();
40729
40730 if (!it.compositeRule && $breakOnError) {
40731 /* istanbul ignore if */
40732 if (it.async) {
40733 out += ' throw new ValidationError([' + __err + ']); ';
40734 } else {
40735 out += ' validate.errors = [' + __err + ']; return false; ';
40736 }
40737 } else {
40738 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
40739 }
40740
40741 out += ' } ';
40742 $errSchemaPath = $currErrSchemaPath;
40743
40744 if ($breakOnError) {
40745 $closingBraces += '}';
40746 out += ' else { ';
40747 }
40748 }
40749
40750 var arr1 = $schema;
40751
40752 if (arr1) {
40753 var $sch,
40754 $i = -1,
40755 l1 = arr1.length - 1;
40756
40757 while ($i < l1) {
40758 $sch = arr1[$i += 1];
40759
40760 if (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)) {
40761 out += ' ' + $nextValid + ' = true; if (' + $data + '.length > ' + $i + ') { ';
40762 var $passData = $data + '[' + $i + ']';
40763 $it.schema = $sch;
40764 $it.schemaPath = $schemaPath + '[' + $i + ']';
40765 $it.errSchemaPath = $errSchemaPath + '/' + $i;
40766 $it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true);
40767 $it.dataPathArr[$dataNxt] = $i;
40768 var $code = it.validate($it);
40769 $it.baseId = $currentBaseId;
40770
40771 if (it.util.varOccurences($code, $nextData) < 2) {
40772 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
40773 } else {
40774 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
40775 }
40776
40777 out += ' } ';
40778
40779 if ($breakOnError) {
40780 out += ' if (' + $nextValid + ') { ';
40781 $closingBraces += '}';
40782 }
40783 }
40784 }
40785 }
40786
40787 if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0 || $additionalItems === false : it.util.schemaHasRules($additionalItems, it.RULES.all))) {
40788 $it.schema = $additionalItems;
40789 $it.schemaPath = it.schemaPath + '.additionalItems';
40790 $it.errSchemaPath = it.errSchemaPath + '/additionalItems';
40791 out += ' ' + $nextValid + ' = true; if (' + $data + '.length > ' + $schema.length + ') { for (var ' + $idx + ' = ' + $schema.length + '; ' + $idx + ' < ' + $data + '.length; ' + $idx + '++) { ';
40792 $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
40793 var $passData = $data + '[' + $idx + ']';
40794 $it.dataPathArr[$dataNxt] = $idx;
40795 var $code = it.validate($it);
40796 $it.baseId = $currentBaseId;
40797
40798 if (it.util.varOccurences($code, $nextData) < 2) {
40799 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
40800 } else {
40801 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
40802 }
40803
40804 if ($breakOnError) {
40805 out += ' if (!' + $nextValid + ') break; ';
40806 }
40807
40808 out += ' } } ';
40809
40810 if ($breakOnError) {
40811 out += ' if (' + $nextValid + ') { ';
40812 $closingBraces += '}';
40813 }
40814 }
40815 } else if (it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 || $schema === false : it.util.schemaHasRules($schema, it.RULES.all)) {
40816 $it.schema = $schema;
40817 $it.schemaPath = $schemaPath;
40818 $it.errSchemaPath = $errSchemaPath;
40819 out += ' for (var ' + $idx + ' = ' + 0 + '; ' + $idx + ' < ' + $data + '.length; ' + $idx + '++) { ';
40820 $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
40821 var $passData = $data + '[' + $idx + ']';
40822 $it.dataPathArr[$dataNxt] = $idx;
40823 var $code = it.validate($it);
40824 $it.baseId = $currentBaseId;
40825
40826 if (it.util.varOccurences($code, $nextData) < 2) {
40827 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
40828 } else {
40829 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
40830 }
40831
40832 if ($breakOnError) {
40833 out += ' if (!' + $nextValid + ') break; ';
40834 }
40835
40836 out += ' }';
40837 }
40838
40839 if ($breakOnError) {
40840 out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {';
40841 }
40842
40843 return out;
40844 };
40845
40846 /***/ }),
40847 /* 473 */
40848 /***/ ((module) => {
40849
40850 "use strict";
40851
40852
40853 module.exports = function generate__limit(it, $keyword, $ruleType) {
40854 var out = ' ';
40855 var $lvl = it.level;
40856 var $dataLvl = it.dataLevel;
40857 var $schema = it.schema[$keyword];
40858 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
40859 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
40860 var $breakOnError = !it.opts.allErrors;
40861 var $errorKeyword;
40862 var $data = 'data' + ($dataLvl || '');
40863 var $isData = it.opts.$data && $schema && $schema.$data,
40864 $schemaValue;
40865
40866 if ($isData) {
40867 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
40868 $schemaValue = 'schema' + $lvl;
40869 } else {
40870 $schemaValue = $schema;
40871 }
40872
40873 var $isMax = $keyword == 'maximum',
40874 $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum',
40875 $schemaExcl = it.schema[$exclusiveKeyword],
40876 $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data,
40877 $op = $isMax ? '<' : '>',
40878 $notOp = $isMax ? '>' : '<',
40879 $errorKeyword = undefined;
40880
40881 if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
40882 throw new Error($keyword + ' must be number');
40883 }
40884
40885 if (!($isDataExcl || $schemaExcl === undefined || typeof $schemaExcl == 'number' || typeof $schemaExcl == 'boolean')) {
40886 throw new Error($exclusiveKeyword + ' must be number or boolean');
40887 }
40888
40889 if ($isDataExcl) {
40890 var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
40891 $exclusive = 'exclusive' + $lvl,
40892 $exclType = 'exclType' + $lvl,
40893 $exclIsNumber = 'exclIsNumber' + $lvl,
40894 $opExpr = 'op' + $lvl,
40895 $opStr = '\' + ' + $opExpr + ' + \'';
40896 out += ' var schemaExcl' + $lvl + ' = ' + $schemaValueExcl + '; ';
40897 $schemaValueExcl = 'schemaExcl' + $lvl;
40898 out += ' var ' + $exclusive + '; var ' + $exclType + ' = typeof ' + $schemaValueExcl + '; if (' + $exclType + ' != \'boolean\' && ' + $exclType + ' != \'undefined\' && ' + $exclType + ' != \'number\') { ';
40899 var $errorKeyword = $exclusiveKeyword;
40900 var $$outStack = $$outStack || [];
40901 $$outStack.push(out);
40902 out = '';
40903 /* istanbul ignore else */
40904
40905 if (it.createErrors !== false) {
40906 out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
40907
40908 if (it.opts.messages !== false) {
40909 out += ' , message: \'' + $exclusiveKeyword + ' should be boolean\' ';
40910 }
40911
40912 if (it.opts.verbose) {
40913 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
40914 }
40915
40916 out += ' } ';
40917 } else {
40918 out += ' {} ';
40919 }
40920
40921 var __err = out;
40922 out = $$outStack.pop();
40923
40924 if (!it.compositeRule && $breakOnError) {
40925 /* istanbul ignore if */
40926 if (it.async) {
40927 out += ' throw new ValidationError([' + __err + ']); ';
40928 } else {
40929 out += ' validate.errors = [' + __err + ']; return false; ';
40930 }
40931 } else {
40932 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
40933 }
40934
40935 out += ' } else if ( ';
40936
40937 if ($isData) {
40938 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
40939 }
40940
40941 out += ' ' + $exclType + ' == \'number\' ? ( (' + $exclusive + ' = ' + $schemaValue + ' === undefined || ' + $schemaValueExcl + ' ' + $op + '= ' + $schemaValue + ') ? ' + $data + ' ' + $notOp + '= ' + $schemaValueExcl + ' : ' + $data + ' ' + $notOp + ' ' + $schemaValue + ' ) : ( (' + $exclusive + ' = ' + $schemaValueExcl + ' === true) ? ' + $data + ' ' + $notOp + '= ' + $schemaValue + ' : ' + $data + ' ' + $notOp + ' ' + $schemaValue + ' ) || ' + $data + ' !== ' + $data + ') { var op' + $lvl + ' = ' + $exclusive + ' ? \'' + $op + '\' : \'' + $op + '=\'; ';
40942
40943 if ($schema === undefined) {
40944 $errorKeyword = $exclusiveKeyword;
40945 $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
40946 $schemaValue = $schemaValueExcl;
40947 $isData = $isDataExcl;
40948 }
40949 } else {
40950 var $exclIsNumber = typeof $schemaExcl == 'number',
40951 $opStr = $op;
40952
40953 if ($exclIsNumber && $isData) {
40954 var $opExpr = '\'' + $opStr + '\'';
40955 out += ' if ( ';
40956
40957 if ($isData) {
40958 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
40959 }
40960
40961 out += ' ( ' + $schemaValue + ' === undefined || ' + $schemaExcl + ' ' + $op + '= ' + $schemaValue + ' ? ' + $data + ' ' + $notOp + '= ' + $schemaExcl + ' : ' + $data + ' ' + $notOp + ' ' + $schemaValue + ' ) || ' + $data + ' !== ' + $data + ') { ';
40962 } else {
40963 if ($exclIsNumber && $schema === undefined) {
40964 $exclusive = true;
40965 $errorKeyword = $exclusiveKeyword;
40966 $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
40967 $schemaValue = $schemaExcl;
40968 $notOp += '=';
40969 } else {
40970 if ($exclIsNumber) $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
40971
40972 if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
40973 $exclusive = true;
40974 $errorKeyword = $exclusiveKeyword;
40975 $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
40976 $notOp += '=';
40977 } else {
40978 $exclusive = false;
40979 $opStr += '=';
40980 }
40981 }
40982
40983 var $opExpr = '\'' + $opStr + '\'';
40984 out += ' if ( ';
40985
40986 if ($isData) {
40987 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
40988 }
40989
40990 out += ' ' + $data + ' ' + $notOp + ' ' + $schemaValue + ' || ' + $data + ' !== ' + $data + ') { ';
40991 }
40992 }
40993
40994 $errorKeyword = $errorKeyword || $keyword;
40995 var $$outStack = $$outStack || [];
40996 $$outStack.push(out);
40997 out = '';
40998 /* istanbul ignore else */
40999
41000 if (it.createErrors !== false) {
41001 out += ' { keyword: \'' + ($errorKeyword || '_limit') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { comparison: ' + $opExpr + ', limit: ' + $schemaValue + ', exclusive: ' + $exclusive + ' } ';
41002
41003 if (it.opts.messages !== false) {
41004 out += ' , message: \'should be ' + $opStr + ' ';
41005
41006 if ($isData) {
41007 out += '\' + ' + $schemaValue;
41008 } else {
41009 out += '' + $schemaValue + '\'';
41010 }
41011 }
41012
41013 if (it.opts.verbose) {
41014 out += ' , schema: ';
41015
41016 if ($isData) {
41017 out += 'validate.schema' + $schemaPath;
41018 } else {
41019 out += '' + $schema;
41020 }
41021
41022 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
41023 }
41024
41025 out += ' } ';
41026 } else {
41027 out += ' {} ';
41028 }
41029
41030 var __err = out;
41031 out = $$outStack.pop();
41032
41033 if (!it.compositeRule && $breakOnError) {
41034 /* istanbul ignore if */
41035 if (it.async) {
41036 out += ' throw new ValidationError([' + __err + ']); ';
41037 } else {
41038 out += ' validate.errors = [' + __err + ']; return false; ';
41039 }
41040 } else {
41041 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
41042 }
41043
41044 out += ' } ';
41045
41046 if ($breakOnError) {
41047 out += ' else { ';
41048 }
41049
41050 return out;
41051 };
41052
41053 /***/ }),
41054 /* 474 */
41055 /***/ ((module) => {
41056
41057 "use strict";
41058
41059
41060 module.exports = function generate__limitItems(it, $keyword, $ruleType) {
41061 var out = ' ';
41062 var $lvl = it.level;
41063 var $dataLvl = it.dataLevel;
41064 var $schema = it.schema[$keyword];
41065 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
41066 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
41067 var $breakOnError = !it.opts.allErrors;
41068 var $errorKeyword;
41069 var $data = 'data' + ($dataLvl || '');
41070 var $isData = it.opts.$data && $schema && $schema.$data,
41071 $schemaValue;
41072
41073 if ($isData) {
41074 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
41075 $schemaValue = 'schema' + $lvl;
41076 } else {
41077 $schemaValue = $schema;
41078 }
41079
41080 if (!($isData || typeof $schema == 'number')) {
41081 throw new Error($keyword + ' must be number');
41082 }
41083
41084 var $op = $keyword == 'maxItems' ? '>' : '<';
41085 out += 'if ( ';
41086
41087 if ($isData) {
41088 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
41089 }
41090
41091 out += ' ' + $data + '.length ' + $op + ' ' + $schemaValue + ') { ';
41092 var $errorKeyword = $keyword;
41093 var $$outStack = $$outStack || [];
41094 $$outStack.push(out);
41095 out = '';
41096 /* istanbul ignore else */
41097
41098 if (it.createErrors !== false) {
41099 out += ' { keyword: \'' + ($errorKeyword || '_limitItems') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { limit: ' + $schemaValue + ' } ';
41100
41101 if (it.opts.messages !== false) {
41102 out += ' , message: \'should NOT have ';
41103
41104 if ($keyword == 'maxItems') {
41105 out += 'more';
41106 } else {
41107 out += 'fewer';
41108 }
41109
41110 out += ' than ';
41111
41112 if ($isData) {
41113 out += '\' + ' + $schemaValue + ' + \'';
41114 } else {
41115 out += '' + $schema;
41116 }
41117
41118 out += ' items\' ';
41119 }
41120
41121 if (it.opts.verbose) {
41122 out += ' , schema: ';
41123
41124 if ($isData) {
41125 out += 'validate.schema' + $schemaPath;
41126 } else {
41127 out += '' + $schema;
41128 }
41129
41130 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
41131 }
41132
41133 out += ' } ';
41134 } else {
41135 out += ' {} ';
41136 }
41137
41138 var __err = out;
41139 out = $$outStack.pop();
41140
41141 if (!it.compositeRule && $breakOnError) {
41142 /* istanbul ignore if */
41143 if (it.async) {
41144 out += ' throw new ValidationError([' + __err + ']); ';
41145 } else {
41146 out += ' validate.errors = [' + __err + ']; return false; ';
41147 }
41148 } else {
41149 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
41150 }
41151
41152 out += '} ';
41153
41154 if ($breakOnError) {
41155 out += ' else { ';
41156 }
41157
41158 return out;
41159 };
41160
41161 /***/ }),
41162 /* 475 */
41163 /***/ ((module) => {
41164
41165 "use strict";
41166
41167
41168 module.exports = function generate__limitLength(it, $keyword, $ruleType) {
41169 var out = ' ';
41170 var $lvl = it.level;
41171 var $dataLvl = it.dataLevel;
41172 var $schema = it.schema[$keyword];
41173 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
41174 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
41175 var $breakOnError = !it.opts.allErrors;
41176 var $errorKeyword;
41177 var $data = 'data' + ($dataLvl || '');
41178 var $isData = it.opts.$data && $schema && $schema.$data,
41179 $schemaValue;
41180
41181 if ($isData) {
41182 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
41183 $schemaValue = 'schema' + $lvl;
41184 } else {
41185 $schemaValue = $schema;
41186 }
41187
41188 if (!($isData || typeof $schema == 'number')) {
41189 throw new Error($keyword + ' must be number');
41190 }
41191
41192 var $op = $keyword == 'maxLength' ? '>' : '<';
41193 out += 'if ( ';
41194
41195 if ($isData) {
41196 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
41197 }
41198
41199 if (it.opts.unicode === false) {
41200 out += ' ' + $data + '.length ';
41201 } else {
41202 out += ' ucs2length(' + $data + ') ';
41203 }
41204
41205 out += ' ' + $op + ' ' + $schemaValue + ') { ';
41206 var $errorKeyword = $keyword;
41207 var $$outStack = $$outStack || [];
41208 $$outStack.push(out);
41209 out = '';
41210 /* istanbul ignore else */
41211
41212 if (it.createErrors !== false) {
41213 out += ' { keyword: \'' + ($errorKeyword || '_limitLength') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { limit: ' + $schemaValue + ' } ';
41214
41215 if (it.opts.messages !== false) {
41216 out += ' , message: \'should NOT be ';
41217
41218 if ($keyword == 'maxLength') {
41219 out += 'longer';
41220 } else {
41221 out += 'shorter';
41222 }
41223
41224 out += ' than ';
41225
41226 if ($isData) {
41227 out += '\' + ' + $schemaValue + ' + \'';
41228 } else {
41229 out += '' + $schema;
41230 }
41231
41232 out += ' characters\' ';
41233 }
41234
41235 if (it.opts.verbose) {
41236 out += ' , schema: ';
41237
41238 if ($isData) {
41239 out += 'validate.schema' + $schemaPath;
41240 } else {
41241 out += '' + $schema;
41242 }
41243
41244 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
41245 }
41246
41247 out += ' } ';
41248 } else {
41249 out += ' {} ';
41250 }
41251
41252 var __err = out;
41253 out = $$outStack.pop();
41254
41255 if (!it.compositeRule && $breakOnError) {
41256 /* istanbul ignore if */
41257 if (it.async) {
41258 out += ' throw new ValidationError([' + __err + ']); ';
41259 } else {
41260 out += ' validate.errors = [' + __err + ']; return false; ';
41261 }
41262 } else {
41263 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
41264 }
41265
41266 out += '} ';
41267
41268 if ($breakOnError) {
41269 out += ' else { ';
41270 }
41271
41272 return out;
41273 };
41274
41275 /***/ }),
41276 /* 476 */
41277 /***/ ((module) => {
41278
41279 "use strict";
41280
41281
41282 module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
41283 var out = ' ';
41284 var $lvl = it.level;
41285 var $dataLvl = it.dataLevel;
41286 var $schema = it.schema[$keyword];
41287 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
41288 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
41289 var $breakOnError = !it.opts.allErrors;
41290 var $errorKeyword;
41291 var $data = 'data' + ($dataLvl || '');
41292 var $isData = it.opts.$data && $schema && $schema.$data,
41293 $schemaValue;
41294
41295 if ($isData) {
41296 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
41297 $schemaValue = 'schema' + $lvl;
41298 } else {
41299 $schemaValue = $schema;
41300 }
41301
41302 if (!($isData || typeof $schema == 'number')) {
41303 throw new Error($keyword + ' must be number');
41304 }
41305
41306 var $op = $keyword == 'maxProperties' ? '>' : '<';
41307 out += 'if ( ';
41308
41309 if ($isData) {
41310 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'number\') || ';
41311 }
41312
41313 out += ' Object.keys(' + $data + ').length ' + $op + ' ' + $schemaValue + ') { ';
41314 var $errorKeyword = $keyword;
41315 var $$outStack = $$outStack || [];
41316 $$outStack.push(out);
41317 out = '';
41318 /* istanbul ignore else */
41319
41320 if (it.createErrors !== false) {
41321 out += ' { keyword: \'' + ($errorKeyword || '_limitProperties') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { limit: ' + $schemaValue + ' } ';
41322
41323 if (it.opts.messages !== false) {
41324 out += ' , message: \'should NOT have ';
41325
41326 if ($keyword == 'maxProperties') {
41327 out += 'more';
41328 } else {
41329 out += 'fewer';
41330 }
41331
41332 out += ' than ';
41333
41334 if ($isData) {
41335 out += '\' + ' + $schemaValue + ' + \'';
41336 } else {
41337 out += '' + $schema;
41338 }
41339
41340 out += ' properties\' ';
41341 }
41342
41343 if (it.opts.verbose) {
41344 out += ' , schema: ';
41345
41346 if ($isData) {
41347 out += 'validate.schema' + $schemaPath;
41348 } else {
41349 out += '' + $schema;
41350 }
41351
41352 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
41353 }
41354
41355 out += ' } ';
41356 } else {
41357 out += ' {} ';
41358 }
41359
41360 var __err = out;
41361 out = $$outStack.pop();
41362
41363 if (!it.compositeRule && $breakOnError) {
41364 /* istanbul ignore if */
41365 if (it.async) {
41366 out += ' throw new ValidationError([' + __err + ']); ';
41367 } else {
41368 out += ' validate.errors = [' + __err + ']; return false; ';
41369 }
41370 } else {
41371 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
41372 }
41373
41374 out += '} ';
41375
41376 if ($breakOnError) {
41377 out += ' else { ';
41378 }
41379
41380 return out;
41381 };
41382
41383 /***/ }),
41384 /* 477 */
41385 /***/ ((module) => {
41386
41387 "use strict";
41388
41389
41390 module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
41391 var out = ' ';
41392 var $lvl = it.level;
41393 var $dataLvl = it.dataLevel;
41394 var $schema = it.schema[$keyword];
41395 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
41396 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
41397 var $breakOnError = !it.opts.allErrors;
41398 var $data = 'data' + ($dataLvl || '');
41399 var $isData = it.opts.$data && $schema && $schema.$data,
41400 $schemaValue;
41401
41402 if ($isData) {
41403 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
41404 $schemaValue = 'schema' + $lvl;
41405 } else {
41406 $schemaValue = $schema;
41407 }
41408
41409 if (!($isData || typeof $schema == 'number')) {
41410 throw new Error($keyword + ' must be number');
41411 }
41412
41413 out += 'var division' + $lvl + ';if (';
41414
41415 if ($isData) {
41416 out += ' ' + $schemaValue + ' !== undefined && ( typeof ' + $schemaValue + ' != \'number\' || ';
41417 }
41418
41419 out += ' (division' + $lvl + ' = ' + $data + ' / ' + $schemaValue + ', ';
41420
41421 if (it.opts.multipleOfPrecision) {
41422 out += ' Math.abs(Math.round(division' + $lvl + ') - division' + $lvl + ') > 1e-' + it.opts.multipleOfPrecision + ' ';
41423 } else {
41424 out += ' division' + $lvl + ' !== parseInt(division' + $lvl + ') ';
41425 }
41426
41427 out += ' ) ';
41428
41429 if ($isData) {
41430 out += ' ) ';
41431 }
41432
41433 out += ' ) { ';
41434 var $$outStack = $$outStack || [];
41435 $$outStack.push(out);
41436 out = '';
41437 /* istanbul ignore else */
41438
41439 if (it.createErrors !== false) {
41440 out += ' { keyword: \'' + 'multipleOf' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { multipleOf: ' + $schemaValue + ' } ';
41441
41442 if (it.opts.messages !== false) {
41443 out += ' , message: \'should be multiple of ';
41444
41445 if ($isData) {
41446 out += '\' + ' + $schemaValue;
41447 } else {
41448 out += '' + $schemaValue + '\'';
41449 }
41450 }
41451
41452 if (it.opts.verbose) {
41453 out += ' , schema: ';
41454
41455 if ($isData) {
41456 out += 'validate.schema' + $schemaPath;
41457 } else {
41458 out += '' + $schema;
41459 }
41460
41461 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
41462 }
41463
41464 out += ' } ';
41465 } else {
41466 out += ' {} ';
41467 }
41468
41469 var __err = out;
41470 out = $$outStack.pop();
41471
41472 if (!it.compositeRule && $breakOnError) {
41473 /* istanbul ignore if */
41474 if (it.async) {
41475 out += ' throw new ValidationError([' + __err + ']); ';
41476 } else {
41477 out += ' validate.errors = [' + __err + ']; return false; ';
41478 }
41479 } else {
41480 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
41481 }
41482
41483 out += '} ';
41484
41485 if ($breakOnError) {
41486 out += ' else { ';
41487 }
41488
41489 return out;
41490 };
41491
41492 /***/ }),
41493 /* 478 */
41494 /***/ ((module) => {
41495
41496 "use strict";
41497
41498
41499 module.exports = function generate_not(it, $keyword, $ruleType) {
41500 var out = ' ';
41501 var $lvl = it.level;
41502 var $dataLvl = it.dataLevel;
41503 var $schema = it.schema[$keyword];
41504 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
41505 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
41506 var $breakOnError = !it.opts.allErrors;
41507 var $data = 'data' + ($dataLvl || '');
41508 var $errs = 'errs__' + $lvl;
41509 var $it = it.util.copy(it);
41510 $it.level++;
41511 var $nextValid = 'valid' + $it.level;
41512
41513 if (it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 || $schema === false : it.util.schemaHasRules($schema, it.RULES.all)) {
41514 $it.schema = $schema;
41515 $it.schemaPath = $schemaPath;
41516 $it.errSchemaPath = $errSchemaPath;
41517 out += ' var ' + $errs + ' = errors; ';
41518 var $wasComposite = it.compositeRule;
41519 it.compositeRule = $it.compositeRule = true;
41520 $it.createErrors = false;
41521 var $allErrorsOption;
41522
41523 if ($it.opts.allErrors) {
41524 $allErrorsOption = $it.opts.allErrors;
41525 $it.opts.allErrors = false;
41526 }
41527
41528 out += ' ' + it.validate($it) + ' ';
41529 $it.createErrors = true;
41530 if ($allErrorsOption) $it.opts.allErrors = $allErrorsOption;
41531 it.compositeRule = $it.compositeRule = $wasComposite;
41532 out += ' if (' + $nextValid + ') { ';
41533 var $$outStack = $$outStack || [];
41534 $$outStack.push(out);
41535 out = '';
41536 /* istanbul ignore else */
41537
41538 if (it.createErrors !== false) {
41539 out += ' { keyword: \'' + 'not' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
41540
41541 if (it.opts.messages !== false) {
41542 out += ' , message: \'should NOT be valid\' ';
41543 }
41544
41545 if (it.opts.verbose) {
41546 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
41547 }
41548
41549 out += ' } ';
41550 } else {
41551 out += ' {} ';
41552 }
41553
41554 var __err = out;
41555 out = $$outStack.pop();
41556
41557 if (!it.compositeRule && $breakOnError) {
41558 /* istanbul ignore if */
41559 if (it.async) {
41560 out += ' throw new ValidationError([' + __err + ']); ';
41561 } else {
41562 out += ' validate.errors = [' + __err + ']; return false; ';
41563 }
41564 } else {
41565 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
41566 }
41567
41568 out += ' } else { errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; } ';
41569
41570 if (it.opts.allErrors) {
41571 out += ' } ';
41572 }
41573 } else {
41574 out += ' var err = ';
41575 /* istanbul ignore else */
41576
41577 if (it.createErrors !== false) {
41578 out += ' { keyword: \'' + 'not' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: {} ';
41579
41580 if (it.opts.messages !== false) {
41581 out += ' , message: \'should NOT be valid\' ';
41582 }
41583
41584 if (it.opts.verbose) {
41585 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
41586 }
41587
41588 out += ' } ';
41589 } else {
41590 out += ' {} ';
41591 }
41592
41593 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
41594
41595 if ($breakOnError) {
41596 out += ' if (false) { ';
41597 }
41598 }
41599
41600 return out;
41601 };
41602
41603 /***/ }),
41604 /* 479 */
41605 /***/ ((module) => {
41606
41607 "use strict";
41608
41609
41610 module.exports = function generate_oneOf(it, $keyword, $ruleType) {
41611 var out = ' ';
41612 var $lvl = it.level;
41613 var $dataLvl = it.dataLevel;
41614 var $schema = it.schema[$keyword];
41615 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
41616 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
41617 var $breakOnError = !it.opts.allErrors;
41618 var $data = 'data' + ($dataLvl || '');
41619 var $valid = 'valid' + $lvl;
41620 var $errs = 'errs__' + $lvl;
41621 var $it = it.util.copy(it);
41622 var $closingBraces = '';
41623 $it.level++;
41624 var $nextValid = 'valid' + $it.level;
41625 var $currentBaseId = $it.baseId,
41626 $prevValid = 'prevValid' + $lvl,
41627 $passingSchemas = 'passingSchemas' + $lvl;
41628 out += 'var ' + $errs + ' = errors , ' + $prevValid + ' = false , ' + $valid + ' = false , ' + $passingSchemas + ' = null; ';
41629 var $wasComposite = it.compositeRule;
41630 it.compositeRule = $it.compositeRule = true;
41631 var arr1 = $schema;
41632
41633 if (arr1) {
41634 var $sch,
41635 $i = -1,
41636 l1 = arr1.length - 1;
41637
41638 while ($i < l1) {
41639 $sch = arr1[$i += 1];
41640
41641 if (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)) {
41642 $it.schema = $sch;
41643 $it.schemaPath = $schemaPath + '[' + $i + ']';
41644 $it.errSchemaPath = $errSchemaPath + '/' + $i;
41645 out += ' ' + it.validate($it) + ' ';
41646 $it.baseId = $currentBaseId;
41647 } else {
41648 out += ' var ' + $nextValid + ' = true; ';
41649 }
41650
41651 if ($i) {
41652 out += ' if (' + $nextValid + ' && ' + $prevValid + ') { ' + $valid + ' = false; ' + $passingSchemas + ' = [' + $passingSchemas + ', ' + $i + ']; } else { ';
41653 $closingBraces += '}';
41654 }
41655
41656 out += ' if (' + $nextValid + ') { ' + $valid + ' = ' + $prevValid + ' = true; ' + $passingSchemas + ' = ' + $i + '; }';
41657 }
41658 }
41659
41660 it.compositeRule = $it.compositeRule = $wasComposite;
41661 out += '' + $closingBraces + 'if (!' + $valid + ') { var err = ';
41662 /* istanbul ignore else */
41663
41664 if (it.createErrors !== false) {
41665 out += ' { keyword: \'' + 'oneOf' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { passingSchemas: ' + $passingSchemas + ' } ';
41666
41667 if (it.opts.messages !== false) {
41668 out += ' , message: \'should match exactly one schema in oneOf\' ';
41669 }
41670
41671 if (it.opts.verbose) {
41672 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
41673 }
41674
41675 out += ' } ';
41676 } else {
41677 out += ' {} ';
41678 }
41679
41680 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
41681
41682 if (!it.compositeRule && $breakOnError) {
41683 /* istanbul ignore if */
41684 if (it.async) {
41685 out += ' throw new ValidationError(vErrors); ';
41686 } else {
41687 out += ' validate.errors = vErrors; return false; ';
41688 }
41689 }
41690
41691 out += '} else { errors = ' + $errs + '; if (vErrors !== null) { if (' + $errs + ') vErrors.length = ' + $errs + '; else vErrors = null; }';
41692
41693 if (it.opts.allErrors) {
41694 out += ' } ';
41695 }
41696
41697 return out;
41698 };
41699
41700 /***/ }),
41701 /* 480 */
41702 /***/ ((module) => {
41703
41704 "use strict";
41705
41706
41707 module.exports = function generate_pattern(it, $keyword, $ruleType) {
41708 var out = ' ';
41709 var $lvl = it.level;
41710 var $dataLvl = it.dataLevel;
41711 var $schema = it.schema[$keyword];
41712 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
41713 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
41714 var $breakOnError = !it.opts.allErrors;
41715 var $data = 'data' + ($dataLvl || '');
41716 var $isData = it.opts.$data && $schema && $schema.$data,
41717 $schemaValue;
41718
41719 if ($isData) {
41720 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
41721 $schemaValue = 'schema' + $lvl;
41722 } else {
41723 $schemaValue = $schema;
41724 }
41725
41726 var $regexp = $isData ? '(new RegExp(' + $schemaValue + '))' : it.usePattern($schema);
41727 out += 'if ( ';
41728
41729 if ($isData) {
41730 out += ' (' + $schemaValue + ' !== undefined && typeof ' + $schemaValue + ' != \'string\') || ';
41731 }
41732
41733 out += ' !' + $regexp + '.test(' + $data + ') ) { ';
41734 var $$outStack = $$outStack || [];
41735 $$outStack.push(out);
41736 out = '';
41737 /* istanbul ignore else */
41738
41739 if (it.createErrors !== false) {
41740 out += ' { keyword: \'' + 'pattern' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { pattern: ';
41741
41742 if ($isData) {
41743 out += '' + $schemaValue;
41744 } else {
41745 out += '' + it.util.toQuotedString($schema);
41746 }
41747
41748 out += ' } ';
41749
41750 if (it.opts.messages !== false) {
41751 out += ' , message: \'should match pattern "';
41752
41753 if ($isData) {
41754 out += '\' + ' + $schemaValue + ' + \'';
41755 } else {
41756 out += '' + it.util.escapeQuotes($schema);
41757 }
41758
41759 out += '"\' ';
41760 }
41761
41762 if (it.opts.verbose) {
41763 out += ' , schema: ';
41764
41765 if ($isData) {
41766 out += 'validate.schema' + $schemaPath;
41767 } else {
41768 out += '' + it.util.toQuotedString($schema);
41769 }
41770
41771 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
41772 }
41773
41774 out += ' } ';
41775 } else {
41776 out += ' {} ';
41777 }
41778
41779 var __err = out;
41780 out = $$outStack.pop();
41781
41782 if (!it.compositeRule && $breakOnError) {
41783 /* istanbul ignore if */
41784 if (it.async) {
41785 out += ' throw new ValidationError([' + __err + ']); ';
41786 } else {
41787 out += ' validate.errors = [' + __err + ']; return false; ';
41788 }
41789 } else {
41790 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
41791 }
41792
41793 out += '} ';
41794
41795 if ($breakOnError) {
41796 out += ' else { ';
41797 }
41798
41799 return out;
41800 };
41801
41802 /***/ }),
41803 /* 481 */
41804 /***/ ((module) => {
41805
41806 "use strict";
41807
41808
41809 module.exports = function generate_properties(it, $keyword, $ruleType) {
41810 var out = ' ';
41811 var $lvl = it.level;
41812 var $dataLvl = it.dataLevel;
41813 var $schema = it.schema[$keyword];
41814 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
41815 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
41816 var $breakOnError = !it.opts.allErrors;
41817 var $data = 'data' + ($dataLvl || '');
41818 var $errs = 'errs__' + $lvl;
41819 var $it = it.util.copy(it);
41820 var $closingBraces = '';
41821 $it.level++;
41822 var $nextValid = 'valid' + $it.level;
41823 var $key = 'key' + $lvl,
41824 $idx = 'idx' + $lvl,
41825 $dataNxt = $it.dataLevel = it.dataLevel + 1,
41826 $nextData = 'data' + $dataNxt,
41827 $dataProperties = 'dataProperties' + $lvl;
41828 var $schemaKeys = Object.keys($schema || {}).filter(notProto),
41829 $pProperties = it.schema.patternProperties || {},
41830 $pPropertyKeys = Object.keys($pProperties).filter(notProto),
41831 $aProperties = it.schema.additionalProperties,
41832 $someProperties = $schemaKeys.length || $pPropertyKeys.length,
41833 $noAdditional = $aProperties === false,
41834 $additionalIsSchema = typeof $aProperties == 'object' && Object.keys($aProperties).length,
41835 $removeAdditional = it.opts.removeAdditional,
41836 $checkAdditional = $noAdditional || $additionalIsSchema || $removeAdditional,
41837 $ownProperties = it.opts.ownProperties,
41838 $currentBaseId = it.baseId;
41839 var $required = it.schema.required;
41840
41841 if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) {
41842 var $requiredHash = it.util.toHash($required);
41843 }
41844
41845 function notProto(p) {
41846 return p !== '__proto__';
41847 }
41848
41849 out += 'var ' + $errs + ' = errors;var ' + $nextValid + ' = true;';
41850
41851 if ($ownProperties) {
41852 out += ' var ' + $dataProperties + ' = undefined;';
41853 }
41854
41855 if ($checkAdditional) {
41856 if ($ownProperties) {
41857 out += ' ' + $dataProperties + ' = ' + $dataProperties + ' || Object.keys(' + $data + '); for (var ' + $idx + '=0; ' + $idx + '<' + $dataProperties + '.length; ' + $idx + '++) { var ' + $key + ' = ' + $dataProperties + '[' + $idx + ']; ';
41858 } else {
41859 out += ' for (var ' + $key + ' in ' + $data + ') { ';
41860 }
41861
41862 if ($someProperties) {
41863 out += ' var isAdditional' + $lvl + ' = !(false ';
41864
41865 if ($schemaKeys.length) {
41866 if ($schemaKeys.length > 8) {
41867 out += ' || validate.schema' + $schemaPath + '.hasOwnProperty(' + $key + ') ';
41868 } else {
41869 var arr1 = $schemaKeys;
41870
41871 if (arr1) {
41872 var $propertyKey,
41873 i1 = -1,
41874 l1 = arr1.length - 1;
41875
41876 while (i1 < l1) {
41877 $propertyKey = arr1[i1 += 1];
41878 out += ' || ' + $key + ' == ' + it.util.toQuotedString($propertyKey) + ' ';
41879 }
41880 }
41881 }
41882 }
41883
41884 if ($pPropertyKeys.length) {
41885 var arr2 = $pPropertyKeys;
41886
41887 if (arr2) {
41888 var $pProperty,
41889 $i = -1,
41890 l2 = arr2.length - 1;
41891
41892 while ($i < l2) {
41893 $pProperty = arr2[$i += 1];
41894 out += ' || ' + it.usePattern($pProperty) + '.test(' + $key + ') ';
41895 }
41896 }
41897 }
41898
41899 out += ' ); if (isAdditional' + $lvl + ') { ';
41900 }
41901
41902 if ($removeAdditional == 'all') {
41903 out += ' delete ' + $data + '[' + $key + ']; ';
41904 } else {
41905 var $currentErrorPath = it.errorPath;
41906 var $additionalProperty = '\' + ' + $key + ' + \'';
41907
41908 if (it.opts._errorDataPathProperty) {
41909 it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
41910 }
41911
41912 if ($noAdditional) {
41913 if ($removeAdditional) {
41914 out += ' delete ' + $data + '[' + $key + ']; ';
41915 } else {
41916 out += ' ' + $nextValid + ' = false; ';
41917 var $currErrSchemaPath = $errSchemaPath;
41918 $errSchemaPath = it.errSchemaPath + '/additionalProperties';
41919 var $$outStack = $$outStack || [];
41920 $$outStack.push(out);
41921 out = '';
41922 /* istanbul ignore else */
41923
41924 if (it.createErrors !== false) {
41925 out += ' { keyword: \'' + 'additionalProperties' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { additionalProperty: \'' + $additionalProperty + '\' } ';
41926
41927 if (it.opts.messages !== false) {
41928 out += ' , message: \'';
41929
41930 if (it.opts._errorDataPathProperty) {
41931 out += 'is an invalid additional property';
41932 } else {
41933 out += 'should NOT have additional properties';
41934 }
41935
41936 out += '\' ';
41937 }
41938
41939 if (it.opts.verbose) {
41940 out += ' , schema: false , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
41941 }
41942
41943 out += ' } ';
41944 } else {
41945 out += ' {} ';
41946 }
41947
41948 var __err = out;
41949 out = $$outStack.pop();
41950
41951 if (!it.compositeRule && $breakOnError) {
41952 /* istanbul ignore if */
41953 if (it.async) {
41954 out += ' throw new ValidationError([' + __err + ']); ';
41955 } else {
41956 out += ' validate.errors = [' + __err + ']; return false; ';
41957 }
41958 } else {
41959 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
41960 }
41961
41962 $errSchemaPath = $currErrSchemaPath;
41963
41964 if ($breakOnError) {
41965 out += ' break; ';
41966 }
41967 }
41968 } else if ($additionalIsSchema) {
41969 if ($removeAdditional == 'failing') {
41970 out += ' var ' + $errs + ' = errors; ';
41971 var $wasComposite = it.compositeRule;
41972 it.compositeRule = $it.compositeRule = true;
41973 $it.schema = $aProperties;
41974 $it.schemaPath = it.schemaPath + '.additionalProperties';
41975 $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
41976 $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
41977 var $passData = $data + '[' + $key + ']';
41978 $it.dataPathArr[$dataNxt] = $key;
41979 var $code = it.validate($it);
41980 $it.baseId = $currentBaseId;
41981
41982 if (it.util.varOccurences($code, $nextData) < 2) {
41983 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
41984 } else {
41985 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
41986 }
41987
41988 out += ' if (!' + $nextValid + ') { errors = ' + $errs + '; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete ' + $data + '[' + $key + ']; } ';
41989 it.compositeRule = $it.compositeRule = $wasComposite;
41990 } else {
41991 $it.schema = $aProperties;
41992 $it.schemaPath = it.schemaPath + '.additionalProperties';
41993 $it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
41994 $it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
41995 var $passData = $data + '[' + $key + ']';
41996 $it.dataPathArr[$dataNxt] = $key;
41997 var $code = it.validate($it);
41998 $it.baseId = $currentBaseId;
41999
42000 if (it.util.varOccurences($code, $nextData) < 2) {
42001 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
42002 } else {
42003 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
42004 }
42005
42006 if ($breakOnError) {
42007 out += ' if (!' + $nextValid + ') break; ';
42008 }
42009 }
42010 }
42011
42012 it.errorPath = $currentErrorPath;
42013 }
42014
42015 if ($someProperties) {
42016 out += ' } ';
42017 }
42018
42019 out += ' } ';
42020
42021 if ($breakOnError) {
42022 out += ' if (' + $nextValid + ') { ';
42023 $closingBraces += '}';
42024 }
42025 }
42026
42027 var $useDefaults = it.opts.useDefaults && !it.compositeRule;
42028
42029 if ($schemaKeys.length) {
42030 var arr3 = $schemaKeys;
42031
42032 if (arr3) {
42033 var $propertyKey,
42034 i3 = -1,
42035 l3 = arr3.length - 1;
42036
42037 while (i3 < l3) {
42038 $propertyKey = arr3[i3 += 1];
42039 var $sch = $schema[$propertyKey];
42040
42041 if (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)) {
42042 var $prop = it.util.getProperty($propertyKey),
42043 $passData = $data + $prop,
42044 $hasDefault = $useDefaults && $sch.default !== undefined;
42045 $it.schema = $sch;
42046 $it.schemaPath = $schemaPath + $prop;
42047 $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($propertyKey);
42048 $it.errorPath = it.util.getPath(it.errorPath, $propertyKey, it.opts.jsonPointers);
42049 $it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey);
42050 var $code = it.validate($it);
42051 $it.baseId = $currentBaseId;
42052
42053 if (it.util.varOccurences($code, $nextData) < 2) {
42054 $code = it.util.varReplace($code, $nextData, $passData);
42055 var $useData = $passData;
42056 } else {
42057 var $useData = $nextData;
42058 out += ' var ' + $nextData + ' = ' + $passData + '; ';
42059 }
42060
42061 if ($hasDefault) {
42062 out += ' ' + $code + ' ';
42063 } else {
42064 if ($requiredHash && $requiredHash[$propertyKey]) {
42065 out += ' if ( ' + $useData + ' === undefined ';
42066
42067 if ($ownProperties) {
42068 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
42069 }
42070
42071 out += ') { ' + $nextValid + ' = false; ';
42072 var $currentErrorPath = it.errorPath,
42073 $currErrSchemaPath = $errSchemaPath,
42074 $missingProperty = it.util.escapeQuotes($propertyKey);
42075
42076 if (it.opts._errorDataPathProperty) {
42077 it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
42078 }
42079
42080 $errSchemaPath = it.errSchemaPath + '/required';
42081 var $$outStack = $$outStack || [];
42082 $$outStack.push(out);
42083 out = '';
42084 /* istanbul ignore else */
42085
42086 if (it.createErrors !== false) {
42087 out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
42088
42089 if (it.opts.messages !== false) {
42090 out += ' , message: \'';
42091
42092 if (it.opts._errorDataPathProperty) {
42093 out += 'is a required property';
42094 } else {
42095 out += 'should have required property \\\'' + $missingProperty + '\\\'';
42096 }
42097
42098 out += '\' ';
42099 }
42100
42101 if (it.opts.verbose) {
42102 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
42103 }
42104
42105 out += ' } ';
42106 } else {
42107 out += ' {} ';
42108 }
42109
42110 var __err = out;
42111 out = $$outStack.pop();
42112
42113 if (!it.compositeRule && $breakOnError) {
42114 /* istanbul ignore if */
42115 if (it.async) {
42116 out += ' throw new ValidationError([' + __err + ']); ';
42117 } else {
42118 out += ' validate.errors = [' + __err + ']; return false; ';
42119 }
42120 } else {
42121 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
42122 }
42123
42124 $errSchemaPath = $currErrSchemaPath;
42125 it.errorPath = $currentErrorPath;
42126 out += ' } else { ';
42127 } else {
42128 if ($breakOnError) {
42129 out += ' if ( ' + $useData + ' === undefined ';
42130
42131 if ($ownProperties) {
42132 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
42133 }
42134
42135 out += ') { ' + $nextValid + ' = true; } else { ';
42136 } else {
42137 out += ' if (' + $useData + ' !== undefined ';
42138
42139 if ($ownProperties) {
42140 out += ' && Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
42141 }
42142
42143 out += ' ) { ';
42144 }
42145 }
42146
42147 out += ' ' + $code + ' } ';
42148 }
42149 }
42150
42151 if ($breakOnError) {
42152 out += ' if (' + $nextValid + ') { ';
42153 $closingBraces += '}';
42154 }
42155 }
42156 }
42157 }
42158
42159 if ($pPropertyKeys.length) {
42160 var arr4 = $pPropertyKeys;
42161
42162 if (arr4) {
42163 var $pProperty,
42164 i4 = -1,
42165 l4 = arr4.length - 1;
42166
42167 while (i4 < l4) {
42168 $pProperty = arr4[i4 += 1];
42169 var $sch = $pProperties[$pProperty];
42170
42171 if (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)) {
42172 $it.schema = $sch;
42173 $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
42174 $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty);
42175
42176 if ($ownProperties) {
42177 out += ' ' + $dataProperties + ' = ' + $dataProperties + ' || Object.keys(' + $data + '); for (var ' + $idx + '=0; ' + $idx + '<' + $dataProperties + '.length; ' + $idx + '++) { var ' + $key + ' = ' + $dataProperties + '[' + $idx + ']; ';
42178 } else {
42179 out += ' for (var ' + $key + ' in ' + $data + ') { ';
42180 }
42181
42182 out += ' if (' + it.usePattern($pProperty) + '.test(' + $key + ')) { ';
42183 $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
42184 var $passData = $data + '[' + $key + ']';
42185 $it.dataPathArr[$dataNxt] = $key;
42186 var $code = it.validate($it);
42187 $it.baseId = $currentBaseId;
42188
42189 if (it.util.varOccurences($code, $nextData) < 2) {
42190 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
42191 } else {
42192 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
42193 }
42194
42195 if ($breakOnError) {
42196 out += ' if (!' + $nextValid + ') break; ';
42197 }
42198
42199 out += ' } ';
42200
42201 if ($breakOnError) {
42202 out += ' else ' + $nextValid + ' = true; ';
42203 }
42204
42205 out += ' } ';
42206
42207 if ($breakOnError) {
42208 out += ' if (' + $nextValid + ') { ';
42209 $closingBraces += '}';
42210 }
42211 }
42212 }
42213 }
42214 }
42215
42216 if ($breakOnError) {
42217 out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {';
42218 }
42219
42220 return out;
42221 };
42222
42223 /***/ }),
42224 /* 482 */
42225 /***/ ((module) => {
42226
42227 "use strict";
42228
42229
42230 module.exports = function generate_propertyNames(it, $keyword, $ruleType) {
42231 var out = ' ';
42232 var $lvl = it.level;
42233 var $dataLvl = it.dataLevel;
42234 var $schema = it.schema[$keyword];
42235 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
42236 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
42237 var $breakOnError = !it.opts.allErrors;
42238 var $data = 'data' + ($dataLvl || '');
42239 var $errs = 'errs__' + $lvl;
42240 var $it = it.util.copy(it);
42241 var $closingBraces = '';
42242 $it.level++;
42243 var $nextValid = 'valid' + $it.level;
42244 out += 'var ' + $errs + ' = errors;';
42245
42246 if (it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 || $schema === false : it.util.schemaHasRules($schema, it.RULES.all)) {
42247 $it.schema = $schema;
42248 $it.schemaPath = $schemaPath;
42249 $it.errSchemaPath = $errSchemaPath;
42250 var $key = 'key' + $lvl,
42251 $idx = 'idx' + $lvl,
42252 $i = 'i' + $lvl,
42253 $invalidName = '\' + ' + $key + ' + \'',
42254 $dataNxt = $it.dataLevel = it.dataLevel + 1,
42255 $nextData = 'data' + $dataNxt,
42256 $dataProperties = 'dataProperties' + $lvl,
42257 $ownProperties = it.opts.ownProperties,
42258 $currentBaseId = it.baseId;
42259
42260 if ($ownProperties) {
42261 out += ' var ' + $dataProperties + ' = undefined; ';
42262 }
42263
42264 if ($ownProperties) {
42265 out += ' ' + $dataProperties + ' = ' + $dataProperties + ' || Object.keys(' + $data + '); for (var ' + $idx + '=0; ' + $idx + '<' + $dataProperties + '.length; ' + $idx + '++) { var ' + $key + ' = ' + $dataProperties + '[' + $idx + ']; ';
42266 } else {
42267 out += ' for (var ' + $key + ' in ' + $data + ') { ';
42268 }
42269
42270 out += ' var startErrs' + $lvl + ' = errors; ';
42271 var $passData = $key;
42272 var $wasComposite = it.compositeRule;
42273 it.compositeRule = $it.compositeRule = true;
42274 var $code = it.validate($it);
42275 $it.baseId = $currentBaseId;
42276
42277 if (it.util.varOccurences($code, $nextData) < 2) {
42278 out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ';
42279 } else {
42280 out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ';
42281 }
42282
42283 it.compositeRule = $it.compositeRule = $wasComposite;
42284 out += ' if (!' + $nextValid + ') { for (var ' + $i + '=startErrs' + $lvl + '; ' + $i + '<errors; ' + $i + '++) { vErrors[' + $i + '].propertyName = ' + $key + '; } var err = ';
42285 /* istanbul ignore else */
42286
42287 if (it.createErrors !== false) {
42288 out += ' { keyword: \'' + 'propertyNames' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { propertyName: \'' + $invalidName + '\' } ';
42289
42290 if (it.opts.messages !== false) {
42291 out += ' , message: \'property name \\\'' + $invalidName + '\\\' is invalid\' ';
42292 }
42293
42294 if (it.opts.verbose) {
42295 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
42296 }
42297
42298 out += ' } ';
42299 } else {
42300 out += ' {} ';
42301 }
42302
42303 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
42304
42305 if (!it.compositeRule && $breakOnError) {
42306 /* istanbul ignore if */
42307 if (it.async) {
42308 out += ' throw new ValidationError(vErrors); ';
42309 } else {
42310 out += ' validate.errors = vErrors; return false; ';
42311 }
42312 }
42313
42314 if ($breakOnError) {
42315 out += ' break; ';
42316 }
42317
42318 out += ' } }';
42319 }
42320
42321 if ($breakOnError) {
42322 out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {';
42323 }
42324
42325 return out;
42326 };
42327
42328 /***/ }),
42329 /* 483 */
42330 /***/ ((module) => {
42331
42332 "use strict";
42333
42334
42335 module.exports = function generate_required(it, $keyword, $ruleType) {
42336 var out = ' ';
42337 var $lvl = it.level;
42338 var $dataLvl = it.dataLevel;
42339 var $schema = it.schema[$keyword];
42340 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
42341 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
42342 var $breakOnError = !it.opts.allErrors;
42343 var $data = 'data' + ($dataLvl || '');
42344 var $valid = 'valid' + $lvl;
42345 var $isData = it.opts.$data && $schema && $schema.$data,
42346 $schemaValue;
42347
42348 if ($isData) {
42349 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
42350 $schemaValue = 'schema' + $lvl;
42351 } else {
42352 $schemaValue = $schema;
42353 }
42354
42355 var $vSchema = 'schema' + $lvl;
42356
42357 if (!$isData) {
42358 if ($schema.length < it.opts.loopRequired && it.schema.properties && Object.keys(it.schema.properties).length) {
42359 var $required = [];
42360 var arr1 = $schema;
42361
42362 if (arr1) {
42363 var $property,
42364 i1 = -1,
42365 l1 = arr1.length - 1;
42366
42367 while (i1 < l1) {
42368 $property = arr1[i1 += 1];
42369 var $propertySch = it.schema.properties[$property];
42370
42371 if (!($propertySch && (it.opts.strictKeywords ? typeof $propertySch == 'object' && Object.keys($propertySch).length > 0 || $propertySch === false : it.util.schemaHasRules($propertySch, it.RULES.all)))) {
42372 $required[$required.length] = $property;
42373 }
42374 }
42375 }
42376 } else {
42377 var $required = $schema;
42378 }
42379 }
42380
42381 if ($isData || $required.length) {
42382 var $currentErrorPath = it.errorPath,
42383 $loopRequired = $isData || $required.length >= it.opts.loopRequired,
42384 $ownProperties = it.opts.ownProperties;
42385
42386 if ($breakOnError) {
42387 out += ' var missing' + $lvl + '; ';
42388
42389 if ($loopRequired) {
42390 if (!$isData) {
42391 out += ' var ' + $vSchema + ' = validate.schema' + $schemaPath + '; ';
42392 }
42393
42394 var $i = 'i' + $lvl,
42395 $propertyPath = 'schema' + $lvl + '[' + $i + ']',
42396 $missingProperty = '\' + ' + $propertyPath + ' + \'';
42397
42398 if (it.opts._errorDataPathProperty) {
42399 it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
42400 }
42401
42402 out += ' var ' + $valid + ' = true; ';
42403
42404 if ($isData) {
42405 out += ' if (schema' + $lvl + ' === undefined) ' + $valid + ' = true; else if (!Array.isArray(schema' + $lvl + ')) ' + $valid + ' = false; else {';
42406 }
42407
42408 out += ' for (var ' + $i + ' = 0; ' + $i + ' < ' + $vSchema + '.length; ' + $i + '++) { ' + $valid + ' = ' + $data + '[' + $vSchema + '[' + $i + ']] !== undefined ';
42409
42410 if ($ownProperties) {
42411 out += ' && Object.prototype.hasOwnProperty.call(' + $data + ', ' + $vSchema + '[' + $i + ']) ';
42412 }
42413
42414 out += '; if (!' + $valid + ') break; } ';
42415
42416 if ($isData) {
42417 out += ' } ';
42418 }
42419
42420 out += ' if (!' + $valid + ') { ';
42421 var $$outStack = $$outStack || [];
42422 $$outStack.push(out);
42423 out = '';
42424 /* istanbul ignore else */
42425
42426 if (it.createErrors !== false) {
42427 out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
42428
42429 if (it.opts.messages !== false) {
42430 out += ' , message: \'';
42431
42432 if (it.opts._errorDataPathProperty) {
42433 out += 'is a required property';
42434 } else {
42435 out += 'should have required property \\\'' + $missingProperty + '\\\'';
42436 }
42437
42438 out += '\' ';
42439 }
42440
42441 if (it.opts.verbose) {
42442 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
42443 }
42444
42445 out += ' } ';
42446 } else {
42447 out += ' {} ';
42448 }
42449
42450 var __err = out;
42451 out = $$outStack.pop();
42452
42453 if (!it.compositeRule && $breakOnError) {
42454 /* istanbul ignore if */
42455 if (it.async) {
42456 out += ' throw new ValidationError([' + __err + ']); ';
42457 } else {
42458 out += ' validate.errors = [' + __err + ']; return false; ';
42459 }
42460 } else {
42461 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
42462 }
42463
42464 out += ' } else { ';
42465 } else {
42466 out += ' if ( ';
42467 var arr2 = $required;
42468
42469 if (arr2) {
42470 var $propertyKey,
42471 $i = -1,
42472 l2 = arr2.length - 1;
42473
42474 while ($i < l2) {
42475 $propertyKey = arr2[$i += 1];
42476
42477 if ($i) {
42478 out += ' || ';
42479 }
42480
42481 var $prop = it.util.getProperty($propertyKey),
42482 $useData = $data + $prop;
42483 out += ' ( ( ' + $useData + ' === undefined ';
42484
42485 if ($ownProperties) {
42486 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
42487 }
42488
42489 out += ') && (missing' + $lvl + ' = ' + it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop) + ') ) ';
42490 }
42491 }
42492
42493 out += ') { ';
42494 var $propertyPath = 'missing' + $lvl,
42495 $missingProperty = '\' + ' + $propertyPath + ' + \'';
42496
42497 if (it.opts._errorDataPathProperty) {
42498 it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
42499 }
42500
42501 var $$outStack = $$outStack || [];
42502 $$outStack.push(out);
42503 out = '';
42504 /* istanbul ignore else */
42505
42506 if (it.createErrors !== false) {
42507 out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
42508
42509 if (it.opts.messages !== false) {
42510 out += ' , message: \'';
42511
42512 if (it.opts._errorDataPathProperty) {
42513 out += 'is a required property';
42514 } else {
42515 out += 'should have required property \\\'' + $missingProperty + '\\\'';
42516 }
42517
42518 out += '\' ';
42519 }
42520
42521 if (it.opts.verbose) {
42522 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
42523 }
42524
42525 out += ' } ';
42526 } else {
42527 out += ' {} ';
42528 }
42529
42530 var __err = out;
42531 out = $$outStack.pop();
42532
42533 if (!it.compositeRule && $breakOnError) {
42534 /* istanbul ignore if */
42535 if (it.async) {
42536 out += ' throw new ValidationError([' + __err + ']); ';
42537 } else {
42538 out += ' validate.errors = [' + __err + ']; return false; ';
42539 }
42540 } else {
42541 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
42542 }
42543
42544 out += ' } else { ';
42545 }
42546 } else {
42547 if ($loopRequired) {
42548 if (!$isData) {
42549 out += ' var ' + $vSchema + ' = validate.schema' + $schemaPath + '; ';
42550 }
42551
42552 var $i = 'i' + $lvl,
42553 $propertyPath = 'schema' + $lvl + '[' + $i + ']',
42554 $missingProperty = '\' + ' + $propertyPath + ' + \'';
42555
42556 if (it.opts._errorDataPathProperty) {
42557 it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
42558 }
42559
42560 if ($isData) {
42561 out += ' if (' + $vSchema + ' && !Array.isArray(' + $vSchema + ')) { var err = ';
42562 /* istanbul ignore else */
42563
42564 if (it.createErrors !== false) {
42565 out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
42566
42567 if (it.opts.messages !== false) {
42568 out += ' , message: \'';
42569
42570 if (it.opts._errorDataPathProperty) {
42571 out += 'is a required property';
42572 } else {
42573 out += 'should have required property \\\'' + $missingProperty + '\\\'';
42574 }
42575
42576 out += '\' ';
42577 }
42578
42579 if (it.opts.verbose) {
42580 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
42581 }
42582
42583 out += ' } ';
42584 } else {
42585 out += ' {} ';
42586 }
42587
42588 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if (' + $vSchema + ' !== undefined) { ';
42589 }
42590
42591 out += ' for (var ' + $i + ' = 0; ' + $i + ' < ' + $vSchema + '.length; ' + $i + '++) { if (' + $data + '[' + $vSchema + '[' + $i + ']] === undefined ';
42592
42593 if ($ownProperties) {
42594 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', ' + $vSchema + '[' + $i + ']) ';
42595 }
42596
42597 out += ') { var err = ';
42598 /* istanbul ignore else */
42599
42600 if (it.createErrors !== false) {
42601 out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
42602
42603 if (it.opts.messages !== false) {
42604 out += ' , message: \'';
42605
42606 if (it.opts._errorDataPathProperty) {
42607 out += 'is a required property';
42608 } else {
42609 out += 'should have required property \\\'' + $missingProperty + '\\\'';
42610 }
42611
42612 out += '\' ';
42613 }
42614
42615 if (it.opts.verbose) {
42616 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
42617 }
42618
42619 out += ' } ';
42620 } else {
42621 out += ' {} ';
42622 }
42623
42624 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ';
42625
42626 if ($isData) {
42627 out += ' } ';
42628 }
42629 } else {
42630 var arr3 = $required;
42631
42632 if (arr3) {
42633 var $propertyKey,
42634 i3 = -1,
42635 l3 = arr3.length - 1;
42636
42637 while (i3 < l3) {
42638 $propertyKey = arr3[i3 += 1];
42639 var $prop = it.util.getProperty($propertyKey),
42640 $missingProperty = it.util.escapeQuotes($propertyKey),
42641 $useData = $data + $prop;
42642
42643 if (it.opts._errorDataPathProperty) {
42644 it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
42645 }
42646
42647 out += ' if ( ' + $useData + ' === undefined ';
42648
42649 if ($ownProperties) {
42650 out += ' || ! Object.prototype.hasOwnProperty.call(' + $data + ', \'' + it.util.escapeQuotes($propertyKey) + '\') ';
42651 }
42652
42653 out += ') { var err = ';
42654 /* istanbul ignore else */
42655
42656 if (it.createErrors !== false) {
42657 out += ' { keyword: \'' + 'required' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { missingProperty: \'' + $missingProperty + '\' } ';
42658
42659 if (it.opts.messages !== false) {
42660 out += ' , message: \'';
42661
42662 if (it.opts._errorDataPathProperty) {
42663 out += 'is a required property';
42664 } else {
42665 out += 'should have required property \\\'' + $missingProperty + '\\\'';
42666 }
42667
42668 out += '\' ';
42669 }
42670
42671 if (it.opts.verbose) {
42672 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
42673 }
42674
42675 out += ' } ';
42676 } else {
42677 out += ' {} ';
42678 }
42679
42680 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
42681 }
42682 }
42683 }
42684 }
42685
42686 it.errorPath = $currentErrorPath;
42687 } else if ($breakOnError) {
42688 out += ' if (true) {';
42689 }
42690
42691 return out;
42692 };
42693
42694 /***/ }),
42695 /* 484 */
42696 /***/ ((module) => {
42697
42698 "use strict";
42699
42700
42701 module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
42702 var out = ' ';
42703 var $lvl = it.level;
42704 var $dataLvl = it.dataLevel;
42705 var $schema = it.schema[$keyword];
42706 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
42707 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
42708 var $breakOnError = !it.opts.allErrors;
42709 var $data = 'data' + ($dataLvl || '');
42710 var $valid = 'valid' + $lvl;
42711 var $isData = it.opts.$data && $schema && $schema.$data,
42712 $schemaValue;
42713
42714 if ($isData) {
42715 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
42716 $schemaValue = 'schema' + $lvl;
42717 } else {
42718 $schemaValue = $schema;
42719 }
42720
42721 if (($schema || $isData) && it.opts.uniqueItems !== false) {
42722 if ($isData) {
42723 out += ' var ' + $valid + '; if (' + $schemaValue + ' === false || ' + $schemaValue + ' === undefined) ' + $valid + ' = true; else if (typeof ' + $schemaValue + ' != \'boolean\') ' + $valid + ' = false; else { ';
42724 }
42725
42726 out += ' var i = ' + $data + '.length , ' + $valid + ' = true , j; if (i > 1) { ';
42727 var $itemType = it.schema.items && it.schema.items.type,
42728 $typeIsArray = Array.isArray($itemType);
42729
42730 if (!$itemType || $itemType == 'object' || $itemType == 'array' || $typeIsArray && ($itemType.indexOf('object') >= 0 || $itemType.indexOf('array') >= 0)) {
42731 out += ' outer: for (;i--;) { for (j = i; j--;) { if (equal(' + $data + '[i], ' + $data + '[j])) { ' + $valid + ' = false; break outer; } } } ';
42732 } else {
42733 out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + $data + '[i]; ';
42734 var $method = 'checkDataType' + ($typeIsArray ? 's' : '');
42735 out += ' if (' + it.util[$method]($itemType, 'item', it.opts.strictNumbers, true) + ') continue; ';
42736
42737 if ($typeIsArray) {
42738 out += ' if (typeof item == \'string\') item = \'"\' + item; ';
42739 }
42740
42741 out += ' if (typeof itemIndices[item] == \'number\') { ' + $valid + ' = false; j = itemIndices[item]; break; } itemIndices[item] = i; } ';
42742 }
42743
42744 out += ' } ';
42745
42746 if ($isData) {
42747 out += ' } ';
42748 }
42749
42750 out += ' if (!' + $valid + ') { ';
42751 var $$outStack = $$outStack || [];
42752 $$outStack.push(out);
42753 out = '';
42754 /* istanbul ignore else */
42755
42756 if (it.createErrors !== false) {
42757 out += ' { keyword: \'' + 'uniqueItems' + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { i: i, j: j } ';
42758
42759 if (it.opts.messages !== false) {
42760 out += ' , message: \'should NOT have duplicate items (items ## \' + j + \' and \' + i + \' are identical)\' ';
42761 }
42762
42763 if (it.opts.verbose) {
42764 out += ' , schema: ';
42765
42766 if ($isData) {
42767 out += 'validate.schema' + $schemaPath;
42768 } else {
42769 out += '' + $schema;
42770 }
42771
42772 out += ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
42773 }
42774
42775 out += ' } ';
42776 } else {
42777 out += ' {} ';
42778 }
42779
42780 var __err = out;
42781 out = $$outStack.pop();
42782
42783 if (!it.compositeRule && $breakOnError) {
42784 /* istanbul ignore if */
42785 if (it.async) {
42786 out += ' throw new ValidationError([' + __err + ']); ';
42787 } else {
42788 out += ' validate.errors = [' + __err + ']; return false; ';
42789 }
42790 } else {
42791 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
42792 }
42793
42794 out += ' } ';
42795
42796 if ($breakOnError) {
42797 out += ' else { ';
42798 }
42799 } else {
42800 if ($breakOnError) {
42801 out += ' if (true) { ';
42802 }
42803 }
42804
42805 return out;
42806 };
42807
42808 /***/ }),
42809 /* 485 */
42810 /***/ ((module) => {
42811
42812 "use strict";
42813
42814
42815 var KEYWORDS = ['multipleOf', 'maximum', 'exclusiveMaximum', 'minimum', 'exclusiveMinimum', 'maxLength', 'minLength', 'pattern', 'additionalItems', 'maxItems', 'minItems', 'uniqueItems', 'maxProperties', 'minProperties', 'required', 'additionalProperties', 'enum', 'format', 'const'];
42816
42817 module.exports = function (metaSchema, keywordsJsonPointers) {
42818 for (var i = 0; i < keywordsJsonPointers.length; i++) {
42819 metaSchema = JSON.parse(JSON.stringify(metaSchema));
42820 var segments = keywordsJsonPointers[i].split('/');
42821 var keywords = metaSchema;
42822 var j;
42823
42824 for (j = 1; j < segments.length; j++) keywords = keywords[segments[j]];
42825
42826 for (j = 0; j < KEYWORDS.length; j++) {
42827 var key = KEYWORDS[j];
42828 var schema = keywords[key];
42829
42830 if (schema) {
42831 keywords[key] = {
42832 anyOf: [schema, {
42833 $ref: 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#'
42834 }]
42835 };
42836 }
42837 }
42838 }
42839
42840 return metaSchema;
42841 };
42842
42843 /***/ }),
42844 /* 486 */
42845 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
42846
42847 "use strict";
42848
42849
42850 var MissingRefError = (__webpack_require__(455).MissingRef);
42851
42852 module.exports = compileAsync;
42853 /**
42854 * Creates validating function for passed schema with asynchronous loading of missing schemas.
42855 * `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
42856 * @this Ajv
42857 * @param {Object} schema schema object
42858 * @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
42859 * @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
42860 * @return {Promise} promise that resolves with a validating function.
42861 */
42862
42863 function compileAsync(schema, meta, callback) {
42864 /* eslint no-shadow: 0 */
42865
42866 /* global Promise */
42867
42868 /* jshint validthis: true */
42869 var self = this;
42870 if (typeof this._opts.loadSchema != 'function') throw new Error('options.loadSchema should be a function');
42871
42872 if (typeof meta == 'function') {
42873 callback = meta;
42874 meta = undefined;
42875 }
42876
42877 var p = loadMetaSchemaOf(schema).then(function () {
42878 var schemaObj = self._addSchema(schema, undefined, meta);
42879
42880 return schemaObj.validate || _compileAsync(schemaObj);
42881 });
42882
42883 if (callback) {
42884 p.then(function (v) {
42885 callback(null, v);
42886 }, callback);
42887 }
42888
42889 return p;
42890
42891 function loadMetaSchemaOf(sch) {
42892 var $schema = sch.$schema;
42893 return $schema && !self.getSchema($schema) ? compileAsync.call(self, {
42894 $ref: $schema
42895 }, true) : Promise.resolve();
42896 }
42897
42898 function _compileAsync(schemaObj) {
42899 try {
42900 return self._compile(schemaObj);
42901 } catch (e) {
42902 if (e instanceof MissingRefError) return loadMissingSchema(e);
42903 throw e;
42904 }
42905
42906 function loadMissingSchema(e) {
42907 var ref = e.missingSchema;
42908 if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
42909 var schemaPromise = self._loadingSchemas[ref];
42910
42911 if (!schemaPromise) {
42912 schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
42913 schemaPromise.then(removePromise, removePromise);
42914 }
42915
42916 return schemaPromise.then(function (sch) {
42917 if (!added(ref)) {
42918 return loadMetaSchemaOf(sch).then(function () {
42919 if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
42920 });
42921 }
42922 }).then(function () {
42923 return _compileAsync(schemaObj);
42924 });
42925
42926 function removePromise() {
42927 delete self._loadingSchemas[ref];
42928 }
42929
42930 function added(ref) {
42931 return self._refs[ref] || self._schemas[ref];
42932 }
42933 }
42934 }
42935 }
42936
42937 /***/ }),
42938 /* 487 */
42939 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
42940
42941 "use strict";
42942
42943
42944 var IDENTIFIER = /^[a-z_$][a-z0-9_$-]*$/i;
42945
42946 var customRuleCode = __webpack_require__(488);
42947
42948 var definitionSchema = __webpack_require__(489);
42949
42950 module.exports = {
42951 add: addKeyword,
42952 get: getKeyword,
42953 remove: removeKeyword,
42954 validate: validateKeyword
42955 };
42956 /**
42957 * Define custom keyword
42958 * @this Ajv
42959 * @param {String} keyword custom keyword, should be unique (including different from all standard, custom and macro keywords).
42960 * @param {Object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`.
42961 * @return {Ajv} this for method chaining
42962 */
42963
42964 function addKeyword(keyword, definition) {
42965 /* jshint validthis: true */
42966
42967 /* eslint no-shadow: 0 */
42968 var RULES = this.RULES;
42969 if (RULES.keywords[keyword]) throw new Error('Keyword ' + keyword + ' is already defined');
42970 if (!IDENTIFIER.test(keyword)) throw new Error('Keyword ' + keyword + ' is not a valid identifier');
42971
42972 if (definition) {
42973 this.validateKeyword(definition, true);
42974 var dataType = definition.type;
42975
42976 if (Array.isArray(dataType)) {
42977 for (var i = 0; i < dataType.length; i++) _addRule(keyword, dataType[i], definition);
42978 } else {
42979 _addRule(keyword, dataType, definition);
42980 }
42981
42982 var metaSchema = definition.metaSchema;
42983
42984 if (metaSchema) {
42985 if (definition.$data && this._opts.$data) {
42986 metaSchema = {
42987 anyOf: [metaSchema, {
42988 '$ref': 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#'
42989 }]
42990 };
42991 }
42992
42993 definition.validateSchema = this.compile(metaSchema, true);
42994 }
42995 }
42996
42997 RULES.keywords[keyword] = RULES.all[keyword] = true;
42998
42999 function _addRule(keyword, dataType, definition) {
43000 var ruleGroup;
43001
43002 for (var i = 0; i < RULES.length; i++) {
43003 var rg = RULES[i];
43004
43005 if (rg.type == dataType) {
43006 ruleGroup = rg;
43007 break;
43008 }
43009 }
43010
43011 if (!ruleGroup) {
43012 ruleGroup = {
43013 type: dataType,
43014 rules: []
43015 };
43016 RULES.push(ruleGroup);
43017 }
43018
43019 var rule = {
43020 keyword: keyword,
43021 definition: definition,
43022 custom: true,
43023 code: customRuleCode,
43024 implements: definition.implements
43025 };
43026 ruleGroup.rules.push(rule);
43027 RULES.custom[keyword] = rule;
43028 }
43029
43030 return this;
43031 }
43032 /**
43033 * Get keyword
43034 * @this Ajv
43035 * @param {String} keyword pre-defined or custom keyword.
43036 * @return {Object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise.
43037 */
43038
43039
43040 function getKeyword(keyword) {
43041 /* jshint validthis: true */
43042 var rule = this.RULES.custom[keyword];
43043 return rule ? rule.definition : this.RULES.keywords[keyword] || false;
43044 }
43045 /**
43046 * Remove keyword
43047 * @this Ajv
43048 * @param {String} keyword pre-defined or custom keyword.
43049 * @return {Ajv} this for method chaining
43050 */
43051
43052
43053 function removeKeyword(keyword) {
43054 /* jshint validthis: true */
43055 var RULES = this.RULES;
43056 delete RULES.keywords[keyword];
43057 delete RULES.all[keyword];
43058 delete RULES.custom[keyword];
43059
43060 for (var i = 0; i < RULES.length; i++) {
43061 var rules = RULES[i].rules;
43062
43063 for (var j = 0; j < rules.length; j++) {
43064 if (rules[j].keyword == keyword) {
43065 rules.splice(j, 1);
43066 break;
43067 }
43068 }
43069 }
43070
43071 return this;
43072 }
43073 /**
43074 * Validate keyword definition
43075 * @this Ajv
43076 * @param {Object} definition keyword definition object.
43077 * @param {Boolean} throwError true to throw exception if definition is invalid
43078 * @return {boolean} validation result
43079 */
43080
43081
43082 function validateKeyword(definition, throwError) {
43083 validateKeyword.errors = null;
43084 var v = this._validateKeyword = this._validateKeyword || this.compile(definitionSchema, true);
43085 if (v(definition)) return true;
43086 validateKeyword.errors = v.errors;
43087 if (throwError) throw new Error('custom keyword definition is invalid: ' + this.errorsText(v.errors));else return false;
43088 }
43089
43090 /***/ }),
43091 /* 488 */
43092 /***/ ((module) => {
43093
43094 "use strict";
43095
43096
43097 module.exports = function generate_custom(it, $keyword, $ruleType) {
43098 var out = ' ';
43099 var $lvl = it.level;
43100 var $dataLvl = it.dataLevel;
43101 var $schema = it.schema[$keyword];
43102 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
43103 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
43104 var $breakOnError = !it.opts.allErrors;
43105 var $errorKeyword;
43106 var $data = 'data' + ($dataLvl || '');
43107 var $valid = 'valid' + $lvl;
43108 var $errs = 'errs__' + $lvl;
43109 var $isData = it.opts.$data && $schema && $schema.$data,
43110 $schemaValue;
43111
43112 if ($isData) {
43113 out += ' var schema' + $lvl + ' = ' + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + '; ';
43114 $schemaValue = 'schema' + $lvl;
43115 } else {
43116 $schemaValue = $schema;
43117 }
43118
43119 var $rule = this,
43120 $definition = 'definition' + $lvl,
43121 $rDef = $rule.definition,
43122 $closingBraces = '';
43123 var $compile, $inline, $macro, $ruleValidate, $validateCode;
43124
43125 if ($isData && $rDef.$data) {
43126 $validateCode = 'keywordValidate' + $lvl;
43127 var $validateSchema = $rDef.validateSchema;
43128 out += ' var ' + $definition + ' = RULES.custom[\'' + $keyword + '\'].definition; var ' + $validateCode + ' = ' + $definition + '.validate;';
43129 } else {
43130 $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
43131 if (!$ruleValidate) return;
43132 $schemaValue = 'validate.schema' + $schemaPath;
43133 $validateCode = $ruleValidate.code;
43134 $compile = $rDef.compile;
43135 $inline = $rDef.inline;
43136 $macro = $rDef.macro;
43137 }
43138
43139 var $ruleErrs = $validateCode + '.errors',
43140 $i = 'i' + $lvl,
43141 $ruleErr = 'ruleErr' + $lvl,
43142 $asyncKeyword = $rDef.async;
43143 if ($asyncKeyword && !it.async) throw new Error('async keyword in sync schema');
43144
43145 if (!($inline || $macro)) {
43146 out += '' + $ruleErrs + ' = null;';
43147 }
43148
43149 out += 'var ' + $errs + ' = errors;var ' + $valid + ';';
43150
43151 if ($isData && $rDef.$data) {
43152 $closingBraces += '}';
43153 out += ' if (' + $schemaValue + ' === undefined) { ' + $valid + ' = true; } else { ';
43154
43155 if ($validateSchema) {
43156 $closingBraces += '}';
43157 out += ' ' + $valid + ' = ' + $definition + '.validateSchema(' + $schemaValue + '); if (' + $valid + ') { ';
43158 }
43159 }
43160
43161 if ($inline) {
43162 if ($rDef.statements) {
43163 out += ' ' + $ruleValidate.validate + ' ';
43164 } else {
43165 out += ' ' + $valid + ' = ' + $ruleValidate.validate + '; ';
43166 }
43167 } else if ($macro) {
43168 var $it = it.util.copy(it);
43169 var $closingBraces = '';
43170 $it.level++;
43171 var $nextValid = 'valid' + $it.level;
43172 $it.schema = $ruleValidate.validate;
43173 $it.schemaPath = '';
43174 var $wasComposite = it.compositeRule;
43175 it.compositeRule = $it.compositeRule = true;
43176 var $code = it.validate($it).replace(/validate\.schema/g, $validateCode);
43177 it.compositeRule = $it.compositeRule = $wasComposite;
43178 out += ' ' + $code;
43179 } else {
43180 var $$outStack = $$outStack || [];
43181 $$outStack.push(out);
43182 out = '';
43183 out += ' ' + $validateCode + '.call( ';
43184
43185 if (it.opts.passContext) {
43186 out += 'this';
43187 } else {
43188 out += 'self';
43189 }
43190
43191 if ($compile || $rDef.schema === false) {
43192 out += ' , ' + $data + ' ';
43193 } else {
43194 out += ' , ' + $schemaValue + ' , ' + $data + ' , validate.schema' + it.schemaPath + ' ';
43195 }
43196
43197 out += ' , (dataPath || \'\')';
43198
43199 if (it.errorPath != '""') {
43200 out += ' + ' + it.errorPath;
43201 }
43202
43203 var $parentData = $dataLvl ? 'data' + ($dataLvl - 1 || '') : 'parentData',
43204 $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
43205 out += ' , ' + $parentData + ' , ' + $parentDataProperty + ' , rootData ) ';
43206 var def_callRuleValidate = out;
43207 out = $$outStack.pop();
43208
43209 if ($rDef.errors === false) {
43210 out += ' ' + $valid + ' = ';
43211
43212 if ($asyncKeyword) {
43213 out += 'await ';
43214 }
43215
43216 out += '' + def_callRuleValidate + '; ';
43217 } else {
43218 if ($asyncKeyword) {
43219 $ruleErrs = 'customErrors' + $lvl;
43220 out += ' var ' + $ruleErrs + ' = null; try { ' + $valid + ' = await ' + def_callRuleValidate + '; } catch (e) { ' + $valid + ' = false; if (e instanceof ValidationError) ' + $ruleErrs + ' = e.errors; else throw e; } ';
43221 } else {
43222 out += ' ' + $ruleErrs + ' = null; ' + $valid + ' = ' + def_callRuleValidate + '; ';
43223 }
43224 }
43225 }
43226
43227 if ($rDef.modifying) {
43228 out += ' if (' + $parentData + ') ' + $data + ' = ' + $parentData + '[' + $parentDataProperty + '];';
43229 }
43230
43231 out += '' + $closingBraces;
43232
43233 if ($rDef.valid) {
43234 if ($breakOnError) {
43235 out += ' if (true) { ';
43236 }
43237 } else {
43238 out += ' if ( ';
43239
43240 if ($rDef.valid === undefined) {
43241 out += ' !';
43242
43243 if ($macro) {
43244 out += '' + $nextValid;
43245 } else {
43246 out += '' + $valid;
43247 }
43248 } else {
43249 out += ' ' + !$rDef.valid + ' ';
43250 }
43251
43252 out += ') { ';
43253 $errorKeyword = $rule.keyword;
43254 var $$outStack = $$outStack || [];
43255 $$outStack.push(out);
43256 out = '';
43257 var $$outStack = $$outStack || [];
43258 $$outStack.push(out);
43259 out = '';
43260 /* istanbul ignore else */
43261
43262 if (it.createErrors !== false) {
43263 out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { keyword: \'' + $rule.keyword + '\' } ';
43264
43265 if (it.opts.messages !== false) {
43266 out += ' , message: \'should pass "' + $rule.keyword + '" keyword validation\' ';
43267 }
43268
43269 if (it.opts.verbose) {
43270 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
43271 }
43272
43273 out += ' } ';
43274 } else {
43275 out += ' {} ';
43276 }
43277
43278 var __err = out;
43279 out = $$outStack.pop();
43280
43281 if (!it.compositeRule && $breakOnError) {
43282 /* istanbul ignore if */
43283 if (it.async) {
43284 out += ' throw new ValidationError([' + __err + ']); ';
43285 } else {
43286 out += ' validate.errors = [' + __err + ']; return false; ';
43287 }
43288 } else {
43289 out += ' var err = ' + __err + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
43290 }
43291
43292 var def_customError = out;
43293 out = $$outStack.pop();
43294
43295 if ($inline) {
43296 if ($rDef.errors) {
43297 if ($rDef.errors != 'full') {
43298 out += ' for (var ' + $i + '=' + $errs + '; ' + $i + '<errors; ' + $i + '++) { var ' + $ruleErr + ' = vErrors[' + $i + ']; if (' + $ruleErr + '.dataPath === undefined) ' + $ruleErr + '.dataPath = (dataPath || \'\') + ' + it.errorPath + '; if (' + $ruleErr + '.schemaPath === undefined) { ' + $ruleErr + '.schemaPath = "' + $errSchemaPath + '"; } ';
43299
43300 if (it.opts.verbose) {
43301 out += ' ' + $ruleErr + '.schema = ' + $schemaValue + '; ' + $ruleErr + '.data = ' + $data + '; ';
43302 }
43303
43304 out += ' } ';
43305 }
43306 } else {
43307 if ($rDef.errors === false) {
43308 out += ' ' + def_customError + ' ';
43309 } else {
43310 out += ' if (' + $errs + ' == errors) { ' + def_customError + ' } else { for (var ' + $i + '=' + $errs + '; ' + $i + '<errors; ' + $i + '++) { var ' + $ruleErr + ' = vErrors[' + $i + ']; if (' + $ruleErr + '.dataPath === undefined) ' + $ruleErr + '.dataPath = (dataPath || \'\') + ' + it.errorPath + '; if (' + $ruleErr + '.schemaPath === undefined) { ' + $ruleErr + '.schemaPath = "' + $errSchemaPath + '"; } ';
43311
43312 if (it.opts.verbose) {
43313 out += ' ' + $ruleErr + '.schema = ' + $schemaValue + '; ' + $ruleErr + '.data = ' + $data + '; ';
43314 }
43315
43316 out += ' } } ';
43317 }
43318 }
43319 } else if ($macro) {
43320 out += ' var err = ';
43321 /* istanbul ignore else */
43322
43323 if (it.createErrors !== false) {
43324 out += ' { keyword: \'' + ($errorKeyword || 'custom') + '\' , dataPath: (dataPath || \'\') + ' + it.errorPath + ' , schemaPath: ' + it.util.toQuotedString($errSchemaPath) + ' , params: { keyword: \'' + $rule.keyword + '\' } ';
43325
43326 if (it.opts.messages !== false) {
43327 out += ' , message: \'should pass "' + $rule.keyword + '" keyword validation\' ';
43328 }
43329
43330 if (it.opts.verbose) {
43331 out += ' , schema: validate.schema' + $schemaPath + ' , parentSchema: validate.schema' + it.schemaPath + ' , data: ' + $data + ' ';
43332 }
43333
43334 out += ' } ';
43335 } else {
43336 out += ' {} ';
43337 }
43338
43339 out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
43340
43341 if (!it.compositeRule && $breakOnError) {
43342 /* istanbul ignore if */
43343 if (it.async) {
43344 out += ' throw new ValidationError(vErrors); ';
43345 } else {
43346 out += ' validate.errors = vErrors; return false; ';
43347 }
43348 }
43349 } else {
43350 if ($rDef.errors === false) {
43351 out += ' ' + def_customError + ' ';
43352 } else {
43353 out += ' if (Array.isArray(' + $ruleErrs + ')) { if (vErrors === null) vErrors = ' + $ruleErrs + '; else vErrors = vErrors.concat(' + $ruleErrs + '); errors = vErrors.length; for (var ' + $i + '=' + $errs + '; ' + $i + '<errors; ' + $i + '++) { var ' + $ruleErr + ' = vErrors[' + $i + ']; if (' + $ruleErr + '.dataPath === undefined) ' + $ruleErr + '.dataPath = (dataPath || \'\') + ' + it.errorPath + '; ' + $ruleErr + '.schemaPath = "' + $errSchemaPath + '"; ';
43354
43355 if (it.opts.verbose) {
43356 out += ' ' + $ruleErr + '.schema = ' + $schemaValue + '; ' + $ruleErr + '.data = ' + $data + '; ';
43357 }
43358
43359 out += ' } } else { ' + def_customError + ' } ';
43360 }
43361 }
43362
43363 out += ' } ';
43364
43365 if ($breakOnError) {
43366 out += ' else { ';
43367 }
43368 }
43369
43370 return out;
43371 };
43372
43373 /***/ }),
43374 /* 489 */
43375 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
43376
43377 "use strict";
43378
43379
43380 var metaSchema = __webpack_require__(490);
43381
43382 module.exports = {
43383 $id: 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js',
43384 definitions: {
43385 simpleTypes: metaSchema.definitions.simpleTypes
43386 },
43387 type: 'object',
43388 dependencies: {
43389 schema: ['validate'],
43390 $data: ['validate'],
43391 statements: ['inline'],
43392 valid: {
43393 not: {
43394 required: ['macro']
43395 }
43396 }
43397 },
43398 properties: {
43399 type: metaSchema.properties.type,
43400 schema: {
43401 type: 'boolean'
43402 },
43403 statements: {
43404 type: 'boolean'
43405 },
43406 dependencies: {
43407 type: 'array',
43408 items: {
43409 type: 'string'
43410 }
43411 },
43412 metaSchema: {
43413 type: 'object'
43414 },
43415 modifying: {
43416 type: 'boolean'
43417 },
43418 valid: {
43419 type: 'boolean'
43420 },
43421 $data: {
43422 type: 'boolean'
43423 },
43424 async: {
43425 type: 'boolean'
43426 },
43427 errors: {
43428 anyOf: [{
43429 type: 'boolean'
43430 }, {
43431 const: 'full'
43432 }]
43433 }
43434 }
43435 };
43436
43437 /***/ }),
43438 /* 490 */
43439 /***/ ((module) => {
43440
43441 "use strict";
43442 module.exports = JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"http://json-schema.org/draft-07/schema#","title":"Core schema meta-schema","definitions":{"schemaArray":{"type":"array","minItems":1,"items":{"$ref":"#"}},"nonNegativeInteger":{"type":"integer","minimum":0},"nonNegativeIntegerDefault0":{"allOf":[{"$ref":"#/definitions/nonNegativeInteger"},{"default":0}]},"simpleTypes":{"enum":["array","boolean","integer","null","number","object","string"]},"stringArray":{"type":"array","items":{"type":"string"},"uniqueItems":true,"default":[]}},"type":["object","boolean"],"properties":{"$id":{"type":"string","format":"uri-reference"},"$schema":{"type":"string","format":"uri"},"$ref":{"type":"string","format":"uri-reference"},"$comment":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"default":true,"readOnly":{"type":"boolean","default":false},"examples":{"type":"array","items":true},"multipleOf":{"type":"number","exclusiveMinimum":0},"maximum":{"type":"number"},"exclusiveMaximum":{"type":"number"},"minimum":{"type":"number"},"exclusiveMinimum":{"type":"number"},"maxLength":{"$ref":"#/definitions/nonNegativeInteger"},"minLength":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"pattern":{"type":"string","format":"regex"},"additionalItems":{"$ref":"#"},"items":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/schemaArray"}],"default":true},"maxItems":{"$ref":"#/definitions/nonNegativeInteger"},"minItems":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"uniqueItems":{"type":"boolean","default":false},"contains":{"$ref":"#"},"maxProperties":{"$ref":"#/definitions/nonNegativeInteger"},"minProperties":{"$ref":"#/definitions/nonNegativeIntegerDefault0"},"required":{"$ref":"#/definitions/stringArray"},"additionalProperties":{"$ref":"#"},"definitions":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"properties":{"type":"object","additionalProperties":{"$ref":"#"},"default":{}},"patternProperties":{"type":"object","additionalProperties":{"$ref":"#"},"propertyNames":{"format":"regex"},"default":{}},"dependencies":{"type":"object","additionalProperties":{"anyOf":[{"$ref":"#"},{"$ref":"#/definitions/stringArray"}]}},"propertyNames":{"$ref":"#"},"const":true,"enum":{"type":"array","items":true,"minItems":1,"uniqueItems":true},"type":{"anyOf":[{"$ref":"#/definitions/simpleTypes"},{"type":"array","items":{"$ref":"#/definitions/simpleTypes"},"minItems":1,"uniqueItems":true}]},"format":{"type":"string"},"contentMediaType":{"type":"string"},"contentEncoding":{"type":"string"},"if":{"$ref":"#"},"then":{"$ref":"#"},"else":{"$ref":"#"},"allOf":{"$ref":"#/definitions/schemaArray"},"anyOf":{"$ref":"#/definitions/schemaArray"},"oneOf":{"$ref":"#/definitions/schemaArray"},"not":{"$ref":"#"}},"default":true}');
43443
43444 /***/ }),
43445 /* 491 */
43446 /***/ ((module) => {
43447
43448 "use strict";
43449 module.exports = JSON.parse('{"$schema":"http://json-schema.org/draft-07/schema#","$id":"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#","description":"Meta-schema for $data reference (JSON Schema extension proposal)","type":"object","required":["$data"],"properties":{"$data":{"type":"string","anyOf":[{"format":"relative-json-pointer"},{"format":"json-pointer"}]}},"additionalProperties":false}');
43450
43451 /***/ }),
43452 /* 492 */
43453 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
43454
43455 "use strict";
43456
43457
43458 module.exports = __webpack_require__(493);
43459
43460 /***/ }),
43461 /* 493 */
43462 /***/ ((module) => {
43463
43464 "use strict";
43465 module.exports = JSON.parse('{"builtin":{"AggregateError":false,"Array":false,"ArrayBuffer":false,"Atomics":false,"BigInt":false,"BigInt64Array":false,"BigUint64Array":false,"Boolean":false,"constructor":false,"DataView":false,"Date":false,"decodeURI":false,"decodeURIComponent":false,"encodeURI":false,"encodeURIComponent":false,"Error":false,"escape":false,"eval":false,"EvalError":false,"FinalizationRegistry":false,"Float32Array":false,"Float64Array":false,"Function":false,"globalThis":false,"hasOwnProperty":false,"Infinity":false,"Int16Array":false,"Int32Array":false,"Int8Array":false,"isFinite":false,"isNaN":false,"isPrototypeOf":false,"JSON":false,"Map":false,"Math":false,"NaN":false,"Number":false,"Object":false,"parseFloat":false,"parseInt":false,"Promise":false,"propertyIsEnumerable":false,"Proxy":false,"RangeError":false,"ReferenceError":false,"Reflect":false,"RegExp":false,"Set":false,"SharedArrayBuffer":false,"String":false,"Symbol":false,"SyntaxError":false,"toLocaleString":false,"toString":false,"TypeError":false,"Uint16Array":false,"Uint32Array":false,"Uint8Array":false,"Uint8ClampedArray":false,"undefined":false,"unescape":false,"URIError":false,"valueOf":false,"WeakMap":false,"WeakRef":false,"WeakSet":false},"es5":{"Array":false,"Boolean":false,"constructor":false,"Date":false,"decodeURI":false,"decodeURIComponent":false,"encodeURI":false,"encodeURIComponent":false,"Error":false,"escape":false,"eval":false,"EvalError":false,"Function":false,"hasOwnProperty":false,"Infinity":false,"isFinite":false,"isNaN":false,"isPrototypeOf":false,"JSON":false,"Math":false,"NaN":false,"Number":false,"Object":false,"parseFloat":false,"parseInt":false,"propertyIsEnumerable":false,"RangeError":false,"ReferenceError":false,"RegExp":false,"String":false,"SyntaxError":false,"toLocaleString":false,"toString":false,"TypeError":false,"undefined":false,"unescape":false,"URIError":false,"valueOf":false},"es2015":{"Array":false,"ArrayBuffer":false,"Boolean":false,"constructor":false,"DataView":false,"Date":false,"decodeURI":false,"decodeURIComponent":false,"encodeURI":false,"encodeURIComponent":false,"Error":false,"escape":false,"eval":false,"EvalError":false,"Float32Array":false,"Float64Array":false,"Function":false,"hasOwnProperty":false,"Infinity":false,"Int16Array":false,"Int32Array":false,"Int8Array":false,"isFinite":false,"isNaN":false,"isPrototypeOf":false,"JSON":false,"Map":false,"Math":false,"NaN":false,"Number":false,"Object":false,"parseFloat":false,"parseInt":false,"Promise":false,"propertyIsEnumerable":false,"Proxy":false,"RangeError":false,"ReferenceError":false,"Reflect":false,"RegExp":false,"Set":false,"String":false,"Symbol":false,"SyntaxError":false,"toLocaleString":false,"toString":false,"TypeError":false,"Uint16Array":false,"Uint32Array":false,"Uint8Array":false,"Uint8ClampedArray":false,"undefined":false,"unescape":false,"URIError":false,"valueOf":false,"WeakMap":false,"WeakSet":false},"es2017":{"Array":false,"ArrayBuffer":false,"Atomics":false,"Boolean":false,"constructor":false,"DataView":false,"Date":false,"decodeURI":false,"decodeURIComponent":false,"encodeURI":false,"encodeURIComponent":false,"Error":false,"escape":false,"eval":false,"EvalError":false,"Float32Array":false,"Float64Array":false,"Function":false,"hasOwnProperty":false,"Infinity":false,"Int16Array":false,"Int32Array":false,"Int8Array":false,"isFinite":false,"isNaN":false,"isPrototypeOf":false,"JSON":false,"Map":false,"Math":false,"NaN":false,"Number":false,"Object":false,"parseFloat":false,"parseInt":false,"Promise":false,"propertyIsEnumerable":false,"Proxy":false,"RangeError":false,"ReferenceError":false,"Reflect":false,"RegExp":false,"Set":false,"SharedArrayBuffer":false,"String":false,"Symbol":false,"SyntaxError":false,"toLocaleString":false,"toString":false,"TypeError":false,"Uint16Array":false,"Uint32Array":false,"Uint8Array":false,"Uint8ClampedArray":false,"undefined":false,"unescape":false,"URIError":false,"valueOf":false,"WeakMap":false,"WeakSet":false},"es2020":{"Array":false,"ArrayBuffer":false,"Atomics":false,"BigInt":false,"BigInt64Array":false,"BigUint64Array":false,"Boolean":false,"constructor":false,"DataView":false,"Date":false,"decodeURI":false,"decodeURIComponent":false,"encodeURI":false,"encodeURIComponent":false,"Error":false,"escape":false,"eval":false,"EvalError":false,"Float32Array":false,"Float64Array":false,"Function":false,"globalThis":false,"hasOwnProperty":false,"Infinity":false,"Int16Array":false,"Int32Array":false,"Int8Array":false,"isFinite":false,"isNaN":false,"isPrototypeOf":false,"JSON":false,"Map":false,"Math":false,"NaN":false,"Number":false,"Object":false,"parseFloat":false,"parseInt":false,"Promise":false,"propertyIsEnumerable":false,"Proxy":false,"RangeError":false,"ReferenceError":false,"Reflect":false,"RegExp":false,"Set":false,"SharedArrayBuffer":false,"String":false,"Symbol":false,"SyntaxError":false,"toLocaleString":false,"toString":false,"TypeError":false,"Uint16Array":false,"Uint32Array":false,"Uint8Array":false,"Uint8ClampedArray":false,"undefined":false,"unescape":false,"URIError":false,"valueOf":false,"WeakMap":false,"WeakSet":false},"es2021":{"AggregateError":false,"Array":false,"ArrayBuffer":false,"Atomics":false,"BigInt":false,"BigInt64Array":false,"BigUint64Array":false,"Boolean":false,"constructor":false,"DataView":false,"Date":false,"decodeURI":false,"decodeURIComponent":false,"encodeURI":false,"encodeURIComponent":false,"Error":false,"escape":false,"eval":false,"EvalError":false,"FinalizationRegistry":false,"Float32Array":false,"Float64Array":false,"Function":false,"globalThis":false,"hasOwnProperty":false,"Infinity":false,"Int16Array":false,"Int32Array":false,"Int8Array":false,"isFinite":false,"isNaN":false,"isPrototypeOf":false,"JSON":false,"Map":false,"Math":false,"NaN":false,"Number":false,"Object":false,"parseFloat":false,"parseInt":false,"Promise":false,"propertyIsEnumerable":false,"Proxy":false,"RangeError":false,"ReferenceError":false,"Reflect":false,"RegExp":false,"Set":false,"SharedArrayBuffer":false,"String":false,"Symbol":false,"SyntaxError":false,"toLocaleString":false,"toString":false,"TypeError":false,"Uint16Array":false,"Uint32Array":false,"Uint8Array":false,"Uint8ClampedArray":false,"undefined":false,"unescape":false,"URIError":false,"valueOf":false,"WeakMap":false,"WeakRef":false,"WeakSet":false},"browser":{"AbortController":false,"AbortSignal":false,"addEventListener":false,"alert":false,"AnalyserNode":false,"Animation":false,"AnimationEffectReadOnly":false,"AnimationEffectTiming":false,"AnimationEffectTimingReadOnly":false,"AnimationEvent":false,"AnimationPlaybackEvent":false,"AnimationTimeline":false,"applicationCache":false,"ApplicationCache":false,"ApplicationCacheErrorEvent":false,"atob":false,"Attr":false,"Audio":false,"AudioBuffer":false,"AudioBufferSourceNode":false,"AudioContext":false,"AudioDestinationNode":false,"AudioListener":false,"AudioNode":false,"AudioParam":false,"AudioProcessingEvent":false,"AudioScheduledSourceNode":false,"AudioWorkletGlobalScope ":false,"AudioWorkletNode":false,"AudioWorkletProcessor":false,"BarProp":false,"BaseAudioContext":false,"BatteryManager":false,"BeforeUnloadEvent":false,"BiquadFilterNode":false,"Blob":false,"BlobEvent":false,"blur":false,"BroadcastChannel":false,"btoa":false,"BudgetService":false,"ByteLengthQueuingStrategy":false,"Cache":false,"caches":false,"CacheStorage":false,"cancelAnimationFrame":false,"cancelIdleCallback":false,"CanvasCaptureMediaStreamTrack":false,"CanvasGradient":false,"CanvasPattern":false,"CanvasRenderingContext2D":false,"ChannelMergerNode":false,"ChannelSplitterNode":false,"CharacterData":false,"clearInterval":false,"clearTimeout":false,"clientInformation":false,"ClipboardEvent":false,"close":false,"closed":false,"CloseEvent":false,"Comment":false,"CompositionEvent":false,"confirm":false,"console":false,"ConstantSourceNode":false,"ConvolverNode":false,"CountQueuingStrategy":false,"createImageBitmap":false,"Credential":false,"CredentialsContainer":false,"crypto":false,"Crypto":false,"CryptoKey":false,"CSS":false,"CSSConditionRule":false,"CSSFontFaceRule":false,"CSSGroupingRule":false,"CSSImportRule":false,"CSSKeyframeRule":false,"CSSKeyframesRule":false,"CSSMatrixComponent":false,"CSSMediaRule":false,"CSSNamespaceRule":false,"CSSPageRule":false,"CSSPerspective":false,"CSSRotate":false,"CSSRule":false,"CSSRuleList":false,"CSSScale":false,"CSSSkew":false,"CSSSkewX":false,"CSSSkewY":false,"CSSStyleDeclaration":false,"CSSStyleRule":false,"CSSStyleSheet":false,"CSSSupportsRule":false,"CSSTransformValue":false,"CSSTranslate":false,"CustomElementRegistry":false,"customElements":false,"CustomEvent":false,"DataTransfer":false,"DataTransferItem":false,"DataTransferItemList":false,"defaultstatus":false,"defaultStatus":false,"DelayNode":false,"DeviceMotionEvent":false,"DeviceOrientationEvent":false,"devicePixelRatio":false,"dispatchEvent":false,"document":false,"Document":false,"DocumentFragment":false,"DocumentType":false,"DOMError":false,"DOMException":false,"DOMImplementation":false,"DOMMatrix":false,"DOMMatrixReadOnly":false,"DOMParser":false,"DOMPoint":false,"DOMPointReadOnly":false,"DOMQuad":false,"DOMRect":false,"DOMRectList":false,"DOMRectReadOnly":false,"DOMStringList":false,"DOMStringMap":false,"DOMTokenList":false,"DragEvent":false,"DynamicsCompressorNode":false,"Element":false,"ErrorEvent":false,"event":false,"Event":false,"EventSource":false,"EventTarget":false,"external":false,"fetch":false,"File":false,"FileList":false,"FileReader":false,"find":false,"focus":false,"FocusEvent":false,"FontFace":false,"FontFaceSetLoadEvent":false,"FormData":false,"frameElement":false,"frames":false,"GainNode":false,"Gamepad":false,"GamepadButton":false,"GamepadEvent":false,"getComputedStyle":false,"getSelection":false,"HashChangeEvent":false,"Headers":false,"history":false,"History":false,"HTMLAllCollection":false,"HTMLAnchorElement":false,"HTMLAreaElement":false,"HTMLAudioElement":false,"HTMLBaseElement":false,"HTMLBodyElement":false,"HTMLBRElement":false,"HTMLButtonElement":false,"HTMLCanvasElement":false,"HTMLCollection":false,"HTMLContentElement":false,"HTMLDataElement":false,"HTMLDataListElement":false,"HTMLDetailsElement":false,"HTMLDialogElement":false,"HTMLDirectoryElement":false,"HTMLDivElement":false,"HTMLDListElement":false,"HTMLDocument":false,"HTMLElement":false,"HTMLEmbedElement":false,"HTMLFieldSetElement":false,"HTMLFontElement":false,"HTMLFormControlsCollection":false,"HTMLFormElement":false,"HTMLFrameElement":false,"HTMLFrameSetElement":false,"HTMLHeadElement":false,"HTMLHeadingElement":false,"HTMLHRElement":false,"HTMLHtmlElement":false,"HTMLIFrameElement":false,"HTMLImageElement":false,"HTMLInputElement":false,"HTMLLabelElement":false,"HTMLLegendElement":false,"HTMLLIElement":false,"HTMLLinkElement":false,"HTMLMapElement":false,"HTMLMarqueeElement":false,"HTMLMediaElement":false,"HTMLMenuElement":false,"HTMLMetaElement":false,"HTMLMeterElement":false,"HTMLModElement":false,"HTMLObjectElement":false,"HTMLOListElement":false,"HTMLOptGroupElement":false,"HTMLOptionElement":false,"HTMLOptionsCollection":false,"HTMLOutputElement":false,"HTMLParagraphElement":false,"HTMLParamElement":false,"HTMLPictureElement":false,"HTMLPreElement":false,"HTMLProgressElement":false,"HTMLQuoteElement":false,"HTMLScriptElement":false,"HTMLSelectElement":false,"HTMLShadowElement":false,"HTMLSlotElement":false,"HTMLSourceElement":false,"HTMLSpanElement":false,"HTMLStyleElement":false,"HTMLTableCaptionElement":false,"HTMLTableCellElement":false,"HTMLTableColElement":false,"HTMLTableElement":false,"HTMLTableRowElement":false,"HTMLTableSectionElement":false,"HTMLTemplateElement":false,"HTMLTextAreaElement":false,"HTMLTimeElement":false,"HTMLTitleElement":false,"HTMLTrackElement":false,"HTMLUListElement":false,"HTMLUnknownElement":false,"HTMLVideoElement":false,"IDBCursor":false,"IDBCursorWithValue":false,"IDBDatabase":false,"IDBFactory":false,"IDBIndex":false,"IDBKeyRange":false,"IDBObjectStore":false,"IDBOpenDBRequest":false,"IDBRequest":false,"IDBTransaction":false,"IDBVersionChangeEvent":false,"IdleDeadline":false,"IIRFilterNode":false,"Image":false,"ImageBitmap":false,"ImageBitmapRenderingContext":false,"ImageCapture":false,"ImageData":false,"indexedDB":false,"innerHeight":false,"innerWidth":false,"InputEvent":false,"IntersectionObserver":false,"IntersectionObserverEntry":false,"Intl":false,"isSecureContext":false,"KeyboardEvent":false,"KeyframeEffect":false,"KeyframeEffectReadOnly":false,"length":false,"localStorage":false,"location":true,"Location":false,"locationbar":false,"matchMedia":false,"MediaDeviceInfo":false,"MediaDevices":false,"MediaElementAudioSourceNode":false,"MediaEncryptedEvent":false,"MediaError":false,"MediaKeyMessageEvent":false,"MediaKeySession":false,"MediaKeyStatusMap":false,"MediaKeySystemAccess":false,"MediaList":false,"MediaQueryList":false,"MediaQueryListEvent":false,"MediaRecorder":false,"MediaSettingsRange":false,"MediaSource":false,"MediaStream":false,"MediaStreamAudioDestinationNode":false,"MediaStreamAudioSourceNode":false,"MediaStreamEvent":false,"MediaStreamTrack":false,"MediaStreamTrackEvent":false,"menubar":false,"MessageChannel":false,"MessageEvent":false,"MessagePort":false,"MIDIAccess":false,"MIDIConnectionEvent":false,"MIDIInput":false,"MIDIInputMap":false,"MIDIMessageEvent":false,"MIDIOutput":false,"MIDIOutputMap":false,"MIDIPort":false,"MimeType":false,"MimeTypeArray":false,"MouseEvent":false,"moveBy":false,"moveTo":false,"MutationEvent":false,"MutationObserver":false,"MutationRecord":false,"name":false,"NamedNodeMap":false,"NavigationPreloadManager":false,"navigator":false,"Navigator":false,"NetworkInformation":false,"Node":false,"NodeFilter":false,"NodeIterator":false,"NodeList":false,"Notification":false,"OfflineAudioCompletionEvent":false,"OfflineAudioContext":false,"offscreenBuffering":false,"OffscreenCanvas":true,"OffscreenCanvasRenderingContext2D":false,"onabort":true,"onafterprint":true,"onanimationend":true,"onanimationiteration":true,"onanimationstart":true,"onappinstalled":true,"onauxclick":true,"onbeforeinstallprompt":true,"onbeforeprint":true,"onbeforeunload":true,"onblur":true,"oncancel":true,"oncanplay":true,"oncanplaythrough":true,"onchange":true,"onclick":true,"onclose":true,"oncontextmenu":true,"oncuechange":true,"ondblclick":true,"ondevicemotion":true,"ondeviceorientation":true,"ondeviceorientationabsolute":true,"ondrag":true,"ondragend":true,"ondragenter":true,"ondragleave":true,"ondragover":true,"ondragstart":true,"ondrop":true,"ondurationchange":true,"onemptied":true,"onended":true,"onerror":true,"onfocus":true,"ongotpointercapture":true,"onhashchange":true,"oninput":true,"oninvalid":true,"onkeydown":true,"onkeypress":true,"onkeyup":true,"onlanguagechange":true,"onload":true,"onloadeddata":true,"onloadedmetadata":true,"onloadstart":true,"onlostpointercapture":true,"onmessage":true,"onmessageerror":true,"onmousedown":true,"onmouseenter":true,"onmouseleave":true,"onmousemove":true,"onmouseout":true,"onmouseover":true,"onmouseup":true,"onmousewheel":true,"onoffline":true,"ononline":true,"onpagehide":true,"onpageshow":true,"onpause":true,"onplay":true,"onplaying":true,"onpointercancel":true,"onpointerdown":true,"onpointerenter":true,"onpointerleave":true,"onpointermove":true,"onpointerout":true,"onpointerover":true,"onpointerup":true,"onpopstate":true,"onprogress":true,"onratechange":true,"onrejectionhandled":true,"onreset":true,"onresize":true,"onscroll":true,"onsearch":true,"onseeked":true,"onseeking":true,"onselect":true,"onstalled":true,"onstorage":true,"onsubmit":true,"onsuspend":true,"ontimeupdate":true,"ontoggle":true,"ontransitionend":true,"onunhandledrejection":true,"onunload":true,"onvolumechange":true,"onwaiting":true,"onwheel":true,"open":false,"openDatabase":false,"opener":false,"Option":false,"origin":false,"OscillatorNode":false,"outerHeight":false,"outerWidth":false,"OverconstrainedError":false,"PageTransitionEvent":false,"pageXOffset":false,"pageYOffset":false,"PannerNode":false,"parent":false,"Path2D":false,"PaymentAddress":false,"PaymentRequest":false,"PaymentRequestUpdateEvent":false,"PaymentResponse":false,"performance":false,"Performance":false,"PerformanceEntry":false,"PerformanceLongTaskTiming":false,"PerformanceMark":false,"PerformanceMeasure":false,"PerformanceNavigation":false,"PerformanceNavigationTiming":false,"PerformanceObserver":false,"PerformanceObserverEntryList":false,"PerformancePaintTiming":false,"PerformanceResourceTiming":false,"PerformanceTiming":false,"PeriodicWave":false,"Permissions":false,"PermissionStatus":false,"personalbar":false,"PhotoCapabilities":false,"Plugin":false,"PluginArray":false,"PointerEvent":false,"PopStateEvent":false,"postMessage":false,"Presentation":false,"PresentationAvailability":false,"PresentationConnection":false,"PresentationConnectionAvailableEvent":false,"PresentationConnectionCloseEvent":false,"PresentationConnectionList":false,"PresentationReceiver":false,"PresentationRequest":false,"print":false,"ProcessingInstruction":false,"ProgressEvent":false,"PromiseRejectionEvent":false,"prompt":false,"PushManager":false,"PushSubscription":false,"PushSubscriptionOptions":false,"queueMicrotask":false,"RadioNodeList":false,"Range":false,"ReadableStream":false,"registerProcessor":false,"RemotePlayback":false,"removeEventListener":false,"Request":false,"requestAnimationFrame":false,"requestIdleCallback":false,"resizeBy":false,"ResizeObserver":false,"ResizeObserverEntry":false,"resizeTo":false,"Response":false,"RTCCertificate":false,"RTCDataChannel":false,"RTCDataChannelEvent":false,"RTCDtlsTransport":false,"RTCIceCandidate":false,"RTCIceGatherer":false,"RTCIceTransport":false,"RTCPeerConnection":false,"RTCPeerConnectionIceEvent":false,"RTCRtpContributingSource":false,"RTCRtpReceiver":false,"RTCRtpSender":false,"RTCSctpTransport":false,"RTCSessionDescription":false,"RTCStatsReport":false,"RTCTrackEvent":false,"screen":false,"Screen":false,"screenLeft":false,"ScreenOrientation":false,"screenTop":false,"screenX":false,"screenY":false,"ScriptProcessorNode":false,"scroll":false,"scrollbars":false,"scrollBy":false,"scrollTo":false,"scrollX":false,"scrollY":false,"SecurityPolicyViolationEvent":false,"Selection":false,"self":false,"ServiceWorker":false,"ServiceWorkerContainer":false,"ServiceWorkerRegistration":false,"sessionStorage":false,"setInterval":false,"setTimeout":false,"ShadowRoot":false,"SharedWorker":false,"SourceBuffer":false,"SourceBufferList":false,"speechSynthesis":false,"SpeechSynthesisEvent":false,"SpeechSynthesisUtterance":false,"StaticRange":false,"status":false,"statusbar":false,"StereoPannerNode":false,"stop":false,"Storage":false,"StorageEvent":false,"StorageManager":false,"styleMedia":false,"StyleSheet":false,"StyleSheetList":false,"SubtleCrypto":false,"SVGAElement":false,"SVGAngle":false,"SVGAnimatedAngle":false,"SVGAnimatedBoolean":false,"SVGAnimatedEnumeration":false,"SVGAnimatedInteger":false,"SVGAnimatedLength":false,"SVGAnimatedLengthList":false,"SVGAnimatedNumber":false,"SVGAnimatedNumberList":false,"SVGAnimatedPreserveAspectRatio":false,"SVGAnimatedRect":false,"SVGAnimatedString":false,"SVGAnimatedTransformList":false,"SVGAnimateElement":false,"SVGAnimateMotionElement":false,"SVGAnimateTransformElement":false,"SVGAnimationElement":false,"SVGCircleElement":false,"SVGClipPathElement":false,"SVGComponentTransferFunctionElement":false,"SVGDefsElement":false,"SVGDescElement":false,"SVGDiscardElement":false,"SVGElement":false,"SVGEllipseElement":false,"SVGFEBlendElement":false,"SVGFEColorMatrixElement":false,"SVGFEComponentTransferElement":false,"SVGFECompositeElement":false,"SVGFEConvolveMatrixElement":false,"SVGFEDiffuseLightingElement":false,"SVGFEDisplacementMapElement":false,"SVGFEDistantLightElement":false,"SVGFEDropShadowElement":false,"SVGFEFloodElement":false,"SVGFEFuncAElement":false,"SVGFEFuncBElement":false,"SVGFEFuncGElement":false,"SVGFEFuncRElement":false,"SVGFEGaussianBlurElement":false,"SVGFEImageElement":false,"SVGFEMergeElement":false,"SVGFEMergeNodeElement":false,"SVGFEMorphologyElement":false,"SVGFEOffsetElement":false,"SVGFEPointLightElement":false,"SVGFESpecularLightingElement":false,"SVGFESpotLightElement":false,"SVGFETileElement":false,"SVGFETurbulenceElement":false,"SVGFilterElement":false,"SVGForeignObjectElement":false,"SVGGElement":false,"SVGGeometryElement":false,"SVGGradientElement":false,"SVGGraphicsElement":false,"SVGImageElement":false,"SVGLength":false,"SVGLengthList":false,"SVGLinearGradientElement":false,"SVGLineElement":false,"SVGMarkerElement":false,"SVGMaskElement":false,"SVGMatrix":false,"SVGMetadataElement":false,"SVGMPathElement":false,"SVGNumber":false,"SVGNumberList":false,"SVGPathElement":false,"SVGPatternElement":false,"SVGPoint":false,"SVGPointList":false,"SVGPolygonElement":false,"SVGPolylineElement":false,"SVGPreserveAspectRatio":false,"SVGRadialGradientElement":false,"SVGRect":false,"SVGRectElement":false,"SVGScriptElement":false,"SVGSetElement":false,"SVGStopElement":false,"SVGStringList":false,"SVGStyleElement":false,"SVGSVGElement":false,"SVGSwitchElement":false,"SVGSymbolElement":false,"SVGTextContentElement":false,"SVGTextElement":false,"SVGTextPathElement":false,"SVGTextPositioningElement":false,"SVGTitleElement":false,"SVGTransform":false,"SVGTransformList":false,"SVGTSpanElement":false,"SVGUnitTypes":false,"SVGUseElement":false,"SVGViewElement":false,"TaskAttributionTiming":false,"Text":false,"TextDecoder":false,"TextEncoder":false,"TextEvent":false,"TextMetrics":false,"TextTrack":false,"TextTrackCue":false,"TextTrackCueList":false,"TextTrackList":false,"TimeRanges":false,"toolbar":false,"top":false,"Touch":false,"TouchEvent":false,"TouchList":false,"TrackEvent":false,"TransitionEvent":false,"TreeWalker":false,"UIEvent":false,"URL":false,"URLSearchParams":false,"ValidityState":false,"visualViewport":false,"VisualViewport":false,"VTTCue":false,"WaveShaperNode":false,"WebAssembly":false,"WebGL2RenderingContext":false,"WebGLActiveInfo":false,"WebGLBuffer":false,"WebGLContextEvent":false,"WebGLFramebuffer":false,"WebGLProgram":false,"WebGLQuery":false,"WebGLRenderbuffer":false,"WebGLRenderingContext":false,"WebGLSampler":false,"WebGLShader":false,"WebGLShaderPrecisionFormat":false,"WebGLSync":false,"WebGLTexture":false,"WebGLTransformFeedback":false,"WebGLUniformLocation":false,"WebGLVertexArrayObject":false,"WebSocket":false,"WheelEvent":false,"window":false,"Window":false,"Worker":false,"WritableStream":false,"XMLDocument":false,"XMLHttpRequest":false,"XMLHttpRequestEventTarget":false,"XMLHttpRequestUpload":false,"XMLSerializer":false,"XPathEvaluator":false,"XPathExpression":false,"XPathResult":false,"XSLTProcessor":false},"worker":{"addEventListener":false,"applicationCache":false,"atob":false,"Blob":false,"BroadcastChannel":false,"btoa":false,"Cache":false,"caches":false,"clearInterval":false,"clearTimeout":false,"close":true,"console":false,"fetch":false,"FileReaderSync":false,"FormData":false,"Headers":false,"IDBCursor":false,"IDBCursorWithValue":false,"IDBDatabase":false,"IDBFactory":false,"IDBIndex":false,"IDBKeyRange":false,"IDBObjectStore":false,"IDBOpenDBRequest":false,"IDBRequest":false,"IDBTransaction":false,"IDBVersionChangeEvent":false,"ImageData":false,"importScripts":true,"indexedDB":false,"location":false,"MessageChannel":false,"MessagePort":false,"name":false,"navigator":false,"Notification":false,"onclose":true,"onconnect":true,"onerror":true,"onlanguagechange":true,"onmessage":true,"onoffline":true,"ononline":true,"onrejectionhandled":true,"onunhandledrejection":true,"performance":false,"Performance":false,"PerformanceEntry":false,"PerformanceMark":false,"PerformanceMeasure":false,"PerformanceNavigation":false,"PerformanceResourceTiming":false,"PerformanceTiming":false,"postMessage":true,"Promise":false,"queueMicrotask":false,"removeEventListener":false,"Request":false,"Response":false,"self":true,"ServiceWorkerRegistration":false,"setInterval":false,"setTimeout":false,"TextDecoder":false,"TextEncoder":false,"URL":false,"URLSearchParams":false,"WebSocket":false,"Worker":false,"WorkerGlobalScope":false,"XMLHttpRequest":false},"node":{"__dirname":false,"__filename":false,"AbortController":false,"AbortSignal":false,"atob":false,"btoa":false,"Buffer":false,"clearImmediate":false,"clearInterval":false,"clearTimeout":false,"console":false,"DOMException":false,"Event":false,"EventTarget":false,"exports":true,"global":false,"Intl":false,"MessageChannel":false,"MessageEvent":false,"MessagePort":false,"module":false,"performance":false,"process":false,"queueMicrotask":false,"require":false,"setImmediate":false,"setInterval":false,"setTimeout":false,"structuredClone":false,"TextDecoder":false,"TextEncoder":false,"URL":false,"URLSearchParams":false},"nodeBuiltin":{"AbortController":false,"AbortSignal":false,"atob":false,"btoa":false,"Buffer":false,"clearImmediate":false,"clearInterval":false,"clearTimeout":false,"console":false,"DOMException":false,"Event":false,"EventTarget":false,"global":false,"Intl":false,"MessageChannel":false,"MessageEvent":false,"MessagePort":false,"performance":false,"process":false,"queueMicrotask":false,"setImmediate":false,"setInterval":false,"setTimeout":false,"structuredClone":false,"TextDecoder":false,"TextEncoder":false,"URL":false,"URLSearchParams":false},"commonjs":{"exports":true,"global":false,"module":false,"require":false},"amd":{"define":false,"require":false},"mocha":{"after":false,"afterEach":false,"before":false,"beforeEach":false,"context":false,"describe":false,"it":false,"mocha":false,"run":false,"setup":false,"specify":false,"suite":false,"suiteSetup":false,"suiteTeardown":false,"teardown":false,"test":false,"xcontext":false,"xdescribe":false,"xit":false,"xspecify":false},"jasmine":{"afterAll":false,"afterEach":false,"beforeAll":false,"beforeEach":false,"describe":false,"expect":false,"expectAsync":false,"fail":false,"fdescribe":false,"fit":false,"it":false,"jasmine":false,"pending":false,"runs":false,"spyOn":false,"spyOnAllFunctions":false,"spyOnProperty":false,"waits":false,"waitsFor":false,"xdescribe":false,"xit":false},"jest":{"afterAll":false,"afterEach":false,"beforeAll":false,"beforeEach":false,"describe":false,"expect":false,"fdescribe":false,"fit":false,"it":false,"jest":false,"pit":false,"require":false,"test":false,"xdescribe":false,"xit":false,"xtest":false},"qunit":{"asyncTest":false,"deepEqual":false,"equal":false,"expect":false,"module":false,"notDeepEqual":false,"notEqual":false,"notOk":false,"notPropEqual":false,"notStrictEqual":false,"ok":false,"propEqual":false,"QUnit":false,"raises":false,"start":false,"stop":false,"strictEqual":false,"test":false,"throws":false},"phantomjs":{"console":true,"exports":true,"phantom":true,"require":true,"WebPage":true},"couch":{"emit":false,"exports":false,"getRow":false,"log":false,"module":false,"provides":false,"require":false,"respond":false,"send":false,"start":false,"sum":false},"rhino":{"defineClass":false,"deserialize":false,"gc":false,"help":false,"importClass":false,"importPackage":false,"java":false,"load":false,"loadClass":false,"Packages":false,"print":false,"quit":false,"readFile":false,"readUrl":false,"runCommand":false,"seal":false,"serialize":false,"spawn":false,"sync":false,"toint32":false,"version":false},"nashorn":{"__DIR__":false,"__FILE__":false,"__LINE__":false,"com":false,"edu":false,"exit":false,"java":false,"Java":false,"javafx":false,"JavaImporter":false,"javax":false,"JSAdapter":false,"load":false,"loadWithNewGlobal":false,"org":false,"Packages":false,"print":false,"quit":false},"wsh":{"ActiveXObject":false,"CollectGarbage":false,"Debug":false,"Enumerator":false,"GetObject":false,"RuntimeObject":false,"ScriptEngine":false,"ScriptEngineBuildVersion":false,"ScriptEngineMajorVersion":false,"ScriptEngineMinorVersion":false,"VBArray":false,"WScript":false,"WSH":false},"jquery":{"$":false,"jQuery":false},"yui":{"YAHOO":false,"YAHOO_config":false,"YUI":false,"YUI_config":false},"shelljs":{"cat":false,"cd":false,"chmod":false,"config":false,"cp":false,"dirs":false,"echo":false,"env":false,"error":false,"exec":false,"exit":false,"find":false,"grep":false,"ln":false,"ls":false,"mkdir":false,"mv":false,"popd":false,"pushd":false,"pwd":false,"rm":false,"sed":false,"set":false,"target":false,"tempdir":false,"test":false,"touch":false,"which":false},"prototypejs":{"$":false,"$$":false,"$A":false,"$break":false,"$continue":false,"$F":false,"$H":false,"$R":false,"$w":false,"Abstract":false,"Ajax":false,"Autocompleter":false,"Builder":false,"Class":false,"Control":false,"Draggable":false,"Draggables":false,"Droppables":false,"Effect":false,"Element":false,"Enumerable":false,"Event":false,"Field":false,"Form":false,"Hash":false,"Insertion":false,"ObjectRange":false,"PeriodicalExecuter":false,"Position":false,"Prototype":false,"Scriptaculous":false,"Selector":false,"Sortable":false,"SortableObserver":false,"Sound":false,"Template":false,"Toggle":false,"Try":false},"meteor":{"$":false,"Accounts":false,"AccountsClient":false,"AccountsCommon":false,"AccountsServer":false,"App":false,"Assets":false,"Blaze":false,"check":false,"Cordova":false,"DDP":false,"DDPRateLimiter":false,"DDPServer":false,"Deps":false,"EJSON":false,"Email":false,"HTTP":false,"Log":false,"Match":false,"Meteor":false,"Mongo":false,"MongoInternals":false,"Npm":false,"Package":false,"Plugin":false,"process":false,"Random":false,"ReactiveDict":false,"ReactiveVar":false,"Router":false,"ServiceConfiguration":false,"Session":false,"share":false,"Spacebars":false,"Template":false,"Tinytest":false,"Tracker":false,"UI":false,"Utils":false,"WebApp":false,"WebAppInternals":false},"mongo":{"_isWindows":false,"_rand":false,"BulkWriteResult":false,"cat":false,"cd":false,"connect":false,"db":false,"getHostName":false,"getMemInfo":false,"hostname":false,"ISODate":false,"listFiles":false,"load":false,"ls":false,"md5sumFile":false,"mkdir":false,"Mongo":false,"NumberInt":false,"NumberLong":false,"ObjectId":false,"PlanCache":false,"print":false,"printjson":false,"pwd":false,"quit":false,"removeFile":false,"rs":false,"sh":false,"UUID":false,"version":false,"WriteResult":false},"applescript":{"$":false,"Application":false,"Automation":false,"console":false,"delay":false,"Library":false,"ObjC":false,"ObjectSpecifier":false,"Path":false,"Progress":false,"Ref":false},"serviceworker":{"addEventListener":false,"applicationCache":false,"atob":false,"Blob":false,"BroadcastChannel":false,"btoa":false,"Cache":false,"caches":false,"CacheStorage":false,"clearInterval":false,"clearTimeout":false,"Client":false,"clients":false,"Clients":false,"close":true,"console":false,"ExtendableEvent":false,"ExtendableMessageEvent":false,"fetch":false,"FetchEvent":false,"FileReaderSync":false,"FormData":false,"Headers":false,"IDBCursor":false,"IDBCursorWithValue":false,"IDBDatabase":false,"IDBFactory":false,"IDBIndex":false,"IDBKeyRange":false,"IDBObjectStore":false,"IDBOpenDBRequest":false,"IDBRequest":false,"IDBTransaction":false,"IDBVersionChangeEvent":false,"ImageData":false,"importScripts":false,"indexedDB":false,"location":false,"MessageChannel":false,"MessagePort":false,"name":false,"navigator":false,"Notification":false,"onclose":true,"onconnect":true,"onerror":true,"onfetch":true,"oninstall":true,"onlanguagechange":true,"onmessage":true,"onmessageerror":true,"onnotificationclick":true,"onnotificationclose":true,"onoffline":true,"ononline":true,"onpush":true,"onpushsubscriptionchange":true,"onrejectionhandled":true,"onsync":true,"onunhandledrejection":true,"performance":false,"Performance":false,"PerformanceEntry":false,"PerformanceMark":false,"PerformanceMeasure":false,"PerformanceNavigation":false,"PerformanceResourceTiming":false,"PerformanceTiming":false,"postMessage":true,"Promise":false,"queueMicrotask":false,"registration":false,"removeEventListener":false,"Request":false,"Response":false,"self":false,"ServiceWorker":false,"ServiceWorkerContainer":false,"ServiceWorkerGlobalScope":false,"ServiceWorkerMessageEvent":false,"ServiceWorkerRegistration":false,"setInterval":false,"setTimeout":false,"skipWaiting":false,"TextDecoder":false,"TextEncoder":false,"URL":false,"URLSearchParams":false,"WebSocket":false,"WindowClient":false,"Worker":false,"WorkerGlobalScope":false,"XMLHttpRequest":false},"atomtest":{"advanceClock":false,"atom":false,"fakeClearInterval":false,"fakeClearTimeout":false,"fakeSetInterval":false,"fakeSetTimeout":false,"resetTimeouts":false,"waitsForPromise":false},"embertest":{"andThen":false,"click":false,"currentPath":false,"currentRouteName":false,"currentURL":false,"fillIn":false,"find":false,"findAll":false,"findWithAssert":false,"keyEvent":false,"pauseTest":false,"resumeTest":false,"triggerEvent":false,"visit":false,"wait":false},"protractor":{"$":false,"$$":false,"browser":false,"by":false,"By":false,"DartObject":false,"element":false,"protractor":false},"shared-node-browser":{"AbortController":false,"AbortSignal":false,"atob":false,"btoa":false,"clearInterval":false,"clearTimeout":false,"console":false,"DOMException":false,"Event":false,"EventTarget":false,"Intl":false,"MessageChannel":false,"MessageEvent":false,"MessagePort":false,"performance":false,"queueMicrotask":false,"setInterval":false,"setTimeout":false,"TextDecoder":false,"TextEncoder":false,"URL":false,"URLSearchParams":false},"webextensions":{"browser":false,"chrome":false,"opr":false},"greasemonkey":{"cloneInto":false,"createObjectIn":false,"exportFunction":false,"GM":false,"GM_addElement":false,"GM_addStyle":false,"GM_addValueChangeListener":false,"GM_deleteValue":false,"GM_download":false,"GM_getResourceText":false,"GM_getResourceURL":false,"GM_getTab":false,"GM_getTabs":false,"GM_getValue":false,"GM_info":false,"GM_listValues":false,"GM_log":false,"GM_notification":false,"GM_openInTab":false,"GM_registerMenuCommand":false,"GM_removeValueChangeListener":false,"GM_saveTab":false,"GM_setClipboard":false,"GM_setValue":false,"GM_unregisterMenuCommand":false,"GM_xmlhttpRequest":false,"unsafeWindow":false},"devtools":{"$":false,"$_":false,"$$":false,"$0":false,"$1":false,"$2":false,"$3":false,"$4":false,"$x":false,"chrome":false,"clear":false,"copy":false,"debug":false,"dir":false,"dirxml":false,"getEventListeners":false,"inspect":false,"keys":false,"monitor":false,"monitorEvents":false,"profile":false,"profileEnd":false,"queryObjects":false,"table":false,"undebug":false,"unmonitor":false,"unmonitorEvents":false,"values":false}}');
43466
43467 /***/ }),
43468 /* 494 */
43469 /***/ ((module) => {
43470
43471 // shim for using process in browser
43472 var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it
43473 // don't break things. But we need to wrap it in a try catch in case it is
43474 // wrapped in strict mode code which doesn't define any globals. It's inside a
43475 // function because try/catches deoptimize in certain engines.
43476
43477 var cachedSetTimeout;
43478 var cachedClearTimeout;
43479
43480 function defaultSetTimout() {
43481 throw new Error('setTimeout has not been defined');
43482 }
43483
43484 function defaultClearTimeout() {
43485 throw new Error('clearTimeout has not been defined');
43486 }
43487
43488 (function () {
43489 try {
43490 if (typeof setTimeout === 'function') {
43491 cachedSetTimeout = setTimeout;
43492 } else {
43493 cachedSetTimeout = defaultSetTimout;
43494 }
43495 } catch (e) {
43496 cachedSetTimeout = defaultSetTimout;
43497 }
43498
43499 try {
43500 if (typeof clearTimeout === 'function') {
43501 cachedClearTimeout = clearTimeout;
43502 } else {
43503 cachedClearTimeout = defaultClearTimeout;
43504 }
43505 } catch (e) {
43506 cachedClearTimeout = defaultClearTimeout;
43507 }
43508 })();
43509
43510 function runTimeout(fun) {
43511 if (cachedSetTimeout === setTimeout) {
43512 //normal enviroments in sane situations
43513 return setTimeout(fun, 0);
43514 } // if setTimeout wasn't available but was latter defined
43515
43516
43517 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
43518 cachedSetTimeout = setTimeout;
43519 return setTimeout(fun, 0);
43520 }
43521
43522 try {
43523 // when when somebody has screwed with setTimeout but no I.E. maddness
43524 return cachedSetTimeout(fun, 0);
43525 } catch (e) {
43526 try {
43527 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
43528 return cachedSetTimeout.call(null, fun, 0);
43529 } catch (e) {
43530 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
43531 return cachedSetTimeout.call(this, fun, 0);
43532 }
43533 }
43534 }
43535
43536 function runClearTimeout(marker) {
43537 if (cachedClearTimeout === clearTimeout) {
43538 //normal enviroments in sane situations
43539 return clearTimeout(marker);
43540 } // if clearTimeout wasn't available but was latter defined
43541
43542
43543 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
43544 cachedClearTimeout = clearTimeout;
43545 return clearTimeout(marker);
43546 }
43547
43548 try {
43549 // when when somebody has screwed with setTimeout but no I.E. maddness
43550 return cachedClearTimeout(marker);
43551 } catch (e) {
43552 try {
43553 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
43554 return cachedClearTimeout.call(null, marker);
43555 } catch (e) {
43556 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
43557 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
43558 return cachedClearTimeout.call(this, marker);
43559 }
43560 }
43561 }
43562
43563 var queue = [];
43564 var draining = false;
43565 var currentQueue;
43566 var queueIndex = -1;
43567
43568 function cleanUpNextTick() {
43569 if (!draining || !currentQueue) {
43570 return;
43571 }
43572
43573 draining = false;
43574
43575 if (currentQueue.length) {
43576 queue = currentQueue.concat(queue);
43577 } else {
43578 queueIndex = -1;
43579 }
43580
43581 if (queue.length) {
43582 drainQueue();
43583 }
43584 }
43585
43586 function drainQueue() {
43587 if (draining) {
43588 return;
43589 }
43590
43591 var timeout = runTimeout(cleanUpNextTick);
43592 draining = true;
43593 var len = queue.length;
43594
43595 while (len) {
43596 currentQueue = queue;
43597 queue = [];
43598
43599 while (++queueIndex < len) {
43600 if (currentQueue) {
43601 currentQueue[queueIndex].run();
43602 }
43603 }
43604
43605 queueIndex = -1;
43606 len = queue.length;
43607 }
43608
43609 currentQueue = null;
43610 draining = false;
43611 runClearTimeout(timeout);
43612 }
43613
43614 process.nextTick = function (fun) {
43615 var args = new Array(arguments.length - 1);
43616
43617 if (arguments.length > 1) {
43618 for (var i = 1; i < arguments.length; i++) {
43619 args[i - 1] = arguments[i];
43620 }
43621 }
43622
43623 queue.push(new Item(fun, args));
43624
43625 if (queue.length === 1 && !draining) {
43626 runTimeout(drainQueue);
43627 }
43628 }; // v8 likes predictible objects
43629
43630
43631 function Item(fun, array) {
43632 this.fun = fun;
43633 this.array = array;
43634 }
43635
43636 Item.prototype.run = function () {
43637 this.fun.apply(null, this.array);
43638 };
43639
43640 process.title = 'browser';
43641 process.browser = true;
43642 process.env = {};
43643 process.argv = [];
43644 process.version = ''; // empty string to avoid regexp issues
43645
43646 process.versions = {};
43647
43648 function noop() {}
43649
43650 process.on = noop;
43651 process.addListener = noop;
43652 process.once = noop;
43653 process.off = noop;
43654 process.removeListener = noop;
43655 process.removeAllListeners = noop;
43656 process.emit = noop;
43657 process.prependListener = noop;
43658 process.prependOnceListener = noop;
43659
43660 process.listeners = function (name) {
43661 return [];
43662 };
43663
43664 process.binding = function (name) {
43665 throw new Error('process.binding is not supported');
43666 };
43667
43668 process.cwd = function () {
43669 return '/';
43670 };
43671
43672 process.chdir = function (dir) {
43673 throw new Error('process.chdir is not supported');
43674 };
43675
43676 process.umask = function () {
43677 return 0;
43678 };
43679
43680 /***/ }),
43681 /* 495 */
43682 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
43683
43684 "use strict";
43685 /**
43686 * @fileoverview Traverser to traverse AST trees.
43687 * @author Nicholas C. Zakas
43688 * @author Toru Nagashima
43689 */
43690 //------------------------------------------------------------------------------
43691 // Requirements
43692 //------------------------------------------------------------------------------
43693
43694 const vk = __webpack_require__(435);
43695
43696 const debug = __webpack_require__(496)("eslint:traverser"); //------------------------------------------------------------------------------
43697 // Helpers
43698 //------------------------------------------------------------------------------
43699
43700 /**
43701 * Do nothing.
43702 * @returns {void}
43703 */
43704
43705
43706 function noop() {// do nothing.
43707 }
43708 /**
43709 * Check whether the given value is an ASTNode or not.
43710 * @param {any} x The value to check.
43711 * @returns {boolean} `true` if the value is an ASTNode.
43712 */
43713
43714
43715 function isNode(x) {
43716 return x !== null && typeof x === "object" && typeof x.type === "string";
43717 }
43718 /**
43719 * Get the visitor keys of a given node.
43720 * @param {Object} visitorKeys The map of visitor keys.
43721 * @param {ASTNode} node The node to get their visitor keys.
43722 * @returns {string[]} The visitor keys of the node.
43723 */
43724
43725
43726 function getVisitorKeys(visitorKeys, node) {
43727 let keys = visitorKeys[node.type];
43728
43729 if (!keys) {
43730 keys = vk.getKeys(node);
43731 debug("Unknown node type \"%s\": Estimated visitor keys %j", node.type, keys);
43732 }
43733
43734 return keys;
43735 }
43736 /**
43737 * The traverser class to traverse AST trees.
43738 */
43739
43740
43741 class Traverser {
43742 constructor() {
43743 this._current = null;
43744 this._parents = [];
43745 this._skipped = false;
43746 this._broken = false;
43747 this._visitorKeys = null;
43748 this._enter = null;
43749 this._leave = null;
43750 }
43751 /**
43752 * Gives current node.
43753 * @returns {ASTNode} The current node.
43754 */
43755
43756
43757 current() {
43758 return this._current;
43759 }
43760 /**
43761 * Gives a a copy of the ancestor nodes.
43762 * @returns {ASTNode[]} The ancestor nodes.
43763 */
43764
43765
43766 parents() {
43767 return this._parents.slice(0);
43768 }
43769 /**
43770 * Break the current traversal.
43771 * @returns {void}
43772 */
43773
43774
43775 break() {
43776 this._broken = true;
43777 }
43778 /**
43779 * Skip child nodes for the current traversal.
43780 * @returns {void}
43781 */
43782
43783
43784 skip() {
43785 this._skipped = true;
43786 }
43787 /**
43788 * Traverse the given AST tree.
43789 * @param {ASTNode} node The root node to traverse.
43790 * @param {Object} options The option object.
43791 * @param {Object} [options.visitorKeys=DEFAULT_VISITOR_KEYS] The keys of each node types to traverse child nodes. Default is `./default-visitor-keys.json`.
43792 * @param {Function} [options.enter=noop] The callback function which is called on entering each node.
43793 * @param {Function} [options.leave=noop] The callback function which is called on leaving each node.
43794 * @returns {void}
43795 */
43796
43797
43798 traverse(node, options) {
43799 this._current = null;
43800 this._parents = [];
43801 this._skipped = false;
43802 this._broken = false;
43803 this._visitorKeys = options.visitorKeys || vk.KEYS;
43804 this._enter = options.enter || noop;
43805 this._leave = options.leave || noop;
43806
43807 this._traverse(node, null);
43808 }
43809 /**
43810 * Traverse the given AST tree recursively.
43811 * @param {ASTNode} node The current node.
43812 * @param {ASTNode|null} parent The parent node.
43813 * @returns {void}
43814 * @private
43815 */
43816
43817
43818 _traverse(node, parent) {
43819 if (!isNode(node)) {
43820 return;
43821 }
43822
43823 this._current = node;
43824 this._skipped = false;
43825
43826 this._enter(node, parent);
43827
43828 if (!this._skipped && !this._broken) {
43829 const keys = getVisitorKeys(this._visitorKeys, node);
43830
43831 if (keys.length >= 1) {
43832 this._parents.push(node);
43833
43834 for (let i = 0; i < keys.length && !this._broken; ++i) {
43835 const child = node[keys[i]];
43836
43837 if (Array.isArray(child)) {
43838 for (let j = 0; j < child.length && !this._broken; ++j) {
43839 this._traverse(child[j], node);
43840 }
43841 } else {
43842 this._traverse(child, node);
43843 }
43844 }
43845
43846 this._parents.pop();
43847 }
43848 }
43849
43850 if (!this._broken) {
43851 this._leave(node, parent);
43852 }
43853
43854 this._current = parent;
43855 }
43856 /**
43857 * Calculates the keys to use for traversal.
43858 * @param {ASTNode} node The node to read keys from.
43859 * @returns {string[]} An array of keys to visit on the node.
43860 * @private
43861 */
43862
43863
43864 static getKeys(node) {
43865 return vk.getKeys(node);
43866 }
43867 /**
43868 * Traverse the given AST tree.
43869 * @param {ASTNode} node The root node to traverse.
43870 * @param {Object} options The option object.
43871 * @param {Object} [options.visitorKeys=DEFAULT_VISITOR_KEYS] The keys of each node types to traverse child nodes. Default is `./default-visitor-keys.json`.
43872 * @param {Function} [options.enter=noop] The callback function which is called on entering each node.
43873 * @param {Function} [options.leave=noop] The callback function which is called on leaving each node.
43874 * @returns {void}
43875 */
43876
43877
43878 static traverse(node, options) {
43879 new Traverser().traverse(node, options);
43880 }
43881 /**
43882 * The default visitor keys.
43883 * @type {Object}
43884 */
43885
43886
43887 static get DEFAULT_VISITOR_KEYS() {
43888 return vk.KEYS;
43889 }
43890
43891 }
43892
43893 module.exports = Traverser;
43894
43895 /***/ }),
43896 /* 496 */
43897 /***/ ((module, exports, __webpack_require__) => {
43898
43899 /* provided dependency */ var console = __webpack_require__(438);
43900 /* provided dependency */ var process = __webpack_require__(494);
43901 /* eslint-env browser */
43902
43903 /**
43904 * This is the web browser implementation of `debug()`.
43905 */
43906 exports.formatArgs = formatArgs;
43907 exports.save = save;
43908 exports.load = load;
43909 exports.useColors = useColors;
43910 exports.storage = localstorage();
43911
43912 exports.destroy = (() => {
43913 let warned = false;
43914 return () => {
43915 if (!warned) {
43916 warned = true;
43917 console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
43918 }
43919 };
43920 })();
43921 /**
43922 * Colors.
43923 */
43924
43925
43926 exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
43927 /**
43928 * Currently only WebKit-based Web Inspectors, Firefox >= v31,
43929 * and the Firebug extension (any Firefox version) are known
43930 * to support "%c" CSS customizations.
43931 *
43932 * TODO: add a `localStorage` variable to explicitly enable/disable colors
43933 */
43934 // eslint-disable-next-line complexity
43935
43936 function useColors() {
43937 // NB: In an Electron preload script, document will be defined but not fully
43938 // initialized. Since we know we're in Chrome, we'll just detect this case
43939 // explicitly
43940 if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
43941 return true;
43942 } // Internet Explorer and Edge do not support colors.
43943
43944
43945 if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
43946 return false;
43947 } // Is webkit? http://stackoverflow.com/a/16459606/376773
43948 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
43949
43950
43951 return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
43952 typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
43953 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
43954 typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
43955 typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
43956 }
43957 /**
43958 * Colorize log arguments if enabled.
43959 *
43960 * @api public
43961 */
43962
43963
43964 function formatArgs(args) {
43965 args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
43966
43967 if (!this.useColors) {
43968 return;
43969 }
43970
43971 const c = 'color: ' + this.color;
43972 args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
43973 // arguments passed either before or after the %c, so we need to
43974 // figure out the correct index to insert the CSS into
43975
43976 let index = 0;
43977 let lastC = 0;
43978 args[0].replace(/%[a-zA-Z%]/g, match => {
43979 if (match === '%%') {
43980 return;
43981 }
43982
43983 index++;
43984
43985 if (match === '%c') {
43986 // We only are interested in the *last* %c
43987 // (the user may have provided their own)
43988 lastC = index;
43989 }
43990 });
43991 args.splice(lastC, 0, c);
43992 }
43993 /**
43994 * Invokes `console.debug()` when available.
43995 * No-op when `console.debug` is not a "function".
43996 * If `console.debug` is not available, falls back
43997 * to `console.log`.
43998 *
43999 * @api public
44000 */
44001
44002
44003 exports.log = console.debug || console.log || (() => {});
44004 /**
44005 * Save `namespaces`.
44006 *
44007 * @param {String} namespaces
44008 * @api private
44009 */
44010
44011
44012 function save(namespaces) {
44013 try {
44014 if (namespaces) {
44015 exports.storage.setItem('debug', namespaces);
44016 } else {
44017 exports.storage.removeItem('debug');
44018 }
44019 } catch (error) {// Swallow
44020 // XXX (@Qix-) should we be logging these?
44021 }
44022 }
44023 /**
44024 * Load `namespaces`.
44025 *
44026 * @return {String} returns the previously persisted debug modes
44027 * @api private
44028 */
44029
44030
44031 function load() {
44032 let r;
44033
44034 try {
44035 r = exports.storage.getItem('debug');
44036 } catch (error) {// Swallow
44037 // XXX (@Qix-) should we be logging these?
44038 } // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
44039
44040
44041 if (!r && typeof process !== 'undefined' && 'env' in process) {
44042 r = process.env.DEBUG;
44043 }
44044
44045 return r;
44046 }
44047 /**
44048 * Localstorage attempts to return the localstorage.
44049 *
44050 * This is necessary because safari throws
44051 * when a user disables cookies/localstorage
44052 * and you attempt to access it.
44053 *
44054 * @return {LocalStorage}
44055 * @api private
44056 */
44057
44058
44059 function localstorage() {
44060 try {
44061 // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
44062 // The Browser also has localStorage in the global context.
44063 return localStorage;
44064 } catch (error) {// Swallow
44065 // XXX (@Qix-) should we be logging these?
44066 }
44067 }
44068
44069 module.exports = __webpack_require__(497)(exports);
44070 const {
44071 formatters
44072 } = module.exports;
44073 /**
44074 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
44075 */
44076
44077 formatters.j = function (v) {
44078 try {
44079 return JSON.stringify(v);
44080 } catch (error) {
44081 return '[UnexpectedJSONParseError]: ' + error.message;
44082 }
44083 };
44084
44085 /***/ }),
44086 /* 497 */
44087 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
44088
44089 /* provided dependency */ var console = __webpack_require__(438);
44090 /**
44091 * This is the common logic for both the Node.js and web browser
44092 * implementations of `debug()`.
44093 */
44094 function setup(env) {
44095 createDebug.debug = createDebug;
44096 createDebug.default = createDebug;
44097 createDebug.coerce = coerce;
44098 createDebug.disable = disable;
44099 createDebug.enable = enable;
44100 createDebug.enabled = enabled;
44101 createDebug.humanize = __webpack_require__(498);
44102 createDebug.destroy = destroy;
44103 Object.keys(env).forEach(key => {
44104 createDebug[key] = env[key];
44105 });
44106 /**
44107 * The currently active debug mode names, and names to skip.
44108 */
44109
44110 createDebug.names = [];
44111 createDebug.skips = [];
44112 /**
44113 * Map of special "%n" handling functions, for the debug "format" argument.
44114 *
44115 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
44116 */
44117
44118 createDebug.formatters = {};
44119 /**
44120 * Selects a color for a debug namespace
44121 * @param {String} namespace The namespace string for the debug instance to be colored
44122 * @return {Number|String} An ANSI color code for the given namespace
44123 * @api private
44124 */
44125
44126 function selectColor(namespace) {
44127 let hash = 0;
44128
44129 for (let i = 0; i < namespace.length; i++) {
44130 hash = (hash << 5) - hash + namespace.charCodeAt(i);
44131 hash |= 0; // Convert to 32bit integer
44132 }
44133
44134 return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
44135 }
44136
44137 createDebug.selectColor = selectColor;
44138 /**
44139 * Create a debugger with the given `namespace`.
44140 *
44141 * @param {String} namespace
44142 * @return {Function}
44143 * @api public
44144 */
44145
44146 function createDebug(namespace) {
44147 let prevTime;
44148 let enableOverride = null;
44149 let namespacesCache;
44150 let enabledCache;
44151
44152 function debug() {
44153 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
44154 args[_key] = arguments[_key];
44155 }
44156
44157 // Disabled?
44158 if (!debug.enabled) {
44159 return;
44160 }
44161
44162 const self = debug; // Set `diff` timestamp
44163
44164 const curr = Number(new Date());
44165 const ms = curr - (prevTime || curr);
44166 self.diff = ms;
44167 self.prev = prevTime;
44168 self.curr = curr;
44169 prevTime = curr;
44170 args[0] = createDebug.coerce(args[0]);
44171
44172 if (typeof args[0] !== 'string') {
44173 // Anything else let's inspect with %O
44174 args.unshift('%O');
44175 } // Apply any `formatters` transformations
44176
44177
44178 let index = 0;
44179 args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
44180 // If we encounter an escaped % then don't increase the array index
44181 if (match === '%%') {
44182 return '%';
44183 }
44184
44185 index++;
44186 const formatter = createDebug.formatters[format];
44187
44188 if (typeof formatter === 'function') {
44189 const val = args[index];
44190 match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
44191
44192 args.splice(index, 1);
44193 index--;
44194 }
44195
44196 return match;
44197 }); // Apply env-specific formatting (colors, etc.)
44198
44199 createDebug.formatArgs.call(self, args);
44200 const logFn = self.log || createDebug.log;
44201 logFn.apply(self, args);
44202 }
44203
44204 debug.namespace = namespace;
44205 debug.useColors = createDebug.useColors();
44206 debug.color = createDebug.selectColor(namespace);
44207 debug.extend = extend;
44208 debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
44209
44210 Object.defineProperty(debug, 'enabled', {
44211 enumerable: true,
44212 configurable: false,
44213 get: () => {
44214 if (enableOverride !== null) {
44215 return enableOverride;
44216 }
44217
44218 if (namespacesCache !== createDebug.namespaces) {
44219 namespacesCache = createDebug.namespaces;
44220 enabledCache = createDebug.enabled(namespace);
44221 }
44222
44223 return enabledCache;
44224 },
44225 set: v => {
44226 enableOverride = v;
44227 }
44228 }); // Env-specific initialization logic for debug instances
44229
44230 if (typeof createDebug.init === 'function') {
44231 createDebug.init(debug);
44232 }
44233
44234 return debug;
44235 }
44236
44237 function extend(namespace, delimiter) {
44238 const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
44239 newDebug.log = this.log;
44240 return newDebug;
44241 }
44242 /**
44243 * Enables a debug mode by namespaces. This can include modes
44244 * separated by a colon and wildcards.
44245 *
44246 * @param {String} namespaces
44247 * @api public
44248 */
44249
44250
44251 function enable(namespaces) {
44252 createDebug.save(namespaces);
44253 createDebug.namespaces = namespaces;
44254 createDebug.names = [];
44255 createDebug.skips = [];
44256 let i;
44257 const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
44258 const len = split.length;
44259
44260 for (i = 0; i < len; i++) {
44261 if (!split[i]) {
44262 // ignore empty strings
44263 continue;
44264 }
44265
44266 namespaces = split[i].replace(/\*/g, '.*?');
44267
44268 if (namespaces[0] === '-') {
44269 createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
44270 } else {
44271 createDebug.names.push(new RegExp('^' + namespaces + '$'));
44272 }
44273 }
44274 }
44275 /**
44276 * Disable debug output.
44277 *
44278 * @return {String} namespaces
44279 * @api public
44280 */
44281
44282
44283 function disable() {
44284 const namespaces = [...createDebug.names.map(toNamespace), ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)].join(',');
44285 createDebug.enable('');
44286 return namespaces;
44287 }
44288 /**
44289 * Returns true if the given mode name is enabled, false otherwise.
44290 *
44291 * @param {String} name
44292 * @return {Boolean}
44293 * @api public
44294 */
44295
44296
44297 function enabled(name) {
44298 if (name[name.length - 1] === '*') {
44299 return true;
44300 }
44301
44302 let i;
44303 let len;
44304
44305 for (i = 0, len = createDebug.skips.length; i < len; i++) {
44306 if (createDebug.skips[i].test(name)) {
44307 return false;
44308 }
44309 }
44310
44311 for (i = 0, len = createDebug.names.length; i < len; i++) {
44312 if (createDebug.names[i].test(name)) {
44313 return true;
44314 }
44315 }
44316
44317 return false;
44318 }
44319 /**
44320 * Convert regexp to namespace
44321 *
44322 * @param {RegExp} regxep
44323 * @return {String} namespace
44324 * @api private
44325 */
44326
44327
44328 function toNamespace(regexp) {
44329 return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*');
44330 }
44331 /**
44332 * Coerce `val`.
44333 *
44334 * @param {Mixed} val
44335 * @return {Mixed}
44336 * @api private
44337 */
44338
44339
44340 function coerce(val) {
44341 if (val instanceof Error) {
44342 return val.stack || val.message;
44343 }
44344
44345 return val;
44346 }
44347 /**
44348 * XXX DO NOT USE. This is a temporary stub function.
44349 * XXX It WILL be removed in the next major release.
44350 */
44351
44352
44353 function destroy() {
44354 console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
44355 }
44356
44357 createDebug.enable(createDebug.load());
44358 return createDebug;
44359 }
44360
44361 module.exports = setup;
44362
44363 /***/ }),
44364 /* 498 */
44365 /***/ ((module) => {
44366
44367 /**
44368 * Helpers.
44369 */
44370 var s = 1000;
44371 var m = s * 60;
44372 var h = m * 60;
44373 var d = h * 24;
44374 var w = d * 7;
44375 var y = d * 365.25;
44376 /**
44377 * Parse or format the given `val`.
44378 *
44379 * Options:
44380 *
44381 * - `long` verbose formatting [false]
44382 *
44383 * @param {String|Number} val
44384 * @param {Object} [options]
44385 * @throws {Error} throw an error if val is not a non-empty string or a number
44386 * @return {String|Number}
44387 * @api public
44388 */
44389
44390 module.exports = function (val, options) {
44391 options = options || {};
44392 var type = typeof val;
44393
44394 if (type === 'string' && val.length > 0) {
44395 return parse(val);
44396 } else if (type === 'number' && isFinite(val)) {
44397 return options.long ? fmtLong(val) : fmtShort(val);
44398 }
44399
44400 throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
44401 };
44402 /**
44403 * Parse the given `str` and return milliseconds.
44404 *
44405 * @param {String} str
44406 * @return {Number}
44407 * @api private
44408 */
44409
44410
44411 function parse(str) {
44412 str = String(str);
44413
44414 if (str.length > 100) {
44415 return;
44416 }
44417
44418 var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
44419
44420 if (!match) {
44421 return;
44422 }
44423
44424 var n = parseFloat(match[1]);
44425 var type = (match[2] || 'ms').toLowerCase();
44426
44427 switch (type) {
44428 case 'years':
44429 case 'year':
44430 case 'yrs':
44431 case 'yr':
44432 case 'y':
44433 return n * y;
44434
44435 case 'weeks':
44436 case 'week':
44437 case 'w':
44438 return n * w;
44439
44440 case 'days':
44441 case 'day':
44442 case 'd':
44443 return n * d;
44444
44445 case 'hours':
44446 case 'hour':
44447 case 'hrs':
44448 case 'hr':
44449 case 'h':
44450 return n * h;
44451
44452 case 'minutes':
44453 case 'minute':
44454 case 'mins':
44455 case 'min':
44456 case 'm':
44457 return n * m;
44458
44459 case 'seconds':
44460 case 'second':
44461 case 'secs':
44462 case 'sec':
44463 case 's':
44464 return n * s;
44465
44466 case 'milliseconds':
44467 case 'millisecond':
44468 case 'msecs':
44469 case 'msec':
44470 case 'ms':
44471 return n;
44472
44473 default:
44474 return undefined;
44475 }
44476 }
44477 /**
44478 * Short format for `ms`.
44479 *
44480 * @param {Number} ms
44481 * @return {String}
44482 * @api private
44483 */
44484
44485
44486 function fmtShort(ms) {
44487 var msAbs = Math.abs(ms);
44488
44489 if (msAbs >= d) {
44490 return Math.round(ms / d) + 'd';
44491 }
44492
44493 if (msAbs >= h) {
44494 return Math.round(ms / h) + 'h';
44495 }
44496
44497 if (msAbs >= m) {
44498 return Math.round(ms / m) + 'm';
44499 }
44500
44501 if (msAbs >= s) {
44502 return Math.round(ms / s) + 's';
44503 }
44504
44505 return ms + 'ms';
44506 }
44507 /**
44508 * Long format for `ms`.
44509 *
44510 * @param {Number} ms
44511 * @return {String}
44512 * @api private
44513 */
44514
44515
44516 function fmtLong(ms) {
44517 var msAbs = Math.abs(ms);
44518
44519 if (msAbs >= d) {
44520 return plural(ms, msAbs, d, 'day');
44521 }
44522
44523 if (msAbs >= h) {
44524 return plural(ms, msAbs, h, 'hour');
44525 }
44526
44527 if (msAbs >= m) {
44528 return plural(ms, msAbs, m, 'minute');
44529 }
44530
44531 if (msAbs >= s) {
44532 return plural(ms, msAbs, s, 'second');
44533 }
44534
44535 return ms + ' ms';
44536 }
44537 /**
44538 * Pluralization helper.
44539 */
44540
44541
44542 function plural(ms, msAbs, n, name) {
44543 var isPlural = msAbs >= n * 1.5;
44544 return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
44545 }
44546
44547 /***/ }),
44548 /* 499 */
44549 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
44550
44551 "use strict";
44552
44553
44554 module.exports = {
44555 SourceCode: __webpack_require__(500)
44556 };
44557
44558 /***/ }),
44559 /* 500 */
44560 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
44561
44562 "use strict";
44563 /**
44564 * @fileoverview Abstraction of JavaScript source code.
44565 * @author Nicholas C. Zakas
44566 */
44567 //------------------------------------------------------------------------------
44568 // Requirements
44569 //------------------------------------------------------------------------------
44570
44571 const {
44572 isCommentToken
44573 } = __webpack_require__(501),
44574 TokenStore = __webpack_require__(504),
44575 astUtils = __webpack_require__(444),
44576 Traverser = __webpack_require__(495); //------------------------------------------------------------------------------
44577 // Private
44578 //------------------------------------------------------------------------------
44579
44580 /**
44581 * Validates that the given AST has the required information.
44582 * @param {ASTNode} ast The Program node of the AST to check.
44583 * @throws {Error} If the AST doesn't contain the correct information.
44584 * @returns {void}
44585 * @private
44586 */
44587
44588
44589 function validate(ast) {
44590 if (!ast.tokens) {
44591 throw new Error("AST is missing the tokens array.");
44592 }
44593
44594 if (!ast.comments) {
44595 throw new Error("AST is missing the comments array.");
44596 }
44597
44598 if (!ast.loc) {
44599 throw new Error("AST is missing location information.");
44600 }
44601
44602 if (!ast.range) {
44603 throw new Error("AST is missing range information");
44604 }
44605 }
44606 /**
44607 * Check to see if its a ES6 export declaration.
44608 * @param {ASTNode} astNode An AST node.
44609 * @returns {boolean} whether the given node represents an export declaration.
44610 * @private
44611 */
44612
44613
44614 function looksLikeExport(astNode) {
44615 return astNode.type === "ExportDefaultDeclaration" || astNode.type === "ExportNamedDeclaration" || astNode.type === "ExportAllDeclaration" || astNode.type === "ExportSpecifier";
44616 }
44617 /**
44618 * Merges two sorted lists into a larger sorted list in O(n) time.
44619 * @param {Token[]} tokens The list of tokens.
44620 * @param {Token[]} comments The list of comments.
44621 * @returns {Token[]} A sorted list of tokens and comments.
44622 * @private
44623 */
44624
44625
44626 function sortedMerge(tokens, comments) {
44627 const result = [];
44628 let tokenIndex = 0;
44629 let commentIndex = 0;
44630
44631 while (tokenIndex < tokens.length || commentIndex < comments.length) {
44632 if (commentIndex >= comments.length || tokenIndex < tokens.length && tokens[tokenIndex].range[0] < comments[commentIndex].range[0]) {
44633 result.push(tokens[tokenIndex++]);
44634 } else {
44635 result.push(comments[commentIndex++]);
44636 }
44637 }
44638
44639 return result;
44640 }
44641 /**
44642 * Determines if two nodes or tokens overlap.
44643 * @param {ASTNode|Token} first The first node or token to check.
44644 * @param {ASTNode|Token} second The second node or token to check.
44645 * @returns {boolean} True if the two nodes or tokens overlap.
44646 * @private
44647 */
44648
44649
44650 function nodesOrTokensOverlap(first, second) {
44651 return first.range[0] <= second.range[0] && first.range[1] >= second.range[0] || second.range[0] <= first.range[0] && second.range[1] >= first.range[0];
44652 }
44653 /**
44654 * Determines if two nodes or tokens have at least one whitespace character
44655 * between them. Order does not matter. Returns false if the given nodes or
44656 * tokens overlap.
44657 * @param {SourceCode} sourceCode The source code object.
44658 * @param {ASTNode|Token} first The first node or token to check between.
44659 * @param {ASTNode|Token} second The second node or token to check between.
44660 * @param {boolean} checkInsideOfJSXText If `true` is present, check inside of JSXText tokens for backward compatibility.
44661 * @returns {boolean} True if there is a whitespace character between
44662 * any of the tokens found between the two given nodes or tokens.
44663 * @public
44664 */
44665
44666
44667 function isSpaceBetween(sourceCode, first, second, checkInsideOfJSXText) {
44668 if (nodesOrTokensOverlap(first, second)) {
44669 return false;
44670 }
44671
44672 const [startingNodeOrToken, endingNodeOrToken] = first.range[1] <= second.range[0] ? [first, second] : [second, first];
44673 const firstToken = sourceCode.getLastToken(startingNodeOrToken) || startingNodeOrToken;
44674 const finalToken = sourceCode.getFirstToken(endingNodeOrToken) || endingNodeOrToken;
44675 let currentToken = firstToken;
44676
44677 while (currentToken !== finalToken) {
44678 const nextToken = sourceCode.getTokenAfter(currentToken, {
44679 includeComments: true
44680 });
44681
44682 if (currentToken.range[1] !== nextToken.range[0] ||
44683 /*
44684 * For backward compatibility, check spaces in JSXText.
44685 * https://github.com/eslint/eslint/issues/12614
44686 */
44687 checkInsideOfJSXText && nextToken !== finalToken && nextToken.type === "JSXText" && /\s/u.test(nextToken.value)) {
44688 return true;
44689 }
44690
44691 currentToken = nextToken;
44692 }
44693
44694 return false;
44695 } //------------------------------------------------------------------------------
44696 // Public Interface
44697 //------------------------------------------------------------------------------
44698
44699 /**
44700 * Represents parsed source code.
44701 */
44702
44703
44704 class SourceCode extends TokenStore {
44705 /**
44706 * @param {string|Object} textOrConfig The source code text or config object.
44707 * @param {string} textOrConfig.text The source code text.
44708 * @param {ASTNode} textOrConfig.ast The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
44709 * @param {Object|null} textOrConfig.parserServices The parser services.
44710 * @param {ScopeManager|null} textOrConfig.scopeManager The scope of this source code.
44711 * @param {Object|null} textOrConfig.visitorKeys The visitor keys to traverse AST.
44712 * @param {ASTNode} [astIfNoConfig] The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
44713 */
44714 constructor(textOrConfig, astIfNoConfig) {
44715 let text, ast, parserServices, scopeManager, visitorKeys; // Process overloading.
44716
44717 if (typeof textOrConfig === "string") {
44718 text = textOrConfig;
44719 ast = astIfNoConfig;
44720 } else if (typeof textOrConfig === "object" && textOrConfig !== null) {
44721 text = textOrConfig.text;
44722 ast = textOrConfig.ast;
44723 parserServices = textOrConfig.parserServices;
44724 scopeManager = textOrConfig.scopeManager;
44725 visitorKeys = textOrConfig.visitorKeys;
44726 }
44727
44728 validate(ast);
44729 super(ast.tokens, ast.comments);
44730 /**
44731 * The flag to indicate that the source code has Unicode BOM.
44732 * @type {boolean}
44733 */
44734
44735 this.hasBOM = text.charCodeAt(0) === 0xFEFF;
44736 /**
44737 * The original text source code.
44738 * BOM was stripped from this text.
44739 * @type {string}
44740 */
44741
44742 this.text = this.hasBOM ? text.slice(1) : text;
44743 /**
44744 * The parsed AST for the source code.
44745 * @type {ASTNode}
44746 */
44747
44748 this.ast = ast;
44749 /**
44750 * The parser services of this source code.
44751 * @type {Object}
44752 */
44753
44754 this.parserServices = parserServices || {};
44755 /**
44756 * The scope of this source code.
44757 * @type {ScopeManager|null}
44758 */
44759
44760 this.scopeManager = scopeManager || null;
44761 /**
44762 * The visitor keys to traverse AST.
44763 * @type {Object}
44764 */
44765
44766 this.visitorKeys = visitorKeys || Traverser.DEFAULT_VISITOR_KEYS; // Check the source text for the presence of a shebang since it is parsed as a standard line comment.
44767
44768 const shebangMatched = this.text.match(astUtils.shebangPattern);
44769 const hasShebang = shebangMatched && ast.comments.length && ast.comments[0].value === shebangMatched[1];
44770
44771 if (hasShebang) {
44772 ast.comments[0].type = "Shebang";
44773 }
44774
44775 this.tokensAndComments = sortedMerge(ast.tokens, ast.comments);
44776 /**
44777 * The source code split into lines according to ECMA-262 specification.
44778 * This is done to avoid each rule needing to do so separately.
44779 * @type {string[]}
44780 */
44781
44782 this.lines = [];
44783 this.lineStartIndices = [0];
44784 const lineEndingPattern = astUtils.createGlobalLinebreakMatcher();
44785 let match;
44786 /*
44787 * Previously, this was implemented using a regex that
44788 * matched a sequence of non-linebreak characters followed by a
44789 * linebreak, then adding the lengths of the matches. However,
44790 * this caused a catastrophic backtracking issue when the end
44791 * of a file contained a large number of non-newline characters.
44792 * To avoid this, the current implementation just matches newlines
44793 * and uses match.index to get the correct line start indices.
44794 */
44795
44796 while (match = lineEndingPattern.exec(this.text)) {
44797 this.lines.push(this.text.slice(this.lineStartIndices[this.lineStartIndices.length - 1], match.index));
44798 this.lineStartIndices.push(match.index + match[0].length);
44799 }
44800
44801 this.lines.push(this.text.slice(this.lineStartIndices[this.lineStartIndices.length - 1])); // Cache for comments found using getComments().
44802
44803 this._commentCache = new WeakMap(); // don't allow modification of this object
44804
44805 Object.freeze(this);
44806 Object.freeze(this.lines);
44807 }
44808 /**
44809 * Split the source code into multiple lines based on the line delimiters.
44810 * @param {string} text Source code as a string.
44811 * @returns {string[]} Array of source code lines.
44812 * @public
44813 */
44814
44815
44816 static splitLines(text) {
44817 return text.split(astUtils.createGlobalLinebreakMatcher());
44818 }
44819 /**
44820 * Gets the source code for the given node.
44821 * @param {ASTNode} [node] The AST node to get the text for.
44822 * @param {int} [beforeCount] The number of characters before the node to retrieve.
44823 * @param {int} [afterCount] The number of characters after the node to retrieve.
44824 * @returns {string} The text representing the AST node.
44825 * @public
44826 */
44827
44828
44829 getText(node, beforeCount, afterCount) {
44830 if (node) {
44831 return this.text.slice(Math.max(node.range[0] - (beforeCount || 0), 0), node.range[1] + (afterCount || 0));
44832 }
44833
44834 return this.text;
44835 }
44836 /**
44837 * Gets the entire source text split into an array of lines.
44838 * @returns {Array} The source text as an array of lines.
44839 * @public
44840 */
44841
44842
44843 getLines() {
44844 return this.lines;
44845 }
44846 /**
44847 * Retrieves an array containing all comments in the source code.
44848 * @returns {ASTNode[]} An array of comment nodes.
44849 * @public
44850 */
44851
44852
44853 getAllComments() {
44854 return this.ast.comments;
44855 }
44856 /**
44857 * Gets all comments for the given node.
44858 * @param {ASTNode} node The AST node to get the comments for.
44859 * @returns {Object} An object containing a leading and trailing array
44860 * of comments indexed by their position.
44861 * @public
44862 * @deprecated replaced by getCommentsBefore(), getCommentsAfter(), and getCommentsInside().
44863 */
44864
44865
44866 getComments(node) {
44867 if (this._commentCache.has(node)) {
44868 return this._commentCache.get(node);
44869 }
44870
44871 const comments = {
44872 leading: [],
44873 trailing: []
44874 };
44875 /*
44876 * Return all comments as leading comments of the Program node when
44877 * there is no executable code.
44878 */
44879
44880 if (node.type === "Program") {
44881 if (node.body.length === 0) {
44882 comments.leading = node.comments;
44883 }
44884 } else {
44885 /*
44886 * Return comments as trailing comments of nodes that only contain
44887 * comments (to mimic the comment attachment behavior present in Espree).
44888 */
44889 if ((node.type === "BlockStatement" || node.type === "ClassBody") && node.body.length === 0 || node.type === "ObjectExpression" && node.properties.length === 0 || node.type === "ArrayExpression" && node.elements.length === 0 || node.type === "SwitchStatement" && node.cases.length === 0) {
44890 comments.trailing = this.getTokens(node, {
44891 includeComments: true,
44892 filter: isCommentToken
44893 });
44894 }
44895 /*
44896 * Iterate over tokens before and after node and collect comment tokens.
44897 * Do not include comments that exist outside of the parent node
44898 * to avoid duplication.
44899 */
44900
44901
44902 let currentToken = this.getTokenBefore(node, {
44903 includeComments: true
44904 });
44905
44906 while (currentToken && isCommentToken(currentToken)) {
44907 if (node.parent && node.parent.type !== "Program" && currentToken.start < node.parent.start) {
44908 break;
44909 }
44910
44911 comments.leading.push(currentToken);
44912 currentToken = this.getTokenBefore(currentToken, {
44913 includeComments: true
44914 });
44915 }
44916
44917 comments.leading.reverse();
44918 currentToken = this.getTokenAfter(node, {
44919 includeComments: true
44920 });
44921
44922 while (currentToken && isCommentToken(currentToken)) {
44923 if (node.parent && node.parent.type !== "Program" && currentToken.end > node.parent.end) {
44924 break;
44925 }
44926
44927 comments.trailing.push(currentToken);
44928 currentToken = this.getTokenAfter(currentToken, {
44929 includeComments: true
44930 });
44931 }
44932 }
44933
44934 this._commentCache.set(node, comments);
44935
44936 return comments;
44937 }
44938 /**
44939 * Retrieves the JSDoc comment for a given node.
44940 * @param {ASTNode} node The AST node to get the comment for.
44941 * @returns {Token|null} The Block comment token containing the JSDoc comment
44942 * for the given node or null if not found.
44943 * @public
44944 * @deprecated
44945 */
44946
44947
44948 getJSDocComment(node) {
44949 /**
44950 * Checks for the presence of a JSDoc comment for the given node and returns it.
44951 * @param {ASTNode} astNode The AST node to get the comment for.
44952 * @returns {Token|null} The Block comment token containing the JSDoc comment
44953 * for the given node or null if not found.
44954 * @private
44955 */
44956 const findJSDocComment = astNode => {
44957 const tokenBefore = this.getTokenBefore(astNode, {
44958 includeComments: true
44959 });
44960
44961 if (tokenBefore && isCommentToken(tokenBefore) && tokenBefore.type === "Block" && tokenBefore.value.charAt(0) === "*" && astNode.loc.start.line - tokenBefore.loc.end.line <= 1) {
44962 return tokenBefore;
44963 }
44964
44965 return null;
44966 };
44967
44968 let parent = node.parent;
44969
44970 switch (node.type) {
44971 case "ClassDeclaration":
44972 case "FunctionDeclaration":
44973 return findJSDocComment(looksLikeExport(parent) ? parent : node);
44974
44975 case "ClassExpression":
44976 return findJSDocComment(parent.parent);
44977
44978 case "ArrowFunctionExpression":
44979 case "FunctionExpression":
44980 if (parent.type !== "CallExpression" && parent.type !== "NewExpression") {
44981 while (!this.getCommentsBefore(parent).length && !/Function/u.test(parent.type) && parent.type !== "MethodDefinition" && parent.type !== "Property") {
44982 parent = parent.parent;
44983
44984 if (!parent) {
44985 break;
44986 }
44987 }
44988
44989 if (parent && parent.type !== "FunctionDeclaration" && parent.type !== "Program") {
44990 return findJSDocComment(parent);
44991 }
44992 }
44993
44994 return findJSDocComment(node);
44995 // falls through
44996
44997 default:
44998 return null;
44999 }
45000 }
45001 /**
45002 * Gets the deepest node containing a range index.
45003 * @param {int} index Range index of the desired node.
45004 * @returns {ASTNode} The node if found or null if not found.
45005 * @public
45006 */
45007
45008
45009 getNodeByRangeIndex(index) {
45010 let result = null;
45011 Traverser.traverse(this.ast, {
45012 visitorKeys: this.visitorKeys,
45013
45014 enter(node) {
45015 if (node.range[0] <= index && index < node.range[1]) {
45016 result = node;
45017 } else {
45018 this.skip();
45019 }
45020 },
45021
45022 leave(node) {
45023 if (node === result) {
45024 this.break();
45025 }
45026 }
45027
45028 });
45029 return result;
45030 }
45031 /**
45032 * Determines if two nodes or tokens have at least one whitespace character
45033 * between them. Order does not matter. Returns false if the given nodes or
45034 * tokens overlap.
45035 * @param {ASTNode|Token} first The first node or token to check between.
45036 * @param {ASTNode|Token} second The second node or token to check between.
45037 * @returns {boolean} True if there is a whitespace character between
45038 * any of the tokens found between the two given nodes or tokens.
45039 * @public
45040 */
45041
45042
45043 isSpaceBetween(first, second) {
45044 return isSpaceBetween(this, first, second, false);
45045 }
45046 /**
45047 * Determines if two nodes or tokens have at least one whitespace character
45048 * between them. Order does not matter. Returns false if the given nodes or
45049 * tokens overlap.
45050 * For backward compatibility, this method returns true if there are
45051 * `JSXText` tokens that contain whitespaces between the two.
45052 * @param {ASTNode|Token} first The first node or token to check between.
45053 * @param {ASTNode|Token} second The second node or token to check between.
45054 * @returns {boolean} True if there is a whitespace character between
45055 * any of the tokens found between the two given nodes or tokens.
45056 * @deprecated in favor of isSpaceBetween().
45057 * @public
45058 */
45059
45060
45061 isSpaceBetweenTokens(first, second) {
45062 return isSpaceBetween(this, first, second, true);
45063 }
45064 /**
45065 * Converts a source text index into a (line, column) pair.
45066 * @param {number} index The index of a character in a file
45067 * @throws {TypeError} If non-numeric index or index out of range.
45068 * @returns {Object} A {line, column} location object with a 0-indexed column
45069 * @public
45070 */
45071
45072
45073 getLocFromIndex(index) {
45074 if (typeof index !== "number") {
45075 throw new TypeError("Expected `index` to be a number.");
45076 }
45077
45078 if (index < 0 || index > this.text.length) {
45079 throw new RangeError("Index out of range (requested index ".concat(index, ", but source text has length ").concat(this.text.length, ")."));
45080 }
45081 /*
45082 * For an argument of this.text.length, return the location one "spot" past the last character
45083 * of the file. If the last character is a linebreak, the location will be column 0 of the next
45084 * line; otherwise, the location will be in the next column on the same line.
45085 *
45086 * See getIndexFromLoc for the motivation for this special case.
45087 */
45088
45089
45090 if (index === this.text.length) {
45091 return {
45092 line: this.lines.length,
45093 column: this.lines[this.lines.length - 1].length
45094 };
45095 }
45096 /*
45097 * To figure out which line index is on, determine the last place at which index could
45098 * be inserted into lineStartIndices to keep the list sorted.
45099 */
45100
45101
45102 const lineNumber = index >= this.lineStartIndices[this.lineStartIndices.length - 1] ? this.lineStartIndices.length : this.lineStartIndices.findIndex(el => index < el);
45103 return {
45104 line: lineNumber,
45105 column: index - this.lineStartIndices[lineNumber - 1]
45106 };
45107 }
45108 /**
45109 * Converts a (line, column) pair into a range index.
45110 * @param {Object} loc A line/column location
45111 * @param {number} loc.line The line number of the location (1-indexed)
45112 * @param {number} loc.column The column number of the location (0-indexed)
45113 * @throws {TypeError|RangeError} If `loc` is not an object with a numeric
45114 * `line` and `column`, if the `line` is less than or equal to zero or
45115 * the line or column is out of the expected range.
45116 * @returns {number} The range index of the location in the file.
45117 * @public
45118 */
45119
45120
45121 getIndexFromLoc(loc) {
45122 if (typeof loc !== "object" || typeof loc.line !== "number" || typeof loc.column !== "number") {
45123 throw new TypeError("Expected `loc` to be an object with numeric `line` and `column` properties.");
45124 }
45125
45126 if (loc.line <= 0) {
45127 throw new RangeError("Line number out of range (line ".concat(loc.line, " requested). Line numbers should be 1-based."));
45128 }
45129
45130 if (loc.line > this.lineStartIndices.length) {
45131 throw new RangeError("Line number out of range (line ".concat(loc.line, " requested, but only ").concat(this.lineStartIndices.length, " lines present)."));
45132 }
45133
45134 const lineStartIndex = this.lineStartIndices[loc.line - 1];
45135 const lineEndIndex = loc.line === this.lineStartIndices.length ? this.text.length : this.lineStartIndices[loc.line];
45136 const positionIndex = lineStartIndex + loc.column;
45137 /*
45138 * By design, getIndexFromLoc({ line: lineNum, column: 0 }) should return the start index of
45139 * the given line, provided that the line number is valid element of this.lines. Since the
45140 * last element of this.lines is an empty string for files with trailing newlines, add a
45141 * special case where getting the index for the first location after the end of the file
45142 * will return the length of the file, rather than throwing an error. This allows rules to
45143 * use getIndexFromLoc consistently without worrying about edge cases at the end of a file.
45144 */
45145
45146 if (loc.line === this.lineStartIndices.length && positionIndex > lineEndIndex || loc.line < this.lineStartIndices.length && positionIndex >= lineEndIndex) {
45147 throw new RangeError("Column number out of range (column ".concat(loc.column, " requested, but the length of line ").concat(loc.line, " is ").concat(lineEndIndex - lineStartIndex, ")."));
45148 }
45149
45150 return positionIndex;
45151 }
45152
45153 }
45154
45155 module.exports = SourceCode;
45156
45157 /***/ }),
45158 /* 501 */
45159 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
45160
45161 "use strict";
45162 /*! @author Toru Nagashima <https://github.com/mysticatea> */
45163
45164
45165 Object.defineProperty(exports, "__esModule", ({
45166 value: true
45167 }));
45168
45169 function _interopDefault(ex) {
45170 return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex;
45171 }
45172
45173 var evk = _interopDefault(__webpack_require__(502));
45174 /**
45175 * Get the innermost scope which contains a given location.
45176 * @param {Scope} initialScope The initial scope to search.
45177 * @param {Node} node The location to search.
45178 * @returns {Scope} The innermost scope.
45179 */
45180
45181
45182 function getInnermostScope(initialScope, node) {
45183 const location = node.range[0];
45184 let scope = initialScope;
45185 let found = false;
45186
45187 do {
45188 found = false;
45189
45190 for (const childScope of scope.childScopes) {
45191 const range = childScope.block.range;
45192
45193 if (range[0] <= location && location < range[1]) {
45194 scope = childScope;
45195 found = true;
45196 break;
45197 }
45198 }
45199 } while (found);
45200
45201 return scope;
45202 }
45203 /**
45204 * Find the variable of a given name.
45205 * @param {Scope} initialScope The scope to start finding.
45206 * @param {string|Node} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node.
45207 * @returns {Variable|null} The found variable or null.
45208 */
45209
45210
45211 function findVariable(initialScope, nameOrNode) {
45212 let name = "";
45213 let scope = initialScope;
45214
45215 if (typeof nameOrNode === "string") {
45216 name = nameOrNode;
45217 } else {
45218 name = nameOrNode.name;
45219 scope = getInnermostScope(scope, nameOrNode);
45220 }
45221
45222 while (scope != null) {
45223 const variable = scope.set.get(name);
45224
45225 if (variable != null) {
45226 return variable;
45227 }
45228
45229 scope = scope.upper;
45230 }
45231
45232 return null;
45233 }
45234 /**
45235 * Negate the result of `this` calling.
45236 * @param {Token} token The token to check.
45237 * @returns {boolean} `true` if the result of `this(token)` is `false`.
45238 */
45239
45240
45241 function negate0(token) {
45242 return !this(token); //eslint-disable-line no-invalid-this
45243 }
45244 /**
45245 * Creates the negate function of the given function.
45246 * @param {function(Token):boolean} f - The function to negate.
45247 * @returns {function(Token):boolean} Negated function.
45248 */
45249
45250
45251 function negate(f) {
45252 return negate0.bind(f);
45253 }
45254 /**
45255 * Checks if the given token is a PunctuatorToken with the given value
45256 * @param {Token} token - The token to check.
45257 * @param {string} value - The value to check.
45258 * @returns {boolean} `true` if the token is a PunctuatorToken with the given value.
45259 */
45260
45261
45262 function isPunctuatorTokenWithValue(token, value) {
45263 return token.type === "Punctuator" && token.value === value;
45264 }
45265 /**
45266 * Checks if the given token is an arrow token or not.
45267 * @param {Token} token - The token to check.
45268 * @returns {boolean} `true` if the token is an arrow token.
45269 */
45270
45271
45272 function isArrowToken(token) {
45273 return isPunctuatorTokenWithValue(token, "=>");
45274 }
45275 /**
45276 * Checks if the given token is a comma token or not.
45277 * @param {Token} token - The token to check.
45278 * @returns {boolean} `true` if the token is a comma token.
45279 */
45280
45281
45282 function isCommaToken(token) {
45283 return isPunctuatorTokenWithValue(token, ",");
45284 }
45285 /**
45286 * Checks if the given token is a semicolon token or not.
45287 * @param {Token} token - The token to check.
45288 * @returns {boolean} `true` if the token is a semicolon token.
45289 */
45290
45291
45292 function isSemicolonToken(token) {
45293 return isPunctuatorTokenWithValue(token, ";");
45294 }
45295 /**
45296 * Checks if the given token is a colon token or not.
45297 * @param {Token} token - The token to check.
45298 * @returns {boolean} `true` if the token is a colon token.
45299 */
45300
45301
45302 function isColonToken(token) {
45303 return isPunctuatorTokenWithValue(token, ":");
45304 }
45305 /**
45306 * Checks if the given token is an opening parenthesis token or not.
45307 * @param {Token} token - The token to check.
45308 * @returns {boolean} `true` if the token is an opening parenthesis token.
45309 */
45310
45311
45312 function isOpeningParenToken(token) {
45313 return isPunctuatorTokenWithValue(token, "(");
45314 }
45315 /**
45316 * Checks if the given token is a closing parenthesis token or not.
45317 * @param {Token} token - The token to check.
45318 * @returns {boolean} `true` if the token is a closing parenthesis token.
45319 */
45320
45321
45322 function isClosingParenToken(token) {
45323 return isPunctuatorTokenWithValue(token, ")");
45324 }
45325 /**
45326 * Checks if the given token is an opening square bracket token or not.
45327 * @param {Token} token - The token to check.
45328 * @returns {boolean} `true` if the token is an opening square bracket token.
45329 */
45330
45331
45332 function isOpeningBracketToken(token) {
45333 return isPunctuatorTokenWithValue(token, "[");
45334 }
45335 /**
45336 * Checks if the given token is a closing square bracket token or not.
45337 * @param {Token} token - The token to check.
45338 * @returns {boolean} `true` if the token is a closing square bracket token.
45339 */
45340
45341
45342 function isClosingBracketToken(token) {
45343 return isPunctuatorTokenWithValue(token, "]");
45344 }
45345 /**
45346 * Checks if the given token is an opening brace token or not.
45347 * @param {Token} token - The token to check.
45348 * @returns {boolean} `true` if the token is an opening brace token.
45349 */
45350
45351
45352 function isOpeningBraceToken(token) {
45353 return isPunctuatorTokenWithValue(token, "{");
45354 }
45355 /**
45356 * Checks if the given token is a closing brace token or not.
45357 * @param {Token} token - The token to check.
45358 * @returns {boolean} `true` if the token is a closing brace token.
45359 */
45360
45361
45362 function isClosingBraceToken(token) {
45363 return isPunctuatorTokenWithValue(token, "}");
45364 }
45365 /**
45366 * Checks if the given token is a comment token or not.
45367 * @param {Token} token - The token to check.
45368 * @returns {boolean} `true` if the token is a comment token.
45369 */
45370
45371
45372 function isCommentToken(token) {
45373 return ["Block", "Line", "Shebang"].includes(token.type);
45374 }
45375
45376 const isNotArrowToken = negate(isArrowToken);
45377 const isNotCommaToken = negate(isCommaToken);
45378 const isNotSemicolonToken = negate(isSemicolonToken);
45379 const isNotColonToken = negate(isColonToken);
45380 const isNotOpeningParenToken = negate(isOpeningParenToken);
45381 const isNotClosingParenToken = negate(isClosingParenToken);
45382 const isNotOpeningBracketToken = negate(isOpeningBracketToken);
45383 const isNotClosingBracketToken = negate(isClosingBracketToken);
45384 const isNotOpeningBraceToken = negate(isOpeningBraceToken);
45385 const isNotClosingBraceToken = negate(isClosingBraceToken);
45386 const isNotCommentToken = negate(isCommentToken);
45387 /**
45388 * Get the `(` token of the given function node.
45389 * @param {Node} node - The function node to get.
45390 * @param {SourceCode} sourceCode - The source code object to get tokens.
45391 * @returns {Token} `(` token.
45392 */
45393
45394 function getOpeningParenOfParams(node, sourceCode) {
45395 return node.id ? sourceCode.getTokenAfter(node.id, isOpeningParenToken) : sourceCode.getFirstToken(node, isOpeningParenToken);
45396 }
45397 /**
45398 * Get the location of the given function node for reporting.
45399 * @param {Node} node - The function node to get.
45400 * @param {SourceCode} sourceCode - The source code object to get tokens.
45401 * @returns {string} The location of the function node for reporting.
45402 */
45403
45404
45405 function getFunctionHeadLocation(node, sourceCode) {
45406 const parent = node.parent;
45407 let start = null;
45408 let end = null;
45409
45410 if (node.type === "ArrowFunctionExpression") {
45411 const arrowToken = sourceCode.getTokenBefore(node.body, isArrowToken);
45412 start = arrowToken.loc.start;
45413 end = arrowToken.loc.end;
45414 } else if (parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") {
45415 start = parent.loc.start;
45416 end = getOpeningParenOfParams(node, sourceCode).loc.start;
45417 } else {
45418 start = node.loc.start;
45419 end = getOpeningParenOfParams(node, sourceCode).loc.start;
45420 }
45421
45422 return {
45423 start: { ...start
45424 },
45425 end: { ...end
45426 }
45427 };
45428 }
45429 /* globals globalThis, global, self, window */
45430
45431
45432 const globalObject = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
45433 const builtinNames = Object.freeze(new Set(["Array", "ArrayBuffer", "BigInt", "BigInt64Array", "BigUint64Array", "Boolean", "DataView", "Date", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape", "Float32Array", "Float64Array", "Function", "Infinity", "Int16Array", "Int32Array", "Int8Array", "isFinite", "isNaN", "isPrototypeOf", "JSON", "Map", "Math", "NaN", "Number", "Object", "parseFloat", "parseInt", "Promise", "Proxy", "Reflect", "RegExp", "Set", "String", "Symbol", "Uint16Array", "Uint32Array", "Uint8Array", "Uint8ClampedArray", "undefined", "unescape", "WeakMap", "WeakSet"]));
45434 const callAllowed = new Set([Array.isArray, typeof BigInt === "function" ? BigInt : undefined, Boolean, Date, Date.parse, decodeURI, decodeURIComponent, encodeURI, encodeURIComponent, escape, isFinite, isNaN, isPrototypeOf, ...Object.getOwnPropertyNames(Math).map(k => Math[k]).filter(f => typeof f === "function"), Number, Number.isFinite, Number.isNaN, Number.parseFloat, Number.parseInt, Object, Object.entries, Object.is, Object.isExtensible, Object.isFrozen, Object.isSealed, Object.keys, Object.values, parseFloat, parseInt, RegExp, String, String.fromCharCode, String.fromCodePoint, String.raw, Symbol.for, Symbol.keyFor, unescape].filter(f => typeof f === "function"));
45435 const callPassThrough = new Set([Object.freeze, Object.preventExtensions, Object.seal]);
45436 /**
45437 * Get the property descriptor.
45438 * @param {object} object The object to get.
45439 * @param {string|number|symbol} name The property name to get.
45440 */
45441
45442 function getPropertyDescriptor(object, name) {
45443 let x = object;
45444
45445 while ((typeof x === "object" || typeof x === "function") && x !== null) {
45446 const d = Object.getOwnPropertyDescriptor(x, name);
45447
45448 if (d) {
45449 return d;
45450 }
45451
45452 x = Object.getPrototypeOf(x);
45453 }
45454
45455 return null;
45456 }
45457 /**
45458 * Check if a property is getter or not.
45459 * @param {object} object The object to check.
45460 * @param {string|number|symbol} name The property name to check.
45461 */
45462
45463
45464 function isGetter(object, name) {
45465 const d = getPropertyDescriptor(object, name);
45466 return d != null && d.get != null;
45467 }
45468 /**
45469 * Get the element values of a given node list.
45470 * @param {Node[]} nodeList The node list to get values.
45471 * @param {Scope|undefined} initialScope The initial scope to find variables.
45472 * @returns {any[]|null} The value list if all nodes are constant. Otherwise, null.
45473 */
45474
45475
45476 function getElementValues(nodeList, initialScope) {
45477 const valueList = [];
45478
45479 for (let i = 0; i < nodeList.length; ++i) {
45480 const elementNode = nodeList[i];
45481
45482 if (elementNode == null) {
45483 valueList.length = i + 1;
45484 } else if (elementNode.type === "SpreadElement") {
45485 const argument = getStaticValueR(elementNode.argument, initialScope);
45486
45487 if (argument == null) {
45488 return null;
45489 }
45490
45491 valueList.push(...argument.value);
45492 } else {
45493 const element = getStaticValueR(elementNode, initialScope);
45494
45495 if (element == null) {
45496 return null;
45497 }
45498
45499 valueList.push(element.value);
45500 }
45501 }
45502
45503 return valueList;
45504 }
45505
45506 const operations = Object.freeze({
45507 ArrayExpression(node, initialScope) {
45508 const elements = getElementValues(node.elements, initialScope);
45509 return elements != null ? {
45510 value: elements
45511 } : null;
45512 },
45513
45514 AssignmentExpression(node, initialScope) {
45515 if (node.operator === "=") {
45516 return getStaticValueR(node.right, initialScope);
45517 }
45518
45519 return null;
45520 },
45521
45522 //eslint-disable-next-line complexity
45523 BinaryExpression(node, initialScope) {
45524 if (node.operator === "in" || node.operator === "instanceof") {
45525 // Not supported.
45526 return null;
45527 }
45528
45529 const left = getStaticValueR(node.left, initialScope);
45530 const right = getStaticValueR(node.right, initialScope);
45531
45532 if (left != null && right != null) {
45533 switch (node.operator) {
45534 case "==":
45535 return {
45536 value: left.value == right.value
45537 };
45538 //eslint-disable-line eqeqeq
45539
45540 case "!=":
45541 return {
45542 value: left.value != right.value
45543 };
45544 //eslint-disable-line eqeqeq
45545
45546 case "===":
45547 return {
45548 value: left.value === right.value
45549 };
45550
45551 case "!==":
45552 return {
45553 value: left.value !== right.value
45554 };
45555
45556 case "<":
45557 return {
45558 value: left.value < right.value
45559 };
45560
45561 case "<=":
45562 return {
45563 value: left.value <= right.value
45564 };
45565
45566 case ">":
45567 return {
45568 value: left.value > right.value
45569 };
45570
45571 case ">=":
45572 return {
45573 value: left.value >= right.value
45574 };
45575
45576 case "<<":
45577 return {
45578 value: left.value << right.value
45579 };
45580
45581 case ">>":
45582 return {
45583 value: left.value >> right.value
45584 };
45585
45586 case ">>>":
45587 return {
45588 value: left.value >>> right.value
45589 };
45590
45591 case "+":
45592 return {
45593 value: left.value + right.value
45594 };
45595
45596 case "-":
45597 return {
45598 value: left.value - right.value
45599 };
45600
45601 case "*":
45602 return {
45603 value: left.value * right.value
45604 };
45605
45606 case "/":
45607 return {
45608 value: left.value / right.value
45609 };
45610
45611 case "%":
45612 return {
45613 value: left.value % right.value
45614 };
45615
45616 case "**":
45617 return {
45618 value: Math.pow(left.value, right.value)
45619 };
45620
45621 case "|":
45622 return {
45623 value: left.value | right.value
45624 };
45625
45626 case "^":
45627 return {
45628 value: left.value ^ right.value
45629 };
45630
45631 case "&":
45632 return {
45633 value: left.value & right.value
45634 };
45635 // no default
45636 }
45637 }
45638
45639 return null;
45640 },
45641
45642 CallExpression(node, initialScope) {
45643 const calleeNode = node.callee;
45644 const args = getElementValues(node.arguments, initialScope);
45645
45646 if (args != null) {
45647 if (calleeNode.type === "MemberExpression") {
45648 if (calleeNode.property.type === "PrivateIdentifier") {
45649 return null;
45650 }
45651
45652 const object = getStaticValueR(calleeNode.object, initialScope);
45653
45654 if (object != null) {
45655 if (object.value == null && (object.optional || node.optional)) {
45656 return {
45657 value: undefined,
45658 optional: true
45659 };
45660 }
45661
45662 const property = getStaticPropertyNameValue(calleeNode, initialScope);
45663
45664 if (property != null) {
45665 const receiver = object.value;
45666 const methodName = property.value;
45667
45668 if (callAllowed.has(receiver[methodName])) {
45669 return {
45670 value: receiver[methodName](...args)
45671 };
45672 }
45673
45674 if (callPassThrough.has(receiver[methodName])) {
45675 return {
45676 value: args[0]
45677 };
45678 }
45679 }
45680 }
45681 } else {
45682 const callee = getStaticValueR(calleeNode, initialScope);
45683
45684 if (callee != null) {
45685 if (callee.value == null && node.optional) {
45686 return {
45687 value: undefined,
45688 optional: true
45689 };
45690 }
45691
45692 const func = callee.value;
45693
45694 if (callAllowed.has(func)) {
45695 return {
45696 value: func(...args)
45697 };
45698 }
45699
45700 if (callPassThrough.has(func)) {
45701 return {
45702 value: args[0]
45703 };
45704 }
45705 }
45706 }
45707 }
45708
45709 return null;
45710 },
45711
45712 ConditionalExpression(node, initialScope) {
45713 const test = getStaticValueR(node.test, initialScope);
45714
45715 if (test != null) {
45716 return test.value ? getStaticValueR(node.consequent, initialScope) : getStaticValueR(node.alternate, initialScope);
45717 }
45718
45719 return null;
45720 },
45721
45722 ExpressionStatement(node, initialScope) {
45723 return getStaticValueR(node.expression, initialScope);
45724 },
45725
45726 Identifier(node, initialScope) {
45727 if (initialScope != null) {
45728 const variable = findVariable(initialScope, node); // Built-in globals.
45729
45730 if (variable != null && variable.defs.length === 0 && builtinNames.has(variable.name) && variable.name in globalObject) {
45731 return {
45732 value: globalObject[variable.name]
45733 };
45734 } // Constants.
45735
45736
45737 if (variable != null && variable.defs.length === 1) {
45738 const def = variable.defs[0];
45739
45740 if (def.parent && def.parent.kind === "const" && // TODO(mysticatea): don't support destructuring here.
45741 def.node.id.type === "Identifier") {
45742 return getStaticValueR(def.node.init, initialScope);
45743 }
45744 }
45745 }
45746
45747 return null;
45748 },
45749
45750 Literal(node) {
45751 //istanbul ignore if : this is implementation-specific behavior.
45752 if ((node.regex != null || node.bigint != null) && node.value == null) {
45753 // It was a RegExp/BigInt literal, but Node.js didn't support it.
45754 return null;
45755 }
45756
45757 return {
45758 value: node.value
45759 };
45760 },
45761
45762 LogicalExpression(node, initialScope) {
45763 const left = getStaticValueR(node.left, initialScope);
45764
45765 if (left != null) {
45766 if (node.operator === "||" && Boolean(left.value) === true || node.operator === "&&" && Boolean(left.value) === false || node.operator === "??" && left.value != null) {
45767 return left;
45768 }
45769
45770 const right = getStaticValueR(node.right, initialScope);
45771
45772 if (right != null) {
45773 return right;
45774 }
45775 }
45776
45777 return null;
45778 },
45779
45780 MemberExpression(node, initialScope) {
45781 if (node.property.type === "PrivateIdentifier") {
45782 return null;
45783 }
45784
45785 const object = getStaticValueR(node.object, initialScope);
45786
45787 if (object != null) {
45788 if (object.value == null && (object.optional || node.optional)) {
45789 return {
45790 value: undefined,
45791 optional: true
45792 };
45793 }
45794
45795 const property = getStaticPropertyNameValue(node, initialScope);
45796
45797 if (property != null && !isGetter(object.value, property.value)) {
45798 return {
45799 value: object.value[property.value]
45800 };
45801 }
45802 }
45803
45804 return null;
45805 },
45806
45807 ChainExpression(node, initialScope) {
45808 const expression = getStaticValueR(node.expression, initialScope);
45809
45810 if (expression != null) {
45811 return {
45812 value: expression.value
45813 };
45814 }
45815
45816 return null;
45817 },
45818
45819 NewExpression(node, initialScope) {
45820 const callee = getStaticValueR(node.callee, initialScope);
45821 const args = getElementValues(node.arguments, initialScope);
45822
45823 if (callee != null && args != null) {
45824 const Func = callee.value;
45825
45826 if (callAllowed.has(Func)) {
45827 return {
45828 value: new Func(...args)
45829 };
45830 }
45831 }
45832
45833 return null;
45834 },
45835
45836 ObjectExpression(node, initialScope) {
45837 const object = {};
45838
45839 for (const propertyNode of node.properties) {
45840 if (propertyNode.type === "Property") {
45841 if (propertyNode.kind !== "init") {
45842 return null;
45843 }
45844
45845 const key = getStaticPropertyNameValue(propertyNode, initialScope);
45846 const value = getStaticValueR(propertyNode.value, initialScope);
45847
45848 if (key == null || value == null) {
45849 return null;
45850 }
45851
45852 object[key.value] = value.value;
45853 } else if (propertyNode.type === "SpreadElement" || propertyNode.type === "ExperimentalSpreadProperty") {
45854 const argument = getStaticValueR(propertyNode.argument, initialScope);
45855
45856 if (argument == null) {
45857 return null;
45858 }
45859
45860 Object.assign(object, argument.value);
45861 } else {
45862 return null;
45863 }
45864 }
45865
45866 return {
45867 value: object
45868 };
45869 },
45870
45871 SequenceExpression(node, initialScope) {
45872 const last = node.expressions[node.expressions.length - 1];
45873 return getStaticValueR(last, initialScope);
45874 },
45875
45876 TaggedTemplateExpression(node, initialScope) {
45877 const tag = getStaticValueR(node.tag, initialScope);
45878 const expressions = getElementValues(node.quasi.expressions, initialScope);
45879
45880 if (tag != null && expressions != null) {
45881 const func = tag.value;
45882 const strings = node.quasi.quasis.map(q => q.value.cooked);
45883 strings.raw = node.quasi.quasis.map(q => q.value.raw);
45884
45885 if (func === String.raw) {
45886 return {
45887 value: func(strings, ...expressions)
45888 };
45889 }
45890 }
45891
45892 return null;
45893 },
45894
45895 TemplateLiteral(node, initialScope) {
45896 const expressions = getElementValues(node.expressions, initialScope);
45897
45898 if (expressions != null) {
45899 let value = node.quasis[0].value.cooked;
45900
45901 for (let i = 0; i < expressions.length; ++i) {
45902 value += expressions[i];
45903 value += node.quasis[i + 1].value.cooked;
45904 }
45905
45906 return {
45907 value
45908 };
45909 }
45910
45911 return null;
45912 },
45913
45914 UnaryExpression(node, initialScope) {
45915 if (node.operator === "delete") {
45916 // Not supported.
45917 return null;
45918 }
45919
45920 if (node.operator === "void") {
45921 return {
45922 value: undefined
45923 };
45924 }
45925
45926 const arg = getStaticValueR(node.argument, initialScope);
45927
45928 if (arg != null) {
45929 switch (node.operator) {
45930 case "-":
45931 return {
45932 value: -arg.value
45933 };
45934
45935 case "+":
45936 return {
45937 value: +arg.value
45938 };
45939 //eslint-disable-line no-implicit-coercion
45940
45941 case "!":
45942 return {
45943 value: !arg.value
45944 };
45945
45946 case "~":
45947 return {
45948 value: ~arg.value
45949 };
45950
45951 case "typeof":
45952 return {
45953 value: typeof arg.value
45954 };
45955 // no default
45956 }
45957 }
45958
45959 return null;
45960 }
45961
45962 });
45963 /**
45964 * Get the value of a given node if it's a static value.
45965 * @param {Node} node The node to get.
45966 * @param {Scope|undefined} initialScope The scope to start finding variable.
45967 * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`.
45968 */
45969
45970 function getStaticValueR(node, initialScope) {
45971 if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
45972 return operations[node.type](node, initialScope);
45973 }
45974
45975 return null;
45976 }
45977 /**
45978 * Get the static value of property name from a MemberExpression node or a Property node.
45979 * @param {Node} node The node to get.
45980 * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
45981 * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the property name of the node, or `null`.
45982 */
45983
45984
45985 function getStaticPropertyNameValue(node, initialScope) {
45986 const nameNode = node.type === "Property" ? node.key : node.property;
45987
45988 if (node.computed) {
45989 return getStaticValueR(nameNode, initialScope);
45990 }
45991
45992 if (nameNode.type === "Identifier") {
45993 return {
45994 value: nameNode.name
45995 };
45996 }
45997
45998 if (nameNode.type === "Literal") {
45999 if (nameNode.bigint) {
46000 return {
46001 value: nameNode.bigint
46002 };
46003 }
46004
46005 return {
46006 value: String(nameNode.value)
46007 };
46008 }
46009
46010 return null;
46011 }
46012 /**
46013 * Get the value of a given node if it's a static value.
46014 * @param {Node} node The node to get.
46015 * @param {Scope} [initialScope] The scope to start finding variable. Optional. If this scope was given, this tries to resolve identifier references which are in the given node as much as possible.
46016 * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`.
46017 */
46018
46019
46020 function getStaticValue(node) {
46021 let initialScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
46022
46023 try {
46024 return getStaticValueR(node, initialScope);
46025 } catch (_error) {
46026 return null;
46027 }
46028 }
46029 /**
46030 * Get the value of a given node if it's a literal or a template literal.
46031 * @param {Node} node The node to get.
46032 * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is an Identifier node and this scope was given, this checks the variable of the identifier, and returns the value of it if the variable is a constant.
46033 * @returns {string|null} The value of the node, or `null`.
46034 */
46035
46036
46037 function getStringIfConstant(node) {
46038 let initialScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
46039
46040 // Handle the literals that the platform doesn't support natively.
46041 if (node && node.type === "Literal" && node.value === null) {
46042 if (node.regex) {
46043 return "/".concat(node.regex.pattern, "/").concat(node.regex.flags);
46044 }
46045
46046 if (node.bigint) {
46047 return node.bigint;
46048 }
46049 }
46050
46051 const evaluated = getStaticValue(node, initialScope);
46052 return evaluated && String(evaluated.value);
46053 }
46054 /**
46055 * Get the property name from a MemberExpression node or a Property node.
46056 * @param {Node} node The node to get.
46057 * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
46058 * @returns {string|null} The property name of the node.
46059 */
46060
46061
46062 function getPropertyName(node, initialScope) {
46063 switch (node.type) {
46064 case "MemberExpression":
46065 if (node.computed) {
46066 return getStringIfConstant(node.property, initialScope);
46067 }
46068
46069 if (node.property.type === "PrivateIdentifier") {
46070 return null;
46071 }
46072
46073 return node.property.name;
46074
46075 case "Property":
46076 case "MethodDefinition":
46077 case "PropertyDefinition":
46078 if (node.computed) {
46079 return getStringIfConstant(node.key, initialScope);
46080 }
46081
46082 if (node.key.type === "Literal") {
46083 return String(node.key.value);
46084 }
46085
46086 if (node.key.type === "PrivateIdentifier") {
46087 return null;
46088 }
46089
46090 return node.key.name;
46091 // no default
46092 }
46093
46094 return null;
46095 }
46096 /**
46097 * Get the name and kind of the given function node.
46098 * @param {ASTNode} node - The function node to get.
46099 * @param {SourceCode} [sourceCode] The source code object to get the code of computed property keys.
46100 * @returns {string} The name and kind of the function node.
46101 */
46102 // eslint-disable-next-line complexity
46103
46104
46105 function getFunctionNameWithKind(node, sourceCode) {
46106 const parent = node.parent;
46107 const tokens = [];
46108 const isObjectMethod = parent.type === "Property" && parent.value === node;
46109 const isClassMethod = parent.type === "MethodDefinition" && parent.value === node;
46110 const isClassFieldMethod = parent.type === "PropertyDefinition" && parent.value === node; // Modifiers.
46111
46112 if (isClassMethod || isClassFieldMethod) {
46113 if (parent.static) {
46114 tokens.push("static");
46115 }
46116
46117 if (parent.key.type === "PrivateIdentifier") {
46118 tokens.push("private");
46119 }
46120 }
46121
46122 if (node.async) {
46123 tokens.push("async");
46124 }
46125
46126 if (node.generator) {
46127 tokens.push("generator");
46128 } // Kinds.
46129
46130
46131 if (isObjectMethod || isClassMethod) {
46132 if (parent.kind === "constructor") {
46133 return "constructor";
46134 }
46135
46136 if (parent.kind === "get") {
46137 tokens.push("getter");
46138 } else if (parent.kind === "set") {
46139 tokens.push("setter");
46140 } else {
46141 tokens.push("method");
46142 }
46143 } else if (isClassFieldMethod) {
46144 tokens.push("method");
46145 } else {
46146 if (node.type === "ArrowFunctionExpression") {
46147 tokens.push("arrow");
46148 }
46149
46150 tokens.push("function");
46151 } // Names.
46152
46153
46154 if (isObjectMethod || isClassMethod || isClassFieldMethod) {
46155 if (parent.key.type === "PrivateIdentifier") {
46156 tokens.push("#".concat(parent.key.name));
46157 } else {
46158 const name = getPropertyName(parent);
46159
46160 if (name) {
46161 tokens.push("'".concat(name, "'"));
46162 } else if (sourceCode) {
46163 const keyText = sourceCode.getText(parent.key);
46164
46165 if (!keyText.includes("\n")) {
46166 tokens.push("[".concat(keyText, "]"));
46167 }
46168 }
46169 }
46170 } else if (node.id) {
46171 tokens.push("'".concat(node.id.name, "'"));
46172 } else if (parent.type === "VariableDeclarator" && parent.id && parent.id.type === "Identifier") {
46173 tokens.push("'".concat(parent.id.name, "'"));
46174 } else if ((parent.type === "AssignmentExpression" || parent.type === "AssignmentPattern") && parent.left && parent.left.type === "Identifier") {
46175 tokens.push("'".concat(parent.left.name, "'"));
46176 }
46177
46178 return tokens.join(" ");
46179 }
46180
46181 const typeConversionBinaryOps = Object.freeze(new Set(["==", "!=", "<", "<=", ">", ">=", "<<", ">>", ">>>", "+", "-", "*", "/", "%", "|", "^", "&", "in"]));
46182 const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"]));
46183 /**
46184 * Check whether the given value is an ASTNode or not.
46185 * @param {any} x The value to check.
46186 * @returns {boolean} `true` if the value is an ASTNode.
46187 */
46188
46189 function isNode(x) {
46190 return x !== null && typeof x === "object" && typeof x.type === "string";
46191 }
46192
46193 const visitor = Object.freeze(Object.assign(Object.create(null), {
46194 $visit(node, options, visitorKeys) {
46195 const {
46196 type
46197 } = node;
46198
46199 if (typeof this[type] === "function") {
46200 return this[type](node, options, visitorKeys);
46201 }
46202
46203 return this.$visitChildren(node, options, visitorKeys);
46204 },
46205
46206 $visitChildren(node, options, visitorKeys) {
46207 const {
46208 type
46209 } = node;
46210
46211 for (const key of visitorKeys[type] || evk.getKeys(node)) {
46212 const value = node[key];
46213
46214 if (Array.isArray(value)) {
46215 for (const element of value) {
46216 if (isNode(element) && this.$visit(element, options, visitorKeys)) {
46217 return true;
46218 }
46219 }
46220 } else if (isNode(value) && this.$visit(value, options, visitorKeys)) {
46221 return true;
46222 }
46223 }
46224
46225 return false;
46226 },
46227
46228 ArrowFunctionExpression() {
46229 return false;
46230 },
46231
46232 AssignmentExpression() {
46233 return true;
46234 },
46235
46236 AwaitExpression() {
46237 return true;
46238 },
46239
46240 BinaryExpression(node, options, visitorKeys) {
46241 if (options.considerImplicitTypeConversion && typeConversionBinaryOps.has(node.operator) && (node.left.type !== "Literal" || node.right.type !== "Literal")) {
46242 return true;
46243 }
46244
46245 return this.$visitChildren(node, options, visitorKeys);
46246 },
46247
46248 CallExpression() {
46249 return true;
46250 },
46251
46252 FunctionExpression() {
46253 return false;
46254 },
46255
46256 ImportExpression() {
46257 return true;
46258 },
46259
46260 MemberExpression(node, options, visitorKeys) {
46261 if (options.considerGetters) {
46262 return true;
46263 }
46264
46265 if (options.considerImplicitTypeConversion && node.computed && node.property.type !== "Literal") {
46266 return true;
46267 }
46268
46269 return this.$visitChildren(node, options, visitorKeys);
46270 },
46271
46272 MethodDefinition(node, options, visitorKeys) {
46273 if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
46274 return true;
46275 }
46276
46277 return this.$visitChildren(node, options, visitorKeys);
46278 },
46279
46280 NewExpression() {
46281 return true;
46282 },
46283
46284 Property(node, options, visitorKeys) {
46285 if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
46286 return true;
46287 }
46288
46289 return this.$visitChildren(node, options, visitorKeys);
46290 },
46291
46292 PropertyDefinition(node, options, visitorKeys) {
46293 if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
46294 return true;
46295 }
46296
46297 return this.$visitChildren(node, options, visitorKeys);
46298 },
46299
46300 UnaryExpression(node, options, visitorKeys) {
46301 if (node.operator === "delete") {
46302 return true;
46303 }
46304
46305 if (options.considerImplicitTypeConversion && typeConversionUnaryOps.has(node.operator) && node.argument.type !== "Literal") {
46306 return true;
46307 }
46308
46309 return this.$visitChildren(node, options, visitorKeys);
46310 },
46311
46312 UpdateExpression() {
46313 return true;
46314 },
46315
46316 YieldExpression() {
46317 return true;
46318 }
46319
46320 }));
46321 /**
46322 * Check whether a given node has any side effect or not.
46323 * @param {Node} node The node to get.
46324 * @param {SourceCode} sourceCode The source code object.
46325 * @param {object} [options] The option object.
46326 * @param {boolean} [options.considerGetters=false] If `true` then it considers member accesses as the node which has side effects.
46327 * @param {boolean} [options.considerImplicitTypeConversion=false] If `true` then it considers implicit type conversion as the node which has side effects.
46328 * @param {object} [options.visitorKeys=evk.KEYS] The keys to traverse nodes. Use `context.getSourceCode().visitorKeys`.
46329 * @returns {boolean} `true` if the node has a certain side effect.
46330 */
46331
46332 function hasSideEffect(node, sourceCode) {
46333 let {
46334 considerGetters = false,
46335 considerImplicitTypeConversion = false
46336 } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
46337 return visitor.$visit(node, {
46338 considerGetters,
46339 considerImplicitTypeConversion
46340 }, sourceCode.visitorKeys || evk.KEYS);
46341 }
46342 /**
46343 * Get the left parenthesis of the parent node syntax if it exists.
46344 * E.g., `if (a) {}` then the `(`.
46345 * @param {Node} node The AST node to check.
46346 * @param {SourceCode} sourceCode The source code object to get tokens.
46347 * @returns {Token|null} The left parenthesis of the parent node syntax
46348 */
46349
46350
46351 function getParentSyntaxParen(node, sourceCode) {
46352 const parent = node.parent;
46353
46354 switch (parent.type) {
46355 case "CallExpression":
46356 case "NewExpression":
46357 if (parent.arguments.length === 1 && parent.arguments[0] === node) {
46358 return sourceCode.getTokenAfter(parent.callee, isOpeningParenToken);
46359 }
46360
46361 return null;
46362
46363 case "DoWhileStatement":
46364 if (parent.test === node) {
46365 return sourceCode.getTokenAfter(parent.body, isOpeningParenToken);
46366 }
46367
46368 return null;
46369
46370 case "IfStatement":
46371 case "WhileStatement":
46372 if (parent.test === node) {
46373 return sourceCode.getFirstToken(parent, 1);
46374 }
46375
46376 return null;
46377
46378 case "ImportExpression":
46379 if (parent.source === node) {
46380 return sourceCode.getFirstToken(parent, 1);
46381 }
46382
46383 return null;
46384
46385 case "SwitchStatement":
46386 if (parent.discriminant === node) {
46387 return sourceCode.getFirstToken(parent, 1);
46388 }
46389
46390 return null;
46391
46392 case "WithStatement":
46393 if (parent.object === node) {
46394 return sourceCode.getFirstToken(parent, 1);
46395 }
46396
46397 return null;
46398
46399 default:
46400 return null;
46401 }
46402 }
46403 /**
46404 * Check whether a given node is parenthesized or not.
46405 * @param {number} times The number of parantheses.
46406 * @param {Node} node The AST node to check.
46407 * @param {SourceCode} sourceCode The source code object to get tokens.
46408 * @returns {boolean} `true` if the node is parenthesized the given times.
46409 */
46410
46411 /**
46412 * Check whether a given node is parenthesized or not.
46413 * @param {Node} node The AST node to check.
46414 * @param {SourceCode} sourceCode The source code object to get tokens.
46415 * @returns {boolean} `true` if the node is parenthesized.
46416 */
46417
46418
46419 function isParenthesized(timesOrNode, nodeOrSourceCode, optionalSourceCode) {
46420 let times, node, sourceCode, maybeLeftParen, maybeRightParen;
46421
46422 if (typeof timesOrNode === "number") {
46423 times = timesOrNode | 0;
46424 node = nodeOrSourceCode;
46425 sourceCode = optionalSourceCode;
46426
46427 if (!(times >= 1)) {
46428 throw new TypeError("'times' should be a positive integer.");
46429 }
46430 } else {
46431 times = 1;
46432 node = timesOrNode;
46433 sourceCode = nodeOrSourceCode;
46434 }
46435
46436 if (node == null || // `CatchClause.param` can't be parenthesized, example `try {} catch (error) {}`
46437 node.parent.type === "CatchClause" && node.parent.param === node) {
46438 return false;
46439 }
46440
46441 maybeLeftParen = maybeRightParen = node;
46442
46443 do {
46444 maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen);
46445 maybeRightParen = sourceCode.getTokenAfter(maybeRightParen);
46446 } while (maybeLeftParen != null && maybeRightParen != null && isOpeningParenToken(maybeLeftParen) && isClosingParenToken(maybeRightParen) && // Avoid false positive such as `if (a) {}`
46447 maybeLeftParen !== getParentSyntaxParen(node, sourceCode) && --times > 0);
46448
46449 return times === 0;
46450 }
46451 /**
46452 * @author Toru Nagashima <https://github.com/mysticatea>
46453 * See LICENSE file in root directory for full license.
46454 */
46455
46456
46457 const placeholder = /\$(?:[$&`']|[1-9][0-9]?)/gu;
46458 /** @type {WeakMap<PatternMatcher, {pattern:RegExp,escaped:boolean}>} */
46459
46460 const internal = new WeakMap();
46461 /**
46462 * Check whether a given character is escaped or not.
46463 * @param {string} str The string to check.
46464 * @param {number} index The location of the character to check.
46465 * @returns {boolean} `true` if the character is escaped.
46466 */
46467
46468 function isEscaped(str, index) {
46469 let escaped = false;
46470
46471 for (let i = index - 1; i >= 0 && str.charCodeAt(i) === 0x5c; --i) {
46472 escaped = !escaped;
46473 }
46474
46475 return escaped;
46476 }
46477 /**
46478 * Replace a given string by a given matcher.
46479 * @param {PatternMatcher} matcher The pattern matcher.
46480 * @param {string} str The string to be replaced.
46481 * @param {string} replacement The new substring to replace each matched part.
46482 * @returns {string} The replaced string.
46483 */
46484
46485
46486 function replaceS(matcher, str, replacement) {
46487 const chunks = [];
46488 let index = 0;
46489 /** @type {RegExpExecArray} */
46490
46491 let match = null;
46492 /**
46493 * @param {string} key The placeholder.
46494 * @returns {string} The replaced string.
46495 */
46496
46497 function replacer(key) {
46498 switch (key) {
46499 case "$$":
46500 return "$";
46501
46502 case "$&":
46503 return match[0];
46504
46505 case "$`":
46506 return str.slice(0, match.index);
46507
46508 case "$'":
46509 return str.slice(match.index + match[0].length);
46510
46511 default:
46512 {
46513 const i = key.slice(1);
46514
46515 if (i in match) {
46516 return match[i];
46517 }
46518
46519 return key;
46520 }
46521 }
46522 }
46523
46524 for (match of matcher.execAll(str)) {
46525 chunks.push(str.slice(index, match.index));
46526 chunks.push(replacement.replace(placeholder, replacer));
46527 index = match.index + match[0].length;
46528 }
46529
46530 chunks.push(str.slice(index));
46531 return chunks.join("");
46532 }
46533 /**
46534 * Replace a given string by a given matcher.
46535 * @param {PatternMatcher} matcher The pattern matcher.
46536 * @param {string} str The string to be replaced.
46537 * @param {(...strs[])=>string} replace The function to replace each matched part.
46538 * @returns {string} The replaced string.
46539 */
46540
46541
46542 function replaceF(matcher, str, replace) {
46543 const chunks = [];
46544 let index = 0;
46545
46546 for (const match of matcher.execAll(str)) {
46547 chunks.push(str.slice(index, match.index));
46548 chunks.push(String(replace(...match, match.index, match.input)));
46549 index = match.index + match[0].length;
46550 }
46551
46552 chunks.push(str.slice(index));
46553 return chunks.join("");
46554 }
46555 /**
46556 * The class to find patterns as considering escape sequences.
46557 */
46558
46559
46560 class PatternMatcher {
46561 /**
46562 * Initialize this matcher.
46563 * @param {RegExp} pattern The pattern to match.
46564 * @param {{escaped:boolean}} options The options.
46565 */
46566 constructor(pattern) {
46567 let {
46568 escaped = false
46569 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
46570
46571 if (!(pattern instanceof RegExp)) {
46572 throw new TypeError("'pattern' should be a RegExp instance.");
46573 }
46574
46575 if (!pattern.flags.includes("g")) {
46576 throw new Error("'pattern' should contains 'g' flag.");
46577 }
46578
46579 internal.set(this, {
46580 pattern: new RegExp(pattern.source, pattern.flags),
46581 escaped: Boolean(escaped)
46582 });
46583 }
46584 /**
46585 * Find the pattern in a given string.
46586 * @param {string} str The string to find.
46587 * @returns {IterableIterator<RegExpExecArray>} The iterator which iterate the matched information.
46588 */
46589
46590
46591 *execAll(str) {
46592 const {
46593 pattern,
46594 escaped
46595 } = internal.get(this);
46596 let match = null;
46597 let lastIndex = 0;
46598 pattern.lastIndex = 0;
46599
46600 while ((match = pattern.exec(str)) != null) {
46601 if (escaped || !isEscaped(str, match.index)) {
46602 lastIndex = pattern.lastIndex;
46603 yield match;
46604 pattern.lastIndex = lastIndex;
46605 }
46606 }
46607 }
46608 /**
46609 * Check whether the pattern is found in a given string.
46610 * @param {string} str The string to check.
46611 * @returns {boolean} `true` if the pattern was found in the string.
46612 */
46613
46614
46615 test(str) {
46616 const it = this.execAll(str);
46617 const ret = it.next();
46618 return !ret.done;
46619 }
46620 /**
46621 * Replace a given string.
46622 * @param {string} str The string to be replaced.
46623 * @param {(string|((...strs:string[])=>string))} replacer The string or function to replace. This is the same as the 2nd argument of `String.prototype.replace`.
46624 * @returns {string} The replaced string.
46625 */
46626
46627
46628 [Symbol.replace](str, replacer) {
46629 return typeof replacer === "function" ? replaceF(this, String(str), replacer) : replaceS(this, String(str), String(replacer));
46630 }
46631
46632 }
46633
46634 const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u;
46635 const has = Function.call.bind(Object.hasOwnProperty);
46636 const READ = Symbol("read");
46637 const CALL = Symbol("call");
46638 const CONSTRUCT = Symbol("construct");
46639 const ESM = Symbol("esm");
46640 const requireCall = {
46641 require: {
46642 [CALL]: true
46643 }
46644 };
46645 /**
46646 * Check whether a given variable is modified or not.
46647 * @param {Variable} variable The variable to check.
46648 * @returns {boolean} `true` if the variable is modified.
46649 */
46650
46651 function isModifiedGlobal(variable) {
46652 return variable == null || variable.defs.length !== 0 || variable.references.some(r => r.isWrite());
46653 }
46654 /**
46655 * Check if the value of a given node is passed through to the parent syntax as-is.
46656 * For example, `a` and `b` in (`a || b` and `c ? a : b`) are passed through.
46657 * @param {Node} node A node to check.
46658 * @returns {boolean} `true` if the node is passed through.
46659 */
46660
46661
46662 function isPassThrough(node) {
46663 const parent = node.parent;
46664
46665 switch (parent && parent.type) {
46666 case "ConditionalExpression":
46667 return parent.consequent === node || parent.alternate === node;
46668
46669 case "LogicalExpression":
46670 return true;
46671
46672 case "SequenceExpression":
46673 return parent.expressions[parent.expressions.length - 1] === node;
46674
46675 case "ChainExpression":
46676 return true;
46677
46678 default:
46679 return false;
46680 }
46681 }
46682 /**
46683 * The reference tracker.
46684 */
46685
46686
46687 class ReferenceTracker {
46688 /**
46689 * Initialize this tracker.
46690 * @param {Scope} globalScope The global scope.
46691 * @param {object} [options] The options.
46692 * @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules.
46693 * @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object.
46694 */
46695 constructor(globalScope) {
46696 let {
46697 mode = "strict",
46698 globalObjectNames = ["global", "globalThis", "self", "window"]
46699 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
46700 this.variableStack = [];
46701 this.globalScope = globalScope;
46702 this.mode = mode;
46703 this.globalObjectNames = globalObjectNames.slice(0);
46704 }
46705 /**
46706 * Iterate the references of global variables.
46707 * @param {object} traceMap The trace map.
46708 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
46709 */
46710
46711
46712 *iterateGlobalReferences(traceMap) {
46713 for (const key of Object.keys(traceMap)) {
46714 const nextTraceMap = traceMap[key];
46715 const path = [key];
46716 const variable = this.globalScope.set.get(key);
46717
46718 if (isModifiedGlobal(variable)) {
46719 continue;
46720 }
46721
46722 yield* this._iterateVariableReferences(variable, path, nextTraceMap, true);
46723 }
46724
46725 for (const key of this.globalObjectNames) {
46726 const path = [];
46727 const variable = this.globalScope.set.get(key);
46728
46729 if (isModifiedGlobal(variable)) {
46730 continue;
46731 }
46732
46733 yield* this._iterateVariableReferences(variable, path, traceMap, false);
46734 }
46735 }
46736 /**
46737 * Iterate the references of CommonJS modules.
46738 * @param {object} traceMap The trace map.
46739 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
46740 */
46741
46742
46743 *iterateCjsReferences(traceMap) {
46744 for (const {
46745 node
46746 } of this.iterateGlobalReferences(requireCall)) {
46747 const key = getStringIfConstant(node.arguments[0]);
46748
46749 if (key == null || !has(traceMap, key)) {
46750 continue;
46751 }
46752
46753 const nextTraceMap = traceMap[key];
46754 const path = [key];
46755
46756 if (nextTraceMap[READ]) {
46757 yield {
46758 node,
46759 path,
46760 type: READ,
46761 info: nextTraceMap[READ]
46762 };
46763 }
46764
46765 yield* this._iteratePropertyReferences(node, path, nextTraceMap);
46766 }
46767 }
46768 /**
46769 * Iterate the references of ES modules.
46770 * @param {object} traceMap The trace map.
46771 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
46772 */
46773
46774
46775 *iterateEsmReferences(traceMap) {
46776 const programNode = this.globalScope.block;
46777
46778 for (const node of programNode.body) {
46779 if (!IMPORT_TYPE.test(node.type) || node.source == null) {
46780 continue;
46781 }
46782
46783 const moduleId = node.source.value;
46784
46785 if (!has(traceMap, moduleId)) {
46786 continue;
46787 }
46788
46789 const nextTraceMap = traceMap[moduleId];
46790 const path = [moduleId];
46791
46792 if (nextTraceMap[READ]) {
46793 yield {
46794 node,
46795 path,
46796 type: READ,
46797 info: nextTraceMap[READ]
46798 };
46799 }
46800
46801 if (node.type === "ExportAllDeclaration") {
46802 for (const key of Object.keys(nextTraceMap)) {
46803 const exportTraceMap = nextTraceMap[key];
46804
46805 if (exportTraceMap[READ]) {
46806 yield {
46807 node,
46808 path: path.concat(key),
46809 type: READ,
46810 info: exportTraceMap[READ]
46811 };
46812 }
46813 }
46814 } else {
46815 for (const specifier of node.specifiers) {
46816 const esm = has(nextTraceMap, ESM);
46817
46818 const it = this._iterateImportReferences(specifier, path, esm ? nextTraceMap : this.mode === "legacy" ? {
46819 default: nextTraceMap,
46820 ...nextTraceMap
46821 } : {
46822 default: nextTraceMap
46823 });
46824
46825 if (esm) {
46826 yield* it;
46827 } else {
46828 for (const report of it) {
46829 report.path = report.path.filter(exceptDefault);
46830
46831 if (report.path.length >= 2 || report.type !== READ) {
46832 yield report;
46833 }
46834 }
46835 }
46836 }
46837 }
46838 }
46839 }
46840 /**
46841 * Iterate the references for a given variable.
46842 * @param {Variable} variable The variable to iterate that references.
46843 * @param {string[]} path The current path.
46844 * @param {object} traceMap The trace map.
46845 * @param {boolean} shouldReport = The flag to report those references.
46846 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
46847 */
46848
46849
46850 *_iterateVariableReferences(variable, path, traceMap, shouldReport) {
46851 if (this.variableStack.includes(variable)) {
46852 return;
46853 }
46854
46855 this.variableStack.push(variable);
46856
46857 try {
46858 for (const reference of variable.references) {
46859 if (!reference.isRead()) {
46860 continue;
46861 }
46862
46863 const node = reference.identifier;
46864
46865 if (shouldReport && traceMap[READ]) {
46866 yield {
46867 node,
46868 path,
46869 type: READ,
46870 info: traceMap[READ]
46871 };
46872 }
46873
46874 yield* this._iteratePropertyReferences(node, path, traceMap);
46875 }
46876 } finally {
46877 this.variableStack.pop();
46878 }
46879 }
46880 /**
46881 * Iterate the references for a given AST node.
46882 * @param rootNode The AST node to iterate references.
46883 * @param {string[]} path The current path.
46884 * @param {object} traceMap The trace map.
46885 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
46886 */
46887 //eslint-disable-next-line complexity
46888
46889
46890 *_iteratePropertyReferences(rootNode, path, traceMap) {
46891 let node = rootNode;
46892
46893 while (isPassThrough(node)) {
46894 node = node.parent;
46895 }
46896
46897 const parent = node.parent;
46898
46899 if (parent.type === "MemberExpression") {
46900 if (parent.object === node) {
46901 const key = getPropertyName(parent);
46902
46903 if (key == null || !has(traceMap, key)) {
46904 return;
46905 }
46906
46907 path = path.concat(key); //eslint-disable-line no-param-reassign
46908
46909 const nextTraceMap = traceMap[key];
46910
46911 if (nextTraceMap[READ]) {
46912 yield {
46913 node: parent,
46914 path,
46915 type: READ,
46916 info: nextTraceMap[READ]
46917 };
46918 }
46919
46920 yield* this._iteratePropertyReferences(parent, path, nextTraceMap);
46921 }
46922
46923 return;
46924 }
46925
46926 if (parent.type === "CallExpression") {
46927 if (parent.callee === node && traceMap[CALL]) {
46928 yield {
46929 node: parent,
46930 path,
46931 type: CALL,
46932 info: traceMap[CALL]
46933 };
46934 }
46935
46936 return;
46937 }
46938
46939 if (parent.type === "NewExpression") {
46940 if (parent.callee === node && traceMap[CONSTRUCT]) {
46941 yield {
46942 node: parent,
46943 path,
46944 type: CONSTRUCT,
46945 info: traceMap[CONSTRUCT]
46946 };
46947 }
46948
46949 return;
46950 }
46951
46952 if (parent.type === "AssignmentExpression") {
46953 if (parent.right === node) {
46954 yield* this._iterateLhsReferences(parent.left, path, traceMap);
46955 yield* this._iteratePropertyReferences(parent, path, traceMap);
46956 }
46957
46958 return;
46959 }
46960
46961 if (parent.type === "AssignmentPattern") {
46962 if (parent.right === node) {
46963 yield* this._iterateLhsReferences(parent.left, path, traceMap);
46964 }
46965
46966 return;
46967 }
46968
46969 if (parent.type === "VariableDeclarator") {
46970 if (parent.init === node) {
46971 yield* this._iterateLhsReferences(parent.id, path, traceMap);
46972 }
46973 }
46974 }
46975 /**
46976 * Iterate the references for a given Pattern node.
46977 * @param {Node} patternNode The Pattern node to iterate references.
46978 * @param {string[]} path The current path.
46979 * @param {object} traceMap The trace map.
46980 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
46981 */
46982
46983
46984 *_iterateLhsReferences(patternNode, path, traceMap) {
46985 if (patternNode.type === "Identifier") {
46986 const variable = findVariable(this.globalScope, patternNode);
46987
46988 if (variable != null) {
46989 yield* this._iterateVariableReferences(variable, path, traceMap, false);
46990 }
46991
46992 return;
46993 }
46994
46995 if (patternNode.type === "ObjectPattern") {
46996 for (const property of patternNode.properties) {
46997 const key = getPropertyName(property);
46998
46999 if (key == null || !has(traceMap, key)) {
47000 continue;
47001 }
47002
47003 const nextPath = path.concat(key);
47004 const nextTraceMap = traceMap[key];
47005
47006 if (nextTraceMap[READ]) {
47007 yield {
47008 node: property,
47009 path: nextPath,
47010 type: READ,
47011 info: nextTraceMap[READ]
47012 };
47013 }
47014
47015 yield* this._iterateLhsReferences(property.value, nextPath, nextTraceMap);
47016 }
47017
47018 return;
47019 }
47020
47021 if (patternNode.type === "AssignmentPattern") {
47022 yield* this._iterateLhsReferences(patternNode.left, path, traceMap);
47023 }
47024 }
47025 /**
47026 * Iterate the references for a given ModuleSpecifier node.
47027 * @param {Node} specifierNode The ModuleSpecifier node to iterate references.
47028 * @param {string[]} path The current path.
47029 * @param {object} traceMap The trace map.
47030 * @returns {IterableIterator<{node:Node,path:string[],type:symbol,info:any}>} The iterator to iterate references.
47031 */
47032
47033
47034 *_iterateImportReferences(specifierNode, path, traceMap) {
47035 const type = specifierNode.type;
47036
47037 if (type === "ImportSpecifier" || type === "ImportDefaultSpecifier") {
47038 const key = type === "ImportDefaultSpecifier" ? "default" : specifierNode.imported.name;
47039
47040 if (!has(traceMap, key)) {
47041 return;
47042 }
47043
47044 path = path.concat(key); //eslint-disable-line no-param-reassign
47045
47046 const nextTraceMap = traceMap[key];
47047
47048 if (nextTraceMap[READ]) {
47049 yield {
47050 node: specifierNode,
47051 path,
47052 type: READ,
47053 info: nextTraceMap[READ]
47054 };
47055 }
47056
47057 yield* this._iterateVariableReferences(findVariable(this.globalScope, specifierNode.local), path, nextTraceMap, false);
47058 return;
47059 }
47060
47061 if (type === "ImportNamespaceSpecifier") {
47062 yield* this._iterateVariableReferences(findVariable(this.globalScope, specifierNode.local), path, traceMap, false);
47063 return;
47064 }
47065
47066 if (type === "ExportSpecifier") {
47067 const key = specifierNode.local.name;
47068
47069 if (!has(traceMap, key)) {
47070 return;
47071 }
47072
47073 path = path.concat(key); //eslint-disable-line no-param-reassign
47074
47075 const nextTraceMap = traceMap[key];
47076
47077 if (nextTraceMap[READ]) {
47078 yield {
47079 node: specifierNode,
47080 path,
47081 type: READ,
47082 info: nextTraceMap[READ]
47083 };
47084 }
47085 }
47086 }
47087
47088 }
47089
47090 ReferenceTracker.READ = READ;
47091 ReferenceTracker.CALL = CALL;
47092 ReferenceTracker.CONSTRUCT = CONSTRUCT;
47093 ReferenceTracker.ESM = ESM;
47094 /**
47095 * This is a predicate function for Array#filter.
47096 * @param {string} name A name part.
47097 * @param {number} index The index of the name.
47098 * @returns {boolean} `false` if it's default.
47099 */
47100
47101 function exceptDefault(name, index) {
47102 return !(index === 1 && name === "default");
47103 }
47104
47105 var index = {
47106 CALL,
47107 CONSTRUCT,
47108 ESM,
47109 findVariable,
47110 getFunctionHeadLocation,
47111 getFunctionNameWithKind,
47112 getInnermostScope,
47113 getPropertyName,
47114 getStaticValue,
47115 getStringIfConstant,
47116 hasSideEffect,
47117 isArrowToken,
47118 isClosingBraceToken,
47119 isClosingBracketToken,
47120 isClosingParenToken,
47121 isColonToken,
47122 isCommaToken,
47123 isCommentToken,
47124 isNotArrowToken,
47125 isNotClosingBraceToken,
47126 isNotClosingBracketToken,
47127 isNotClosingParenToken,
47128 isNotColonToken,
47129 isNotCommaToken,
47130 isNotCommentToken,
47131 isNotOpeningBraceToken,
47132 isNotOpeningBracketToken,
47133 isNotOpeningParenToken,
47134 isNotSemicolonToken,
47135 isOpeningBraceToken,
47136 isOpeningBracketToken,
47137 isOpeningParenToken,
47138 isParenthesized,
47139 isSemicolonToken,
47140 PatternMatcher,
47141 READ,
47142 ReferenceTracker
47143 };
47144 exports.CALL = CALL;
47145 exports.CONSTRUCT = CONSTRUCT;
47146 exports.ESM = ESM;
47147 exports.PatternMatcher = PatternMatcher;
47148 exports.READ = READ;
47149 exports.ReferenceTracker = ReferenceTracker;
47150 exports["default"] = index;
47151 exports.findVariable = findVariable;
47152 exports.getFunctionHeadLocation = getFunctionHeadLocation;
47153 exports.getFunctionNameWithKind = getFunctionNameWithKind;
47154 exports.getInnermostScope = getInnermostScope;
47155 exports.getPropertyName = getPropertyName;
47156 exports.getStaticValue = getStaticValue;
47157 exports.getStringIfConstant = getStringIfConstant;
47158 exports.hasSideEffect = hasSideEffect;
47159 exports.isArrowToken = isArrowToken;
47160 exports.isClosingBraceToken = isClosingBraceToken;
47161 exports.isClosingBracketToken = isClosingBracketToken;
47162 exports.isClosingParenToken = isClosingParenToken;
47163 exports.isColonToken = isColonToken;
47164 exports.isCommaToken = isCommaToken;
47165 exports.isCommentToken = isCommentToken;
47166 exports.isNotArrowToken = isNotArrowToken;
47167 exports.isNotClosingBraceToken = isNotClosingBraceToken;
47168 exports.isNotClosingBracketToken = isNotClosingBracketToken;
47169 exports.isNotClosingParenToken = isNotClosingParenToken;
47170 exports.isNotColonToken = isNotColonToken;
47171 exports.isNotCommaToken = isNotCommaToken;
47172 exports.isNotCommentToken = isNotCommentToken;
47173 exports.isNotOpeningBraceToken = isNotOpeningBraceToken;
47174 exports.isNotOpeningBracketToken = isNotOpeningBracketToken;
47175 exports.isNotOpeningParenToken = isNotOpeningParenToken;
47176 exports.isNotSemicolonToken = isNotSemicolonToken;
47177 exports.isOpeningBraceToken = isOpeningBraceToken;
47178 exports.isOpeningBracketToken = isOpeningBracketToken;
47179 exports.isOpeningParenToken = isOpeningParenToken;
47180 exports.isParenthesized = isParenthesized;
47181 exports.isSemicolonToken = isSemicolonToken;
47182
47183 /***/ }),
47184 /* 502 */
47185 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
47186
47187 "use strict";
47188 /**
47189 * @author Toru Nagashima <https://github.com/mysticatea>
47190 * See LICENSE file in root directory for full license.
47191 */
47192
47193
47194 const KEYS = __webpack_require__(503); // Types.
47195
47196
47197 const NODE_TYPES = Object.freeze(Object.keys(KEYS)); // Freeze the keys.
47198
47199 for (const type of NODE_TYPES) {
47200 Object.freeze(KEYS[type]);
47201 }
47202
47203 Object.freeze(KEYS); // List to ignore keys.
47204
47205 const KEY_BLACKLIST = new Set(["parent", "leadingComments", "trailingComments"]);
47206 /**
47207 * Check whether a given key should be used or not.
47208 * @param {string} key The key to check.
47209 * @returns {boolean} `true` if the key should be used.
47210 */
47211
47212 function filterKey(key) {
47213 return !KEY_BLACKLIST.has(key) && key[0] !== "_";
47214 } //------------------------------------------------------------------------------
47215 // Public interfaces
47216 //------------------------------------------------------------------------------
47217
47218
47219 module.exports = Object.freeze({
47220 /**
47221 * Visitor keys.
47222 * @type {{ [type: string]: string[] | undefined }}
47223 */
47224 KEYS,
47225
47226 /**
47227 * Get visitor keys of a given node.
47228 * @param {Object} node The AST node to get keys.
47229 * @returns {string[]} Visitor keys of the node.
47230 */
47231 getKeys(node) {
47232 return Object.keys(node).filter(filterKey);
47233 },
47234
47235 // Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
47236 // eslint-disable-next-line valid-jsdoc
47237
47238 /**
47239 * Make the union set with `KEYS` and given keys.
47240 * @param {Object} additionalKeys The additional keys.
47241 * @returns {{ [type: string]: string[] | undefined }} The union set.
47242 */
47243 unionWith(additionalKeys) {
47244 const retv = Object.assign({}, KEYS);
47245
47246 for (const type of Object.keys(additionalKeys)) {
47247 if (retv.hasOwnProperty(type)) {
47248 const keys = new Set(additionalKeys[type]);
47249
47250 for (const key of retv[type]) {
47251 keys.add(key);
47252 }
47253
47254 retv[type] = Object.freeze(Array.from(keys));
47255 } else {
47256 retv[type] = Object.freeze(Array.from(additionalKeys[type]));
47257 }
47258 }
47259
47260 return Object.freeze(retv);
47261 }
47262
47263 });
47264
47265 /***/ }),
47266 /* 503 */
47267 /***/ ((module) => {
47268
47269 "use strict";
47270 module.exports = JSON.parse('{"AssignmentExpression":["left","right"],"AssignmentPattern":["left","right"],"ArrayExpression":["elements"],"ArrayPattern":["elements"],"ArrowFunctionExpression":["params","body"],"AwaitExpression":["argument"],"BlockStatement":["body"],"BinaryExpression":["left","right"],"BreakStatement":["label"],"CallExpression":["callee","arguments"],"CatchClause":["param","body"],"ChainExpression":["expression"],"ClassBody":["body"],"ClassDeclaration":["id","superClass","body"],"ClassExpression":["id","superClass","body"],"ConditionalExpression":["test","consequent","alternate"],"ContinueStatement":["label"],"DebuggerStatement":[],"DoWhileStatement":["body","test"],"EmptyStatement":[],"ExportAllDeclaration":["exported","source"],"ExportDefaultDeclaration":["declaration"],"ExportNamedDeclaration":["declaration","specifiers","source"],"ExportSpecifier":["exported","local"],"ExpressionStatement":["expression"],"ExperimentalRestProperty":["argument"],"ExperimentalSpreadProperty":["argument"],"ForStatement":["init","test","update","body"],"ForInStatement":["left","right","body"],"ForOfStatement":["left","right","body"],"FunctionDeclaration":["id","params","body"],"FunctionExpression":["id","params","body"],"Identifier":[],"IfStatement":["test","consequent","alternate"],"ImportDeclaration":["specifiers","source"],"ImportDefaultSpecifier":["local"],"ImportExpression":["source"],"ImportNamespaceSpecifier":["local"],"ImportSpecifier":["imported","local"],"JSXAttribute":["name","value"],"JSXClosingElement":["name"],"JSXElement":["openingElement","children","closingElement"],"JSXEmptyExpression":[],"JSXExpressionContainer":["expression"],"JSXIdentifier":[],"JSXMemberExpression":["object","property"],"JSXNamespacedName":["namespace","name"],"JSXOpeningElement":["name","attributes"],"JSXSpreadAttribute":["argument"],"JSXText":[],"JSXFragment":["openingFragment","children","closingFragment"],"Literal":[],"LabeledStatement":["label","body"],"LogicalExpression":["left","right"],"MemberExpression":["object","property"],"MetaProperty":["meta","property"],"MethodDefinition":["key","value"],"NewExpression":["callee","arguments"],"ObjectExpression":["properties"],"ObjectPattern":["properties"],"PrivateIdentifier":[],"Program":["body"],"Property":["key","value"],"PropertyDefinition":["key","value"],"RestElement":["argument"],"ReturnStatement":["argument"],"SequenceExpression":["expressions"],"SpreadElement":["argument"],"Super":[],"SwitchStatement":["discriminant","cases"],"SwitchCase":["test","consequent"],"TaggedTemplateExpression":["tag","quasi"],"TemplateElement":[],"TemplateLiteral":["quasis","expressions"],"ThisExpression":[],"ThrowStatement":["argument"],"TryStatement":["block","handler","finalizer"],"UnaryExpression":["argument"],"UpdateExpression":["argument"],"VariableDeclaration":["declarations"],"VariableDeclarator":["id","init"],"WhileStatement":["test","body"],"WithStatement":["object","body"],"YieldExpression":["argument"]}');
47271
47272 /***/ }),
47273 /* 504 */
47274 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
47275
47276 "use strict";
47277 /**
47278 * @fileoverview Object to handle access and retrieval of tokens.
47279 * @author Brandon Mills
47280 */
47281 //------------------------------------------------------------------------------
47282 // Requirements
47283 //------------------------------------------------------------------------------
47284
47285 const assert = __webpack_require__(431);
47286
47287 const {
47288 isCommentToken
47289 } = __webpack_require__(501);
47290
47291 const cursors = __webpack_require__(505);
47292
47293 const ForwardTokenCursor = __webpack_require__(513);
47294
47295 const PaddedTokenCursor = __webpack_require__(516);
47296
47297 const utils = __webpack_require__(508); //------------------------------------------------------------------------------
47298 // Helpers
47299 //------------------------------------------------------------------------------
47300
47301
47302 const TOKENS = Symbol("tokens");
47303 const COMMENTS = Symbol("comments");
47304 const INDEX_MAP = Symbol("indexMap");
47305 /**
47306 * Creates the map from locations to indices in `tokens`.
47307 *
47308 * The first/last location of tokens is mapped to the index of the token.
47309 * The first/last location of comments is mapped to the index of the next token of each comment.
47310 * @param {Token[]} tokens The array of tokens.
47311 * @param {Comment[]} comments The array of comments.
47312 * @returns {Object} The map from locations to indices in `tokens`.
47313 * @private
47314 */
47315
47316 function createIndexMap(tokens, comments) {
47317 const map = Object.create(null);
47318 let tokenIndex = 0;
47319 let commentIndex = 0;
47320 let nextStart = 0;
47321 let range = null;
47322
47323 while (tokenIndex < tokens.length || commentIndex < comments.length) {
47324 nextStart = commentIndex < comments.length ? comments[commentIndex].range[0] : Number.MAX_SAFE_INTEGER;
47325
47326 while (tokenIndex < tokens.length && (range = tokens[tokenIndex].range)[0] < nextStart) {
47327 map[range[0]] = tokenIndex;
47328 map[range[1] - 1] = tokenIndex;
47329 tokenIndex += 1;
47330 }
47331
47332 nextStart = tokenIndex < tokens.length ? tokens[tokenIndex].range[0] : Number.MAX_SAFE_INTEGER;
47333
47334 while (commentIndex < comments.length && (range = comments[commentIndex].range)[0] < nextStart) {
47335 map[range[0]] = tokenIndex;
47336 map[range[1] - 1] = tokenIndex;
47337 commentIndex += 1;
47338 }
47339 }
47340
47341 return map;
47342 }
47343 /**
47344 * Creates the cursor iterates tokens with options.
47345 * @param {CursorFactory} factory The cursor factory to initialize cursor.
47346 * @param {Token[]} tokens The array of tokens.
47347 * @param {Comment[]} comments The array of comments.
47348 * @param {Object} indexMap The map from locations to indices in `tokens`.
47349 * @param {number} startLoc The start location of the iteration range.
47350 * @param {number} endLoc The end location of the iteration range.
47351 * @param {number|Function|Object} [opts=0] The option object. If this is a number then it's `opts.skip`. If this is a function then it's `opts.filter`.
47352 * @param {boolean} [opts.includeComments=false] The flag to iterate comments as well.
47353 * @param {Function|null} [opts.filter=null] The predicate function to choose tokens.
47354 * @param {number} [opts.skip=0] The count of tokens the cursor skips.
47355 * @returns {Cursor} The created cursor.
47356 * @private
47357 */
47358
47359
47360 function createCursorWithSkip(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
47361 let includeComments = false;
47362 let skip = 0;
47363 let filter = null;
47364
47365 if (typeof opts === "number") {
47366 skip = opts | 0;
47367 } else if (typeof opts === "function") {
47368 filter = opts;
47369 } else if (opts) {
47370 includeComments = !!opts.includeComments;
47371 skip = opts.skip | 0;
47372 filter = opts.filter || null;
47373 }
47374
47375 assert(skip >= 0, "options.skip should be zero or a positive integer.");
47376 assert(!filter || typeof filter === "function", "options.filter should be a function.");
47377 return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, -1);
47378 }
47379 /**
47380 * Creates the cursor iterates tokens with options.
47381 * @param {CursorFactory} factory The cursor factory to initialize cursor.
47382 * @param {Token[]} tokens The array of tokens.
47383 * @param {Comment[]} comments The array of comments.
47384 * @param {Object} indexMap The map from locations to indices in `tokens`.
47385 * @param {number} startLoc The start location of the iteration range.
47386 * @param {number} endLoc The end location of the iteration range.
47387 * @param {number|Function|Object} [opts=0] The option object. If this is a number then it's `opts.count`. If this is a function then it's `opts.filter`.
47388 * @param {boolean} [opts.includeComments] The flag to iterate comments as well.
47389 * @param {Function|null} [opts.filter=null] The predicate function to choose tokens.
47390 * @param {number} [opts.count=0] The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
47391 * @returns {Cursor} The created cursor.
47392 * @private
47393 */
47394
47395
47396 function createCursorWithCount(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
47397 let includeComments = false;
47398 let count = 0;
47399 let countExists = false;
47400 let filter = null;
47401
47402 if (typeof opts === "number") {
47403 count = opts | 0;
47404 countExists = true;
47405 } else if (typeof opts === "function") {
47406 filter = opts;
47407 } else if (opts) {
47408 includeComments = !!opts.includeComments;
47409 count = opts.count | 0;
47410 countExists = typeof opts.count === "number";
47411 filter = opts.filter || null;
47412 }
47413
47414 assert(count >= 0, "options.count should be zero or a positive integer.");
47415 assert(!filter || typeof filter === "function", "options.filter should be a function.");
47416 return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, 0, countExists ? count : -1);
47417 }
47418 /**
47419 * Creates the cursor iterates tokens with options.
47420 * This is overload function of the below.
47421 * @param {Token[]} tokens The array of tokens.
47422 * @param {Comment[]} comments The array of comments.
47423 * @param {Object} indexMap The map from locations to indices in `tokens`.
47424 * @param {number} startLoc The start location of the iteration range.
47425 * @param {number} endLoc The end location of the iteration range.
47426 * @param {Function|Object} opts The option object. If this is a function then it's `opts.filter`.
47427 * @param {boolean} [opts.includeComments] The flag to iterate comments as well.
47428 * @param {Function|null} [opts.filter=null] The predicate function to choose tokens.
47429 * @param {number} [opts.count=0] The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
47430 * @returns {Cursor} The created cursor.
47431 * @private
47432 */
47433
47434 /**
47435 * Creates the cursor iterates tokens with options.
47436 * @param {Token[]} tokens The array of tokens.
47437 * @param {Comment[]} comments The array of comments.
47438 * @param {Object} indexMap The map from locations to indices in `tokens`.
47439 * @param {number} startLoc The start location of the iteration range.
47440 * @param {number} endLoc The end location of the iteration range.
47441 * @param {number} [beforeCount=0] The number of tokens before the node to retrieve.
47442 * @param {boolean} [afterCount=0] The number of tokens after the node to retrieve.
47443 * @returns {Cursor} The created cursor.
47444 * @private
47445 */
47446
47447
47448 function createCursorWithPadding(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) {
47449 if (typeof beforeCount === "undefined" && typeof afterCount === "undefined") {
47450 return new ForwardTokenCursor(tokens, comments, indexMap, startLoc, endLoc);
47451 }
47452
47453 if (typeof beforeCount === "number" || typeof beforeCount === "undefined") {
47454 return new PaddedTokenCursor(tokens, comments, indexMap, startLoc, endLoc, beforeCount | 0, afterCount | 0);
47455 }
47456
47457 return createCursorWithCount(cursors.forward, tokens, comments, indexMap, startLoc, endLoc, beforeCount);
47458 }
47459 /**
47460 * Gets comment tokens that are adjacent to the current cursor position.
47461 * @param {Cursor} cursor A cursor instance.
47462 * @returns {Array} An array of comment tokens adjacent to the current cursor position.
47463 * @private
47464 */
47465
47466
47467 function getAdjacentCommentTokensFromCursor(cursor) {
47468 const tokens = [];
47469 let currentToken = cursor.getOneToken();
47470
47471 while (currentToken && isCommentToken(currentToken)) {
47472 tokens.push(currentToken);
47473 currentToken = cursor.getOneToken();
47474 }
47475
47476 return tokens;
47477 } //------------------------------------------------------------------------------
47478 // Exports
47479 //------------------------------------------------------------------------------
47480
47481 /**
47482 * The token store.
47483 *
47484 * This class provides methods to get tokens by locations as fast as possible.
47485 * The methods are a part of public API, so we should be careful if it changes this class.
47486 *
47487 * People can get tokens in O(1) by the hash map which is mapping from the location of tokens/comments to tokens.
47488 * Also people can get a mix of tokens and comments in O(log k), the k is the number of comments.
47489 * Assuming that comments to be much fewer than tokens, this does not make hash map from token's locations to comments to reduce memory cost.
47490 * This uses binary-searching instead for comments.
47491 */
47492
47493
47494 module.exports = class TokenStore {
47495 /**
47496 * Initializes this token store.
47497 * @param {Token[]} tokens The array of tokens.
47498 * @param {Comment[]} comments The array of comments.
47499 */
47500 constructor(tokens, comments) {
47501 this[TOKENS] = tokens;
47502 this[COMMENTS] = comments;
47503 this[INDEX_MAP] = createIndexMap(tokens, comments);
47504 } //--------------------------------------------------------------------------
47505 // Gets single token.
47506 //--------------------------------------------------------------------------
47507
47508 /**
47509 * Gets the token starting at the specified index.
47510 * @param {number} offset Index of the start of the token's range.
47511 * @param {Object} [options=0] The option object.
47512 * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
47513 * @returns {Token|null} The token starting at index, or null if no such token.
47514 */
47515
47516
47517 getTokenByRangeStart(offset, options) {
47518 const includeComments = options && options.includeComments;
47519 const token = cursors.forward.createBaseCursor(this[TOKENS], this[COMMENTS], this[INDEX_MAP], offset, -1, includeComments).getOneToken();
47520
47521 if (token && token.range[0] === offset) {
47522 return token;
47523 }
47524
47525 return null;
47526 }
47527 /**
47528 * Gets the first token of the given node.
47529 * @param {ASTNode} node The AST node.
47530 * @param {number|Function|Object} [options=0] The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.
47531 * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
47532 * @param {Function|null} [options.filter=null] The predicate function to choose tokens.
47533 * @param {number} [options.skip=0] The count of tokens the cursor skips.
47534 * @returns {Token|null} An object representing the token.
47535 */
47536
47537
47538 getFirstToken(node, options) {
47539 return createCursorWithSkip(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], options).getOneToken();
47540 }
47541 /**
47542 * Gets the last token of the given node.
47543 * @param {ASTNode} node The AST node.
47544 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
47545 * @returns {Token|null} An object representing the token.
47546 */
47547
47548
47549 getLastToken(node, options) {
47550 return createCursorWithSkip(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], options).getOneToken();
47551 }
47552 /**
47553 * Gets the token that precedes a given node or token.
47554 * @param {ASTNode|Token|Comment} node The AST node or token.
47555 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
47556 * @returns {Token|null} An object representing the token.
47557 */
47558
47559
47560 getTokenBefore(node, options) {
47561 return createCursorWithSkip(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], -1, node.range[0], options).getOneToken();
47562 }
47563 /**
47564 * Gets the token that follows a given node or token.
47565 * @param {ASTNode|Token|Comment} node The AST node or token.
47566 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
47567 * @returns {Token|null} An object representing the token.
47568 */
47569
47570
47571 getTokenAfter(node, options) {
47572 return createCursorWithSkip(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[1], -1, options).getOneToken();
47573 }
47574 /**
47575 * Gets the first token between two non-overlapping nodes.
47576 * @param {ASTNode|Token|Comment} left Node before the desired token range.
47577 * @param {ASTNode|Token|Comment} right Node after the desired token range.
47578 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
47579 * @returns {Token|null} An object representing the token.
47580 */
47581
47582
47583 getFirstTokenBetween(left, right, options) {
47584 return createCursorWithSkip(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], options).getOneToken();
47585 }
47586 /**
47587 * Gets the last token between two non-overlapping nodes.
47588 * @param {ASTNode|Token|Comment} left Node before the desired token range.
47589 * @param {ASTNode|Token|Comment} right Node after the desired token range.
47590 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstToken()
47591 * @returns {Token|null} An object representing the token.
47592 */
47593
47594
47595 getLastTokenBetween(left, right, options) {
47596 return createCursorWithSkip(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], options).getOneToken();
47597 }
47598 /**
47599 * Gets the token that precedes a given node or token in the token stream.
47600 * This is defined for backward compatibility. Use `includeComments` option instead.
47601 * TODO: We have a plan to remove this in a future major version.
47602 * @param {ASTNode|Token|Comment} node The AST node or token.
47603 * @param {number} [skip=0] A number of tokens to skip.
47604 * @returns {Token|null} An object representing the token.
47605 * @deprecated
47606 */
47607
47608
47609 getTokenOrCommentBefore(node, skip) {
47610 return this.getTokenBefore(node, {
47611 includeComments: true,
47612 skip
47613 });
47614 }
47615 /**
47616 * Gets the token that follows a given node or token in the token stream.
47617 * This is defined for backward compatibility. Use `includeComments` option instead.
47618 * TODO: We have a plan to remove this in a future major version.
47619 * @param {ASTNode|Token|Comment} node The AST node or token.
47620 * @param {number} [skip=0] A number of tokens to skip.
47621 * @returns {Token|null} An object representing the token.
47622 * @deprecated
47623 */
47624
47625
47626 getTokenOrCommentAfter(node, skip) {
47627 return this.getTokenAfter(node, {
47628 includeComments: true,
47629 skip
47630 });
47631 } //--------------------------------------------------------------------------
47632 // Gets multiple tokens.
47633 //--------------------------------------------------------------------------
47634
47635 /**
47636 * Gets the first `count` tokens of the given node.
47637 * @param {ASTNode} node The AST node.
47638 * @param {number|Function|Object} [options=0] The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.
47639 * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
47640 * @param {Function|null} [options.filter=null] The predicate function to choose tokens.
47641 * @param {number} [options.count=0] The maximum count of tokens the cursor iterates.
47642 * @returns {Token[]} Tokens.
47643 */
47644
47645
47646 getFirstTokens(node, options) {
47647 return createCursorWithCount(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], options).getAllTokens();
47648 }
47649 /**
47650 * Gets the last `count` tokens of the given node.
47651 * @param {ASTNode} node The AST node.
47652 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
47653 * @returns {Token[]} Tokens.
47654 */
47655
47656
47657 getLastTokens(node, options) {
47658 return createCursorWithCount(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], options).getAllTokens().reverse();
47659 }
47660 /**
47661 * Gets the `count` tokens that precedes a given node or token.
47662 * @param {ASTNode|Token|Comment} node The AST node or token.
47663 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
47664 * @returns {Token[]} Tokens.
47665 */
47666
47667
47668 getTokensBefore(node, options) {
47669 return createCursorWithCount(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], -1, node.range[0], options).getAllTokens().reverse();
47670 }
47671 /**
47672 * Gets the `count` tokens that follows a given node or token.
47673 * @param {ASTNode|Token|Comment} node The AST node or token.
47674 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
47675 * @returns {Token[]} Tokens.
47676 */
47677
47678
47679 getTokensAfter(node, options) {
47680 return createCursorWithCount(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[1], -1, options).getAllTokens();
47681 }
47682 /**
47683 * Gets the first `count` tokens between two non-overlapping nodes.
47684 * @param {ASTNode|Token|Comment} left Node before the desired token range.
47685 * @param {ASTNode|Token|Comment} right Node after the desired token range.
47686 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
47687 * @returns {Token[]} Tokens between left and right.
47688 */
47689
47690
47691 getFirstTokensBetween(left, right, options) {
47692 return createCursorWithCount(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], options).getAllTokens();
47693 }
47694 /**
47695 * Gets the last `count` tokens between two non-overlapping nodes.
47696 * @param {ASTNode|Token|Comment} left Node before the desired token range.
47697 * @param {ASTNode|Token|Comment} right Node after the desired token range.
47698 * @param {number|Function|Object} [options=0] The option object. Same options as getFirstTokens()
47699 * @returns {Token[]} Tokens between left and right.
47700 */
47701
47702
47703 getLastTokensBetween(left, right, options) {
47704 return createCursorWithCount(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], options).getAllTokens().reverse();
47705 }
47706 /**
47707 * Gets all tokens that are related to the given node.
47708 * @param {ASTNode} node The AST node.
47709 * @param {Function|Object} options The option object. If this is a function then it's `options.filter`.
47710 * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
47711 * @param {Function|null} [options.filter=null] The predicate function to choose tokens.
47712 * @param {number} [options.count=0] The maximum count of tokens the cursor iterates.
47713 * @returns {Token[]} Array of objects representing tokens.
47714 */
47715
47716 /**
47717 * Gets all tokens that are related to the given node.
47718 * @param {ASTNode} node The AST node.
47719 * @param {int} [beforeCount=0] The number of tokens before the node to retrieve.
47720 * @param {int} [afterCount=0] The number of tokens after the node to retrieve.
47721 * @returns {Token[]} Array of objects representing tokens.
47722 */
47723
47724
47725 getTokens(node, beforeCount, afterCount) {
47726 return createCursorWithPadding(this[TOKENS], this[COMMENTS], this[INDEX_MAP], node.range[0], node.range[1], beforeCount, afterCount).getAllTokens();
47727 }
47728 /**
47729 * Gets all of the tokens between two non-overlapping nodes.
47730 * @param {ASTNode|Token|Comment} left Node before the desired token range.
47731 * @param {ASTNode|Token|Comment} right Node after the desired token range.
47732 * @param {Function|Object} options The option object. If this is a function then it's `options.filter`.
47733 * @param {boolean} [options.includeComments=false] The flag to iterate comments as well.
47734 * @param {Function|null} [options.filter=null] The predicate function to choose tokens.
47735 * @param {number} [options.count=0] The maximum count of tokens the cursor iterates.
47736 * @returns {Token[]} Tokens between left and right.
47737 */
47738
47739 /**
47740 * Gets all of the tokens between two non-overlapping nodes.
47741 * @param {ASTNode|Token|Comment} left Node before the desired token range.
47742 * @param {ASTNode|Token|Comment} right Node after the desired token range.
47743 * @param {int} [padding=0] Number of extra tokens on either side of center.
47744 * @returns {Token[]} Tokens between left and right.
47745 */
47746
47747
47748 getTokensBetween(left, right, padding) {
47749 return createCursorWithPadding(this[TOKENS], this[COMMENTS], this[INDEX_MAP], left.range[1], right.range[0], padding, padding).getAllTokens();
47750 } //--------------------------------------------------------------------------
47751 // Others.
47752 //--------------------------------------------------------------------------
47753
47754 /**
47755 * Checks whether any comments exist or not between the given 2 nodes.
47756 * @param {ASTNode} left The node to check.
47757 * @param {ASTNode} right The node to check.
47758 * @returns {boolean} `true` if one or more comments exist.
47759 */
47760
47761
47762 commentsExistBetween(left, right) {
47763 const index = utils.search(this[COMMENTS], left.range[1]);
47764 return index < this[COMMENTS].length && this[COMMENTS][index].range[1] <= right.range[0];
47765 }
47766 /**
47767 * Gets all comment tokens directly before the given node or token.
47768 * @param {ASTNode|token} nodeOrToken The AST node or token to check for adjacent comment tokens.
47769 * @returns {Array} An array of comments in occurrence order.
47770 */
47771
47772
47773 getCommentsBefore(nodeOrToken) {
47774 const cursor = createCursorWithCount(cursors.backward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], -1, nodeOrToken.range[0], {
47775 includeComments: true
47776 });
47777 return getAdjacentCommentTokensFromCursor(cursor).reverse();
47778 }
47779 /**
47780 * Gets all comment tokens directly after the given node or token.
47781 * @param {ASTNode|token} nodeOrToken The AST node or token to check for adjacent comment tokens.
47782 * @returns {Array} An array of comments in occurrence order.
47783 */
47784
47785
47786 getCommentsAfter(nodeOrToken) {
47787 const cursor = createCursorWithCount(cursors.forward, this[TOKENS], this[COMMENTS], this[INDEX_MAP], nodeOrToken.range[1], -1, {
47788 includeComments: true
47789 });
47790 return getAdjacentCommentTokensFromCursor(cursor);
47791 }
47792 /**
47793 * Gets all comment tokens inside the given node.
47794 * @param {ASTNode} node The AST node to get the comments for.
47795 * @returns {Array} An array of comments in occurrence order.
47796 */
47797
47798
47799 getCommentsInside(node) {
47800 return this.getTokens(node, {
47801 includeComments: true,
47802 filter: isCommentToken
47803 });
47804 }
47805
47806 };
47807
47808 /***/ }),
47809 /* 505 */
47810 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
47811
47812 "use strict";
47813 /**
47814 * @fileoverview Define 2 token factories; forward and backward.
47815 * @author Toru Nagashima
47816 */
47817 //------------------------------------------------------------------------------
47818 // Requirements
47819 //------------------------------------------------------------------------------
47820
47821 const BackwardTokenCommentCursor = __webpack_require__(506);
47822
47823 const BackwardTokenCursor = __webpack_require__(509);
47824
47825 const FilterCursor = __webpack_require__(510);
47826
47827 const ForwardTokenCommentCursor = __webpack_require__(512);
47828
47829 const ForwardTokenCursor = __webpack_require__(513);
47830
47831 const LimitCursor = __webpack_require__(514);
47832
47833 const SkipCursor = __webpack_require__(515); //------------------------------------------------------------------------------
47834 // Helpers
47835 //------------------------------------------------------------------------------
47836
47837 /**
47838 * The cursor factory.
47839 * @private
47840 */
47841
47842
47843 class CursorFactory {
47844 /**
47845 * Initializes this cursor.
47846 * @param {Function} TokenCursor The class of the cursor which iterates tokens only.
47847 * @param {Function} TokenCommentCursor The class of the cursor which iterates the mix of tokens and comments.
47848 */
47849 constructor(TokenCursor, TokenCommentCursor) {
47850 this.TokenCursor = TokenCursor;
47851 this.TokenCommentCursor = TokenCommentCursor;
47852 }
47853 /**
47854 * Creates a base cursor instance that can be decorated by createCursor.
47855 * @param {Token[]} tokens The array of tokens.
47856 * @param {Comment[]} comments The array of comments.
47857 * @param {Object} indexMap The map from locations to indices in `tokens`.
47858 * @param {number} startLoc The start location of the iteration range.
47859 * @param {number} endLoc The end location of the iteration range.
47860 * @param {boolean} includeComments The flag to iterate comments as well.
47861 * @returns {Cursor} The created base cursor.
47862 */
47863
47864
47865 createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments) {
47866 const Cursor = includeComments ? this.TokenCommentCursor : this.TokenCursor;
47867 return new Cursor(tokens, comments, indexMap, startLoc, endLoc);
47868 }
47869 /**
47870 * Creates a cursor that iterates tokens with normalized options.
47871 * @param {Token[]} tokens The array of tokens.
47872 * @param {Comment[]} comments The array of comments.
47873 * @param {Object} indexMap The map from locations to indices in `tokens`.
47874 * @param {number} startLoc The start location of the iteration range.
47875 * @param {number} endLoc The end location of the iteration range.
47876 * @param {boolean} includeComments The flag to iterate comments as well.
47877 * @param {Function|null} filter The predicate function to choose tokens.
47878 * @param {number} skip The count of tokens the cursor skips.
47879 * @param {number} count The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
47880 * @returns {Cursor} The created cursor.
47881 */
47882
47883
47884 createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, count) {
47885 let cursor = this.createBaseCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments);
47886
47887 if (filter) {
47888 cursor = new FilterCursor(cursor, filter);
47889 }
47890
47891 if (skip >= 1) {
47892 cursor = new SkipCursor(cursor, skip);
47893 }
47894
47895 if (count >= 0) {
47896 cursor = new LimitCursor(cursor, count);
47897 }
47898
47899 return cursor;
47900 }
47901
47902 } //------------------------------------------------------------------------------
47903 // Exports
47904 //------------------------------------------------------------------------------
47905
47906
47907 exports.forward = new CursorFactory(ForwardTokenCursor, ForwardTokenCommentCursor);
47908 exports.backward = new CursorFactory(BackwardTokenCursor, BackwardTokenCommentCursor);
47909
47910 /***/ }),
47911 /* 506 */
47912 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
47913
47914 "use strict";
47915 /**
47916 * @fileoverview Define the cursor which iterates tokens and comments in reverse.
47917 * @author Toru Nagashima
47918 */
47919 //------------------------------------------------------------------------------
47920 // Requirements
47921 //------------------------------------------------------------------------------
47922
47923 const Cursor = __webpack_require__(507);
47924
47925 const utils = __webpack_require__(508); //------------------------------------------------------------------------------
47926 // Exports
47927 //------------------------------------------------------------------------------
47928
47929 /**
47930 * The cursor which iterates tokens and comments in reverse.
47931 */
47932
47933
47934 module.exports = class BackwardTokenCommentCursor extends Cursor {
47935 /**
47936 * Initializes this cursor.
47937 * @param {Token[]} tokens The array of tokens.
47938 * @param {Comment[]} comments The array of comments.
47939 * @param {Object} indexMap The map from locations to indices in `tokens`.
47940 * @param {number} startLoc The start location of the iteration range.
47941 * @param {number} endLoc The end location of the iteration range.
47942 */
47943 constructor(tokens, comments, indexMap, startLoc, endLoc) {
47944 super();
47945 this.tokens = tokens;
47946 this.comments = comments;
47947 this.tokenIndex = utils.getLastIndex(tokens, indexMap, endLoc);
47948 this.commentIndex = utils.search(comments, endLoc) - 1;
47949 this.border = startLoc;
47950 }
47951 /** @inheritdoc */
47952
47953
47954 moveNext() {
47955 const token = this.tokenIndex >= 0 ? this.tokens[this.tokenIndex] : null;
47956 const comment = this.commentIndex >= 0 ? this.comments[this.commentIndex] : null;
47957
47958 if (token && (!comment || token.range[1] > comment.range[1])) {
47959 this.current = token;
47960 this.tokenIndex -= 1;
47961 } else if (comment) {
47962 this.current = comment;
47963 this.commentIndex -= 1;
47964 } else {
47965 this.current = null;
47966 }
47967
47968 return Boolean(this.current) && (this.border === -1 || this.current.range[0] >= this.border);
47969 }
47970
47971 };
47972
47973 /***/ }),
47974 /* 507 */
47975 /***/ ((module) => {
47976
47977 "use strict";
47978 /**
47979 * @fileoverview Define the abstract class about cursors which iterate tokens.
47980 * @author Toru Nagashima
47981 */
47982 //------------------------------------------------------------------------------
47983 // Exports
47984 //------------------------------------------------------------------------------
47985
47986 /**
47987 * The abstract class about cursors which iterate tokens.
47988 *
47989 * This class has 2 abstract methods.
47990 *
47991 * - `current: Token | Comment | null` ... The current token.
47992 * - `moveNext(): boolean` ... Moves this cursor to the next token. If the next token didn't exist, it returns `false`.
47993 *
47994 * This is similar to ES2015 Iterators.
47995 * However, Iterators were slow (at 2017-01), so I created this class as similar to C# IEnumerable.
47996 *
47997 * There are the following known sub classes.
47998 *
47999 * - ForwardTokenCursor .......... The cursor which iterates tokens only.
48000 * - BackwardTokenCursor ......... The cursor which iterates tokens only in reverse.
48001 * - ForwardTokenCommentCursor ... The cursor which iterates tokens and comments.
48002 * - BackwardTokenCommentCursor .. The cursor which iterates tokens and comments in reverse.
48003 * - DecorativeCursor
48004 * - FilterCursor ............ The cursor which ignores the specified tokens.
48005 * - SkipCursor .............. The cursor which ignores the first few tokens.
48006 * - LimitCursor ............. The cursor which limits the count of tokens.
48007 *
48008 */
48009
48010 module.exports = class Cursor {
48011 /**
48012 * Initializes this cursor.
48013 */
48014 constructor() {
48015 this.current = null;
48016 }
48017 /**
48018 * Gets the first token.
48019 * This consumes this cursor.
48020 * @returns {Token|Comment} The first token or null.
48021 */
48022
48023
48024 getOneToken() {
48025 return this.moveNext() ? this.current : null;
48026 }
48027 /**
48028 * Gets the first tokens.
48029 * This consumes this cursor.
48030 * @returns {(Token|Comment)[]} All tokens.
48031 */
48032
48033
48034 getAllTokens() {
48035 const tokens = [];
48036
48037 while (this.moveNext()) {
48038 tokens.push(this.current);
48039 }
48040
48041 return tokens;
48042 }
48043 /**
48044 * Moves this cursor to the next token.
48045 * @returns {boolean} `true` if the next token exists.
48046 * @abstract
48047 */
48048
48049 /* istanbul ignore next */
48050
48051
48052 moveNext() {
48053 // eslint-disable-line class-methods-use-this -- Unused
48054 throw new Error("Not implemented.");
48055 }
48056
48057 };
48058
48059 /***/ }),
48060 /* 508 */
48061 /***/ ((__unused_webpack_module, exports) => {
48062
48063 "use strict";
48064 /**
48065 * @fileoverview Define utility functions for token store.
48066 * @author Toru Nagashima
48067 */
48068 //------------------------------------------------------------------------------
48069 // Helpers
48070 //------------------------------------------------------------------------------
48071
48072 /**
48073 * Gets `token.range[0]` from the given token.
48074 * @param {Node|Token|Comment} token The token to get.
48075 * @returns {number} The start location.
48076 * @private
48077 */
48078
48079 function getStartLocation(token) {
48080 return token.range[0];
48081 } //------------------------------------------------------------------------------
48082 // Exports
48083 //------------------------------------------------------------------------------
48084
48085 /**
48086 * Finds the index of the first token which is after the given location.
48087 * If it was not found, this returns `tokens.length`.
48088 * @param {(Token|Comment)[]} tokens It searches the token in this list.
48089 * @param {number} location The location to search.
48090 * @returns {number} The found index or `tokens.length`.
48091 */
48092
48093
48094 exports.search = function search(tokens, location) {
48095 const index = tokens.findIndex(el => location <= getStartLocation(el));
48096 return index === -1 ? tokens.length : index;
48097 };
48098 /**
48099 * Gets the index of the `startLoc` in `tokens`.
48100 * `startLoc` can be the value of `node.range[1]`, so this checks about `startLoc - 1` as well.
48101 * @param {(Token|Comment)[]} tokens The tokens to find an index.
48102 * @param {Object} indexMap The map from locations to indices.
48103 * @param {number} startLoc The location to get an index.
48104 * @returns {number} The index.
48105 */
48106
48107
48108 exports.getFirstIndex = function getFirstIndex(tokens, indexMap, startLoc) {
48109 if (startLoc in indexMap) {
48110 return indexMap[startLoc];
48111 }
48112
48113 if (startLoc - 1 in indexMap) {
48114 const index = indexMap[startLoc - 1];
48115 const token = index >= 0 && index < tokens.length ? tokens[index] : null;
48116 /*
48117 * For the map of "comment's location -> token's index", it points the next token of a comment.
48118 * In that case, +1 is unnecessary.
48119 */
48120
48121 if (token && token.range[0] >= startLoc) {
48122 return index;
48123 }
48124
48125 return index + 1;
48126 }
48127
48128 return 0;
48129 };
48130 /**
48131 * Gets the index of the `endLoc` in `tokens`.
48132 * The information of end locations are recorded at `endLoc - 1` in `indexMap`, so this checks about `endLoc - 1` as well.
48133 * @param {(Token|Comment)[]} tokens The tokens to find an index.
48134 * @param {Object} indexMap The map from locations to indices.
48135 * @param {number} endLoc The location to get an index.
48136 * @returns {number} The index.
48137 */
48138
48139
48140 exports.getLastIndex = function getLastIndex(tokens, indexMap, endLoc) {
48141 if (endLoc in indexMap) {
48142 return indexMap[endLoc] - 1;
48143 }
48144
48145 if (endLoc - 1 in indexMap) {
48146 const index = indexMap[endLoc - 1];
48147 const token = index >= 0 && index < tokens.length ? tokens[index] : null;
48148 /*
48149 * For the map of "comment's location -> token's index", it points the next token of a comment.
48150 * In that case, -1 is necessary.
48151 */
48152
48153 if (token && token.range[1] > endLoc) {
48154 return index - 1;
48155 }
48156
48157 return index;
48158 }
48159
48160 return tokens.length - 1;
48161 };
48162
48163 /***/ }),
48164 /* 509 */
48165 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
48166
48167 "use strict";
48168 /**
48169 * @fileoverview Define the cursor which iterates tokens only in reverse.
48170 * @author Toru Nagashima
48171 */
48172 //------------------------------------------------------------------------------
48173 // Requirements
48174 //------------------------------------------------------------------------------
48175
48176 const Cursor = __webpack_require__(507);
48177
48178 const utils = __webpack_require__(508); //------------------------------------------------------------------------------
48179 // Exports
48180 //------------------------------------------------------------------------------
48181
48182 /**
48183 * The cursor which iterates tokens only in reverse.
48184 */
48185
48186
48187 module.exports = class BackwardTokenCursor extends Cursor {
48188 /**
48189 * Initializes this cursor.
48190 * @param {Token[]} tokens The array of tokens.
48191 * @param {Comment[]} comments The array of comments.
48192 * @param {Object} indexMap The map from locations to indices in `tokens`.
48193 * @param {number} startLoc The start location of the iteration range.
48194 * @param {number} endLoc The end location of the iteration range.
48195 */
48196 constructor(tokens, comments, indexMap, startLoc, endLoc) {
48197 super();
48198 this.tokens = tokens;
48199 this.index = utils.getLastIndex(tokens, indexMap, endLoc);
48200 this.indexEnd = utils.getFirstIndex(tokens, indexMap, startLoc);
48201 }
48202 /** @inheritdoc */
48203
48204
48205 moveNext() {
48206 if (this.index >= this.indexEnd) {
48207 this.current = this.tokens[this.index];
48208 this.index -= 1;
48209 return true;
48210 }
48211
48212 return false;
48213 }
48214 /*
48215 *
48216 * Shorthand for performance.
48217 *
48218 */
48219
48220 /** @inheritdoc */
48221
48222
48223 getOneToken() {
48224 return this.index >= this.indexEnd ? this.tokens[this.index] : null;
48225 }
48226
48227 };
48228
48229 /***/ }),
48230 /* 510 */
48231 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
48232
48233 "use strict";
48234 /**
48235 * @fileoverview Define the cursor which ignores specified tokens.
48236 * @author Toru Nagashima
48237 */
48238 //------------------------------------------------------------------------------
48239 // Requirements
48240 //------------------------------------------------------------------------------
48241
48242 const DecorativeCursor = __webpack_require__(511); //------------------------------------------------------------------------------
48243 // Exports
48244 //------------------------------------------------------------------------------
48245
48246 /**
48247 * The decorative cursor which ignores specified tokens.
48248 */
48249
48250
48251 module.exports = class FilterCursor extends DecorativeCursor {
48252 /**
48253 * Initializes this cursor.
48254 * @param {Cursor} cursor The cursor to be decorated.
48255 * @param {Function} predicate The predicate function to decide tokens this cursor iterates.
48256 */
48257 constructor(cursor, predicate) {
48258 super(cursor);
48259 this.predicate = predicate;
48260 }
48261 /** @inheritdoc */
48262
48263
48264 moveNext() {
48265 const predicate = this.predicate;
48266
48267 while (super.moveNext()) {
48268 if (predicate(this.current)) {
48269 return true;
48270 }
48271 }
48272
48273 return false;
48274 }
48275
48276 };
48277
48278 /***/ }),
48279 /* 511 */
48280 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
48281
48282 "use strict";
48283 /**
48284 * @fileoverview Define the abstract class about cursors which manipulate another cursor.
48285 * @author Toru Nagashima
48286 */
48287 //------------------------------------------------------------------------------
48288 // Requirements
48289 //------------------------------------------------------------------------------
48290
48291 const Cursor = __webpack_require__(507); //------------------------------------------------------------------------------
48292 // Exports
48293 //------------------------------------------------------------------------------
48294
48295 /**
48296 * The abstract class about cursors which manipulate another cursor.
48297 */
48298
48299
48300 module.exports = class DecorativeCursor extends Cursor {
48301 /**
48302 * Initializes this cursor.
48303 * @param {Cursor} cursor The cursor to be decorated.
48304 */
48305 constructor(cursor) {
48306 super();
48307 this.cursor = cursor;
48308 }
48309 /** @inheritdoc */
48310
48311
48312 moveNext() {
48313 const retv = this.cursor.moveNext();
48314 this.current = this.cursor.current;
48315 return retv;
48316 }
48317
48318 };
48319
48320 /***/ }),
48321 /* 512 */
48322 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
48323
48324 "use strict";
48325 /**
48326 * @fileoverview Define the cursor which iterates tokens and comments.
48327 * @author Toru Nagashima
48328 */
48329 //------------------------------------------------------------------------------
48330 // Requirements
48331 //------------------------------------------------------------------------------
48332
48333 const Cursor = __webpack_require__(507);
48334
48335 const utils = __webpack_require__(508); //------------------------------------------------------------------------------
48336 // Exports
48337 //------------------------------------------------------------------------------
48338
48339 /**
48340 * The cursor which iterates tokens and comments.
48341 */
48342
48343
48344 module.exports = class ForwardTokenCommentCursor extends Cursor {
48345 /**
48346 * Initializes this cursor.
48347 * @param {Token[]} tokens The array of tokens.
48348 * @param {Comment[]} comments The array of comments.
48349 * @param {Object} indexMap The map from locations to indices in `tokens`.
48350 * @param {number} startLoc The start location of the iteration range.
48351 * @param {number} endLoc The end location of the iteration range.
48352 */
48353 constructor(tokens, comments, indexMap, startLoc, endLoc) {
48354 super();
48355 this.tokens = tokens;
48356 this.comments = comments;
48357 this.tokenIndex = utils.getFirstIndex(tokens, indexMap, startLoc);
48358 this.commentIndex = utils.search(comments, startLoc);
48359 this.border = endLoc;
48360 }
48361 /** @inheritdoc */
48362
48363
48364 moveNext() {
48365 const token = this.tokenIndex < this.tokens.length ? this.tokens[this.tokenIndex] : null;
48366 const comment = this.commentIndex < this.comments.length ? this.comments[this.commentIndex] : null;
48367
48368 if (token && (!comment || token.range[0] < comment.range[0])) {
48369 this.current = token;
48370 this.tokenIndex += 1;
48371 } else if (comment) {
48372 this.current = comment;
48373 this.commentIndex += 1;
48374 } else {
48375 this.current = null;
48376 }
48377
48378 return Boolean(this.current) && (this.border === -1 || this.current.range[1] <= this.border);
48379 }
48380
48381 };
48382
48383 /***/ }),
48384 /* 513 */
48385 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
48386
48387 "use strict";
48388 /**
48389 * @fileoverview Define the cursor which iterates tokens only.
48390 * @author Toru Nagashima
48391 */
48392 //------------------------------------------------------------------------------
48393 // Requirements
48394 //------------------------------------------------------------------------------
48395
48396 const Cursor = __webpack_require__(507);
48397
48398 const utils = __webpack_require__(508); //------------------------------------------------------------------------------
48399 // Exports
48400 //------------------------------------------------------------------------------
48401
48402 /**
48403 * The cursor which iterates tokens only.
48404 */
48405
48406
48407 module.exports = class ForwardTokenCursor extends Cursor {
48408 /**
48409 * Initializes this cursor.
48410 * @param {Token[]} tokens The array of tokens.
48411 * @param {Comment[]} comments The array of comments.
48412 * @param {Object} indexMap The map from locations to indices in `tokens`.
48413 * @param {number} startLoc The start location of the iteration range.
48414 * @param {number} endLoc The end location of the iteration range.
48415 */
48416 constructor(tokens, comments, indexMap, startLoc, endLoc) {
48417 super();
48418 this.tokens = tokens;
48419 this.index = utils.getFirstIndex(tokens, indexMap, startLoc);
48420 this.indexEnd = utils.getLastIndex(tokens, indexMap, endLoc);
48421 }
48422 /** @inheritdoc */
48423
48424
48425 moveNext() {
48426 if (this.index <= this.indexEnd) {
48427 this.current = this.tokens[this.index];
48428 this.index += 1;
48429 return true;
48430 }
48431
48432 return false;
48433 }
48434 /*
48435 *
48436 * Shorthand for performance.
48437 *
48438 */
48439
48440 /** @inheritdoc */
48441
48442
48443 getOneToken() {
48444 return this.index <= this.indexEnd ? this.tokens[this.index] : null;
48445 }
48446 /** @inheritdoc */
48447
48448
48449 getAllTokens() {
48450 return this.tokens.slice(this.index, this.indexEnd + 1);
48451 }
48452
48453 };
48454
48455 /***/ }),
48456 /* 514 */
48457 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
48458
48459 "use strict";
48460 /**
48461 * @fileoverview Define the cursor which limits the number of tokens.
48462 * @author Toru Nagashima
48463 */
48464 //------------------------------------------------------------------------------
48465 // Requirements
48466 //------------------------------------------------------------------------------
48467
48468 const DecorativeCursor = __webpack_require__(511); //------------------------------------------------------------------------------
48469 // Exports
48470 //------------------------------------------------------------------------------
48471
48472 /**
48473 * The decorative cursor which limits the number of tokens.
48474 */
48475
48476
48477 module.exports = class LimitCursor extends DecorativeCursor {
48478 /**
48479 * Initializes this cursor.
48480 * @param {Cursor} cursor The cursor to be decorated.
48481 * @param {number} count The count of tokens this cursor iterates.
48482 */
48483 constructor(cursor, count) {
48484 super(cursor);
48485 this.count = count;
48486 }
48487 /** @inheritdoc */
48488
48489
48490 moveNext() {
48491 if (this.count > 0) {
48492 this.count -= 1;
48493 return super.moveNext();
48494 }
48495
48496 return false;
48497 }
48498
48499 };
48500
48501 /***/ }),
48502 /* 515 */
48503 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
48504
48505 "use strict";
48506 /**
48507 * @fileoverview Define the cursor which ignores the first few tokens.
48508 * @author Toru Nagashima
48509 */
48510 //------------------------------------------------------------------------------
48511 // Requirements
48512 //------------------------------------------------------------------------------
48513
48514 const DecorativeCursor = __webpack_require__(511); //------------------------------------------------------------------------------
48515 // Exports
48516 //------------------------------------------------------------------------------
48517
48518 /**
48519 * The decorative cursor which ignores the first few tokens.
48520 */
48521
48522
48523 module.exports = class SkipCursor extends DecorativeCursor {
48524 /**
48525 * Initializes this cursor.
48526 * @param {Cursor} cursor The cursor to be decorated.
48527 * @param {number} count The count of tokens this cursor skips.
48528 */
48529 constructor(cursor, count) {
48530 super(cursor);
48531 this.count = count;
48532 }
48533 /** @inheritdoc */
48534
48535
48536 moveNext() {
48537 while (this.count > 0) {
48538 this.count -= 1;
48539
48540 if (!super.moveNext()) {
48541 return false;
48542 }
48543 }
48544
48545 return super.moveNext();
48546 }
48547
48548 };
48549
48550 /***/ }),
48551 /* 516 */
48552 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
48553
48554 "use strict";
48555 /**
48556 * @fileoverview Define the cursor which iterates tokens only, with inflated range.
48557 * @author Toru Nagashima
48558 */
48559 //------------------------------------------------------------------------------
48560 // Requirements
48561 //------------------------------------------------------------------------------
48562
48563 const ForwardTokenCursor = __webpack_require__(513); //------------------------------------------------------------------------------
48564 // Exports
48565 //------------------------------------------------------------------------------
48566
48567 /**
48568 * The cursor which iterates tokens only, with inflated range.
48569 * This is for the backward compatibility of padding options.
48570 */
48571
48572
48573 module.exports = class PaddedTokenCursor extends ForwardTokenCursor {
48574 /**
48575 * Initializes this cursor.
48576 * @param {Token[]} tokens The array of tokens.
48577 * @param {Comment[]} comments The array of comments.
48578 * @param {Object} indexMap The map from locations to indices in `tokens`.
48579 * @param {number} startLoc The start location of the iteration range.
48580 * @param {number} endLoc The end location of the iteration range.
48581 * @param {number} beforeCount The number of tokens this cursor iterates before start.
48582 * @param {number} afterCount The number of tokens this cursor iterates after end.
48583 */
48584 constructor(tokens, comments, indexMap, startLoc, endLoc, beforeCount, afterCount) {
48585 super(tokens, comments, indexMap, startLoc, endLoc);
48586 this.index = Math.max(0, this.index - beforeCount);
48587 this.indexEnd = Math.min(tokens.length - 1, this.indexEnd + afterCount);
48588 }
48589
48590 };
48591
48592 /***/ }),
48593 /* 517 */
48594 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
48595
48596 "use strict";
48597 /**
48598 * @fileoverview A class of the code path analyzer.
48599 * @author Toru Nagashima
48600 */
48601 //------------------------------------------------------------------------------
48602 // Requirements
48603 //------------------------------------------------------------------------------
48604
48605 const assert = __webpack_require__(431),
48606 {
48607 breakableTypePattern
48608 } = __webpack_require__(444),
48609 CodePath = __webpack_require__(518),
48610 CodePathSegment = __webpack_require__(520),
48611 IdGenerator = __webpack_require__(523),
48612 debug = __webpack_require__(521); //------------------------------------------------------------------------------
48613 // Helpers
48614 //------------------------------------------------------------------------------
48615
48616 /**
48617 * Checks whether or not a given node is a `case` node (not `default` node).
48618 * @param {ASTNode} node A `SwitchCase` node to check.
48619 * @returns {boolean} `true` if the node is a `case` node (not `default` node).
48620 */
48621
48622
48623 function isCaseNode(node) {
48624 return Boolean(node.test);
48625 }
48626 /**
48627 * Checks if a given node appears as the value of a PropertyDefinition node.
48628 * @param {ASTNode} node THe node to check.
48629 * @returns {boolean} `true` if the node is a PropertyDefinition value,
48630 * false if not.
48631 */
48632
48633
48634 function isPropertyDefinitionValue(node) {
48635 const parent = node.parent;
48636 return parent && parent.type === "PropertyDefinition" && parent.value === node;
48637 }
48638 /**
48639 * Checks whether the given logical operator is taken into account for the code
48640 * path analysis.
48641 * @param {string} operator The operator found in the LogicalExpression node
48642 * @returns {boolean} `true` if the operator is "&&" or "||" or "??"
48643 */
48644
48645
48646 function isHandledLogicalOperator(operator) {
48647 return operator === "&&" || operator === "||" || operator === "??";
48648 }
48649 /**
48650 * Checks whether the given assignment operator is a logical assignment operator.
48651 * Logical assignments are taken into account for the code path analysis
48652 * because of their short-circuiting semantics.
48653 * @param {string} operator The operator found in the AssignmentExpression node
48654 * @returns {boolean} `true` if the operator is "&&=" or "||=" or "??="
48655 */
48656
48657
48658 function isLogicalAssignmentOperator(operator) {
48659 return operator === "&&=" || operator === "||=" || operator === "??=";
48660 }
48661 /**
48662 * Gets the label if the parent node of a given node is a LabeledStatement.
48663 * @param {ASTNode} node A node to get.
48664 * @returns {string|null} The label or `null`.
48665 */
48666
48667
48668 function getLabel(node) {
48669 if (node.parent.type === "LabeledStatement") {
48670 return node.parent.label.name;
48671 }
48672
48673 return null;
48674 }
48675 /**
48676 * Checks whether or not a given logical expression node goes different path
48677 * between the `true` case and the `false` case.
48678 * @param {ASTNode} node A node to check.
48679 * @returns {boolean} `true` if the node is a test of a choice statement.
48680 */
48681
48682
48683 function isForkingByTrueOrFalse(node) {
48684 const parent = node.parent;
48685
48686 switch (parent.type) {
48687 case "ConditionalExpression":
48688 case "IfStatement":
48689 case "WhileStatement":
48690 case "DoWhileStatement":
48691 case "ForStatement":
48692 return parent.test === node;
48693
48694 case "LogicalExpression":
48695 return isHandledLogicalOperator(parent.operator);
48696
48697 case "AssignmentExpression":
48698 return isLogicalAssignmentOperator(parent.operator);
48699
48700 default:
48701 return false;
48702 }
48703 }
48704 /**
48705 * Gets the boolean value of a given literal node.
48706 *
48707 * This is used to detect infinity loops (e.g. `while (true) {}`).
48708 * Statements preceded by an infinity loop are unreachable if the loop didn't
48709 * have any `break` statement.
48710 * @param {ASTNode} node A node to get.
48711 * @returns {boolean|undefined} a boolean value if the node is a Literal node,
48712 * otherwise `undefined`.
48713 */
48714
48715
48716 function getBooleanValueIfSimpleConstant(node) {
48717 if (node.type === "Literal") {
48718 return Boolean(node.value);
48719 }
48720
48721 return void 0;
48722 }
48723 /**
48724 * Checks that a given identifier node is a reference or not.
48725 *
48726 * This is used to detect the first throwable node in a `try` block.
48727 * @param {ASTNode} node An Identifier node to check.
48728 * @returns {boolean} `true` if the node is a reference.
48729 */
48730
48731
48732 function isIdentifierReference(node) {
48733 const parent = node.parent;
48734
48735 switch (parent.type) {
48736 case "LabeledStatement":
48737 case "BreakStatement":
48738 case "ContinueStatement":
48739 case "ArrayPattern":
48740 case "RestElement":
48741 case "ImportSpecifier":
48742 case "ImportDefaultSpecifier":
48743 case "ImportNamespaceSpecifier":
48744 case "CatchClause":
48745 return false;
48746
48747 case "FunctionDeclaration":
48748 case "FunctionExpression":
48749 case "ArrowFunctionExpression":
48750 case "ClassDeclaration":
48751 case "ClassExpression":
48752 case "VariableDeclarator":
48753 return parent.id !== node;
48754
48755 case "Property":
48756 case "PropertyDefinition":
48757 case "MethodDefinition":
48758 return parent.key !== node || parent.computed || parent.shorthand;
48759
48760 case "AssignmentPattern":
48761 return parent.key !== node;
48762
48763 default:
48764 return true;
48765 }
48766 }
48767 /**
48768 * Updates the current segment with the head segment.
48769 * This is similar to local branches and tracking branches of git.
48770 *
48771 * To separate the current and the head is in order to not make useless segments.
48772 *
48773 * In this process, both "onCodePathSegmentStart" and "onCodePathSegmentEnd"
48774 * events are fired.
48775 * @param {CodePathAnalyzer} analyzer The instance.
48776 * @param {ASTNode} node The current AST node.
48777 * @returns {void}
48778 */
48779
48780
48781 function forwardCurrentToHead(analyzer, node) {
48782 const codePath = analyzer.codePath;
48783 const state = CodePath.getState(codePath);
48784 const currentSegments = state.currentSegments;
48785 const headSegments = state.headSegments;
48786 const end = Math.max(currentSegments.length, headSegments.length);
48787 let i, currentSegment, headSegment; // Fires leaving events.
48788
48789 for (i = 0; i < end; ++i) {
48790 currentSegment = currentSegments[i];
48791 headSegment = headSegments[i];
48792
48793 if (currentSegment !== headSegment && currentSegment) {
48794 debug.dump("onCodePathSegmentEnd ".concat(currentSegment.id));
48795
48796 if (currentSegment.reachable) {
48797 analyzer.emitter.emit("onCodePathSegmentEnd", currentSegment, node);
48798 }
48799 }
48800 } // Update state.
48801
48802
48803 state.currentSegments = headSegments; // Fires entering events.
48804
48805 for (i = 0; i < end; ++i) {
48806 currentSegment = currentSegments[i];
48807 headSegment = headSegments[i];
48808
48809 if (currentSegment !== headSegment && headSegment) {
48810 debug.dump("onCodePathSegmentStart ".concat(headSegment.id));
48811 CodePathSegment.markUsed(headSegment);
48812
48813 if (headSegment.reachable) {
48814 analyzer.emitter.emit("onCodePathSegmentStart", headSegment, node);
48815 }
48816 }
48817 }
48818 }
48819 /**
48820 * Updates the current segment with empty.
48821 * This is called at the last of functions or the program.
48822 * @param {CodePathAnalyzer} analyzer The instance.
48823 * @param {ASTNode} node The current AST node.
48824 * @returns {void}
48825 */
48826
48827
48828 function leaveFromCurrentSegment(analyzer, node) {
48829 const state = CodePath.getState(analyzer.codePath);
48830 const currentSegments = state.currentSegments;
48831
48832 for (let i = 0; i < currentSegments.length; ++i) {
48833 const currentSegment = currentSegments[i];
48834 debug.dump("onCodePathSegmentEnd ".concat(currentSegment.id));
48835
48836 if (currentSegment.reachable) {
48837 analyzer.emitter.emit("onCodePathSegmentEnd", currentSegment, node);
48838 }
48839 }
48840
48841 state.currentSegments = [];
48842 }
48843 /**
48844 * Updates the code path due to the position of a given node in the parent node
48845 * thereof.
48846 *
48847 * For example, if the node is `parent.consequent`, this creates a fork from the
48848 * current path.
48849 * @param {CodePathAnalyzer} analyzer The instance.
48850 * @param {ASTNode} node The current AST node.
48851 * @returns {void}
48852 */
48853
48854
48855 function preprocess(analyzer, node) {
48856 const codePath = analyzer.codePath;
48857 const state = CodePath.getState(codePath);
48858 const parent = node.parent;
48859
48860 switch (parent.type) {
48861 // The `arguments.length == 0` case is in `postprocess` function.
48862 case "CallExpression":
48863 if (parent.optional === true && parent.arguments.length >= 1 && parent.arguments[0] === node) {
48864 state.makeOptionalRight();
48865 }
48866
48867 break;
48868
48869 case "MemberExpression":
48870 if (parent.optional === true && parent.property === node) {
48871 state.makeOptionalRight();
48872 }
48873
48874 break;
48875
48876 case "LogicalExpression":
48877 if (parent.right === node && isHandledLogicalOperator(parent.operator)) {
48878 state.makeLogicalRight();
48879 }
48880
48881 break;
48882
48883 case "AssignmentExpression":
48884 if (parent.right === node && isLogicalAssignmentOperator(parent.operator)) {
48885 state.makeLogicalRight();
48886 }
48887
48888 break;
48889
48890 case "ConditionalExpression":
48891 case "IfStatement":
48892 /*
48893 * Fork if this node is at `consequent`/`alternate`.
48894 * `popForkContext()` exists at `IfStatement:exit` and
48895 * `ConditionalExpression:exit`.
48896 */
48897 if (parent.consequent === node) {
48898 state.makeIfConsequent();
48899 } else if (parent.alternate === node) {
48900 state.makeIfAlternate();
48901 }
48902
48903 break;
48904
48905 case "SwitchCase":
48906 if (parent.consequent[0] === node) {
48907 state.makeSwitchCaseBody(false, !parent.test);
48908 }
48909
48910 break;
48911
48912 case "TryStatement":
48913 if (parent.handler === node) {
48914 state.makeCatchBlock();
48915 } else if (parent.finalizer === node) {
48916 state.makeFinallyBlock();
48917 }
48918
48919 break;
48920
48921 case "WhileStatement":
48922 if (parent.test === node) {
48923 state.makeWhileTest(getBooleanValueIfSimpleConstant(node));
48924 } else {
48925 assert(parent.body === node);
48926 state.makeWhileBody();
48927 }
48928
48929 break;
48930
48931 case "DoWhileStatement":
48932 if (parent.body === node) {
48933 state.makeDoWhileBody();
48934 } else {
48935 assert(parent.test === node);
48936 state.makeDoWhileTest(getBooleanValueIfSimpleConstant(node));
48937 }
48938
48939 break;
48940
48941 case "ForStatement":
48942 if (parent.test === node) {
48943 state.makeForTest(getBooleanValueIfSimpleConstant(node));
48944 } else if (parent.update === node) {
48945 state.makeForUpdate();
48946 } else if (parent.body === node) {
48947 state.makeForBody();
48948 }
48949
48950 break;
48951
48952 case "ForInStatement":
48953 case "ForOfStatement":
48954 if (parent.left === node) {
48955 state.makeForInOfLeft();
48956 } else if (parent.right === node) {
48957 state.makeForInOfRight();
48958 } else {
48959 assert(parent.body === node);
48960 state.makeForInOfBody();
48961 }
48962
48963 break;
48964
48965 case "AssignmentPattern":
48966 /*
48967 * Fork if this node is at `right`.
48968 * `left` is executed always, so it uses the current path.
48969 * `popForkContext()` exists at `AssignmentPattern:exit`.
48970 */
48971 if (parent.right === node) {
48972 state.pushForkContext();
48973 state.forkBypassPath();
48974 state.forkPath();
48975 }
48976
48977 break;
48978
48979 default:
48980 break;
48981 }
48982 }
48983 /**
48984 * Updates the code path due to the type of a given node in entering.
48985 * @param {CodePathAnalyzer} analyzer The instance.
48986 * @param {ASTNode} node The current AST node.
48987 * @returns {void}
48988 */
48989
48990
48991 function processCodePathToEnter(analyzer, node) {
48992 let codePath = analyzer.codePath;
48993 let state = codePath && CodePath.getState(codePath);
48994 const parent = node.parent;
48995 /**
48996 * Creates a new code path and trigger the onCodePathStart event
48997 * based on the currently selected node.
48998 * @param {string} origin The reason the code path was started.
48999 * @returns {void}
49000 */
49001
49002 function startCodePath(origin) {
49003 if (codePath) {
49004 // Emits onCodePathSegmentStart events if updated.
49005 forwardCurrentToHead(analyzer, node);
49006 debug.dumpState(node, state, false);
49007 } // Create the code path of this scope.
49008
49009
49010 codePath = analyzer.codePath = new CodePath({
49011 id: analyzer.idGenerator.next(),
49012 origin,
49013 upper: codePath,
49014 onLooped: analyzer.onLooped
49015 });
49016 state = CodePath.getState(codePath); // Emits onCodePathStart events.
49017
49018 debug.dump("onCodePathStart ".concat(codePath.id));
49019 analyzer.emitter.emit("onCodePathStart", codePath, node);
49020 }
49021 /*
49022 * Special case: The right side of class field initializer is considered
49023 * to be its own function, so we need to start a new code path in this
49024 * case.
49025 */
49026
49027
49028 if (isPropertyDefinitionValue(node)) {
49029 startCodePath("class-field-initializer");
49030 /*
49031 * Intentional fall through because `node` needs to also be
49032 * processed by the code below. For example, if we have:
49033 *
49034 * class Foo {
49035 * a = () => {}
49036 * }
49037 *
49038 * In this case, we also need start a second code path.
49039 */
49040 }
49041
49042 switch (node.type) {
49043 case "Program":
49044 startCodePath("program");
49045 break;
49046
49047 case "FunctionDeclaration":
49048 case "FunctionExpression":
49049 case "ArrowFunctionExpression":
49050 startCodePath("function");
49051 break;
49052
49053 case "StaticBlock":
49054 startCodePath("class-static-block");
49055 break;
49056
49057 case "ChainExpression":
49058 state.pushChainContext();
49059 break;
49060
49061 case "CallExpression":
49062 if (node.optional === true) {
49063 state.makeOptionalNode();
49064 }
49065
49066 break;
49067
49068 case "MemberExpression":
49069 if (node.optional === true) {
49070 state.makeOptionalNode();
49071 }
49072
49073 break;
49074
49075 case "LogicalExpression":
49076 if (isHandledLogicalOperator(node.operator)) {
49077 state.pushChoiceContext(node.operator, isForkingByTrueOrFalse(node));
49078 }
49079
49080 break;
49081
49082 case "AssignmentExpression":
49083 if (isLogicalAssignmentOperator(node.operator)) {
49084 state.pushChoiceContext(node.operator.slice(0, -1), // removes `=` from the end
49085 isForkingByTrueOrFalse(node));
49086 }
49087
49088 break;
49089
49090 case "ConditionalExpression":
49091 case "IfStatement":
49092 state.pushChoiceContext("test", false);
49093 break;
49094
49095 case "SwitchStatement":
49096 state.pushSwitchContext(node.cases.some(isCaseNode), getLabel(node));
49097 break;
49098
49099 case "TryStatement":
49100 state.pushTryContext(Boolean(node.finalizer));
49101 break;
49102
49103 case "SwitchCase":
49104 /*
49105 * Fork if this node is after the 2st node in `cases`.
49106 * It's similar to `else` blocks.
49107 * The next `test` node is processed in this path.
49108 */
49109 if (parent.discriminant !== node && parent.cases[0] !== node) {
49110 state.forkPath();
49111 }
49112
49113 break;
49114
49115 case "WhileStatement":
49116 case "DoWhileStatement":
49117 case "ForStatement":
49118 case "ForInStatement":
49119 case "ForOfStatement":
49120 state.pushLoopContext(node.type, getLabel(node));
49121 break;
49122
49123 case "LabeledStatement":
49124 if (!breakableTypePattern.test(node.body.type)) {
49125 state.pushBreakContext(false, node.label.name);
49126 }
49127
49128 break;
49129
49130 default:
49131 break;
49132 } // Emits onCodePathSegmentStart events if updated.
49133
49134
49135 forwardCurrentToHead(analyzer, node);
49136 debug.dumpState(node, state, false);
49137 }
49138 /**
49139 * Updates the code path due to the type of a given node in leaving.
49140 * @param {CodePathAnalyzer} analyzer The instance.
49141 * @param {ASTNode} node The current AST node.
49142 * @returns {void}
49143 */
49144
49145
49146 function processCodePathToExit(analyzer, node) {
49147 const codePath = analyzer.codePath;
49148 const state = CodePath.getState(codePath);
49149 let dontForward = false;
49150
49151 switch (node.type) {
49152 case "ChainExpression":
49153 state.popChainContext();
49154 break;
49155
49156 case "IfStatement":
49157 case "ConditionalExpression":
49158 state.popChoiceContext();
49159 break;
49160
49161 case "LogicalExpression":
49162 if (isHandledLogicalOperator(node.operator)) {
49163 state.popChoiceContext();
49164 }
49165
49166 break;
49167
49168 case "AssignmentExpression":
49169 if (isLogicalAssignmentOperator(node.operator)) {
49170 state.popChoiceContext();
49171 }
49172
49173 break;
49174
49175 case "SwitchStatement":
49176 state.popSwitchContext();
49177 break;
49178
49179 case "SwitchCase":
49180 /*
49181 * This is the same as the process at the 1st `consequent` node in
49182 * `preprocess` function.
49183 * Must do if this `consequent` is empty.
49184 */
49185 if (node.consequent.length === 0) {
49186 state.makeSwitchCaseBody(true, !node.test);
49187 }
49188
49189 if (state.forkContext.reachable) {
49190 dontForward = true;
49191 }
49192
49193 break;
49194
49195 case "TryStatement":
49196 state.popTryContext();
49197 break;
49198
49199 case "BreakStatement":
49200 forwardCurrentToHead(analyzer, node);
49201 state.makeBreak(node.label && node.label.name);
49202 dontForward = true;
49203 break;
49204
49205 case "ContinueStatement":
49206 forwardCurrentToHead(analyzer, node);
49207 state.makeContinue(node.label && node.label.name);
49208 dontForward = true;
49209 break;
49210
49211 case "ReturnStatement":
49212 forwardCurrentToHead(analyzer, node);
49213 state.makeReturn();
49214 dontForward = true;
49215 break;
49216
49217 case "ThrowStatement":
49218 forwardCurrentToHead(analyzer, node);
49219 state.makeThrow();
49220 dontForward = true;
49221 break;
49222
49223 case "Identifier":
49224 if (isIdentifierReference(node)) {
49225 state.makeFirstThrowablePathInTryBlock();
49226 dontForward = true;
49227 }
49228
49229 break;
49230
49231 case "CallExpression":
49232 case "ImportExpression":
49233 case "MemberExpression":
49234 case "NewExpression":
49235 case "YieldExpression":
49236 state.makeFirstThrowablePathInTryBlock();
49237 break;
49238
49239 case "WhileStatement":
49240 case "DoWhileStatement":
49241 case "ForStatement":
49242 case "ForInStatement":
49243 case "ForOfStatement":
49244 state.popLoopContext();
49245 break;
49246
49247 case "AssignmentPattern":
49248 state.popForkContext();
49249 break;
49250
49251 case "LabeledStatement":
49252 if (!breakableTypePattern.test(node.body.type)) {
49253 state.popBreakContext();
49254 }
49255
49256 break;
49257
49258 default:
49259 break;
49260 } // Emits onCodePathSegmentStart events if updated.
49261
49262
49263 if (!dontForward) {
49264 forwardCurrentToHead(analyzer, node);
49265 }
49266
49267 debug.dumpState(node, state, true);
49268 }
49269 /**
49270 * Updates the code path to finalize the current code path.
49271 * @param {CodePathAnalyzer} analyzer The instance.
49272 * @param {ASTNode} node The current AST node.
49273 * @returns {void}
49274 */
49275
49276
49277 function postprocess(analyzer, node) {
49278 /**
49279 * Ends the code path for the current node.
49280 * @returns {void}
49281 */
49282 function endCodePath() {
49283 let codePath = analyzer.codePath; // Mark the current path as the final node.
49284
49285 CodePath.getState(codePath).makeFinal(); // Emits onCodePathSegmentEnd event of the current segments.
49286
49287 leaveFromCurrentSegment(analyzer, node); // Emits onCodePathEnd event of this code path.
49288
49289 debug.dump("onCodePathEnd ".concat(codePath.id));
49290 analyzer.emitter.emit("onCodePathEnd", codePath, node);
49291 debug.dumpDot(codePath);
49292 codePath = analyzer.codePath = analyzer.codePath.upper;
49293
49294 if (codePath) {
49295 debug.dumpState(node, CodePath.getState(codePath), true);
49296 }
49297 }
49298
49299 switch (node.type) {
49300 case "Program":
49301 case "FunctionDeclaration":
49302 case "FunctionExpression":
49303 case "ArrowFunctionExpression":
49304 case "StaticBlock":
49305 {
49306 endCodePath();
49307 break;
49308 }
49309 // The `arguments.length >= 1` case is in `preprocess` function.
49310
49311 case "CallExpression":
49312 if (node.optional === true && node.arguments.length === 0) {
49313 CodePath.getState(analyzer.codePath).makeOptionalRight();
49314 }
49315
49316 break;
49317
49318 default:
49319 break;
49320 }
49321 /*
49322 * Special case: The right side of class field initializer is considered
49323 * to be its own function, so we need to end a code path in this
49324 * case.
49325 *
49326 * We need to check after the other checks in order to close the
49327 * code paths in the correct order for code like this:
49328 *
49329 *
49330 * class Foo {
49331 * a = () => {}
49332 * }
49333 *
49334 * In this case, The ArrowFunctionExpression code path is closed first
49335 * and then we need to close the code path for the PropertyDefinition
49336 * value.
49337 */
49338
49339
49340 if (isPropertyDefinitionValue(node)) {
49341 endCodePath();
49342 }
49343 } //------------------------------------------------------------------------------
49344 // Public Interface
49345 //------------------------------------------------------------------------------
49346
49347 /**
49348 * The class to analyze code paths.
49349 * This class implements the EventGenerator interface.
49350 */
49351
49352
49353 class CodePathAnalyzer {
49354 /**
49355 * @param {EventGenerator} eventGenerator An event generator to wrap.
49356 */
49357 constructor(eventGenerator) {
49358 this.original = eventGenerator;
49359 this.emitter = eventGenerator.emitter;
49360 this.codePath = null;
49361 this.idGenerator = new IdGenerator("s");
49362 this.currentNode = null;
49363 this.onLooped = this.onLooped.bind(this);
49364 }
49365 /**
49366 * Does the process to enter a given AST node.
49367 * This updates state of analysis and calls `enterNode` of the wrapped.
49368 * @param {ASTNode} node A node which is entering.
49369 * @returns {void}
49370 */
49371
49372
49373 enterNode(node) {
49374 this.currentNode = node; // Updates the code path due to node's position in its parent node.
49375
49376 if (node.parent) {
49377 preprocess(this, node);
49378 }
49379 /*
49380 * Updates the code path.
49381 * And emits onCodePathStart/onCodePathSegmentStart events.
49382 */
49383
49384
49385 processCodePathToEnter(this, node); // Emits node events.
49386
49387 this.original.enterNode(node);
49388 this.currentNode = null;
49389 }
49390 /**
49391 * Does the process to leave a given AST node.
49392 * This updates state of analysis and calls `leaveNode` of the wrapped.
49393 * @param {ASTNode} node A node which is leaving.
49394 * @returns {void}
49395 */
49396
49397
49398 leaveNode(node) {
49399 this.currentNode = node;
49400 /*
49401 * Updates the code path.
49402 * And emits onCodePathStart/onCodePathSegmentStart events.
49403 */
49404
49405 processCodePathToExit(this, node); // Emits node events.
49406
49407 this.original.leaveNode(node); // Emits the last onCodePathStart/onCodePathSegmentStart events.
49408
49409 postprocess(this, node);
49410 this.currentNode = null;
49411 }
49412 /**
49413 * This is called on a code path looped.
49414 * Then this raises a looped event.
49415 * @param {CodePathSegment} fromSegment A segment of prev.
49416 * @param {CodePathSegment} toSegment A segment of next.
49417 * @returns {void}
49418 */
49419
49420
49421 onLooped(fromSegment, toSegment) {
49422 if (fromSegment.reachable && toSegment.reachable) {
49423 debug.dump("onCodePathSegmentLoop ".concat(fromSegment.id, " -> ").concat(toSegment.id));
49424 this.emitter.emit("onCodePathSegmentLoop", fromSegment, toSegment, this.currentNode);
49425 }
49426 }
49427
49428 }
49429
49430 module.exports = CodePathAnalyzer;
49431
49432 /***/ }),
49433 /* 518 */
49434 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
49435
49436 "use strict";
49437 /**
49438 * @fileoverview A class of the code path.
49439 * @author Toru Nagashima
49440 */
49441 //------------------------------------------------------------------------------
49442 // Requirements
49443 //------------------------------------------------------------------------------
49444
49445 const CodePathState = __webpack_require__(519);
49446
49447 const IdGenerator = __webpack_require__(523); //------------------------------------------------------------------------------
49448 // Public Interface
49449 //------------------------------------------------------------------------------
49450
49451 /**
49452 * A code path.
49453 */
49454
49455
49456 class CodePath {
49457 /**
49458 * Creates a new instance.
49459 * @param {Object} options Options for the function (see below).
49460 * @param {string} options.id An identifier.
49461 * @param {string} options.origin The type of code path origin.
49462 * @param {CodePath|null} options.upper The code path of the upper function scope.
49463 * @param {Function} options.onLooped A callback function to notify looping.
49464 */
49465 constructor(_ref) {
49466 let {
49467 id,
49468 origin,
49469 upper,
49470 onLooped
49471 } = _ref;
49472
49473 /**
49474 * The identifier of this code path.
49475 * Rules use it to store additional information of each rule.
49476 * @type {string}
49477 */
49478 this.id = id;
49479 /**
49480 * The reason that this code path was started. May be "program",
49481 * "function", "class-field-initializer", or "class-static-block".
49482 * @type {string}
49483 */
49484
49485 this.origin = origin;
49486 /**
49487 * The code path of the upper function scope.
49488 * @type {CodePath|null}
49489 */
49490
49491 this.upper = upper;
49492 /**
49493 * The code paths of nested function scopes.
49494 * @type {CodePath[]}
49495 */
49496
49497 this.childCodePaths = []; // Initializes internal state.
49498
49499 Object.defineProperty(this, "internal", {
49500 value: new CodePathState(new IdGenerator("".concat(id, "_")), onLooped)
49501 }); // Adds this into `childCodePaths` of `upper`.
49502
49503 if (upper) {
49504 upper.childCodePaths.push(this);
49505 }
49506 }
49507 /**
49508 * Gets the state of a given code path.
49509 * @param {CodePath} codePath A code path to get.
49510 * @returns {CodePathState} The state of the code path.
49511 */
49512
49513
49514 static getState(codePath) {
49515 return codePath.internal;
49516 }
49517 /**
49518 * The initial code path segment.
49519 * @type {CodePathSegment}
49520 */
49521
49522
49523 get initialSegment() {
49524 return this.internal.initialSegment;
49525 }
49526 /**
49527 * Final code path segments.
49528 * This array is a mix of `returnedSegments` and `thrownSegments`.
49529 * @type {CodePathSegment[]}
49530 */
49531
49532
49533 get finalSegments() {
49534 return this.internal.finalSegments;
49535 }
49536 /**
49537 * Final code path segments which is with `return` statements.
49538 * This array contains the last path segment if it's reachable.
49539 * Since the reachable last path returns `undefined`.
49540 * @type {CodePathSegment[]}
49541 */
49542
49543
49544 get returnedSegments() {
49545 return this.internal.returnedForkContext;
49546 }
49547 /**
49548 * Final code path segments which is with `throw` statements.
49549 * @type {CodePathSegment[]}
49550 */
49551
49552
49553 get thrownSegments() {
49554 return this.internal.thrownForkContext;
49555 }
49556 /**
49557 * Current code path segments.
49558 * @type {CodePathSegment[]}
49559 */
49560
49561
49562 get currentSegments() {
49563 return this.internal.currentSegments;
49564 }
49565 /**
49566 * Traverses all segments in this code path.
49567 *
49568 * codePath.traverseSegments(function(segment, controller) {
49569 * // do something.
49570 * });
49571 *
49572 * This method enumerates segments in order from the head.
49573 *
49574 * The `controller` object has two methods.
49575 *
49576 * - `controller.skip()` - Skip the following segments in this branch.
49577 * - `controller.break()` - Skip all following segments.
49578 * @param {Object} [options] Omittable.
49579 * @param {CodePathSegment} [options.first] The first segment to traverse.
49580 * @param {CodePathSegment} [options.last] The last segment to traverse.
49581 * @param {Function} callback A callback function.
49582 * @returns {void}
49583 */
49584
49585
49586 traverseSegments(options, callback) {
49587 let resolvedOptions;
49588 let resolvedCallback;
49589
49590 if (typeof options === "function") {
49591 resolvedCallback = options;
49592 resolvedOptions = {};
49593 } else {
49594 resolvedOptions = options || {};
49595 resolvedCallback = callback;
49596 }
49597
49598 const startSegment = resolvedOptions.first || this.internal.initialSegment;
49599 const lastSegment = resolvedOptions.last;
49600 let item = null;
49601 let index = 0;
49602 let end = 0;
49603 let segment = null;
49604 const visited = Object.create(null);
49605 const stack = [[startSegment, 0]];
49606 let skippedSegment = null;
49607 let broken = false;
49608 const controller = {
49609 skip() {
49610 if (stack.length <= 1) {
49611 broken = true;
49612 } else {
49613 skippedSegment = stack[stack.length - 2][0];
49614 }
49615 },
49616
49617 break() {
49618 broken = true;
49619 }
49620
49621 };
49622 /**
49623 * Checks a given previous segment has been visited.
49624 * @param {CodePathSegment} prevSegment A previous segment to check.
49625 * @returns {boolean} `true` if the segment has been visited.
49626 */
49627
49628 function isVisited(prevSegment) {
49629 return visited[prevSegment.id] || segment.isLoopedPrevSegment(prevSegment);
49630 }
49631
49632 while (stack.length > 0) {
49633 item = stack[stack.length - 1];
49634 segment = item[0];
49635 index = item[1];
49636
49637 if (index === 0) {
49638 // Skip if this segment has been visited already.
49639 if (visited[segment.id]) {
49640 stack.pop();
49641 continue;
49642 } // Skip if all previous segments have not been visited.
49643
49644
49645 if (segment !== startSegment && segment.prevSegments.length > 0 && !segment.prevSegments.every(isVisited)) {
49646 stack.pop();
49647 continue;
49648 } // Reset the flag of skipping if all branches have been skipped.
49649
49650
49651 if (skippedSegment && segment.prevSegments.indexOf(skippedSegment) !== -1) {
49652 skippedSegment = null;
49653 }
49654
49655 visited[segment.id] = true; // Call the callback when the first time.
49656
49657 if (!skippedSegment) {
49658 resolvedCallback.call(this, segment, controller);
49659
49660 if (segment === lastSegment) {
49661 controller.skip();
49662 }
49663
49664 if (broken) {
49665 break;
49666 }
49667 }
49668 } // Update the stack.
49669
49670
49671 end = segment.nextSegments.length - 1;
49672
49673 if (index < end) {
49674 item[1] += 1;
49675 stack.push([segment.nextSegments[index], 0]);
49676 } else if (index === end) {
49677 item[0] = segment.nextSegments[index];
49678 item[1] = 0;
49679 } else {
49680 stack.pop();
49681 }
49682 }
49683 }
49684
49685 }
49686
49687 module.exports = CodePath;
49688
49689 /***/ }),
49690 /* 519 */
49691 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
49692
49693 "use strict";
49694 /**
49695 * @fileoverview A class to manage state of generating a code path.
49696 * @author Toru Nagashima
49697 */
49698 //------------------------------------------------------------------------------
49699 // Requirements
49700 //------------------------------------------------------------------------------
49701
49702 const CodePathSegment = __webpack_require__(520),
49703 ForkContext = __webpack_require__(522); //------------------------------------------------------------------------------
49704 // Helpers
49705 //------------------------------------------------------------------------------
49706
49707 /**
49708 * Adds given segments into the `dest` array.
49709 * If the `others` array does not includes the given segments, adds to the `all`
49710 * array as well.
49711 *
49712 * This adds only reachable and used segments.
49713 * @param {CodePathSegment[]} dest A destination array (`returnedSegments` or `thrownSegments`).
49714 * @param {CodePathSegment[]} others Another destination array (`returnedSegments` or `thrownSegments`).
49715 * @param {CodePathSegment[]} all The unified destination array (`finalSegments`).
49716 * @param {CodePathSegment[]} segments Segments to add.
49717 * @returns {void}
49718 */
49719
49720
49721 function addToReturnedOrThrown(dest, others, all, segments) {
49722 for (let i = 0; i < segments.length; ++i) {
49723 const segment = segments[i];
49724 dest.push(segment);
49725
49726 if (others.indexOf(segment) === -1) {
49727 all.push(segment);
49728 }
49729 }
49730 }
49731 /**
49732 * Gets a loop-context for a `continue` statement.
49733 * @param {CodePathState} state A state to get.
49734 * @param {string} label The label of a `continue` statement.
49735 * @returns {LoopContext} A loop-context for a `continue` statement.
49736 */
49737
49738
49739 function getContinueContext(state, label) {
49740 if (!label) {
49741 return state.loopContext;
49742 }
49743
49744 let context = state.loopContext;
49745
49746 while (context) {
49747 if (context.label === label) {
49748 return context;
49749 }
49750
49751 context = context.upper;
49752 }
49753 /* istanbul ignore next: foolproof (syntax error) */
49754
49755
49756 return null;
49757 }
49758 /**
49759 * Gets a context for a `break` statement.
49760 * @param {CodePathState} state A state to get.
49761 * @param {string} label The label of a `break` statement.
49762 * @returns {LoopContext|SwitchContext} A context for a `break` statement.
49763 */
49764
49765
49766 function getBreakContext(state, label) {
49767 let context = state.breakContext;
49768
49769 while (context) {
49770 if (label ? context.label === label : context.breakable) {
49771 return context;
49772 }
49773
49774 context = context.upper;
49775 }
49776 /* istanbul ignore next: foolproof (syntax error) */
49777
49778
49779 return null;
49780 }
49781 /**
49782 * Gets a context for a `return` statement.
49783 * @param {CodePathState} state A state to get.
49784 * @returns {TryContext|CodePathState} A context for a `return` statement.
49785 */
49786
49787
49788 function getReturnContext(state) {
49789 let context = state.tryContext;
49790
49791 while (context) {
49792 if (context.hasFinalizer && context.position !== "finally") {
49793 return context;
49794 }
49795
49796 context = context.upper;
49797 }
49798
49799 return state;
49800 }
49801 /**
49802 * Gets a context for a `throw` statement.
49803 * @param {CodePathState} state A state to get.
49804 * @returns {TryContext|CodePathState} A context for a `throw` statement.
49805 */
49806
49807
49808 function getThrowContext(state) {
49809 let context = state.tryContext;
49810
49811 while (context) {
49812 if (context.position === "try" || context.hasFinalizer && context.position === "catch") {
49813 return context;
49814 }
49815
49816 context = context.upper;
49817 }
49818
49819 return state;
49820 }
49821 /**
49822 * Removes a given element from a given array.
49823 * @param {any[]} xs An array to remove the specific element.
49824 * @param {any} x An element to be removed.
49825 * @returns {void}
49826 */
49827
49828
49829 function remove(xs, x) {
49830 xs.splice(xs.indexOf(x), 1);
49831 }
49832 /**
49833 * Disconnect given segments.
49834 *
49835 * This is used in a process for switch statements.
49836 * If there is the "default" chunk before other cases, the order is different
49837 * between node's and running's.
49838 * @param {CodePathSegment[]} prevSegments Forward segments to disconnect.
49839 * @param {CodePathSegment[]} nextSegments Backward segments to disconnect.
49840 * @returns {void}
49841 */
49842
49843
49844 function removeConnection(prevSegments, nextSegments) {
49845 for (let i = 0; i < prevSegments.length; ++i) {
49846 const prevSegment = prevSegments[i];
49847 const nextSegment = nextSegments[i];
49848 remove(prevSegment.nextSegments, nextSegment);
49849 remove(prevSegment.allNextSegments, nextSegment);
49850 remove(nextSegment.prevSegments, prevSegment);
49851 remove(nextSegment.allPrevSegments, prevSegment);
49852 }
49853 }
49854 /**
49855 * Creates looping path.
49856 * @param {CodePathState} state The instance.
49857 * @param {CodePathSegment[]} unflattenedFromSegments Segments which are source.
49858 * @param {CodePathSegment[]} unflattenedToSegments Segments which are destination.
49859 * @returns {void}
49860 */
49861
49862
49863 function makeLooped(state, unflattenedFromSegments, unflattenedToSegments) {
49864 const fromSegments = CodePathSegment.flattenUnusedSegments(unflattenedFromSegments);
49865 const toSegments = CodePathSegment.flattenUnusedSegments(unflattenedToSegments);
49866 const end = Math.min(fromSegments.length, toSegments.length);
49867
49868 for (let i = 0; i < end; ++i) {
49869 const fromSegment = fromSegments[i];
49870 const toSegment = toSegments[i];
49871
49872 if (toSegment.reachable) {
49873 fromSegment.nextSegments.push(toSegment);
49874 }
49875
49876 if (fromSegment.reachable) {
49877 toSegment.prevSegments.push(fromSegment);
49878 }
49879
49880 fromSegment.allNextSegments.push(toSegment);
49881 toSegment.allPrevSegments.push(fromSegment);
49882
49883 if (toSegment.allPrevSegments.length >= 2) {
49884 CodePathSegment.markPrevSegmentAsLooped(toSegment, fromSegment);
49885 }
49886
49887 state.notifyLooped(fromSegment, toSegment);
49888 }
49889 }
49890 /**
49891 * Finalizes segments of `test` chunk of a ForStatement.
49892 *
49893 * - Adds `false` paths to paths which are leaving from the loop.
49894 * - Sets `true` paths to paths which go to the body.
49895 * @param {LoopContext} context A loop context to modify.
49896 * @param {ChoiceContext} choiceContext A choice context of this loop.
49897 * @param {CodePathSegment[]} head The current head paths.
49898 * @returns {void}
49899 */
49900
49901
49902 function finalizeTestSegmentsOfFor(context, choiceContext, head) {
49903 if (!choiceContext.processed) {
49904 choiceContext.trueForkContext.add(head);
49905 choiceContext.falseForkContext.add(head);
49906 choiceContext.qqForkContext.add(head);
49907 }
49908
49909 if (context.test !== true) {
49910 context.brokenForkContext.addAll(choiceContext.falseForkContext);
49911 }
49912
49913 context.endOfTestSegments = choiceContext.trueForkContext.makeNext(0, -1);
49914 } //------------------------------------------------------------------------------
49915 // Public Interface
49916 //------------------------------------------------------------------------------
49917
49918 /**
49919 * A class which manages state to analyze code paths.
49920 */
49921
49922
49923 class CodePathState {
49924 /**
49925 * @param {IdGenerator} idGenerator An id generator to generate id for code
49926 * path segments.
49927 * @param {Function} onLooped A callback function to notify looping.
49928 */
49929 constructor(idGenerator, onLooped) {
49930 this.idGenerator = idGenerator;
49931 this.notifyLooped = onLooped;
49932 this.forkContext = ForkContext.newRoot(idGenerator);
49933 this.choiceContext = null;
49934 this.switchContext = null;
49935 this.tryContext = null;
49936 this.loopContext = null;
49937 this.breakContext = null;
49938 this.chainContext = null;
49939 this.currentSegments = [];
49940 this.initialSegment = this.forkContext.head[0]; // returnedSegments and thrownSegments push elements into finalSegments also.
49941
49942 const final = this.finalSegments = [];
49943 const returned = this.returnedForkContext = [];
49944 const thrown = this.thrownForkContext = [];
49945 returned.add = addToReturnedOrThrown.bind(null, returned, thrown, final);
49946 thrown.add = addToReturnedOrThrown.bind(null, thrown, returned, final);
49947 }
49948 /**
49949 * The head segments.
49950 * @type {CodePathSegment[]}
49951 */
49952
49953
49954 get headSegments() {
49955 return this.forkContext.head;
49956 }
49957 /**
49958 * The parent forking context.
49959 * This is used for the root of new forks.
49960 * @type {ForkContext}
49961 */
49962
49963
49964 get parentForkContext() {
49965 const current = this.forkContext;
49966 return current && current.upper;
49967 }
49968 /**
49969 * Creates and stacks new forking context.
49970 * @param {boolean} forkLeavingPath A flag which shows being in a
49971 * "finally" block.
49972 * @returns {ForkContext} The created context.
49973 */
49974
49975
49976 pushForkContext(forkLeavingPath) {
49977 this.forkContext = ForkContext.newEmpty(this.forkContext, forkLeavingPath);
49978 return this.forkContext;
49979 }
49980 /**
49981 * Pops and merges the last forking context.
49982 * @returns {ForkContext} The last context.
49983 */
49984
49985
49986 popForkContext() {
49987 const lastContext = this.forkContext;
49988 this.forkContext = lastContext.upper;
49989 this.forkContext.replaceHead(lastContext.makeNext(0, -1));
49990 return lastContext;
49991 }
49992 /**
49993 * Creates a new path.
49994 * @returns {void}
49995 */
49996
49997
49998 forkPath() {
49999 this.forkContext.add(this.parentForkContext.makeNext(-1, -1));
50000 }
50001 /**
50002 * Creates a bypass path.
50003 * This is used for such as IfStatement which does not have "else" chunk.
50004 * @returns {void}
50005 */
50006
50007
50008 forkBypassPath() {
50009 this.forkContext.add(this.parentForkContext.head);
50010 } //--------------------------------------------------------------------------
50011 // ConditionalExpression, LogicalExpression, IfStatement
50012 //--------------------------------------------------------------------------
50013
50014 /**
50015 * Creates a context for ConditionalExpression, LogicalExpression, AssignmentExpression (logical assignments only),
50016 * IfStatement, WhileStatement, DoWhileStatement, or ForStatement.
50017 *
50018 * LogicalExpressions have cases that it goes different paths between the
50019 * `true` case and the `false` case.
50020 *
50021 * For Example:
50022 *
50023 * if (a || b) {
50024 * foo();
50025 * } else {
50026 * bar();
50027 * }
50028 *
50029 * In this case, `b` is evaluated always in the code path of the `else`
50030 * block, but it's not so in the code path of the `if` block.
50031 * So there are 3 paths.
50032 *
50033 * a -> foo();
50034 * a -> b -> foo();
50035 * a -> b -> bar();
50036 * @param {string} kind A kind string.
50037 * If the new context is LogicalExpression's or AssignmentExpression's, this is `"&&"` or `"||"` or `"??"`.
50038 * If it's IfStatement's or ConditionalExpression's, this is `"test"`.
50039 * Otherwise, this is `"loop"`.
50040 * @param {boolean} isForkingAsResult A flag that shows that goes different
50041 * paths between `true` and `false`.
50042 * @returns {void}
50043 */
50044
50045
50046 pushChoiceContext(kind, isForkingAsResult) {
50047 this.choiceContext = {
50048 upper: this.choiceContext,
50049 kind,
50050 isForkingAsResult,
50051 trueForkContext: ForkContext.newEmpty(this.forkContext),
50052 falseForkContext: ForkContext.newEmpty(this.forkContext),
50053 qqForkContext: ForkContext.newEmpty(this.forkContext),
50054 processed: false
50055 };
50056 }
50057 /**
50058 * Pops the last choice context and finalizes it.
50059 * @throws {Error} (Unreachable.)
50060 * @returns {ChoiceContext} The popped context.
50061 */
50062
50063
50064 popChoiceContext() {
50065 const context = this.choiceContext;
50066 this.choiceContext = context.upper;
50067 const forkContext = this.forkContext;
50068 const headSegments = forkContext.head;
50069
50070 switch (context.kind) {
50071 case "&&":
50072 case "||":
50073 case "??":
50074 /*
50075 * If any result were not transferred from child contexts,
50076 * this sets the head segments to both cases.
50077 * The head segments are the path of the right-hand operand.
50078 */
50079 if (!context.processed) {
50080 context.trueForkContext.add(headSegments);
50081 context.falseForkContext.add(headSegments);
50082 context.qqForkContext.add(headSegments);
50083 }
50084 /*
50085 * Transfers results to upper context if this context is in
50086 * test chunk.
50087 */
50088
50089
50090 if (context.isForkingAsResult) {
50091 const parentContext = this.choiceContext;
50092 parentContext.trueForkContext.addAll(context.trueForkContext);
50093 parentContext.falseForkContext.addAll(context.falseForkContext);
50094 parentContext.qqForkContext.addAll(context.qqForkContext);
50095 parentContext.processed = true;
50096 return context;
50097 }
50098
50099 break;
50100
50101 case "test":
50102 if (!context.processed) {
50103 /*
50104 * The head segments are the path of the `if` block here.
50105 * Updates the `true` path with the end of the `if` block.
50106 */
50107 context.trueForkContext.clear();
50108 context.trueForkContext.add(headSegments);
50109 } else {
50110 /*
50111 * The head segments are the path of the `else` block here.
50112 * Updates the `false` path with the end of the `else`
50113 * block.
50114 */
50115 context.falseForkContext.clear();
50116 context.falseForkContext.add(headSegments);
50117 }
50118
50119 break;
50120
50121 case "loop":
50122 /*
50123 * Loops are addressed in popLoopContext().
50124 * This is called from popLoopContext().
50125 */
50126 return context;
50127
50128 /* istanbul ignore next */
50129
50130 default:
50131 throw new Error("unreachable");
50132 } // Merges all paths.
50133
50134
50135 const prevForkContext = context.trueForkContext;
50136 prevForkContext.addAll(context.falseForkContext);
50137 forkContext.replaceHead(prevForkContext.makeNext(0, -1));
50138 return context;
50139 }
50140 /**
50141 * Makes a code path segment of the right-hand operand of a logical
50142 * expression.
50143 * @throws {Error} (Unreachable.)
50144 * @returns {void}
50145 */
50146
50147
50148 makeLogicalRight() {
50149 const context = this.choiceContext;
50150 const forkContext = this.forkContext;
50151
50152 if (context.processed) {
50153 /*
50154 * This got segments already from the child choice context.
50155 * Creates the next path from own true/false fork context.
50156 */
50157 let prevForkContext;
50158
50159 switch (context.kind) {
50160 case "&&":
50161 // if true then go to the right-hand side.
50162 prevForkContext = context.trueForkContext;
50163 break;
50164
50165 case "||":
50166 // if false then go to the right-hand side.
50167 prevForkContext = context.falseForkContext;
50168 break;
50169
50170 case "??":
50171 // Both true/false can short-circuit, so needs the third path to go to the right-hand side. That's qqForkContext.
50172 prevForkContext = context.qqForkContext;
50173 break;
50174
50175 default:
50176 throw new Error("unreachable");
50177 }
50178
50179 forkContext.replaceHead(prevForkContext.makeNext(0, -1));
50180 prevForkContext.clear();
50181 context.processed = false;
50182 } else {
50183 /*
50184 * This did not get segments from the child choice context.
50185 * So addresses the head segments.
50186 * The head segments are the path of the left-hand operand.
50187 */
50188 switch (context.kind) {
50189 case "&&":
50190 // the false path can short-circuit.
50191 context.falseForkContext.add(forkContext.head);
50192 break;
50193
50194 case "||":
50195 // the true path can short-circuit.
50196 context.trueForkContext.add(forkContext.head);
50197 break;
50198
50199 case "??":
50200 // both can short-circuit.
50201 context.trueForkContext.add(forkContext.head);
50202 context.falseForkContext.add(forkContext.head);
50203 break;
50204
50205 default:
50206 throw new Error("unreachable");
50207 }
50208
50209 forkContext.replaceHead(forkContext.makeNext(-1, -1));
50210 }
50211 }
50212 /**
50213 * Makes a code path segment of the `if` block.
50214 * @returns {void}
50215 */
50216
50217
50218 makeIfConsequent() {
50219 const context = this.choiceContext;
50220 const forkContext = this.forkContext;
50221 /*
50222 * If any result were not transferred from child contexts,
50223 * this sets the head segments to both cases.
50224 * The head segments are the path of the test expression.
50225 */
50226
50227 if (!context.processed) {
50228 context.trueForkContext.add(forkContext.head);
50229 context.falseForkContext.add(forkContext.head);
50230 context.qqForkContext.add(forkContext.head);
50231 }
50232
50233 context.processed = false; // Creates new path from the `true` case.
50234
50235 forkContext.replaceHead(context.trueForkContext.makeNext(0, -1));
50236 }
50237 /**
50238 * Makes a code path segment of the `else` block.
50239 * @returns {void}
50240 */
50241
50242
50243 makeIfAlternate() {
50244 const context = this.choiceContext;
50245 const forkContext = this.forkContext;
50246 /*
50247 * The head segments are the path of the `if` block.
50248 * Updates the `true` path with the end of the `if` block.
50249 */
50250
50251 context.trueForkContext.clear();
50252 context.trueForkContext.add(forkContext.head);
50253 context.processed = true; // Creates new path from the `false` case.
50254
50255 forkContext.replaceHead(context.falseForkContext.makeNext(0, -1));
50256 } //--------------------------------------------------------------------------
50257 // ChainExpression
50258 //--------------------------------------------------------------------------
50259
50260 /**
50261 * Push a new `ChainExpression` context to the stack.
50262 * This method is called on entering to each `ChainExpression` node.
50263 * This context is used to count forking in the optional chain then merge them on the exiting from the `ChainExpression` node.
50264 * @returns {void}
50265 */
50266
50267
50268 pushChainContext() {
50269 this.chainContext = {
50270 upper: this.chainContext,
50271 countChoiceContexts: 0
50272 };
50273 }
50274 /**
50275 * Pop a `ChainExpression` context from the stack.
50276 * This method is called on exiting from each `ChainExpression` node.
50277 * This merges all forks of the last optional chaining.
50278 * @returns {void}
50279 */
50280
50281
50282 popChainContext() {
50283 const context = this.chainContext;
50284 this.chainContext = context.upper; // pop all choice contexts of this.
50285
50286 for (let i = context.countChoiceContexts; i > 0; --i) {
50287 this.popChoiceContext();
50288 }
50289 }
50290 /**
50291 * Create a choice context for optional access.
50292 * This method is called on entering to each `(Call|Member)Expression[optional=true]` node.
50293 * This creates a choice context as similar to `LogicalExpression[operator="??"]` node.
50294 * @returns {void}
50295 */
50296
50297
50298 makeOptionalNode() {
50299 if (this.chainContext) {
50300 this.chainContext.countChoiceContexts += 1;
50301 this.pushChoiceContext("??", false);
50302 }
50303 }
50304 /**
50305 * Create a fork.
50306 * This method is called on entering to the `arguments|property` property of each `(Call|Member)Expression` node.
50307 * @returns {void}
50308 */
50309
50310
50311 makeOptionalRight() {
50312 if (this.chainContext) {
50313 this.makeLogicalRight();
50314 }
50315 } //--------------------------------------------------------------------------
50316 // SwitchStatement
50317 //--------------------------------------------------------------------------
50318
50319 /**
50320 * Creates a context object of SwitchStatement and stacks it.
50321 * @param {boolean} hasCase `true` if the switch statement has one or more
50322 * case parts.
50323 * @param {string|null} label The label text.
50324 * @returns {void}
50325 */
50326
50327
50328 pushSwitchContext(hasCase, label) {
50329 this.switchContext = {
50330 upper: this.switchContext,
50331 hasCase,
50332 defaultSegments: null,
50333 defaultBodySegments: null,
50334 foundDefault: false,
50335 lastIsDefault: false,
50336 countForks: 0
50337 };
50338 this.pushBreakContext(true, label);
50339 }
50340 /**
50341 * Pops the last context of SwitchStatement and finalizes it.
50342 *
50343 * - Disposes all forking stack for `case` and `default`.
50344 * - Creates the next code path segment from `context.brokenForkContext`.
50345 * - If the last `SwitchCase` node is not a `default` part, creates a path
50346 * to the `default` body.
50347 * @returns {void}
50348 */
50349
50350
50351 popSwitchContext() {
50352 const context = this.switchContext;
50353 this.switchContext = context.upper;
50354 const forkContext = this.forkContext;
50355 const brokenForkContext = this.popBreakContext().brokenForkContext;
50356
50357 if (context.countForks === 0) {
50358 /*
50359 * When there is only one `default` chunk and there is one or more
50360 * `break` statements, even if forks are nothing, it needs to merge
50361 * those.
50362 */
50363 if (!brokenForkContext.empty) {
50364 brokenForkContext.add(forkContext.makeNext(-1, -1));
50365 forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
50366 }
50367
50368 return;
50369 }
50370
50371 const lastSegments = forkContext.head;
50372 this.forkBypassPath();
50373 const lastCaseSegments = forkContext.head;
50374 /*
50375 * `brokenForkContext` is used to make the next segment.
50376 * It must add the last segment into `brokenForkContext`.
50377 */
50378
50379 brokenForkContext.add(lastSegments);
50380 /*
50381 * A path which is failed in all case test should be connected to path
50382 * of `default` chunk.
50383 */
50384
50385 if (!context.lastIsDefault) {
50386 if (context.defaultBodySegments) {
50387 /*
50388 * Remove a link from `default` label to its chunk.
50389 * It's false route.
50390 */
50391 removeConnection(context.defaultSegments, context.defaultBodySegments);
50392 makeLooped(this, lastCaseSegments, context.defaultBodySegments);
50393 } else {
50394 /*
50395 * It handles the last case body as broken if `default` chunk
50396 * does not exist.
50397 */
50398 brokenForkContext.add(lastCaseSegments);
50399 }
50400 } // Pops the segment context stack until the entry segment.
50401
50402
50403 for (let i = 0; i < context.countForks; ++i) {
50404 this.forkContext = this.forkContext.upper;
50405 }
50406 /*
50407 * Creates a path from all brokenForkContext paths.
50408 * This is a path after switch statement.
50409 */
50410
50411
50412 this.forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
50413 }
50414 /**
50415 * Makes a code path segment for a `SwitchCase` node.
50416 * @param {boolean} isEmpty `true` if the body is empty.
50417 * @param {boolean} isDefault `true` if the body is the default case.
50418 * @returns {void}
50419 */
50420
50421
50422 makeSwitchCaseBody(isEmpty, isDefault) {
50423 const context = this.switchContext;
50424
50425 if (!context.hasCase) {
50426 return;
50427 }
50428 /*
50429 * Merge forks.
50430 * The parent fork context has two segments.
50431 * Those are from the current case and the body of the previous case.
50432 */
50433
50434
50435 const parentForkContext = this.forkContext;
50436 const forkContext = this.pushForkContext();
50437 forkContext.add(parentForkContext.makeNext(0, -1));
50438 /*
50439 * Save `default` chunk info.
50440 * If the `default` label is not at the last, we must make a path from
50441 * the last `case` to the `default` chunk.
50442 */
50443
50444 if (isDefault) {
50445 context.defaultSegments = parentForkContext.head;
50446
50447 if (isEmpty) {
50448 context.foundDefault = true;
50449 } else {
50450 context.defaultBodySegments = forkContext.head;
50451 }
50452 } else {
50453 if (!isEmpty && context.foundDefault) {
50454 context.foundDefault = false;
50455 context.defaultBodySegments = forkContext.head;
50456 }
50457 }
50458
50459 context.lastIsDefault = isDefault;
50460 context.countForks += 1;
50461 } //--------------------------------------------------------------------------
50462 // TryStatement
50463 //--------------------------------------------------------------------------
50464
50465 /**
50466 * Creates a context object of TryStatement and stacks it.
50467 * @param {boolean} hasFinalizer `true` if the try statement has a
50468 * `finally` block.
50469 * @returns {void}
50470 */
50471
50472
50473 pushTryContext(hasFinalizer) {
50474 this.tryContext = {
50475 upper: this.tryContext,
50476 position: "try",
50477 hasFinalizer,
50478 returnedForkContext: hasFinalizer ? ForkContext.newEmpty(this.forkContext) : null,
50479 thrownForkContext: ForkContext.newEmpty(this.forkContext),
50480 lastOfTryIsReachable: false,
50481 lastOfCatchIsReachable: false
50482 };
50483 }
50484 /**
50485 * Pops the last context of TryStatement and finalizes it.
50486 * @returns {void}
50487 */
50488
50489
50490 popTryContext() {
50491 const context = this.tryContext;
50492 this.tryContext = context.upper;
50493
50494 if (context.position === "catch") {
50495 // Merges two paths from the `try` block and `catch` block merely.
50496 this.popForkContext();
50497 return;
50498 }
50499 /*
50500 * The following process is executed only when there is the `finally`
50501 * block.
50502 */
50503
50504
50505 const returned = context.returnedForkContext;
50506 const thrown = context.thrownForkContext;
50507
50508 if (returned.empty && thrown.empty) {
50509 return;
50510 } // Separate head to normal paths and leaving paths.
50511
50512
50513 const headSegments = this.forkContext.head;
50514 this.forkContext = this.forkContext.upper;
50515 const normalSegments = headSegments.slice(0, headSegments.length / 2 | 0);
50516 const leavingSegments = headSegments.slice(headSegments.length / 2 | 0); // Forwards the leaving path to upper contexts.
50517
50518 if (!returned.empty) {
50519 getReturnContext(this).returnedForkContext.add(leavingSegments);
50520 }
50521
50522 if (!thrown.empty) {
50523 getThrowContext(this).thrownForkContext.add(leavingSegments);
50524 } // Sets the normal path as the next.
50525
50526
50527 this.forkContext.replaceHead(normalSegments);
50528 /*
50529 * If both paths of the `try` block and the `catch` block are
50530 * unreachable, the next path becomes unreachable as well.
50531 */
50532
50533 if (!context.lastOfTryIsReachable && !context.lastOfCatchIsReachable) {
50534 this.forkContext.makeUnreachable();
50535 }
50536 }
50537 /**
50538 * Makes a code path segment for a `catch` block.
50539 * @returns {void}
50540 */
50541
50542
50543 makeCatchBlock() {
50544 const context = this.tryContext;
50545 const forkContext = this.forkContext;
50546 const thrown = context.thrownForkContext; // Update state.
50547
50548 context.position = "catch";
50549 context.thrownForkContext = ForkContext.newEmpty(forkContext);
50550 context.lastOfTryIsReachable = forkContext.reachable; // Merge thrown paths.
50551
50552 thrown.add(forkContext.head);
50553 const thrownSegments = thrown.makeNext(0, -1); // Fork to a bypass and the merged thrown path.
50554
50555 this.pushForkContext();
50556 this.forkBypassPath();
50557 this.forkContext.add(thrownSegments);
50558 }
50559 /**
50560 * Makes a code path segment for a `finally` block.
50561 *
50562 * In the `finally` block, parallel paths are created. The parallel paths
50563 * are used as leaving-paths. The leaving-paths are paths from `return`
50564 * statements and `throw` statements in a `try` block or a `catch` block.
50565 * @returns {void}
50566 */
50567
50568
50569 makeFinallyBlock() {
50570 const context = this.tryContext;
50571 let forkContext = this.forkContext;
50572 const returned = context.returnedForkContext;
50573 const thrown = context.thrownForkContext;
50574 const headOfLeavingSegments = forkContext.head; // Update state.
50575
50576 if (context.position === "catch") {
50577 // Merges two paths from the `try` block and `catch` block.
50578 this.popForkContext();
50579 forkContext = this.forkContext;
50580 context.lastOfCatchIsReachable = forkContext.reachable;
50581 } else {
50582 context.lastOfTryIsReachable = forkContext.reachable;
50583 }
50584
50585 context.position = "finally";
50586
50587 if (returned.empty && thrown.empty) {
50588 // This path does not leave.
50589 return;
50590 }
50591 /*
50592 * Create a parallel segment from merging returned and thrown.
50593 * This segment will leave at the end of this finally block.
50594 */
50595
50596
50597 const segments = forkContext.makeNext(-1, -1);
50598
50599 for (let i = 0; i < forkContext.count; ++i) {
50600 const prevSegsOfLeavingSegment = [headOfLeavingSegments[i]];
50601
50602 for (let j = 0; j < returned.segmentsList.length; ++j) {
50603 prevSegsOfLeavingSegment.push(returned.segmentsList[j][i]);
50604 }
50605
50606 for (let j = 0; j < thrown.segmentsList.length; ++j) {
50607 prevSegsOfLeavingSegment.push(thrown.segmentsList[j][i]);
50608 }
50609
50610 segments.push(CodePathSegment.newNext(this.idGenerator.next(), prevSegsOfLeavingSegment));
50611 }
50612
50613 this.pushForkContext(true);
50614 this.forkContext.add(segments);
50615 }
50616 /**
50617 * Makes a code path segment from the first throwable node to the `catch`
50618 * block or the `finally` block.
50619 * @returns {void}
50620 */
50621
50622
50623 makeFirstThrowablePathInTryBlock() {
50624 const forkContext = this.forkContext;
50625
50626 if (!forkContext.reachable) {
50627 return;
50628 }
50629
50630 const context = getThrowContext(this);
50631
50632 if (context === this || context.position !== "try" || !context.thrownForkContext.empty) {
50633 return;
50634 }
50635
50636 context.thrownForkContext.add(forkContext.head);
50637 forkContext.replaceHead(forkContext.makeNext(-1, -1));
50638 } //--------------------------------------------------------------------------
50639 // Loop Statements
50640 //--------------------------------------------------------------------------
50641
50642 /**
50643 * Creates a context object of a loop statement and stacks it.
50644 * @param {string} type The type of the node which was triggered. One of
50645 * `WhileStatement`, `DoWhileStatement`, `ForStatement`, `ForInStatement`,
50646 * and `ForStatement`.
50647 * @param {string|null} label A label of the node which was triggered.
50648 * @throws {Error} (Unreachable - unknown type.)
50649 * @returns {void}
50650 */
50651
50652
50653 pushLoopContext(type, label) {
50654 const forkContext = this.forkContext;
50655 const breakContext = this.pushBreakContext(true, label);
50656
50657 switch (type) {
50658 case "WhileStatement":
50659 this.pushChoiceContext("loop", false);
50660 this.loopContext = {
50661 upper: this.loopContext,
50662 type,
50663 label,
50664 test: void 0,
50665 continueDestSegments: null,
50666 brokenForkContext: breakContext.brokenForkContext
50667 };
50668 break;
50669
50670 case "DoWhileStatement":
50671 this.pushChoiceContext("loop", false);
50672 this.loopContext = {
50673 upper: this.loopContext,
50674 type,
50675 label,
50676 test: void 0,
50677 entrySegments: null,
50678 continueForkContext: ForkContext.newEmpty(forkContext),
50679 brokenForkContext: breakContext.brokenForkContext
50680 };
50681 break;
50682
50683 case "ForStatement":
50684 this.pushChoiceContext("loop", false);
50685 this.loopContext = {
50686 upper: this.loopContext,
50687 type,
50688 label,
50689 test: void 0,
50690 endOfInitSegments: null,
50691 testSegments: null,
50692 endOfTestSegments: null,
50693 updateSegments: null,
50694 endOfUpdateSegments: null,
50695 continueDestSegments: null,
50696 brokenForkContext: breakContext.brokenForkContext
50697 };
50698 break;
50699
50700 case "ForInStatement":
50701 case "ForOfStatement":
50702 this.loopContext = {
50703 upper: this.loopContext,
50704 type,
50705 label,
50706 prevSegments: null,
50707 leftSegments: null,
50708 endOfLeftSegments: null,
50709 continueDestSegments: null,
50710 brokenForkContext: breakContext.brokenForkContext
50711 };
50712 break;
50713
50714 /* istanbul ignore next */
50715
50716 default:
50717 throw new Error("unknown type: \"".concat(type, "\""));
50718 }
50719 }
50720 /**
50721 * Pops the last context of a loop statement and finalizes it.
50722 * @throws {Error} (Unreachable - unknown type.)
50723 * @returns {void}
50724 */
50725
50726
50727 popLoopContext() {
50728 const context = this.loopContext;
50729 this.loopContext = context.upper;
50730 const forkContext = this.forkContext;
50731 const brokenForkContext = this.popBreakContext().brokenForkContext; // Creates a looped path.
50732
50733 switch (context.type) {
50734 case "WhileStatement":
50735 case "ForStatement":
50736 this.popChoiceContext();
50737 makeLooped(this, forkContext.head, context.continueDestSegments);
50738 break;
50739
50740 case "DoWhileStatement":
50741 {
50742 const choiceContext = this.popChoiceContext();
50743
50744 if (!choiceContext.processed) {
50745 choiceContext.trueForkContext.add(forkContext.head);
50746 choiceContext.falseForkContext.add(forkContext.head);
50747 }
50748
50749 if (context.test !== true) {
50750 brokenForkContext.addAll(choiceContext.falseForkContext);
50751 } // `true` paths go to looping.
50752
50753
50754 const segmentsList = choiceContext.trueForkContext.segmentsList;
50755
50756 for (let i = 0; i < segmentsList.length; ++i) {
50757 makeLooped(this, segmentsList[i], context.entrySegments);
50758 }
50759
50760 break;
50761 }
50762
50763 case "ForInStatement":
50764 case "ForOfStatement":
50765 brokenForkContext.add(forkContext.head);
50766 makeLooped(this, forkContext.head, context.leftSegments);
50767 break;
50768
50769 /* istanbul ignore next */
50770
50771 default:
50772 throw new Error("unreachable");
50773 } // Go next.
50774
50775
50776 if (brokenForkContext.empty) {
50777 forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
50778 } else {
50779 forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
50780 }
50781 }
50782 /**
50783 * Makes a code path segment for the test part of a WhileStatement.
50784 * @param {boolean|undefined} test The test value (only when constant).
50785 * @returns {void}
50786 */
50787
50788
50789 makeWhileTest(test) {
50790 const context = this.loopContext;
50791 const forkContext = this.forkContext;
50792 const testSegments = forkContext.makeNext(0, -1); // Update state.
50793
50794 context.test = test;
50795 context.continueDestSegments = testSegments;
50796 forkContext.replaceHead(testSegments);
50797 }
50798 /**
50799 * Makes a code path segment for the body part of a WhileStatement.
50800 * @returns {void}
50801 */
50802
50803
50804 makeWhileBody() {
50805 const context = this.loopContext;
50806 const choiceContext = this.choiceContext;
50807 const forkContext = this.forkContext;
50808
50809 if (!choiceContext.processed) {
50810 choiceContext.trueForkContext.add(forkContext.head);
50811 choiceContext.falseForkContext.add(forkContext.head);
50812 } // Update state.
50813
50814
50815 if (context.test !== true) {
50816 context.brokenForkContext.addAll(choiceContext.falseForkContext);
50817 }
50818
50819 forkContext.replaceHead(choiceContext.trueForkContext.makeNext(0, -1));
50820 }
50821 /**
50822 * Makes a code path segment for the body part of a DoWhileStatement.
50823 * @returns {void}
50824 */
50825
50826
50827 makeDoWhileBody() {
50828 const context = this.loopContext;
50829 const forkContext = this.forkContext;
50830 const bodySegments = forkContext.makeNext(-1, -1); // Update state.
50831
50832 context.entrySegments = bodySegments;
50833 forkContext.replaceHead(bodySegments);
50834 }
50835 /**
50836 * Makes a code path segment for the test part of a DoWhileStatement.
50837 * @param {boolean|undefined} test The test value (only when constant).
50838 * @returns {void}
50839 */
50840
50841
50842 makeDoWhileTest(test) {
50843 const context = this.loopContext;
50844 const forkContext = this.forkContext;
50845 context.test = test; // Creates paths of `continue` statements.
50846
50847 if (!context.continueForkContext.empty) {
50848 context.continueForkContext.add(forkContext.head);
50849 const testSegments = context.continueForkContext.makeNext(0, -1);
50850 forkContext.replaceHead(testSegments);
50851 }
50852 }
50853 /**
50854 * Makes a code path segment for the test part of a ForStatement.
50855 * @param {boolean|undefined} test The test value (only when constant).
50856 * @returns {void}
50857 */
50858
50859
50860 makeForTest(test) {
50861 const context = this.loopContext;
50862 const forkContext = this.forkContext;
50863 const endOfInitSegments = forkContext.head;
50864 const testSegments = forkContext.makeNext(-1, -1); // Update state.
50865
50866 context.test = test;
50867 context.endOfInitSegments = endOfInitSegments;
50868 context.continueDestSegments = context.testSegments = testSegments;
50869 forkContext.replaceHead(testSegments);
50870 }
50871 /**
50872 * Makes a code path segment for the update part of a ForStatement.
50873 * @returns {void}
50874 */
50875
50876
50877 makeForUpdate() {
50878 const context = this.loopContext;
50879 const choiceContext = this.choiceContext;
50880 const forkContext = this.forkContext; // Make the next paths of the test.
50881
50882 if (context.testSegments) {
50883 finalizeTestSegmentsOfFor(context, choiceContext, forkContext.head);
50884 } else {
50885 context.endOfInitSegments = forkContext.head;
50886 } // Update state.
50887
50888
50889 const updateSegments = forkContext.makeDisconnected(-1, -1);
50890 context.continueDestSegments = context.updateSegments = updateSegments;
50891 forkContext.replaceHead(updateSegments);
50892 }
50893 /**
50894 * Makes a code path segment for the body part of a ForStatement.
50895 * @returns {void}
50896 */
50897
50898
50899 makeForBody() {
50900 const context = this.loopContext;
50901 const choiceContext = this.choiceContext;
50902 const forkContext = this.forkContext; // Update state.
50903
50904 if (context.updateSegments) {
50905 context.endOfUpdateSegments = forkContext.head; // `update` -> `test`
50906
50907 if (context.testSegments) {
50908 makeLooped(this, context.endOfUpdateSegments, context.testSegments);
50909 }
50910 } else if (context.testSegments) {
50911 finalizeTestSegmentsOfFor(context, choiceContext, forkContext.head);
50912 } else {
50913 context.endOfInitSegments = forkContext.head;
50914 }
50915
50916 let bodySegments = context.endOfTestSegments;
50917
50918 if (!bodySegments) {
50919 /*
50920 * If there is not the `test` part, the `body` path comes from the
50921 * `init` part and the `update` part.
50922 */
50923 const prevForkContext = ForkContext.newEmpty(forkContext);
50924 prevForkContext.add(context.endOfInitSegments);
50925
50926 if (context.endOfUpdateSegments) {
50927 prevForkContext.add(context.endOfUpdateSegments);
50928 }
50929
50930 bodySegments = prevForkContext.makeNext(0, -1);
50931 }
50932
50933 context.continueDestSegments = context.continueDestSegments || bodySegments;
50934 forkContext.replaceHead(bodySegments);
50935 }
50936 /**
50937 * Makes a code path segment for the left part of a ForInStatement and a
50938 * ForOfStatement.
50939 * @returns {void}
50940 */
50941
50942
50943 makeForInOfLeft() {
50944 const context = this.loopContext;
50945 const forkContext = this.forkContext;
50946 const leftSegments = forkContext.makeDisconnected(-1, -1); // Update state.
50947
50948 context.prevSegments = forkContext.head;
50949 context.leftSegments = context.continueDestSegments = leftSegments;
50950 forkContext.replaceHead(leftSegments);
50951 }
50952 /**
50953 * Makes a code path segment for the right part of a ForInStatement and a
50954 * ForOfStatement.
50955 * @returns {void}
50956 */
50957
50958
50959 makeForInOfRight() {
50960 const context = this.loopContext;
50961 const forkContext = this.forkContext;
50962 const temp = ForkContext.newEmpty(forkContext);
50963 temp.add(context.prevSegments);
50964 const rightSegments = temp.makeNext(-1, -1); // Update state.
50965
50966 context.endOfLeftSegments = forkContext.head;
50967 forkContext.replaceHead(rightSegments);
50968 }
50969 /**
50970 * Makes a code path segment for the body part of a ForInStatement and a
50971 * ForOfStatement.
50972 * @returns {void}
50973 */
50974
50975
50976 makeForInOfBody() {
50977 const context = this.loopContext;
50978 const forkContext = this.forkContext;
50979 const temp = ForkContext.newEmpty(forkContext);
50980 temp.add(context.endOfLeftSegments);
50981 const bodySegments = temp.makeNext(-1, -1); // Make a path: `right` -> `left`.
50982
50983 makeLooped(this, forkContext.head, context.leftSegments); // Update state.
50984
50985 context.brokenForkContext.add(forkContext.head);
50986 forkContext.replaceHead(bodySegments);
50987 } //--------------------------------------------------------------------------
50988 // Control Statements
50989 //--------------------------------------------------------------------------
50990
50991 /**
50992 * Creates new context for BreakStatement.
50993 * @param {boolean} breakable The flag to indicate it can break by
50994 * an unlabeled BreakStatement.
50995 * @param {string|null} label The label of this context.
50996 * @returns {Object} The new context.
50997 */
50998
50999
51000 pushBreakContext(breakable, label) {
51001 this.breakContext = {
51002 upper: this.breakContext,
51003 breakable,
51004 label,
51005 brokenForkContext: ForkContext.newEmpty(this.forkContext)
51006 };
51007 return this.breakContext;
51008 }
51009 /**
51010 * Removes the top item of the break context stack.
51011 * @returns {Object} The removed context.
51012 */
51013
51014
51015 popBreakContext() {
51016 const context = this.breakContext;
51017 const forkContext = this.forkContext;
51018 this.breakContext = context.upper; // Process this context here for other than switches and loops.
51019
51020 if (!context.breakable) {
51021 const brokenForkContext = context.brokenForkContext;
51022
51023 if (!brokenForkContext.empty) {
51024 brokenForkContext.add(forkContext.head);
51025 forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
51026 }
51027 }
51028
51029 return context;
51030 }
51031 /**
51032 * Makes a path for a `break` statement.
51033 *
51034 * It registers the head segment to a context of `break`.
51035 * It makes new unreachable segment, then it set the head with the segment.
51036 * @param {string} label A label of the break statement.
51037 * @returns {void}
51038 */
51039
51040
51041 makeBreak(label) {
51042 const forkContext = this.forkContext;
51043
51044 if (!forkContext.reachable) {
51045 return;
51046 }
51047
51048 const context = getBreakContext(this, label);
51049 /* istanbul ignore else: foolproof (syntax error) */
51050
51051 if (context) {
51052 context.brokenForkContext.add(forkContext.head);
51053 }
51054
51055 forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
51056 }
51057 /**
51058 * Makes a path for a `continue` statement.
51059 *
51060 * It makes a looping path.
51061 * It makes new unreachable segment, then it set the head with the segment.
51062 * @param {string} label A label of the continue statement.
51063 * @returns {void}
51064 */
51065
51066
51067 makeContinue(label) {
51068 const forkContext = this.forkContext;
51069
51070 if (!forkContext.reachable) {
51071 return;
51072 }
51073
51074 const context = getContinueContext(this, label);
51075 /* istanbul ignore else: foolproof (syntax error) */
51076
51077 if (context) {
51078 if (context.continueDestSegments) {
51079 makeLooped(this, forkContext.head, context.continueDestSegments); // If the context is a for-in/of loop, this effects a break also.
51080
51081 if (context.type === "ForInStatement" || context.type === "ForOfStatement") {
51082 context.brokenForkContext.add(forkContext.head);
51083 }
51084 } else {
51085 context.continueForkContext.add(forkContext.head);
51086 }
51087 }
51088
51089 forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
51090 }
51091 /**
51092 * Makes a path for a `return` statement.
51093 *
51094 * It registers the head segment to a context of `return`.
51095 * It makes new unreachable segment, then it set the head with the segment.
51096 * @returns {void}
51097 */
51098
51099
51100 makeReturn() {
51101 const forkContext = this.forkContext;
51102
51103 if (forkContext.reachable) {
51104 getReturnContext(this).returnedForkContext.add(forkContext.head);
51105 forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
51106 }
51107 }
51108 /**
51109 * Makes a path for a `throw` statement.
51110 *
51111 * It registers the head segment to a context of `throw`.
51112 * It makes new unreachable segment, then it set the head with the segment.
51113 * @returns {void}
51114 */
51115
51116
51117 makeThrow() {
51118 const forkContext = this.forkContext;
51119
51120 if (forkContext.reachable) {
51121 getThrowContext(this).thrownForkContext.add(forkContext.head);
51122 forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
51123 }
51124 }
51125 /**
51126 * Makes the final path.
51127 * @returns {void}
51128 */
51129
51130
51131 makeFinal() {
51132 const segments = this.currentSegments;
51133
51134 if (segments.length > 0 && segments[0].reachable) {
51135 this.returnedForkContext.add(segments);
51136 }
51137 }
51138
51139 }
51140
51141 module.exports = CodePathState;
51142
51143 /***/ }),
51144 /* 520 */
51145 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
51146
51147 "use strict";
51148 /**
51149 * @fileoverview A class of the code path segment.
51150 * @author Toru Nagashima
51151 */
51152 //------------------------------------------------------------------------------
51153 // Requirements
51154 //------------------------------------------------------------------------------
51155
51156 const debug = __webpack_require__(521); //------------------------------------------------------------------------------
51157 // Helpers
51158 //------------------------------------------------------------------------------
51159
51160 /**
51161 * Checks whether or not a given segment is reachable.
51162 * @param {CodePathSegment} segment A segment to check.
51163 * @returns {boolean} `true` if the segment is reachable.
51164 */
51165
51166
51167 function isReachable(segment) {
51168 return segment.reachable;
51169 } //------------------------------------------------------------------------------
51170 // Public Interface
51171 //------------------------------------------------------------------------------
51172
51173 /**
51174 * A code path segment.
51175 */
51176
51177
51178 class CodePathSegment {
51179 /**
51180 * @param {string} id An identifier.
51181 * @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
51182 * This array includes unreachable segments.
51183 * @param {boolean} reachable A flag which shows this is reachable.
51184 */
51185 constructor(id, allPrevSegments, reachable) {
51186 /**
51187 * The identifier of this code path.
51188 * Rules use it to store additional information of each rule.
51189 * @type {string}
51190 */
51191 this.id = id;
51192 /**
51193 * An array of the next segments.
51194 * @type {CodePathSegment[]}
51195 */
51196
51197 this.nextSegments = [];
51198 /**
51199 * An array of the previous segments.
51200 * @type {CodePathSegment[]}
51201 */
51202
51203 this.prevSegments = allPrevSegments.filter(isReachable);
51204 /**
51205 * An array of the next segments.
51206 * This array includes unreachable segments.
51207 * @type {CodePathSegment[]}
51208 */
51209
51210 this.allNextSegments = [];
51211 /**
51212 * An array of the previous segments.
51213 * This array includes unreachable segments.
51214 * @type {CodePathSegment[]}
51215 */
51216
51217 this.allPrevSegments = allPrevSegments;
51218 /**
51219 * A flag which shows this is reachable.
51220 * @type {boolean}
51221 */
51222
51223 this.reachable = reachable; // Internal data.
51224
51225 Object.defineProperty(this, "internal", {
51226 value: {
51227 used: false,
51228 loopedPrevSegments: []
51229 }
51230 });
51231 /* istanbul ignore if */
51232
51233 if (debug.enabled) {
51234 this.internal.nodes = [];
51235 }
51236 }
51237 /**
51238 * Checks a given previous segment is coming from the end of a loop.
51239 * @param {CodePathSegment} segment A previous segment to check.
51240 * @returns {boolean} `true` if the segment is coming from the end of a loop.
51241 */
51242
51243
51244 isLoopedPrevSegment(segment) {
51245 return this.internal.loopedPrevSegments.indexOf(segment) !== -1;
51246 }
51247 /**
51248 * Creates the root segment.
51249 * @param {string} id An identifier.
51250 * @returns {CodePathSegment} The created segment.
51251 */
51252
51253
51254 static newRoot(id) {
51255 return new CodePathSegment(id, [], true);
51256 }
51257 /**
51258 * Creates a segment that follows given segments.
51259 * @param {string} id An identifier.
51260 * @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
51261 * @returns {CodePathSegment} The created segment.
51262 */
51263
51264
51265 static newNext(id, allPrevSegments) {
51266 return new CodePathSegment(id, CodePathSegment.flattenUnusedSegments(allPrevSegments), allPrevSegments.some(isReachable));
51267 }
51268 /**
51269 * Creates an unreachable segment that follows given segments.
51270 * @param {string} id An identifier.
51271 * @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
51272 * @returns {CodePathSegment} The created segment.
51273 */
51274
51275
51276 static newUnreachable(id, allPrevSegments) {
51277 const segment = new CodePathSegment(id, CodePathSegment.flattenUnusedSegments(allPrevSegments), false);
51278 /*
51279 * In `if (a) return a; foo();` case, the unreachable segment preceded by
51280 * the return statement is not used but must not be remove.
51281 */
51282
51283 CodePathSegment.markUsed(segment);
51284 return segment;
51285 }
51286 /**
51287 * Creates a segment that follows given segments.
51288 * This factory method does not connect with `allPrevSegments`.
51289 * But this inherits `reachable` flag.
51290 * @param {string} id An identifier.
51291 * @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
51292 * @returns {CodePathSegment} The created segment.
51293 */
51294
51295
51296 static newDisconnected(id, allPrevSegments) {
51297 return new CodePathSegment(id, [], allPrevSegments.some(isReachable));
51298 }
51299 /**
51300 * Makes a given segment being used.
51301 *
51302 * And this function registers the segment into the previous segments as a next.
51303 * @param {CodePathSegment} segment A segment to mark.
51304 * @returns {void}
51305 */
51306
51307
51308 static markUsed(segment) {
51309 if (segment.internal.used) {
51310 return;
51311 }
51312
51313 segment.internal.used = true;
51314 let i;
51315
51316 if (segment.reachable) {
51317 for (i = 0; i < segment.allPrevSegments.length; ++i) {
51318 const prevSegment = segment.allPrevSegments[i];
51319 prevSegment.allNextSegments.push(segment);
51320 prevSegment.nextSegments.push(segment);
51321 }
51322 } else {
51323 for (i = 0; i < segment.allPrevSegments.length; ++i) {
51324 segment.allPrevSegments[i].allNextSegments.push(segment);
51325 }
51326 }
51327 }
51328 /**
51329 * Marks a previous segment as looped.
51330 * @param {CodePathSegment} segment A segment.
51331 * @param {CodePathSegment} prevSegment A previous segment to mark.
51332 * @returns {void}
51333 */
51334
51335
51336 static markPrevSegmentAsLooped(segment, prevSegment) {
51337 segment.internal.loopedPrevSegments.push(prevSegment);
51338 }
51339 /**
51340 * Replaces unused segments with the previous segments of each unused segment.
51341 * @param {CodePathSegment[]} segments An array of segments to replace.
51342 * @returns {CodePathSegment[]} The replaced array.
51343 */
51344
51345
51346 static flattenUnusedSegments(segments) {
51347 const done = Object.create(null);
51348 const retv = [];
51349
51350 for (let i = 0; i < segments.length; ++i) {
51351 const segment = segments[i]; // Ignores duplicated.
51352
51353 if (done[segment.id]) {
51354 continue;
51355 } // Use previous segments if unused.
51356
51357
51358 if (!segment.internal.used) {
51359 for (let j = 0; j < segment.allPrevSegments.length; ++j) {
51360 const prevSegment = segment.allPrevSegments[j];
51361
51362 if (!done[prevSegment.id]) {
51363 done[prevSegment.id] = true;
51364 retv.push(prevSegment);
51365 }
51366 }
51367 } else {
51368 done[segment.id] = true;
51369 retv.push(segment);
51370 }
51371 }
51372
51373 return retv;
51374 }
51375
51376 }
51377
51378 module.exports = CodePathSegment;
51379
51380 /***/ }),
51381 /* 521 */
51382 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
51383
51384 "use strict";
51385 /**
51386 * @fileoverview Helpers to debug for code path analysis.
51387 * @author Toru Nagashima
51388 */
51389 //------------------------------------------------------------------------------
51390 // Requirements
51391 //------------------------------------------------------------------------------
51392
51393 const debug = __webpack_require__(496)("eslint:code-path"); //------------------------------------------------------------------------------
51394 // Helpers
51395 //------------------------------------------------------------------------------
51396
51397 /**
51398 * Gets id of a given segment.
51399 * @param {CodePathSegment} segment A segment to get.
51400 * @returns {string} Id of the segment.
51401 */
51402
51403 /* istanbul ignore next */
51404
51405
51406 function getId(segment) {
51407 // eslint-disable-line jsdoc/require-jsdoc -- Ignoring
51408 return segment.id + (segment.reachable ? "" : "!");
51409 }
51410 /**
51411 * Get string for the given node and operation.
51412 * @param {ASTNode} node The node to convert.
51413 * @param {"enter" | "exit" | undefined} label The operation label.
51414 * @returns {string} The string representation.
51415 */
51416
51417
51418 function nodeToString(node, label) {
51419 const suffix = label ? ":".concat(label) : "";
51420
51421 switch (node.type) {
51422 case "Identifier":
51423 return "".concat(node.type).concat(suffix, " (").concat(node.name, ")");
51424
51425 case "Literal":
51426 return "".concat(node.type).concat(suffix, " (").concat(node.value, ")");
51427
51428 default:
51429 return "".concat(node.type).concat(suffix);
51430 }
51431 } //------------------------------------------------------------------------------
51432 // Public Interface
51433 //------------------------------------------------------------------------------
51434
51435
51436 module.exports = {
51437 /**
51438 * A flag that debug dumping is enabled or not.
51439 * @type {boolean}
51440 */
51441 enabled: debug.enabled,
51442
51443 /**
51444 * Dumps given objects.
51445 * @param {...any} args objects to dump.
51446 * @returns {void}
51447 */
51448 dump: debug,
51449
51450 /**
51451 * Dumps the current analyzing state.
51452 * @param {ASTNode} node A node to dump.
51453 * @param {CodePathState} state A state to dump.
51454 * @param {boolean} leaving A flag whether or not it's leaving
51455 * @returns {void}
51456 */
51457 dumpState: !debug.enabled ? debug :
51458 /* istanbul ignore next */
51459 function (node, state, leaving) {
51460 for (let i = 0; i < state.currentSegments.length; ++i) {
51461 const segInternal = state.currentSegments[i].internal;
51462
51463 if (leaving) {
51464 const last = segInternal.nodes.length - 1;
51465
51466 if (last >= 0 && segInternal.nodes[last] === nodeToString(node, "enter")) {
51467 segInternal.nodes[last] = nodeToString(node, void 0);
51468 } else {
51469 segInternal.nodes.push(nodeToString(node, "exit"));
51470 }
51471 } else {
51472 segInternal.nodes.push(nodeToString(node, "enter"));
51473 }
51474 }
51475
51476 debug(["".concat(state.currentSegments.map(getId).join(","), ")"), "".concat(node.type).concat(leaving ? ":exit" : "")].join(" "));
51477 },
51478
51479 /**
51480 * Dumps a DOT code of a given code path.
51481 * The DOT code can be visualized with Graphvis.
51482 * @param {CodePath} codePath A code path to dump.
51483 * @returns {void}
51484 * @see http://www.graphviz.org
51485 * @see http://www.webgraphviz.com
51486 */
51487 dumpDot: !debug.enabled ? debug :
51488 /* istanbul ignore next */
51489 function (codePath) {
51490 let text = "\n" + "digraph {\n" + "node[shape=box,style=\"rounded,filled\",fillcolor=white];\n" + "initial[label=\"\",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25];\n";
51491
51492 if (codePath.returnedSegments.length > 0) {
51493 text += "final[label=\"\",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25];\n";
51494 }
51495
51496 if (codePath.thrownSegments.length > 0) {
51497 text += "thrown[label=\"\",shape=circle,width=0.3,height=0.3,fixedsize];\n";
51498 }
51499
51500 const traceMap = Object.create(null);
51501 const arrows = this.makeDotArrows(codePath, traceMap);
51502
51503 for (const id in traceMap) {
51504 // eslint-disable-line guard-for-in -- Want ability to traverse prototype
51505 const segment = traceMap[id];
51506 text += "".concat(id, "[");
51507
51508 if (segment.reachable) {
51509 text += "label=\"";
51510 } else {
51511 text += "style=\"rounded,dashed,filled\",fillcolor=\"#FF9800\",label=\"<<unreachable>>\\n";
51512 }
51513
51514 if (segment.internal.nodes.length > 0) {
51515 text += segment.internal.nodes.join("\\n");
51516 } else {
51517 text += "????";
51518 }
51519
51520 text += "\"];\n";
51521 }
51522
51523 text += "".concat(arrows, "\n");
51524 text += "}";
51525 debug("DOT", text);
51526 },
51527
51528 /**
51529 * Makes a DOT code of a given code path.
51530 * The DOT code can be visualized with Graphvis.
51531 * @param {CodePath} codePath A code path to make DOT.
51532 * @param {Object} traceMap Optional. A map to check whether or not segments had been done.
51533 * @returns {string} A DOT code of the code path.
51534 */
51535 makeDotArrows(codePath, traceMap) {
51536 const stack = [[codePath.initialSegment, 0]];
51537 const done = traceMap || Object.create(null);
51538 let lastId = codePath.initialSegment.id;
51539 let text = "initial->".concat(codePath.initialSegment.id);
51540
51541 while (stack.length > 0) {
51542 const item = stack.pop();
51543 const segment = item[0];
51544 const index = item[1];
51545
51546 if (done[segment.id] && index === 0) {
51547 continue;
51548 }
51549
51550 done[segment.id] = segment;
51551 const nextSegment = segment.allNextSegments[index];
51552
51553 if (!nextSegment) {
51554 continue;
51555 }
51556
51557 if (lastId === segment.id) {
51558 text += "->".concat(nextSegment.id);
51559 } else {
51560 text += ";\n".concat(segment.id, "->").concat(nextSegment.id);
51561 }
51562
51563 lastId = nextSegment.id;
51564 stack.unshift([segment, 1 + index]);
51565 stack.push([nextSegment, 0]);
51566 }
51567
51568 codePath.returnedSegments.forEach(finalSegment => {
51569 if (lastId === finalSegment.id) {
51570 text += "->final";
51571 } else {
51572 text += ";\n".concat(finalSegment.id, "->final");
51573 }
51574
51575 lastId = null;
51576 });
51577 codePath.thrownSegments.forEach(finalSegment => {
51578 if (lastId === finalSegment.id) {
51579 text += "->thrown";
51580 } else {
51581 text += ";\n".concat(finalSegment.id, "->thrown");
51582 }
51583
51584 lastId = null;
51585 });
51586 return "".concat(text, ";");
51587 }
51588
51589 };
51590
51591 /***/ }),
51592 /* 522 */
51593 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
51594
51595 "use strict";
51596 /**
51597 * @fileoverview A class to operate forking.
51598 *
51599 * This is state of forking.
51600 * This has a fork list and manages it.
51601 *
51602 * @author Toru Nagashima
51603 */
51604 //------------------------------------------------------------------------------
51605 // Requirements
51606 //------------------------------------------------------------------------------
51607
51608 const assert = __webpack_require__(431),
51609 CodePathSegment = __webpack_require__(520); //------------------------------------------------------------------------------
51610 // Helpers
51611 //------------------------------------------------------------------------------
51612
51613 /**
51614 * Gets whether or not a given segment is reachable.
51615 * @param {CodePathSegment} segment A segment to get.
51616 * @returns {boolean} `true` if the segment is reachable.
51617 */
51618
51619
51620 function isReachable(segment) {
51621 return segment.reachable;
51622 }
51623 /**
51624 * Creates new segments from the specific range of `context.segmentsList`.
51625 *
51626 * When `context.segmentsList` is `[[a, b], [c, d], [e, f]]`, `begin` is `0`, and
51627 * `end` is `-1`, this creates `[g, h]`. This `g` is from `a`, `c`, and `e`.
51628 * This `h` is from `b`, `d`, and `f`.
51629 * @param {ForkContext} context An instance.
51630 * @param {number} begin The first index of the previous segments.
51631 * @param {number} end The last index of the previous segments.
51632 * @param {Function} create A factory function of new segments.
51633 * @returns {CodePathSegment[]} New segments.
51634 */
51635
51636
51637 function makeSegments(context, begin, end, create) {
51638 const list = context.segmentsList;
51639 const normalizedBegin = begin >= 0 ? begin : list.length + begin;
51640 const normalizedEnd = end >= 0 ? end : list.length + end;
51641 const segments = [];
51642
51643 for (let i = 0; i < context.count; ++i) {
51644 const allPrevSegments = [];
51645
51646 for (let j = normalizedBegin; j <= normalizedEnd; ++j) {
51647 allPrevSegments.push(list[j][i]);
51648 }
51649
51650 segments.push(create(context.idGenerator.next(), allPrevSegments));
51651 }
51652
51653 return segments;
51654 }
51655 /**
51656 * `segments` becomes doubly in a `finally` block. Then if a code path exits by a
51657 * control statement (such as `break`, `continue`) from the `finally` block, the
51658 * destination's segments may be half of the source segments. In that case, this
51659 * merges segments.
51660 * @param {ForkContext} context An instance.
51661 * @param {CodePathSegment[]} segments Segments to merge.
51662 * @returns {CodePathSegment[]} The merged segments.
51663 */
51664
51665
51666 function mergeExtraSegments(context, segments) {
51667 let currentSegments = segments;
51668
51669 while (currentSegments.length > context.count) {
51670 const merged = [];
51671
51672 for (let i = 0, length = currentSegments.length / 2 | 0; i < length; ++i) {
51673 merged.push(CodePathSegment.newNext(context.idGenerator.next(), [currentSegments[i], currentSegments[i + length]]));
51674 }
51675
51676 currentSegments = merged;
51677 }
51678
51679 return currentSegments;
51680 } //------------------------------------------------------------------------------
51681 // Public Interface
51682 //------------------------------------------------------------------------------
51683
51684 /**
51685 * A class to manage forking.
51686 */
51687
51688
51689 class ForkContext {
51690 /**
51691 * @param {IdGenerator} idGenerator An identifier generator for segments.
51692 * @param {ForkContext|null} upper An upper fork context.
51693 * @param {number} count A number of parallel segments.
51694 */
51695 constructor(idGenerator, upper, count) {
51696 this.idGenerator = idGenerator;
51697 this.upper = upper;
51698 this.count = count;
51699 this.segmentsList = [];
51700 }
51701 /**
51702 * The head segments.
51703 * @type {CodePathSegment[]}
51704 */
51705
51706
51707 get head() {
51708 const list = this.segmentsList;
51709 return list.length === 0 ? [] : list[list.length - 1];
51710 }
51711 /**
51712 * A flag which shows empty.
51713 * @type {boolean}
51714 */
51715
51716
51717 get empty() {
51718 return this.segmentsList.length === 0;
51719 }
51720 /**
51721 * A flag which shows reachable.
51722 * @type {boolean}
51723 */
51724
51725
51726 get reachable() {
51727 const segments = this.head;
51728 return segments.length > 0 && segments.some(isReachable);
51729 }
51730 /**
51731 * Creates new segments from this context.
51732 * @param {number} begin The first index of previous segments.
51733 * @param {number} end The last index of previous segments.
51734 * @returns {CodePathSegment[]} New segments.
51735 */
51736
51737
51738 makeNext(begin, end) {
51739 return makeSegments(this, begin, end, CodePathSegment.newNext);
51740 }
51741 /**
51742 * Creates new segments from this context.
51743 * The new segments is always unreachable.
51744 * @param {number} begin The first index of previous segments.
51745 * @param {number} end The last index of previous segments.
51746 * @returns {CodePathSegment[]} New segments.
51747 */
51748
51749
51750 makeUnreachable(begin, end) {
51751 return makeSegments(this, begin, end, CodePathSegment.newUnreachable);
51752 }
51753 /**
51754 * Creates new segments from this context.
51755 * The new segments don't have connections for previous segments.
51756 * But these inherit the reachable flag from this context.
51757 * @param {number} begin The first index of previous segments.
51758 * @param {number} end The last index of previous segments.
51759 * @returns {CodePathSegment[]} New segments.
51760 */
51761
51762
51763 makeDisconnected(begin, end) {
51764 return makeSegments(this, begin, end, CodePathSegment.newDisconnected);
51765 }
51766 /**
51767 * Adds segments into this context.
51768 * The added segments become the head.
51769 * @param {CodePathSegment[]} segments Segments to add.
51770 * @returns {void}
51771 */
51772
51773
51774 add(segments) {
51775 assert(segments.length >= this.count, "".concat(segments.length, " >= ").concat(this.count));
51776 this.segmentsList.push(mergeExtraSegments(this, segments));
51777 }
51778 /**
51779 * Replaces the head segments with given segments.
51780 * The current head segments are removed.
51781 * @param {CodePathSegment[]} segments Segments to add.
51782 * @returns {void}
51783 */
51784
51785
51786 replaceHead(segments) {
51787 assert(segments.length >= this.count, "".concat(segments.length, " >= ").concat(this.count));
51788 this.segmentsList.splice(-1, 1, mergeExtraSegments(this, segments));
51789 }
51790 /**
51791 * Adds all segments of a given fork context into this context.
51792 * @param {ForkContext} context A fork context to add.
51793 * @returns {void}
51794 */
51795
51796
51797 addAll(context) {
51798 assert(context.count === this.count);
51799 const source = context.segmentsList;
51800
51801 for (let i = 0; i < source.length; ++i) {
51802 this.segmentsList.push(source[i]);
51803 }
51804 }
51805 /**
51806 * Clears all segments in this context.
51807 * @returns {void}
51808 */
51809
51810
51811 clear() {
51812 this.segmentsList = [];
51813 }
51814 /**
51815 * Creates the root fork context.
51816 * @param {IdGenerator} idGenerator An identifier generator for segments.
51817 * @returns {ForkContext} New fork context.
51818 */
51819
51820
51821 static newRoot(idGenerator) {
51822 const context = new ForkContext(idGenerator, null, 1);
51823 context.add([CodePathSegment.newRoot(idGenerator.next())]);
51824 return context;
51825 }
51826 /**
51827 * Creates an empty fork context preceded by a given context.
51828 * @param {ForkContext} parentContext The parent fork context.
51829 * @param {boolean} forkLeavingPath A flag which shows inside of `finally` block.
51830 * @returns {ForkContext} New fork context.
51831 */
51832
51833
51834 static newEmpty(parentContext, forkLeavingPath) {
51835 return new ForkContext(parentContext.idGenerator, parentContext, (forkLeavingPath ? 2 : 1) * parentContext.count);
51836 }
51837
51838 }
51839
51840 module.exports = ForkContext;
51841
51842 /***/ }),
51843 /* 523 */
51844 /***/ ((module) => {
51845
51846 "use strict";
51847 /**
51848 * @fileoverview A class of identifiers generator for code path segments.
51849 *
51850 * Each rule uses the identifier of code path segments to store additional
51851 * information of the code path.
51852 *
51853 * @author Toru Nagashima
51854 */
51855 //------------------------------------------------------------------------------
51856 // Public Interface
51857 //------------------------------------------------------------------------------
51858
51859 /**
51860 * A generator for unique ids.
51861 */
51862
51863 class IdGenerator {
51864 /**
51865 * @param {string} prefix Optional. A prefix of generated ids.
51866 */
51867 constructor(prefix) {
51868 this.prefix = String(prefix);
51869 this.n = 0;
51870 }
51871 /**
51872 * Generates id.
51873 * @returns {string} A generated id.
51874 */
51875
51876
51877 next() {
51878 this.n = 1 + this.n | 0;
51879 /* istanbul ignore if */
51880
51881 if (this.n < 0) {
51882 this.n = 1;
51883 }
51884
51885 return this.prefix + this.n;
51886 }
51887
51888 }
51889
51890 module.exports = IdGenerator;
51891
51892 /***/ }),
51893 /* 524 */
51894 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
51895
51896 "use strict";
51897 /**
51898 * @fileoverview A module that filters reported problems based on `eslint-disable` and `eslint-enable` comments
51899 * @author Teddy Katz
51900 */
51901
51902
51903 var _templateObject;
51904
51905 function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
51906
51907 const escapeRegExp = __webpack_require__(525);
51908 /**
51909 * Compares the locations of two objects in a source file
51910 * @param {{line: number, column: number}} itemA The first object
51911 * @param {{line: number, column: number}} itemB The second object
51912 * @returns {number} A value less than 1 if itemA appears before itemB in the source file, greater than 1 if
51913 * itemA appears after itemB in the source file, or 0 if itemA and itemB have the same location.
51914 */
51915
51916
51917 function compareLocations(itemA, itemB) {
51918 return itemA.line - itemB.line || itemA.column - itemB.column;
51919 }
51920 /**
51921 * Groups a set of directives into sub-arrays by their parent comment.
51922 * @param {Directive[]} directives Unused directives to be removed.
51923 * @returns {Directive[][]} Directives grouped by their parent comment.
51924 */
51925
51926
51927 function groupByParentComment(directives) {
51928 const groups = new Map();
51929
51930 for (const directive of directives) {
51931 const {
51932 unprocessedDirective: {
51933 parentComment
51934 }
51935 } = directive;
51936
51937 if (groups.has(parentComment)) {
51938 groups.get(parentComment).push(directive);
51939 } else {
51940 groups.set(parentComment, [directive]);
51941 }
51942 }
51943
51944 return [...groups.values()];
51945 }
51946 /**
51947 * Creates removal details for a set of directives within the same comment.
51948 * @param {Directive[]} directives Unused directives to be removed.
51949 * @param {Token} commentToken The backing Comment token.
51950 * @returns {{ description, fix, position }[]} Details for later creation of output Problems.
51951 */
51952
51953
51954 function createIndividualDirectivesRemoval(directives, commentToken) {
51955 /*
51956 * `commentToken.value` starts right after `//` or `/*`.
51957 * All calculated offsets will be relative to this index.
51958 */
51959 const commentValueStart = commentToken.range[0] + "//".length; // Find where the list of rules starts. `\S+` matches with the directive name (e.g. `eslint-disable-line`)
51960
51961 const listStartOffset = /^\s*\S+\s+/u.exec(commentToken.value)[0].length;
51962 /*
51963 * Get the list text without any surrounding whitespace. In order to preserve the original
51964 * formatting, we don't want to change that whitespace.
51965 *
51966 * // eslint-disable-line rule-one , rule-two , rule-three -- comment
51967 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51968 */
51969
51970 const listText = commentToken.value.slice(listStartOffset) // remove directive name and all whitespace before the list
51971 .split(/\s-{2,}\s/u)[0] // remove `-- comment`, if it exists
51972 .trimRight(); // remove all whitespace after the list
51973
51974 /*
51975 * We can assume that `listText` contains multiple elements.
51976 * Otherwise, this function wouldn't be called - if there is
51977 * only one rule in the list, then the whole comment must be removed.
51978 */
51979
51980 return directives.map(directive => {
51981 const {
51982 ruleId
51983 } = directive;
51984 const regex = new RegExp(String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["(?:^|s*,s*)", "(?:s*,s*|$)"], ["(?:^|\\s*,\\s*)", "(?:\\s*,\\s*|$)"])), escapeRegExp(ruleId)), "u");
51985 const match = regex.exec(listText);
51986 const matchedText = match[0];
51987 const matchStartOffset = listStartOffset + match.index;
51988 const matchEndOffset = matchStartOffset + matchedText.length;
51989 const firstIndexOfComma = matchedText.indexOf(",");
51990 const lastIndexOfComma = matchedText.lastIndexOf(",");
51991 let removalStartOffset, removalEndOffset;
51992
51993 if (firstIndexOfComma !== lastIndexOfComma) {
51994 /*
51995 * Since there are two commas, this must one of the elements in the middle of the list.
51996 * Matched range starts where the previous rule name ends, and ends where the next rule name starts.
51997 *
51998 * // eslint-disable-line rule-one , rule-two , rule-three -- comment
51999 * ^^^^^^^^^^^^^^
52000 *
52001 * We want to remove only the content between the two commas, and also one of the commas.
52002 *
52003 * // eslint-disable-line rule-one , rule-two , rule-three -- comment
52004 * ^^^^^^^^^^^
52005 */
52006 removalStartOffset = matchStartOffset + firstIndexOfComma;
52007 removalEndOffset = matchStartOffset + lastIndexOfComma;
52008 } else {
52009 /*
52010 * This is either the first element or the last element.
52011 *
52012 * If this is the first element, matched range starts where the first rule name starts
52013 * and ends where the second rule name starts. This is exactly the range we want
52014 * to remove so that the second rule name will start where the first one was starting
52015 * and thus preserve the original formatting.
52016 *
52017 * // eslint-disable-line rule-one , rule-two , rule-three -- comment
52018 * ^^^^^^^^^^^
52019 *
52020 * Similarly, if this is the last element, we've already matched the range we want to
52021 * remove. The previous rule name will end where the last one was ending, relative
52022 * to the content on the right side.
52023 *
52024 * // eslint-disable-line rule-one , rule-two , rule-three -- comment
52025 * ^^^^^^^^^^^^^
52026 */
52027 removalStartOffset = matchStartOffset;
52028 removalEndOffset = matchEndOffset;
52029 }
52030
52031 return {
52032 description: "'".concat(ruleId, "'"),
52033 fix: {
52034 range: [commentValueStart + removalStartOffset, commentValueStart + removalEndOffset],
52035 text: ""
52036 },
52037 position: directive.unprocessedDirective
52038 };
52039 });
52040 }
52041 /**
52042 * Creates a description of deleting an entire unused disable comment.
52043 * @param {Directive[]} directives Unused directives to be removed.
52044 * @param {Token} commentToken The backing Comment token.
52045 * @returns {{ description, fix, position }} Details for later creation of an output Problem.
52046 */
52047
52048
52049 function createCommentRemoval(directives, commentToken) {
52050 const {
52051 range
52052 } = commentToken;
52053 const ruleIds = directives.filter(directive => directive.ruleId).map(directive => "'".concat(directive.ruleId, "'"));
52054 return {
52055 description: ruleIds.length <= 2 ? ruleIds.join(" or ") : "".concat(ruleIds.slice(0, ruleIds.length - 1).join(", "), ", or ").concat(ruleIds[ruleIds.length - 1]),
52056 fix: {
52057 range,
52058 text: " "
52059 },
52060 position: directives[0].unprocessedDirective
52061 };
52062 }
52063 /**
52064 * Parses details from directives to create output Problems.
52065 * @param {Directive[]} allDirectives Unused directives to be removed.
52066 * @returns {{ description, fix, position }[]} Details for later creation of output Problems.
52067 */
52068
52069
52070 function processUnusedDisableDirectives(allDirectives) {
52071 const directiveGroups = groupByParentComment(allDirectives);
52072 return directiveGroups.flatMap(directives => {
52073 const {
52074 parentComment
52075 } = directives[0].unprocessedDirective;
52076 const remainingRuleIds = new Set(parentComment.ruleIds);
52077
52078 for (const directive of directives) {
52079 remainingRuleIds.delete(directive.ruleId);
52080 }
52081
52082 return remainingRuleIds.size ? createIndividualDirectivesRemoval(directives, parentComment.commentToken) : [createCommentRemoval(directives, parentComment.commentToken)];
52083 });
52084 }
52085 /**
52086 * This is the same as the exported function, except that it
52087 * doesn't handle disable-line and disable-next-line directives, and it always reports unused
52088 * disable directives.
52089 * @param {Object} options options for applying directives. This is the same as the options
52090 * for the exported function, except that `reportUnusedDisableDirectives` is not supported
52091 * (this function always reports unused disable directives).
52092 * @returns {{problems: Problem[], unusedDisableDirectives: Problem[]}} An object with a list
52093 * of filtered problems and unused eslint-disable directives
52094 */
52095
52096
52097 function applyDirectives(options) {
52098 const problems = [];
52099 let nextDirectiveIndex = 0;
52100 let currentGlobalDisableDirective = null;
52101 const disabledRuleMap = new Map(); // enabledRules is only used when there is a current global disable directive.
52102
52103 const enabledRules = new Set();
52104 const usedDisableDirectives = new Set();
52105
52106 for (const problem of options.problems) {
52107 while (nextDirectiveIndex < options.directives.length && compareLocations(options.directives[nextDirectiveIndex], problem) <= 0) {
52108 const directive = options.directives[nextDirectiveIndex++];
52109
52110 switch (directive.type) {
52111 case "disable":
52112 if (directive.ruleId === null) {
52113 currentGlobalDisableDirective = directive;
52114 disabledRuleMap.clear();
52115 enabledRules.clear();
52116 } else if (currentGlobalDisableDirective) {
52117 enabledRules.delete(directive.ruleId);
52118 disabledRuleMap.set(directive.ruleId, directive);
52119 } else {
52120 disabledRuleMap.set(directive.ruleId, directive);
52121 }
52122
52123 break;
52124
52125 case "enable":
52126 if (directive.ruleId === null) {
52127 currentGlobalDisableDirective = null;
52128 disabledRuleMap.clear();
52129 } else if (currentGlobalDisableDirective) {
52130 enabledRules.add(directive.ruleId);
52131 disabledRuleMap.delete(directive.ruleId);
52132 } else {
52133 disabledRuleMap.delete(directive.ruleId);
52134 }
52135
52136 break;
52137 // no default
52138 }
52139 }
52140
52141 if (disabledRuleMap.has(problem.ruleId)) {
52142 usedDisableDirectives.add(disabledRuleMap.get(problem.ruleId));
52143 } else if (currentGlobalDisableDirective && !enabledRules.has(problem.ruleId)) {
52144 usedDisableDirectives.add(currentGlobalDisableDirective);
52145 } else {
52146 problems.push(problem);
52147 }
52148 }
52149
52150 const unusedDisableDirectivesToReport = options.directives.filter(directive => directive.type === "disable" && !usedDisableDirectives.has(directive));
52151 const processed = processUnusedDisableDirectives(unusedDisableDirectivesToReport);
52152 const unusedDisableDirectives = processed.map(_ref => {
52153 let {
52154 description,
52155 fix,
52156 position
52157 } = _ref;
52158 return {
52159 ruleId: null,
52160 message: description ? "Unused eslint-disable directive (no problems were reported from ".concat(description, ").") : "Unused eslint-disable directive (no problems were reported).",
52161 line: position.line,
52162 column: position.column,
52163 severity: options.reportUnusedDisableDirectives === "warn" ? 1 : 2,
52164 nodeType: null,
52165 ...(options.disableFixes ? {} : {
52166 fix
52167 })
52168 };
52169 });
52170 return {
52171 problems,
52172 unusedDisableDirectives
52173 };
52174 }
52175 /**
52176 * Given a list of directive comments (i.e. metadata about eslint-disable and eslint-enable comments) and a list
52177 * of reported problems, determines which problems should be reported.
52178 * @param {Object} options Information about directives and problems
52179 * @param {{
52180 * type: ("disable"|"enable"|"disable-line"|"disable-next-line"),
52181 * ruleId: (string|null),
52182 * line: number,
52183 * column: number
52184 * }} options.directives Directive comments found in the file, with one-based columns.
52185 * Two directive comments can only have the same location if they also have the same type (e.g. a single eslint-disable
52186 * comment for two different rules is represented as two directives).
52187 * @param {{ruleId: (string|null), line: number, column: number}[]} options.problems
52188 * A list of problems reported by rules, sorted by increasing location in the file, with one-based columns.
52189 * @param {"off" | "warn" | "error"} options.reportUnusedDisableDirectives If `"warn"` or `"error"`, adds additional problems for unused directives
52190 * @param {boolean} options.disableFixes If true, it doesn't make `fix` properties.
52191 * @returns {{ruleId: (string|null), line: number, column: number}[]}
52192 * A list of reported problems that were not disabled by the directive comments.
52193 */
52194
52195
52196 module.exports = _ref2 => {
52197 let {
52198 directives,
52199 disableFixes,
52200 problems,
52201 reportUnusedDisableDirectives = "off"
52202 } = _ref2;
52203 const blockDirectives = directives.filter(directive => directive.type === "disable" || directive.type === "enable").map(directive => Object.assign({}, directive, {
52204 unprocessedDirective: directive
52205 })).sort(compareLocations);
52206 const lineDirectives = directives.flatMap(directive => {
52207 switch (directive.type) {
52208 case "disable":
52209 case "enable":
52210 return [];
52211
52212 case "disable-line":
52213 return [{
52214 type: "disable",
52215 line: directive.line,
52216 column: 1,
52217 ruleId: directive.ruleId,
52218 unprocessedDirective: directive
52219 }, {
52220 type: "enable",
52221 line: directive.line + 1,
52222 column: 0,
52223 ruleId: directive.ruleId,
52224 unprocessedDirective: directive
52225 }];
52226
52227 case "disable-next-line":
52228 return [{
52229 type: "disable",
52230 line: directive.line + 1,
52231 column: 1,
52232 ruleId: directive.ruleId,
52233 unprocessedDirective: directive
52234 }, {
52235 type: "enable",
52236 line: directive.line + 2,
52237 column: 0,
52238 ruleId: directive.ruleId,
52239 unprocessedDirective: directive
52240 }];
52241
52242 default:
52243 throw new TypeError("Unrecognized directive type '".concat(directive.type, "'"));
52244 }
52245 }).sort(compareLocations);
52246 const blockDirectivesResult = applyDirectives({
52247 problems,
52248 directives: blockDirectives,
52249 disableFixes,
52250 reportUnusedDisableDirectives
52251 });
52252 const lineDirectivesResult = applyDirectives({
52253 problems: blockDirectivesResult.problems,
52254 directives: lineDirectives,
52255 disableFixes,
52256 reportUnusedDisableDirectives
52257 });
52258 return reportUnusedDisableDirectives !== "off" ? lineDirectivesResult.problems.concat(blockDirectivesResult.unusedDisableDirectives).concat(lineDirectivesResult.unusedDisableDirectives).sort(compareLocations) : lineDirectivesResult.problems;
52259 };
52260
52261 /***/ }),
52262 /* 525 */
52263 /***/ ((module) => {
52264
52265 "use strict";
52266
52267
52268 module.exports = string => {
52269 if (typeof string !== 'string') {
52270 throw new TypeError('Expected a string');
52271 } // Escape characters with special meaning either inside or outside character sets.
52272 // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
52273
52274
52275 return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
52276 };
52277
52278 /***/ }),
52279 /* 526 */
52280 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
52281
52282 "use strict";
52283 /**
52284 * @fileoverview Config Comment Parser
52285 * @author Nicholas C. Zakas
52286 */
52287
52288 /* eslint class-methods-use-this: off -- Methods desired on instance */
52289 //------------------------------------------------------------------------------
52290 // Requirements
52291 //------------------------------------------------------------------------------
52292
52293 const levn = __webpack_require__(527),
52294 {
52295 Legacy: {
52296 ConfigOps
52297 }
52298 } = __webpack_require__(445);
52299
52300 const debug = __webpack_require__(496)("eslint:config-comment-parser"); //------------------------------------------------------------------------------
52301 // Public Interface
52302 //------------------------------------------------------------------------------
52303
52304 /**
52305 * Object to parse ESLint configuration comments inside JavaScript files.
52306 * @name ConfigCommentParser
52307 */
52308
52309
52310 module.exports = class ConfigCommentParser {
52311 /**
52312 * Parses a list of "name:string_value" or/and "name" options divided by comma or
52313 * whitespace. Used for "global" and "exported" comments.
52314 * @param {string} string The string to parse.
52315 * @param {Comment} comment The comment node which has the string.
52316 * @returns {Object} Result map object of names and string values, or null values if no value was provided
52317 */
52318 parseStringConfig(string, comment) {
52319 debug("Parsing String config");
52320 const items = {}; // Collapse whitespace around `:` and `,` to make parsing easier
52321
52322 const trimmedString = string.replace(/\s*([:,])\s*/gu, "$1");
52323 trimmedString.split(/\s|,+/u).forEach(name => {
52324 if (!name) {
52325 return;
52326 } // value defaults to null (if not provided), e.g: "foo" => ["foo", null]
52327
52328
52329 const [key, value = null] = name.split(":");
52330 items[key] = {
52331 value,
52332 comment
52333 };
52334 });
52335 return items;
52336 }
52337 /**
52338 * Parses a JSON-like config.
52339 * @param {string} string The string to parse.
52340 * @param {Object} location Start line and column of comments for potential error message.
52341 * @returns {({success: true, config: Object}|{success: false, error: Problem})} Result map object
52342 */
52343
52344
52345 parseJsonConfig(string, location) {
52346 debug("Parsing JSON config");
52347 let items = {}; // Parses a JSON-like comment by the same way as parsing CLI option.
52348
52349 try {
52350 items = levn.parse("Object", string) || {}; // Some tests say that it should ignore invalid comments such as `/*eslint no-alert:abc*/`.
52351 // Also, commaless notations have invalid severity:
52352 // "no-alert: 2 no-console: 2" --> {"no-alert": "2 no-console: 2"}
52353 // Should ignore that case as well.
52354
52355 if (ConfigOps.isEverySeverityValid(items)) {
52356 return {
52357 success: true,
52358 config: items
52359 };
52360 }
52361 } catch {
52362 debug("Levn parsing failed; falling back to manual parsing."); // ignore to parse the string by a fallback.
52363 }
52364 /*
52365 * Optionator cannot parse commaless notations.
52366 * But we are supporting that. So this is a fallback for that.
52367 */
52368
52369
52370 items = {};
52371 const normalizedString = string.replace(/([-a-zA-Z0-9/]+):/gu, "\"$1\":").replace(/(\]|[0-9])\s+(?=")/u, "$1,");
52372
52373 try {
52374 items = JSON.parse("{".concat(normalizedString, "}"));
52375 } catch (ex) {
52376 debug("Manual parsing failed.");
52377 return {
52378 success: false,
52379 error: {
52380 ruleId: null,
52381 fatal: true,
52382 severity: 2,
52383 message: "Failed to parse JSON from '".concat(normalizedString, "': ").concat(ex.message),
52384 line: location.start.line,
52385 column: location.start.column + 1
52386 }
52387 };
52388 }
52389
52390 return {
52391 success: true,
52392 config: items
52393 };
52394 }
52395 /**
52396 * Parses a config of values separated by comma.
52397 * @param {string} string The string to parse.
52398 * @returns {Object} Result map of values and true values
52399 */
52400
52401
52402 parseListConfig(string) {
52403 debug("Parsing list config");
52404 const items = {}; // Collapse whitespace around commas
52405
52406 string.replace(/\s*,\s*/gu, ",").split(/,+/u).forEach(name => {
52407 const trimmedName = name.trim();
52408
52409 if (trimmedName) {
52410 items[trimmedName] = true;
52411 }
52412 });
52413 return items;
52414 }
52415
52416 };
52417
52418 /***/ }),
52419 /* 527 */
52420 /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
52421
52422 // Generated by LiveScript 1.6.0
52423 (function () {
52424 var parseString, cast, parseType, VERSION, parsedTypeParse, parse;
52425 parseString = __webpack_require__(528);
52426 cast = __webpack_require__(535);
52427 parseType = (__webpack_require__(536).parseType);
52428 VERSION = '0.4.1';
52429
52430 parsedTypeParse = function (parsedType, string, options) {
52431 options == null && (options = {});
52432 options.explicit == null && (options.explicit = false);
52433 options.customTypes == null && (options.customTypes = {});
52434 return cast(parseString(parsedType, string, options), parsedType, options);
52435 };
52436
52437 parse = function (type, string, options) {
52438 return parsedTypeParse(parseType(type), string, options);
52439 };
52440
52441 module.exports = {
52442 VERSION: VERSION,
52443 parse: parse,
52444 parsedTypeParse: parsedTypeParse
52445 };
52446 }).call(this);
52447
52448 /***/ }),
52449 /* 528 */
52450 /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
52451
52452 // Generated by LiveScript 1.6.0
52453 (function () {
52454 var reject, special, tokenRegex;
52455 reject = (__webpack_require__(529).reject);
52456
52457 function consumeOp(tokens, op) {
52458 if (tokens[0] === op) {
52459 return tokens.shift();
52460 } else {
52461 throw new Error("Expected '" + op + "', but got '" + tokens[0] + "' instead in " + JSON.stringify(tokens) + ".");
52462 }
52463 }
52464
52465 function maybeConsumeOp(tokens, op) {
52466 if (tokens[0] === op) {
52467 return tokens.shift();
52468 }
52469 }
52470
52471 function consumeList(tokens, arg$, hasDelimiters) {
52472 var open, close, result, untilTest;
52473 open = arg$[0], close = arg$[1];
52474
52475 if (hasDelimiters) {
52476 consumeOp(tokens, open);
52477 }
52478
52479 result = [];
52480 untilTest = "," + (hasDelimiters ? close : '');
52481
52482 while (tokens.length && hasDelimiters && tokens[0] !== close) {
52483 result.push(consumeElement(tokens, untilTest));
52484 maybeConsumeOp(tokens, ',');
52485 }
52486
52487 if (hasDelimiters) {
52488 consumeOp(tokens, close);
52489 }
52490
52491 return result;
52492 }
52493
52494 function consumeArray(tokens, hasDelimiters) {
52495 return consumeList(tokens, ['[', ']'], hasDelimiters);
52496 }
52497
52498 function consumeTuple(tokens, hasDelimiters) {
52499 return consumeList(tokens, ['(', ')'], hasDelimiters);
52500 }
52501
52502 function consumeFields(tokens, hasDelimiters) {
52503 var result, untilTest, key;
52504
52505 if (hasDelimiters) {
52506 consumeOp(tokens, '{');
52507 }
52508
52509 result = {};
52510 untilTest = "," + (hasDelimiters ? '}' : '');
52511
52512 while (tokens.length && (!hasDelimiters || tokens[0] !== '}')) {
52513 key = consumeValue(tokens, ':');
52514 consumeOp(tokens, ':');
52515 result[key] = consumeElement(tokens, untilTest);
52516 maybeConsumeOp(tokens, ',');
52517 }
52518
52519 if (hasDelimiters) {
52520 consumeOp(tokens, '}');
52521 }
52522
52523 return result;
52524 }
52525
52526 function consumeValue(tokens, untilTest) {
52527 var out;
52528 untilTest == null && (untilTest = '');
52529 out = '';
52530
52531 while (tokens.length && -1 === untilTest.indexOf(tokens[0])) {
52532 out += tokens.shift();
52533 }
52534
52535 return out;
52536 }
52537
52538 function consumeElement(tokens, untilTest) {
52539 switch (tokens[0]) {
52540 case '[':
52541 return consumeArray(tokens, true);
52542
52543 case '(':
52544 return consumeTuple(tokens, true);
52545
52546 case '{':
52547 return consumeFields(tokens, true);
52548
52549 default:
52550 return consumeValue(tokens, untilTest);
52551 }
52552 }
52553
52554 function consumeTopLevel(tokens, types, options) {
52555 var ref$, type, structure, origTokens, result, finalResult, x$, y$;
52556 ref$ = types[0], type = ref$.type, structure = ref$.structure;
52557 origTokens = tokens.concat();
52558
52559 if (!options.explicit && types.length === 1 && (!type && structure || type === 'Array' || type === 'Object')) {
52560 result = structure === 'array' || type === 'Array' ? consumeArray(tokens, tokens[0] === '[') : structure === 'tuple' ? consumeTuple(tokens, tokens[0] === '(') : consumeFields(tokens, tokens[0] === '{');
52561 finalResult = tokens.length ? consumeElement(structure === 'array' || type === 'Array' ? (x$ = origTokens, x$.unshift('['), x$.push(']'), x$) : (y$ = origTokens, y$.unshift('('), y$.push(')'), y$)) : result;
52562 } else {
52563 finalResult = consumeElement(tokens);
52564 }
52565
52566 return finalResult;
52567 }
52568
52569 special = /\[\]\(\)}{:,/.source;
52570 tokenRegex = RegExp('("(?:\\\\"|[^"])*")|(\'(?:\\\\\'|[^\'])*\')|(/(?:\\\\/|[^/])*/[a-zA-Z]*)|(#.*#)|([' + special + '])|([^\\s' + special + '](?:\\s*[^\\s' + special + ']+)*)|\\s*');
52571
52572 module.exports = function (types, string, options) {
52573 var tokens, node;
52574 options == null && (options = {});
52575
52576 if (!options.explicit && types.length === 1 && types[0].type === 'String') {
52577 return string;
52578 }
52579
52580 tokens = reject(not$, string.split(tokenRegex));
52581 node = consumeTopLevel(tokens, types, options);
52582
52583 if (!node) {
52584 throw new Error("Error parsing '" + string + "'.");
52585 }
52586
52587 return node;
52588 };
52589
52590 function not$(x) {
52591 return !x;
52592 }
52593 }).call(this);
52594
52595 /***/ }),
52596 /* 529 */
52597 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
52598
52599 // Generated by LiveScript 1.6.0
52600 var Func,
52601 List,
52602 Obj,
52603 Str,
52604 Num,
52605 id,
52606 isType,
52607 replicate,
52608 prelude,
52609 toString$ = {}.toString;
52610 Func = __webpack_require__(530);
52611 List = __webpack_require__(531);
52612 Obj = __webpack_require__(532);
52613 Str = __webpack_require__(533);
52614 Num = __webpack_require__(534);
52615
52616 id = function (x) {
52617 return x;
52618 };
52619
52620 isType = curry$(function (type, x) {
52621 return toString$.call(x).slice(8, -1) === type;
52622 });
52623 replicate = curry$(function (n, x) {
52624 var i$,
52625 results$ = [];
52626
52627 for (i$ = 0; i$ < n; ++i$) {
52628 results$.push(x);
52629 }
52630
52631 return results$;
52632 });
52633 Str.empty = List.empty;
52634 Str.slice = List.slice;
52635 Str.take = List.take;
52636 Str.drop = List.drop;
52637 Str.splitAt = List.splitAt;
52638 Str.takeWhile = List.takeWhile;
52639 Str.dropWhile = List.dropWhile;
52640 Str.span = List.span;
52641 Str.breakStr = List.breakList;
52642 prelude = {
52643 Func: Func,
52644 List: List,
52645 Obj: Obj,
52646 Str: Str,
52647 Num: Num,
52648 id: id,
52649 isType: isType,
52650 replicate: replicate
52651 };
52652 prelude.each = List.each;
52653 prelude.map = List.map;
52654 prelude.filter = List.filter;
52655 prelude.compact = List.compact;
52656 prelude.reject = List.reject;
52657 prelude.partition = List.partition;
52658 prelude.find = List.find;
52659 prelude.head = List.head;
52660 prelude.first = List.first;
52661 prelude.tail = List.tail;
52662 prelude.last = List.last;
52663 prelude.initial = List.initial;
52664 prelude.empty = List.empty;
52665 prelude.reverse = List.reverse;
52666 prelude.difference = List.difference;
52667 prelude.intersection = List.intersection;
52668 prelude.union = List.union;
52669 prelude.countBy = List.countBy;
52670 prelude.groupBy = List.groupBy;
52671 prelude.fold = List.fold;
52672 prelude.foldl = List.foldl;
52673 prelude.fold1 = List.fold1;
52674 prelude.foldl1 = List.foldl1;
52675 prelude.foldr = List.foldr;
52676 prelude.foldr1 = List.foldr1;
52677 prelude.unfoldr = List.unfoldr;
52678 prelude.andList = List.andList;
52679 prelude.orList = List.orList;
52680 prelude.any = List.any;
52681 prelude.all = List.all;
52682 prelude.unique = List.unique;
52683 prelude.uniqueBy = List.uniqueBy;
52684 prelude.sort = List.sort;
52685 prelude.sortWith = List.sortWith;
52686 prelude.sortBy = List.sortBy;
52687 prelude.sum = List.sum;
52688 prelude.product = List.product;
52689 prelude.mean = List.mean;
52690 prelude.average = List.average;
52691 prelude.concat = List.concat;
52692 prelude.concatMap = List.concatMap;
52693 prelude.flatten = List.flatten;
52694 prelude.maximum = List.maximum;
52695 prelude.minimum = List.minimum;
52696 prelude.maximumBy = List.maximumBy;
52697 prelude.minimumBy = List.minimumBy;
52698 prelude.scan = List.scan;
52699 prelude.scanl = List.scanl;
52700 prelude.scan1 = List.scan1;
52701 prelude.scanl1 = List.scanl1;
52702 prelude.scanr = List.scanr;
52703 prelude.scanr1 = List.scanr1;
52704 prelude.slice = List.slice;
52705 prelude.take = List.take;
52706 prelude.drop = List.drop;
52707 prelude.splitAt = List.splitAt;
52708 prelude.takeWhile = List.takeWhile;
52709 prelude.dropWhile = List.dropWhile;
52710 prelude.span = List.span;
52711 prelude.breakList = List.breakList;
52712 prelude.zip = List.zip;
52713 prelude.zipWith = List.zipWith;
52714 prelude.zipAll = List.zipAll;
52715 prelude.zipAllWith = List.zipAllWith;
52716 prelude.at = List.at;
52717 prelude.elemIndex = List.elemIndex;
52718 prelude.elemIndices = List.elemIndices;
52719 prelude.findIndex = List.findIndex;
52720 prelude.findIndices = List.findIndices;
52721 prelude.apply = Func.apply;
52722 prelude.curry = Func.curry;
52723 prelude.flip = Func.flip;
52724 prelude.fix = Func.fix;
52725 prelude.over = Func.over;
52726 prelude.split = Str.split;
52727 prelude.join = Str.join;
52728 prelude.lines = Str.lines;
52729 prelude.unlines = Str.unlines;
52730 prelude.words = Str.words;
52731 prelude.unwords = Str.unwords;
52732 prelude.chars = Str.chars;
52733 prelude.unchars = Str.unchars;
52734 prelude.repeat = Str.repeat;
52735 prelude.capitalize = Str.capitalize;
52736 prelude.camelize = Str.camelize;
52737 prelude.dasherize = Str.dasherize;
52738 prelude.values = Obj.values;
52739 prelude.keys = Obj.keys;
52740 prelude.pairsToObj = Obj.pairsToObj;
52741 prelude.objToPairs = Obj.objToPairs;
52742 prelude.listsToObj = Obj.listsToObj;
52743 prelude.objToLists = Obj.objToLists;
52744 prelude.max = Num.max;
52745 prelude.min = Num.min;
52746 prelude.negate = Num.negate;
52747 prelude.abs = Num.abs;
52748 prelude.signum = Num.signum;
52749 prelude.quot = Num.quot;
52750 prelude.rem = Num.rem;
52751 prelude.div = Num.div;
52752 prelude.mod = Num.mod;
52753 prelude.recip = Num.recip;
52754 prelude.pi = Num.pi;
52755 prelude.tau = Num.tau;
52756 prelude.exp = Num.exp;
52757 prelude.sqrt = Num.sqrt;
52758 prelude.ln = Num.ln;
52759 prelude.pow = Num.pow;
52760 prelude.sin = Num.sin;
52761 prelude.tan = Num.tan;
52762 prelude.cos = Num.cos;
52763 prelude.acos = Num.acos;
52764 prelude.asin = Num.asin;
52765 prelude.atan = Num.atan;
52766 prelude.atan2 = Num.atan2;
52767 prelude.truncate = Num.truncate;
52768 prelude.round = Num.round;
52769 prelude.ceiling = Num.ceiling;
52770 prelude.floor = Num.floor;
52771 prelude.isItNaN = Num.isItNaN;
52772 prelude.even = Num.even;
52773 prelude.odd = Num.odd;
52774 prelude.gcd = Num.gcd;
52775 prelude.lcm = Num.lcm;
52776 prelude.VERSION = '1.2.1';
52777 module.exports = prelude;
52778
52779 function curry$(f, bound) {
52780 var context,
52781 _curry = function (args) {
52782 return f.length > 1 ? function () {
52783 var params = args ? args.concat() : [];
52784 context = bound ? context || this : this;
52785 return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
52786 } : f;
52787 };
52788
52789 return _curry();
52790 }
52791
52792 /***/ }),
52793 /* 530 */
52794 /***/ ((module) => {
52795
52796 // Generated by LiveScript 1.6.0
52797 var apply,
52798 curry,
52799 flip,
52800 fix,
52801 over,
52802 memoize,
52803 toString$ = {}.toString;
52804 apply = curry$(function (f, list) {
52805 return f.apply(null, list);
52806 });
52807
52808 curry = function (f) {
52809 return curry$(f);
52810 };
52811
52812 flip = curry$(function (f, x, y) {
52813 return f(y, x);
52814 });
52815
52816 fix = function (f) {
52817 return function (g) {
52818 return function () {
52819 return f(g(g)).apply(null, arguments);
52820 };
52821 }(function (g) {
52822 return function () {
52823 return f(g(g)).apply(null, arguments);
52824 };
52825 });
52826 };
52827
52828 over = curry$(function (f, g, x, y) {
52829 return f(g(x), g(y));
52830 });
52831
52832 memoize = function (f) {
52833 var memo;
52834 memo = {};
52835 return function () {
52836 var args, res$, i$, to$, key, arg;
52837 res$ = [];
52838
52839 for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
52840 res$.push(arguments[i$]);
52841 }
52842
52843 args = res$;
52844
52845 key = function () {
52846 var i$,
52847 ref$,
52848 len$,
52849 results$ = [];
52850
52851 for (i$ = 0, len$ = (ref$ = args).length; i$ < len$; ++i$) {
52852 arg = ref$[i$];
52853 results$.push(arg + toString$.call(arg).slice(8, -1));
52854 }
52855
52856 return results$;
52857 }().join('');
52858
52859 return memo[key] = key in memo ? memo[key] : f.apply(null, args);
52860 };
52861 };
52862
52863 module.exports = {
52864 curry: curry,
52865 flip: flip,
52866 fix: fix,
52867 apply: apply,
52868 over: over,
52869 memoize: memoize
52870 };
52871
52872 function curry$(f, bound) {
52873 var context,
52874 _curry = function (args) {
52875 return f.length > 1 ? function () {
52876 var params = args ? args.concat() : [];
52877 context = bound ? context || this : this;
52878 return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
52879 } : f;
52880 };
52881
52882 return _curry();
52883 }
52884
52885 /***/ }),
52886 /* 531 */
52887 /***/ ((module) => {
52888
52889 // Generated by LiveScript 1.6.0
52890 var each,
52891 map,
52892 compact,
52893 filter,
52894 reject,
52895 remove,
52896 partition,
52897 find,
52898 head,
52899 first,
52900 tail,
52901 last,
52902 initial,
52903 empty,
52904 reverse,
52905 unique,
52906 uniqueBy,
52907 fold,
52908 foldl,
52909 fold1,
52910 foldl1,
52911 foldr,
52912 foldr1,
52913 unfoldr,
52914 concat,
52915 concatMap,
52916 flatten,
52917 difference,
52918 intersection,
52919 union,
52920 countBy,
52921 groupBy,
52922 andList,
52923 orList,
52924 any,
52925 all,
52926 sort,
52927 sortWith,
52928 sortBy,
52929 sum,
52930 product,
52931 mean,
52932 average,
52933 maximum,
52934 minimum,
52935 maximumBy,
52936 minimumBy,
52937 scan,
52938 scanl,
52939 scan1,
52940 scanl1,
52941 scanr,
52942 scanr1,
52943 slice,
52944 take,
52945 drop,
52946 splitAt,
52947 takeWhile,
52948 dropWhile,
52949 span,
52950 breakList,
52951 zip,
52952 zipWith,
52953 zipAll,
52954 zipAllWith,
52955 at,
52956 elemIndex,
52957 elemIndices,
52958 findIndex,
52959 findIndices,
52960 toString$ = {}.toString;
52961 each = curry$(function (f, xs) {
52962 var i$, len$, x;
52963
52964 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
52965 x = xs[i$];
52966 f(x);
52967 }
52968
52969 return xs;
52970 });
52971 map = curry$(function (f, xs) {
52972 var i$,
52973 len$,
52974 x,
52975 results$ = [];
52976
52977 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
52978 x = xs[i$];
52979 results$.push(f(x));
52980 }
52981
52982 return results$;
52983 });
52984
52985 compact = function (xs) {
52986 var i$,
52987 len$,
52988 x,
52989 results$ = [];
52990
52991 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
52992 x = xs[i$];
52993
52994 if (x) {
52995 results$.push(x);
52996 }
52997 }
52998
52999 return results$;
53000 };
53001
53002 filter = curry$(function (f, xs) {
53003 var i$,
53004 len$,
53005 x,
53006 results$ = [];
53007
53008 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53009 x = xs[i$];
53010
53011 if (f(x)) {
53012 results$.push(x);
53013 }
53014 }
53015
53016 return results$;
53017 });
53018 reject = curry$(function (f, xs) {
53019 var i$,
53020 len$,
53021 x,
53022 results$ = [];
53023
53024 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53025 x = xs[i$];
53026
53027 if (!f(x)) {
53028 results$.push(x);
53029 }
53030 }
53031
53032 return results$;
53033 });
53034 remove = curry$(function (el, xs) {
53035 var i, x$;
53036 i = elemIndex(el, xs);
53037 x$ = xs.slice();
53038
53039 if (i != null) {
53040 x$.splice(i, 1);
53041 }
53042
53043 return x$;
53044 });
53045 partition = curry$(function (f, xs) {
53046 var passed, failed, i$, len$, x;
53047 passed = [];
53048 failed = [];
53049
53050 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53051 x = xs[i$];
53052 (f(x) ? passed : failed).push(x);
53053 }
53054
53055 return [passed, failed];
53056 });
53057 find = curry$(function (f, xs) {
53058 var i$, len$, x;
53059
53060 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53061 x = xs[i$];
53062
53063 if (f(x)) {
53064 return x;
53065 }
53066 }
53067 });
53068
53069 head = first = function (xs) {
53070 return xs[0];
53071 };
53072
53073 tail = function (xs) {
53074 if (!xs.length) {
53075 return;
53076 }
53077
53078 return xs.slice(1);
53079 };
53080
53081 last = function (xs) {
53082 return xs[xs.length - 1];
53083 };
53084
53085 initial = function (xs) {
53086 if (!xs.length) {
53087 return;
53088 }
53089
53090 return xs.slice(0, -1);
53091 };
53092
53093 empty = function (xs) {
53094 return !xs.length;
53095 };
53096
53097 reverse = function (xs) {
53098 return xs.concat().reverse();
53099 };
53100
53101 unique = function (xs) {
53102 var result, i$, len$, x;
53103 result = [];
53104
53105 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53106 x = xs[i$];
53107
53108 if (!in$(x, result)) {
53109 result.push(x);
53110 }
53111 }
53112
53113 return result;
53114 };
53115
53116 uniqueBy = curry$(function (f, xs) {
53117 var seen,
53118 i$,
53119 len$,
53120 x,
53121 val,
53122 results$ = [];
53123 seen = [];
53124
53125 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53126 x = xs[i$];
53127 val = f(x);
53128
53129 if (in$(val, seen)) {
53130 continue;
53131 }
53132
53133 seen.push(val);
53134 results$.push(x);
53135 }
53136
53137 return results$;
53138 });
53139 fold = foldl = curry$(function (f, memo, xs) {
53140 var i$, len$, x;
53141
53142 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53143 x = xs[i$];
53144 memo = f(memo, x);
53145 }
53146
53147 return memo;
53148 });
53149 fold1 = foldl1 = curry$(function (f, xs) {
53150 return fold(f, xs[0], xs.slice(1));
53151 });
53152 foldr = curry$(function (f, memo, xs) {
53153 var i$, x;
53154
53155 for (i$ = xs.length - 1; i$ >= 0; --i$) {
53156 x = xs[i$];
53157 memo = f(x, memo);
53158 }
53159
53160 return memo;
53161 });
53162 foldr1 = curry$(function (f, xs) {
53163 return foldr(f, xs[xs.length - 1], xs.slice(0, -1));
53164 });
53165 unfoldr = curry$(function (f, b) {
53166 var result, x, that;
53167 result = [];
53168 x = b;
53169
53170 while ((that = f(x)) != null) {
53171 result.push(that[0]);
53172 x = that[1];
53173 }
53174
53175 return result;
53176 });
53177
53178 concat = function (xss) {
53179 return [].concat.apply([], xss);
53180 };
53181
53182 concatMap = curry$(function (f, xs) {
53183 var x;
53184 return [].concat.apply([], function () {
53185 var i$,
53186 ref$,
53187 len$,
53188 results$ = [];
53189
53190 for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
53191 x = ref$[i$];
53192 results$.push(f(x));
53193 }
53194
53195 return results$;
53196 }());
53197 });
53198
53199 flatten = function (xs) {
53200 var x;
53201 return [].concat.apply([], function () {
53202 var i$,
53203 ref$,
53204 len$,
53205 results$ = [];
53206
53207 for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
53208 x = ref$[i$];
53209
53210 if (toString$.call(x).slice(8, -1) === 'Array') {
53211 results$.push(flatten(x));
53212 } else {
53213 results$.push(x);
53214 }
53215 }
53216
53217 return results$;
53218 }());
53219 };
53220
53221 difference = function (xs) {
53222 var yss, res$, i$, to$, results, len$, x, j$, len1$, ys;
53223 res$ = [];
53224
53225 for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
53226 res$.push(arguments[i$]);
53227 }
53228
53229 yss = res$;
53230 results = [];
53231
53232 outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53233 x = xs[i$];
53234
53235 for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
53236 ys = yss[j$];
53237
53238 if (in$(x, ys)) {
53239 continue outer;
53240 }
53241 }
53242
53243 results.push(x);
53244 }
53245
53246 return results;
53247 };
53248
53249 intersection = function (xs) {
53250 var yss, res$, i$, to$, results, len$, x, j$, len1$, ys;
53251 res$ = [];
53252
53253 for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
53254 res$.push(arguments[i$]);
53255 }
53256
53257 yss = res$;
53258 results = [];
53259
53260 outer: for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53261 x = xs[i$];
53262
53263 for (j$ = 0, len1$ = yss.length; j$ < len1$; ++j$) {
53264 ys = yss[j$];
53265
53266 if (!in$(x, ys)) {
53267 continue outer;
53268 }
53269 }
53270
53271 results.push(x);
53272 }
53273
53274 return results;
53275 };
53276
53277 union = function () {
53278 var xss, res$, i$, to$, results, len$, xs, j$, len1$, x;
53279 res$ = [];
53280
53281 for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
53282 res$.push(arguments[i$]);
53283 }
53284
53285 xss = res$;
53286 results = [];
53287
53288 for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
53289 xs = xss[i$];
53290
53291 for (j$ = 0, len1$ = xs.length; j$ < len1$; ++j$) {
53292 x = xs[j$];
53293
53294 if (!in$(x, results)) {
53295 results.push(x);
53296 }
53297 }
53298 }
53299
53300 return results;
53301 };
53302
53303 countBy = curry$(function (f, xs) {
53304 var results, i$, len$, x, key;
53305 results = {};
53306
53307 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53308 x = xs[i$];
53309 key = f(x);
53310
53311 if (key in results) {
53312 results[key] += 1;
53313 } else {
53314 results[key] = 1;
53315 }
53316 }
53317
53318 return results;
53319 });
53320 groupBy = curry$(function (f, xs) {
53321 var results, i$, len$, x, key;
53322 results = {};
53323
53324 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53325 x = xs[i$];
53326 key = f(x);
53327
53328 if (key in results) {
53329 results[key].push(x);
53330 } else {
53331 results[key] = [x];
53332 }
53333 }
53334
53335 return results;
53336 });
53337
53338 andList = function (xs) {
53339 var i$, len$, x;
53340
53341 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53342 x = xs[i$];
53343
53344 if (!x) {
53345 return false;
53346 }
53347 }
53348
53349 return true;
53350 };
53351
53352 orList = function (xs) {
53353 var i$, len$, x;
53354
53355 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53356 x = xs[i$];
53357
53358 if (x) {
53359 return true;
53360 }
53361 }
53362
53363 return false;
53364 };
53365
53366 any = curry$(function (f, xs) {
53367 var i$, len$, x;
53368
53369 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53370 x = xs[i$];
53371
53372 if (f(x)) {
53373 return true;
53374 }
53375 }
53376
53377 return false;
53378 });
53379 all = curry$(function (f, xs) {
53380 var i$, len$, x;
53381
53382 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53383 x = xs[i$];
53384
53385 if (!f(x)) {
53386 return false;
53387 }
53388 }
53389
53390 return true;
53391 });
53392
53393 sort = function (xs) {
53394 return xs.concat().sort(function (x, y) {
53395 if (x > y) {
53396 return 1;
53397 } else if (x < y) {
53398 return -1;
53399 } else {
53400 return 0;
53401 }
53402 });
53403 };
53404
53405 sortWith = curry$(function (f, xs) {
53406 return xs.concat().sort(f);
53407 });
53408 sortBy = curry$(function (f, xs) {
53409 return xs.concat().sort(function (x, y) {
53410 if (f(x) > f(y)) {
53411 return 1;
53412 } else if (f(x) < f(y)) {
53413 return -1;
53414 } else {
53415 return 0;
53416 }
53417 });
53418 });
53419
53420 sum = function (xs) {
53421 var result, i$, len$, x;
53422 result = 0;
53423
53424 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53425 x = xs[i$];
53426 result += x;
53427 }
53428
53429 return result;
53430 };
53431
53432 product = function (xs) {
53433 var result, i$, len$, x;
53434 result = 1;
53435
53436 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53437 x = xs[i$];
53438 result *= x;
53439 }
53440
53441 return result;
53442 };
53443
53444 mean = average = function (xs) {
53445 var sum, i$, len$, x;
53446 sum = 0;
53447
53448 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53449 x = xs[i$];
53450 sum += x;
53451 }
53452
53453 return sum / xs.length;
53454 };
53455
53456 maximum = function (xs) {
53457 var max, i$, ref$, len$, x;
53458 max = xs[0];
53459
53460 for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
53461 x = ref$[i$];
53462
53463 if (x > max) {
53464 max = x;
53465 }
53466 }
53467
53468 return max;
53469 };
53470
53471 minimum = function (xs) {
53472 var min, i$, ref$, len$, x;
53473 min = xs[0];
53474
53475 for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
53476 x = ref$[i$];
53477
53478 if (x < min) {
53479 min = x;
53480 }
53481 }
53482
53483 return min;
53484 };
53485
53486 maximumBy = curry$(function (f, xs) {
53487 var max, i$, ref$, len$, x;
53488 max = xs[0];
53489
53490 for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
53491 x = ref$[i$];
53492
53493 if (f(x) > f(max)) {
53494 max = x;
53495 }
53496 }
53497
53498 return max;
53499 });
53500 minimumBy = curry$(function (f, xs) {
53501 var min, i$, ref$, len$, x;
53502 min = xs[0];
53503
53504 for (i$ = 0, len$ = (ref$ = xs.slice(1)).length; i$ < len$; ++i$) {
53505 x = ref$[i$];
53506
53507 if (f(x) < f(min)) {
53508 min = x;
53509 }
53510 }
53511
53512 return min;
53513 });
53514 scan = scanl = curry$(function (f, memo, xs) {
53515 var last, x;
53516 last = memo;
53517 return [memo].concat(function () {
53518 var i$,
53519 ref$,
53520 len$,
53521 results$ = [];
53522
53523 for (i$ = 0, len$ = (ref$ = xs).length; i$ < len$; ++i$) {
53524 x = ref$[i$];
53525 results$.push(last = f(last, x));
53526 }
53527
53528 return results$;
53529 }());
53530 });
53531 scan1 = scanl1 = curry$(function (f, xs) {
53532 if (!xs.length) {
53533 return;
53534 }
53535
53536 return scan(f, xs[0], xs.slice(1));
53537 });
53538 scanr = curry$(function (f, memo, xs) {
53539 xs = xs.concat().reverse();
53540 return scan(f, memo, xs).reverse();
53541 });
53542 scanr1 = curry$(function (f, xs) {
53543 if (!xs.length) {
53544 return;
53545 }
53546
53547 xs = xs.concat().reverse();
53548 return scan(f, xs[0], xs.slice(1)).reverse();
53549 });
53550 slice = curry$(function (x, y, xs) {
53551 return xs.slice(x, y);
53552 });
53553 take = curry$(function (n, xs) {
53554 if (n <= 0) {
53555 return xs.slice(0, 0);
53556 } else {
53557 return xs.slice(0, n);
53558 }
53559 });
53560 drop = curry$(function (n, xs) {
53561 if (n <= 0) {
53562 return xs;
53563 } else {
53564 return xs.slice(n);
53565 }
53566 });
53567 splitAt = curry$(function (n, xs) {
53568 return [take(n, xs), drop(n, xs)];
53569 });
53570 takeWhile = curry$(function (p, xs) {
53571 var len, i;
53572 len = xs.length;
53573
53574 if (!len) {
53575 return xs;
53576 }
53577
53578 i = 0;
53579
53580 while (i < len && p(xs[i])) {
53581 i += 1;
53582 }
53583
53584 return xs.slice(0, i);
53585 });
53586 dropWhile = curry$(function (p, xs) {
53587 var len, i;
53588 len = xs.length;
53589
53590 if (!len) {
53591 return xs;
53592 }
53593
53594 i = 0;
53595
53596 while (i < len && p(xs[i])) {
53597 i += 1;
53598 }
53599
53600 return xs.slice(i);
53601 });
53602 span = curry$(function (p, xs) {
53603 return [takeWhile(p, xs), dropWhile(p, xs)];
53604 });
53605 breakList = curry$(function (p, xs) {
53606 return span(compose$(p, not$), xs);
53607 });
53608 zip = curry$(function (xs, ys) {
53609 var result, len, i$, len$, i, x;
53610 result = [];
53611 len = ys.length;
53612
53613 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53614 i = i$;
53615 x = xs[i$];
53616
53617 if (i === len) {
53618 break;
53619 }
53620
53621 result.push([x, ys[i]]);
53622 }
53623
53624 return result;
53625 });
53626 zipWith = curry$(function (f, xs, ys) {
53627 var result, len, i$, len$, i, x;
53628 result = [];
53629 len = ys.length;
53630
53631 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53632 i = i$;
53633 x = xs[i$];
53634
53635 if (i === len) {
53636 break;
53637 }
53638
53639 result.push(f(x, ys[i]));
53640 }
53641
53642 return result;
53643 });
53644
53645 zipAll = function () {
53646 var xss,
53647 res$,
53648 i$,
53649 to$,
53650 minLength,
53651 len$,
53652 xs,
53653 ref$,
53654 i,
53655 lresult$,
53656 j$,
53657 results$ = [];
53658 res$ = [];
53659
53660 for (i$ = 0, to$ = arguments.length; i$ < to$; ++i$) {
53661 res$.push(arguments[i$]);
53662 }
53663
53664 xss = res$;
53665 minLength = undefined;
53666
53667 for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
53668 xs = xss[i$];
53669 minLength <= (ref$ = xs.length) || (minLength = ref$);
53670 }
53671
53672 for (i$ = 0; i$ < minLength; ++i$) {
53673 i = i$;
53674 lresult$ = [];
53675
53676 for (j$ = 0, len$ = xss.length; j$ < len$; ++j$) {
53677 xs = xss[j$];
53678 lresult$.push(xs[i]);
53679 }
53680
53681 results$.push(lresult$);
53682 }
53683
53684 return results$;
53685 };
53686
53687 zipAllWith = function (f) {
53688 var xss,
53689 res$,
53690 i$,
53691 to$,
53692 minLength,
53693 len$,
53694 xs,
53695 ref$,
53696 i,
53697 results$ = [];
53698 res$ = [];
53699
53700 for (i$ = 1, to$ = arguments.length; i$ < to$; ++i$) {
53701 res$.push(arguments[i$]);
53702 }
53703
53704 xss = res$;
53705 minLength = undefined;
53706
53707 for (i$ = 0, len$ = xss.length; i$ < len$; ++i$) {
53708 xs = xss[i$];
53709 minLength <= (ref$ = xs.length) || (minLength = ref$);
53710 }
53711
53712 for (i$ = 0; i$ < minLength; ++i$) {
53713 i = i$;
53714 results$.push(f.apply(null, fn$()));
53715 }
53716
53717 return results$;
53718
53719 function fn$() {
53720 var i$,
53721 ref$,
53722 len$,
53723 results$ = [];
53724
53725 for (i$ = 0, len$ = (ref$ = xss).length; i$ < len$; ++i$) {
53726 xs = ref$[i$];
53727 results$.push(xs[i]);
53728 }
53729
53730 return results$;
53731 }
53732 };
53733
53734 at = curry$(function (n, xs) {
53735 if (n < 0) {
53736 return xs[xs.length + n];
53737 } else {
53738 return xs[n];
53739 }
53740 });
53741 elemIndex = curry$(function (el, xs) {
53742 var i$, len$, i, x;
53743
53744 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53745 i = i$;
53746 x = xs[i$];
53747
53748 if (x === el) {
53749 return i;
53750 }
53751 }
53752 });
53753 elemIndices = curry$(function (el, xs) {
53754 var i$,
53755 len$,
53756 i,
53757 x,
53758 results$ = [];
53759
53760 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53761 i = i$;
53762 x = xs[i$];
53763
53764 if (x === el) {
53765 results$.push(i);
53766 }
53767 }
53768
53769 return results$;
53770 });
53771 findIndex = curry$(function (f, xs) {
53772 var i$, len$, i, x;
53773
53774 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53775 i = i$;
53776 x = xs[i$];
53777
53778 if (f(x)) {
53779 return i;
53780 }
53781 }
53782 });
53783 findIndices = curry$(function (f, xs) {
53784 var i$,
53785 len$,
53786 i,
53787 x,
53788 results$ = [];
53789
53790 for (i$ = 0, len$ = xs.length; i$ < len$; ++i$) {
53791 i = i$;
53792 x = xs[i$];
53793
53794 if (f(x)) {
53795 results$.push(i);
53796 }
53797 }
53798
53799 return results$;
53800 });
53801 module.exports = {
53802 each: each,
53803 map: map,
53804 filter: filter,
53805 compact: compact,
53806 reject: reject,
53807 remove: remove,
53808 partition: partition,
53809 find: find,
53810 head: head,
53811 first: first,
53812 tail: tail,
53813 last: last,
53814 initial: initial,
53815 empty: empty,
53816 reverse: reverse,
53817 difference: difference,
53818 intersection: intersection,
53819 union: union,
53820 countBy: countBy,
53821 groupBy: groupBy,
53822 fold: fold,
53823 fold1: fold1,
53824 foldl: foldl,
53825 foldl1: foldl1,
53826 foldr: foldr,
53827 foldr1: foldr1,
53828 unfoldr: unfoldr,
53829 andList: andList,
53830 orList: orList,
53831 any: any,
53832 all: all,
53833 unique: unique,
53834 uniqueBy: uniqueBy,
53835 sort: sort,
53836 sortWith: sortWith,
53837 sortBy: sortBy,
53838 sum: sum,
53839 product: product,
53840 mean: mean,
53841 average: average,
53842 concat: concat,
53843 concatMap: concatMap,
53844 flatten: flatten,
53845 maximum: maximum,
53846 minimum: minimum,
53847 maximumBy: maximumBy,
53848 minimumBy: minimumBy,
53849 scan: scan,
53850 scan1: scan1,
53851 scanl: scanl,
53852 scanl1: scanl1,
53853 scanr: scanr,
53854 scanr1: scanr1,
53855 slice: slice,
53856 take: take,
53857 drop: drop,
53858 splitAt: splitAt,
53859 takeWhile: takeWhile,
53860 dropWhile: dropWhile,
53861 span: span,
53862 breakList: breakList,
53863 zip: zip,
53864 zipWith: zipWith,
53865 zipAll: zipAll,
53866 zipAllWith: zipAllWith,
53867 at: at,
53868 elemIndex: elemIndex,
53869 elemIndices: elemIndices,
53870 findIndex: findIndex,
53871 findIndices: findIndices
53872 };
53873
53874 function curry$(f, bound) {
53875 var context,
53876 _curry = function (args) {
53877 return f.length > 1 ? function () {
53878 var params = args ? args.concat() : [];
53879 context = bound ? context || this : this;
53880 return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
53881 } : f;
53882 };
53883
53884 return _curry();
53885 }
53886
53887 function in$(x, xs) {
53888 var i = -1,
53889 l = xs.length >>> 0;
53890
53891 while (++i < l) if (x === xs[i]) return true;
53892
53893 return false;
53894 }
53895
53896 function compose$() {
53897 var functions = arguments;
53898 return function () {
53899 var i, result;
53900 result = functions[0].apply(this, arguments);
53901
53902 for (i = 1; i < functions.length; ++i) {
53903 result = functions[i](result);
53904 }
53905
53906 return result;
53907 };
53908 }
53909
53910 function not$(x) {
53911 return !x;
53912 }
53913
53914 /***/ }),
53915 /* 532 */
53916 /***/ ((module) => {
53917
53918 // Generated by LiveScript 1.6.0
53919 var values, keys, pairsToObj, objToPairs, listsToObj, objToLists, empty, each, map, compact, filter, reject, partition, find;
53920
53921 values = function (object) {
53922 var i$,
53923 x,
53924 results$ = [];
53925
53926 for (i$ in object) {
53927 x = object[i$];
53928 results$.push(x);
53929 }
53930
53931 return results$;
53932 };
53933
53934 keys = function (object) {
53935 var x,
53936 results$ = [];
53937
53938 for (x in object) {
53939 results$.push(x);
53940 }
53941
53942 return results$;
53943 };
53944
53945 pairsToObj = function (object) {
53946 var i$,
53947 len$,
53948 x,
53949 resultObj$ = {};
53950
53951 for (i$ = 0, len$ = object.length; i$ < len$; ++i$) {
53952 x = object[i$];
53953 resultObj$[x[0]] = x[1];
53954 }
53955
53956 return resultObj$;
53957 };
53958
53959 objToPairs = function (object) {
53960 var key,
53961 value,
53962 results$ = [];
53963
53964 for (key in object) {
53965 value = object[key];
53966 results$.push([key, value]);
53967 }
53968
53969 return results$;
53970 };
53971
53972 listsToObj = curry$(function (keys, values) {
53973 var i$,
53974 len$,
53975 i,
53976 key,
53977 resultObj$ = {};
53978
53979 for (i$ = 0, len$ = keys.length; i$ < len$; ++i$) {
53980 i = i$;
53981 key = keys[i$];
53982 resultObj$[key] = values[i];
53983 }
53984
53985 return resultObj$;
53986 });
53987
53988 objToLists = function (object) {
53989 var keys, values, key, value;
53990 keys = [];
53991 values = [];
53992
53993 for (key in object) {
53994 value = object[key];
53995 keys.push(key);
53996 values.push(value);
53997 }
53998
53999 return [keys, values];
54000 };
54001
54002 empty = function (object) {
54003 var x;
54004
54005 for (x in object) {
54006 return false;
54007 }
54008
54009 return true;
54010 };
54011
54012 each = curry$(function (f, object) {
54013 var i$, x;
54014
54015 for (i$ in object) {
54016 x = object[i$];
54017 f(x);
54018 }
54019
54020 return object;
54021 });
54022 map = curry$(function (f, object) {
54023 var k,
54024 x,
54025 resultObj$ = {};
54026
54027 for (k in object) {
54028 x = object[k];
54029 resultObj$[k] = f(x);
54030 }
54031
54032 return resultObj$;
54033 });
54034
54035 compact = function (object) {
54036 var k,
54037 x,
54038 resultObj$ = {};
54039
54040 for (k in object) {
54041 x = object[k];
54042
54043 if (x) {
54044 resultObj$[k] = x;
54045 }
54046 }
54047
54048 return resultObj$;
54049 };
54050
54051 filter = curry$(function (f, object) {
54052 var k,
54053 x,
54054 resultObj$ = {};
54055
54056 for (k in object) {
54057 x = object[k];
54058
54059 if (f(x)) {
54060 resultObj$[k] = x;
54061 }
54062 }
54063
54064 return resultObj$;
54065 });
54066 reject = curry$(function (f, object) {
54067 var k,
54068 x,
54069 resultObj$ = {};
54070
54071 for (k in object) {
54072 x = object[k];
54073
54074 if (!f(x)) {
54075 resultObj$[k] = x;
54076 }
54077 }
54078
54079 return resultObj$;
54080 });
54081 partition = curry$(function (f, object) {
54082 var passed, failed, k, x;
54083 passed = {};
54084 failed = {};
54085
54086 for (k in object) {
54087 x = object[k];
54088 (f(x) ? passed : failed)[k] = x;
54089 }
54090
54091 return [passed, failed];
54092 });
54093 find = curry$(function (f, object) {
54094 var i$, x;
54095
54096 for (i$ in object) {
54097 x = object[i$];
54098
54099 if (f(x)) {
54100 return x;
54101 }
54102 }
54103 });
54104 module.exports = {
54105 values: values,
54106 keys: keys,
54107 pairsToObj: pairsToObj,
54108 objToPairs: objToPairs,
54109 listsToObj: listsToObj,
54110 objToLists: objToLists,
54111 empty: empty,
54112 each: each,
54113 map: map,
54114 filter: filter,
54115 compact: compact,
54116 reject: reject,
54117 partition: partition,
54118 find: find
54119 };
54120
54121 function curry$(f, bound) {
54122 var context,
54123 _curry = function (args) {
54124 return f.length > 1 ? function () {
54125 var params = args ? args.concat() : [];
54126 context = bound ? context || this : this;
54127 return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
54128 } : f;
54129 };
54130
54131 return _curry();
54132 }
54133
54134 /***/ }),
54135 /* 533 */
54136 /***/ ((module) => {
54137
54138 // Generated by LiveScript 1.6.0
54139 var split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat, capitalize, camelize, dasherize;
54140 split = curry$(function (sep, str) {
54141 return str.split(sep);
54142 });
54143 join = curry$(function (sep, xs) {
54144 return xs.join(sep);
54145 });
54146
54147 lines = function (str) {
54148 if (!str.length) {
54149 return [];
54150 }
54151
54152 return str.split('\n');
54153 };
54154
54155 unlines = function (it) {
54156 return it.join('\n');
54157 };
54158
54159 words = function (str) {
54160 if (!str.length) {
54161 return [];
54162 }
54163
54164 return str.split(/[ ]+/);
54165 };
54166
54167 unwords = function (it) {
54168 return it.join(' ');
54169 };
54170
54171 chars = function (it) {
54172 return it.split('');
54173 };
54174
54175 unchars = function (it) {
54176 return it.join('');
54177 };
54178
54179 reverse = function (str) {
54180 return str.split('').reverse().join('');
54181 };
54182
54183 repeat = curry$(function (n, str) {
54184 var result, i$;
54185 result = '';
54186
54187 for (i$ = 0; i$ < n; ++i$) {
54188 result += str;
54189 }
54190
54191 return result;
54192 });
54193
54194 capitalize = function (str) {
54195 return str.charAt(0).toUpperCase() + str.slice(1);
54196 };
54197
54198 camelize = function (it) {
54199 return it.replace(/[-_]+(.)?/g, function (arg$, c) {
54200 return (c != null ? c : '').toUpperCase();
54201 });
54202 };
54203
54204 dasherize = function (str) {
54205 return str.replace(/([^-A-Z])([A-Z]+)/g, function (arg$, lower, upper) {
54206 return lower + "-" + (upper.length > 1 ? upper : upper.toLowerCase());
54207 }).replace(/^([A-Z]+)/, function (arg$, upper) {
54208 if (upper.length > 1) {
54209 return upper + "-";
54210 } else {
54211 return upper.toLowerCase();
54212 }
54213 });
54214 };
54215
54216 module.exports = {
54217 split: split,
54218 join: join,
54219 lines: lines,
54220 unlines: unlines,
54221 words: words,
54222 unwords: unwords,
54223 chars: chars,
54224 unchars: unchars,
54225 reverse: reverse,
54226 repeat: repeat,
54227 capitalize: capitalize,
54228 camelize: camelize,
54229 dasherize: dasherize
54230 };
54231
54232 function curry$(f, bound) {
54233 var context,
54234 _curry = function (args) {
54235 return f.length > 1 ? function () {
54236 var params = args ? args.concat() : [];
54237 context = bound ? context || this : this;
54238 return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
54239 } : f;
54240 };
54241
54242 return _curry();
54243 }
54244
54245 /***/ }),
54246 /* 534 */
54247 /***/ ((module) => {
54248
54249 // Generated by LiveScript 1.6.0
54250 var max, min, negate, abs, signum, quot, rem, div, mod, recip, pi, tau, exp, sqrt, ln, pow, sin, tan, cos, asin, acos, atan, atan2, truncate, round, ceiling, floor, isItNaN, even, odd, gcd, lcm;
54251 max = curry$(function (x$, y$) {
54252 return x$ > y$ ? x$ : y$;
54253 });
54254 min = curry$(function (x$, y$) {
54255 return x$ < y$ ? x$ : y$;
54256 });
54257
54258 negate = function (x) {
54259 return -x;
54260 };
54261
54262 abs = Math.abs;
54263
54264 signum = function (x) {
54265 if (x < 0) {
54266 return -1;
54267 } else if (x > 0) {
54268 return 1;
54269 } else {
54270 return 0;
54271 }
54272 };
54273
54274 quot = curry$(function (x, y) {
54275 return ~~(x / y);
54276 });
54277 rem = curry$(function (x$, y$) {
54278 return x$ % y$;
54279 });
54280 div = curry$(function (x, y) {
54281 return Math.floor(x / y);
54282 });
54283 mod = curry$(function (x$, y$) {
54284 var ref$;
54285 return (x$ % (ref$ = y$) + ref$) % ref$;
54286 });
54287
54288 recip = function (it) {
54289 return 1 / it;
54290 };
54291
54292 pi = Math.PI;
54293 tau = pi * 2;
54294 exp = Math.exp;
54295 sqrt = Math.sqrt;
54296 ln = Math.log;
54297 pow = curry$(function (x$, y$) {
54298 return Math.pow(x$, y$);
54299 });
54300 sin = Math.sin;
54301 tan = Math.tan;
54302 cos = Math.cos;
54303 asin = Math.asin;
54304 acos = Math.acos;
54305 atan = Math.atan;
54306 atan2 = curry$(function (x, y) {
54307 return Math.atan2(x, y);
54308 });
54309
54310 truncate = function (x) {
54311 return ~~x;
54312 };
54313
54314 round = Math.round;
54315 ceiling = Math.ceil;
54316 floor = Math.floor;
54317
54318 isItNaN = function (x) {
54319 return x !== x;
54320 };
54321
54322 even = function (x) {
54323 return x % 2 === 0;
54324 };
54325
54326 odd = function (x) {
54327 return x % 2 !== 0;
54328 };
54329
54330 gcd = curry$(function (x, y) {
54331 var z;
54332 x = Math.abs(x);
54333 y = Math.abs(y);
54334
54335 while (y !== 0) {
54336 z = x % y;
54337 x = y;
54338 y = z;
54339 }
54340
54341 return x;
54342 });
54343 lcm = curry$(function (x, y) {
54344 return Math.abs(Math.floor(x / gcd(x, y) * y));
54345 });
54346 module.exports = {
54347 max: max,
54348 min: min,
54349 negate: negate,
54350 abs: abs,
54351 signum: signum,
54352 quot: quot,
54353 rem: rem,
54354 div: div,
54355 mod: mod,
54356 recip: recip,
54357 pi: pi,
54358 tau: tau,
54359 exp: exp,
54360 sqrt: sqrt,
54361 ln: ln,
54362 pow: pow,
54363 sin: sin,
54364 tan: tan,
54365 cos: cos,
54366 acos: acos,
54367 asin: asin,
54368 atan: atan,
54369 atan2: atan2,
54370 truncate: truncate,
54371 round: round,
54372 ceiling: ceiling,
54373 floor: floor,
54374 isItNaN: isItNaN,
54375 even: even,
54376 odd: odd,
54377 gcd: gcd,
54378 lcm: lcm
54379 };
54380
54381 function curry$(f, bound) {
54382 var context,
54383 _curry = function (args) {
54384 return f.length > 1 ? function () {
54385 var params = args ? args.concat() : [];
54386 context = bound ? context || this : this;
54387 return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params);
54388 } : f;
54389 };
54390
54391 return _curry();
54392 }
54393
54394 /***/ }),
54395 /* 535 */
54396 /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
54397
54398 // Generated by LiveScript 1.6.0
54399 (function () {
54400 var parsedTypeCheck,
54401 types,
54402 toString$ = {}.toString;
54403 parsedTypeCheck = (__webpack_require__(536).parsedTypeCheck);
54404 types = {
54405 '*': function (value, options) {
54406 switch (toString$.call(value).slice(8, -1)) {
54407 case 'Array':
54408 return typeCast(value, {
54409 type: 'Array'
54410 }, options);
54411
54412 case 'Object':
54413 return typeCast(value, {
54414 type: 'Object'
54415 }, options);
54416
54417 default:
54418 return {
54419 type: 'Just',
54420 value: typesCast(value, [{
54421 type: 'Undefined'
54422 }, {
54423 type: 'Null'
54424 }, {
54425 type: 'NaN'
54426 }, {
54427 type: 'Boolean'
54428 }, {
54429 type: 'Number'
54430 }, {
54431 type: 'Date'
54432 }, {
54433 type: 'RegExp'
54434 }, {
54435 type: 'Array'
54436 }, {
54437 type: 'Object'
54438 }, {
54439 type: 'String'
54440 }], (options.explicit = true, options))
54441 };
54442 }
54443 },
54444 Undefined: function (it) {
54445 if (it === 'undefined' || it === void 8) {
54446 return {
54447 type: 'Just',
54448 value: void 8
54449 };
54450 } else {
54451 return {
54452 type: 'Nothing'
54453 };
54454 }
54455 },
54456 Null: function (it) {
54457 if (it === 'null') {
54458 return {
54459 type: 'Just',
54460 value: null
54461 };
54462 } else {
54463 return {
54464 type: 'Nothing'
54465 };
54466 }
54467 },
54468 NaN: function (it) {
54469 if (it === 'NaN') {
54470 return {
54471 type: 'Just',
54472 value: NaN
54473 };
54474 } else {
54475 return {
54476 type: 'Nothing'
54477 };
54478 }
54479 },
54480 Boolean: function (it) {
54481 if (it === 'true') {
54482 return {
54483 type: 'Just',
54484 value: true
54485 };
54486 } else if (it === 'false') {
54487 return {
54488 type: 'Just',
54489 value: false
54490 };
54491 } else {
54492 return {
54493 type: 'Nothing'
54494 };
54495 }
54496 },
54497 Number: function (it) {
54498 return {
54499 type: 'Just',
54500 value: +it
54501 };
54502 },
54503 Int: function (it) {
54504 return {
54505 type: 'Just',
54506 value: +it
54507 };
54508 },
54509 Float: function (it) {
54510 return {
54511 type: 'Just',
54512 value: +it
54513 };
54514 },
54515 Date: function (value, options) {
54516 var that;
54517
54518 if (that = /^\#([\s\S]*)\#$/.exec(value)) {
54519 return {
54520 type: 'Just',
54521 value: new Date(+that[1] || that[1])
54522 };
54523 } else if (options.explicit) {
54524 return {
54525 type: 'Nothing'
54526 };
54527 } else {
54528 return {
54529 type: 'Just',
54530 value: new Date(+value || value)
54531 };
54532 }
54533 },
54534 RegExp: function (value, options) {
54535 var that;
54536
54537 if (that = /^\/([\s\S]*)\/([gimy]*)$/.exec(value)) {
54538 return {
54539 type: 'Just',
54540 value: new RegExp(that[1], that[2])
54541 };
54542 } else if (options.explicit) {
54543 return {
54544 type: 'Nothing'
54545 };
54546 } else {
54547 return {
54548 type: 'Just',
54549 value: new RegExp(value)
54550 };
54551 }
54552 },
54553 Array: function (value, options) {
54554 return castArray(value, {
54555 of: [{
54556 type: '*'
54557 }]
54558 }, options);
54559 },
54560 Object: function (value, options) {
54561 return castFields(value, {
54562 of: {}
54563 }, options);
54564 },
54565 String: function (it) {
54566 var replace, that;
54567
54568 if (toString$.call(it).slice(8, -1) !== 'String') {
54569 return {
54570 type: 'Nothing'
54571 };
54572 }
54573
54574 replace = function (value, quote) {
54575 return value.replace(/\\([^u]|u[0-9a-fA-F]{4})/g, function (all, escaped) {
54576 switch (escaped[0]) {
54577 case quote:
54578 return quote;
54579
54580 case '\\':
54581 return '\\';
54582
54583 case 'b':
54584 return '\b';
54585
54586 case 'f':
54587 return '\f';
54588
54589 case 'n':
54590 return '\n';
54591
54592 case 'r':
54593 return '\r';
54594
54595 case 't':
54596 return '\t';
54597
54598 case 'u':
54599 return JSON.parse("\"" + all + "\"");
54600
54601 default:
54602 return escaped;
54603 }
54604 });
54605 };
54606
54607 if (that = it.match(/^'([\s\S]*)'$/)) {
54608 return {
54609 type: 'Just',
54610 value: replace(that[1], "'")
54611 };
54612 } else if (that = it.match(/^"([\s\S]*)"$/)) {
54613 return {
54614 type: 'Just',
54615 value: replace(that[1], '"')
54616 };
54617 } else {
54618 return {
54619 type: 'Just',
54620 value: it
54621 };
54622 }
54623 }
54624 };
54625
54626 function castArray(node, type, options) {
54627 var typeOf, element;
54628
54629 if (toString$.call(node).slice(8, -1) !== 'Array') {
54630 return {
54631 type: 'Nothing'
54632 };
54633 }
54634
54635 typeOf = type.of;
54636 return {
54637 type: 'Just',
54638 value: function () {
54639 var i$,
54640 ref$,
54641 len$,
54642 results$ = [];
54643
54644 for (i$ = 0, len$ = (ref$ = node).length; i$ < len$; ++i$) {
54645 element = ref$[i$];
54646 results$.push(typesCast(element, typeOf, options));
54647 }
54648
54649 return results$;
54650 }()
54651 };
54652 }
54653
54654 function castTuple(node, type, options) {
54655 var result, i, i$, ref$, len$, types, cast;
54656
54657 if (toString$.call(node).slice(8, -1) !== 'Array') {
54658 return {
54659 type: 'Nothing'
54660 };
54661 }
54662
54663 result = [];
54664 i = 0;
54665
54666 for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) {
54667 types = ref$[i$];
54668 cast = typesCast(node[i], types, options);
54669
54670 if (toString$.call(cast).slice(8, -1) !== 'Undefined') {
54671 result.push(cast);
54672 }
54673
54674 i++;
54675 }
54676
54677 if (node.length <= i) {
54678 return {
54679 type: 'Just',
54680 value: result
54681 };
54682 } else {
54683 return {
54684 type: 'Nothing'
54685 };
54686 }
54687 }
54688
54689 function castFields(node, type, options) {
54690 var typeOf, key, value;
54691
54692 if (toString$.call(node).slice(8, -1) !== 'Object') {
54693 return {
54694 type: 'Nothing'
54695 };
54696 }
54697
54698 typeOf = type.of;
54699 return {
54700 type: 'Just',
54701 value: function () {
54702 var ref$,
54703 resultObj$ = {};
54704
54705 for (key in ref$ = node) {
54706 value = ref$[key];
54707 resultObj$[typesCast(key, [{
54708 type: 'String'
54709 }], options)] = typesCast(value, typeOf[key] || [{
54710 type: '*'
54711 }], options);
54712 }
54713
54714 return resultObj$;
54715 }()
54716 };
54717 }
54718
54719 function typeCast(node, typeObj, options) {
54720 var type, structure, castFunc, ref$;
54721 type = typeObj.type, structure = typeObj.structure;
54722
54723 if (type) {
54724 castFunc = ((ref$ = options.customTypes[type]) != null ? ref$.cast : void 8) || types[type];
54725
54726 if (!castFunc) {
54727 throw new Error("Type not defined: " + type + ".");
54728 }
54729
54730 return castFunc(node, options, typesCast);
54731 } else {
54732 switch (structure) {
54733 case 'array':
54734 return castArray(node, typeObj, options);
54735
54736 case 'tuple':
54737 return castTuple(node, typeObj, options);
54738
54739 case 'fields':
54740 return castFields(node, typeObj, options);
54741 }
54742 }
54743 }
54744
54745 function typesCast(node, types, options) {
54746 var i$, len$, type, ref$, valueType, value;
54747
54748 for (i$ = 0, len$ = types.length; i$ < len$; ++i$) {
54749 type = types[i$];
54750 ref$ = typeCast(node, type, options), valueType = ref$.type, value = ref$.value;
54751
54752 if (valueType === 'Nothing') {
54753 continue;
54754 }
54755
54756 if (parsedTypeCheck([type], value, {
54757 customTypes: options.customTypes
54758 })) {
54759 return value;
54760 }
54761 }
54762
54763 throw new Error("Value " + JSON.stringify(node) + " does not type check against " + JSON.stringify(types) + ".");
54764 }
54765
54766 module.exports = function (node, types, options) {
54767 if (!options.explicit && types.length === 1 && types[0].type === 'String') {
54768 return node;
54769 }
54770
54771 return typesCast(node, types, options);
54772 };
54773 }).call(this);
54774
54775 /***/ }),
54776 /* 536 */
54777 /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
54778
54779 // Generated by LiveScript 1.6.0
54780 (function () {
54781 var VERSION, parseType, parsedTypeCheck, typeCheck;
54782 VERSION = '0.4.0';
54783 parseType = __webpack_require__(537);
54784 parsedTypeCheck = __webpack_require__(538);
54785
54786 typeCheck = function (type, input, options) {
54787 return parsedTypeCheck(parseType(type), input, options);
54788 };
54789
54790 module.exports = {
54791 VERSION: VERSION,
54792 typeCheck: typeCheck,
54793 parsedTypeCheck: parsedTypeCheck,
54794 parseType: parseType
54795 };
54796 }).call(this);
54797
54798 /***/ }),
54799 /* 537 */
54800 /***/ (function(module) {
54801
54802 // Generated by LiveScript 1.6.0
54803 (function () {
54804 var identifierRegex, tokenRegex;
54805 identifierRegex = /[\$\w]+/;
54806
54807 function peek(tokens) {
54808 var token;
54809 token = tokens[0];
54810
54811 if (token == null) {
54812 throw new Error('Unexpected end of input.');
54813 }
54814
54815 return token;
54816 }
54817
54818 function consumeIdent(tokens) {
54819 var token;
54820 token = peek(tokens);
54821
54822 if (!identifierRegex.test(token)) {
54823 throw new Error("Expected text, got '" + token + "' instead.");
54824 }
54825
54826 return tokens.shift();
54827 }
54828
54829 function consumeOp(tokens, op) {
54830 var token;
54831 token = peek(tokens);
54832
54833 if (token !== op) {
54834 throw new Error("Expected '" + op + "', got '" + token + "' instead.");
54835 }
54836
54837 return tokens.shift();
54838 }
54839
54840 function maybeConsumeOp(tokens, op) {
54841 var token;
54842 token = tokens[0];
54843
54844 if (token === op) {
54845 return tokens.shift();
54846 } else {
54847 return null;
54848 }
54849 }
54850
54851 function consumeArray(tokens) {
54852 var types;
54853 consumeOp(tokens, '[');
54854
54855 if (peek(tokens) === ']') {
54856 throw new Error("Must specify type of Array - eg. [Type], got [] instead.");
54857 }
54858
54859 types = consumeTypes(tokens);
54860 consumeOp(tokens, ']');
54861 return {
54862 structure: 'array',
54863 of: types
54864 };
54865 }
54866
54867 function consumeTuple(tokens) {
54868 var components;
54869 components = [];
54870 consumeOp(tokens, '(');
54871
54872 if (peek(tokens) === ')') {
54873 throw new Error("Tuple must be of at least length 1 - eg. (Type), got () instead.");
54874 }
54875
54876 for (;;) {
54877 components.push(consumeTypes(tokens));
54878 maybeConsumeOp(tokens, ',');
54879
54880 if (')' === peek(tokens)) {
54881 break;
54882 }
54883 }
54884
54885 consumeOp(tokens, ')');
54886 return {
54887 structure: 'tuple',
54888 of: components
54889 };
54890 }
54891
54892 function consumeFields(tokens) {
54893 var fields, subset, ref$, key, types;
54894 fields = {};
54895 consumeOp(tokens, '{');
54896 subset = false;
54897
54898 for (;;) {
54899 if (maybeConsumeOp(tokens, '...')) {
54900 subset = true;
54901 break;
54902 }
54903
54904 ref$ = consumeField(tokens), key = ref$[0], types = ref$[1];
54905 fields[key] = types;
54906 maybeConsumeOp(tokens, ',');
54907
54908 if ('}' === peek(tokens)) {
54909 break;
54910 }
54911 }
54912
54913 consumeOp(tokens, '}');
54914 return {
54915 structure: 'fields',
54916 of: fields,
54917 subset: subset
54918 };
54919 }
54920
54921 function consumeField(tokens) {
54922 var key, types;
54923 key = consumeIdent(tokens);
54924 consumeOp(tokens, ':');
54925 types = consumeTypes(tokens);
54926 return [key, types];
54927 }
54928
54929 function maybeConsumeStructure(tokens) {
54930 switch (tokens[0]) {
54931 case '[':
54932 return consumeArray(tokens);
54933
54934 case '(':
54935 return consumeTuple(tokens);
54936
54937 case '{':
54938 return consumeFields(tokens);
54939 }
54940 }
54941
54942 function consumeType(tokens) {
54943 var token, wildcard, type, structure;
54944 token = peek(tokens);
54945 wildcard = token === '*';
54946
54947 if (wildcard || identifierRegex.test(token)) {
54948 type = wildcard ? consumeOp(tokens, '*') : consumeIdent(tokens);
54949 structure = maybeConsumeStructure(tokens);
54950
54951 if (structure) {
54952 return structure.type = type, structure;
54953 } else {
54954 return {
54955 type: type
54956 };
54957 }
54958 } else {
54959 structure = maybeConsumeStructure(tokens);
54960
54961 if (!structure) {
54962 throw new Error("Unexpected character: " + token);
54963 }
54964
54965 return structure;
54966 }
54967 }
54968
54969 function consumeTypes(tokens) {
54970 var lookahead, types, typesSoFar, typeObj, type, structure;
54971
54972 if ('::' === peek(tokens)) {
54973 throw new Error("No comment before comment separator '::' found.");
54974 }
54975
54976 lookahead = tokens[1];
54977
54978 if (lookahead != null && lookahead === '::') {
54979 tokens.shift();
54980 tokens.shift();
54981 }
54982
54983 types = [];
54984 typesSoFar = {};
54985
54986 if ('Maybe' === peek(tokens)) {
54987 tokens.shift();
54988 types = [{
54989 type: 'Undefined'
54990 }, {
54991 type: 'Null'
54992 }];
54993 typesSoFar = {
54994 Undefined: true,
54995 Null: true
54996 };
54997 }
54998
54999 for (;;) {
55000 typeObj = consumeType(tokens), type = typeObj.type, structure = typeObj.structure;
55001
55002 if (!typesSoFar[type]) {
55003 types.push(typeObj);
55004 }
55005
55006 if (structure == null) {
55007 typesSoFar[type] = true;
55008 }
55009
55010 if (!maybeConsumeOp(tokens, '|')) {
55011 break;
55012 }
55013 }
55014
55015 return types;
55016 }
55017
55018 tokenRegex = RegExp('\\.\\.\\.|::|->|' + identifierRegex.source + '|\\S', 'g');
55019
55020 module.exports = function (input) {
55021 var tokens, e;
55022
55023 if (!input.length) {
55024 throw new Error('No type specified.');
55025 }
55026
55027 tokens = input.match(tokenRegex) || [];
55028
55029 if (in$('->', tokens)) {
55030 throw new Error("Function types are not supported.\ To validate that something is a function, you may use 'Function'.");
55031 }
55032
55033 try {
55034 return consumeTypes(tokens);
55035 } catch (e$) {
55036 e = e$;
55037 throw new Error(e.message + " - Remaining tokens: " + JSON.stringify(tokens) + " - Initial input: '" + input + "'");
55038 }
55039 };
55040
55041 function in$(x, xs) {
55042 var i = -1,
55043 l = xs.length >>> 0;
55044
55045 while (++i < l) if (x === xs[i]) return true;
55046
55047 return false;
55048 }
55049 }).call(this);
55050
55051 /***/ }),
55052 /* 538 */
55053 /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
55054
55055 // Generated by LiveScript 1.6.0
55056 (function () {
55057 var ref$,
55058 any,
55059 all,
55060 isItNaN,
55061 types,
55062 defaultType,
55063 toString$ = {}.toString;
55064 ref$ = __webpack_require__(529), any = ref$.any, all = ref$.all, isItNaN = ref$.isItNaN;
55065 types = {
55066 Number: {
55067 typeOf: 'Number',
55068 validate: function (it) {
55069 return !isItNaN(it);
55070 }
55071 },
55072 NaN: {
55073 typeOf: 'Number',
55074 validate: isItNaN
55075 },
55076 Int: {
55077 typeOf: 'Number',
55078 validate: function (it) {
55079 return !isItNaN(it) && it % 1 === 0;
55080 }
55081 },
55082 Float: {
55083 typeOf: 'Number',
55084 validate: function (it) {
55085 return !isItNaN(it);
55086 }
55087 },
55088 Date: {
55089 typeOf: 'Date',
55090 validate: function (it) {
55091 return !isItNaN(it.getTime());
55092 }
55093 }
55094 };
55095 defaultType = {
55096 array: 'Array',
55097 tuple: 'Array'
55098 };
55099
55100 function checkArray(input, type, options) {
55101 return all(function (it) {
55102 return checkMultiple(it, type.of, options);
55103 }, input);
55104 }
55105
55106 function checkTuple(input, type, options) {
55107 var i, i$, ref$, len$, types;
55108 i = 0;
55109
55110 for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) {
55111 types = ref$[i$];
55112
55113 if (!checkMultiple(input[i], types, options)) {
55114 return false;
55115 }
55116
55117 i++;
55118 }
55119
55120 return input.length <= i;
55121 }
55122
55123 function checkFields(input, type, options) {
55124 var inputKeys, numInputKeys, k, numOfKeys, key, ref$, types;
55125 inputKeys = {};
55126 numInputKeys = 0;
55127
55128 for (k in input) {
55129 inputKeys[k] = true;
55130 numInputKeys++;
55131 }
55132
55133 numOfKeys = 0;
55134
55135 for (key in ref$ = type.of) {
55136 types = ref$[key];
55137
55138 if (!checkMultiple(input[key], types, options)) {
55139 return false;
55140 }
55141
55142 if (inputKeys[key]) {
55143 numOfKeys++;
55144 }
55145 }
55146
55147 return type.subset || numInputKeys === numOfKeys;
55148 }
55149
55150 function checkStructure(input, type, options) {
55151 if (!(input instanceof Object)) {
55152 return false;
55153 }
55154
55155 switch (type.structure) {
55156 case 'fields':
55157 return checkFields(input, type, options);
55158
55159 case 'array':
55160 return checkArray(input, type, options);
55161
55162 case 'tuple':
55163 return checkTuple(input, type, options);
55164 }
55165 }
55166
55167 function check(input, typeObj, options) {
55168 var type, structure, setting, that;
55169 type = typeObj.type, structure = typeObj.structure;
55170
55171 if (type) {
55172 if (type === '*') {
55173 return true;
55174 }
55175
55176 setting = options.customTypes[type] || types[type];
55177
55178 if (setting) {
55179 return (setting.typeOf === void 8 || setting.typeOf === toString$.call(input).slice(8, -1)) && setting.validate(input);
55180 } else {
55181 return type === toString$.call(input).slice(8, -1) && (!structure || checkStructure(input, typeObj, options));
55182 }
55183 } else if (structure) {
55184 if (that = defaultType[structure]) {
55185 if (that !== toString$.call(input).slice(8, -1)) {
55186 return false;
55187 }
55188 }
55189
55190 return checkStructure(input, typeObj, options);
55191 } else {
55192 throw new Error("No type defined. Input: " + input + ".");
55193 }
55194 }
55195
55196 function checkMultiple(input, types, options) {
55197 if (toString$.call(types).slice(8, -1) !== 'Array') {
55198 throw new Error("Types must be in an array. Input: " + input + ".");
55199 }
55200
55201 return any(function (it) {
55202 return check(input, it, options);
55203 }, types);
55204 }
55205
55206 module.exports = function (parsedType, input, options) {
55207 options == null && (options = {});
55208
55209 if (options.customTypes == null) {
55210 options.customTypes = {};
55211 }
55212
55213 return checkMultiple(input, parsedType, options);
55214 };
55215 }).call(this);
55216
55217 /***/ }),
55218 /* 539 */
55219 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
55220
55221 "use strict";
55222 /**
55223 * @fileoverview The event generator for AST nodes.
55224 * @author Toru Nagashima
55225 */
55226 //------------------------------------------------------------------------------
55227 // Requirements
55228 //------------------------------------------------------------------------------
55229
55230 const esquery = __webpack_require__(540); //------------------------------------------------------------------------------
55231 // Typedefs
55232 //------------------------------------------------------------------------------
55233
55234 /**
55235 * An object describing an AST selector
55236 * @typedef {Object} ASTSelector
55237 * @property {string} rawSelector The string that was parsed into this selector
55238 * @property {boolean} isExit `true` if this should be emitted when exiting the node rather than when entering
55239 * @property {Object} parsedSelector An object (from esquery) describing the matching behavior of the selector
55240 * @property {string[]|null} listenerTypes A list of node types that could possibly cause the selector to match,
55241 * or `null` if all node types could cause a match
55242 * @property {number} attributeCount The total number of classes, pseudo-classes, and attribute queries in this selector
55243 * @property {number} identifierCount The total number of identifier queries in this selector
55244 */
55245 //------------------------------------------------------------------------------
55246 // Helpers
55247 //------------------------------------------------------------------------------
55248
55249 /**
55250 * Computes the union of one or more arrays
55251 * @param {...any[]} arrays One or more arrays to union
55252 * @returns {any[]} The union of the input arrays
55253 */
55254
55255
55256 function union() {
55257 for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) {
55258 arrays[_key] = arguments[_key];
55259 }
55260
55261 return [...new Set(arrays.flat())];
55262 }
55263 /**
55264 * Computes the intersection of one or more arrays
55265 * @param {...any[]} arrays One or more arrays to intersect
55266 * @returns {any[]} The intersection of the input arrays
55267 */
55268
55269
55270 function intersection() {
55271 for (var _len2 = arguments.length, arrays = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
55272 arrays[_key2] = arguments[_key2];
55273 }
55274
55275 if (arrays.length === 0) {
55276 return [];
55277 }
55278
55279 let result = [...new Set(arrays[0])];
55280
55281 for (const array of arrays.slice(1)) {
55282 result = result.filter(x => array.includes(x));
55283 }
55284
55285 return result;
55286 }
55287 /**
55288 * Gets the possible types of a selector
55289 * @param {Object} parsedSelector An object (from esquery) describing the matching behavior of the selector
55290 * @returns {string[]|null} The node types that could possibly trigger this selector, or `null` if all node types could trigger it
55291 */
55292
55293
55294 function getPossibleTypes(parsedSelector) {
55295 switch (parsedSelector.type) {
55296 case "identifier":
55297 return [parsedSelector.value];
55298
55299 case "matches":
55300 {
55301 const typesForComponents = parsedSelector.selectors.map(getPossibleTypes);
55302
55303 if (typesForComponents.every(Boolean)) {
55304 return union(...typesForComponents);
55305 }
55306
55307 return null;
55308 }
55309
55310 case "compound":
55311 {
55312 const typesForComponents = parsedSelector.selectors.map(getPossibleTypes).filter(typesForComponent => typesForComponent); // If all of the components could match any type, then the compound could also match any type.
55313
55314 if (!typesForComponents.length) {
55315 return null;
55316 }
55317 /*
55318 * If at least one of the components could only match a particular type, the compound could only match
55319 * the intersection of those types.
55320 */
55321
55322
55323 return intersection(...typesForComponents);
55324 }
55325
55326 case "child":
55327 case "descendant":
55328 case "sibling":
55329 case "adjacent":
55330 return getPossibleTypes(parsedSelector.right);
55331
55332 case "class":
55333 if (parsedSelector.name === "function") {
55334 return ["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"];
55335 }
55336
55337 return null;
55338
55339 default:
55340 return null;
55341 }
55342 }
55343 /**
55344 * Counts the number of class, pseudo-class, and attribute queries in this selector
55345 * @param {Object} parsedSelector An object (from esquery) describing the selector's matching behavior
55346 * @returns {number} The number of class, pseudo-class, and attribute queries in this selector
55347 */
55348
55349
55350 function countClassAttributes(parsedSelector) {
55351 switch (parsedSelector.type) {
55352 case "child":
55353 case "descendant":
55354 case "sibling":
55355 case "adjacent":
55356 return countClassAttributes(parsedSelector.left) + countClassAttributes(parsedSelector.right);
55357
55358 case "compound":
55359 case "not":
55360 case "matches":
55361 return parsedSelector.selectors.reduce((sum, childSelector) => sum + countClassAttributes(childSelector), 0);
55362
55363 case "attribute":
55364 case "field":
55365 case "nth-child":
55366 case "nth-last-child":
55367 return 1;
55368
55369 default:
55370 return 0;
55371 }
55372 }
55373 /**
55374 * Counts the number of identifier queries in this selector
55375 * @param {Object} parsedSelector An object (from esquery) describing the selector's matching behavior
55376 * @returns {number} The number of identifier queries
55377 */
55378
55379
55380 function countIdentifiers(parsedSelector) {
55381 switch (parsedSelector.type) {
55382 case "child":
55383 case "descendant":
55384 case "sibling":
55385 case "adjacent":
55386 return countIdentifiers(parsedSelector.left) + countIdentifiers(parsedSelector.right);
55387
55388 case "compound":
55389 case "not":
55390 case "matches":
55391 return parsedSelector.selectors.reduce((sum, childSelector) => sum + countIdentifiers(childSelector), 0);
55392
55393 case "identifier":
55394 return 1;
55395
55396 default:
55397 return 0;
55398 }
55399 }
55400 /**
55401 * Compares the specificity of two selector objects, with CSS-like rules.
55402 * @param {ASTSelector} selectorA An AST selector descriptor
55403 * @param {ASTSelector} selectorB Another AST selector descriptor
55404 * @returns {number}
55405 * a value less than 0 if selectorA is less specific than selectorB
55406 * a value greater than 0 if selectorA is more specific than selectorB
55407 * a value less than 0 if selectorA and selectorB have the same specificity, and selectorA <= selectorB alphabetically
55408 * a value greater than 0 if selectorA and selectorB have the same specificity, and selectorA > selectorB alphabetically
55409 */
55410
55411
55412 function compareSpecificity(selectorA, selectorB) {
55413 return selectorA.attributeCount - selectorB.attributeCount || selectorA.identifierCount - selectorB.identifierCount || (selectorA.rawSelector <= selectorB.rawSelector ? -1 : 1);
55414 }
55415 /**
55416 * Parses a raw selector string, and throws a useful error if parsing fails.
55417 * @param {string} rawSelector A raw AST selector
55418 * @returns {Object} An object (from esquery) describing the matching behavior of this selector
55419 * @throws {Error} An error if the selector is invalid
55420 */
55421
55422
55423 function tryParseSelector(rawSelector) {
55424 try {
55425 return esquery.parse(rawSelector.replace(/:exit$/u, ""));
55426 } catch (err) {
55427 if (err.location && err.location.start && typeof err.location.start.offset === "number") {
55428 throw new SyntaxError("Syntax error in selector \"".concat(rawSelector, "\" at position ").concat(err.location.start.offset, ": ").concat(err.message));
55429 }
55430
55431 throw err;
55432 }
55433 }
55434
55435 const selectorCache = new Map();
55436 /**
55437 * Parses a raw selector string, and returns the parsed selector along with specificity and type information.
55438 * @param {string} rawSelector A raw AST selector
55439 * @returns {ASTSelector} A selector descriptor
55440 */
55441
55442 function parseSelector(rawSelector) {
55443 if (selectorCache.has(rawSelector)) {
55444 return selectorCache.get(rawSelector);
55445 }
55446
55447 const parsedSelector = tryParseSelector(rawSelector);
55448 const result = {
55449 rawSelector,
55450 isExit: rawSelector.endsWith(":exit"),
55451 parsedSelector,
55452 listenerTypes: getPossibleTypes(parsedSelector),
55453 attributeCount: countClassAttributes(parsedSelector),
55454 identifierCount: countIdentifiers(parsedSelector)
55455 };
55456 selectorCache.set(rawSelector, result);
55457 return result;
55458 } //------------------------------------------------------------------------------
55459 // Public Interface
55460 //------------------------------------------------------------------------------
55461
55462 /**
55463 * The event generator for AST nodes.
55464 * This implements below interface.
55465 *
55466 * ```ts
55467 * interface EventGenerator {
55468 * emitter: SafeEmitter;
55469 * enterNode(node: ASTNode): void;
55470 * leaveNode(node: ASTNode): void;
55471 * }
55472 * ```
55473 */
55474
55475
55476 class NodeEventGenerator {
55477 /**
55478 * @param {SafeEmitter} emitter
55479 * An SafeEmitter which is the destination of events. This emitter must already
55480 * have registered listeners for all of the events that it needs to listen for.
55481 * (See lib/linter/safe-emitter.js for more details on `SafeEmitter`.)
55482 * @param {ESQueryOptions} esqueryOptions `esquery` options for traversing custom nodes.
55483 * @returns {NodeEventGenerator} new instance
55484 */
55485 constructor(emitter, esqueryOptions) {
55486 this.emitter = emitter;
55487 this.esqueryOptions = esqueryOptions;
55488 this.currentAncestry = [];
55489 this.enterSelectorsByNodeType = new Map();
55490 this.exitSelectorsByNodeType = new Map();
55491 this.anyTypeEnterSelectors = [];
55492 this.anyTypeExitSelectors = [];
55493 emitter.eventNames().forEach(rawSelector => {
55494 const selector = parseSelector(rawSelector);
55495
55496 if (selector.listenerTypes) {
55497 const typeMap = selector.isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType;
55498 selector.listenerTypes.forEach(nodeType => {
55499 if (!typeMap.has(nodeType)) {
55500 typeMap.set(nodeType, []);
55501 }
55502
55503 typeMap.get(nodeType).push(selector);
55504 });
55505 return;
55506 }
55507
55508 const selectors = selector.isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors;
55509 selectors.push(selector);
55510 });
55511 this.anyTypeEnterSelectors.sort(compareSpecificity);
55512 this.anyTypeExitSelectors.sort(compareSpecificity);
55513 this.enterSelectorsByNodeType.forEach(selectorList => selectorList.sort(compareSpecificity));
55514 this.exitSelectorsByNodeType.forEach(selectorList => selectorList.sort(compareSpecificity));
55515 }
55516 /**
55517 * Checks a selector against a node, and emits it if it matches
55518 * @param {ASTNode} node The node to check
55519 * @param {ASTSelector} selector An AST selector descriptor
55520 * @returns {void}
55521 */
55522
55523
55524 applySelector(node, selector) {
55525 if (esquery.matches(node, selector.parsedSelector, this.currentAncestry, this.esqueryOptions)) {
55526 this.emitter.emit(selector.rawSelector, node);
55527 }
55528 }
55529 /**
55530 * Applies all appropriate selectors to a node, in specificity order
55531 * @param {ASTNode} node The node to check
55532 * @param {boolean} isExit `false` if the node is currently being entered, `true` if it's currently being exited
55533 * @returns {void}
55534 */
55535
55536
55537 applySelectors(node, isExit) {
55538 const selectorsByNodeType = (isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType).get(node.type) || [];
55539 const anyTypeSelectors = isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors;
55540 /*
55541 * selectorsByNodeType and anyTypeSelectors were already sorted by specificity in the constructor.
55542 * Iterate through each of them, applying selectors in the right order.
55543 */
55544
55545 let selectorsByTypeIndex = 0;
55546 let anyTypeSelectorsIndex = 0;
55547
55548 while (selectorsByTypeIndex < selectorsByNodeType.length || anyTypeSelectorsIndex < anyTypeSelectors.length) {
55549 if (selectorsByTypeIndex >= selectorsByNodeType.length || anyTypeSelectorsIndex < anyTypeSelectors.length && compareSpecificity(anyTypeSelectors[anyTypeSelectorsIndex], selectorsByNodeType[selectorsByTypeIndex]) < 0) {
55550 this.applySelector(node, anyTypeSelectors[anyTypeSelectorsIndex++]);
55551 } else {
55552 this.applySelector(node, selectorsByNodeType[selectorsByTypeIndex++]);
55553 }
55554 }
55555 }
55556 /**
55557 * Emits an event of entering AST node.
55558 * @param {ASTNode} node A node which was entered.
55559 * @returns {void}
55560 */
55561
55562
55563 enterNode(node) {
55564 if (node.parent) {
55565 this.currentAncestry.unshift(node.parent);
55566 }
55567
55568 this.applySelectors(node, false);
55569 }
55570 /**
55571 * Emits an event of leaving AST node.
55572 * @param {ASTNode} node A node which was left.
55573 * @returns {void}
55574 */
55575
55576
55577 leaveNode(node) {
55578 this.applySelectors(node, true);
55579 this.currentAncestry.shift();
55580 }
55581
55582 }
55583
55584 module.exports = NodeEventGenerator;
55585
55586 /***/ }),
55587 /* 540 */
55588 /***/ (function(module) {
55589
55590 !function (e, t) {
55591 true ? module.exports = t() : 0;
55592 }(this, function () {
55593 "use strict";
55594
55595 function e(t) {
55596 return (e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) {
55597 return typeof e;
55598 } : function (e) {
55599 return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
55600 })(t);
55601 }
55602
55603 function t(e, t) {
55604 return function (e) {
55605 if (Array.isArray(e)) return e;
55606 }(e) || function (e, t) {
55607 if ("undefined" == typeof Symbol || !(Symbol.iterator in Object(e))) return;
55608 var r = [],
55609 n = !0,
55610 o = !1,
55611 a = void 0;
55612
55613 try {
55614 for (var i, s = e[Symbol.iterator](); !(n = (i = s.next()).done) && (r.push(i.value), !t || r.length !== t); n = !0);
55615 } catch (e) {
55616 o = !0, a = e;
55617 } finally {
55618 try {
55619 n || null == s.return || s.return();
55620 } finally {
55621 if (o) throw a;
55622 }
55623 }
55624
55625 return r;
55626 }(e, t) || n(e, t) || function () {
55627 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
55628 }();
55629 }
55630
55631 function r(e) {
55632 return function (e) {
55633 if (Array.isArray(e)) return o(e);
55634 }(e) || function (e) {
55635 if ("undefined" != typeof Symbol && Symbol.iterator in Object(e)) return Array.from(e);
55636 }(e) || n(e) || function () {
55637 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
55638 }();
55639 }
55640
55641 function n(e, t) {
55642 if (e) {
55643 if ("string" == typeof e) return o(e, t);
55644 var r = Object.prototype.toString.call(e).slice(8, -1);
55645 return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? o(e, t) : void 0;
55646 }
55647 }
55648
55649 function o(e, t) {
55650 (null == t || t > e.length) && (t = e.length);
55651
55652 for (var r = 0, n = new Array(t); r < t; r++) n[r] = e[r];
55653
55654 return n;
55655 }
55656
55657 function a(e, t) {
55658 var r;
55659
55660 if ("undefined" == typeof Symbol || null == e[Symbol.iterator]) {
55661 if (Array.isArray(e) || (r = n(e)) || t && e && "number" == typeof e.length) {
55662 r && (e = r);
55663
55664 var o = 0,
55665 a = function () {};
55666
55667 return {
55668 s: a,
55669 n: function () {
55670 return o >= e.length ? {
55671 done: !0
55672 } : {
55673 done: !1,
55674 value: e[o++]
55675 };
55676 },
55677 e: function (e) {
55678 throw e;
55679 },
55680 f: a
55681 };
55682 }
55683
55684 throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
55685 }
55686
55687 var i,
55688 s = !0,
55689 l = !1;
55690 return {
55691 s: function () {
55692 r = e[Symbol.iterator]();
55693 },
55694 n: function () {
55695 var e = r.next();
55696 return s = e.done, e;
55697 },
55698 e: function (e) {
55699 l = !0, i = e;
55700 },
55701 f: function () {
55702 try {
55703 s || null == r.return || r.return();
55704 } finally {
55705 if (l) throw i;
55706 }
55707 }
55708 };
55709 }
55710
55711 "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self && self;
55712
55713 function i(e, t) {
55714 return e(t = {
55715 exports: {}
55716 }, t.exports), t.exports;
55717 }
55718
55719 var s = i(function (e, t) {
55720 !function e(t) {
55721 var r, n, o, a, i, s;
55722
55723 function l(e) {
55724 var t,
55725 r,
55726 n = {};
55727
55728 for (t in e) e.hasOwnProperty(t) && (r = e[t], n[t] = "object" == typeof r && null !== r ? l(r) : r);
55729
55730 return n;
55731 }
55732
55733 function u(e, t) {
55734 this.parent = e, this.key = t;
55735 }
55736
55737 function c(e, t, r, n) {
55738 this.node = e, this.path = t, this.wrap = r, this.ref = n;
55739 }
55740
55741 function f() {}
55742
55743 function p(e) {
55744 return null != e && "object" == typeof e && "string" == typeof e.type;
55745 }
55746
55747 function h(e, t) {
55748 return (e === r.ObjectExpression || e === r.ObjectPattern) && "properties" === t;
55749 }
55750
55751 function y(e, t) {
55752 for (var r = e.length - 1; r >= 0; --r) if (e[r].node === t) return !0;
55753
55754 return !1;
55755 }
55756
55757 function d(e, t) {
55758 return new f().traverse(e, t);
55759 }
55760
55761 function m(e, t) {
55762 var r;
55763 return r = function (e, t) {
55764 var r, n, o, a;
55765
55766 for (n = e.length, o = 0; n;) t(e[a = o + (r = n >>> 1)]) ? n = r : (o = a + 1, n -= r + 1);
55767
55768 return o;
55769 }(t, function (t) {
55770 return t.range[0] > e.range[0];
55771 }), e.extendedRange = [e.range[0], e.range[1]], r !== t.length && (e.extendedRange[1] = t[r].range[0]), (r -= 1) >= 0 && (e.extendedRange[0] = t[r].range[1]), e;
55772 }
55773
55774 return r = {
55775 AssignmentExpression: "AssignmentExpression",
55776 AssignmentPattern: "AssignmentPattern",
55777 ArrayExpression: "ArrayExpression",
55778 ArrayPattern: "ArrayPattern",
55779 ArrowFunctionExpression: "ArrowFunctionExpression",
55780 AwaitExpression: "AwaitExpression",
55781 BlockStatement: "BlockStatement",
55782 BinaryExpression: "BinaryExpression",
55783 BreakStatement: "BreakStatement",
55784 CallExpression: "CallExpression",
55785 CatchClause: "CatchClause",
55786 ChainExpression: "ChainExpression",
55787 ClassBody: "ClassBody",
55788 ClassDeclaration: "ClassDeclaration",
55789 ClassExpression: "ClassExpression",
55790 ComprehensionBlock: "ComprehensionBlock",
55791 ComprehensionExpression: "ComprehensionExpression",
55792 ConditionalExpression: "ConditionalExpression",
55793 ContinueStatement: "ContinueStatement",
55794 DebuggerStatement: "DebuggerStatement",
55795 DirectiveStatement: "DirectiveStatement",
55796 DoWhileStatement: "DoWhileStatement",
55797 EmptyStatement: "EmptyStatement",
55798 ExportAllDeclaration: "ExportAllDeclaration",
55799 ExportDefaultDeclaration: "ExportDefaultDeclaration",
55800 ExportNamedDeclaration: "ExportNamedDeclaration",
55801 ExportSpecifier: "ExportSpecifier",
55802 ExpressionStatement: "ExpressionStatement",
55803 ForStatement: "ForStatement",
55804 ForInStatement: "ForInStatement",
55805 ForOfStatement: "ForOfStatement",
55806 FunctionDeclaration: "FunctionDeclaration",
55807 FunctionExpression: "FunctionExpression",
55808 GeneratorExpression: "GeneratorExpression",
55809 Identifier: "Identifier",
55810 IfStatement: "IfStatement",
55811 ImportExpression: "ImportExpression",
55812 ImportDeclaration: "ImportDeclaration",
55813 ImportDefaultSpecifier: "ImportDefaultSpecifier",
55814 ImportNamespaceSpecifier: "ImportNamespaceSpecifier",
55815 ImportSpecifier: "ImportSpecifier",
55816 Literal: "Literal",
55817 LabeledStatement: "LabeledStatement",
55818 LogicalExpression: "LogicalExpression",
55819 MemberExpression: "MemberExpression",
55820 MetaProperty: "MetaProperty",
55821 MethodDefinition: "MethodDefinition",
55822 ModuleSpecifier: "ModuleSpecifier",
55823 NewExpression: "NewExpression",
55824 ObjectExpression: "ObjectExpression",
55825 ObjectPattern: "ObjectPattern",
55826 Program: "Program",
55827 Property: "Property",
55828 RestElement: "RestElement",
55829 ReturnStatement: "ReturnStatement",
55830 SequenceExpression: "SequenceExpression",
55831 SpreadElement: "SpreadElement",
55832 Super: "Super",
55833 SwitchStatement: "SwitchStatement",
55834 SwitchCase: "SwitchCase",
55835 TaggedTemplateExpression: "TaggedTemplateExpression",
55836 TemplateElement: "TemplateElement",
55837 TemplateLiteral: "TemplateLiteral",
55838 ThisExpression: "ThisExpression",
55839 ThrowStatement: "ThrowStatement",
55840 TryStatement: "TryStatement",
55841 UnaryExpression: "UnaryExpression",
55842 UpdateExpression: "UpdateExpression",
55843 VariableDeclaration: "VariableDeclaration",
55844 VariableDeclarator: "VariableDeclarator",
55845 WhileStatement: "WhileStatement",
55846 WithStatement: "WithStatement",
55847 YieldExpression: "YieldExpression"
55848 }, o = {
55849 AssignmentExpression: ["left", "right"],
55850 AssignmentPattern: ["left", "right"],
55851 ArrayExpression: ["elements"],
55852 ArrayPattern: ["elements"],
55853 ArrowFunctionExpression: ["params", "body"],
55854 AwaitExpression: ["argument"],
55855 BlockStatement: ["body"],
55856 BinaryExpression: ["left", "right"],
55857 BreakStatement: ["label"],
55858 CallExpression: ["callee", "arguments"],
55859 CatchClause: ["param", "body"],
55860 ChainExpression: ["expression"],
55861 ClassBody: ["body"],
55862 ClassDeclaration: ["id", "superClass", "body"],
55863 ClassExpression: ["id", "superClass", "body"],
55864 ComprehensionBlock: ["left", "right"],
55865 ComprehensionExpression: ["blocks", "filter", "body"],
55866 ConditionalExpression: ["test", "consequent", "alternate"],
55867 ContinueStatement: ["label"],
55868 DebuggerStatement: [],
55869 DirectiveStatement: [],
55870 DoWhileStatement: ["body", "test"],
55871 EmptyStatement: [],
55872 ExportAllDeclaration: ["source"],
55873 ExportDefaultDeclaration: ["declaration"],
55874 ExportNamedDeclaration: ["declaration", "specifiers", "source"],
55875 ExportSpecifier: ["exported", "local"],
55876 ExpressionStatement: ["expression"],
55877 ForStatement: ["init", "test", "update", "body"],
55878 ForInStatement: ["left", "right", "body"],
55879 ForOfStatement: ["left", "right", "body"],
55880 FunctionDeclaration: ["id", "params", "body"],
55881 FunctionExpression: ["id", "params", "body"],
55882 GeneratorExpression: ["blocks", "filter", "body"],
55883 Identifier: [],
55884 IfStatement: ["test", "consequent", "alternate"],
55885 ImportExpression: ["source"],
55886 ImportDeclaration: ["specifiers", "source"],
55887 ImportDefaultSpecifier: ["local"],
55888 ImportNamespaceSpecifier: ["local"],
55889 ImportSpecifier: ["imported", "local"],
55890 Literal: [],
55891 LabeledStatement: ["label", "body"],
55892 LogicalExpression: ["left", "right"],
55893 MemberExpression: ["object", "property"],
55894 MetaProperty: ["meta", "property"],
55895 MethodDefinition: ["key", "value"],
55896 ModuleSpecifier: [],
55897 NewExpression: ["callee", "arguments"],
55898 ObjectExpression: ["properties"],
55899 ObjectPattern: ["properties"],
55900 Program: ["body"],
55901 Property: ["key", "value"],
55902 RestElement: ["argument"],
55903 ReturnStatement: ["argument"],
55904 SequenceExpression: ["expressions"],
55905 SpreadElement: ["argument"],
55906 Super: [],
55907 SwitchStatement: ["discriminant", "cases"],
55908 SwitchCase: ["test", "consequent"],
55909 TaggedTemplateExpression: ["tag", "quasi"],
55910 TemplateElement: [],
55911 TemplateLiteral: ["quasis", "expressions"],
55912 ThisExpression: [],
55913 ThrowStatement: ["argument"],
55914 TryStatement: ["block", "handler", "finalizer"],
55915 UnaryExpression: ["argument"],
55916 UpdateExpression: ["argument"],
55917 VariableDeclaration: ["declarations"],
55918 VariableDeclarator: ["id", "init"],
55919 WhileStatement: ["test", "body"],
55920 WithStatement: ["object", "body"],
55921 YieldExpression: ["argument"]
55922 }, n = {
55923 Break: a = {},
55924 Skip: i = {},
55925 Remove: s = {}
55926 }, u.prototype.replace = function (e) {
55927 this.parent[this.key] = e;
55928 }, u.prototype.remove = function () {
55929 return Array.isArray(this.parent) ? (this.parent.splice(this.key, 1), !0) : (this.replace(null), !1);
55930 }, f.prototype.path = function () {
55931 var e, t, r, n, o;
55932
55933 function a(e, t) {
55934 if (Array.isArray(t)) for (r = 0, n = t.length; r < n; ++r) e.push(t[r]);else e.push(t);
55935 }
55936
55937 if (!this.__current.path) return null;
55938
55939 for (o = [], e = 2, t = this.__leavelist.length; e < t; ++e) a(o, this.__leavelist[e].path);
55940
55941 return a(o, this.__current.path), o;
55942 }, f.prototype.type = function () {
55943 return this.current().type || this.__current.wrap;
55944 }, f.prototype.parents = function () {
55945 var e, t, r;
55946
55947 for (r = [], e = 1, t = this.__leavelist.length; e < t; ++e) r.push(this.__leavelist[e].node);
55948
55949 return r;
55950 }, f.prototype.current = function () {
55951 return this.__current.node;
55952 }, f.prototype.__execute = function (e, t) {
55953 var r, n;
55954 return n = void 0, r = this.__current, this.__current = t, this.__state = null, e && (n = e.call(this, t.node, this.__leavelist[this.__leavelist.length - 1].node)), this.__current = r, n;
55955 }, f.prototype.notify = function (e) {
55956 this.__state = e;
55957 }, f.prototype.skip = function () {
55958 this.notify(i);
55959 }, f.prototype.break = function () {
55960 this.notify(a);
55961 }, f.prototype.remove = function () {
55962 this.notify(s);
55963 }, f.prototype.__initialize = function (e, t) {
55964 this.visitor = t, this.root = e, this.__worklist = [], this.__leavelist = [], this.__current = null, this.__state = null, this.__fallback = null, "iteration" === t.fallback ? this.__fallback = Object.keys : "function" == typeof t.fallback && (this.__fallback = t.fallback), this.__keys = o, t.keys && (this.__keys = Object.assign(Object.create(this.__keys), t.keys));
55965 }, f.prototype.traverse = function (e, t) {
55966 var r, n, o, s, l, u, f, d, m, x, v, g;
55967
55968 for (this.__initialize(e, t), g = {}, r = this.__worklist, n = this.__leavelist, r.push(new c(e, null, null, null)), n.push(new c(null, null, null, null)); r.length;) if ((o = r.pop()) !== g) {
55969 if (o.node) {
55970 if (u = this.__execute(t.enter, o), this.__state === a || u === a) return;
55971 if (r.push(g), n.push(o), this.__state === i || u === i) continue;
55972
55973 if (l = (s = o.node).type || o.wrap, !(x = this.__keys[l])) {
55974 if (!this.__fallback) throw new Error("Unknown node type " + l + ".");
55975 x = this.__fallback(s);
55976 }
55977
55978 for (d = x.length; (d -= 1) >= 0;) if (v = s[f = x[d]]) if (Array.isArray(v)) {
55979 for (m = v.length; (m -= 1) >= 0;) if (v[m] && !y(n, v[m])) {
55980 if (h(l, x[d])) o = new c(v[m], [f, m], "Property", null);else {
55981 if (!p(v[m])) continue;
55982 o = new c(v[m], [f, m], null, null);
55983 }
55984 r.push(o);
55985 }
55986 } else if (p(v)) {
55987 if (y(n, v)) continue;
55988 r.push(new c(v, f, null, null));
55989 }
55990 }
55991 } else if (o = n.pop(), u = this.__execute(t.leave, o), this.__state === a || u === a) return;
55992 }, f.prototype.replace = function (e, t) {
55993 var r, n, o, l, f, y, d, m, x, v, g, b, A;
55994
55995 function E(e) {
55996 var t, n, o, a;
55997 if (e.ref.remove()) for (n = e.ref.key, a = e.ref.parent, t = r.length; t--;) if ((o = r[t]).ref && o.ref.parent === a) {
55998 if (o.ref.key < n) break;
55999 --o.ref.key;
56000 }
56001 }
56002
56003 for (this.__initialize(e, t), g = {}, r = this.__worklist, n = this.__leavelist, y = new c(e, null, null, new u(b = {
56004 root: e
56005 }, "root")), r.push(y), n.push(y); r.length;) if ((y = r.pop()) !== g) {
56006 if (void 0 !== (f = this.__execute(t.enter, y)) && f !== a && f !== i && f !== s && (y.ref.replace(f), y.node = f), this.__state !== s && f !== s || (E(y), y.node = null), this.__state === a || f === a) return b.root;
56007
56008 if ((o = y.node) && (r.push(g), n.push(y), this.__state !== i && f !== i)) {
56009 if (l = o.type || y.wrap, !(x = this.__keys[l])) {
56010 if (!this.__fallback) throw new Error("Unknown node type " + l + ".");
56011 x = this.__fallback(o);
56012 }
56013
56014 for (d = x.length; (d -= 1) >= 0;) if (v = o[A = x[d]]) if (Array.isArray(v)) {
56015 for (m = v.length; (m -= 1) >= 0;) if (v[m]) {
56016 if (h(l, x[d])) y = new c(v[m], [A, m], "Property", new u(v, m));else {
56017 if (!p(v[m])) continue;
56018 y = new c(v[m], [A, m], null, new u(v, m));
56019 }
56020 r.push(y);
56021 }
56022 } else p(v) && r.push(new c(v, A, null, new u(o, A)));
56023 }
56024 } else if (y = n.pop(), void 0 !== (f = this.__execute(t.leave, y)) && f !== a && f !== i && f !== s && y.ref.replace(f), this.__state !== s && f !== s || E(y), this.__state === a || f === a) return b.root;
56025
56026 return b.root;
56027 }, t.Syntax = r, t.traverse = d, t.replace = function (e, t) {
56028 return new f().replace(e, t);
56029 }, t.attachComments = function (e, t, r) {
56030 var o,
56031 a,
56032 i,
56033 s,
56034 u = [];
56035 if (!e.range) throw new Error("attachComments needs range information");
56036
56037 if (!r.length) {
56038 if (t.length) {
56039 for (i = 0, a = t.length; i < a; i += 1) (o = l(t[i])).extendedRange = [0, e.range[0]], u.push(o);
56040
56041 e.leadingComments = u;
56042 }
56043
56044 return e;
56045 }
56046
56047 for (i = 0, a = t.length; i < a; i += 1) u.push(m(l(t[i]), r));
56048
56049 return s = 0, d(e, {
56050 enter: function (e) {
56051 for (var t; s < u.length && !((t = u[s]).extendedRange[1] > e.range[0]);) t.extendedRange[1] === e.range[0] ? (e.leadingComments || (e.leadingComments = []), e.leadingComments.push(t), u.splice(s, 1)) : s += 1;
56052
56053 return s === u.length ? n.Break : u[s].extendedRange[0] > e.range[1] ? n.Skip : void 0;
56054 }
56055 }), s = 0, d(e, {
56056 leave: function (e) {
56057 for (var t; s < u.length && (t = u[s], !(e.range[1] < t.extendedRange[0]));) e.range[1] === t.extendedRange[0] ? (e.trailingComments || (e.trailingComments = []), e.trailingComments.push(t), u.splice(s, 1)) : s += 1;
56058
56059 return s === u.length ? n.Break : u[s].extendedRange[0] > e.range[1] ? n.Skip : void 0;
56060 }
56061 }), e;
56062 }, t.VisitorKeys = o, t.VisitorOption = n, t.Controller = f, t.cloneEnvironment = function () {
56063 return e({});
56064 }, t;
56065 }(t);
56066 }),
56067 l = i(function (e) {
56068 e.exports && (e.exports = function () {
56069 function e(t, r, n, o) {
56070 this.message = t, this.expected = r, this.found = n, this.location = o, this.name = "SyntaxError", "function" == typeof Error.captureStackTrace && Error.captureStackTrace(this, e);
56071 }
56072
56073 return function (e, t) {
56074 function r() {
56075 this.constructor = e;
56076 }
56077
56078 r.prototype = t.prototype, e.prototype = new r();
56079 }(e, Error), e.buildMessage = function (e, t) {
56080 var r = {
56081 literal: function (e) {
56082 return '"' + o(e.text) + '"';
56083 },
56084 class: function (e) {
56085 var t,
56086 r = "";
56087
56088 for (t = 0; t < e.parts.length; t++) r += e.parts[t] instanceof Array ? a(e.parts[t][0]) + "-" + a(e.parts[t][1]) : a(e.parts[t]);
56089
56090 return "[" + (e.inverted ? "^" : "") + r + "]";
56091 },
56092 any: function (e) {
56093 return "any character";
56094 },
56095 end: function (e) {
56096 return "end of input";
56097 },
56098 other: function (e) {
56099 return e.description;
56100 }
56101 };
56102
56103 function n(e) {
56104 return e.charCodeAt(0).toString(16).toUpperCase();
56105 }
56106
56107 function o(e) {
56108 return e.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function (e) {
56109 return "\\x0" + n(e);
56110 }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (e) {
56111 return "\\x" + n(e);
56112 });
56113 }
56114
56115 function a(e) {
56116 return e.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function (e) {
56117 return "\\x0" + n(e);
56118 }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (e) {
56119 return "\\x" + n(e);
56120 });
56121 }
56122
56123 return "Expected " + function (e) {
56124 var t,
56125 n,
56126 o,
56127 a = new Array(e.length);
56128
56129 for (t = 0; t < e.length; t++) a[t] = (o = e[t], r[o.type](o));
56130
56131 if (a.sort(), a.length > 0) {
56132 for (t = 1, n = 1; t < a.length; t++) a[t - 1] !== a[t] && (a[n] = a[t], n++);
56133
56134 a.length = n;
56135 }
56136
56137 switch (a.length) {
56138 case 1:
56139 return a[0];
56140
56141 case 2:
56142 return a[0] + " or " + a[1];
56143
56144 default:
56145 return a.slice(0, -1).join(", ") + ", or " + a[a.length - 1];
56146 }
56147 }(e) + " but " + function (e) {
56148 return e ? '"' + o(e) + '"' : "end of input";
56149 }(t) + " found.";
56150 }, {
56151 SyntaxError: e,
56152 parse: function (t, r) {
56153 r = void 0 !== r ? r : {};
56154
56155 var n,
56156 o,
56157 a,
56158 i,
56159 s = {},
56160 l = {
56161 start: be
56162 },
56163 u = be,
56164 c = de(" ", !1),
56165 f = /^[^ [\],():#!=><~+.]/,
56166 p = me([" ", "[", "]", ",", "(", ")", ":", "#", "!", "=", ">", "<", "~", "+", "."], !0, !1),
56167 h = de(">", !1),
56168 y = de("~", !1),
56169 d = de("+", !1),
56170 m = de(",", !1),
56171 x = de("!", !1),
56172 v = de("*", !1),
56173 g = de("#", !1),
56174 b = de("[", !1),
56175 A = de("]", !1),
56176 E = /^[><!]/,
56177 S = me([">", "<", "!"], !1, !1),
56178 _ = de("=", !1),
56179 w = function (e) {
56180 return (e || "") + "=";
56181 },
56182 C = /^[><]/,
56183 P = me([">", "<"], !1, !1),
56184 k = de(".", !1),
56185 D = function (e, t, r) {
56186 return {
56187 type: "attribute",
56188 name: e,
56189 operator: t,
56190 value: r
56191 };
56192 },
56193 j = de('"', !1),
56194 I = /^[^\\"]/,
56195 T = me(["\\", '"'], !0, !1),
56196 F = de("\\", !1),
56197 L = {
56198 type: "any"
56199 },
56200 O = function (e, t) {
56201 return e + t;
56202 },
56203 R = function (e) {
56204 return {
56205 type: "literal",
56206 value: (t = e.join(""), t.replace(/\\(.)/g, function (e, t) {
56207 switch (t) {
56208 case "b":
56209 return "\b";
56210
56211 case "f":
56212 return "\f";
56213
56214 case "n":
56215 return "\n";
56216
56217 case "r":
56218 return "\r";
56219
56220 case "t":
56221 return "\t";
56222
56223 case "v":
56224 return "\v";
56225
56226 default:
56227 return t;
56228 }
56229 }))
56230 };
56231 var t;
56232 },
56233 B = de("'", !1),
56234 M = /^[^\\']/,
56235 U = me(["\\", "'"], !0, !1),
56236 q = /^[0-9]/,
56237 V = me([["0", "9"]], !1, !1),
56238 N = de("type(", !1),
56239 W = /^[^ )]/,
56240 K = me([" ", ")"], !0, !1),
56241 G = de(")", !1),
56242 z = /^[imsu]/,
56243 H = me(["i", "m", "s", "u"], !1, !1),
56244 Y = de("/", !1),
56245 $ = /^[^\/]/,
56246 J = me(["/"], !0, !1),
56247 Q = de(":not(", !1),
56248 X = de(":matches(", !1),
56249 Z = de(":has(", !1),
56250 ee = de(":first-child", !1),
56251 te = de(":last-child", !1),
56252 re = de(":nth-child(", !1),
56253 ne = de(":nth-last-child(", !1),
56254 oe = de(":", !1),
56255 ae = de("statement", !0),
56256 ie = de("expression", !0),
56257 se = de("declaration", !0),
56258 le = de("function", !0),
56259 ue = de("pattern", !0),
56260 ce = 0,
56261 fe = [{
56262 line: 1,
56263 column: 1
56264 }],
56265 pe = 0,
56266 he = [],
56267 ye = {};
56268
56269 if ("startRule" in r) {
56270 if (!(r.startRule in l)) throw new Error("Can't start parsing from rule \"" + r.startRule + '".');
56271 u = l[r.startRule];
56272 }
56273
56274 function de(e, t) {
56275 return {
56276 type: "literal",
56277 text: e,
56278 ignoreCase: t
56279 };
56280 }
56281
56282 function me(e, t, r) {
56283 return {
56284 type: "class",
56285 parts: e,
56286 inverted: t,
56287 ignoreCase: r
56288 };
56289 }
56290
56291 function xe(e) {
56292 var r,
56293 n = fe[e];
56294 if (n) return n;
56295
56296 for (r = e - 1; !fe[r];) r--;
56297
56298 for (n = {
56299 line: (n = fe[r]).line,
56300 column: n.column
56301 }; r < e;) 10 === t.charCodeAt(r) ? (n.line++, n.column = 1) : n.column++, r++;
56302
56303 return fe[e] = n, n;
56304 }
56305
56306 function ve(e, t) {
56307 var r = xe(e),
56308 n = xe(t);
56309 return {
56310 start: {
56311 offset: e,
56312 line: r.line,
56313 column: r.column
56314 },
56315 end: {
56316 offset: t,
56317 line: n.line,
56318 column: n.column
56319 }
56320 };
56321 }
56322
56323 function ge(e) {
56324 ce < pe || (ce > pe && (pe = ce, he = []), he.push(e));
56325 }
56326
56327 function be() {
56328 var e,
56329 t,
56330 r,
56331 n,
56332 o = 30 * ce + 0,
56333 a = ye[o];
56334 return a ? (ce = a.nextPos, a.result) : (e = ce, (t = Ae()) !== s && (r = _e()) !== s && Ae() !== s ? e = t = 1 === (n = r).length ? n[0] : {
56335 type: "matches",
56336 selectors: n
56337 } : (ce = e, e = s), e === s && (e = ce, (t = Ae()) !== s && (t = void 0), e = t), ye[o] = {
56338 nextPos: ce,
56339 result: e
56340 }, e);
56341 }
56342
56343 function Ae() {
56344 var e,
56345 r,
56346 n = 30 * ce + 1,
56347 o = ye[n];
56348 if (o) return ce = o.nextPos, o.result;
56349
56350 for (e = [], 32 === t.charCodeAt(ce) ? (r = " ", ce++) : (r = s, ge(c)); r !== s;) e.push(r), 32 === t.charCodeAt(ce) ? (r = " ", ce++) : (r = s, ge(c));
56351
56352 return ye[n] = {
56353 nextPos: ce,
56354 result: e
56355 }, e;
56356 }
56357
56358 function Ee() {
56359 var e,
56360 r,
56361 n,
56362 o = 30 * ce + 2,
56363 a = ye[o];
56364 if (a) return ce = a.nextPos, a.result;
56365 if (r = [], f.test(t.charAt(ce)) ? (n = t.charAt(ce), ce++) : (n = s, ge(p)), n !== s) for (; n !== s;) r.push(n), f.test(t.charAt(ce)) ? (n = t.charAt(ce), ce++) : (n = s, ge(p));else r = s;
56366 return r !== s && (r = r.join("")), e = r, ye[o] = {
56367 nextPos: ce,
56368 result: e
56369 }, e;
56370 }
56371
56372 function Se() {
56373 var e,
56374 r,
56375 n,
56376 o = 30 * ce + 3,
56377 a = ye[o];
56378 return a ? (ce = a.nextPos, a.result) : (e = ce, (r = Ae()) !== s ? (62 === t.charCodeAt(ce) ? (n = ">", ce++) : (n = s, ge(h)), n !== s && Ae() !== s ? e = r = "child" : (ce = e, e = s)) : (ce = e, e = s), e === s && (e = ce, (r = Ae()) !== s ? (126 === t.charCodeAt(ce) ? (n = "~", ce++) : (n = s, ge(y)), n !== s && Ae() !== s ? e = r = "sibling" : (ce = e, e = s)) : (ce = e, e = s), e === s && (e = ce, (r = Ae()) !== s ? (43 === t.charCodeAt(ce) ? (n = "+", ce++) : (n = s, ge(d)), n !== s && Ae() !== s ? e = r = "adjacent" : (ce = e, e = s)) : (ce = e, e = s), e === s && (e = ce, 32 === t.charCodeAt(ce) ? (r = " ", ce++) : (r = s, ge(c)), r !== s && (n = Ae()) !== s ? e = r = "descendant" : (ce = e, e = s)))), ye[o] = {
56379 nextPos: ce,
56380 result: e
56381 }, e);
56382 }
56383
56384 function _e() {
56385 var e,
56386 r,
56387 n,
56388 o,
56389 a,
56390 i,
56391 l,
56392 u,
56393 c = 30 * ce + 4,
56394 f = ye[c];
56395 if (f) return ce = f.nextPos, f.result;
56396
56397 if (e = ce, (r = we()) !== s) {
56398 for (n = [], o = ce, (a = Ae()) !== s ? (44 === t.charCodeAt(ce) ? (i = ",", ce++) : (i = s, ge(m)), i !== s && (l = Ae()) !== s && (u = we()) !== s ? o = a = [a, i, l, u] : (ce = o, o = s)) : (ce = o, o = s); o !== s;) n.push(o), o = ce, (a = Ae()) !== s ? (44 === t.charCodeAt(ce) ? (i = ",", ce++) : (i = s, ge(m)), i !== s && (l = Ae()) !== s && (u = we()) !== s ? o = a = [a, i, l, u] : (ce = o, o = s)) : (ce = o, o = s);
56399
56400 n !== s ? e = r = [r].concat(n.map(function (e) {
56401 return e[3];
56402 })) : (ce = e, e = s);
56403 } else ce = e, e = s;
56404
56405 return ye[c] = {
56406 nextPos: ce,
56407 result: e
56408 }, e;
56409 }
56410
56411 function we() {
56412 var e,
56413 t,
56414 r,
56415 n,
56416 o,
56417 a,
56418 i,
56419 l = 30 * ce + 5,
56420 u = ye[l];
56421 if (u) return ce = u.nextPos, u.result;
56422
56423 if (e = ce, (t = Ce()) !== s) {
56424 for (r = [], n = ce, (o = Se()) !== s && (a = Ce()) !== s ? n = o = [o, a] : (ce = n, n = s); n !== s;) r.push(n), n = ce, (o = Se()) !== s && (a = Ce()) !== s ? n = o = [o, a] : (ce = n, n = s);
56425
56426 r !== s ? (i = t, e = t = r.reduce(function (e, t) {
56427 return {
56428 type: t[0],
56429 left: e,
56430 right: t[1]
56431 };
56432 }, i)) : (ce = e, e = s);
56433 } else ce = e, e = s;
56434
56435 return ye[l] = {
56436 nextPos: ce,
56437 result: e
56438 }, e;
56439 }
56440
56441 function Ce() {
56442 var e,
56443 r,
56444 n,
56445 o,
56446 a,
56447 i,
56448 l,
56449 u = 30 * ce + 6,
56450 c = ye[u];
56451 if (c) return ce = c.nextPos, c.result;
56452
56453 if (e = ce, 33 === t.charCodeAt(ce) ? (r = "!", ce++) : (r = s, ge(x)), r === s && (r = null), r !== s) {
56454 if (n = [], (o = Pe()) !== s) for (; o !== s;) n.push(o), o = Pe();else n = s;
56455 n !== s ? (a = r, l = 1 === (i = n).length ? i[0] : {
56456 type: "compound",
56457 selectors: i
56458 }, a && (l.subject = !0), e = r = l) : (ce = e, e = s);
56459 } else ce = e, e = s;
56460
56461 return ye[u] = {
56462 nextPos: ce,
56463 result: e
56464 }, e;
56465 }
56466
56467 function Pe() {
56468 var e,
56469 r = 30 * ce + 7,
56470 n = ye[r];
56471 return n ? (ce = n.nextPos, n.result) : ((e = function () {
56472 var e,
56473 r,
56474 n = 30 * ce + 8,
56475 o = ye[n];
56476 return o ? (ce = o.nextPos, o.result) : (42 === t.charCodeAt(ce) ? (r = "*", ce++) : (r = s, ge(v)), r !== s && (r = {
56477 type: "wildcard",
56478 value: r
56479 }), e = r, ye[n] = {
56480 nextPos: ce,
56481 result: e
56482 }, e);
56483 }()) === s && (e = function () {
56484 var e,
56485 r,
56486 n,
56487 o = 30 * ce + 9,
56488 a = ye[o];
56489 return a ? (ce = a.nextPos, a.result) : (e = ce, 35 === t.charCodeAt(ce) ? (r = "#", ce++) : (r = s, ge(g)), r === s && (r = null), r !== s && (n = Ee()) !== s ? e = r = {
56490 type: "identifier",
56491 value: n
56492 } : (ce = e, e = s), ye[o] = {
56493 nextPos: ce,
56494 result: e
56495 }, e);
56496 }()) === s && (e = function () {
56497 var e,
56498 r,
56499 n,
56500 o,
56501 a = 30 * ce + 10,
56502 i = ye[a];
56503 return i ? (ce = i.nextPos, i.result) : (e = ce, 91 === t.charCodeAt(ce) ? (r = "[", ce++) : (r = s, ge(b)), r !== s && Ae() !== s && (n = function () {
56504 var e,
56505 r,
56506 n,
56507 o,
56508 a = 30 * ce + 14,
56509 i = ye[a];
56510 return i ? (ce = i.nextPos, i.result) : (e = ce, (r = ke()) !== s && Ae() !== s && (n = function () {
56511 var e,
56512 r,
56513 n,
56514 o = 30 * ce + 12,
56515 a = ye[o];
56516 return a ? (ce = a.nextPos, a.result) : (e = ce, 33 === t.charCodeAt(ce) ? (r = "!", ce++) : (r = s, ge(x)), r === s && (r = null), r !== s ? (61 === t.charCodeAt(ce) ? (n = "=", ce++) : (n = s, ge(_)), n !== s ? (r = w(r), e = r) : (ce = e, e = s)) : (ce = e, e = s), ye[o] = {
56517 nextPos: ce,
56518 result: e
56519 }, e);
56520 }()) !== s && Ae() !== s ? ((o = function () {
56521 var e,
56522 r,
56523 n,
56524 o,
56525 a,
56526 i = 30 * ce + 18,
56527 l = ye[i];
56528 if (l) return ce = l.nextPos, l.result;
56529 if (e = ce, "type(" === t.substr(ce, 5) ? (r = "type(", ce += 5) : (r = s, ge(N)), r !== s) {
56530 if (Ae() !== s) {
56531 if (n = [], W.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(K)), o !== s) for (; o !== s;) n.push(o), W.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(K));else n = s;
56532 n !== s && (o = Ae()) !== s ? (41 === t.charCodeAt(ce) ? (a = ")", ce++) : (a = s, ge(G)), a !== s ? (r = {
56533 type: "type",
56534 value: n.join("")
56535 }, e = r) : (ce = e, e = s)) : (ce = e, e = s);
56536 } else ce = e, e = s;
56537 } else ce = e, e = s;
56538 return ye[i] = {
56539 nextPos: ce,
56540 result: e
56541 }, e;
56542 }()) === s && (o = function () {
56543 var e,
56544 r,
56545 n,
56546 o,
56547 a,
56548 i,
56549 l = 30 * ce + 20,
56550 u = ye[l];
56551 if (u) return ce = u.nextPos, u.result;
56552
56553 if (e = ce, 47 === t.charCodeAt(ce) ? (r = "/", ce++) : (r = s, ge(Y)), r !== s) {
56554 if (n = [], $.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(J)), o !== s) for (; o !== s;) n.push(o), $.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(J));else n = s;
56555 n !== s ? (47 === t.charCodeAt(ce) ? (o = "/", ce++) : (o = s, ge(Y)), o !== s ? ((a = function () {
56556 var e,
56557 r,
56558 n = 30 * ce + 19,
56559 o = ye[n];
56560 if (o) return ce = o.nextPos, o.result;
56561 if (e = [], z.test(t.charAt(ce)) ? (r = t.charAt(ce), ce++) : (r = s, ge(H)), r !== s) for (; r !== s;) e.push(r), z.test(t.charAt(ce)) ? (r = t.charAt(ce), ce++) : (r = s, ge(H));else e = s;
56562 return ye[n] = {
56563 nextPos: ce,
56564 result: e
56565 }, e;
56566 }()) === s && (a = null), a !== s ? (i = a, r = {
56567 type: "regexp",
56568 value: new RegExp(n.join(""), i ? i.join("") : "")
56569 }, e = r) : (ce = e, e = s)) : (ce = e, e = s)) : (ce = e, e = s);
56570 } else ce = e, e = s;
56571
56572 return ye[l] = {
56573 nextPos: ce,
56574 result: e
56575 }, e;
56576 }()), o !== s ? (r = D(r, n, o), e = r) : (ce = e, e = s)) : (ce = e, e = s), e === s && (e = ce, (r = ke()) !== s && Ae() !== s && (n = function () {
56577 var e,
56578 r,
56579 n,
56580 o = 30 * ce + 11,
56581 a = ye[o];
56582 return a ? (ce = a.nextPos, a.result) : (e = ce, E.test(t.charAt(ce)) ? (r = t.charAt(ce), ce++) : (r = s, ge(S)), r === s && (r = null), r !== s ? (61 === t.charCodeAt(ce) ? (n = "=", ce++) : (n = s, ge(_)), n !== s ? (r = w(r), e = r) : (ce = e, e = s)) : (ce = e, e = s), e === s && (C.test(t.charAt(ce)) ? (e = t.charAt(ce), ce++) : (e = s, ge(P))), ye[o] = {
56583 nextPos: ce,
56584 result: e
56585 }, e);
56586 }()) !== s && Ae() !== s ? ((o = function () {
56587 var e,
56588 r,
56589 n,
56590 o,
56591 a,
56592 i,
56593 l = 30 * ce + 15,
56594 u = ye[l];
56595 if (u) return ce = u.nextPos, u.result;
56596
56597 if (e = ce, 34 === t.charCodeAt(ce) ? (r = '"', ce++) : (r = s, ge(j)), r !== s) {
56598 for (n = [], I.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(T)), o === s && (o = ce, 92 === t.charCodeAt(ce) ? (a = "\\", ce++) : (a = s, ge(F)), a !== s ? (t.length > ce ? (i = t.charAt(ce), ce++) : (i = s, ge(L)), i !== s ? (a = O(a, i), o = a) : (ce = o, o = s)) : (ce = o, o = s)); o !== s;) n.push(o), I.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(T)), o === s && (o = ce, 92 === t.charCodeAt(ce) ? (a = "\\", ce++) : (a = s, ge(F)), a !== s ? (t.length > ce ? (i = t.charAt(ce), ce++) : (i = s, ge(L)), i !== s ? (a = O(a, i), o = a) : (ce = o, o = s)) : (ce = o, o = s));
56599
56600 n !== s ? (34 === t.charCodeAt(ce) ? (o = '"', ce++) : (o = s, ge(j)), o !== s ? (r = R(n), e = r) : (ce = e, e = s)) : (ce = e, e = s);
56601 } else ce = e, e = s;
56602
56603 if (e === s) if (e = ce, 39 === t.charCodeAt(ce) ? (r = "'", ce++) : (r = s, ge(B)), r !== s) {
56604 for (n = [], M.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(U)), o === s && (o = ce, 92 === t.charCodeAt(ce) ? (a = "\\", ce++) : (a = s, ge(F)), a !== s ? (t.length > ce ? (i = t.charAt(ce), ce++) : (i = s, ge(L)), i !== s ? (a = O(a, i), o = a) : (ce = o, o = s)) : (ce = o, o = s)); o !== s;) n.push(o), M.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(U)), o === s && (o = ce, 92 === t.charCodeAt(ce) ? (a = "\\", ce++) : (a = s, ge(F)), a !== s ? (t.length > ce ? (i = t.charAt(ce), ce++) : (i = s, ge(L)), i !== s ? (a = O(a, i), o = a) : (ce = o, o = s)) : (ce = o, o = s));
56605
56606 n !== s ? (39 === t.charCodeAt(ce) ? (o = "'", ce++) : (o = s, ge(B)), o !== s ? (r = R(n), e = r) : (ce = e, e = s)) : (ce = e, e = s);
56607 } else ce = e, e = s;
56608 return ye[l] = {
56609 nextPos: ce,
56610 result: e
56611 }, e;
56612 }()) === s && (o = function () {
56613 var e,
56614 r,
56615 n,
56616 o,
56617 a,
56618 i,
56619 l,
56620 u = 30 * ce + 16,
56621 c = ye[u];
56622 if (c) return ce = c.nextPos, c.result;
56623
56624 for (e = ce, r = ce, n = [], q.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(V)); o !== s;) n.push(o), q.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(V));
56625
56626 if (n !== s ? (46 === t.charCodeAt(ce) ? (o = ".", ce++) : (o = s, ge(k)), o !== s ? r = n = [n, o] : (ce = r, r = s)) : (ce = r, r = s), r === s && (r = null), r !== s) {
56627 if (n = [], q.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(V)), o !== s) for (; o !== s;) n.push(o), q.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(V));else n = s;
56628 n !== s ? (i = n, l = (a = r) ? [].concat.apply([], a).join("") : "", r = {
56629 type: "literal",
56630 value: parseFloat(l + i.join(""))
56631 }, e = r) : (ce = e, e = s);
56632 } else ce = e, e = s;
56633
56634 return ye[u] = {
56635 nextPos: ce,
56636 result: e
56637 }, e;
56638 }()) === s && (o = function () {
56639 var e,
56640 t,
56641 r = 30 * ce + 17,
56642 n = ye[r];
56643 return n ? (ce = n.nextPos, n.result) : ((t = Ee()) !== s && (t = {
56644 type: "literal",
56645 value: t
56646 }), e = t, ye[r] = {
56647 nextPos: ce,
56648 result: e
56649 }, e);
56650 }()), o !== s ? (r = D(r, n, o), e = r) : (ce = e, e = s)) : (ce = e, e = s), e === s && (e = ce, (r = ke()) !== s && (r = {
56651 type: "attribute",
56652 name: r
56653 }), e = r)), ye[a] = {
56654 nextPos: ce,
56655 result: e
56656 }, e);
56657 }()) !== s && Ae() !== s ? (93 === t.charCodeAt(ce) ? (o = "]", ce++) : (o = s, ge(A)), o !== s ? e = r = n : (ce = e, e = s)) : (ce = e, e = s), ye[a] = {
56658 nextPos: ce,
56659 result: e
56660 }, e);
56661 }()) === s && (e = function () {
56662 var e,
56663 r,
56664 n,
56665 o,
56666 a,
56667 i,
56668 l,
56669 u,
56670 c = 30 * ce + 21,
56671 f = ye[c];
56672 if (f) return ce = f.nextPos, f.result;
56673 if (e = ce, 46 === t.charCodeAt(ce) ? (r = ".", ce++) : (r = s, ge(k)), r !== s) {
56674 if ((n = Ee()) !== s) {
56675 for (o = [], a = ce, 46 === t.charCodeAt(ce) ? (i = ".", ce++) : (i = s, ge(k)), i !== s && (l = Ee()) !== s ? a = i = [i, l] : (ce = a, a = s); a !== s;) o.push(a), a = ce, 46 === t.charCodeAt(ce) ? (i = ".", ce++) : (i = s, ge(k)), i !== s && (l = Ee()) !== s ? a = i = [i, l] : (ce = a, a = s);
56676
56677 o !== s ? (u = n, r = {
56678 type: "field",
56679 name: o.reduce(function (e, t) {
56680 return e + t[0] + t[1];
56681 }, u)
56682 }, e = r) : (ce = e, e = s);
56683 } else ce = e, e = s;
56684 } else ce = e, e = s;
56685 return ye[c] = {
56686 nextPos: ce,
56687 result: e
56688 }, e;
56689 }()) === s && (e = function () {
56690 var e,
56691 r,
56692 n,
56693 o,
56694 a = 30 * ce + 22,
56695 i = ye[a];
56696 return i ? (ce = i.nextPos, i.result) : (e = ce, ":not(" === t.substr(ce, 5) ? (r = ":not(", ce += 5) : (r = s, ge(Q)), r !== s && Ae() !== s && (n = _e()) !== s && Ae() !== s ? (41 === t.charCodeAt(ce) ? (o = ")", ce++) : (o = s, ge(G)), o !== s ? e = r = {
56697 type: "not",
56698 selectors: n
56699 } : (ce = e, e = s)) : (ce = e, e = s), ye[a] = {
56700 nextPos: ce,
56701 result: e
56702 }, e);
56703 }()) === s && (e = function () {
56704 var e,
56705 r,
56706 n,
56707 o,
56708 a = 30 * ce + 23,
56709 i = ye[a];
56710 return i ? (ce = i.nextPos, i.result) : (e = ce, ":matches(" === t.substr(ce, 9) ? (r = ":matches(", ce += 9) : (r = s, ge(X)), r !== s && Ae() !== s && (n = _e()) !== s && Ae() !== s ? (41 === t.charCodeAt(ce) ? (o = ")", ce++) : (o = s, ge(G)), o !== s ? e = r = {
56711 type: "matches",
56712 selectors: n
56713 } : (ce = e, e = s)) : (ce = e, e = s), ye[a] = {
56714 nextPos: ce,
56715 result: e
56716 }, e);
56717 }()) === s && (e = function () {
56718 var e,
56719 r,
56720 n,
56721 o,
56722 a = 30 * ce + 24,
56723 i = ye[a];
56724 return i ? (ce = i.nextPos, i.result) : (e = ce, ":has(" === t.substr(ce, 5) ? (r = ":has(", ce += 5) : (r = s, ge(Z)), r !== s && Ae() !== s && (n = _e()) !== s && Ae() !== s ? (41 === t.charCodeAt(ce) ? (o = ")", ce++) : (o = s, ge(G)), o !== s ? e = r = {
56725 type: "has",
56726 selectors: n
56727 } : (ce = e, e = s)) : (ce = e, e = s), ye[a] = {
56728 nextPos: ce,
56729 result: e
56730 }, e);
56731 }()) === s && (e = function () {
56732 var e,
56733 r,
56734 n = 30 * ce + 25,
56735 o = ye[n];
56736 return o ? (ce = o.nextPos, o.result) : (":first-child" === t.substr(ce, 12) ? (r = ":first-child", ce += 12) : (r = s, ge(ee)), r !== s && (r = De(1)), e = r, ye[n] = {
56737 nextPos: ce,
56738 result: e
56739 }, e);
56740 }()) === s && (e = function () {
56741 var e,
56742 r,
56743 n = 30 * ce + 26,
56744 o = ye[n];
56745 return o ? (ce = o.nextPos, o.result) : (":last-child" === t.substr(ce, 11) ? (r = ":last-child", ce += 11) : (r = s, ge(te)), r !== s && (r = je(1)), e = r, ye[n] = {
56746 nextPos: ce,
56747 result: e
56748 }, e);
56749 }()) === s && (e = function () {
56750 var e,
56751 r,
56752 n,
56753 o,
56754 a,
56755 i = 30 * ce + 27,
56756 l = ye[i];
56757 if (l) return ce = l.nextPos, l.result;
56758 if (e = ce, ":nth-child(" === t.substr(ce, 11) ? (r = ":nth-child(", ce += 11) : (r = s, ge(re)), r !== s) {
56759 if (Ae() !== s) {
56760 if (n = [], q.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(V)), o !== s) for (; o !== s;) n.push(o), q.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(V));else n = s;
56761 n !== s && (o = Ae()) !== s ? (41 === t.charCodeAt(ce) ? (a = ")", ce++) : (a = s, ge(G)), a !== s ? (r = De(parseInt(n.join(""), 10)), e = r) : (ce = e, e = s)) : (ce = e, e = s);
56762 } else ce = e, e = s;
56763 } else ce = e, e = s;
56764 return ye[i] = {
56765 nextPos: ce,
56766 result: e
56767 }, e;
56768 }()) === s && (e = function () {
56769 var e,
56770 r,
56771 n,
56772 o,
56773 a,
56774 i = 30 * ce + 28,
56775 l = ye[i];
56776 if (l) return ce = l.nextPos, l.result;
56777 if (e = ce, ":nth-last-child(" === t.substr(ce, 16) ? (r = ":nth-last-child(", ce += 16) : (r = s, ge(ne)), r !== s) {
56778 if (Ae() !== s) {
56779 if (n = [], q.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(V)), o !== s) for (; o !== s;) n.push(o), q.test(t.charAt(ce)) ? (o = t.charAt(ce), ce++) : (o = s, ge(V));else n = s;
56780 n !== s && (o = Ae()) !== s ? (41 === t.charCodeAt(ce) ? (a = ")", ce++) : (a = s, ge(G)), a !== s ? (r = je(parseInt(n.join(""), 10)), e = r) : (ce = e, e = s)) : (ce = e, e = s);
56781 } else ce = e, e = s;
56782 } else ce = e, e = s;
56783 return ye[i] = {
56784 nextPos: ce,
56785 result: e
56786 }, e;
56787 }()) === s && (e = function () {
56788 var e,
56789 r,
56790 n,
56791 o = 30 * ce + 29,
56792 a = ye[o];
56793 return a ? (ce = a.nextPos, a.result) : (e = ce, 58 === t.charCodeAt(ce) ? (r = ":", ce++) : (r = s, ge(oe)), r !== s ? ("statement" === t.substr(ce, 9).toLowerCase() ? (n = t.substr(ce, 9), ce += 9) : (n = s, ge(ae)), n === s && ("expression" === t.substr(ce, 10).toLowerCase() ? (n = t.substr(ce, 10), ce += 10) : (n = s, ge(ie)), n === s && ("declaration" === t.substr(ce, 11).toLowerCase() ? (n = t.substr(ce, 11), ce += 11) : (n = s, ge(se)), n === s && ("function" === t.substr(ce, 8).toLowerCase() ? (n = t.substr(ce, 8), ce += 8) : (n = s, ge(le)), n === s && ("pattern" === t.substr(ce, 7).toLowerCase() ? (n = t.substr(ce, 7), ce += 7) : (n = s, ge(ue)))))), n !== s ? e = r = {
56794 type: "class",
56795 name: n
56796 } : (ce = e, e = s)) : (ce = e, e = s), ye[o] = {
56797 nextPos: ce,
56798 result: e
56799 }, e);
56800 }()), ye[r] = {
56801 nextPos: ce,
56802 result: e
56803 }, e);
56804 }
56805
56806 function ke() {
56807 var e,
56808 r,
56809 n,
56810 o,
56811 a,
56812 i,
56813 l,
56814 u,
56815 c = 30 * ce + 13,
56816 f = ye[c];
56817 if (f) return ce = f.nextPos, f.result;
56818
56819 if (e = ce, (r = Ee()) !== s) {
56820 for (n = [], o = ce, 46 === t.charCodeAt(ce) ? (a = ".", ce++) : (a = s, ge(k)), a !== s && (i = Ee()) !== s ? o = a = [a, i] : (ce = o, o = s); o !== s;) n.push(o), o = ce, 46 === t.charCodeAt(ce) ? (a = ".", ce++) : (a = s, ge(k)), a !== s && (i = Ee()) !== s ? o = a = [a, i] : (ce = o, o = s);
56821
56822 n !== s ? (l = r, u = n, e = r = [].concat.apply([l], u).join("")) : (ce = e, e = s);
56823 } else ce = e, e = s;
56824
56825 return ye[c] = {
56826 nextPos: ce,
56827 result: e
56828 }, e;
56829 }
56830
56831 function De(e) {
56832 return {
56833 type: "nth-child",
56834 index: {
56835 type: "literal",
56836 value: e
56837 }
56838 };
56839 }
56840
56841 function je(e) {
56842 return {
56843 type: "nth-last-child",
56844 index: {
56845 type: "literal",
56846 value: e
56847 }
56848 };
56849 }
56850
56851 if ((n = u()) !== s && ce === t.length) return n;
56852 throw n !== s && ce < t.length && ge({
56853 type: "end"
56854 }), o = he, a = pe < t.length ? t.charAt(pe) : null, i = pe < t.length ? ve(pe, pe + 1) : ve(pe, pe), new e(e.buildMessage(o, a), o, a, i);
56855 }
56856 };
56857 }());
56858 });
56859
56860 function u(t, r, n, o) {
56861 if (!r) return !0;
56862 if (!t) return !1;
56863
56864 switch (n || (n = []), r.type) {
56865 case "wildcard":
56866 return !0;
56867
56868 case "identifier":
56869 return r.value.toLowerCase() === t.type.toLowerCase();
56870
56871 case "field":
56872 var i = r.name.split("."),
56873 l = n[i.length - 1];
56874 return function e(t, r, n) {
56875 if (0 === n.length) return t === r;
56876 if (null == r) return !1;
56877 var o = r[n[0]],
56878 i = n.slice(1);
56879
56880 if (Array.isArray(o)) {
56881 var s,
56882 l = a(o);
56883
56884 try {
56885 for (l.s(); !(s = l.n()).done;) {
56886 if (e(t, s.value, i)) return !0;
56887 }
56888 } catch (e) {
56889 l.e(e);
56890 } finally {
56891 l.f();
56892 }
56893
56894 return !1;
56895 }
56896
56897 return e(t, o, i);
56898 }(t, l, i);
56899
56900 case "matches":
56901 var c,
56902 f = a(r.selectors);
56903
56904 try {
56905 for (f.s(); !(c = f.n()).done;) {
56906 var d = c.value;
56907 if (u(t, d, n, o)) return !0;
56908 }
56909 } catch (e) {
56910 f.e(e);
56911 } finally {
56912 f.f();
56913 }
56914
56915 return !1;
56916
56917 case "compound":
56918 var m,
56919 x = a(r.selectors);
56920
56921 try {
56922 for (x.s(); !(m = x.n()).done;) {
56923 var v = m.value;
56924 if (!u(t, v, n, o)) return !1;
56925 }
56926 } catch (e) {
56927 x.e(e);
56928 } finally {
56929 x.f();
56930 }
56931
56932 return !0;
56933
56934 case "not":
56935 var g,
56936 b = a(r.selectors);
56937
56938 try {
56939 for (b.s(); !(g = b.n()).done;) {
56940 var A = g.value;
56941 if (u(t, A, n, o)) return !1;
56942 }
56943 } catch (e) {
56944 b.e(e);
56945 } finally {
56946 b.f();
56947 }
56948
56949 return !0;
56950
56951 case "has":
56952 var E = function () {
56953 var e,
56954 n = [],
56955 i = a(r.selectors);
56956
56957 try {
56958 var l = function () {
56959 var r = e.value,
56960 a = [];
56961 s.traverse(t, {
56962 enter: function (e, t) {
56963 null != t && a.unshift(t), u(e, r, a, o) && n.push(e);
56964 },
56965 leave: function () {
56966 a.shift();
56967 },
56968 keys: o && o.visitorKeys,
56969 fallback: o && o.fallback || "iteration"
56970 });
56971 };
56972
56973 for (i.s(); !(e = i.n()).done;) l();
56974 } catch (e) {
56975 i.e(e);
56976 } finally {
56977 i.f();
56978 }
56979
56980 return {
56981 v: 0 !== n.length
56982 };
56983 }();
56984
56985 if ("object" === e(E)) return E.v;
56986
56987 case "child":
56988 return !!u(t, r.right, n, o) && u(n[0], r.left, n.slice(1), o);
56989
56990 case "descendant":
56991 if (u(t, r.right, n, o)) for (var S = 0, _ = n.length; S < _; ++S) if (u(n[S], r.left, n.slice(S + 1), o)) return !0;
56992 return !1;
56993
56994 case "attribute":
56995 var w = function (e, t) {
56996 var r,
56997 n = a(t.split("."));
56998
56999 try {
57000 for (n.s(); !(r = n.n()).done;) {
57001 var o = r.value;
57002 if (null == e) return e;
57003 e = e[o];
57004 }
57005 } catch (e) {
57006 n.e(e);
57007 } finally {
57008 n.f();
57009 }
57010
57011 return e;
57012 }(t, r.name);
57013
57014 switch (r.operator) {
57015 case void 0:
57016 return null != w;
57017
57018 case "=":
57019 switch (r.value.type) {
57020 case "regexp":
57021 return "string" == typeof w && r.value.value.test(w);
57022
57023 case "literal":
57024 return "".concat(r.value.value) === "".concat(w);
57025
57026 case "type":
57027 return r.value.value === e(w);
57028 }
57029
57030 throw new Error("Unknown selector value type: ".concat(r.value.type));
57031
57032 case "!=":
57033 switch (r.value.type) {
57034 case "regexp":
57035 return !r.value.value.test(w);
57036
57037 case "literal":
57038 return "".concat(r.value.value) !== "".concat(w);
57039
57040 case "type":
57041 return r.value.value !== e(w);
57042 }
57043
57044 throw new Error("Unknown selector value type: ".concat(r.value.type));
57045
57046 case "<=":
57047 return w <= r.value.value;
57048
57049 case "<":
57050 return w < r.value.value;
57051
57052 case ">":
57053 return w > r.value.value;
57054
57055 case ">=":
57056 return w >= r.value.value;
57057 }
57058
57059 throw new Error("Unknown operator: ".concat(r.operator));
57060
57061 case "sibling":
57062 return u(t, r.right, n, o) && p(t, r.left, n, "LEFT_SIDE", o) || r.left.subject && u(t, r.left, n, o) && p(t, r.right, n, "RIGHT_SIDE", o);
57063
57064 case "adjacent":
57065 return u(t, r.right, n, o) && h(t, r.left, n, "LEFT_SIDE", o) || r.right.subject && u(t, r.left, n, o) && h(t, r.right, n, "RIGHT_SIDE", o);
57066
57067 case "nth-child":
57068 return u(t, r.right, n, o) && y(t, n, function () {
57069 return r.index.value - 1;
57070 }, o);
57071
57072 case "nth-last-child":
57073 return u(t, r.right, n, o) && y(t, n, function (e) {
57074 return e - r.index.value;
57075 }, o);
57076
57077 case "class":
57078 switch (r.name.toLowerCase()) {
57079 case "statement":
57080 if ("Statement" === t.type.slice(-9)) return !0;
57081
57082 case "declaration":
57083 return "Declaration" === t.type.slice(-11);
57084
57085 case "pattern":
57086 if ("Pattern" === t.type.slice(-7)) return !0;
57087
57088 case "expression":
57089 return "Expression" === t.type.slice(-10) || "Literal" === t.type.slice(-7) || "Identifier" === t.type && (0 === n.length || "MetaProperty" !== n[0].type) || "MetaProperty" === t.type;
57090
57091 case "function":
57092 return "FunctionDeclaration" === t.type || "FunctionExpression" === t.type || "ArrowFunctionExpression" === t.type;
57093 }
57094
57095 throw new Error("Unknown class name: ".concat(r.name));
57096 }
57097
57098 throw new Error("Unknown selector type: ".concat(r.type));
57099 }
57100
57101 function c(e, t) {
57102 var r = e.type;
57103 return t && t.visitorKeys && t.visitorKeys[r] ? t.visitorKeys[r] : s.VisitorKeys[r] ? s.VisitorKeys[r] : t && "function" == typeof t.fallback ? t.fallback(e) : Object.keys(e).filter(function (e) {
57104 return "type" !== e;
57105 });
57106 }
57107
57108 function f(t) {
57109 return null !== t && "object" === e(t) && "string" == typeof t.type;
57110 }
57111
57112 function p(e, r, n, o, i) {
57113 var s = t(n, 1)[0];
57114 if (!s) return !1;
57115 var l,
57116 p = a(c(s, i));
57117
57118 try {
57119 for (p.s(); !(l = p.n()).done;) {
57120 var h = s[l.value];
57121
57122 if (Array.isArray(h)) {
57123 var y = h.indexOf(e);
57124 if (y < 0) continue;
57125 var d = void 0,
57126 m = void 0;
57127 "LEFT_SIDE" === o ? (d = 0, m = y) : (d = y + 1, m = h.length);
57128
57129 for (var x = d; x < m; ++x) if (f(h[x]) && u(h[x], r, n, i)) return !0;
57130 }
57131 }
57132 } catch (e) {
57133 p.e(e);
57134 } finally {
57135 p.f();
57136 }
57137
57138 return !1;
57139 }
57140
57141 function h(e, r, n, o, i) {
57142 var s = t(n, 1)[0];
57143 if (!s) return !1;
57144 var l,
57145 p = a(c(s, i));
57146
57147 try {
57148 for (p.s(); !(l = p.n()).done;) {
57149 var h = s[l.value];
57150
57151 if (Array.isArray(h)) {
57152 var y = h.indexOf(e);
57153 if (y < 0) continue;
57154 if ("LEFT_SIDE" === o && y > 0 && f(h[y - 1]) && u(h[y - 1], r, n, i)) return !0;
57155 if ("RIGHT_SIDE" === o && y < h.length - 1 && f(h[y + 1]) && u(h[y + 1], r, n, i)) return !0;
57156 }
57157 }
57158 } catch (e) {
57159 p.e(e);
57160 } finally {
57161 p.f();
57162 }
57163
57164 return !1;
57165 }
57166
57167 function y(e, r, n, o) {
57168 var i = t(r, 1)[0];
57169 if (!i) return !1;
57170 var s,
57171 l = a(c(i, o));
57172
57173 try {
57174 for (l.s(); !(s = l.n()).done;) {
57175 var u = i[s.value];
57176
57177 if (Array.isArray(u)) {
57178 var f = u.indexOf(e);
57179 if (f >= 0 && f === n(u.length)) return !0;
57180 }
57181 }
57182 } catch (e) {
57183 l.e(e);
57184 } finally {
57185 l.f();
57186 }
57187
57188 return !1;
57189 }
57190
57191 function d(n, o) {
57192 if (null == n || "object" != e(n)) return [];
57193 null == o && (o = n);
57194
57195 for (var a = n.subject ? [o] : [], i = 0, s = function (e) {
57196 for (var t = [], r = Object.keys(e), n = 0; n < r.length; n++) t.push([r[n], e[r[n]]]);
57197
57198 return t;
57199 }(n); i < s.length; i++) {
57200 var l = t(s[i], 2),
57201 u = l[0],
57202 c = l[1];
57203 a.push.apply(a, r(d(c, "left" === u ? c : o)));
57204 }
57205
57206 return a;
57207 }
57208
57209 function m(e, t, r, n) {
57210 if (t) {
57211 var o = [],
57212 a = d(t);
57213 s.traverse(e, {
57214 enter: function (e, i) {
57215 if (null != i && o.unshift(i), u(e, t, o, n)) if (a.length) for (var s = 0, l = a.length; s < l; ++s) {
57216 u(e, a[s], o, n) && r(e, i, o);
57217
57218 for (var c = 0, f = o.length; c < f; ++c) {
57219 var p = o.slice(c + 1);
57220 u(o[c], a[s], p, n) && r(o[c], i, p);
57221 }
57222 } else r(e, i, o);
57223 },
57224 leave: function () {
57225 o.shift();
57226 },
57227 keys: n && n.visitorKeys,
57228 fallback: n && n.fallback || "iteration"
57229 });
57230 }
57231 }
57232
57233 function x(e, t, r) {
57234 var n = [];
57235 return m(e, t, function (e) {
57236 n.push(e);
57237 }, r), n;
57238 }
57239
57240 function v(e) {
57241 return l.parse(e);
57242 }
57243
57244 function g(e, t, r) {
57245 return x(e, v(t), r);
57246 }
57247
57248 return g.parse = v, g.match = x, g.traverse = m, g.matches = u, g.query = g, g;
57249 });
57250
57251 /***/ }),
57252 /* 541 */
57253 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
57254
57255 "use strict";
57256 /**
57257 * @fileoverview A helper that translates context.report() calls from the rule API into generic problem objects
57258 * @author Teddy Katz
57259 */
57260 //------------------------------------------------------------------------------
57261 // Requirements
57262 //------------------------------------------------------------------------------
57263
57264 const assert = __webpack_require__(431);
57265
57266 const ruleFixer = __webpack_require__(542);
57267
57268 const interpolate = __webpack_require__(543); //------------------------------------------------------------------------------
57269 // Typedefs
57270 //------------------------------------------------------------------------------
57271
57272 /**
57273 * An error message description
57274 * @typedef {Object} MessageDescriptor
57275 * @property {ASTNode} [node] The reported node
57276 * @property {Location} loc The location of the problem.
57277 * @property {string} message The problem message.
57278 * @property {Object} [data] Optional data to use to fill in placeholders in the
57279 * message.
57280 * @property {Function} [fix] The function to call that creates a fix command.
57281 * @property {Array<{desc?: string, messageId?: string, fix: Function}>} suggest Suggestion descriptions and functions to create a the associated fixes.
57282 */
57283
57284 /**
57285 * Information about the report
57286 * @typedef {Object} ReportInfo
57287 * @property {string} ruleId The rule ID
57288 * @property {(0|1|2)} severity Severity of the error
57289 * @property {(string|undefined)} message The message
57290 * @property {(string|undefined)} [messageId] The message ID
57291 * @property {number} line The line number
57292 * @property {number} column The column number
57293 * @property {(number|undefined)} [endLine] The ending line number
57294 * @property {(number|undefined)} [endColumn] The ending column number
57295 * @property {(string|null)} nodeType Type of node
57296 * @property {string} source Source text
57297 * @property {({text: string, range: (number[]|null)}|null)} [fix] The fix object
57298 * @property {Array<{text: string, range: (number[]|null)}|null>} [suggestions] Suggestion info
57299 */
57300 //------------------------------------------------------------------------------
57301 // Module Definition
57302 //------------------------------------------------------------------------------
57303
57304 /**
57305 * Translates a multi-argument context.report() call into a single object argument call
57306 * @param {...*} args A list of arguments passed to `context.report`
57307 * @returns {MessageDescriptor} A normalized object containing report information
57308 */
57309
57310
57311 function normalizeMultiArgReportCall() {
57312 // If there is one argument, it is considered to be a new-style call already.
57313 if (arguments.length === 1) {
57314 // Shallow clone the object to avoid surprises if reusing the descriptor
57315 return Object.assign({}, arguments.length <= 0 ? undefined : arguments[0]);
57316 } // If the second argument is a string, the arguments are interpreted as [node, message, data, fix].
57317
57318
57319 if (typeof (arguments.length <= 1 ? undefined : arguments[1]) === "string") {
57320 return {
57321 node: arguments.length <= 0 ? undefined : arguments[0],
57322 message: arguments.length <= 1 ? undefined : arguments[1],
57323 data: arguments.length <= 2 ? undefined : arguments[2],
57324 fix: arguments.length <= 3 ? undefined : arguments[3]
57325 };
57326 } // Otherwise, the arguments are interpreted as [node, loc, message, data, fix].
57327
57328
57329 return {
57330 node: arguments.length <= 0 ? undefined : arguments[0],
57331 loc: arguments.length <= 1 ? undefined : arguments[1],
57332 message: arguments.length <= 2 ? undefined : arguments[2],
57333 data: arguments.length <= 3 ? undefined : arguments[3],
57334 fix: arguments.length <= 4 ? undefined : arguments[4]
57335 };
57336 }
57337 /**
57338 * Asserts that either a loc or a node was provided, and the node is valid if it was provided.
57339 * @param {MessageDescriptor} descriptor A descriptor to validate
57340 * @returns {void}
57341 * @throws AssertionError if neither a node nor a loc was provided, or if the node is not an object
57342 */
57343
57344
57345 function assertValidNodeInfo(descriptor) {
57346 if (descriptor.node) {
57347 assert(typeof descriptor.node === "object", "Node must be an object");
57348 } else {
57349 assert(descriptor.loc, "Node must be provided when reporting error if location is not provided");
57350 }
57351 }
57352 /**
57353 * Normalizes a MessageDescriptor to always have a `loc` with `start` and `end` properties
57354 * @param {MessageDescriptor} descriptor A descriptor for the report from a rule.
57355 * @returns {{start: Location, end: (Location|null)}} An updated location that infers the `start` and `end` properties
57356 * from the `node` of the original descriptor, or infers the `start` from the `loc` of the original descriptor.
57357 */
57358
57359
57360 function normalizeReportLoc(descriptor) {
57361 if (descriptor.loc) {
57362 if (descriptor.loc.start) {
57363 return descriptor.loc;
57364 }
57365
57366 return {
57367 start: descriptor.loc,
57368 end: null
57369 };
57370 }
57371
57372 return descriptor.node.loc;
57373 }
57374 /**
57375 * Check that a fix has a valid range.
57376 * @param {Fix|null} fix The fix to validate.
57377 * @returns {void}
57378 */
57379
57380
57381 function assertValidFix(fix) {
57382 if (fix) {
57383 assert(fix.range && typeof fix.range[0] === "number" && typeof fix.range[1] === "number", "Fix has invalid range: ".concat(JSON.stringify(fix, null, 2)));
57384 }
57385 }
57386 /**
57387 * Compares items in a fixes array by range.
57388 * @param {Fix} a The first message.
57389 * @param {Fix} b The second message.
57390 * @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
57391 * @private
57392 */
57393
57394
57395 function compareFixesByRange(a, b) {
57396 return a.range[0] - b.range[0] || a.range[1] - b.range[1];
57397 }
57398 /**
57399 * Merges the given fixes array into one.
57400 * @param {Fix[]} fixes The fixes to merge.
57401 * @param {SourceCode} sourceCode The source code object to get the text between fixes.
57402 * @returns {{text: string, range: number[]}} The merged fixes
57403 */
57404
57405
57406 function mergeFixes(fixes, sourceCode) {
57407 for (const fix of fixes) {
57408 assertValidFix(fix);
57409 }
57410
57411 if (fixes.length === 0) {
57412 return null;
57413 }
57414
57415 if (fixes.length === 1) {
57416 return fixes[0];
57417 }
57418
57419 fixes.sort(compareFixesByRange);
57420 const originalText = sourceCode.text;
57421 const start = fixes[0].range[0];
57422 const end = fixes[fixes.length - 1].range[1];
57423 let text = "";
57424 let lastPos = Number.MIN_SAFE_INTEGER;
57425
57426 for (const fix of fixes) {
57427 assert(fix.range[0] >= lastPos, "Fix objects must not be overlapped in a report.");
57428
57429 if (fix.range[0] >= 0) {
57430 text += originalText.slice(Math.max(0, start, lastPos), fix.range[0]);
57431 }
57432
57433 text += fix.text;
57434 lastPos = fix.range[1];
57435 }
57436
57437 text += originalText.slice(Math.max(0, start, lastPos), end);
57438 return {
57439 range: [start, end],
57440 text
57441 };
57442 }
57443 /**
57444 * Gets one fix object from the given descriptor.
57445 * If the descriptor retrieves multiple fixes, this merges those to one.
57446 * @param {MessageDescriptor} descriptor The report descriptor.
57447 * @param {SourceCode} sourceCode The source code object to get text between fixes.
57448 * @returns {({text: string, range: number[]}|null)} The fix for the descriptor
57449 */
57450
57451
57452 function normalizeFixes(descriptor, sourceCode) {
57453 if (typeof descriptor.fix !== "function") {
57454 return null;
57455 } // @type {null | Fix | Fix[] | IterableIterator<Fix>}
57456
57457
57458 const fix = descriptor.fix(ruleFixer); // Merge to one.
57459
57460 if (fix && Symbol.iterator in fix) {
57461 return mergeFixes(Array.from(fix), sourceCode);
57462 }
57463
57464 assertValidFix(fix);
57465 return fix;
57466 }
57467 /**
57468 * Gets an array of suggestion objects from the given descriptor.
57469 * @param {MessageDescriptor} descriptor The report descriptor.
57470 * @param {SourceCode} sourceCode The source code object to get text between fixes.
57471 * @param {Object} messages Object of meta messages for the rule.
57472 * @returns {Array<SuggestionResult>} The suggestions for the descriptor
57473 */
57474
57475
57476 function mapSuggestions(descriptor, sourceCode, messages) {
57477 if (!descriptor.suggest || !Array.isArray(descriptor.suggest)) {
57478 return [];
57479 }
57480
57481 return descriptor.suggest.map(suggestInfo => {
57482 const computedDesc = suggestInfo.desc || messages[suggestInfo.messageId];
57483 return { ...suggestInfo,
57484 desc: interpolate(computedDesc, suggestInfo.data),
57485 fix: normalizeFixes(suggestInfo, sourceCode)
57486 };
57487 }) // Remove suggestions that didn't provide a fix
57488 .filter(_ref => {
57489 let {
57490 fix
57491 } = _ref;
57492 return fix;
57493 });
57494 }
57495 /**
57496 * Creates information about the report from a descriptor
57497 * @param {Object} options Information about the problem
57498 * @param {string} options.ruleId Rule ID
57499 * @param {(0|1|2)} options.severity Rule severity
57500 * @param {(ASTNode|null)} options.node Node
57501 * @param {string} options.message Error message
57502 * @param {string} [options.messageId] The error message ID.
57503 * @param {{start: SourceLocation, end: (SourceLocation|null)}} options.loc Start and end location
57504 * @param {{text: string, range: (number[]|null)}} options.fix The fix object
57505 * @param {Array<{text: string, range: (number[]|null)}>} options.suggestions The array of suggestions objects
57506 * @returns {function(...args): ReportInfo} Function that returns information about the report
57507 */
57508
57509
57510 function createProblem(options) {
57511 const problem = {
57512 ruleId: options.ruleId,
57513 severity: options.severity,
57514 message: options.message,
57515 line: options.loc.start.line,
57516 column: options.loc.start.column + 1,
57517 nodeType: options.node && options.node.type || null
57518 };
57519 /*
57520 * If this isn’t in the conditional, some of the tests fail
57521 * because `messageId` is present in the problem object
57522 */
57523
57524 if (options.messageId) {
57525 problem.messageId = options.messageId;
57526 }
57527
57528 if (options.loc.end) {
57529 problem.endLine = options.loc.end.line;
57530 problem.endColumn = options.loc.end.column + 1;
57531 }
57532
57533 if (options.fix) {
57534 problem.fix = options.fix;
57535 }
57536
57537 if (options.suggestions && options.suggestions.length > 0) {
57538 problem.suggestions = options.suggestions;
57539 }
57540
57541 return problem;
57542 }
57543 /**
57544 * Validates that suggestions are properly defined. Throws if an error is detected.
57545 * @param {Array<{ desc?: string, messageId?: string }>} suggest The incoming suggest data.
57546 * @param {Object} messages Object of meta messages for the rule.
57547 * @returns {void}
57548 */
57549
57550
57551 function validateSuggestions(suggest, messages) {
57552 if (suggest && Array.isArray(suggest)) {
57553 suggest.forEach(suggestion => {
57554 if (suggestion.messageId) {
57555 const {
57556 messageId
57557 } = suggestion;
57558
57559 if (!messages) {
57560 throw new TypeError("context.report() called with a suggest option with a messageId '".concat(messageId, "', but no messages were present in the rule metadata."));
57561 }
57562
57563 if (!messages[messageId]) {
57564 throw new TypeError("context.report() called with a suggest option with a messageId '".concat(messageId, "' which is not present in the 'messages' config: ").concat(JSON.stringify(messages, null, 2)));
57565 }
57566
57567 if (suggestion.desc) {
57568 throw new TypeError("context.report() called with a suggest option that defines both a 'messageId' and an 'desc'. Please only pass one.");
57569 }
57570 } else if (!suggestion.desc) {
57571 throw new TypeError("context.report() called with a suggest option that doesn't have either a `desc` or `messageId`");
57572 }
57573
57574 if (typeof suggestion.fix !== "function") {
57575 throw new TypeError("context.report() called with a suggest option without a fix function. See: ".concat(suggestion));
57576 }
57577 });
57578 }
57579 }
57580 /**
57581 * Returns a function that converts the arguments of a `context.report` call from a rule into a reported
57582 * problem for the Node.js API.
57583 * @param {{ruleId: string, severity: number, sourceCode: SourceCode, messageIds: Object, disableFixes: boolean}} metadata Metadata for the reported problem
57584 * @param {SourceCode} sourceCode The `SourceCode` instance for the text being linted
57585 * @returns {function(...args): ReportInfo} Function that returns information about the report
57586 */
57587
57588
57589 module.exports = function createReportTranslator(metadata) {
57590 /*
57591 * `createReportTranslator` gets called once per enabled rule per file. It needs to be very performant.
57592 * The report translator itself (i.e. the function that `createReportTranslator` returns) gets
57593 * called every time a rule reports a problem, which happens much less frequently (usually, the vast
57594 * majority of rules don't report any problems for a given file).
57595 */
57596 return function () {
57597 const descriptor = normalizeMultiArgReportCall(...arguments);
57598 const messages = metadata.messageIds;
57599 assertValidNodeInfo(descriptor);
57600 let computedMessage;
57601
57602 if (descriptor.messageId) {
57603 if (!messages) {
57604 throw new TypeError("context.report() called with a messageId, but no messages were present in the rule metadata.");
57605 }
57606
57607 const id = descriptor.messageId;
57608
57609 if (descriptor.message) {
57610 throw new TypeError("context.report() called with a message and a messageId. Please only pass one.");
57611 }
57612
57613 if (!messages || !Object.prototype.hasOwnProperty.call(messages, id)) {
57614 throw new TypeError("context.report() called with a messageId of '".concat(id, "' which is not present in the 'messages' config: ").concat(JSON.stringify(messages, null, 2)));
57615 }
57616
57617 computedMessage = messages[id];
57618 } else if (descriptor.message) {
57619 computedMessage = descriptor.message;
57620 } else {
57621 throw new TypeError("Missing `message` property in report() call; add a message that describes the linting problem.");
57622 }
57623
57624 validateSuggestions(descriptor.suggest, messages);
57625 return createProblem({
57626 ruleId: metadata.ruleId,
57627 severity: metadata.severity,
57628 node: descriptor.node,
57629 message: interpolate(computedMessage, descriptor.data),
57630 messageId: descriptor.messageId,
57631 loc: normalizeReportLoc(descriptor),
57632 fix: metadata.disableFixes ? null : normalizeFixes(descriptor, metadata.sourceCode),
57633 suggestions: metadata.disableFixes ? [] : mapSuggestions(descriptor, metadata.sourceCode, messages)
57634 });
57635 };
57636 };
57637
57638 /***/ }),
57639 /* 542 */
57640 /***/ ((module) => {
57641
57642 "use strict";
57643 /**
57644 * @fileoverview An object that creates fix commands for rules.
57645 * @author Nicholas C. Zakas
57646 */
57647 //------------------------------------------------------------------------------
57648 // Requirements
57649 //------------------------------------------------------------------------------
57650 // none!
57651 //------------------------------------------------------------------------------
57652 // Helpers
57653 //------------------------------------------------------------------------------
57654
57655 /**
57656 * Creates a fix command that inserts text at the specified index in the source text.
57657 * @param {int} index The 0-based index at which to insert the new text.
57658 * @param {string} text The text to insert.
57659 * @returns {Object} The fix command.
57660 * @private
57661 */
57662
57663 function insertTextAt(index, text) {
57664 return {
57665 range: [index, index],
57666 text
57667 };
57668 } //------------------------------------------------------------------------------
57669 // Public Interface
57670 //------------------------------------------------------------------------------
57671
57672 /**
57673 * Creates code fixing commands for rules.
57674 */
57675
57676
57677 const ruleFixer = Object.freeze({
57678 /**
57679 * Creates a fix command that inserts text after the given node or token.
57680 * The fix is not applied until applyFixes() is called.
57681 * @param {ASTNode|Token} nodeOrToken The node or token to insert after.
57682 * @param {string} text The text to insert.
57683 * @returns {Object} The fix command.
57684 */
57685 insertTextAfter(nodeOrToken, text) {
57686 return this.insertTextAfterRange(nodeOrToken.range, text);
57687 },
57688
57689 /**
57690 * Creates a fix command that inserts text after the specified range in the source text.
57691 * The fix is not applied until applyFixes() is called.
57692 * @param {int[]} range The range to replace, first item is start of range, second
57693 * is end of range.
57694 * @param {string} text The text to insert.
57695 * @returns {Object} The fix command.
57696 */
57697 insertTextAfterRange(range, text) {
57698 return insertTextAt(range[1], text);
57699 },
57700
57701 /**
57702 * Creates a fix command that inserts text before the given node or token.
57703 * The fix is not applied until applyFixes() is called.
57704 * @param {ASTNode|Token} nodeOrToken The node or token to insert before.
57705 * @param {string} text The text to insert.
57706 * @returns {Object} The fix command.
57707 */
57708 insertTextBefore(nodeOrToken, text) {
57709 return this.insertTextBeforeRange(nodeOrToken.range, text);
57710 },
57711
57712 /**
57713 * Creates a fix command that inserts text before the specified range in the source text.
57714 * The fix is not applied until applyFixes() is called.
57715 * @param {int[]} range The range to replace, first item is start of range, second
57716 * is end of range.
57717 * @param {string} text The text to insert.
57718 * @returns {Object} The fix command.
57719 */
57720 insertTextBeforeRange(range, text) {
57721 return insertTextAt(range[0], text);
57722 },
57723
57724 /**
57725 * Creates a fix command that replaces text at the node or token.
57726 * The fix is not applied until applyFixes() is called.
57727 * @param {ASTNode|Token} nodeOrToken The node or token to remove.
57728 * @param {string} text The text to insert.
57729 * @returns {Object} The fix command.
57730 */
57731 replaceText(nodeOrToken, text) {
57732 return this.replaceTextRange(nodeOrToken.range, text);
57733 },
57734
57735 /**
57736 * Creates a fix command that replaces text at the specified range in the source text.
57737 * The fix is not applied until applyFixes() is called.
57738 * @param {int[]} range The range to replace, first item is start of range, second
57739 * is end of range.
57740 * @param {string} text The text to insert.
57741 * @returns {Object} The fix command.
57742 */
57743 replaceTextRange(range, text) {
57744 return {
57745 range,
57746 text
57747 };
57748 },
57749
57750 /**
57751 * Creates a fix command that removes the node or token from the source.
57752 * The fix is not applied until applyFixes() is called.
57753 * @param {ASTNode|Token} nodeOrToken The node or token to remove.
57754 * @returns {Object} The fix command.
57755 */
57756 remove(nodeOrToken) {
57757 return this.removeRange(nodeOrToken.range);
57758 },
57759
57760 /**
57761 * Creates a fix command that removes the specified range of text from the source.
57762 * The fix is not applied until applyFixes() is called.
57763 * @param {int[]} range The range to remove, first item is start of range, second
57764 * is end of range.
57765 * @returns {Object} The fix command.
57766 */
57767 removeRange(range) {
57768 return {
57769 range,
57770 text: ""
57771 };
57772 }
57773
57774 });
57775 module.exports = ruleFixer;
57776
57777 /***/ }),
57778 /* 543 */
57779 /***/ ((module) => {
57780
57781 "use strict";
57782 /**
57783 * @fileoverview Interpolate keys from an object into a string with {{ }} markers.
57784 * @author Jed Fox
57785 */
57786 //------------------------------------------------------------------------------
57787 // Public Interface
57788 //------------------------------------------------------------------------------
57789
57790 module.exports = (text, data) => {
57791 if (!data) {
57792 return text;
57793 } // Substitution content for any {{ }} markers.
57794
57795
57796 return text.replace(/\{\{([^{}]+?)\}\}/gu, (fullMatch, termWithWhitespace) => {
57797 const term = termWithWhitespace.trim();
57798
57799 if (term in data) {
57800 return data[term];
57801 } // Preserve old behavior: If parameter name not provided, don't replace it.
57802
57803
57804 return fullMatch;
57805 });
57806 };
57807
57808 /***/ }),
57809 /* 544 */
57810 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
57811
57812 "use strict";
57813 /**
57814 * @fileoverview Defines a storage for rules.
57815 * @author Nicholas C. Zakas
57816 * @author aladdin-add
57817 */
57818 //------------------------------------------------------------------------------
57819 // Requirements
57820 //------------------------------------------------------------------------------
57821
57822 const builtInRules = __webpack_require__(545); //------------------------------------------------------------------------------
57823 // Helpers
57824 //------------------------------------------------------------------------------
57825
57826 /**
57827 * Normalizes a rule module to the new-style API
57828 * @param {(Function|{create: Function})} rule A rule object, which can either be a function
57829 * ("old-style") or an object with a `create` method ("new-style")
57830 * @returns {{create: Function}} A new-style rule.
57831 */
57832
57833
57834 function normalizeRule(rule) {
57835 return typeof rule === "function" ? Object.assign({
57836 create: rule
57837 }, rule) : rule;
57838 } //------------------------------------------------------------------------------
57839 // Public Interface
57840 //------------------------------------------------------------------------------
57841
57842 /**
57843 * A storage for rules.
57844 */
57845
57846
57847 class Rules {
57848 constructor() {
57849 this._rules = Object.create(null);
57850 }
57851 /**
57852 * Registers a rule module for rule id in storage.
57853 * @param {string} ruleId Rule id (file name).
57854 * @param {Function} ruleModule Rule handler.
57855 * @returns {void}
57856 */
57857
57858
57859 define(ruleId, ruleModule) {
57860 this._rules[ruleId] = normalizeRule(ruleModule);
57861 }
57862 /**
57863 * Access rule handler by id (file name).
57864 * @param {string} ruleId Rule id (file name).
57865 * @returns {{create: Function, schema: JsonSchema[]}}
57866 * A rule. This is normalized to always have the new-style shape with a `create` method.
57867 */
57868
57869
57870 get(ruleId) {
57871 if (typeof this._rules[ruleId] === "string") {
57872 this.define(ruleId, __webpack_require__(854)(this._rules[ruleId]));
57873 }
57874
57875 if (this._rules[ruleId]) {
57876 return this._rules[ruleId];
57877 }
57878
57879 if (builtInRules.has(ruleId)) {
57880 return builtInRules.get(ruleId);
57881 }
57882
57883 return null;
57884 }
57885
57886 *[Symbol.iterator]() {
57887 yield* builtInRules;
57888
57889 for (const ruleId of Object.keys(this._rules)) {
57890 yield [ruleId, this.get(ruleId)];
57891 }
57892 }
57893
57894 }
57895
57896 module.exports = Rules;
57897
57898 /***/ }),
57899 /* 545 */
57900 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
57901
57902 "use strict";
57903 /**
57904 * @fileoverview Collects the built-in rules into a map structure so that they can be imported all at once and without
57905 * using the file-system directly.
57906 * @author Peter (Somogyvari) Metz
57907 */
57908
57909 /* eslint sort-keys: ["error", "asc"] -- More readable for long list */
57910
57911 const {
57912 LazyLoadingRuleMap
57913 } = __webpack_require__(546);
57914 /** @type {Map<string, import("../shared/types").Rule>} */
57915
57916
57917 module.exports = new LazyLoadingRuleMap(Object.entries({
57918 "accessor-pairs": () => __webpack_require__(547),
57919 "array-bracket-newline": () => __webpack_require__(553),
57920 "array-bracket-spacing": () => __webpack_require__(554),
57921 "array-callback-return": () => __webpack_require__(555),
57922 "array-element-newline": () => __webpack_require__(556),
57923 "arrow-body-style": () => __webpack_require__(557),
57924 "arrow-parens": () => __webpack_require__(558),
57925 "arrow-spacing": () => __webpack_require__(559),
57926 "block-scoped-var": () => __webpack_require__(560),
57927 "block-spacing": () => __webpack_require__(561),
57928 "brace-style": () => __webpack_require__(562),
57929 "callback-return": () => __webpack_require__(563),
57930 camelcase: () => __webpack_require__(564),
57931 "capitalized-comments": () => __webpack_require__(565),
57932 "class-methods-use-this": () => __webpack_require__(567),
57933 "comma-dangle": () => __webpack_require__(568),
57934 "comma-spacing": () => __webpack_require__(569),
57935 "comma-style": () => __webpack_require__(570),
57936 complexity: () => __webpack_require__(571),
57937 "computed-property-spacing": () => __webpack_require__(573),
57938 "consistent-return": () => __webpack_require__(574),
57939 "consistent-this": () => __webpack_require__(575),
57940 "constructor-super": () => __webpack_require__(576),
57941 curly: () => __webpack_require__(577),
57942 "default-case": () => __webpack_require__(578),
57943 "default-case-last": () => __webpack_require__(579),
57944 "default-param-last": () => __webpack_require__(580),
57945 "dot-location": () => __webpack_require__(581),
57946 "dot-notation": () => __webpack_require__(582),
57947 "eol-last": () => __webpack_require__(584),
57948 eqeqeq: () => __webpack_require__(585),
57949 "for-direction": () => __webpack_require__(586),
57950 "func-call-spacing": () => __webpack_require__(587),
57951 "func-name-matching": () => __webpack_require__(588),
57952 "func-names": () => __webpack_require__(589),
57953 "func-style": () => __webpack_require__(590),
57954 "function-call-argument-newline": () => __webpack_require__(591),
57955 "function-paren-newline": () => __webpack_require__(592),
57956 "generator-star-spacing": () => __webpack_require__(593),
57957 "getter-return": () => __webpack_require__(594),
57958 "global-require": () => __webpack_require__(595),
57959 "grouped-accessor-pairs": () => __webpack_require__(596),
57960 "guard-for-in": () => __webpack_require__(597),
57961 "handle-callback-err": () => __webpack_require__(598),
57962 "id-blacklist": () => __webpack_require__(599),
57963 "id-denylist": () => __webpack_require__(600),
57964 "id-length": () => __webpack_require__(601),
57965 "id-match": () => __webpack_require__(602),
57966 "implicit-arrow-linebreak": () => __webpack_require__(603),
57967 indent: () => __webpack_require__(604),
57968 "indent-legacy": () => __webpack_require__(606),
57969 "init-declarations": () => __webpack_require__(607),
57970 "jsx-quotes": () => __webpack_require__(608),
57971 "key-spacing": () => __webpack_require__(609),
57972 "keyword-spacing": () => __webpack_require__(610),
57973 "line-comment-position": () => __webpack_require__(611),
57974 "linebreak-style": () => __webpack_require__(612),
57975 "lines-around-comment": () => __webpack_require__(613),
57976 "lines-around-directive": () => __webpack_require__(614),
57977 "lines-between-class-members": () => __webpack_require__(615),
57978 "max-classes-per-file": () => __webpack_require__(616),
57979 "max-depth": () => __webpack_require__(617),
57980 "max-len": () => __webpack_require__(618),
57981 "max-lines": () => __webpack_require__(619),
57982 "max-lines-per-function": () => __webpack_require__(620),
57983 "max-nested-callbacks": () => __webpack_require__(621),
57984 "max-params": () => __webpack_require__(622),
57985 "max-statements": () => __webpack_require__(623),
57986 "max-statements-per-line": () => __webpack_require__(624),
57987 "multiline-comment-style": () => __webpack_require__(625),
57988 "multiline-ternary": () => __webpack_require__(626),
57989 "new-cap": () => __webpack_require__(627),
57990 "new-parens": () => __webpack_require__(628),
57991 "newline-after-var": () => __webpack_require__(629),
57992 "newline-before-return": () => __webpack_require__(630),
57993 "newline-per-chained-call": () => __webpack_require__(631),
57994 "no-alert": () => __webpack_require__(632),
57995 "no-array-constructor": () => __webpack_require__(633),
57996 "no-async-promise-executor": () => __webpack_require__(634),
57997 "no-await-in-loop": () => __webpack_require__(635),
57998 "no-bitwise": () => __webpack_require__(636),
57999 "no-buffer-constructor": () => __webpack_require__(637),
58000 "no-caller": () => __webpack_require__(638),
58001 "no-case-declarations": () => __webpack_require__(639),
58002 "no-catch-shadow": () => __webpack_require__(640),
58003 "no-class-assign": () => __webpack_require__(641),
58004 "no-compare-neg-zero": () => __webpack_require__(642),
58005 "no-cond-assign": () => __webpack_require__(643),
58006 "no-confusing-arrow": () => __webpack_require__(644),
58007 "no-console": () => __webpack_require__(645),
58008 "no-const-assign": () => __webpack_require__(646),
58009 "no-constant-condition": () => __webpack_require__(647),
58010 "no-constructor-return": () => __webpack_require__(648),
58011 "no-continue": () => __webpack_require__(649),
58012 "no-control-regex": () => __webpack_require__(650),
58013 "no-debugger": () => __webpack_require__(652),
58014 "no-delete-var": () => __webpack_require__(653),
58015 "no-div-regex": () => __webpack_require__(654),
58016 "no-dupe-args": () => __webpack_require__(655),
58017 "no-dupe-class-members": () => __webpack_require__(656),
58018 "no-dupe-else-if": () => __webpack_require__(657),
58019 "no-dupe-keys": () => __webpack_require__(658),
58020 "no-duplicate-case": () => __webpack_require__(659),
58021 "no-duplicate-imports": () => __webpack_require__(660),
58022 "no-else-return": () => __webpack_require__(661),
58023 "no-empty": () => __webpack_require__(663),
58024 "no-empty-character-class": () => __webpack_require__(664),
58025 "no-empty-function": () => __webpack_require__(665),
58026 "no-empty-pattern": () => __webpack_require__(666),
58027 "no-eq-null": () => __webpack_require__(667),
58028 "no-eval": () => __webpack_require__(668),
58029 "no-ex-assign": () => __webpack_require__(669),
58030 "no-extend-native": () => __webpack_require__(670),
58031 "no-extra-bind": () => __webpack_require__(671),
58032 "no-extra-boolean-cast": () => __webpack_require__(672),
58033 "no-extra-label": () => __webpack_require__(673),
58034 "no-extra-parens": () => __webpack_require__(674),
58035 "no-extra-semi": () => __webpack_require__(675),
58036 "no-fallthrough": () => __webpack_require__(676),
58037 "no-floating-decimal": () => __webpack_require__(677),
58038 "no-func-assign": () => __webpack_require__(678),
58039 "no-global-assign": () => __webpack_require__(679),
58040 "no-implicit-coercion": () => __webpack_require__(680),
58041 "no-implicit-globals": () => __webpack_require__(681),
58042 "no-implied-eval": () => __webpack_require__(682),
58043 "no-import-assign": () => __webpack_require__(683),
58044 "no-inline-comments": () => __webpack_require__(684),
58045 "no-inner-declarations": () => __webpack_require__(685),
58046 "no-invalid-regexp": () => __webpack_require__(686),
58047 "no-invalid-this": () => __webpack_require__(687),
58048 "no-irregular-whitespace": () => __webpack_require__(688),
58049 "no-iterator": () => __webpack_require__(689),
58050 "no-label-var": () => __webpack_require__(690),
58051 "no-labels": () => __webpack_require__(691),
58052 "no-lone-blocks": () => __webpack_require__(692),
58053 "no-lonely-if": () => __webpack_require__(693),
58054 "no-loop-func": () => __webpack_require__(694),
58055 "no-loss-of-precision": () => __webpack_require__(695),
58056 "no-magic-numbers": () => __webpack_require__(696),
58057 "no-misleading-character-class": () => __webpack_require__(697),
58058 "no-mixed-operators": () => __webpack_require__(703),
58059 "no-mixed-requires": () => __webpack_require__(704),
58060 "no-mixed-spaces-and-tabs": () => __webpack_require__(705),
58061 "no-multi-assign": () => __webpack_require__(706),
58062 "no-multi-spaces": () => __webpack_require__(707),
58063 "no-multi-str": () => __webpack_require__(708),
58064 "no-multiple-empty-lines": () => __webpack_require__(709),
58065 "no-native-reassign": () => __webpack_require__(710),
58066 "no-negated-condition": () => __webpack_require__(711),
58067 "no-negated-in-lhs": () => __webpack_require__(712),
58068 "no-nested-ternary": () => __webpack_require__(713),
58069 "no-new": () => __webpack_require__(714),
58070 "no-new-func": () => __webpack_require__(715),
58071 "no-new-object": () => __webpack_require__(716),
58072 "no-new-require": () => __webpack_require__(717),
58073 "no-new-symbol": () => __webpack_require__(718),
58074 "no-new-wrappers": () => __webpack_require__(719),
58075 "no-nonoctal-decimal-escape": () => __webpack_require__(720),
58076 "no-obj-calls": () => __webpack_require__(721),
58077 "no-octal": () => __webpack_require__(722),
58078 "no-octal-escape": () => __webpack_require__(723),
58079 "no-param-reassign": () => __webpack_require__(724),
58080 "no-path-concat": () => __webpack_require__(725),
58081 "no-plusplus": () => __webpack_require__(726),
58082 "no-process-env": () => __webpack_require__(727),
58083 "no-process-exit": () => __webpack_require__(728),
58084 "no-promise-executor-return": () => __webpack_require__(729),
58085 "no-proto": () => __webpack_require__(730),
58086 "no-prototype-builtins": () => __webpack_require__(731),
58087 "no-redeclare": () => __webpack_require__(732),
58088 "no-regex-spaces": () => __webpack_require__(733),
58089 "no-restricted-exports": () => __webpack_require__(734),
58090 "no-restricted-globals": () => __webpack_require__(735),
58091 "no-restricted-imports": () => __webpack_require__(736),
58092 "no-restricted-modules": () => __webpack_require__(738),
58093 "no-restricted-properties": () => __webpack_require__(739),
58094 "no-restricted-syntax": () => __webpack_require__(740),
58095 "no-return-assign": () => __webpack_require__(741),
58096 "no-return-await": () => __webpack_require__(742),
58097 "no-script-url": () => __webpack_require__(743),
58098 "no-self-assign": () => __webpack_require__(744),
58099 "no-self-compare": () => __webpack_require__(745),
58100 "no-sequences": () => __webpack_require__(746),
58101 "no-setter-return": () => __webpack_require__(747),
58102 "no-shadow": () => __webpack_require__(748),
58103 "no-shadow-restricted-names": () => __webpack_require__(749),
58104 "no-spaced-func": () => __webpack_require__(750),
58105 "no-sparse-arrays": () => __webpack_require__(751),
58106 "no-sync": () => __webpack_require__(752),
58107 "no-tabs": () => __webpack_require__(753),
58108 "no-template-curly-in-string": () => __webpack_require__(754),
58109 "no-ternary": () => __webpack_require__(755),
58110 "no-this-before-super": () => __webpack_require__(756),
58111 "no-throw-literal": () => __webpack_require__(757),
58112 "no-trailing-spaces": () => __webpack_require__(758),
58113 "no-undef": () => __webpack_require__(759),
58114 "no-undef-init": () => __webpack_require__(760),
58115 "no-undefined": () => __webpack_require__(761),
58116 "no-underscore-dangle": () => __webpack_require__(762),
58117 "no-unexpected-multiline": () => __webpack_require__(763),
58118 "no-unmodified-loop-condition": () => __webpack_require__(764),
58119 "no-unneeded-ternary": () => __webpack_require__(765),
58120 "no-unreachable": () => __webpack_require__(766),
58121 "no-unreachable-loop": () => __webpack_require__(767),
58122 "no-unsafe-finally": () => __webpack_require__(768),
58123 "no-unsafe-negation": () => __webpack_require__(769),
58124 "no-unsafe-optional-chaining": () => __webpack_require__(770),
58125 "no-unused-expressions": () => __webpack_require__(771),
58126 "no-unused-labels": () => __webpack_require__(772),
58127 "no-unused-private-class-members": () => __webpack_require__(773),
58128 "no-unused-vars": () => __webpack_require__(774),
58129 "no-use-before-define": () => __webpack_require__(775),
58130 "no-useless-backreference": () => __webpack_require__(776),
58131 "no-useless-call": () => __webpack_require__(777),
58132 "no-useless-catch": () => __webpack_require__(778),
58133 "no-useless-computed-key": () => __webpack_require__(779),
58134 "no-useless-concat": () => __webpack_require__(780),
58135 "no-useless-constructor": () => __webpack_require__(781),
58136 "no-useless-escape": () => __webpack_require__(782),
58137 "no-useless-rename": () => __webpack_require__(783),
58138 "no-useless-return": () => __webpack_require__(784),
58139 "no-var": () => __webpack_require__(785),
58140 "no-void": () => __webpack_require__(786),
58141 "no-warning-comments": () => __webpack_require__(787),
58142 "no-whitespace-before-property": () => __webpack_require__(788),
58143 "no-with": () => __webpack_require__(789),
58144 "nonblock-statement-body-position": () => __webpack_require__(790),
58145 "object-curly-newline": () => __webpack_require__(791),
58146 "object-curly-spacing": () => __webpack_require__(792),
58147 "object-property-newline": () => __webpack_require__(793),
58148 "object-shorthand": () => __webpack_require__(794),
58149 "one-var": () => __webpack_require__(795),
58150 "one-var-declaration-per-line": () => __webpack_require__(796),
58151 "operator-assignment": () => __webpack_require__(797),
58152 "operator-linebreak": () => __webpack_require__(798),
58153 "padded-blocks": () => __webpack_require__(799),
58154 "padding-line-between-statements": () => __webpack_require__(800),
58155 "prefer-arrow-callback": () => __webpack_require__(801),
58156 "prefer-const": () => __webpack_require__(802),
58157 "prefer-destructuring": () => __webpack_require__(803),
58158 "prefer-exponentiation-operator": () => __webpack_require__(804),
58159 "prefer-named-capture-group": () => __webpack_require__(805),
58160 "prefer-numeric-literals": () => __webpack_require__(806),
58161 "prefer-object-spread": () => __webpack_require__(807),
58162 "prefer-promise-reject-errors": () => __webpack_require__(808),
58163 "prefer-reflect": () => __webpack_require__(809),
58164 "prefer-regex-literals": () => __webpack_require__(810),
58165 "prefer-rest-params": () => __webpack_require__(811),
58166 "prefer-spread": () => __webpack_require__(812),
58167 "prefer-template": () => __webpack_require__(813),
58168 "quote-props": () => __webpack_require__(814),
58169 quotes: () => __webpack_require__(815),
58170 radix: () => __webpack_require__(816),
58171 "require-atomic-updates": () => __webpack_require__(817),
58172 "require-await": () => __webpack_require__(818),
58173 "require-jsdoc": () => __webpack_require__(819),
58174 "require-unicode-regexp": () => __webpack_require__(820),
58175 "require-yield": () => __webpack_require__(821),
58176 "rest-spread-spacing": () => __webpack_require__(822),
58177 semi: () => __webpack_require__(823),
58178 "semi-spacing": () => __webpack_require__(824),
58179 "semi-style": () => __webpack_require__(825),
58180 "sort-imports": () => __webpack_require__(826),
58181 "sort-keys": () => __webpack_require__(827),
58182 "sort-vars": () => __webpack_require__(829),
58183 "space-before-blocks": () => __webpack_require__(830),
58184 "space-before-function-paren": () => __webpack_require__(831),
58185 "space-in-parens": () => __webpack_require__(832),
58186 "space-infix-ops": () => __webpack_require__(833),
58187 "space-unary-ops": () => __webpack_require__(834),
58188 "spaced-comment": () => __webpack_require__(835),
58189 strict: () => __webpack_require__(836),
58190 "switch-colon-spacing": () => __webpack_require__(837),
58191 "symbol-description": () => __webpack_require__(838),
58192 "template-curly-spacing": () => __webpack_require__(839),
58193 "template-tag-spacing": () => __webpack_require__(840),
58194 "unicode-bom": () => __webpack_require__(841),
58195 "use-isnan": () => __webpack_require__(842),
58196 "valid-jsdoc": () => __webpack_require__(843),
58197 "valid-typeof": () => __webpack_require__(848),
58198 "vars-on-top": () => __webpack_require__(849),
58199 "wrap-iife": () => __webpack_require__(850),
58200 "wrap-regex": () => __webpack_require__(851),
58201 "yield-star-spacing": () => __webpack_require__(852),
58202 yoda: () => __webpack_require__(853)
58203 }));
58204
58205 /***/ }),
58206 /* 546 */
58207 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
58208
58209 "use strict";
58210 /**
58211 * @fileoverview `Map` to load rules lazily.
58212 * @author Toru Nagashima <https://github.com/mysticatea>
58213 */
58214
58215
58216 const debug = __webpack_require__(496)("eslint:rules");
58217 /** @typedef {import("./types").Rule} Rule */
58218
58219 /**
58220 * The `Map` object that loads each rule when it's accessed.
58221 * @example
58222 * const rules = new LazyLoadingRuleMap([
58223 * ["eqeqeq", () => require("eqeqeq")],
58224 * ["semi", () => require("semi")],
58225 * ["no-unused-vars", () => require("no-unused-vars")]
58226 * ]);
58227 *
58228 * rules.get("semi"); // call `() => require("semi")` here.
58229 *
58230 * @extends {Map<string, () => Rule>}
58231 */
58232
58233
58234 class LazyLoadingRuleMap extends Map {
58235 /**
58236 * Initialize this map.
58237 * @param {Array<[string, function(): Rule]>} loaders The rule loaders.
58238 */
58239 constructor(loaders) {
58240 let remaining = loaders.length;
58241 super(debug.enabled ? loaders.map(_ref => {
58242 let [ruleId, load] = _ref;
58243 let cache = null;
58244 return [ruleId, () => {
58245 if (!cache) {
58246 debug("Loading rule %o (remaining=%d)", ruleId, --remaining);
58247 cache = load();
58248 }
58249
58250 return cache;
58251 }];
58252 }) : loaders); // `super(...iterable)` uses `this.set()`, so disable it here.
58253
58254 Object.defineProperty(LazyLoadingRuleMap.prototype, "set", {
58255 configurable: true,
58256 value: void 0
58257 });
58258 }
58259 /**
58260 * Get a rule.
58261 * Each rule will be loaded on the first access.
58262 * @param {string} ruleId The rule ID to get.
58263 * @returns {Rule|undefined} The rule.
58264 */
58265
58266
58267 get(ruleId) {
58268 const load = super.get(ruleId);
58269 return load && load();
58270 }
58271 /**
58272 * Iterate rules.
58273 * @returns {IterableIterator<Rule>} Rules.
58274 */
58275
58276
58277 *values() {
58278 for (const load of super.values()) {
58279 yield load();
58280 }
58281 }
58282 /**
58283 * Iterate rules.
58284 * @returns {IterableIterator<[string, Rule]>} Rules.
58285 */
58286
58287
58288 *entries() {
58289 for (const [ruleId, load] of super.entries()) {
58290 yield [ruleId, load()];
58291 }
58292 }
58293 /**
58294 * Call a function with each rule.
58295 * @param {Function} callbackFn The callback function.
58296 * @param {any} [thisArg] The object to pass to `this` of the callback function.
58297 * @returns {void}
58298 */
58299
58300
58301 forEach(callbackFn, thisArg) {
58302 for (const [ruleId, load] of super.entries()) {
58303 callbackFn.call(thisArg, load(), ruleId, this);
58304 }
58305 }
58306
58307 } // Forbid mutation.
58308
58309
58310 Object.defineProperties(LazyLoadingRuleMap.prototype, {
58311 clear: {
58312 configurable: true,
58313 value: void 0
58314 },
58315 delete: {
58316 configurable: true,
58317 value: void 0
58318 },
58319 [Symbol.iterator]: {
58320 configurable: true,
58321 writable: true,
58322 value: LazyLoadingRuleMap.prototype.entries
58323 }
58324 });
58325 module.exports = {
58326 LazyLoadingRuleMap
58327 };
58328
58329 /***/ }),
58330 /* 547 */
58331 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
58332
58333 "use strict";
58334 /**
58335 * @fileoverview Rule to enforce getter and setter pairs in objects and classes.
58336 * @author Gyandeep Singh
58337 */
58338 //------------------------------------------------------------------------------
58339 // Requirements
58340 //------------------------------------------------------------------------------
58341
58342 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
58343 // Typedefs
58344 //------------------------------------------------------------------------------
58345
58346 /**
58347 * Property name if it can be computed statically, otherwise the list of the tokens of the key node.
58348 * @typedef {string|Token[]} Key
58349 */
58350
58351 /**
58352 * Accessor nodes with the same key.
58353 * @typedef {Object} AccessorData
58354 * @property {Key} key Accessor's key
58355 * @property {ASTNode[]} getters List of getter nodes.
58356 * @property {ASTNode[]} setters List of setter nodes.
58357 */
58358 //------------------------------------------------------------------------------
58359 // Helpers
58360 //------------------------------------------------------------------------------
58361
58362 /**
58363 * Checks whether or not the given lists represent the equal tokens in the same order.
58364 * Tokens are compared by their properties, not by instance.
58365 * @param {Token[]} left First list of tokens.
58366 * @param {Token[]} right Second list of tokens.
58367 * @returns {boolean} `true` if the lists have same tokens.
58368 */
58369
58370
58371 function areEqualTokenLists(left, right) {
58372 if (left.length !== right.length) {
58373 return false;
58374 }
58375
58376 for (let i = 0; i < left.length; i++) {
58377 const leftToken = left[i],
58378 rightToken = right[i];
58379
58380 if (leftToken.type !== rightToken.type || leftToken.value !== rightToken.value) {
58381 return false;
58382 }
58383 }
58384
58385 return true;
58386 }
58387 /**
58388 * Checks whether or not the given keys are equal.
58389 * @param {Key} left First key.
58390 * @param {Key} right Second key.
58391 * @returns {boolean} `true` if the keys are equal.
58392 */
58393
58394
58395 function areEqualKeys(left, right) {
58396 if (typeof left === "string" && typeof right === "string") {
58397 // Statically computed names.
58398 return left === right;
58399 }
58400
58401 if (Array.isArray(left) && Array.isArray(right)) {
58402 // Token lists.
58403 return areEqualTokenLists(left, right);
58404 }
58405
58406 return false;
58407 }
58408 /**
58409 * Checks whether or not a given node is of an accessor kind ('get' or 'set').
58410 * @param {ASTNode} node A node to check.
58411 * @returns {boolean} `true` if the node is of an accessor kind.
58412 */
58413
58414
58415 function isAccessorKind(node) {
58416 return node.kind === "get" || node.kind === "set";
58417 }
58418 /**
58419 * Checks whether or not a given node is an argument of a specified method call.
58420 * @param {ASTNode} node A node to check.
58421 * @param {number} index An expected index of the node in arguments.
58422 * @param {string} object An expected name of the object of the method.
58423 * @param {string} property An expected name of the method.
58424 * @returns {boolean} `true` if the node is an argument of the specified method call.
58425 */
58426
58427
58428 function isArgumentOfMethodCall(node, index, object, property) {
58429 const parent = node.parent;
58430 return parent.type === "CallExpression" && astUtils.isSpecificMemberAccess(parent.callee, object, property) && parent.arguments[index] === node;
58431 }
58432 /**
58433 * Checks whether or not a given node is a property descriptor.
58434 * @param {ASTNode} node A node to check.
58435 * @returns {boolean} `true` if the node is a property descriptor.
58436 */
58437
58438
58439 function isPropertyDescriptor(node) {
58440 // Object.defineProperty(obj, "foo", {set: ...})
58441 if (isArgumentOfMethodCall(node, 2, "Object", "defineProperty") || isArgumentOfMethodCall(node, 2, "Reflect", "defineProperty")) {
58442 return true;
58443 }
58444 /*
58445 * Object.defineProperties(obj, {foo: {set: ...}})
58446 * Object.create(proto, {foo: {set: ...}})
58447 */
58448
58449
58450 const grandparent = node.parent.parent;
58451 return grandparent.type === "ObjectExpression" && (isArgumentOfMethodCall(grandparent, 1, "Object", "create") || isArgumentOfMethodCall(grandparent, 1, "Object", "defineProperties"));
58452 } //------------------------------------------------------------------------------
58453 // Rule Definition
58454 //------------------------------------------------------------------------------
58455
58456
58457 module.exports = {
58458 meta: {
58459 type: "suggestion",
58460 docs: {
58461 description: "enforce getter and setter pairs in objects and classes",
58462 recommended: false,
58463 url: "https://eslint.org/docs/rules/accessor-pairs"
58464 },
58465 schema: [{
58466 type: "object",
58467 properties: {
58468 getWithoutSet: {
58469 type: "boolean",
58470 default: false
58471 },
58472 setWithoutGet: {
58473 type: "boolean",
58474 default: true
58475 },
58476 enforceForClassMembers: {
58477 type: "boolean",
58478 default: true
58479 }
58480 },
58481 additionalProperties: false
58482 }],
58483 messages: {
58484 missingGetterInPropertyDescriptor: "Getter is not present in property descriptor.",
58485 missingSetterInPropertyDescriptor: "Setter is not present in property descriptor.",
58486 missingGetterInObjectLiteral: "Getter is not present for {{ name }}.",
58487 missingSetterInObjectLiteral: "Setter is not present for {{ name }}.",
58488 missingGetterInClass: "Getter is not present for class {{ name }}.",
58489 missingSetterInClass: "Setter is not present for class {{ name }}."
58490 }
58491 },
58492
58493 create(context) {
58494 const config = context.options[0] || {};
58495 const checkGetWithoutSet = config.getWithoutSet === true;
58496 const checkSetWithoutGet = config.setWithoutGet !== false;
58497 const enforceForClassMembers = config.enforceForClassMembers !== false;
58498 const sourceCode = context.getSourceCode();
58499 /**
58500 * Reports the given node.
58501 * @param {ASTNode} node The node to report.
58502 * @param {string} messageKind "missingGetter" or "missingSetter".
58503 * @returns {void}
58504 * @private
58505 */
58506
58507 function report(node, messageKind) {
58508 if (node.type === "Property") {
58509 context.report({
58510 node,
58511 messageId: "".concat(messageKind, "InObjectLiteral"),
58512 loc: astUtils.getFunctionHeadLoc(node.value, sourceCode),
58513 data: {
58514 name: astUtils.getFunctionNameWithKind(node.value)
58515 }
58516 });
58517 } else if (node.type === "MethodDefinition") {
58518 context.report({
58519 node,
58520 messageId: "".concat(messageKind, "InClass"),
58521 loc: astUtils.getFunctionHeadLoc(node.value, sourceCode),
58522 data: {
58523 name: astUtils.getFunctionNameWithKind(node.value)
58524 }
58525 });
58526 } else {
58527 context.report({
58528 node,
58529 messageId: "".concat(messageKind, "InPropertyDescriptor")
58530 });
58531 }
58532 }
58533 /**
58534 * Reports each of the nodes in the given list using the same messageId.
58535 * @param {ASTNode[]} nodes Nodes to report.
58536 * @param {string} messageKind "missingGetter" or "missingSetter".
58537 * @returns {void}
58538 * @private
58539 */
58540
58541
58542 function reportList(nodes, messageKind) {
58543 for (const node of nodes) {
58544 report(node, messageKind);
58545 }
58546 }
58547 /**
58548 * Creates a new `AccessorData` object for the given getter or setter node.
58549 * @param {ASTNode} node A getter or setter node.
58550 * @returns {AccessorData} New `AccessorData` object that contains the given node.
58551 * @private
58552 */
58553
58554
58555 function createAccessorData(node) {
58556 const name = astUtils.getStaticPropertyName(node);
58557 const key = name !== null ? name : sourceCode.getTokens(node.key);
58558 return {
58559 key,
58560 getters: node.kind === "get" ? [node] : [],
58561 setters: node.kind === "set" ? [node] : []
58562 };
58563 }
58564 /**
58565 * Merges the given `AccessorData` object into the given accessors list.
58566 * @param {AccessorData[]} accessors The list to merge into.
58567 * @param {AccessorData} accessorData The object to merge.
58568 * @returns {AccessorData[]} The same instance with the merged object.
58569 * @private
58570 */
58571
58572
58573 function mergeAccessorData(accessors, accessorData) {
58574 const equalKeyElement = accessors.find(a => areEqualKeys(a.key, accessorData.key));
58575
58576 if (equalKeyElement) {
58577 equalKeyElement.getters.push(...accessorData.getters);
58578 equalKeyElement.setters.push(...accessorData.setters);
58579 } else {
58580 accessors.push(accessorData);
58581 }
58582
58583 return accessors;
58584 }
58585 /**
58586 * Checks accessor pairs in the given list of nodes.
58587 * @param {ASTNode[]} nodes The list to check.
58588 * @returns {void}
58589 * @private
58590 */
58591
58592
58593 function checkList(nodes) {
58594 const accessors = nodes.filter(isAccessorKind).map(createAccessorData).reduce(mergeAccessorData, []);
58595
58596 for (const {
58597 getters,
58598 setters
58599 } of accessors) {
58600 if (checkSetWithoutGet && setters.length && !getters.length) {
58601 reportList(setters, "missingGetter");
58602 }
58603
58604 if (checkGetWithoutSet && getters.length && !setters.length) {
58605 reportList(getters, "missingSetter");
58606 }
58607 }
58608 }
58609 /**
58610 * Checks accessor pairs in an object literal.
58611 * @param {ASTNode} node `ObjectExpression` node to check.
58612 * @returns {void}
58613 * @private
58614 */
58615
58616
58617 function checkObjectLiteral(node) {
58618 checkList(node.properties.filter(p => p.type === "Property"));
58619 }
58620 /**
58621 * Checks accessor pairs in a property descriptor.
58622 * @param {ASTNode} node Property descriptor `ObjectExpression` node to check.
58623 * @returns {void}
58624 * @private
58625 */
58626
58627
58628 function checkPropertyDescriptor(node) {
58629 const namesToCheck = node.properties.filter(p => p.type === "Property" && p.kind === "init" && !p.computed).map(_ref => {
58630 let {
58631 key
58632 } = _ref;
58633 return key.name;
58634 });
58635 const hasGetter = namesToCheck.includes("get");
58636 const hasSetter = namesToCheck.includes("set");
58637
58638 if (checkSetWithoutGet && hasSetter && !hasGetter) {
58639 report(node, "missingGetter");
58640 }
58641
58642 if (checkGetWithoutSet && hasGetter && !hasSetter) {
58643 report(node, "missingSetter");
58644 }
58645 }
58646 /**
58647 * Checks the given object expression as an object literal and as a possible property descriptor.
58648 * @param {ASTNode} node `ObjectExpression` node to check.
58649 * @returns {void}
58650 * @private
58651 */
58652
58653
58654 function checkObjectExpression(node) {
58655 checkObjectLiteral(node);
58656
58657 if (isPropertyDescriptor(node)) {
58658 checkPropertyDescriptor(node);
58659 }
58660 }
58661 /**
58662 * Checks the given class body.
58663 * @param {ASTNode} node `ClassBody` node to check.
58664 * @returns {void}
58665 * @private
58666 */
58667
58668
58669 function checkClassBody(node) {
58670 const methodDefinitions = node.body.filter(m => m.type === "MethodDefinition");
58671 checkList(methodDefinitions.filter(m => m.static));
58672 checkList(methodDefinitions.filter(m => !m.static));
58673 }
58674
58675 const listeners = {};
58676
58677 if (checkSetWithoutGet || checkGetWithoutSet) {
58678 listeners.ObjectExpression = checkObjectExpression;
58679
58680 if (enforceForClassMembers) {
58681 listeners.ClassBody = checkClassBody;
58682 }
58683 }
58684
58685 return listeners;
58686 }
58687
58688 };
58689
58690 /***/ }),
58691 /* 548 */
58692 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
58693
58694 "use strict";
58695 /**
58696 * @fileoverview Common utils for AST.
58697 * @author Gyandeep Singh
58698 */
58699 //------------------------------------------------------------------------------
58700 // Requirements
58701 //------------------------------------------------------------------------------
58702
58703 const esutils = __webpack_require__(549);
58704
58705 const espree = __webpack_require__(436);
58706
58707 const escapeRegExp = __webpack_require__(525);
58708
58709 const {
58710 breakableTypePattern,
58711 createGlobalLinebreakMatcher,
58712 lineBreakPattern,
58713 shebangPattern
58714 } = __webpack_require__(444); //------------------------------------------------------------------------------
58715 // Helpers
58716 //------------------------------------------------------------------------------
58717
58718
58719 const anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/u;
58720 const anyLoopPattern = /^(?:DoWhile|For|ForIn|ForOf|While)Statement$/u;
58721 const arrayOrTypedArrayPattern = /Array$/u;
58722 const arrayMethodPattern = /^(?:every|filter|find|findIndex|forEach|map|some)$/u;
58723 const bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/u;
58724 const thisTagPattern = /^[\s*]*@this/mu;
58725 const COMMENTS_IGNORE_PATTERN = /^\s*(?:eslint|jshint\s+|jslint\s+|istanbul\s+|globals?\s+|exported\s+|jscs)/u;
58726 const LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]); // A set of node types that can contain a list of statements
58727
58728 const STATEMENT_LIST_PARENTS = new Set(["Program", "BlockStatement", "StaticBlock", "SwitchCase"]);
58729 const DECIMAL_INTEGER_PATTERN = /^(?:0|0[0-7]*[89]\d*|[1-9](?:_?\d)*)$/u; // Tests the presence of at least one LegacyOctalEscapeSequence or NonOctalDecimalEscapeSequence in a raw string
58730
58731 const OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN = /^(?:[^\\]|\\.)*\\(?:[1-9]|0[0-9])/su;
58732 const LOGICAL_ASSIGNMENT_OPERATORS = new Set(["&&=", "||=", "??="]);
58733 /**
58734 * Checks reference if is non initializer and writable.
58735 * @param {Reference} reference A reference to check.
58736 * @param {int} index The index of the reference in the references.
58737 * @param {Reference[]} references The array that the reference belongs to.
58738 * @returns {boolean} Success/Failure
58739 * @private
58740 */
58741
58742 function isModifyingReference(reference, index, references) {
58743 const identifier = reference.identifier;
58744 /*
58745 * Destructuring assignments can have multiple default value, so
58746 * possibly there are multiple writeable references for the same
58747 * identifier.
58748 */
58749
58750 const modifyingDifferentIdentifier = index === 0 || references[index - 1].identifier !== identifier;
58751 return identifier && reference.init === false && reference.isWrite() && modifyingDifferentIdentifier;
58752 }
58753 /**
58754 * Checks whether the given string starts with uppercase or not.
58755 * @param {string} s The string to check.
58756 * @returns {boolean} `true` if the string starts with uppercase.
58757 */
58758
58759
58760 function startsWithUpperCase(s) {
58761 return s[0] !== s[0].toLocaleLowerCase();
58762 }
58763 /**
58764 * Checks whether or not a node is a constructor.
58765 * @param {ASTNode} node A function node to check.
58766 * @returns {boolean} Whether or not a node is a constructor.
58767 */
58768
58769
58770 function isES5Constructor(node) {
58771 return node.id && startsWithUpperCase(node.id.name);
58772 }
58773 /**
58774 * Finds a function node from ancestors of a node.
58775 * @param {ASTNode} node A start node to find.
58776 * @returns {Node|null} A found function node.
58777 */
58778
58779
58780 function getUpperFunction(node) {
58781 for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
58782 if (anyFunctionPattern.test(currentNode.type)) {
58783 return currentNode;
58784 }
58785 }
58786
58787 return null;
58788 }
58789 /**
58790 * Checks whether a given node is a function node or not.
58791 * The following types are function nodes:
58792 *
58793 * - ArrowFunctionExpression
58794 * - FunctionDeclaration
58795 * - FunctionExpression
58796 * @param {ASTNode|null} node A node to check.
58797 * @returns {boolean} `true` if the node is a function node.
58798 */
58799
58800
58801 function isFunction(node) {
58802 return Boolean(node && anyFunctionPattern.test(node.type));
58803 }
58804 /**
58805 * Checks whether a given node is a loop node or not.
58806 * The following types are loop nodes:
58807 *
58808 * - DoWhileStatement
58809 * - ForInStatement
58810 * - ForOfStatement
58811 * - ForStatement
58812 * - WhileStatement
58813 * @param {ASTNode|null} node A node to check.
58814 * @returns {boolean} `true` if the node is a loop node.
58815 */
58816
58817
58818 function isLoop(node) {
58819 return Boolean(node && anyLoopPattern.test(node.type));
58820 }
58821 /**
58822 * Checks whether the given node is in a loop or not.
58823 * @param {ASTNode} node The node to check.
58824 * @returns {boolean} `true` if the node is in a loop.
58825 */
58826
58827
58828 function isInLoop(node) {
58829 for (let currentNode = node; currentNode && !isFunction(currentNode); currentNode = currentNode.parent) {
58830 if (isLoop(currentNode)) {
58831 return true;
58832 }
58833 }
58834
58835 return false;
58836 }
58837 /**
58838 * Determines whether the given node is a `null` literal.
58839 * @param {ASTNode} node The node to check
58840 * @returns {boolean} `true` if the node is a `null` literal
58841 */
58842
58843
58844 function isNullLiteral(node) {
58845 /*
58846 * Checking `node.value === null` does not guarantee that a literal is a null literal.
58847 * When parsing values that cannot be represented in the current environment (e.g. unicode
58848 * regexes in Node 4), `node.value` is set to `null` because it wouldn't be possible to
58849 * set `node.value` to a unicode regex. To make sure a literal is actually `null`, check
58850 * `node.regex` instead. Also see: https://github.com/eslint/eslint/issues/8020
58851 */
58852 return node.type === "Literal" && node.value === null && !node.regex && !node.bigint;
58853 }
58854 /**
58855 * Checks whether or not a node is `null` or `undefined`.
58856 * @param {ASTNode} node A node to check.
58857 * @returns {boolean} Whether or not the node is a `null` or `undefined`.
58858 * @public
58859 */
58860
58861
58862 function isNullOrUndefined(node) {
58863 return isNullLiteral(node) || node.type === "Identifier" && node.name === "undefined" || node.type === "UnaryExpression" && node.operator === "void";
58864 }
58865 /**
58866 * Checks whether or not a node is callee.
58867 * @param {ASTNode} node A node to check.
58868 * @returns {boolean} Whether or not the node is callee.
58869 */
58870
58871
58872 function isCallee(node) {
58873 return node.parent.type === "CallExpression" && node.parent.callee === node;
58874 }
58875 /**
58876 * Returns the result of the string conversion applied to the evaluated value of the given expression node,
58877 * if it can be determined statically.
58878 *
58879 * This function returns a `string` value for all `Literal` nodes and simple `TemplateLiteral` nodes only.
58880 * In all other cases, this function returns `null`.
58881 * @param {ASTNode} node Expression node.
58882 * @returns {string|null} String value if it can be determined. Otherwise, `null`.
58883 */
58884
58885
58886 function getStaticStringValue(node) {
58887 switch (node.type) {
58888 case "Literal":
58889 if (node.value === null) {
58890 if (isNullLiteral(node)) {
58891 return String(node.value); // "null"
58892 }
58893
58894 if (node.regex) {
58895 return "/".concat(node.regex.pattern, "/").concat(node.regex.flags);
58896 }
58897
58898 if (node.bigint) {
58899 return node.bigint;
58900 } // Otherwise, this is an unknown literal. The function will return null.
58901
58902 } else {
58903 return String(node.value);
58904 }
58905
58906 break;
58907
58908 case "TemplateLiteral":
58909 if (node.expressions.length === 0 && node.quasis.length === 1) {
58910 return node.quasis[0].value.cooked;
58911 }
58912
58913 break;
58914 // no default
58915 }
58916
58917 return null;
58918 }
58919 /**
58920 * Gets the property name of a given node.
58921 * The node can be a MemberExpression, a Property, or a MethodDefinition.
58922 *
58923 * If the name is dynamic, this returns `null`.
58924 *
58925 * For examples:
58926 *
58927 * a.b // => "b"
58928 * a["b"] // => "b"
58929 * a['b'] // => "b"
58930 * a[`b`] // => "b"
58931 * a[100] // => "100"
58932 * a[b] // => null
58933 * a["a" + "b"] // => null
58934 * a[tag`b`] // => null
58935 * a[`${b}`] // => null
58936 *
58937 * let a = {b: 1} // => "b"
58938 * let a = {["b"]: 1} // => "b"
58939 * let a = {['b']: 1} // => "b"
58940 * let a = {[`b`]: 1} // => "b"
58941 * let a = {[100]: 1} // => "100"
58942 * let a = {[b]: 1} // => null
58943 * let a = {["a" + "b"]: 1} // => null
58944 * let a = {[tag`b`]: 1} // => null
58945 * let a = {[`${b}`]: 1} // => null
58946 * @param {ASTNode} node The node to get.
58947 * @returns {string|null} The property name if static. Otherwise, null.
58948 */
58949
58950
58951 function getStaticPropertyName(node) {
58952 let prop;
58953
58954 switch (node && node.type) {
58955 case "ChainExpression":
58956 return getStaticPropertyName(node.expression);
58957
58958 case "Property":
58959 case "PropertyDefinition":
58960 case "MethodDefinition":
58961 prop = node.key;
58962 break;
58963
58964 case "MemberExpression":
58965 prop = node.property;
58966 break;
58967 // no default
58968 }
58969
58970 if (prop) {
58971 if (prop.type === "Identifier" && !node.computed) {
58972 return prop.name;
58973 }
58974
58975 return getStaticStringValue(prop);
58976 }
58977
58978 return null;
58979 }
58980 /**
58981 * Retrieve `ChainExpression#expression` value if the given node a `ChainExpression` node. Otherwise, pass through it.
58982 * @param {ASTNode} node The node to address.
58983 * @returns {ASTNode} The `ChainExpression#expression` value if the node is a `ChainExpression` node. Otherwise, the node.
58984 */
58985
58986
58987 function skipChainExpression(node) {
58988 return node && node.type === "ChainExpression" ? node.expression : node;
58989 }
58990 /**
58991 * Check if the `actual` is an expected value.
58992 * @param {string} actual The string value to check.
58993 * @param {string | RegExp} expected The expected string value or pattern.
58994 * @returns {boolean} `true` if the `actual` is an expected value.
58995 */
58996
58997
58998 function checkText(actual, expected) {
58999 return typeof expected === "string" ? actual === expected : expected.test(actual);
59000 }
59001 /**
59002 * Check if a given node is an Identifier node with a given name.
59003 * @param {ASTNode} node The node to check.
59004 * @param {string | RegExp} name The expected name or the expected pattern of the object name.
59005 * @returns {boolean} `true` if the node is an Identifier node with the name.
59006 */
59007
59008
59009 function isSpecificId(node, name) {
59010 return node.type === "Identifier" && checkText(node.name, name);
59011 }
59012 /**
59013 * Check if a given node is member access with a given object name and property name pair.
59014 * This is regardless of optional or not.
59015 * @param {ASTNode} node The node to check.
59016 * @param {string | RegExp | null} objectName The expected name or the expected pattern of the object name. If this is nullish, this method doesn't check object.
59017 * @param {string | RegExp | null} propertyName The expected name or the expected pattern of the property name. If this is nullish, this method doesn't check property.
59018 * @returns {boolean} `true` if the node is member access with the object name and property name pair.
59019 * The node is a `MemberExpression` or `ChainExpression`.
59020 */
59021
59022
59023 function isSpecificMemberAccess(node, objectName, propertyName) {
59024 const checkNode = skipChainExpression(node);
59025
59026 if (checkNode.type !== "MemberExpression") {
59027 return false;
59028 }
59029
59030 if (objectName && !isSpecificId(checkNode.object, objectName)) {
59031 return false;
59032 }
59033
59034 if (propertyName) {
59035 const actualPropertyName = getStaticPropertyName(checkNode);
59036
59037 if (typeof actualPropertyName !== "string" || !checkText(actualPropertyName, propertyName)) {
59038 return false;
59039 }
59040 }
59041
59042 return true;
59043 }
59044 /**
59045 * Check if two literal nodes are the same value.
59046 * @param {ASTNode} left The Literal node to compare.
59047 * @param {ASTNode} right The other Literal node to compare.
59048 * @returns {boolean} `true` if the two literal nodes are the same value.
59049 */
59050
59051
59052 function equalLiteralValue(left, right) {
59053 // RegExp literal.
59054 if (left.regex || right.regex) {
59055 return Boolean(left.regex && right.regex && left.regex.pattern === right.regex.pattern && left.regex.flags === right.regex.flags);
59056 } // BigInt literal.
59057
59058
59059 if (left.bigint || right.bigint) {
59060 return left.bigint === right.bigint;
59061 }
59062
59063 return left.value === right.value;
59064 }
59065 /**
59066 * Check if two expressions reference the same value. For example:
59067 * a = a
59068 * a.b = a.b
59069 * a[0] = a[0]
59070 * a['b'] = a['b']
59071 * @param {ASTNode} left The left side of the comparison.
59072 * @param {ASTNode} right The right side of the comparison.
59073 * @param {boolean} [disableStaticComputedKey] Don't address `a.b` and `a["b"]` are the same if `true`. For backward compatibility.
59074 * @returns {boolean} `true` if both sides match and reference the same value.
59075 */
59076
59077
59078 function isSameReference(left, right) {
59079 let disableStaticComputedKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
59080
59081 if (left.type !== right.type) {
59082 // Handle `a.b` and `a?.b` are samely.
59083 if (left.type === "ChainExpression") {
59084 return isSameReference(left.expression, right, disableStaticComputedKey);
59085 }
59086
59087 if (right.type === "ChainExpression") {
59088 return isSameReference(left, right.expression, disableStaticComputedKey);
59089 }
59090
59091 return false;
59092 }
59093
59094 switch (left.type) {
59095 case "Super":
59096 case "ThisExpression":
59097 return true;
59098
59099 case "Identifier":
59100 case "PrivateIdentifier":
59101 return left.name === right.name;
59102
59103 case "Literal":
59104 return equalLiteralValue(left, right);
59105
59106 case "ChainExpression":
59107 return isSameReference(left.expression, right.expression, disableStaticComputedKey);
59108
59109 case "MemberExpression":
59110 {
59111 if (!disableStaticComputedKey) {
59112 const nameA = getStaticPropertyName(left); // x.y = x["y"]
59113
59114 if (nameA !== null) {
59115 return isSameReference(left.object, right.object, disableStaticComputedKey) && nameA === getStaticPropertyName(right);
59116 }
59117 }
59118 /*
59119 * x[0] = x[0]
59120 * x[y] = x[y]
59121 * x.y = x.y
59122 */
59123
59124
59125 return left.computed === right.computed && isSameReference(left.object, right.object, disableStaticComputedKey) && isSameReference(left.property, right.property, disableStaticComputedKey);
59126 }
59127
59128 default:
59129 return false;
59130 }
59131 }
59132 /**
59133 * Checks whether or not a node is `Reflect.apply`.
59134 * @param {ASTNode} node A node to check.
59135 * @returns {boolean} Whether or not the node is a `Reflect.apply`.
59136 */
59137
59138
59139 function isReflectApply(node) {
59140 return isSpecificMemberAccess(node, "Reflect", "apply");
59141 }
59142 /**
59143 * Checks whether or not a node is `Array.from`.
59144 * @param {ASTNode} node A node to check.
59145 * @returns {boolean} Whether or not the node is a `Array.from`.
59146 */
59147
59148
59149 function isArrayFromMethod(node) {
59150 return isSpecificMemberAccess(node, arrayOrTypedArrayPattern, "from");
59151 }
59152 /**
59153 * Checks whether or not a node is a method which has `thisArg`.
59154 * @param {ASTNode} node A node to check.
59155 * @returns {boolean} Whether or not the node is a method which has `thisArg`.
59156 */
59157
59158
59159 function isMethodWhichHasThisArg(node) {
59160 return isSpecificMemberAccess(node, null, arrayMethodPattern);
59161 }
59162 /**
59163 * Creates the negate function of the given function.
59164 * @param {Function} f The function to negate.
59165 * @returns {Function} Negated function.
59166 */
59167
59168
59169 function negate(f) {
59170 return token => !f(token);
59171 }
59172 /**
59173 * Checks whether or not a node has a `@this` tag in its comments.
59174 * @param {ASTNode} node A node to check.
59175 * @param {SourceCode} sourceCode A SourceCode instance to get comments.
59176 * @returns {boolean} Whether or not the node has a `@this` tag in its comments.
59177 */
59178
59179
59180 function hasJSDocThisTag(node, sourceCode) {
59181 const jsdocComment = sourceCode.getJSDocComment(node);
59182
59183 if (jsdocComment && thisTagPattern.test(jsdocComment.value)) {
59184 return true;
59185 } // Checks `@this` in its leading comments for callbacks,
59186 // because callbacks don't have its JSDoc comment.
59187 // e.g.
59188 // sinon.test(/* @this sinon.Sandbox */function() { this.spy(); });
59189
59190
59191 return sourceCode.getCommentsBefore(node).some(comment => thisTagPattern.test(comment.value));
59192 }
59193 /**
59194 * Determines if a node is surrounded by parentheses.
59195 * @param {SourceCode} sourceCode The ESLint source code object
59196 * @param {ASTNode} node The node to be checked.
59197 * @returns {boolean} True if the node is parenthesised.
59198 * @private
59199 */
59200
59201
59202 function isParenthesised(sourceCode, node) {
59203 const previousToken = sourceCode.getTokenBefore(node),
59204 nextToken = sourceCode.getTokenAfter(node);
59205 return Boolean(previousToken && nextToken) && previousToken.value === "(" && previousToken.range[1] <= node.range[0] && nextToken.value === ")" && nextToken.range[0] >= node.range[1];
59206 }
59207 /**
59208 * Checks if the given token is a `=` token or not.
59209 * @param {Token} token The token to check.
59210 * @returns {boolean} `true` if the token is a `=` token.
59211 */
59212
59213
59214 function isEqToken(token) {
59215 return token.value === "=" && token.type === "Punctuator";
59216 }
59217 /**
59218 * Checks if the given token is an arrow token or not.
59219 * @param {Token} token The token to check.
59220 * @returns {boolean} `true` if the token is an arrow token.
59221 */
59222
59223
59224 function isArrowToken(token) {
59225 return token.value === "=>" && token.type === "Punctuator";
59226 }
59227 /**
59228 * Checks if the given token is a comma token or not.
59229 * @param {Token} token The token to check.
59230 * @returns {boolean} `true` if the token is a comma token.
59231 */
59232
59233
59234 function isCommaToken(token) {
59235 return token.value === "," && token.type === "Punctuator";
59236 }
59237 /**
59238 * Checks if the given token is a dot token or not.
59239 * @param {Token} token The token to check.
59240 * @returns {boolean} `true` if the token is a dot token.
59241 */
59242
59243
59244 function isDotToken(token) {
59245 return token.value === "." && token.type === "Punctuator";
59246 }
59247 /**
59248 * Checks if the given token is a `?.` token or not.
59249 * @param {Token} token The token to check.
59250 * @returns {boolean} `true` if the token is a `?.` token.
59251 */
59252
59253
59254 function isQuestionDotToken(token) {
59255 return token.value === "?." && token.type === "Punctuator";
59256 }
59257 /**
59258 * Checks if the given token is a semicolon token or not.
59259 * @param {Token} token The token to check.
59260 * @returns {boolean} `true` if the token is a semicolon token.
59261 */
59262
59263
59264 function isSemicolonToken(token) {
59265 return token.value === ";" && token.type === "Punctuator";
59266 }
59267 /**
59268 * Checks if the given token is a colon token or not.
59269 * @param {Token} token The token to check.
59270 * @returns {boolean} `true` if the token is a colon token.
59271 */
59272
59273
59274 function isColonToken(token) {
59275 return token.value === ":" && token.type === "Punctuator";
59276 }
59277 /**
59278 * Checks if the given token is an opening parenthesis token or not.
59279 * @param {Token} token The token to check.
59280 * @returns {boolean} `true` if the token is an opening parenthesis token.
59281 */
59282
59283
59284 function isOpeningParenToken(token) {
59285 return token.value === "(" && token.type === "Punctuator";
59286 }
59287 /**
59288 * Checks if the given token is a closing parenthesis token or not.
59289 * @param {Token} token The token to check.
59290 * @returns {boolean} `true` if the token is a closing parenthesis token.
59291 */
59292
59293
59294 function isClosingParenToken(token) {
59295 return token.value === ")" && token.type === "Punctuator";
59296 }
59297 /**
59298 * Checks if the given token is an opening square bracket token or not.
59299 * @param {Token} token The token to check.
59300 * @returns {boolean} `true` if the token is an opening square bracket token.
59301 */
59302
59303
59304 function isOpeningBracketToken(token) {
59305 return token.value === "[" && token.type === "Punctuator";
59306 }
59307 /**
59308 * Checks if the given token is a closing square bracket token or not.
59309 * @param {Token} token The token to check.
59310 * @returns {boolean} `true` if the token is a closing square bracket token.
59311 */
59312
59313
59314 function isClosingBracketToken(token) {
59315 return token.value === "]" && token.type === "Punctuator";
59316 }
59317 /**
59318 * Checks if the given token is an opening brace token or not.
59319 * @param {Token} token The token to check.
59320 * @returns {boolean} `true` if the token is an opening brace token.
59321 */
59322
59323
59324 function isOpeningBraceToken(token) {
59325 return token.value === "{" && token.type === "Punctuator";
59326 }
59327 /**
59328 * Checks if the given token is a closing brace token or not.
59329 * @param {Token} token The token to check.
59330 * @returns {boolean} `true` if the token is a closing brace token.
59331 */
59332
59333
59334 function isClosingBraceToken(token) {
59335 return token.value === "}" && token.type === "Punctuator";
59336 }
59337 /**
59338 * Checks if the given token is a comment token or not.
59339 * @param {Token} token The token to check.
59340 * @returns {boolean} `true` if the token is a comment token.
59341 */
59342
59343
59344 function isCommentToken(token) {
59345 return token.type === "Line" || token.type === "Block" || token.type === "Shebang";
59346 }
59347 /**
59348 * Checks if the given token is a keyword token or not.
59349 * @param {Token} token The token to check.
59350 * @returns {boolean} `true` if the token is a keyword token.
59351 */
59352
59353
59354 function isKeywordToken(token) {
59355 return token.type === "Keyword";
59356 }
59357 /**
59358 * Gets the `(` token of the given function node.
59359 * @param {ASTNode} node The function node to get.
59360 * @param {SourceCode} sourceCode The source code object to get tokens.
59361 * @returns {Token} `(` token.
59362 */
59363
59364
59365 function getOpeningParenOfParams(node, sourceCode) {
59366 // If the node is an arrow function and doesn't have parens, this returns the identifier of the first param.
59367 if (node.type === "ArrowFunctionExpression" && node.params.length === 1) {
59368 const argToken = sourceCode.getFirstToken(node.params[0]);
59369 const maybeParenToken = sourceCode.getTokenBefore(argToken);
59370 return isOpeningParenToken(maybeParenToken) ? maybeParenToken : argToken;
59371 } // Otherwise, returns paren.
59372
59373
59374 return node.id ? sourceCode.getTokenAfter(node.id, isOpeningParenToken) : sourceCode.getFirstToken(node, isOpeningParenToken);
59375 }
59376 /**
59377 * Checks whether or not the tokens of two given nodes are same.
59378 * @param {ASTNode} left A node 1 to compare.
59379 * @param {ASTNode} right A node 2 to compare.
59380 * @param {SourceCode} sourceCode The ESLint source code object.
59381 * @returns {boolean} the source code for the given node.
59382 */
59383
59384
59385 function equalTokens(left, right, sourceCode) {
59386 const tokensL = sourceCode.getTokens(left);
59387 const tokensR = sourceCode.getTokens(right);
59388
59389 if (tokensL.length !== tokensR.length) {
59390 return false;
59391 }
59392
59393 for (let i = 0; i < tokensL.length; ++i) {
59394 if (tokensL[i].type !== tokensR[i].type || tokensL[i].value !== tokensR[i].value) {
59395 return false;
59396 }
59397 }
59398
59399 return true;
59400 }
59401 /**
59402 * Check if the given node is a true logical expression or not.
59403 *
59404 * The three binary expressions logical-or (`||`), logical-and (`&&`), and
59405 * coalesce (`??`) are known as `ShortCircuitExpression`.
59406 * But ESTree represents those by `LogicalExpression` node.
59407 *
59408 * This function rejects coalesce expressions of `LogicalExpression` node.
59409 * @param {ASTNode} node The node to check.
59410 * @returns {boolean} `true` if the node is `&&` or `||`.
59411 * @see https://tc39.es/ecma262/#prod-ShortCircuitExpression
59412 */
59413
59414
59415 function isLogicalExpression(node) {
59416 return node.type === "LogicalExpression" && (node.operator === "&&" || node.operator === "||");
59417 }
59418 /**
59419 * Check if the given node is a nullish coalescing expression or not.
59420 *
59421 * The three binary expressions logical-or (`||`), logical-and (`&&`), and
59422 * coalesce (`??`) are known as `ShortCircuitExpression`.
59423 * But ESTree represents those by `LogicalExpression` node.
59424 *
59425 * This function finds only coalesce expressions of `LogicalExpression` node.
59426 * @param {ASTNode} node The node to check.
59427 * @returns {boolean} `true` if the node is `??`.
59428 */
59429
59430
59431 function isCoalesceExpression(node) {
59432 return node.type === "LogicalExpression" && node.operator === "??";
59433 }
59434 /**
59435 * Check if given two nodes are the pair of a logical expression and a coalesce expression.
59436 * @param {ASTNode} left A node to check.
59437 * @param {ASTNode} right Another node to check.
59438 * @returns {boolean} `true` if the two nodes are the pair of a logical expression and a coalesce expression.
59439 */
59440
59441
59442 function isMixedLogicalAndCoalesceExpressions(left, right) {
59443 return isLogicalExpression(left) && isCoalesceExpression(right) || isCoalesceExpression(left) && isLogicalExpression(right);
59444 }
59445 /**
59446 * Checks if the given operator is a logical assignment operator.
59447 * @param {string} operator The operator to check.
59448 * @returns {boolean} `true` if the operator is a logical assignment operator.
59449 */
59450
59451
59452 function isLogicalAssignmentOperator(operator) {
59453 return LOGICAL_ASSIGNMENT_OPERATORS.has(operator);
59454 }
59455 /**
59456 * Get the colon token of the given SwitchCase node.
59457 * @param {ASTNode} node The SwitchCase node to get.
59458 * @param {SourceCode} sourceCode The source code object to get tokens.
59459 * @returns {Token} The colon token of the node.
59460 */
59461
59462
59463 function getSwitchCaseColonToken(node, sourceCode) {
59464 if (node.test) {
59465 return sourceCode.getTokenAfter(node.test, isColonToken);
59466 }
59467
59468 return sourceCode.getFirstToken(node, 1);
59469 } //------------------------------------------------------------------------------
59470 // Public Interface
59471 //------------------------------------------------------------------------------
59472
59473
59474 module.exports = {
59475 COMMENTS_IGNORE_PATTERN,
59476 LINEBREAKS,
59477 LINEBREAK_MATCHER: lineBreakPattern,
59478 SHEBANG_MATCHER: shebangPattern,
59479 STATEMENT_LIST_PARENTS,
59480
59481 /**
59482 * Determines whether two adjacent tokens are on the same line.
59483 * @param {Object} left The left token object.
59484 * @param {Object} right The right token object.
59485 * @returns {boolean} Whether or not the tokens are on the same line.
59486 * @public
59487 */
59488 isTokenOnSameLine(left, right) {
59489 return left.loc.end.line === right.loc.start.line;
59490 },
59491
59492 isNullOrUndefined,
59493 isCallee,
59494 isES5Constructor,
59495 getUpperFunction,
59496 isFunction,
59497 isLoop,
59498 isInLoop,
59499 isArrayFromMethod,
59500 isParenthesised,
59501 createGlobalLinebreakMatcher,
59502 equalTokens,
59503 isArrowToken,
59504 isClosingBraceToken,
59505 isClosingBracketToken,
59506 isClosingParenToken,
59507 isColonToken,
59508 isCommaToken,
59509 isCommentToken,
59510 isDotToken,
59511 isQuestionDotToken,
59512 isKeywordToken,
59513 isNotClosingBraceToken: negate(isClosingBraceToken),
59514 isNotClosingBracketToken: negate(isClosingBracketToken),
59515 isNotClosingParenToken: negate(isClosingParenToken),
59516 isNotColonToken: negate(isColonToken),
59517 isNotCommaToken: negate(isCommaToken),
59518 isNotDotToken: negate(isDotToken),
59519 isNotQuestionDotToken: negate(isQuestionDotToken),
59520 isNotOpeningBraceToken: negate(isOpeningBraceToken),
59521 isNotOpeningBracketToken: negate(isOpeningBracketToken),
59522 isNotOpeningParenToken: negate(isOpeningParenToken),
59523 isNotSemicolonToken: negate(isSemicolonToken),
59524 isOpeningBraceToken,
59525 isOpeningBracketToken,
59526 isOpeningParenToken,
59527 isSemicolonToken,
59528 isEqToken,
59529
59530 /**
59531 * Checks whether or not a given node is a string literal.
59532 * @param {ASTNode} node A node to check.
59533 * @returns {boolean} `true` if the node is a string literal.
59534 */
59535 isStringLiteral(node) {
59536 return node.type === "Literal" && typeof node.value === "string" || node.type === "TemplateLiteral";
59537 },
59538
59539 /**
59540 * Checks whether a given node is a breakable statement or not.
59541 * The node is breakable if the node is one of the following type:
59542 *
59543 * - DoWhileStatement
59544 * - ForInStatement
59545 * - ForOfStatement
59546 * - ForStatement
59547 * - SwitchStatement
59548 * - WhileStatement
59549 * @param {ASTNode} node A node to check.
59550 * @returns {boolean} `true` if the node is breakable.
59551 */
59552 isBreakableStatement(node) {
59553 return breakableTypePattern.test(node.type);
59554 },
59555
59556 /**
59557 * Gets references which are non initializer and writable.
59558 * @param {Reference[]} references An array of references.
59559 * @returns {Reference[]} An array of only references which are non initializer and writable.
59560 * @public
59561 */
59562 getModifyingReferences(references) {
59563 return references.filter(isModifyingReference);
59564 },
59565
59566 /**
59567 * Validate that a string passed in is surrounded by the specified character
59568 * @param {string} val The text to check.
59569 * @param {string} character The character to see if it's surrounded by.
59570 * @returns {boolean} True if the text is surrounded by the character, false if not.
59571 * @private
59572 */
59573 isSurroundedBy(val, character) {
59574 return val[0] === character && val[val.length - 1] === character;
59575 },
59576
59577 /**
59578 * Returns whether the provided node is an ESLint directive comment or not
59579 * @param {Line|Block} node The comment token to be checked
59580 * @returns {boolean} `true` if the node is an ESLint directive comment
59581 */
59582 isDirectiveComment(node) {
59583 const comment = node.value.trim();
59584 return node.type === "Line" && comment.indexOf("eslint-") === 0 || node.type === "Block" && (comment.indexOf("global ") === 0 || comment.indexOf("eslint ") === 0 || comment.indexOf("eslint-") === 0);
59585 },
59586
59587 /**
59588 * Gets the trailing statement of a given node.
59589 *
59590 * if (code)
59591 * consequent;
59592 *
59593 * When taking this `IfStatement`, returns `consequent;` statement.
59594 * @param {ASTNode} A node to get.
59595 * @returns {ASTNode|null} The trailing statement's node.
59596 */
59597 getTrailingStatement: esutils.ast.trailingStatement,
59598
59599 /**
59600 * Finds the variable by a given name in a given scope and its upper scopes.
59601 * @param {eslint-scope.Scope} initScope A scope to start find.
59602 * @param {string} name A variable name to find.
59603 * @returns {eslint-scope.Variable|null} A found variable or `null`.
59604 */
59605 getVariableByName(initScope, name) {
59606 let scope = initScope;
59607
59608 while (scope) {
59609 const variable = scope.set.get(name);
59610
59611 if (variable) {
59612 return variable;
59613 }
59614
59615 scope = scope.upper;
59616 }
59617
59618 return null;
59619 },
59620
59621 /**
59622 * Checks whether or not a given function node is the default `this` binding.
59623 *
59624 * First, this checks the node:
59625 *
59626 * - The given node is not in `PropertyDefinition#value` position.
59627 * - The given node is not `StaticBlock`.
59628 * - The function name does not start with uppercase. It's a convention to capitalize the names
59629 * of constructor functions. This check is not performed if `capIsConstructor` is set to `false`.
59630 * - The function does not have a JSDoc comment that has a @this tag.
59631 *
59632 * Next, this checks the location of the node.
59633 * If the location is below, this judges `this` is valid.
59634 *
59635 * - The location is not on an object literal.
59636 * - The location is not assigned to a variable which starts with an uppercase letter. Applies to anonymous
59637 * functions only, as the name of the variable is considered to be the name of the function in this case.
59638 * This check is not performed if `capIsConstructor` is set to `false`.
59639 * - The location is not on an ES2015 class.
59640 * - Its `bind`/`call`/`apply` method is not called directly.
59641 * - The function is not a callback of array methods (such as `.forEach()`) if `thisArg` is given.
59642 * @param {ASTNode} node A function node to check. It also can be an implicit function, like `StaticBlock`
59643 * or any expression that is `PropertyDefinition#value` node.
59644 * @param {SourceCode} sourceCode A SourceCode instance to get comments.
59645 * @param {boolean} [capIsConstructor = true] `false` disables the assumption that functions which name starts
59646 * with an uppercase or are assigned to a variable which name starts with an uppercase are constructors.
59647 * @returns {boolean} The function node is the default `this` binding.
59648 */
59649 isDefaultThisBinding(node, sourceCode) {
59650 let {
59651 capIsConstructor = true
59652 } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
59653
59654 /*
59655 * Class field initializers are implicit functions, but ESTree doesn't have the AST node of field initializers.
59656 * Therefore, A expression node at `PropertyDefinition#value` is a function.
59657 * In this case, `this` is always not default binding.
59658 */
59659 if (node.parent.type === "PropertyDefinition" && node.parent.value === node) {
59660 return false;
59661 } // Class static blocks are implicit functions. In this case, `this` is always not default binding.
59662
59663
59664 if (node.type === "StaticBlock") {
59665 return false;
59666 }
59667
59668 if (capIsConstructor && isES5Constructor(node) || hasJSDocThisTag(node, sourceCode)) {
59669 return false;
59670 }
59671
59672 const isAnonymous = node.id === null;
59673 let currentNode = node;
59674
59675 while (currentNode) {
59676 const parent = currentNode.parent;
59677
59678 switch (parent.type) {
59679 /*
59680 * Looks up the destination.
59681 * e.g., obj.foo = nativeFoo || function foo() { ... };
59682 */
59683 case "LogicalExpression":
59684 case "ConditionalExpression":
59685 case "ChainExpression":
59686 currentNode = parent;
59687 break;
59688
59689 /*
59690 * If the upper function is IIFE, checks the destination of the return value.
59691 * e.g.
59692 * obj.foo = (function() {
59693 * // setup...
59694 * return function foo() { ... };
59695 * })();
59696 * obj.foo = (() =>
59697 * function foo() { ... }
59698 * )();
59699 */
59700
59701 case "ReturnStatement":
59702 {
59703 const func = getUpperFunction(parent);
59704
59705 if (func === null || !isCallee(func)) {
59706 return true;
59707 }
59708
59709 currentNode = func.parent;
59710 break;
59711 }
59712
59713 case "ArrowFunctionExpression":
59714 if (currentNode !== parent.body || !isCallee(parent)) {
59715 return true;
59716 }
59717
59718 currentNode = parent.parent;
59719 break;
59720
59721 /*
59722 * e.g.
59723 * var obj = { foo() { ... } };
59724 * var obj = { foo: function() { ... } };
59725 * class A { constructor() { ... } }
59726 * class A { foo() { ... } }
59727 * class A { get foo() { ... } }
59728 * class A { set foo() { ... } }
59729 * class A { static foo() { ... } }
59730 * class A { foo = function() { ... } }
59731 */
59732
59733 case "Property":
59734 case "PropertyDefinition":
59735 case "MethodDefinition":
59736 return parent.value !== currentNode;
59737
59738 /*
59739 * e.g.
59740 * obj.foo = function foo() { ... };
59741 * Foo = function() { ... };
59742 * [obj.foo = function foo() { ... }] = a;
59743 * [Foo = function() { ... }] = a;
59744 */
59745
59746 case "AssignmentExpression":
59747 case "AssignmentPattern":
59748 if (parent.left.type === "MemberExpression") {
59749 return false;
59750 }
59751
59752 if (capIsConstructor && isAnonymous && parent.left.type === "Identifier" && startsWithUpperCase(parent.left.name)) {
59753 return false;
59754 }
59755
59756 return true;
59757
59758 /*
59759 * e.g.
59760 * var Foo = function() { ... };
59761 */
59762
59763 case "VariableDeclarator":
59764 return !(capIsConstructor && isAnonymous && parent.init === currentNode && parent.id.type === "Identifier" && startsWithUpperCase(parent.id.name));
59765
59766 /*
59767 * e.g.
59768 * var foo = function foo() { ... }.bind(obj);
59769 * (function foo() { ... }).call(obj);
59770 * (function foo() { ... }).apply(obj, []);
59771 */
59772
59773 case "MemberExpression":
59774 if (parent.object === currentNode && isSpecificMemberAccess(parent, null, bindOrCallOrApplyPattern)) {
59775 const maybeCalleeNode = parent.parent.type === "ChainExpression" ? parent.parent : parent;
59776 return !(isCallee(maybeCalleeNode) && maybeCalleeNode.parent.arguments.length >= 1 && !isNullOrUndefined(maybeCalleeNode.parent.arguments[0]));
59777 }
59778
59779 return true;
59780
59781 /*
59782 * e.g.
59783 * Reflect.apply(function() {}, obj, []);
59784 * Array.from([], function() {}, obj);
59785 * list.forEach(function() {}, obj);
59786 */
59787
59788 case "CallExpression":
59789 if (isReflectApply(parent.callee)) {
59790 return parent.arguments.length !== 3 || parent.arguments[0] !== currentNode || isNullOrUndefined(parent.arguments[1]);
59791 }
59792
59793 if (isArrayFromMethod(parent.callee)) {
59794 return parent.arguments.length !== 3 || parent.arguments[1] !== currentNode || isNullOrUndefined(parent.arguments[2]);
59795 }
59796
59797 if (isMethodWhichHasThisArg(parent.callee)) {
59798 return parent.arguments.length !== 2 || parent.arguments[0] !== currentNode || isNullOrUndefined(parent.arguments[1]);
59799 }
59800
59801 return true;
59802 // Otherwise `this` is default.
59803
59804 default:
59805 return true;
59806 }
59807 }
59808 /* istanbul ignore next */
59809
59810
59811 return true;
59812 },
59813
59814 /**
59815 * Get the precedence level based on the node type
59816 * @param {ASTNode} node node to evaluate
59817 * @returns {int} precedence level
59818 * @private
59819 */
59820 getPrecedence(node) {
59821 switch (node.type) {
59822 case "SequenceExpression":
59823 return 0;
59824
59825 case "AssignmentExpression":
59826 case "ArrowFunctionExpression":
59827 case "YieldExpression":
59828 return 1;
59829
59830 case "ConditionalExpression":
59831 return 3;
59832
59833 case "LogicalExpression":
59834 switch (node.operator) {
59835 case "||":
59836 case "??":
59837 return 4;
59838
59839 case "&&":
59840 return 5;
59841 // no default
59842 }
59843
59844 /* falls through */
59845
59846 case "BinaryExpression":
59847 switch (node.operator) {
59848 case "|":
59849 return 6;
59850
59851 case "^":
59852 return 7;
59853
59854 case "&":
59855 return 8;
59856
59857 case "==":
59858 case "!=":
59859 case "===":
59860 case "!==":
59861 return 9;
59862
59863 case "<":
59864 case "<=":
59865 case ">":
59866 case ">=":
59867 case "in":
59868 case "instanceof":
59869 return 10;
59870
59871 case "<<":
59872 case ">>":
59873 case ">>>":
59874 return 11;
59875
59876 case "+":
59877 case "-":
59878 return 12;
59879
59880 case "*":
59881 case "/":
59882 case "%":
59883 return 13;
59884
59885 case "**":
59886 return 15;
59887 // no default
59888 }
59889
59890 /* falls through */
59891
59892 case "UnaryExpression":
59893 case "AwaitExpression":
59894 return 16;
59895
59896 case "UpdateExpression":
59897 return 17;
59898
59899 case "CallExpression":
59900 case "ChainExpression":
59901 case "ImportExpression":
59902 return 18;
59903
59904 case "NewExpression":
59905 return 19;
59906
59907 default:
59908 return 20;
59909 }
59910 },
59911
59912 /**
59913 * Checks whether the given node is an empty block node or not.
59914 * @param {ASTNode|null} node The node to check.
59915 * @returns {boolean} `true` if the node is an empty block.
59916 */
59917 isEmptyBlock(node) {
59918 return Boolean(node && node.type === "BlockStatement" && node.body.length === 0);
59919 },
59920
59921 /**
59922 * Checks whether the given node is an empty function node or not.
59923 * @param {ASTNode|null} node The node to check.
59924 * @returns {boolean} `true` if the node is an empty function.
59925 */
59926 isEmptyFunction(node) {
59927 return isFunction(node) && module.exports.isEmptyBlock(node.body);
59928 },
59929
59930 /**
59931 * Get directives from directive prologue of a Program or Function node.
59932 * @param {ASTNode} node The node to check.
59933 * @returns {ASTNode[]} The directives found in the directive prologue.
59934 */
59935 getDirectivePrologue(node) {
59936 const directives = []; // Directive prologues only occur at the top of files or functions.
59937
59938 if (node.type === "Program" || node.type === "FunctionDeclaration" || node.type === "FunctionExpression" ||
59939 /*
59940 * Do not check arrow functions with implicit return.
59941 * `() => "use strict";` returns the string `"use strict"`.
59942 */
59943 node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement") {
59944 const statements = node.type === "Program" ? node.body : node.body.body;
59945
59946 for (const statement of statements) {
59947 if (statement.type === "ExpressionStatement" && statement.expression.type === "Literal") {
59948 directives.push(statement);
59949 } else {
59950 break;
59951 }
59952 }
59953 }
59954
59955 return directives;
59956 },
59957
59958 /**
59959 * Determines whether this node is a decimal integer literal. If a node is a decimal integer literal, a dot added
59960 * after the node will be parsed as a decimal point, rather than a property-access dot.
59961 * @param {ASTNode} node The node to check.
59962 * @returns {boolean} `true` if this node is a decimal integer.
59963 * @example
59964 *
59965 * 0 // true
59966 * 5 // true
59967 * 50 // true
59968 * 5_000 // true
59969 * 1_234_56 // true
59970 * 08 // true
59971 * 0192 // true
59972 * 5. // false
59973 * .5 // false
59974 * 5.0 // false
59975 * 5.00_00 // false
59976 * 05 // false
59977 * 0x5 // false
59978 * 0b101 // false
59979 * 0b11_01 // false
59980 * 0o5 // false
59981 * 5e0 // false
59982 * 5e1_000 // false
59983 * 5n // false
59984 * 1_000n // false
59985 * "5" // false
59986 *
59987 */
59988 isDecimalInteger(node) {
59989 return node.type === "Literal" && typeof node.value === "number" && DECIMAL_INTEGER_PATTERN.test(node.raw);
59990 },
59991
59992 /**
59993 * Determines whether this token is a decimal integer numeric token.
59994 * This is similar to isDecimalInteger(), but for tokens.
59995 * @param {Token} token The token to check.
59996 * @returns {boolean} `true` if this token is a decimal integer.
59997 */
59998 isDecimalIntegerNumericToken(token) {
59999 return token.type === "Numeric" && DECIMAL_INTEGER_PATTERN.test(token.value);
60000 },
60001
60002 /**
60003 * Gets the name and kind of the given function node.
60004 *
60005 * - `function foo() {}` .................... `function 'foo'`
60006 * - `(function foo() {})` .................. `function 'foo'`
60007 * - `(function() {})` ...................... `function`
60008 * - `function* foo() {}` ................... `generator function 'foo'`
60009 * - `(function* foo() {})` ................. `generator function 'foo'`
60010 * - `(function*() {})` ..................... `generator function`
60011 * - `() => {}` ............................. `arrow function`
60012 * - `async () => {}` ....................... `async arrow function`
60013 * - `({ foo: function foo() {} })` ......... `method 'foo'`
60014 * - `({ foo: function() {} })` ............. `method 'foo'`
60015 * - `({ ['foo']: function() {} })` ......... `method 'foo'`
60016 * - `({ [foo]: function() {} })` ........... `method`
60017 * - `({ foo() {} })` ....................... `method 'foo'`
60018 * - `({ foo: function* foo() {} })` ........ `generator method 'foo'`
60019 * - `({ foo: function*() {} })` ............ `generator method 'foo'`
60020 * - `({ ['foo']: function*() {} })` ........ `generator method 'foo'`
60021 * - `({ [foo]: function*() {} })` .......... `generator method`
60022 * - `({ *foo() {} })` ...................... `generator method 'foo'`
60023 * - `({ foo: async function foo() {} })` ... `async method 'foo'`
60024 * - `({ foo: async function() {} })` ....... `async method 'foo'`
60025 * - `({ ['foo']: async function() {} })` ... `async method 'foo'`
60026 * - `({ [foo]: async function() {} })` ..... `async method`
60027 * - `({ async foo() {} })` ................. `async method 'foo'`
60028 * - `({ get foo() {} })` ................... `getter 'foo'`
60029 * - `({ set foo(a) {} })` .................. `setter 'foo'`
60030 * - `class A { constructor() {} }` ......... `constructor`
60031 * - `class A { foo() {} }` ................. `method 'foo'`
60032 * - `class A { *foo() {} }` ................ `generator method 'foo'`
60033 * - `class A { async foo() {} }` ........... `async method 'foo'`
60034 * - `class A { ['foo']() {} }` ............. `method 'foo'`
60035 * - `class A { *['foo']() {} }` ............ `generator method 'foo'`
60036 * - `class A { async ['foo']() {} }` ....... `async method 'foo'`
60037 * - `class A { [foo]() {} }` ............... `method`
60038 * - `class A { *[foo]() {} }` .............. `generator method`
60039 * - `class A { async [foo]() {} }` ......... `async method`
60040 * - `class A { get foo() {} }` ............. `getter 'foo'`
60041 * - `class A { set foo(a) {} }` ............ `setter 'foo'`
60042 * - `class A { static foo() {} }` .......... `static method 'foo'`
60043 * - `class A { static *foo() {} }` ......... `static generator method 'foo'`
60044 * - `class A { static async foo() {} }` .... `static async method 'foo'`
60045 * - `class A { static get foo() {} }` ...... `static getter 'foo'`
60046 * - `class A { static set foo(a) {} }` ..... `static setter 'foo'`
60047 * - `class A { foo = () => {}; }` .......... `method 'foo'`
60048 * - `class A { foo = function() {}; }` ..... `method 'foo'`
60049 * - `class A { foo = function bar() {}; }` . `method 'foo'`
60050 * - `class A { static foo = () => {}; }` ... `static method 'foo'`
60051 * - `class A { '#foo' = () => {}; }` ....... `method '#foo'`
60052 * - `class A { #foo = () => {}; }` ......... `private method #foo`
60053 * - `class A { static #foo = () => {}; }` .. `static private method #foo`
60054 * - `class A { '#foo'() {} }` .............. `method '#foo'`
60055 * - `class A { #foo() {} }` ................ `private method #foo`
60056 * - `class A { static #foo() {} }` ......... `static private method #foo`
60057 * @param {ASTNode} node The function node to get.
60058 * @returns {string} The name and kind of the function node.
60059 */
60060 getFunctionNameWithKind(node) {
60061 const parent = node.parent;
60062 const tokens = [];
60063
60064 if (parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") {
60065 // The proposal uses `static` word consistently before visibility words: https://github.com/tc39/proposal-static-class-features
60066 if (parent.static) {
60067 tokens.push("static");
60068 }
60069
60070 if (!parent.computed && parent.key.type === "PrivateIdentifier") {
60071 tokens.push("private");
60072 }
60073 }
60074
60075 if (node.async) {
60076 tokens.push("async");
60077 }
60078
60079 if (node.generator) {
60080 tokens.push("generator");
60081 }
60082
60083 if (parent.type === "Property" || parent.type === "MethodDefinition") {
60084 if (parent.kind === "constructor") {
60085 return "constructor";
60086 }
60087
60088 if (parent.kind === "get") {
60089 tokens.push("getter");
60090 } else if (parent.kind === "set") {
60091 tokens.push("setter");
60092 } else {
60093 tokens.push("method");
60094 }
60095 } else if (parent.type === "PropertyDefinition") {
60096 tokens.push("method");
60097 } else {
60098 if (node.type === "ArrowFunctionExpression") {
60099 tokens.push("arrow");
60100 }
60101
60102 tokens.push("function");
60103 }
60104
60105 if (parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") {
60106 if (!parent.computed && parent.key.type === "PrivateIdentifier") {
60107 tokens.push("#".concat(parent.key.name));
60108 } else {
60109 const name = getStaticPropertyName(parent);
60110
60111 if (name !== null) {
60112 tokens.push("'".concat(name, "'"));
60113 } else if (node.id) {
60114 tokens.push("'".concat(node.id.name, "'"));
60115 }
60116 }
60117 } else if (node.id) {
60118 tokens.push("'".concat(node.id.name, "'"));
60119 }
60120
60121 return tokens.join(" ");
60122 },
60123
60124 /**
60125 * Gets the location of the given function node for reporting.
60126 *
60127 * - `function foo() {}`
60128 * ^^^^^^^^^^^^
60129 * - `(function foo() {})`
60130 * ^^^^^^^^^^^^
60131 * - `(function() {})`
60132 * ^^^^^^^^
60133 * - `function* foo() {}`
60134 * ^^^^^^^^^^^^^
60135 * - `(function* foo() {})`
60136 * ^^^^^^^^^^^^^
60137 * - `(function*() {})`
60138 * ^^^^^^^^^
60139 * - `() => {}`
60140 * ^^
60141 * - `async () => {}`
60142 * ^^
60143 * - `({ foo: function foo() {} })`
60144 * ^^^^^^^^^^^^^^^^^
60145 * - `({ foo: function() {} })`
60146 * ^^^^^^^^^^^^^
60147 * - `({ ['foo']: function() {} })`
60148 * ^^^^^^^^^^^^^^^^^
60149 * - `({ [foo]: function() {} })`
60150 * ^^^^^^^^^^^^^^^
60151 * - `({ foo() {} })`
60152 * ^^^
60153 * - `({ foo: function* foo() {} })`
60154 * ^^^^^^^^^^^^^^^^^^
60155 * - `({ foo: function*() {} })`
60156 * ^^^^^^^^^^^^^^
60157 * - `({ ['foo']: function*() {} })`
60158 * ^^^^^^^^^^^^^^^^^^
60159 * - `({ [foo]: function*() {} })`
60160 * ^^^^^^^^^^^^^^^^
60161 * - `({ *foo() {} })`
60162 * ^^^^
60163 * - `({ foo: async function foo() {} })`
60164 * ^^^^^^^^^^^^^^^^^^^^^^^
60165 * - `({ foo: async function() {} })`
60166 * ^^^^^^^^^^^^^^^^^^^
60167 * - `({ ['foo']: async function() {} })`
60168 * ^^^^^^^^^^^^^^^^^^^^^^^
60169 * - `({ [foo]: async function() {} })`
60170 * ^^^^^^^^^^^^^^^^^^^^^
60171 * - `({ async foo() {} })`
60172 * ^^^^^^^^^
60173 * - `({ get foo() {} })`
60174 * ^^^^^^^
60175 * - `({ set foo(a) {} })`
60176 * ^^^^^^^
60177 * - `class A { constructor() {} }`
60178 * ^^^^^^^^^^^
60179 * - `class A { foo() {} }`
60180 * ^^^
60181 * - `class A { *foo() {} }`
60182 * ^^^^
60183 * - `class A { async foo() {} }`
60184 * ^^^^^^^^^
60185 * - `class A { ['foo']() {} }`
60186 * ^^^^^^^
60187 * - `class A { *['foo']() {} }`
60188 * ^^^^^^^^
60189 * - `class A { async ['foo']() {} }`
60190 * ^^^^^^^^^^^^^
60191 * - `class A { [foo]() {} }`
60192 * ^^^^^
60193 * - `class A { *[foo]() {} }`
60194 * ^^^^^^
60195 * - `class A { async [foo]() {} }`
60196 * ^^^^^^^^^^^
60197 * - `class A { get foo() {} }`
60198 * ^^^^^^^
60199 * - `class A { set foo(a) {} }`
60200 * ^^^^^^^
60201 * - `class A { static foo() {} }`
60202 * ^^^^^^^^^^
60203 * - `class A { static *foo() {} }`
60204 * ^^^^^^^^^^^
60205 * - `class A { static async foo() {} }`
60206 * ^^^^^^^^^^^^^^^^
60207 * - `class A { static get foo() {} }`
60208 * ^^^^^^^^^^^^^^
60209 * - `class A { static set foo(a) {} }`
60210 * ^^^^^^^^^^^^^^
60211 * - `class A { foo = function() {} }`
60212 * ^^^^^^^^^^^^^^
60213 * - `class A { static foo = function() {} }`
60214 * ^^^^^^^^^^^^^^^^^^^^^
60215 * - `class A { foo = (a, b) => {} }`
60216 * ^^^^^^
60217 * @param {ASTNode} node The function node to get.
60218 * @param {SourceCode} sourceCode The source code object to get tokens.
60219 * @returns {string} The location of the function node for reporting.
60220 */
60221 getFunctionHeadLoc(node, sourceCode) {
60222 const parent = node.parent;
60223 let start = null;
60224 let end = null;
60225
60226 if (parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") {
60227 start = parent.loc.start;
60228 end = getOpeningParenOfParams(node, sourceCode).loc.start;
60229 } else if (node.type === "ArrowFunctionExpression") {
60230 const arrowToken = sourceCode.getTokenBefore(node.body, isArrowToken);
60231 start = arrowToken.loc.start;
60232 end = arrowToken.loc.end;
60233 } else {
60234 start = node.loc.start;
60235 end = getOpeningParenOfParams(node, sourceCode).loc.start;
60236 }
60237
60238 return {
60239 start: Object.assign({}, start),
60240 end: Object.assign({}, end)
60241 };
60242 },
60243
60244 /**
60245 * Gets next location when the result is not out of bound, otherwise returns null.
60246 *
60247 * Assumptions:
60248 *
60249 * - The given location represents a valid location in the given source code.
60250 * - Columns are 0-based.
60251 * - Lines are 1-based.
60252 * - Column immediately after the last character in a line (not incl. linebreaks) is considered to be a valid location.
60253 * - If the source code ends with a linebreak, `sourceCode.lines` array will have an extra element (empty string) at the end.
60254 * The start (column 0) of that extra line is considered to be a valid location.
60255 *
60256 * Examples of successive locations (line, column):
60257 *
60258 * code: foo
60259 * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> null
60260 *
60261 * code: foo<LF>
60262 * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null
60263 *
60264 * code: foo<CR><LF>
60265 * locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null
60266 *
60267 * code: a<LF>b
60268 * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> null
60269 *
60270 * code: a<LF>b<LF>
60271 * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null
60272 *
60273 * code: a<CR><LF>b<CR><LF>
60274 * locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null
60275 *
60276 * code: a<LF><LF>
60277 * locations: (1, 0) -> (1, 1) -> (2, 0) -> (3, 0) -> null
60278 *
60279 * code: <LF>
60280 * locations: (1, 0) -> (2, 0) -> null
60281 *
60282 * code:
60283 * locations: (1, 0) -> null
60284 * @param {SourceCode} sourceCode The sourceCode
60285 * @param {{line: number, column: number}} location The location
60286 * @returns {{line: number, column: number} | null} Next location
60287 */
60288 getNextLocation(sourceCode, _ref) {
60289 let {
60290 line,
60291 column
60292 } = _ref;
60293
60294 if (column < sourceCode.lines[line - 1].length) {
60295 return {
60296 line,
60297 column: column + 1
60298 };
60299 }
60300
60301 if (line < sourceCode.lines.length) {
60302 return {
60303 line: line + 1,
60304 column: 0
60305 };
60306 }
60307
60308 return null;
60309 },
60310
60311 /**
60312 * Gets the parenthesized text of a node. This is similar to sourceCode.getText(node), but it also includes any parentheses
60313 * surrounding the node.
60314 * @param {SourceCode} sourceCode The source code object
60315 * @param {ASTNode} node An expression node
60316 * @returns {string} The text representing the node, with all surrounding parentheses included
60317 */
60318 getParenthesisedText(sourceCode, node) {
60319 let leftToken = sourceCode.getFirstToken(node);
60320 let rightToken = sourceCode.getLastToken(node);
60321
60322 while (sourceCode.getTokenBefore(leftToken) && sourceCode.getTokenBefore(leftToken).type === "Punctuator" && sourceCode.getTokenBefore(leftToken).value === "(" && sourceCode.getTokenAfter(rightToken) && sourceCode.getTokenAfter(rightToken).type === "Punctuator" && sourceCode.getTokenAfter(rightToken).value === ")") {
60323 leftToken = sourceCode.getTokenBefore(leftToken);
60324 rightToken = sourceCode.getTokenAfter(rightToken);
60325 }
60326
60327 return sourceCode.getText().slice(leftToken.range[0], rightToken.range[1]);
60328 },
60329
60330 /**
60331 * Determine if a node has a possibility to be an Error object
60332 * @param {ASTNode} node ASTNode to check
60333 * @returns {boolean} True if there is a chance it contains an Error obj
60334 */
60335 couldBeError(node) {
60336 switch (node.type) {
60337 case "Identifier":
60338 case "CallExpression":
60339 case "NewExpression":
60340 case "MemberExpression":
60341 case "TaggedTemplateExpression":
60342 case "YieldExpression":
60343 case "AwaitExpression":
60344 case "ChainExpression":
60345 return true;
60346 // possibly an error object.
60347
60348 case "AssignmentExpression":
60349 if (["=", "&&="].includes(node.operator)) {
60350 return module.exports.couldBeError(node.right);
60351 }
60352
60353 if (["||=", "??="].includes(node.operator)) {
60354 return module.exports.couldBeError(node.left) || module.exports.couldBeError(node.right);
60355 }
60356 /**
60357 * All other assignment operators are mathematical assignment operators (arithmetic or bitwise).
60358 * An assignment expression with a mathematical operator can either evaluate to a primitive value,
60359 * or throw, depending on the operands. Thus, it cannot evaluate to an `Error` object.
60360 */
60361
60362
60363 return false;
60364
60365 case "SequenceExpression":
60366 {
60367 const exprs = node.expressions;
60368 return exprs.length !== 0 && module.exports.couldBeError(exprs[exprs.length - 1]);
60369 }
60370
60371 case "LogicalExpression":
60372 /*
60373 * If the && operator short-circuits, the left side was falsy and therefore not an error, and if it
60374 * doesn't short-circuit, it takes the value from the right side, so the right side must always be
60375 * a plausible error. A future improvement could verify that the left side could be truthy by
60376 * excluding falsy literals.
60377 */
60378 if (node.operator === "&&") {
60379 return module.exports.couldBeError(node.right);
60380 }
60381
60382 return module.exports.couldBeError(node.left) || module.exports.couldBeError(node.right);
60383
60384 case "ConditionalExpression":
60385 return module.exports.couldBeError(node.consequent) || module.exports.couldBeError(node.alternate);
60386
60387 default:
60388 return false;
60389 }
60390 },
60391
60392 /**
60393 * Check if a given node is a numeric literal or not.
60394 * @param {ASTNode} node The node to check.
60395 * @returns {boolean} `true` if the node is a number or bigint literal.
60396 */
60397 isNumericLiteral(node) {
60398 return node.type === "Literal" && (typeof node.value === "number" || Boolean(node.bigint));
60399 },
60400
60401 /**
60402 * Determines whether two tokens can safely be placed next to each other without merging into a single token
60403 * @param {Token|string} leftValue The left token. If this is a string, it will be tokenized and the last token will be used.
60404 * @param {Token|string} rightValue The right token. If this is a string, it will be tokenized and the first token will be used.
60405 * @returns {boolean} If the tokens cannot be safely placed next to each other, returns `false`. If the tokens can be placed
60406 * next to each other, behavior is undefined (although it should return `true` in most cases).
60407 */
60408 canTokensBeAdjacent(leftValue, rightValue) {
60409 const espreeOptions = {
60410 ecmaVersion: espree.latestEcmaVersion,
60411 comment: true,
60412 range: true
60413 };
60414 let leftToken;
60415
60416 if (typeof leftValue === "string") {
60417 let tokens;
60418
60419 try {
60420 tokens = espree.tokenize(leftValue, espreeOptions);
60421 } catch {
60422 return false;
60423 }
60424
60425 const comments = tokens.comments;
60426 leftToken = tokens[tokens.length - 1];
60427
60428 if (comments.length) {
60429 const lastComment = comments[comments.length - 1];
60430
60431 if (lastComment.range[0] > leftToken.range[0]) {
60432 leftToken = lastComment;
60433 }
60434 }
60435 } else {
60436 leftToken = leftValue;
60437 }
60438
60439 if (leftToken.type === "Shebang") {
60440 return false;
60441 }
60442
60443 let rightToken;
60444
60445 if (typeof rightValue === "string") {
60446 let tokens;
60447
60448 try {
60449 tokens = espree.tokenize(rightValue, espreeOptions);
60450 } catch {
60451 return false;
60452 }
60453
60454 const comments = tokens.comments;
60455 rightToken = tokens[0];
60456
60457 if (comments.length) {
60458 const firstComment = comments[0];
60459
60460 if (firstComment.range[0] < rightToken.range[0]) {
60461 rightToken = firstComment;
60462 }
60463 }
60464 } else {
60465 rightToken = rightValue;
60466 }
60467
60468 if (leftToken.type === "Punctuator" || rightToken.type === "Punctuator") {
60469 if (leftToken.type === "Punctuator" && rightToken.type === "Punctuator") {
60470 const PLUS_TOKENS = new Set(["+", "++"]);
60471 const MINUS_TOKENS = new Set(["-", "--"]);
60472 return !(PLUS_TOKENS.has(leftToken.value) && PLUS_TOKENS.has(rightToken.value) || MINUS_TOKENS.has(leftToken.value) && MINUS_TOKENS.has(rightToken.value));
60473 }
60474
60475 if (leftToken.type === "Punctuator" && leftToken.value === "/") {
60476 return !["Block", "Line", "RegularExpression"].includes(rightToken.type);
60477 }
60478
60479 return true;
60480 }
60481
60482 if (leftToken.type === "String" || rightToken.type === "String" || leftToken.type === "Template" || rightToken.type === "Template") {
60483 return true;
60484 }
60485
60486 if (leftToken.type !== "Numeric" && rightToken.type === "Numeric" && rightToken.value.startsWith(".")) {
60487 return true;
60488 }
60489
60490 if (leftToken.type === "Block" || rightToken.type === "Block" || rightToken.type === "Line") {
60491 return true;
60492 }
60493
60494 if (rightToken.type === "PrivateIdentifier") {
60495 return true;
60496 }
60497
60498 return false;
60499 },
60500
60501 /**
60502 * Get the `loc` object of a given name in a `/*globals` directive comment.
60503 * @param {SourceCode} sourceCode The source code to convert index to loc.
60504 * @param {Comment} comment The `/*globals` directive comment which include the name.
60505 * @param {string} name The name to find.
60506 * @returns {SourceLocation} The `loc` object.
60507 */
60508 getNameLocationInGlobalDirectiveComment(sourceCode, comment, name) {
60509 const namePattern = new RegExp("[\\s,]".concat(escapeRegExp(name), "(?:$|[\\s,:])"), "gu"); // To ignore the first text "global".
60510
60511 namePattern.lastIndex = comment.value.indexOf("global") + 6; // Search a given variable name.
60512
60513 const match = namePattern.exec(comment.value); // Convert the index to loc.
60514
60515 const start = sourceCode.getLocFromIndex(comment.range[0] + "/*".length + (match ? match.index + 1 : 0));
60516 const end = {
60517 line: start.line,
60518 column: start.column + (match ? name.length : 1)
60519 };
60520 return {
60521 start,
60522 end
60523 };
60524 },
60525
60526 /**
60527 * Determines whether the given raw string contains an octal escape sequence
60528 * or a non-octal decimal escape sequence ("\8", "\9").
60529 *
60530 * "\1", "\2" ... "\7", "\8", "\9"
60531 * "\00", "\01" ... "\07", "\08", "\09"
60532 *
60533 * "\0", when not followed by a digit, is not an octal escape sequence.
60534 * @param {string} rawString A string in its raw representation.
60535 * @returns {boolean} `true` if the string contains at least one octal escape sequence
60536 * or at least one non-octal decimal escape sequence.
60537 */
60538 hasOctalOrNonOctalDecimalEscapeSequence(rawString) {
60539 return OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN.test(rawString);
60540 },
60541
60542 isLogicalExpression,
60543 isCoalesceExpression,
60544 isMixedLogicalAndCoalesceExpressions,
60545 isNullLiteral,
60546 getStaticStringValue,
60547 getStaticPropertyName,
60548 skipChainExpression,
60549 isSpecificId,
60550 isSpecificMemberAccess,
60551 equalLiteralValue,
60552 isSameReference,
60553 isLogicalAssignmentOperator,
60554 getSwitchCaseColonToken
60555 };
60556
60557 /***/ }),
60558 /* 549 */
60559 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
60560
60561 /*
60562 Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
60563
60564 Redistribution and use in source and binary forms, with or without
60565 modification, are permitted provided that the following conditions are met:
60566
60567 * Redistributions of source code must retain the above copyright
60568 notice, this list of conditions and the following disclaimer.
60569 * Redistributions in binary form must reproduce the above copyright
60570 notice, this list of conditions and the following disclaimer in the
60571 documentation and/or other materials provided with the distribution.
60572
60573 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
60574 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60575 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
60576 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
60577 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
60578 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
60579 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
60580 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60581 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
60582 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60583 */
60584 (function () {
60585 'use strict';
60586
60587 exports.ast = __webpack_require__(550);
60588 exports.code = __webpack_require__(551);
60589 exports.keyword = __webpack_require__(552);
60590 })();
60591 /* vim: set sw=4 ts=4 et tw=80 : */
60592
60593 /***/ }),
60594 /* 550 */
60595 /***/ ((module) => {
60596
60597 /*
60598 Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
60599
60600 Redistribution and use in source and binary forms, with or without
60601 modification, are permitted provided that the following conditions are met:
60602
60603 * Redistributions of source code must retain the above copyright
60604 notice, this list of conditions and the following disclaimer.
60605 * Redistributions in binary form must reproduce the above copyright
60606 notice, this list of conditions and the following disclaimer in the
60607 documentation and/or other materials provided with the distribution.
60608
60609 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
60610 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60611 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
60612 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
60613 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
60614 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
60615 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
60616 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60617 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
60618 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60619 */
60620 (function () {
60621 'use strict';
60622
60623 function isExpression(node) {
60624 if (node == null) {
60625 return false;
60626 }
60627
60628 switch (node.type) {
60629 case 'ArrayExpression':
60630 case 'AssignmentExpression':
60631 case 'BinaryExpression':
60632 case 'CallExpression':
60633 case 'ConditionalExpression':
60634 case 'FunctionExpression':
60635 case 'Identifier':
60636 case 'Literal':
60637 case 'LogicalExpression':
60638 case 'MemberExpression':
60639 case 'NewExpression':
60640 case 'ObjectExpression':
60641 case 'SequenceExpression':
60642 case 'ThisExpression':
60643 case 'UnaryExpression':
60644 case 'UpdateExpression':
60645 return true;
60646 }
60647
60648 return false;
60649 }
60650
60651 function isIterationStatement(node) {
60652 if (node == null) {
60653 return false;
60654 }
60655
60656 switch (node.type) {
60657 case 'DoWhileStatement':
60658 case 'ForInStatement':
60659 case 'ForStatement':
60660 case 'WhileStatement':
60661 return true;
60662 }
60663
60664 return false;
60665 }
60666
60667 function isStatement(node) {
60668 if (node == null) {
60669 return false;
60670 }
60671
60672 switch (node.type) {
60673 case 'BlockStatement':
60674 case 'BreakStatement':
60675 case 'ContinueStatement':
60676 case 'DebuggerStatement':
60677 case 'DoWhileStatement':
60678 case 'EmptyStatement':
60679 case 'ExpressionStatement':
60680 case 'ForInStatement':
60681 case 'ForStatement':
60682 case 'IfStatement':
60683 case 'LabeledStatement':
60684 case 'ReturnStatement':
60685 case 'SwitchStatement':
60686 case 'ThrowStatement':
60687 case 'TryStatement':
60688 case 'VariableDeclaration':
60689 case 'WhileStatement':
60690 case 'WithStatement':
60691 return true;
60692 }
60693
60694 return false;
60695 }
60696
60697 function isSourceElement(node) {
60698 return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
60699 }
60700
60701 function trailingStatement(node) {
60702 switch (node.type) {
60703 case 'IfStatement':
60704 if (node.alternate != null) {
60705 return node.alternate;
60706 }
60707
60708 return node.consequent;
60709
60710 case 'LabeledStatement':
60711 case 'ForStatement':
60712 case 'ForInStatement':
60713 case 'WhileStatement':
60714 case 'WithStatement':
60715 return node.body;
60716 }
60717
60718 return null;
60719 }
60720
60721 function isProblematicIfStatement(node) {
60722 var current;
60723
60724 if (node.type !== 'IfStatement') {
60725 return false;
60726 }
60727
60728 if (node.alternate == null) {
60729 return false;
60730 }
60731
60732 current = node.consequent;
60733
60734 do {
60735 if (current.type === 'IfStatement') {
60736 if (current.alternate == null) {
60737 return true;
60738 }
60739 }
60740
60741 current = trailingStatement(current);
60742 } while (current);
60743
60744 return false;
60745 }
60746
60747 module.exports = {
60748 isExpression: isExpression,
60749 isStatement: isStatement,
60750 isIterationStatement: isIterationStatement,
60751 isSourceElement: isSourceElement,
60752 isProblematicIfStatement: isProblematicIfStatement,
60753 trailingStatement: trailingStatement
60754 };
60755 })();
60756 /* vim: set sw=4 ts=4 et tw=80 : */
60757
60758 /***/ }),
60759 /* 551 */
60760 /***/ ((module) => {
60761
60762 /*
60763 Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
60764 Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
60765
60766 Redistribution and use in source and binary forms, with or without
60767 modification, are permitted provided that the following conditions are met:
60768
60769 * Redistributions of source code must retain the above copyright
60770 notice, this list of conditions and the following disclaimer.
60771 * Redistributions in binary form must reproduce the above copyright
60772 notice, this list of conditions and the following disclaimer in the
60773 documentation and/or other materials provided with the distribution.
60774
60775 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
60776 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60777 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
60778 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
60779 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
60780 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
60781 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
60782 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60783 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
60784 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60785 */
60786 (function () {
60787 'use strict';
60788
60789 var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`.
60790
60791 ES5Regex = {
60792 // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierStart:
60793 NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
60794 // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierPart:
60795 NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/
60796 };
60797 ES6Regex = {
60798 // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierStart:
60799 NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
60800 // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierPart:
60801 NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
60802 };
60803
60804 function isDecimalDigit(ch) {
60805 return 0x30 <= ch && ch <= 0x39; // 0..9
60806 }
60807
60808 function isHexDigit(ch) {
60809 return 0x30 <= ch && ch <= 0x39 || // 0..9
60810 0x61 <= ch && ch <= 0x66 || // a..f
60811 0x41 <= ch && ch <= 0x46; // A..F
60812 }
60813
60814 function isOctalDigit(ch) {
60815 return ch >= 0x30 && ch <= 0x37; // 0..7
60816 } // 7.2 White Space
60817
60818
60819 NON_ASCII_WHITESPACES = [0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
60820
60821 function isWhiteSpace(ch) {
60822 return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
60823 } // 7.3 Line Terminators
60824
60825
60826 function isLineTerminator(ch) {
60827 return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
60828 } // 7.6 Identifier Names and Identifiers
60829
60830
60831 function fromCodePoint(cp) {
60832 if (cp <= 0xFFFF) {
60833 return String.fromCharCode(cp);
60834 }
60835
60836 var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
60837 var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
60838 return cu1 + cu2;
60839 }
60840
60841 IDENTIFIER_START = new Array(0x80);
60842
60843 for (ch = 0; ch < 0x80; ++ch) {
60844 IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
60845 ch >= 0x41 && ch <= 0x5A || // A..Z
60846 ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
60847 }
60848
60849 IDENTIFIER_PART = new Array(0x80);
60850
60851 for (ch = 0; ch < 0x80; ++ch) {
60852 IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
60853 ch >= 0x41 && ch <= 0x5A || // A..Z
60854 ch >= 0x30 && ch <= 0x39 || // 0..9
60855 ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
60856 }
60857
60858 function isIdentifierStartES5(ch) {
60859 return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
60860 }
60861
60862 function isIdentifierPartES5(ch) {
60863 return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
60864 }
60865
60866 function isIdentifierStartES6(ch) {
60867 return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
60868 }
60869
60870 function isIdentifierPartES6(ch) {
60871 return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
60872 }
60873
60874 module.exports = {
60875 isDecimalDigit: isDecimalDigit,
60876 isHexDigit: isHexDigit,
60877 isOctalDigit: isOctalDigit,
60878 isWhiteSpace: isWhiteSpace,
60879 isLineTerminator: isLineTerminator,
60880 isIdentifierStartES5: isIdentifierStartES5,
60881 isIdentifierPartES5: isIdentifierPartES5,
60882 isIdentifierStartES6: isIdentifierStartES6,
60883 isIdentifierPartES6: isIdentifierPartES6
60884 };
60885 })();
60886 /* vim: set sw=4 ts=4 et tw=80 : */
60887
60888 /***/ }),
60889 /* 552 */
60890 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
60891
60892 /*
60893 Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
60894
60895 Redistribution and use in source and binary forms, with or without
60896 modification, are permitted provided that the following conditions are met:
60897
60898 * Redistributions of source code must retain the above copyright
60899 notice, this list of conditions and the following disclaimer.
60900 * Redistributions in binary form must reproduce the above copyright
60901 notice, this list of conditions and the following disclaimer in the
60902 documentation and/or other materials provided with the distribution.
60903
60904 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
60905 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60906 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
60907 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
60908 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
60909 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
60910 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
60911 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60912 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
60913 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60914 */
60915 (function () {
60916 'use strict';
60917
60918 var code = __webpack_require__(551);
60919
60920 function isStrictModeReservedWordES6(id) {
60921 switch (id) {
60922 case 'implements':
60923 case 'interface':
60924 case 'package':
60925 case 'private':
60926 case 'protected':
60927 case 'public':
60928 case 'static':
60929 case 'let':
60930 return true;
60931
60932 default:
60933 return false;
60934 }
60935 }
60936
60937 function isKeywordES5(id, strict) {
60938 // yield should not be treated as keyword under non-strict mode.
60939 if (!strict && id === 'yield') {
60940 return false;
60941 }
60942
60943 return isKeywordES6(id, strict);
60944 }
60945
60946 function isKeywordES6(id, strict) {
60947 if (strict && isStrictModeReservedWordES6(id)) {
60948 return true;
60949 }
60950
60951 switch (id.length) {
60952 case 2:
60953 return id === 'if' || id === 'in' || id === 'do';
60954
60955 case 3:
60956 return id === 'var' || id === 'for' || id === 'new' || id === 'try';
60957
60958 case 4:
60959 return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
60960
60961 case 5:
60962 return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
60963
60964 case 6:
60965 return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
60966
60967 case 7:
60968 return id === 'default' || id === 'finally' || id === 'extends';
60969
60970 case 8:
60971 return id === 'function' || id === 'continue' || id === 'debugger';
60972
60973 case 10:
60974 return id === 'instanceof';
60975
60976 default:
60977 return false;
60978 }
60979 }
60980
60981 function isReservedWordES5(id, strict) {
60982 return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
60983 }
60984
60985 function isReservedWordES6(id, strict) {
60986 return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
60987 }
60988
60989 function isRestrictedWord(id) {
60990 return id === 'eval' || id === 'arguments';
60991 }
60992
60993 function isIdentifierNameES5(id) {
60994 var i, iz, ch;
60995
60996 if (id.length === 0) {
60997 return false;
60998 }
60999
61000 ch = id.charCodeAt(0);
61001
61002 if (!code.isIdentifierStartES5(ch)) {
61003 return false;
61004 }
61005
61006 for (i = 1, iz = id.length; i < iz; ++i) {
61007 ch = id.charCodeAt(i);
61008
61009 if (!code.isIdentifierPartES5(ch)) {
61010 return false;
61011 }
61012 }
61013
61014 return true;
61015 }
61016
61017 function decodeUtf16(lead, trail) {
61018 return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
61019 }
61020
61021 function isIdentifierNameES6(id) {
61022 var i, iz, ch, lowCh, check;
61023
61024 if (id.length === 0) {
61025 return false;
61026 }
61027
61028 check = code.isIdentifierStartES6;
61029
61030 for (i = 0, iz = id.length; i < iz; ++i) {
61031 ch = id.charCodeAt(i);
61032
61033 if (0xD800 <= ch && ch <= 0xDBFF) {
61034 ++i;
61035
61036 if (i >= iz) {
61037 return false;
61038 }
61039
61040 lowCh = id.charCodeAt(i);
61041
61042 if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
61043 return false;
61044 }
61045
61046 ch = decodeUtf16(ch, lowCh);
61047 }
61048
61049 if (!check(ch)) {
61050 return false;
61051 }
61052
61053 check = code.isIdentifierPartES6;
61054 }
61055
61056 return true;
61057 }
61058
61059 function isIdentifierES5(id, strict) {
61060 return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
61061 }
61062
61063 function isIdentifierES6(id, strict) {
61064 return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
61065 }
61066
61067 module.exports = {
61068 isKeywordES5: isKeywordES5,
61069 isKeywordES6: isKeywordES6,
61070 isReservedWordES5: isReservedWordES5,
61071 isReservedWordES6: isReservedWordES6,
61072 isRestrictedWord: isRestrictedWord,
61073 isIdentifierNameES5: isIdentifierNameES5,
61074 isIdentifierNameES6: isIdentifierNameES6,
61075 isIdentifierES5: isIdentifierES5,
61076 isIdentifierES6: isIdentifierES6
61077 };
61078 })();
61079 /* vim: set sw=4 ts=4 et tw=80 : */
61080
61081 /***/ }),
61082 /* 553 */
61083 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
61084
61085 "use strict";
61086 /**
61087 * @fileoverview Rule to enforce linebreaks after open and before close array brackets
61088 * @author Jan Peer Stöcklmair <https://github.com/JPeer264>
61089 */
61090
61091
61092 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
61093 // Rule Definition
61094 //------------------------------------------------------------------------------
61095
61096
61097 module.exports = {
61098 meta: {
61099 type: "layout",
61100 docs: {
61101 description: "enforce linebreaks after opening and before closing array brackets",
61102 recommended: false,
61103 url: "https://eslint.org/docs/rules/array-bracket-newline"
61104 },
61105 fixable: "whitespace",
61106 schema: [{
61107 oneOf: [{
61108 enum: ["always", "never", "consistent"]
61109 }, {
61110 type: "object",
61111 properties: {
61112 multiline: {
61113 type: "boolean"
61114 },
61115 minItems: {
61116 type: ["integer", "null"],
61117 minimum: 0
61118 }
61119 },
61120 additionalProperties: false
61121 }]
61122 }],
61123 messages: {
61124 unexpectedOpeningLinebreak: "There should be no linebreak after '['.",
61125 unexpectedClosingLinebreak: "There should be no linebreak before ']'.",
61126 missingOpeningLinebreak: "A linebreak is required after '['.",
61127 missingClosingLinebreak: "A linebreak is required before ']'."
61128 }
61129 },
61130
61131 create(context) {
61132 const sourceCode = context.getSourceCode(); //----------------------------------------------------------------------
61133 // Helpers
61134 //----------------------------------------------------------------------
61135
61136 /**
61137 * Normalizes a given option value.
61138 * @param {string|Object|undefined} option An option value to parse.
61139 * @returns {{multiline: boolean, minItems: number}} Normalized option object.
61140 */
61141
61142 function normalizeOptionValue(option) {
61143 let consistent = false;
61144 let multiline = false;
61145 let minItems = 0;
61146
61147 if (option) {
61148 if (option === "consistent") {
61149 consistent = true;
61150 minItems = Number.POSITIVE_INFINITY;
61151 } else if (option === "always" || option.minItems === 0) {
61152 minItems = 0;
61153 } else if (option === "never") {
61154 minItems = Number.POSITIVE_INFINITY;
61155 } else {
61156 multiline = Boolean(option.multiline);
61157 minItems = option.minItems || Number.POSITIVE_INFINITY;
61158 }
61159 } else {
61160 consistent = false;
61161 multiline = true;
61162 minItems = Number.POSITIVE_INFINITY;
61163 }
61164
61165 return {
61166 consistent,
61167 multiline,
61168 minItems
61169 };
61170 }
61171 /**
61172 * Normalizes a given option value.
61173 * @param {string|Object|undefined} options An option value to parse.
61174 * @returns {{ArrayExpression: {multiline: boolean, minItems: number}, ArrayPattern: {multiline: boolean, minItems: number}}} Normalized option object.
61175 */
61176
61177
61178 function normalizeOptions(options) {
61179 const value = normalizeOptionValue(options);
61180 return {
61181 ArrayExpression: value,
61182 ArrayPattern: value
61183 };
61184 }
61185 /**
61186 * Reports that there shouldn't be a linebreak after the first token
61187 * @param {ASTNode} node The node to report in the event of an error.
61188 * @param {Token} token The token to use for the report.
61189 * @returns {void}
61190 */
61191
61192
61193 function reportNoBeginningLinebreak(node, token) {
61194 context.report({
61195 node,
61196 loc: token.loc,
61197 messageId: "unexpectedOpeningLinebreak",
61198
61199 fix(fixer) {
61200 const nextToken = sourceCode.getTokenAfter(token, {
61201 includeComments: true
61202 });
61203
61204 if (astUtils.isCommentToken(nextToken)) {
61205 return null;
61206 }
61207
61208 return fixer.removeRange([token.range[1], nextToken.range[0]]);
61209 }
61210
61211 });
61212 }
61213 /**
61214 * Reports that there shouldn't be a linebreak before the last token
61215 * @param {ASTNode} node The node to report in the event of an error.
61216 * @param {Token} token The token to use for the report.
61217 * @returns {void}
61218 */
61219
61220
61221 function reportNoEndingLinebreak(node, token) {
61222 context.report({
61223 node,
61224 loc: token.loc,
61225 messageId: "unexpectedClosingLinebreak",
61226
61227 fix(fixer) {
61228 const previousToken = sourceCode.getTokenBefore(token, {
61229 includeComments: true
61230 });
61231
61232 if (astUtils.isCommentToken(previousToken)) {
61233 return null;
61234 }
61235
61236 return fixer.removeRange([previousToken.range[1], token.range[0]]);
61237 }
61238
61239 });
61240 }
61241 /**
61242 * Reports that there should be a linebreak after the first token
61243 * @param {ASTNode} node The node to report in the event of an error.
61244 * @param {Token} token The token to use for the report.
61245 * @returns {void}
61246 */
61247
61248
61249 function reportRequiredBeginningLinebreak(node, token) {
61250 context.report({
61251 node,
61252 loc: token.loc,
61253 messageId: "missingOpeningLinebreak",
61254
61255 fix(fixer) {
61256 return fixer.insertTextAfter(token, "\n");
61257 }
61258
61259 });
61260 }
61261 /**
61262 * Reports that there should be a linebreak before the last token
61263 * @param {ASTNode} node The node to report in the event of an error.
61264 * @param {Token} token The token to use for the report.
61265 * @returns {void}
61266 */
61267
61268
61269 function reportRequiredEndingLinebreak(node, token) {
61270 context.report({
61271 node,
61272 loc: token.loc,
61273 messageId: "missingClosingLinebreak",
61274
61275 fix(fixer) {
61276 return fixer.insertTextBefore(token, "\n");
61277 }
61278
61279 });
61280 }
61281 /**
61282 * Reports a given node if it violated this rule.
61283 * @param {ASTNode} node A node to check. This is an ArrayExpression node or an ArrayPattern node.
61284 * @returns {void}
61285 */
61286
61287
61288 function check(node) {
61289 const elements = node.elements;
61290 const normalizedOptions = normalizeOptions(context.options[0]);
61291 const options = normalizedOptions[node.type];
61292 const openBracket = sourceCode.getFirstToken(node);
61293 const closeBracket = sourceCode.getLastToken(node);
61294 const firstIncComment = sourceCode.getTokenAfter(openBracket, {
61295 includeComments: true
61296 });
61297 const lastIncComment = sourceCode.getTokenBefore(closeBracket, {
61298 includeComments: true
61299 });
61300 const first = sourceCode.getTokenAfter(openBracket);
61301 const last = sourceCode.getTokenBefore(closeBracket);
61302 const needsLinebreaks = elements.length >= options.minItems || options.multiline && elements.length > 0 && firstIncComment.loc.start.line !== lastIncComment.loc.end.line || elements.length === 0 && firstIncComment.type === "Block" && firstIncComment.loc.start.line !== lastIncComment.loc.end.line && firstIncComment === lastIncComment || options.consistent && openBracket.loc.end.line !== first.loc.start.line;
61303 /*
61304 * Use tokens or comments to check multiline or not.
61305 * But use only tokens to check whether linebreaks are needed.
61306 * This allows:
61307 * var arr = [ // eslint-disable-line foo
61308 * 'a'
61309 * ]
61310 */
61311
61312 if (needsLinebreaks) {
61313 if (astUtils.isTokenOnSameLine(openBracket, first)) {
61314 reportRequiredBeginningLinebreak(node, openBracket);
61315 }
61316
61317 if (astUtils.isTokenOnSameLine(last, closeBracket)) {
61318 reportRequiredEndingLinebreak(node, closeBracket);
61319 }
61320 } else {
61321 if (!astUtils.isTokenOnSameLine(openBracket, first)) {
61322 reportNoBeginningLinebreak(node, openBracket);
61323 }
61324
61325 if (!astUtils.isTokenOnSameLine(last, closeBracket)) {
61326 reportNoEndingLinebreak(node, closeBracket);
61327 }
61328 }
61329 } //----------------------------------------------------------------------
61330 // Public
61331 //----------------------------------------------------------------------
61332
61333
61334 return {
61335 ArrayPattern: check,
61336 ArrayExpression: check
61337 };
61338 }
61339
61340 };
61341
61342 /***/ }),
61343 /* 554 */
61344 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
61345
61346 "use strict";
61347 /**
61348 * @fileoverview Disallows or enforces spaces inside of array brackets.
61349 * @author Jamund Ferguson
61350 */
61351
61352
61353 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
61354 // Rule Definition
61355 //------------------------------------------------------------------------------
61356
61357
61358 module.exports = {
61359 meta: {
61360 type: "layout",
61361 docs: {
61362 description: "enforce consistent spacing inside array brackets",
61363 recommended: false,
61364 url: "https://eslint.org/docs/rules/array-bracket-spacing"
61365 },
61366 fixable: "whitespace",
61367 schema: [{
61368 enum: ["always", "never"]
61369 }, {
61370 type: "object",
61371 properties: {
61372 singleValue: {
61373 type: "boolean"
61374 },
61375 objectsInArrays: {
61376 type: "boolean"
61377 },
61378 arraysInArrays: {
61379 type: "boolean"
61380 }
61381 },
61382 additionalProperties: false
61383 }],
61384 messages: {
61385 unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.",
61386 unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.",
61387 missingSpaceAfter: "A space is required after '{{tokenValue}}'.",
61388 missingSpaceBefore: "A space is required before '{{tokenValue}}'."
61389 }
61390 },
61391
61392 create(context) {
61393 const spaced = context.options[0] === "always",
61394 sourceCode = context.getSourceCode();
61395 /**
61396 * Determines whether an option is set, relative to the spacing option.
61397 * If spaced is "always", then check whether option is set to false.
61398 * If spaced is "never", then check whether option is set to true.
61399 * @param {Object} option The option to exclude.
61400 * @returns {boolean} Whether or not the property is excluded.
61401 */
61402
61403 function isOptionSet(option) {
61404 return context.options[1] ? context.options[1][option] === !spaced : false;
61405 }
61406
61407 const options = {
61408 spaced,
61409 singleElementException: isOptionSet("singleValue"),
61410 objectsInArraysException: isOptionSet("objectsInArrays"),
61411 arraysInArraysException: isOptionSet("arraysInArrays")
61412 }; //--------------------------------------------------------------------------
61413 // Helpers
61414 //--------------------------------------------------------------------------
61415
61416 /**
61417 * Reports that there shouldn't be a space after the first token
61418 * @param {ASTNode} node The node to report in the event of an error.
61419 * @param {Token} token The token to use for the report.
61420 * @returns {void}
61421 */
61422
61423 function reportNoBeginningSpace(node, token) {
61424 const nextToken = sourceCode.getTokenAfter(token);
61425 context.report({
61426 node,
61427 loc: {
61428 start: token.loc.end,
61429 end: nextToken.loc.start
61430 },
61431 messageId: "unexpectedSpaceAfter",
61432 data: {
61433 tokenValue: token.value
61434 },
61435
61436 fix(fixer) {
61437 return fixer.removeRange([token.range[1], nextToken.range[0]]);
61438 }
61439
61440 });
61441 }
61442 /**
61443 * Reports that there shouldn't be a space before the last token
61444 * @param {ASTNode} node The node to report in the event of an error.
61445 * @param {Token} token The token to use for the report.
61446 * @returns {void}
61447 */
61448
61449
61450 function reportNoEndingSpace(node, token) {
61451 const previousToken = sourceCode.getTokenBefore(token);
61452 context.report({
61453 node,
61454 loc: {
61455 start: previousToken.loc.end,
61456 end: token.loc.start
61457 },
61458 messageId: "unexpectedSpaceBefore",
61459 data: {
61460 tokenValue: token.value
61461 },
61462
61463 fix(fixer) {
61464 return fixer.removeRange([previousToken.range[1], token.range[0]]);
61465 }
61466
61467 });
61468 }
61469 /**
61470 * Reports that there should be a space after the first token
61471 * @param {ASTNode} node The node to report in the event of an error.
61472 * @param {Token} token The token to use for the report.
61473 * @returns {void}
61474 */
61475
61476
61477 function reportRequiredBeginningSpace(node, token) {
61478 context.report({
61479 node,
61480 loc: token.loc,
61481 messageId: "missingSpaceAfter",
61482 data: {
61483 tokenValue: token.value
61484 },
61485
61486 fix(fixer) {
61487 return fixer.insertTextAfter(token, " ");
61488 }
61489
61490 });
61491 }
61492 /**
61493 * Reports that there should be a space before the last token
61494 * @param {ASTNode} node The node to report in the event of an error.
61495 * @param {Token} token The token to use for the report.
61496 * @returns {void}
61497 */
61498
61499
61500 function reportRequiredEndingSpace(node, token) {
61501 context.report({
61502 node,
61503 loc: token.loc,
61504 messageId: "missingSpaceBefore",
61505 data: {
61506 tokenValue: token.value
61507 },
61508
61509 fix(fixer) {
61510 return fixer.insertTextBefore(token, " ");
61511 }
61512
61513 });
61514 }
61515 /**
61516 * Determines if a node is an object type
61517 * @param {ASTNode} node The node to check.
61518 * @returns {boolean} Whether or not the node is an object type.
61519 */
61520
61521
61522 function isObjectType(node) {
61523 return node && (node.type === "ObjectExpression" || node.type === "ObjectPattern");
61524 }
61525 /**
61526 * Determines if a node is an array type
61527 * @param {ASTNode} node The node to check.
61528 * @returns {boolean} Whether or not the node is an array type.
61529 */
61530
61531
61532 function isArrayType(node) {
61533 return node && (node.type === "ArrayExpression" || node.type === "ArrayPattern");
61534 }
61535 /**
61536 * Validates the spacing around array brackets
61537 * @param {ASTNode} node The node we're checking for spacing
61538 * @returns {void}
61539 */
61540
61541
61542 function validateArraySpacing(node) {
61543 if (options.spaced && node.elements.length === 0) {
61544 return;
61545 }
61546
61547 const first = sourceCode.getFirstToken(node),
61548 second = sourceCode.getFirstToken(node, 1),
61549 last = node.typeAnnotation ? sourceCode.getTokenBefore(node.typeAnnotation) : sourceCode.getLastToken(node),
61550 penultimate = sourceCode.getTokenBefore(last),
61551 firstElement = node.elements[0],
61552 lastElement = node.elements[node.elements.length - 1];
61553 const openingBracketMustBeSpaced = options.objectsInArraysException && isObjectType(firstElement) || options.arraysInArraysException && isArrayType(firstElement) || options.singleElementException && node.elements.length === 1 ? !options.spaced : options.spaced;
61554 const closingBracketMustBeSpaced = options.objectsInArraysException && isObjectType(lastElement) || options.arraysInArraysException && isArrayType(lastElement) || options.singleElementException && node.elements.length === 1 ? !options.spaced : options.spaced;
61555
61556 if (astUtils.isTokenOnSameLine(first, second)) {
61557 if (openingBracketMustBeSpaced && !sourceCode.isSpaceBetweenTokens(first, second)) {
61558 reportRequiredBeginningSpace(node, first);
61559 }
61560
61561 if (!openingBracketMustBeSpaced && sourceCode.isSpaceBetweenTokens(first, second)) {
61562 reportNoBeginningSpace(node, first);
61563 }
61564 }
61565
61566 if (first !== penultimate && astUtils.isTokenOnSameLine(penultimate, last)) {
61567 if (closingBracketMustBeSpaced && !sourceCode.isSpaceBetweenTokens(penultimate, last)) {
61568 reportRequiredEndingSpace(node, last);
61569 }
61570
61571 if (!closingBracketMustBeSpaced && sourceCode.isSpaceBetweenTokens(penultimate, last)) {
61572 reportNoEndingSpace(node, last);
61573 }
61574 }
61575 } //--------------------------------------------------------------------------
61576 // Public
61577 //--------------------------------------------------------------------------
61578
61579
61580 return {
61581 ArrayPattern: validateArraySpacing,
61582 ArrayExpression: validateArraySpacing
61583 };
61584 }
61585
61586 };
61587
61588 /***/ }),
61589 /* 555 */
61590 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
61591
61592 "use strict";
61593 /**
61594 * @fileoverview Rule to enforce return statements in callbacks of array's methods
61595 * @author Toru Nagashima
61596 */
61597 //------------------------------------------------------------------------------
61598 // Requirements
61599 //------------------------------------------------------------------------------
61600
61601 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
61602 // Helpers
61603 //------------------------------------------------------------------------------
61604
61605
61606 const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u;
61607 const TARGET_METHODS = /^(?:every|filter|find(?:Index)?|flatMap|forEach|map|reduce(?:Right)?|some|sort)$/u;
61608 /**
61609 * Checks a given code path segment is reachable.
61610 * @param {CodePathSegment} segment A segment to check.
61611 * @returns {boolean} `true` if the segment is reachable.
61612 */
61613
61614 function isReachable(segment) {
61615 return segment.reachable;
61616 }
61617 /**
61618 * Checks a given node is a member access which has the specified name's
61619 * property.
61620 * @param {ASTNode} node A node to check.
61621 * @returns {boolean} `true` if the node is a member access which has
61622 * the specified name's property. The node may be a `(Chain|Member)Expression` node.
61623 */
61624
61625
61626 function isTargetMethod(node) {
61627 return astUtils.isSpecificMemberAccess(node, null, TARGET_METHODS);
61628 }
61629 /**
61630 * Returns a human-legible description of an array method
61631 * @param {string} arrayMethodName A method name to fully qualify
61632 * @returns {string} the method name prefixed with `Array.` if it is a class method,
61633 * or else `Array.prototype.` if it is an instance method.
61634 */
61635
61636
61637 function fullMethodName(arrayMethodName) {
61638 if (["from", "of", "isArray"].includes(arrayMethodName)) {
61639 return "Array.".concat(arrayMethodName);
61640 }
61641
61642 return "Array.prototype.".concat(arrayMethodName);
61643 }
61644 /**
61645 * Checks whether or not a given node is a function expression which is the
61646 * callback of an array method, returning the method name.
61647 * @param {ASTNode} node A node to check. This is one of
61648 * FunctionExpression or ArrowFunctionExpression.
61649 * @returns {string} The method name if the node is a callback method,
61650 * null otherwise.
61651 */
61652
61653
61654 function getArrayMethodName(node) {
61655 let currentNode = node;
61656
61657 while (currentNode) {
61658 const parent = currentNode.parent;
61659
61660 switch (parent.type) {
61661 /*
61662 * Looks up the destination. e.g.,
61663 * foo.every(nativeFoo || function foo() { ... });
61664 */
61665 case "LogicalExpression":
61666 case "ConditionalExpression":
61667 case "ChainExpression":
61668 currentNode = parent;
61669 break;
61670
61671 /*
61672 * If the upper function is IIFE, checks the destination of the return value.
61673 * e.g.
61674 * foo.every((function() {
61675 * // setup...
61676 * return function callback() { ... };
61677 * })());
61678 */
61679
61680 case "ReturnStatement":
61681 {
61682 const func = astUtils.getUpperFunction(parent);
61683
61684 if (func === null || !astUtils.isCallee(func)) {
61685 return null;
61686 }
61687
61688 currentNode = func.parent;
61689 break;
61690 }
61691
61692 /*
61693 * e.g.
61694 * Array.from([], function() {});
61695 * list.every(function() {});
61696 */
61697
61698 case "CallExpression":
61699 if (astUtils.isArrayFromMethod(parent.callee)) {
61700 if (parent.arguments.length >= 2 && parent.arguments[1] === currentNode) {
61701 return "from";
61702 }
61703 }
61704
61705 if (isTargetMethod(parent.callee)) {
61706 if (parent.arguments.length >= 1 && parent.arguments[0] === currentNode) {
61707 return astUtils.getStaticPropertyName(parent.callee);
61708 }
61709 }
61710
61711 return null;
61712 // Otherwise this node is not target.
61713
61714 default:
61715 return null;
61716 }
61717 }
61718 /* istanbul ignore next: unreachable */
61719
61720
61721 return null;
61722 } //------------------------------------------------------------------------------
61723 // Rule Definition
61724 //------------------------------------------------------------------------------
61725
61726
61727 module.exports = {
61728 meta: {
61729 type: "problem",
61730 docs: {
61731 description: "enforce `return` statements in callbacks of array methods",
61732 recommended: false,
61733 url: "https://eslint.org/docs/rules/array-callback-return"
61734 },
61735 schema: [{
61736 type: "object",
61737 properties: {
61738 allowImplicit: {
61739 type: "boolean",
61740 default: false
61741 },
61742 checkForEach: {
61743 type: "boolean",
61744 default: false
61745 }
61746 },
61747 additionalProperties: false
61748 }],
61749 messages: {
61750 expectedAtEnd: "{{arrayMethodName}}() expects a value to be returned at the end of {{name}}.",
61751 expectedInside: "{{arrayMethodName}}() expects a return value from {{name}}.",
61752 expectedReturnValue: "{{arrayMethodName}}() expects a return value from {{name}}.",
61753 expectedNoReturnValue: "{{arrayMethodName}}() expects no useless return value from {{name}}."
61754 }
61755 },
61756
61757 create(context) {
61758 const options = context.options[0] || {
61759 allowImplicit: false,
61760 checkForEach: false
61761 };
61762 const sourceCode = context.getSourceCode();
61763 let funcInfo = {
61764 arrayMethodName: null,
61765 upper: null,
61766 codePath: null,
61767 hasReturn: false,
61768 shouldCheck: false,
61769 node: null
61770 };
61771 /**
61772 * Checks whether or not the last code path segment is reachable.
61773 * Then reports this function if the segment is reachable.
61774 *
61775 * If the last code path segment is reachable, there are paths which are not
61776 * returned or thrown.
61777 * @param {ASTNode} node A node to check.
61778 * @returns {void}
61779 */
61780
61781 function checkLastSegment(node) {
61782 if (!funcInfo.shouldCheck) {
61783 return;
61784 }
61785
61786 let messageId = null;
61787
61788 if (funcInfo.arrayMethodName === "forEach") {
61789 if (options.checkForEach && node.type === "ArrowFunctionExpression" && node.expression) {
61790 messageId = "expectedNoReturnValue";
61791 }
61792 } else {
61793 if (node.body.type === "BlockStatement" && funcInfo.codePath.currentSegments.some(isReachable)) {
61794 messageId = funcInfo.hasReturn ? "expectedAtEnd" : "expectedInside";
61795 }
61796 }
61797
61798 if (messageId) {
61799 const name = astUtils.getFunctionNameWithKind(node);
61800 context.report({
61801 node,
61802 loc: astUtils.getFunctionHeadLoc(node, sourceCode),
61803 messageId,
61804 data: {
61805 name,
61806 arrayMethodName: fullMethodName(funcInfo.arrayMethodName)
61807 }
61808 });
61809 }
61810 }
61811
61812 return {
61813 // Stacks this function's information.
61814 onCodePathStart(codePath, node) {
61815 let methodName = null;
61816
61817 if (TARGET_NODE_TYPE.test(node.type)) {
61818 methodName = getArrayMethodName(node);
61819 }
61820
61821 funcInfo = {
61822 arrayMethodName: methodName,
61823 upper: funcInfo,
61824 codePath,
61825 hasReturn: false,
61826 shouldCheck: methodName && !node.async && !node.generator,
61827 node
61828 };
61829 },
61830
61831 // Pops this function's information.
61832 onCodePathEnd() {
61833 funcInfo = funcInfo.upper;
61834 },
61835
61836 // Checks the return statement is valid.
61837 ReturnStatement(node) {
61838 if (!funcInfo.shouldCheck) {
61839 return;
61840 }
61841
61842 funcInfo.hasReturn = true;
61843 let messageId = null;
61844
61845 if (funcInfo.arrayMethodName === "forEach") {
61846 // if checkForEach: true, returning a value at any path inside a forEach is not allowed
61847 if (options.checkForEach && node.argument) {
61848 messageId = "expectedNoReturnValue";
61849 }
61850 } else {
61851 // if allowImplicit: false, should also check node.argument
61852 if (!options.allowImplicit && !node.argument) {
61853 messageId = "expectedReturnValue";
61854 }
61855 }
61856
61857 if (messageId) {
61858 context.report({
61859 node,
61860 messageId,
61861 data: {
61862 name: astUtils.getFunctionNameWithKind(funcInfo.node),
61863 arrayMethodName: fullMethodName(funcInfo.arrayMethodName)
61864 }
61865 });
61866 }
61867 },
61868
61869 // Reports a given function if the last path is reachable.
61870 "FunctionExpression:exit": checkLastSegment,
61871 "ArrowFunctionExpression:exit": checkLastSegment
61872 };
61873 }
61874
61875 };
61876
61877 /***/ }),
61878 /* 556 */
61879 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
61880
61881 "use strict";
61882 /**
61883 * @fileoverview Rule to enforce line breaks after each array element
61884 * @author Jan Peer Stöcklmair <https://github.com/JPeer264>
61885 */
61886
61887
61888 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
61889 // Rule Definition
61890 //------------------------------------------------------------------------------
61891
61892
61893 module.exports = {
61894 meta: {
61895 type: "layout",
61896 docs: {
61897 description: "enforce line breaks after each array element",
61898 recommended: false,
61899 url: "https://eslint.org/docs/rules/array-element-newline"
61900 },
61901 fixable: "whitespace",
61902 schema: {
61903 definitions: {
61904 basicConfig: {
61905 oneOf: [{
61906 enum: ["always", "never", "consistent"]
61907 }, {
61908 type: "object",
61909 properties: {
61910 multiline: {
61911 type: "boolean"
61912 },
61913 minItems: {
61914 type: ["integer", "null"],
61915 minimum: 0
61916 }
61917 },
61918 additionalProperties: false
61919 }]
61920 }
61921 },
61922 items: [{
61923 oneOf: [{
61924 $ref: "#/definitions/basicConfig"
61925 }, {
61926 type: "object",
61927 properties: {
61928 ArrayExpression: {
61929 $ref: "#/definitions/basicConfig"
61930 },
61931 ArrayPattern: {
61932 $ref: "#/definitions/basicConfig"
61933 }
61934 },
61935 additionalProperties: false,
61936 minProperties: 1
61937 }]
61938 }]
61939 },
61940 messages: {
61941 unexpectedLineBreak: "There should be no linebreak here.",
61942 missingLineBreak: "There should be a linebreak after this element."
61943 }
61944 },
61945
61946 create(context) {
61947 const sourceCode = context.getSourceCode(); //----------------------------------------------------------------------
61948 // Helpers
61949 //----------------------------------------------------------------------
61950
61951 /**
61952 * Normalizes a given option value.
61953 * @param {string|Object|undefined} providedOption An option value to parse.
61954 * @returns {{multiline: boolean, minItems: number}} Normalized option object.
61955 */
61956
61957 function normalizeOptionValue(providedOption) {
61958 let consistent = false;
61959 let multiline = false;
61960 let minItems;
61961 const option = providedOption || "always";
61962
61963 if (!option || option === "always" || option.minItems === 0) {
61964 minItems = 0;
61965 } else if (option === "never") {
61966 minItems = Number.POSITIVE_INFINITY;
61967 } else if (option === "consistent") {
61968 consistent = true;
61969 minItems = Number.POSITIVE_INFINITY;
61970 } else {
61971 multiline = Boolean(option.multiline);
61972 minItems = option.minItems || Number.POSITIVE_INFINITY;
61973 }
61974
61975 return {
61976 consistent,
61977 multiline,
61978 minItems
61979 };
61980 }
61981 /**
61982 * Normalizes a given option value.
61983 * @param {string|Object|undefined} options An option value to parse.
61984 * @returns {{ArrayExpression: {multiline: boolean, minItems: number}, ArrayPattern: {multiline: boolean, minItems: number}}} Normalized option object.
61985 */
61986
61987
61988 function normalizeOptions(options) {
61989 if (options && (options.ArrayExpression || options.ArrayPattern)) {
61990 let expressionOptions, patternOptions;
61991
61992 if (options.ArrayExpression) {
61993 expressionOptions = normalizeOptionValue(options.ArrayExpression);
61994 }
61995
61996 if (options.ArrayPattern) {
61997 patternOptions = normalizeOptionValue(options.ArrayPattern);
61998 }
61999
62000 return {
62001 ArrayExpression: expressionOptions,
62002 ArrayPattern: patternOptions
62003 };
62004 }
62005
62006 const value = normalizeOptionValue(options);
62007 return {
62008 ArrayExpression: value,
62009 ArrayPattern: value
62010 };
62011 }
62012 /**
62013 * Reports that there shouldn't be a line break after the first token
62014 * @param {Token} token The token to use for the report.
62015 * @returns {void}
62016 */
62017
62018
62019 function reportNoLineBreak(token) {
62020 const tokenBefore = sourceCode.getTokenBefore(token, {
62021 includeComments: true
62022 });
62023 context.report({
62024 loc: {
62025 start: tokenBefore.loc.end,
62026 end: token.loc.start
62027 },
62028 messageId: "unexpectedLineBreak",
62029
62030 fix(fixer) {
62031 if (astUtils.isCommentToken(tokenBefore)) {
62032 return null;
62033 }
62034
62035 if (!astUtils.isTokenOnSameLine(tokenBefore, token)) {
62036 return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " ");
62037 }
62038 /*
62039 * This will check if the comma is on the same line as the next element
62040 * Following array:
62041 * [
62042 * 1
62043 * , 2
62044 * , 3
62045 * ]
62046 *
62047 * will be fixed to:
62048 * [
62049 * 1, 2, 3
62050 * ]
62051 */
62052
62053
62054 const twoTokensBefore = sourceCode.getTokenBefore(tokenBefore, {
62055 includeComments: true
62056 });
62057
62058 if (astUtils.isCommentToken(twoTokensBefore)) {
62059 return null;
62060 }
62061
62062 return fixer.replaceTextRange([twoTokensBefore.range[1], tokenBefore.range[0]], "");
62063 }
62064
62065 });
62066 }
62067 /**
62068 * Reports that there should be a line break after the first token
62069 * @param {Token} token The token to use for the report.
62070 * @returns {void}
62071 */
62072
62073
62074 function reportRequiredLineBreak(token) {
62075 const tokenBefore = sourceCode.getTokenBefore(token, {
62076 includeComments: true
62077 });
62078 context.report({
62079 loc: {
62080 start: tokenBefore.loc.end,
62081 end: token.loc.start
62082 },
62083 messageId: "missingLineBreak",
62084
62085 fix(fixer) {
62086 return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n");
62087 }
62088
62089 });
62090 }
62091 /**
62092 * Reports a given node if it violated this rule.
62093 * @param {ASTNode} node A node to check. This is an ObjectExpression node or an ObjectPattern node.
62094 * @returns {void}
62095 */
62096
62097
62098 function check(node) {
62099 const elements = node.elements;
62100 const normalizedOptions = normalizeOptions(context.options[0]);
62101 const options = normalizedOptions[node.type];
62102
62103 if (!options) {
62104 return;
62105 }
62106
62107 let elementBreak = false;
62108 /*
62109 * MULTILINE: true
62110 * loop through every element and check
62111 * if at least one element has linebreaks inside
62112 * this ensures that following is not valid (due to elements are on the same line):
62113 *
62114 * [
62115 * 1,
62116 * 2,
62117 * 3
62118 * ]
62119 */
62120
62121 if (options.multiline) {
62122 elementBreak = elements.filter(element => element !== null).some(element => element.loc.start.line !== element.loc.end.line);
62123 }
62124
62125 const linebreaksCount = node.elements.map((element, i) => {
62126 const previousElement = elements[i - 1];
62127
62128 if (i === 0 || element === null || previousElement === null) {
62129 return false;
62130 }
62131
62132 const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken);
62133 const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken);
62134 const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
62135 return !astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement);
62136 }).filter(isBreak => isBreak === true).length;
62137 const needsLinebreaks = elements.length >= options.minItems || options.multiline && elementBreak || options.consistent && linebreaksCount > 0 && linebreaksCount < node.elements.length;
62138 elements.forEach((element, i) => {
62139 const previousElement = elements[i - 1];
62140
62141 if (i === 0 || element === null || previousElement === null) {
62142 return;
62143 }
62144
62145 const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken);
62146 const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken);
62147 const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
62148
62149 if (needsLinebreaks) {
62150 if (astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) {
62151 reportRequiredLineBreak(firstTokenOfCurrentElement);
62152 }
62153 } else {
62154 if (!astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) {
62155 reportNoLineBreak(firstTokenOfCurrentElement);
62156 }
62157 }
62158 });
62159 } //----------------------------------------------------------------------
62160 // Public
62161 //----------------------------------------------------------------------
62162
62163
62164 return {
62165 ArrayPattern: check,
62166 ArrayExpression: check
62167 };
62168 }
62169
62170 };
62171
62172 /***/ }),
62173 /* 557 */
62174 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
62175
62176 "use strict";
62177 /**
62178 * @fileoverview Rule to require braces in arrow function body.
62179 * @author Alberto Rodríguez
62180 */
62181 //------------------------------------------------------------------------------
62182 // Requirements
62183 //------------------------------------------------------------------------------
62184
62185 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
62186 // Rule Definition
62187 //------------------------------------------------------------------------------
62188
62189
62190 module.exports = {
62191 meta: {
62192 type: "suggestion",
62193 docs: {
62194 description: "require braces around arrow function bodies",
62195 recommended: false,
62196 url: "https://eslint.org/docs/rules/arrow-body-style"
62197 },
62198 schema: {
62199 anyOf: [{
62200 type: "array",
62201 items: [{
62202 enum: ["always", "never"]
62203 }],
62204 minItems: 0,
62205 maxItems: 1
62206 }, {
62207 type: "array",
62208 items: [{
62209 enum: ["as-needed"]
62210 }, {
62211 type: "object",
62212 properties: {
62213 requireReturnForObjectLiteral: {
62214 type: "boolean"
62215 }
62216 },
62217 additionalProperties: false
62218 }],
62219 minItems: 0,
62220 maxItems: 2
62221 }]
62222 },
62223 fixable: "code",
62224 messages: {
62225 unexpectedOtherBlock: "Unexpected block statement surrounding arrow body.",
62226 unexpectedEmptyBlock: "Unexpected block statement surrounding arrow body; put a value of `undefined` immediately after the `=>`.",
62227 unexpectedObjectBlock: "Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`.",
62228 unexpectedSingleBlock: "Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`.",
62229 expectedBlock: "Expected block statement surrounding arrow body."
62230 }
62231 },
62232
62233 create(context) {
62234 const options = context.options;
62235 const always = options[0] === "always";
62236 const asNeeded = !options[0] || options[0] === "as-needed";
62237 const never = options[0] === "never";
62238 const requireReturnForObjectLiteral = options[1] && options[1].requireReturnForObjectLiteral;
62239 const sourceCode = context.getSourceCode();
62240 let funcInfo = null;
62241 /**
62242 * Checks whether the given node has ASI problem or not.
62243 * @param {Token} token The token to check.
62244 * @returns {boolean} `true` if it changes semantics if `;` or `}` followed by the token are removed.
62245 */
62246
62247 function hasASIProblem(token) {
62248 return token && token.type === "Punctuator" && /^[([/`+-]/u.test(token.value);
62249 }
62250 /**
62251 * Gets the closing parenthesis by the given node.
62252 * @param {ASTNode} node first node after an opening parenthesis.
62253 * @returns {Token} The found closing parenthesis token.
62254 */
62255
62256
62257 function findClosingParen(node) {
62258 let nodeToCheck = node;
62259
62260 while (!astUtils.isParenthesised(sourceCode, nodeToCheck)) {
62261 nodeToCheck = nodeToCheck.parent;
62262 }
62263
62264 return sourceCode.getTokenAfter(nodeToCheck);
62265 }
62266 /**
62267 * Check whether the node is inside of a for loop's init
62268 * @param {ASTNode} node node is inside for loop
62269 * @returns {boolean} `true` if the node is inside of a for loop, else `false`
62270 */
62271
62272
62273 function isInsideForLoopInitializer(node) {
62274 if (node && node.parent) {
62275 if (node.parent.type === "ForStatement" && node.parent.init === node) {
62276 return true;
62277 }
62278
62279 return isInsideForLoopInitializer(node.parent);
62280 }
62281
62282 return false;
62283 }
62284 /**
62285 * Determines whether a arrow function body needs braces
62286 * @param {ASTNode} node The arrow function node.
62287 * @returns {void}
62288 */
62289
62290
62291 function validate(node) {
62292 const arrowBody = node.body;
62293
62294 if (arrowBody.type === "BlockStatement") {
62295 const blockBody = arrowBody.body;
62296
62297 if (blockBody.length !== 1 && !never) {
62298 return;
62299 }
62300
62301 if (asNeeded && requireReturnForObjectLiteral && blockBody[0].type === "ReturnStatement" && blockBody[0].argument && blockBody[0].argument.type === "ObjectExpression") {
62302 return;
62303 }
62304
62305 if (never || asNeeded && blockBody[0].type === "ReturnStatement") {
62306 let messageId;
62307
62308 if (blockBody.length === 0) {
62309 messageId = "unexpectedEmptyBlock";
62310 } else if (blockBody.length > 1) {
62311 messageId = "unexpectedOtherBlock";
62312 } else if (blockBody[0].argument === null) {
62313 messageId = "unexpectedSingleBlock";
62314 } else if (astUtils.isOpeningBraceToken(sourceCode.getFirstToken(blockBody[0], {
62315 skip: 1
62316 }))) {
62317 messageId = "unexpectedObjectBlock";
62318 } else {
62319 messageId = "unexpectedSingleBlock";
62320 }
62321
62322 context.report({
62323 node,
62324 loc: arrowBody.loc,
62325 messageId,
62326
62327 fix(fixer) {
62328 const fixes = [];
62329
62330 if (blockBody.length !== 1 || blockBody[0].type !== "ReturnStatement" || !blockBody[0].argument || hasASIProblem(sourceCode.getTokenAfter(arrowBody))) {
62331 return fixes;
62332 }
62333
62334 const openingBrace = sourceCode.getFirstToken(arrowBody);
62335 const closingBrace = sourceCode.getLastToken(arrowBody);
62336 const firstValueToken = sourceCode.getFirstToken(blockBody[0], 1);
62337 const lastValueToken = sourceCode.getLastToken(blockBody[0]);
62338 const commentsExist = sourceCode.commentsExistBetween(openingBrace, firstValueToken) || sourceCode.commentsExistBetween(lastValueToken, closingBrace);
62339 /*
62340 * Remove tokens around the return value.
62341 * If comments don't exist, remove extra spaces as well.
62342 */
62343
62344 if (commentsExist) {
62345 fixes.push(fixer.remove(openingBrace), fixer.remove(closingBrace), fixer.remove(sourceCode.getTokenAfter(openingBrace)) // return keyword
62346 );
62347 } else {
62348 fixes.push(fixer.removeRange([openingBrace.range[0], firstValueToken.range[0]]), fixer.removeRange([lastValueToken.range[1], closingBrace.range[1]]));
62349 }
62350 /*
62351 * If the first token of the return value is `{` or the return value is a sequence expression,
62352 * enclose the return value by parentheses to avoid syntax error.
62353 */
62354
62355
62356 if (astUtils.isOpeningBraceToken(firstValueToken) || blockBody[0].argument.type === "SequenceExpression" || funcInfo.hasInOperator && isInsideForLoopInitializer(node)) {
62357 if (!astUtils.isParenthesised(sourceCode, blockBody[0].argument)) {
62358 fixes.push(fixer.insertTextBefore(firstValueToken, "("), fixer.insertTextAfter(lastValueToken, ")"));
62359 }
62360 }
62361 /*
62362 * If the last token of the return statement is semicolon, remove it.
62363 * Non-block arrow body is an expression, not a statement.
62364 */
62365
62366
62367 if (astUtils.isSemicolonToken(lastValueToken)) {
62368 fixes.push(fixer.remove(lastValueToken));
62369 }
62370
62371 return fixes;
62372 }
62373
62374 });
62375 }
62376 } else {
62377 if (always || asNeeded && requireReturnForObjectLiteral && arrowBody.type === "ObjectExpression") {
62378 context.report({
62379 node,
62380 loc: arrowBody.loc,
62381 messageId: "expectedBlock",
62382
62383 fix(fixer) {
62384 const fixes = [];
62385 const arrowToken = sourceCode.getTokenBefore(arrowBody, astUtils.isArrowToken);
62386 const [firstTokenAfterArrow, secondTokenAfterArrow] = sourceCode.getTokensAfter(arrowToken, {
62387 count: 2
62388 });
62389 const lastToken = sourceCode.getLastToken(node);
62390 let parenthesisedObjectLiteral = null;
62391
62392 if (astUtils.isOpeningParenToken(firstTokenAfterArrow) && astUtils.isOpeningBraceToken(secondTokenAfterArrow)) {
62393 const braceNode = sourceCode.getNodeByRangeIndex(secondTokenAfterArrow.range[0]);
62394
62395 if (braceNode.type === "ObjectExpression") {
62396 parenthesisedObjectLiteral = braceNode;
62397 }
62398 } // If the value is object literal, remove parentheses which were forced by syntax.
62399
62400
62401 if (parenthesisedObjectLiteral) {
62402 const openingParenToken = firstTokenAfterArrow;
62403 const openingBraceToken = secondTokenAfterArrow;
62404
62405 if (astUtils.isTokenOnSameLine(openingParenToken, openingBraceToken)) {
62406 fixes.push(fixer.replaceText(openingParenToken, "{return "));
62407 } else {
62408 // Avoid ASI
62409 fixes.push(fixer.replaceText(openingParenToken, "{"), fixer.insertTextBefore(openingBraceToken, "return "));
62410 } // Closing paren for the object doesn't have to be lastToken, e.g.: () => ({}).foo()
62411
62412
62413 fixes.push(fixer.remove(findClosingParen(parenthesisedObjectLiteral)));
62414 fixes.push(fixer.insertTextAfter(lastToken, "}"));
62415 } else {
62416 fixes.push(fixer.insertTextBefore(firstTokenAfterArrow, "{return "));
62417 fixes.push(fixer.insertTextAfter(lastToken, "}"));
62418 }
62419
62420 return fixes;
62421 }
62422
62423 });
62424 }
62425 }
62426 }
62427
62428 return {
62429 "BinaryExpression[operator='in']"() {
62430 let info = funcInfo;
62431
62432 while (info) {
62433 info.hasInOperator = true;
62434 info = info.upper;
62435 }
62436 },
62437
62438 ArrowFunctionExpression() {
62439 funcInfo = {
62440 upper: funcInfo,
62441 hasInOperator: false
62442 };
62443 },
62444
62445 "ArrowFunctionExpression:exit"(node) {
62446 validate(node);
62447 funcInfo = funcInfo.upper;
62448 }
62449
62450 };
62451 }
62452
62453 };
62454
62455 /***/ }),
62456 /* 558 */
62457 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
62458
62459 "use strict";
62460 /**
62461 * @fileoverview Rule to require parens in arrow function arguments.
62462 * @author Jxck
62463 */
62464 //------------------------------------------------------------------------------
62465 // Requirements
62466 //------------------------------------------------------------------------------
62467
62468 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
62469 // Helpers
62470 //------------------------------------------------------------------------------
62471
62472 /**
62473 * Determines if the given arrow function has block body.
62474 * @param {ASTNode} node `ArrowFunctionExpression` node.
62475 * @returns {boolean} `true` if the function has block body.
62476 */
62477
62478
62479 function hasBlockBody(node) {
62480 return node.body.type === "BlockStatement";
62481 } //------------------------------------------------------------------------------
62482 // Rule Definition
62483 //------------------------------------------------------------------------------
62484
62485
62486 module.exports = {
62487 meta: {
62488 type: "layout",
62489 docs: {
62490 description: "require parentheses around arrow function arguments",
62491 recommended: false,
62492 url: "https://eslint.org/docs/rules/arrow-parens"
62493 },
62494 fixable: "code",
62495 schema: [{
62496 enum: ["always", "as-needed"]
62497 }, {
62498 type: "object",
62499 properties: {
62500 requireForBlockBody: {
62501 type: "boolean",
62502 default: false
62503 }
62504 },
62505 additionalProperties: false
62506 }],
62507 messages: {
62508 unexpectedParens: "Unexpected parentheses around single function argument.",
62509 expectedParens: "Expected parentheses around arrow function argument.",
62510 unexpectedParensInline: "Unexpected parentheses around single function argument having a body with no curly braces.",
62511 expectedParensBlock: "Expected parentheses around arrow function argument having a body with curly braces."
62512 }
62513 },
62514
62515 create(context) {
62516 const asNeeded = context.options[0] === "as-needed";
62517 const requireForBlockBody = asNeeded && context.options[1] && context.options[1].requireForBlockBody === true;
62518 const sourceCode = context.getSourceCode();
62519 /**
62520 * Finds opening paren of parameters for the given arrow function, if it exists.
62521 * It is assumed that the given arrow function has exactly one parameter.
62522 * @param {ASTNode} node `ArrowFunctionExpression` node.
62523 * @returns {Token|null} the opening paren, or `null` if the given arrow function doesn't have parens of parameters.
62524 */
62525
62526 function findOpeningParenOfParams(node) {
62527 const tokenBeforeParams = sourceCode.getTokenBefore(node.params[0]);
62528
62529 if (tokenBeforeParams && astUtils.isOpeningParenToken(tokenBeforeParams) && node.range[0] <= tokenBeforeParams.range[0]) {
62530 return tokenBeforeParams;
62531 }
62532
62533 return null;
62534 }
62535 /**
62536 * Finds closing paren of parameters for the given arrow function.
62537 * It is assumed that the given arrow function has parens of parameters and that it has exactly one parameter.
62538 * @param {ASTNode} node `ArrowFunctionExpression` node.
62539 * @returns {Token} the closing paren of parameters.
62540 */
62541
62542
62543 function getClosingParenOfParams(node) {
62544 return sourceCode.getTokenAfter(node.params[0], astUtils.isClosingParenToken);
62545 }
62546 /**
62547 * Determines whether the given arrow function has comments inside parens of parameters.
62548 * It is assumed that the given arrow function has parens of parameters.
62549 * @param {ASTNode} node `ArrowFunctionExpression` node.
62550 * @param {Token} openingParen Opening paren of parameters.
62551 * @returns {boolean} `true` if the function has at least one comment inside of parens of parameters.
62552 */
62553
62554
62555 function hasCommentsInParensOfParams(node, openingParen) {
62556 return sourceCode.commentsExistBetween(openingParen, getClosingParenOfParams(node));
62557 }
62558 /**
62559 * Determines whether the given arrow function has unexpected tokens before opening paren of parameters,
62560 * in which case it will be assumed that the existing parens of parameters are necessary.
62561 * Only tokens within the range of the arrow function (tokens that are part of the arrow function) are taken into account.
62562 * Example: <T>(a) => b
62563 * @param {ASTNode} node `ArrowFunctionExpression` node.
62564 * @param {Token} openingParen Opening paren of parameters.
62565 * @returns {boolean} `true` if the function has at least one unexpected token.
62566 */
62567
62568
62569 function hasUnexpectedTokensBeforeOpeningParen(node, openingParen) {
62570 const expectedCount = node.async ? 1 : 0;
62571 return sourceCode.getFirstToken(node, {
62572 skip: expectedCount
62573 }) !== openingParen;
62574 }
62575
62576 return {
62577 "ArrowFunctionExpression[params.length=1]"(node) {
62578 const shouldHaveParens = !asNeeded || requireForBlockBody && hasBlockBody(node);
62579 const openingParen = findOpeningParenOfParams(node);
62580 const hasParens = openingParen !== null;
62581 const [param] = node.params;
62582
62583 if (shouldHaveParens && !hasParens) {
62584 context.report({
62585 node,
62586 messageId: requireForBlockBody ? "expectedParensBlock" : "expectedParens",
62587 loc: param.loc,
62588
62589 *fix(fixer) {
62590 yield fixer.insertTextBefore(param, "(");
62591 yield fixer.insertTextAfter(param, ")");
62592 }
62593
62594 });
62595 }
62596
62597 if (!shouldHaveParens && hasParens && param.type === "Identifier" && !param.typeAnnotation && !node.returnType && !hasCommentsInParensOfParams(node, openingParen) && !hasUnexpectedTokensBeforeOpeningParen(node, openingParen)) {
62598 context.report({
62599 node,
62600 messageId: requireForBlockBody ? "unexpectedParensInline" : "unexpectedParens",
62601 loc: param.loc,
62602
62603 *fix(fixer) {
62604 const tokenBeforeOpeningParen = sourceCode.getTokenBefore(openingParen);
62605 const closingParen = getClosingParenOfParams(node);
62606
62607 if (tokenBeforeOpeningParen && tokenBeforeOpeningParen.range[1] === openingParen.range[0] && !astUtils.canTokensBeAdjacent(tokenBeforeOpeningParen, sourceCode.getFirstToken(param))) {
62608 yield fixer.insertTextBefore(openingParen, " ");
62609 } // remove parens, whitespace inside parens, and possible trailing comma
62610
62611
62612 yield fixer.removeRange([openingParen.range[0], param.range[0]]);
62613 yield fixer.removeRange([param.range[1], closingParen.range[1]]);
62614 }
62615
62616 });
62617 }
62618 }
62619
62620 };
62621 }
62622
62623 };
62624
62625 /***/ }),
62626 /* 559 */
62627 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
62628
62629 "use strict";
62630 /**
62631 * @fileoverview Rule to define spacing before/after arrow function's arrow.
62632 * @author Jxck
62633 */
62634 //------------------------------------------------------------------------------
62635 // Requirements
62636 //------------------------------------------------------------------------------
62637
62638 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
62639 // Rule Definition
62640 //------------------------------------------------------------------------------
62641
62642
62643 module.exports = {
62644 meta: {
62645 type: "layout",
62646 docs: {
62647 description: "enforce consistent spacing before and after the arrow in arrow functions",
62648 recommended: false,
62649 url: "https://eslint.org/docs/rules/arrow-spacing"
62650 },
62651 fixable: "whitespace",
62652 schema: [{
62653 type: "object",
62654 properties: {
62655 before: {
62656 type: "boolean",
62657 default: true
62658 },
62659 after: {
62660 type: "boolean",
62661 default: true
62662 }
62663 },
62664 additionalProperties: false
62665 }],
62666 messages: {
62667 expectedBefore: "Missing space before =>.",
62668 unexpectedBefore: "Unexpected space before =>.",
62669 expectedAfter: "Missing space after =>.",
62670 unexpectedAfter: "Unexpected space after =>."
62671 }
62672 },
62673
62674 create(context) {
62675 // merge rules with default
62676 const rule = Object.assign({}, context.options[0]);
62677 rule.before = rule.before !== false;
62678 rule.after = rule.after !== false;
62679 const sourceCode = context.getSourceCode();
62680 /**
62681 * Get tokens of arrow(`=>`) and before/after arrow.
62682 * @param {ASTNode} node The arrow function node.
62683 * @returns {Object} Tokens of arrow and before/after arrow.
62684 */
62685
62686 function getTokens(node) {
62687 const arrow = sourceCode.getTokenBefore(node.body, astUtils.isArrowToken);
62688 return {
62689 before: sourceCode.getTokenBefore(arrow),
62690 arrow,
62691 after: sourceCode.getTokenAfter(arrow)
62692 };
62693 }
62694 /**
62695 * Count spaces before/after arrow(`=>`) token.
62696 * @param {Object} tokens Tokens before/after arrow.
62697 * @returns {Object} count of space before/after arrow.
62698 */
62699
62700
62701 function countSpaces(tokens) {
62702 const before = tokens.arrow.range[0] - tokens.before.range[1];
62703 const after = tokens.after.range[0] - tokens.arrow.range[1];
62704 return {
62705 before,
62706 after
62707 };
62708 }
62709 /**
62710 * Determines whether space(s) before after arrow(`=>`) is satisfy rule.
62711 * if before/after value is `true`, there should be space(s).
62712 * if before/after value is `false`, there should be no space.
62713 * @param {ASTNode} node The arrow function node.
62714 * @returns {void}
62715 */
62716
62717
62718 function spaces(node) {
62719 const tokens = getTokens(node);
62720 const countSpace = countSpaces(tokens);
62721
62722 if (rule.before) {
62723 // should be space(s) before arrow
62724 if (countSpace.before === 0) {
62725 context.report({
62726 node: tokens.before,
62727 messageId: "expectedBefore",
62728
62729 fix(fixer) {
62730 return fixer.insertTextBefore(tokens.arrow, " ");
62731 }
62732
62733 });
62734 }
62735 } else {
62736 // should be no space before arrow
62737 if (countSpace.before > 0) {
62738 context.report({
62739 node: tokens.before,
62740 messageId: "unexpectedBefore",
62741
62742 fix(fixer) {
62743 return fixer.removeRange([tokens.before.range[1], tokens.arrow.range[0]]);
62744 }
62745
62746 });
62747 }
62748 }
62749
62750 if (rule.after) {
62751 // should be space(s) after arrow
62752 if (countSpace.after === 0) {
62753 context.report({
62754 node: tokens.after,
62755 messageId: "expectedAfter",
62756
62757 fix(fixer) {
62758 return fixer.insertTextAfter(tokens.arrow, " ");
62759 }
62760
62761 });
62762 }
62763 } else {
62764 // should be no space after arrow
62765 if (countSpace.after > 0) {
62766 context.report({
62767 node: tokens.after,
62768 messageId: "unexpectedAfter",
62769
62770 fix(fixer) {
62771 return fixer.removeRange([tokens.arrow.range[1], tokens.after.range[0]]);
62772 }
62773
62774 });
62775 }
62776 }
62777 }
62778
62779 return {
62780 ArrowFunctionExpression: spaces
62781 };
62782 }
62783
62784 };
62785
62786 /***/ }),
62787 /* 560 */
62788 /***/ ((module) => {
62789
62790 "use strict";
62791 /**
62792 * @fileoverview Rule to check for "block scoped" variables by binding context
62793 * @author Matt DuVall <http://www.mattduvall.com>
62794 */
62795 //------------------------------------------------------------------------------
62796 // Rule Definition
62797 //------------------------------------------------------------------------------
62798
62799 module.exports = {
62800 meta: {
62801 type: "suggestion",
62802 docs: {
62803 description: "enforce the use of variables within the scope they are defined",
62804 recommended: false,
62805 url: "https://eslint.org/docs/rules/block-scoped-var"
62806 },
62807 schema: [],
62808 messages: {
62809 outOfScope: "'{{name}}' used outside of binding context."
62810 }
62811 },
62812
62813 create(context) {
62814 let stack = [];
62815 /**
62816 * Makes a block scope.
62817 * @param {ASTNode} node A node of a scope.
62818 * @returns {void}
62819 */
62820
62821 function enterScope(node) {
62822 stack.push(node.range);
62823 }
62824 /**
62825 * Pops the last block scope.
62826 * @returns {void}
62827 */
62828
62829
62830 function exitScope() {
62831 stack.pop();
62832 }
62833 /**
62834 * Reports a given reference.
62835 * @param {eslint-scope.Reference} reference A reference to report.
62836 * @returns {void}
62837 */
62838
62839
62840 function report(reference) {
62841 const identifier = reference.identifier;
62842 context.report({
62843 node: identifier,
62844 messageId: "outOfScope",
62845 data: {
62846 name: identifier.name
62847 }
62848 });
62849 }
62850 /**
62851 * Finds and reports references which are outside of valid scopes.
62852 * @param {ASTNode} node A node to get variables.
62853 * @returns {void}
62854 */
62855
62856
62857 function checkForVariables(node) {
62858 if (node.kind !== "var") {
62859 return;
62860 } // Defines a predicate to check whether or not a given reference is outside of valid scope.
62861
62862
62863 const scopeRange = stack[stack.length - 1];
62864 /**
62865 * Check if a reference is out of scope
62866 * @param {ASTNode} reference node to examine
62867 * @returns {boolean} True is its outside the scope
62868 * @private
62869 */
62870
62871 function isOutsideOfScope(reference) {
62872 const idRange = reference.identifier.range;
62873 return idRange[0] < scopeRange[0] || idRange[1] > scopeRange[1];
62874 } // Gets declared variables, and checks its references.
62875
62876
62877 const variables = context.getDeclaredVariables(node);
62878
62879 for (let i = 0; i < variables.length; ++i) {
62880 // Reports.
62881 variables[i].references.filter(isOutsideOfScope).forEach(report);
62882 }
62883 }
62884
62885 return {
62886 Program(node) {
62887 stack = [node.range];
62888 },
62889
62890 // Manages scopes.
62891 BlockStatement: enterScope,
62892 "BlockStatement:exit": exitScope,
62893 ForStatement: enterScope,
62894 "ForStatement:exit": exitScope,
62895 ForInStatement: enterScope,
62896 "ForInStatement:exit": exitScope,
62897 ForOfStatement: enterScope,
62898 "ForOfStatement:exit": exitScope,
62899 SwitchStatement: enterScope,
62900 "SwitchStatement:exit": exitScope,
62901 CatchClause: enterScope,
62902 "CatchClause:exit": exitScope,
62903 StaticBlock: enterScope,
62904 "StaticBlock:exit": exitScope,
62905 // Finds and reports references which are outside of valid scope.
62906 VariableDeclaration: checkForVariables
62907 };
62908 }
62909
62910 };
62911
62912 /***/ }),
62913 /* 561 */
62914 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
62915
62916 "use strict";
62917 /**
62918 * @fileoverview A rule to disallow or enforce spaces inside of single line blocks.
62919 * @author Toru Nagashima
62920 */
62921
62922
62923 const util = __webpack_require__(548); //------------------------------------------------------------------------------
62924 // Rule Definition
62925 //------------------------------------------------------------------------------
62926
62927
62928 module.exports = {
62929 meta: {
62930 type: "layout",
62931 docs: {
62932 description: "disallow or enforce spaces inside of blocks after opening block and before closing block",
62933 recommended: false,
62934 url: "https://eslint.org/docs/rules/block-spacing"
62935 },
62936 fixable: "whitespace",
62937 schema: [{
62938 enum: ["always", "never"]
62939 }],
62940 messages: {
62941 missing: "Requires a space {{location}} '{{token}}'.",
62942 extra: "Unexpected space(s) {{location}} '{{token}}'."
62943 }
62944 },
62945
62946 create(context) {
62947 const always = context.options[0] !== "never",
62948 messageId = always ? "missing" : "extra",
62949 sourceCode = context.getSourceCode();
62950 /**
62951 * Gets the open brace token from a given node.
62952 * @param {ASTNode} node A BlockStatement/StaticBlock/SwitchStatement node to get.
62953 * @returns {Token} The token of the open brace.
62954 */
62955
62956 function getOpenBrace(node) {
62957 if (node.type === "SwitchStatement") {
62958 if (node.cases.length > 0) {
62959 return sourceCode.getTokenBefore(node.cases[0]);
62960 }
62961
62962 return sourceCode.getLastToken(node, 1);
62963 }
62964
62965 if (node.type === "StaticBlock") {
62966 return sourceCode.getFirstToken(node, {
62967 skip: 1
62968 }); // skip the `static` token
62969 } // "BlockStatement"
62970
62971
62972 return sourceCode.getFirstToken(node);
62973 }
62974 /**
62975 * Checks whether or not:
62976 * - given tokens are on same line.
62977 * - there is/isn't a space between given tokens.
62978 * @param {Token} left A token to check.
62979 * @param {Token} right The token which is next to `left`.
62980 * @returns {boolean}
62981 * When the option is `"always"`, `true` if there are one or more spaces between given tokens.
62982 * When the option is `"never"`, `true` if there are not any spaces between given tokens.
62983 * If given tokens are not on same line, it's always `true`.
62984 */
62985
62986
62987 function isValid(left, right) {
62988 return !util.isTokenOnSameLine(left, right) || sourceCode.isSpaceBetweenTokens(left, right) === always;
62989 }
62990 /**
62991 * Checks and reports invalid spacing style inside braces.
62992 * @param {ASTNode} node A BlockStatement/StaticBlock/SwitchStatement node to check.
62993 * @returns {void}
62994 */
62995
62996
62997 function checkSpacingInsideBraces(node) {
62998 // Gets braces and the first/last token of content.
62999 const openBrace = getOpenBrace(node);
63000 const closeBrace = sourceCode.getLastToken(node);
63001 const firstToken = sourceCode.getTokenAfter(openBrace, {
63002 includeComments: true
63003 });
63004 const lastToken = sourceCode.getTokenBefore(closeBrace, {
63005 includeComments: true
63006 }); // Skip if the node is invalid or empty.
63007
63008 if (openBrace.type !== "Punctuator" || openBrace.value !== "{" || closeBrace.type !== "Punctuator" || closeBrace.value !== "}" || firstToken === closeBrace) {
63009 return;
63010 } // Skip line comments for option never
63011
63012
63013 if (!always && firstToken.type === "Line") {
63014 return;
63015 } // Check.
63016
63017
63018 if (!isValid(openBrace, firstToken)) {
63019 let loc = openBrace.loc;
63020
63021 if (messageId === "extra") {
63022 loc = {
63023 start: openBrace.loc.end,
63024 end: firstToken.loc.start
63025 };
63026 }
63027
63028 context.report({
63029 node,
63030 loc,
63031 messageId,
63032 data: {
63033 location: "after",
63034 token: openBrace.value
63035 },
63036
63037 fix(fixer) {
63038 if (always) {
63039 return fixer.insertTextBefore(firstToken, " ");
63040 }
63041
63042 return fixer.removeRange([openBrace.range[1], firstToken.range[0]]);
63043 }
63044
63045 });
63046 }
63047
63048 if (!isValid(lastToken, closeBrace)) {
63049 let loc = closeBrace.loc;
63050
63051 if (messageId === "extra") {
63052 loc = {
63053 start: lastToken.loc.end,
63054 end: closeBrace.loc.start
63055 };
63056 }
63057
63058 context.report({
63059 node,
63060 loc,
63061 messageId,
63062 data: {
63063 location: "before",
63064 token: closeBrace.value
63065 },
63066
63067 fix(fixer) {
63068 if (always) {
63069 return fixer.insertTextAfter(lastToken, " ");
63070 }
63071
63072 return fixer.removeRange([lastToken.range[1], closeBrace.range[0]]);
63073 }
63074
63075 });
63076 }
63077 }
63078
63079 return {
63080 BlockStatement: checkSpacingInsideBraces,
63081 StaticBlock: checkSpacingInsideBraces,
63082 SwitchStatement: checkSpacingInsideBraces
63083 };
63084 }
63085
63086 };
63087
63088 /***/ }),
63089 /* 562 */
63090 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
63091
63092 "use strict";
63093 /**
63094 * @fileoverview Rule to flag block statements that do not use the one true brace style
63095 * @author Ian Christian Myers
63096 */
63097
63098
63099 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
63100 // Rule Definition
63101 //------------------------------------------------------------------------------
63102
63103
63104 module.exports = {
63105 meta: {
63106 type: "layout",
63107 docs: {
63108 description: "enforce consistent brace style for blocks",
63109 recommended: false,
63110 url: "https://eslint.org/docs/rules/brace-style"
63111 },
63112 schema: [{
63113 enum: ["1tbs", "stroustrup", "allman"]
63114 }, {
63115 type: "object",
63116 properties: {
63117 allowSingleLine: {
63118 type: "boolean",
63119 default: false
63120 }
63121 },
63122 additionalProperties: false
63123 }],
63124 fixable: "whitespace",
63125 messages: {
63126 nextLineOpen: "Opening curly brace does not appear on the same line as controlling statement.",
63127 sameLineOpen: "Opening curly brace appears on the same line as controlling statement.",
63128 blockSameLine: "Statement inside of curly braces should be on next line.",
63129 nextLineClose: "Closing curly brace does not appear on the same line as the subsequent block.",
63130 singleLineClose: "Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.",
63131 sameLineClose: "Closing curly brace appears on the same line as the subsequent block."
63132 }
63133 },
63134
63135 create(context) {
63136 const style = context.options[0] || "1tbs",
63137 params = context.options[1] || {},
63138 sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
63139 // Helpers
63140 //--------------------------------------------------------------------------
63141
63142 /**
63143 * Fixes a place where a newline unexpectedly appears
63144 * @param {Token} firstToken The token before the unexpected newline
63145 * @param {Token} secondToken The token after the unexpected newline
63146 * @returns {Function} A fixer function to remove the newlines between the tokens
63147 */
63148
63149 function removeNewlineBetween(firstToken, secondToken) {
63150 const textRange = [firstToken.range[1], secondToken.range[0]];
63151 const textBetween = sourceCode.text.slice(textRange[0], textRange[1]); // Don't do a fix if there is a comment between the tokens
63152
63153 if (textBetween.trim()) {
63154 return null;
63155 }
63156
63157 return fixer => fixer.replaceTextRange(textRange, " ");
63158 }
63159 /**
63160 * Validates a pair of curly brackets based on the user's config
63161 * @param {Token} openingCurly The opening curly bracket
63162 * @param {Token} closingCurly The closing curly bracket
63163 * @returns {void}
63164 */
63165
63166
63167 function validateCurlyPair(openingCurly, closingCurly) {
63168 const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurly);
63169 const tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurly);
63170 const tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurly);
63171 const singleLineException = params.allowSingleLine && astUtils.isTokenOnSameLine(openingCurly, closingCurly);
63172
63173 if (style !== "allman" && !astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly)) {
63174 context.report({
63175 node: openingCurly,
63176 messageId: "nextLineOpen",
63177 fix: removeNewlineBetween(tokenBeforeOpeningCurly, openingCurly)
63178 });
63179 }
63180
63181 if (style === "allman" && astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly) && !singleLineException) {
63182 context.report({
63183 node: openingCurly,
63184 messageId: "sameLineOpen",
63185 fix: fixer => fixer.insertTextBefore(openingCurly, "\n")
63186 });
63187 }
63188
63189 if (astUtils.isTokenOnSameLine(openingCurly, tokenAfterOpeningCurly) && tokenAfterOpeningCurly !== closingCurly && !singleLineException) {
63190 context.report({
63191 node: openingCurly,
63192 messageId: "blockSameLine",
63193 fix: fixer => fixer.insertTextAfter(openingCurly, "\n")
63194 });
63195 }
63196
63197 if (tokenBeforeClosingCurly !== openingCurly && !singleLineException && astUtils.isTokenOnSameLine(tokenBeforeClosingCurly, closingCurly)) {
63198 context.report({
63199 node: closingCurly,
63200 messageId: "singleLineClose",
63201 fix: fixer => fixer.insertTextBefore(closingCurly, "\n")
63202 });
63203 }
63204 }
63205 /**
63206 * Validates the location of a token that appears before a keyword (e.g. a newline before `else`)
63207 * @param {Token} curlyToken The closing curly token. This is assumed to precede a keyword token (such as `else` or `finally`).
63208 * @returns {void}
63209 */
63210
63211
63212 function validateCurlyBeforeKeyword(curlyToken) {
63213 const keywordToken = sourceCode.getTokenAfter(curlyToken);
63214
63215 if (style === "1tbs" && !astUtils.isTokenOnSameLine(curlyToken, keywordToken)) {
63216 context.report({
63217 node: curlyToken,
63218 messageId: "nextLineClose",
63219 fix: removeNewlineBetween(curlyToken, keywordToken)
63220 });
63221 }
63222
63223 if (style !== "1tbs" && astUtils.isTokenOnSameLine(curlyToken, keywordToken)) {
63224 context.report({
63225 node: curlyToken,
63226 messageId: "sameLineClose",
63227 fix: fixer => fixer.insertTextAfter(curlyToken, "\n")
63228 });
63229 }
63230 } //--------------------------------------------------------------------------
63231 // Public API
63232 //--------------------------------------------------------------------------
63233
63234
63235 return {
63236 BlockStatement(node) {
63237 if (!astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) {
63238 validateCurlyPair(sourceCode.getFirstToken(node), sourceCode.getLastToken(node));
63239 }
63240 },
63241
63242 StaticBlock(node) {
63243 validateCurlyPair(sourceCode.getFirstToken(node, {
63244 skip: 1
63245 }), // skip the `static` token
63246 sourceCode.getLastToken(node));
63247 },
63248
63249 ClassBody(node) {
63250 validateCurlyPair(sourceCode.getFirstToken(node), sourceCode.getLastToken(node));
63251 },
63252
63253 SwitchStatement(node) {
63254 const closingCurly = sourceCode.getLastToken(node);
63255 const openingCurly = sourceCode.getTokenBefore(node.cases.length ? node.cases[0] : closingCurly);
63256 validateCurlyPair(openingCurly, closingCurly);
63257 },
63258
63259 IfStatement(node) {
63260 if (node.consequent.type === "BlockStatement" && node.alternate) {
63261 // Handle the keyword after the `if` block (before `else`)
63262 validateCurlyBeforeKeyword(sourceCode.getLastToken(node.consequent));
63263 }
63264 },
63265
63266 TryStatement(node) {
63267 // Handle the keyword after the `try` block (before `catch` or `finally`)
63268 validateCurlyBeforeKeyword(sourceCode.getLastToken(node.block));
63269
63270 if (node.handler && node.finalizer) {
63271 // Handle the keyword after the `catch` block (before `finally`)
63272 validateCurlyBeforeKeyword(sourceCode.getLastToken(node.handler.body));
63273 }
63274 }
63275
63276 };
63277 }
63278
63279 };
63280
63281 /***/ }),
63282 /* 563 */
63283 /***/ ((module) => {
63284
63285 "use strict";
63286 /**
63287 * @fileoverview Enforce return after a callback.
63288 * @author Jamund Ferguson
63289 * @deprecated in ESLint v7.0.0
63290 */
63291 //------------------------------------------------------------------------------
63292 // Rule Definition
63293 //------------------------------------------------------------------------------
63294
63295 module.exports = {
63296 meta: {
63297 deprecated: true,
63298 replacedBy: [],
63299 type: "suggestion",
63300 docs: {
63301 description: "require `return` statements after callbacks",
63302 recommended: false,
63303 url: "https://eslint.org/docs/rules/callback-return"
63304 },
63305 schema: [{
63306 type: "array",
63307 items: {
63308 type: "string"
63309 }
63310 }],
63311 messages: {
63312 missingReturn: "Expected return with your callback function."
63313 }
63314 },
63315
63316 create(context) {
63317 const callbacks = context.options[0] || ["callback", "cb", "next"],
63318 sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
63319 // Helpers
63320 //--------------------------------------------------------------------------
63321
63322 /**
63323 * Find the closest parent matching a list of types.
63324 * @param {ASTNode} node The node whose parents we are searching
63325 * @param {Array} types The node types to match
63326 * @returns {ASTNode} The matched node or undefined.
63327 */
63328
63329 function findClosestParentOfType(node, types) {
63330 if (!node.parent) {
63331 return null;
63332 }
63333
63334 if (types.indexOf(node.parent.type) === -1) {
63335 return findClosestParentOfType(node.parent, types);
63336 }
63337
63338 return node.parent;
63339 }
63340 /**
63341 * Check to see if a node contains only identifiers
63342 * @param {ASTNode} node The node to check
63343 * @returns {boolean} Whether or not the node contains only identifiers
63344 */
63345
63346
63347 function containsOnlyIdentifiers(node) {
63348 if (node.type === "Identifier") {
63349 return true;
63350 }
63351
63352 if (node.type === "MemberExpression") {
63353 if (node.object.type === "Identifier") {
63354 return true;
63355 }
63356
63357 if (node.object.type === "MemberExpression") {
63358 return containsOnlyIdentifiers(node.object);
63359 }
63360 }
63361
63362 return false;
63363 }
63364 /**
63365 * Check to see if a CallExpression is in our callback list.
63366 * @param {ASTNode} node The node to check against our callback names list.
63367 * @returns {boolean} Whether or not this function matches our callback name.
63368 */
63369
63370
63371 function isCallback(node) {
63372 return containsOnlyIdentifiers(node.callee) && callbacks.indexOf(sourceCode.getText(node.callee)) > -1;
63373 }
63374 /**
63375 * Determines whether or not the callback is part of a callback expression.
63376 * @param {ASTNode} node The callback node
63377 * @param {ASTNode} parentNode The expression node
63378 * @returns {boolean} Whether or not this is part of a callback expression
63379 */
63380
63381
63382 function isCallbackExpression(node, parentNode) {
63383 // ensure the parent node exists and is an expression
63384 if (!parentNode || parentNode.type !== "ExpressionStatement") {
63385 return false;
63386 } // cb()
63387
63388
63389 if (parentNode.expression === node) {
63390 return true;
63391 } // special case for cb && cb() and similar
63392
63393
63394 if (parentNode.expression.type === "BinaryExpression" || parentNode.expression.type === "LogicalExpression") {
63395 if (parentNode.expression.right === node) {
63396 return true;
63397 }
63398 }
63399
63400 return false;
63401 } //--------------------------------------------------------------------------
63402 // Public
63403 //--------------------------------------------------------------------------
63404
63405
63406 return {
63407 CallExpression(node) {
63408 // if we're not a callback we can return
63409 if (!isCallback(node)) {
63410 return;
63411 } // find the closest block, return or loop
63412
63413
63414 const closestBlock = findClosestParentOfType(node, ["BlockStatement", "ReturnStatement", "ArrowFunctionExpression"]) || {}; // if our parent is a return we know we're ok
63415
63416 if (closestBlock.type === "ReturnStatement") {
63417 return;
63418 } // arrow functions don't always have blocks and implicitly return
63419
63420
63421 if (closestBlock.type === "ArrowFunctionExpression") {
63422 return;
63423 } // block statements are part of functions and most if statements
63424
63425
63426 if (closestBlock.type === "BlockStatement") {
63427 // find the last item in the block
63428 const lastItem = closestBlock.body[closestBlock.body.length - 1]; // if the callback is the last thing in a block that might be ok
63429
63430 if (isCallbackExpression(node, lastItem)) {
63431 const parentType = closestBlock.parent.type; // but only if the block is part of a function
63432
63433 if (parentType === "FunctionExpression" || parentType === "FunctionDeclaration" || parentType === "ArrowFunctionExpression") {
63434 return;
63435 }
63436 } // ending a block with a return is also ok
63437
63438
63439 if (lastItem.type === "ReturnStatement") {
63440 // but only if the callback is immediately before
63441 if (isCallbackExpression(node, closestBlock.body[closestBlock.body.length - 2])) {
63442 return;
63443 }
63444 }
63445 } // as long as you're the child of a function at this point you should be asked to return
63446
63447
63448 if (findClosestParentOfType(node, ["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"])) {
63449 context.report({
63450 node,
63451 messageId: "missingReturn"
63452 });
63453 }
63454 }
63455
63456 };
63457 }
63458
63459 };
63460
63461 /***/ }),
63462 /* 564 */
63463 /***/ ((module) => {
63464
63465 "use strict";
63466 /**
63467 * @fileoverview Rule to flag non-camelcased identifiers
63468 * @author Nicholas C. Zakas
63469 */
63470 //------------------------------------------------------------------------------
63471 // Rule Definition
63472 //------------------------------------------------------------------------------
63473
63474 module.exports = {
63475 meta: {
63476 type: "suggestion",
63477 docs: {
63478 description: "enforce camelcase naming convention",
63479 recommended: false,
63480 url: "https://eslint.org/docs/rules/camelcase"
63481 },
63482 schema: [{
63483 type: "object",
63484 properties: {
63485 ignoreDestructuring: {
63486 type: "boolean",
63487 default: false
63488 },
63489 ignoreImports: {
63490 type: "boolean",
63491 default: false
63492 },
63493 ignoreGlobals: {
63494 type: "boolean",
63495 default: false
63496 },
63497 properties: {
63498 enum: ["always", "never"]
63499 },
63500 allow: {
63501 type: "array",
63502 items: [{
63503 type: "string"
63504 }],
63505 minItems: 0,
63506 uniqueItems: true
63507 }
63508 },
63509 additionalProperties: false
63510 }],
63511 messages: {
63512 notCamelCase: "Identifier '{{name}}' is not in camel case.",
63513 notCamelCasePrivate: "#{{name}} is not in camel case."
63514 }
63515 },
63516
63517 create(context) {
63518 const options = context.options[0] || {};
63519 const properties = options.properties === "never" ? "never" : "always";
63520 const ignoreDestructuring = options.ignoreDestructuring;
63521 const ignoreImports = options.ignoreImports;
63522 const ignoreGlobals = options.ignoreGlobals;
63523 const allow = options.allow || []; //--------------------------------------------------------------------------
63524 // Helpers
63525 //--------------------------------------------------------------------------
63526 // contains reported nodes to avoid reporting twice on destructuring with shorthand notation
63527
63528 const reported = new Set();
63529 /**
63530 * Checks if a string contains an underscore and isn't all upper-case
63531 * @param {string} name The string to check.
63532 * @returns {boolean} if the string is underscored
63533 * @private
63534 */
63535
63536 function isUnderscored(name) {
63537 const nameBody = name.replace(/^_+|_+$/gu, ""); // if there's an underscore, it might be A_CONSTANT, which is okay
63538
63539 return nameBody.includes("_") && nameBody !== nameBody.toUpperCase();
63540 }
63541 /**
63542 * Checks if a string match the ignore list
63543 * @param {string} name The string to check.
63544 * @returns {boolean} if the string is ignored
63545 * @private
63546 */
63547
63548
63549 function isAllowed(name) {
63550 return allow.some(entry => name === entry || name.match(new RegExp(entry, "u")));
63551 }
63552 /**
63553 * Checks if a given name is good or not.
63554 * @param {string} name The name to check.
63555 * @returns {boolean} `true` if the name is good.
63556 * @private
63557 */
63558
63559
63560 function isGoodName(name) {
63561 return !isUnderscored(name) || isAllowed(name);
63562 }
63563 /**
63564 * Checks if a given identifier reference or member expression is an assignment
63565 * target.
63566 * @param {ASTNode} node The node to check.
63567 * @returns {boolean} `true` if the node is an assignment target.
63568 */
63569
63570
63571 function isAssignmentTarget(node) {
63572 const parent = node.parent;
63573
63574 switch (parent.type) {
63575 case "AssignmentExpression":
63576 case "AssignmentPattern":
63577 return parent.left === node;
63578
63579 case "Property":
63580 return parent.parent.type === "ObjectPattern" && parent.value === node;
63581
63582 case "ArrayPattern":
63583 case "RestElement":
63584 return true;
63585
63586 default:
63587 return false;
63588 }
63589 }
63590 /**
63591 * Checks if a given binding identifier uses the original name as-is.
63592 * - If it's in object destructuring, the original name is its property name.
63593 * - If it's in import declaration, the original name is its exported name.
63594 * @param {ASTNode} node The `Identifier` node to check.
63595 * @returns {boolean} `true` if the identifier uses the original name as-is.
63596 */
63597
63598
63599 function equalsToOriginalName(node) {
63600 const localName = node.name;
63601 const valueNode = node.parent.type === "AssignmentPattern" ? node.parent : node;
63602 const parent = valueNode.parent;
63603
63604 switch (parent.type) {
63605 case "Property":
63606 return parent.parent.type === "ObjectPattern" && parent.value === valueNode && !parent.computed && parent.key.type === "Identifier" && parent.key.name === localName;
63607
63608 case "ImportSpecifier":
63609 return parent.local === node && parent.imported.name === localName;
63610
63611 default:
63612 return false;
63613 }
63614 }
63615 /**
63616 * Reports an AST node as a rule violation.
63617 * @param {ASTNode} node The node to report.
63618 * @returns {void}
63619 * @private
63620 */
63621
63622
63623 function report(node) {
63624 if (reported.has(node.range[0])) {
63625 return;
63626 }
63627
63628 reported.add(node.range[0]); // Report it.
63629
63630 context.report({
63631 node,
63632 messageId: node.type === "PrivateIdentifier" ? "notCamelCasePrivate" : "notCamelCase",
63633 data: {
63634 name: node.name
63635 }
63636 });
63637 }
63638 /**
63639 * Reports an identifier reference or a binding identifier.
63640 * @param {ASTNode} node The `Identifier` node to report.
63641 * @returns {void}
63642 */
63643
63644
63645 function reportReferenceId(node) {
63646 /*
63647 * For backward compatibility, if it's in callings then ignore it.
63648 * Not sure why it is.
63649 */
63650 if (node.parent.type === "CallExpression" || node.parent.type === "NewExpression") {
63651 return;
63652 }
63653 /*
63654 * For backward compatibility, if it's a default value of
63655 * destructuring/parameters then ignore it.
63656 * Not sure why it is.
63657 */
63658
63659
63660 if (node.parent.type === "AssignmentPattern" && node.parent.right === node) {
63661 return;
63662 }
63663 /*
63664 * The `ignoreDestructuring` flag skips the identifiers that uses
63665 * the property name as-is.
63666 */
63667
63668
63669 if (ignoreDestructuring && equalsToOriginalName(node)) {
63670 return;
63671 }
63672
63673 report(node);
63674 }
63675
63676 return {
63677 // Report camelcase of global variable references ------------------
63678 Program() {
63679 const scope = context.getScope();
63680
63681 if (!ignoreGlobals) {
63682 // Defined globals in config files or directive comments.
63683 for (const variable of scope.variables) {
63684 if (variable.identifiers.length > 0 || isGoodName(variable.name)) {
63685 continue;
63686 }
63687
63688 for (const reference of variable.references) {
63689 /*
63690 * For backward compatibility, this rule reports read-only
63691 * references as well.
63692 */
63693 reportReferenceId(reference.identifier);
63694 }
63695 }
63696 } // Undefined globals.
63697
63698
63699 for (const reference of scope.through) {
63700 const id = reference.identifier;
63701
63702 if (isGoodName(id.name)) {
63703 continue;
63704 }
63705 /*
63706 * For backward compatibility, this rule reports read-only
63707 * references as well.
63708 */
63709
63710
63711 reportReferenceId(id);
63712 }
63713 },
63714
63715 // Report camelcase of declared variables --------------------------
63716 [["VariableDeclaration", "FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression", "ClassDeclaration", "ClassExpression", "CatchClause"]](node) {
63717 for (const variable of context.getDeclaredVariables(node)) {
63718 if (isGoodName(variable.name)) {
63719 continue;
63720 }
63721
63722 const id = variable.identifiers[0]; // Report declaration.
63723
63724 if (!(ignoreDestructuring && equalsToOriginalName(id))) {
63725 report(id);
63726 }
63727 /*
63728 * For backward compatibility, report references as well.
63729 * It looks unnecessary because declarations are reported.
63730 */
63731
63732
63733 for (const reference of variable.references) {
63734 if (reference.init) {
63735 continue; // Skip the write references of initializers.
63736 }
63737
63738 reportReferenceId(reference.identifier);
63739 }
63740 }
63741 },
63742
63743 // Report camelcase in properties ----------------------------------
63744 [["ObjectExpression > Property[computed!=true] > Identifier.key", "MethodDefinition[computed!=true] > Identifier.key", "PropertyDefinition[computed!=true] > Identifier.key", "MethodDefinition > PrivateIdentifier.key", "PropertyDefinition > PrivateIdentifier.key"]](node) {
63745 if (properties === "never" || isGoodName(node.name)) {
63746 return;
63747 }
63748
63749 report(node);
63750 },
63751
63752 "MemberExpression[computed!=true] > Identifier.property"(node) {
63753 if (properties === "never" || !isAssignmentTarget(node.parent) || // ← ignore read-only references.
63754 isGoodName(node.name)) {
63755 return;
63756 }
63757
63758 report(node);
63759 },
63760
63761 // Report camelcase in import --------------------------------------
63762 ImportDeclaration(node) {
63763 for (const variable of context.getDeclaredVariables(node)) {
63764 if (isGoodName(variable.name)) {
63765 continue;
63766 }
63767
63768 const id = variable.identifiers[0]; // Report declaration.
63769
63770 if (!(ignoreImports && equalsToOriginalName(id))) {
63771 report(id);
63772 }
63773 /*
63774 * For backward compatibility, report references as well.
63775 * It looks unnecessary because declarations are reported.
63776 */
63777
63778
63779 for (const reference of variable.references) {
63780 reportReferenceId(reference.identifier);
63781 }
63782 }
63783 },
63784
63785 // Report camelcase in re-export -----------------------------------
63786 [["ExportAllDeclaration > Identifier.exported", "ExportSpecifier > Identifier.exported"]](node) {
63787 if (isGoodName(node.name)) {
63788 return;
63789 }
63790
63791 report(node);
63792 },
63793
63794 // Report camelcase in labels --------------------------------------
63795 [["LabeledStatement > Identifier.label",
63796 /*
63797 * For backward compatibility, report references as well.
63798 * It looks unnecessary because declarations are reported.
63799 */
63800 "BreakStatement > Identifier.label", "ContinueStatement > Identifier.label"]](node) {
63801 if (isGoodName(node.name)) {
63802 return;
63803 }
63804
63805 report(node);
63806 }
63807
63808 };
63809 }
63810
63811 };
63812
63813 /***/ }),
63814 /* 565 */
63815 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
63816
63817 "use strict";
63818 /**
63819 * @fileoverview enforce or disallow capitalization of the first letter of a comment
63820 * @author Kevin Partington
63821 */
63822 //------------------------------------------------------------------------------
63823 // Requirements
63824 //------------------------------------------------------------------------------
63825
63826 const LETTER_PATTERN = __webpack_require__(566);
63827
63828 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
63829 // Helpers
63830 //------------------------------------------------------------------------------
63831
63832
63833 const DEFAULT_IGNORE_PATTERN = astUtils.COMMENTS_IGNORE_PATTERN,
63834 WHITESPACE = /\s/gu,
63835 MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]/u; // TODO: Combine w/ max-len pattern?
63836
63837 /*
63838 * Base schema body for defining the basic capitalization rule, ignorePattern,
63839 * and ignoreInlineComments values.
63840 * This can be used in a few different ways in the actual schema.
63841 */
63842
63843 const SCHEMA_BODY = {
63844 type: "object",
63845 properties: {
63846 ignorePattern: {
63847 type: "string"
63848 },
63849 ignoreInlineComments: {
63850 type: "boolean"
63851 },
63852 ignoreConsecutiveComments: {
63853 type: "boolean"
63854 }
63855 },
63856 additionalProperties: false
63857 };
63858 const DEFAULTS = {
63859 ignorePattern: "",
63860 ignoreInlineComments: false,
63861 ignoreConsecutiveComments: false
63862 };
63863 /**
63864 * Get normalized options for either block or line comments from the given
63865 * user-provided options.
63866 * - If the user-provided options is just a string, returns a normalized
63867 * set of options using default values for all other options.
63868 * - If the user-provided options is an object, then a normalized option
63869 * set is returned. Options specified in overrides will take priority
63870 * over options specified in the main options object, which will in
63871 * turn take priority over the rule's defaults.
63872 * @param {Object|string} rawOptions The user-provided options.
63873 * @param {string} which Either "line" or "block".
63874 * @returns {Object} The normalized options.
63875 */
63876
63877 function getNormalizedOptions(rawOptions, which) {
63878 return Object.assign({}, DEFAULTS, rawOptions[which] || rawOptions);
63879 }
63880 /**
63881 * Get normalized options for block and line comments.
63882 * @param {Object|string} rawOptions The user-provided options.
63883 * @returns {Object} An object with "Line" and "Block" keys and corresponding
63884 * normalized options objects.
63885 */
63886
63887
63888 function getAllNormalizedOptions() {
63889 let rawOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
63890 return {
63891 Line: getNormalizedOptions(rawOptions, "line"),
63892 Block: getNormalizedOptions(rawOptions, "block")
63893 };
63894 }
63895 /**
63896 * Creates a regular expression for each ignorePattern defined in the rule
63897 * options.
63898 *
63899 * This is done in order to avoid invoking the RegExp constructor repeatedly.
63900 * @param {Object} normalizedOptions The normalized rule options.
63901 * @returns {void}
63902 */
63903
63904
63905 function createRegExpForIgnorePatterns(normalizedOptions) {
63906 Object.keys(normalizedOptions).forEach(key => {
63907 const ignorePatternStr = normalizedOptions[key].ignorePattern;
63908
63909 if (ignorePatternStr) {
63910 const regExp = RegExp("^\\s*(?:".concat(ignorePatternStr, ")"), "u");
63911 normalizedOptions[key].ignorePatternRegExp = regExp;
63912 }
63913 });
63914 } //------------------------------------------------------------------------------
63915 // Rule Definition
63916 //------------------------------------------------------------------------------
63917
63918
63919 module.exports = {
63920 meta: {
63921 type: "suggestion",
63922 docs: {
63923 description: "enforce or disallow capitalization of the first letter of a comment",
63924 recommended: false,
63925 url: "https://eslint.org/docs/rules/capitalized-comments"
63926 },
63927 fixable: "code",
63928 schema: [{
63929 enum: ["always", "never"]
63930 }, {
63931 oneOf: [SCHEMA_BODY, {
63932 type: "object",
63933 properties: {
63934 line: SCHEMA_BODY,
63935 block: SCHEMA_BODY
63936 },
63937 additionalProperties: false
63938 }]
63939 }],
63940 messages: {
63941 unexpectedLowercaseComment: "Comments should not begin with a lowercase character.",
63942 unexpectedUppercaseComment: "Comments should not begin with an uppercase character."
63943 }
63944 },
63945
63946 create(context) {
63947 const capitalize = context.options[0] || "always",
63948 normalizedOptions = getAllNormalizedOptions(context.options[1]),
63949 sourceCode = context.getSourceCode();
63950 createRegExpForIgnorePatterns(normalizedOptions); //----------------------------------------------------------------------
63951 // Helpers
63952 //----------------------------------------------------------------------
63953
63954 /**
63955 * Checks whether a comment is an inline comment.
63956 *
63957 * For the purpose of this rule, a comment is inline if:
63958 * 1. The comment is preceded by a token on the same line; and
63959 * 2. The command is followed by a token on the same line.
63960 *
63961 * Note that the comment itself need not be single-line!
63962 *
63963 * Also, it follows from this definition that only block comments can
63964 * be considered as possibly inline. This is because line comments
63965 * would consume any following tokens on the same line as the comment.
63966 * @param {ASTNode} comment The comment node to check.
63967 * @returns {boolean} True if the comment is an inline comment, false
63968 * otherwise.
63969 */
63970
63971 function isInlineComment(comment) {
63972 const previousToken = sourceCode.getTokenBefore(comment, {
63973 includeComments: true
63974 }),
63975 nextToken = sourceCode.getTokenAfter(comment, {
63976 includeComments: true
63977 });
63978 return Boolean(previousToken && nextToken && comment.loc.start.line === previousToken.loc.end.line && comment.loc.end.line === nextToken.loc.start.line);
63979 }
63980 /**
63981 * Determine if a comment follows another comment.
63982 * @param {ASTNode} comment The comment to check.
63983 * @returns {boolean} True if the comment follows a valid comment.
63984 */
63985
63986
63987 function isConsecutiveComment(comment) {
63988 const previousTokenOrComment = sourceCode.getTokenBefore(comment, {
63989 includeComments: true
63990 });
63991 return Boolean(previousTokenOrComment && ["Block", "Line"].indexOf(previousTokenOrComment.type) !== -1);
63992 }
63993 /**
63994 * Check a comment to determine if it is valid for this rule.
63995 * @param {ASTNode} comment The comment node to process.
63996 * @param {Object} options The options for checking this comment.
63997 * @returns {boolean} True if the comment is valid, false otherwise.
63998 */
63999
64000
64001 function isCommentValid(comment, options) {
64002 // 1. Check for default ignore pattern.
64003 if (DEFAULT_IGNORE_PATTERN.test(comment.value)) {
64004 return true;
64005 } // 2. Check for custom ignore pattern.
64006
64007
64008 const commentWithoutAsterisks = comment.value.replace(/\*/gu, "");
64009
64010 if (options.ignorePatternRegExp && options.ignorePatternRegExp.test(commentWithoutAsterisks)) {
64011 return true;
64012 } // 3. Check for inline comments.
64013
64014
64015 if (options.ignoreInlineComments && isInlineComment(comment)) {
64016 return true;
64017 } // 4. Is this a consecutive comment (and are we tolerating those)?
64018
64019
64020 if (options.ignoreConsecutiveComments && isConsecutiveComment(comment)) {
64021 return true;
64022 } // 5. Does the comment start with a possible URL?
64023
64024
64025 if (MAYBE_URL.test(commentWithoutAsterisks)) {
64026 return true;
64027 } // 6. Is the initial word character a letter?
64028
64029
64030 const commentWordCharsOnly = commentWithoutAsterisks.replace(WHITESPACE, "");
64031
64032 if (commentWordCharsOnly.length === 0) {
64033 return true;
64034 }
64035
64036 const firstWordChar = commentWordCharsOnly[0];
64037
64038 if (!LETTER_PATTERN.test(firstWordChar)) {
64039 return true;
64040 } // 7. Check the case of the initial word character.
64041
64042
64043 const isUppercase = firstWordChar !== firstWordChar.toLocaleLowerCase(),
64044 isLowercase = firstWordChar !== firstWordChar.toLocaleUpperCase();
64045
64046 if (capitalize === "always" && isLowercase) {
64047 return false;
64048 }
64049
64050 if (capitalize === "never" && isUppercase) {
64051 return false;
64052 }
64053
64054 return true;
64055 }
64056 /**
64057 * Process a comment to determine if it needs to be reported.
64058 * @param {ASTNode} comment The comment node to process.
64059 * @returns {void}
64060 */
64061
64062
64063 function processComment(comment) {
64064 const options = normalizedOptions[comment.type],
64065 commentValid = isCommentValid(comment, options);
64066
64067 if (!commentValid) {
64068 const messageId = capitalize === "always" ? "unexpectedLowercaseComment" : "unexpectedUppercaseComment";
64069 context.report({
64070 node: null,
64071 // Intentionally using loc instead
64072 loc: comment.loc,
64073 messageId,
64074
64075 fix(fixer) {
64076 const match = comment.value.match(LETTER_PATTERN);
64077 return fixer.replaceTextRange( // Offset match.index by 2 to account for the first 2 characters that start the comment (// or /*)
64078 [comment.range[0] + match.index + 2, comment.range[0] + match.index + 3], capitalize === "always" ? match[0].toLocaleUpperCase() : match[0].toLocaleLowerCase());
64079 }
64080
64081 });
64082 }
64083 } //----------------------------------------------------------------------
64084 // Public
64085 //----------------------------------------------------------------------
64086
64087
64088 return {
64089 Program() {
64090 const comments = sourceCode.getAllComments();
64091 comments.filter(token => token.type !== "Shebang").forEach(processComment);
64092 }
64093
64094 };
64095 }
64096
64097 };
64098
64099 /***/ }),
64100 /* 566 */
64101 /***/ ((module) => {
64102
64103 "use strict";
64104 /**
64105 * @fileoverview Pattern for detecting any letter (even letters outside of ASCII).
64106 * NOTE: This file was generated using this script in JSCS based on the Unicode 7.0.0 standard: https://github.com/jscs-dev/node-jscs/blob/f5ed14427deb7e7aac84f3056a5aab2d9f3e563e/publish/helpers/generate-patterns.js
64107 * Do not edit this file by hand-- please use https://github.com/mathiasbynens/regenerate to regenerate the regular expression exported from this file.
64108 * @author Kevin Partington
64109 * @license MIT License (from JSCS). See below.
64110 */
64111
64112 /*
64113 * The MIT License (MIT)
64114 *
64115 * Copyright 2013-2016 Dulin Marat and other contributors
64116 *
64117 * Permission is hereby granted, free of charge, to any person obtaining
64118 * a copy of this software and associated documentation files (the
64119 * "Software"), to deal in the Software without restriction, including
64120 * without limitation the rights to use, copy, modify, merge, publish,
64121 * distribute, sublicense, and/or sell copies of the Software, and to
64122 * permit persons to whom the Software is furnished to do so, subject to
64123 * the following conditions:
64124 *
64125 * The above copyright notice and this permission notice shall be
64126 * included in all copies or substantial portions of the Software.
64127 *
64128 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
64129 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
64130 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
64131 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
64132 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
64133 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
64134 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
64135 */
64136
64137
64138 module.exports = /[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/u;
64139
64140 /***/ }),
64141 /* 567 */
64142 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
64143
64144 "use strict";
64145 /**
64146 * @fileoverview Rule to enforce that all class methods use 'this'.
64147 * @author Patrick Williams
64148 */
64149 //------------------------------------------------------------------------------
64150 // Requirements
64151 //------------------------------------------------------------------------------
64152
64153 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
64154 // Rule Definition
64155 //------------------------------------------------------------------------------
64156
64157
64158 module.exports = {
64159 meta: {
64160 type: "suggestion",
64161 docs: {
64162 description: "enforce that class methods utilize `this`",
64163 recommended: false,
64164 url: "https://eslint.org/docs/rules/class-methods-use-this"
64165 },
64166 schema: [{
64167 type: "object",
64168 properties: {
64169 exceptMethods: {
64170 type: "array",
64171 items: {
64172 type: "string"
64173 }
64174 },
64175 enforceForClassFields: {
64176 type: "boolean",
64177 default: true
64178 }
64179 },
64180 additionalProperties: false
64181 }],
64182 messages: {
64183 missingThis: "Expected 'this' to be used by class {{name}}."
64184 }
64185 },
64186
64187 create(context) {
64188 const config = Object.assign({}, context.options[0]);
64189 const enforceForClassFields = config.enforceForClassFields !== false;
64190 const exceptMethods = new Set(config.exceptMethods || []);
64191 const stack = [];
64192 /**
64193 * Push `this` used flag initialized with `false` onto the stack.
64194 * @returns {void}
64195 */
64196
64197 function pushContext() {
64198 stack.push(false);
64199 }
64200 /**
64201 * Pop `this` used flag from the stack.
64202 * @returns {boolean | undefined} `this` used flag
64203 */
64204
64205
64206 function popContext() {
64207 return stack.pop();
64208 }
64209 /**
64210 * Initializes the current context to false and pushes it onto the stack.
64211 * These booleans represent whether 'this' has been used in the context.
64212 * @returns {void}
64213 * @private
64214 */
64215
64216
64217 function enterFunction() {
64218 pushContext();
64219 }
64220 /**
64221 * Check if the node is an instance method
64222 * @param {ASTNode} node node to check
64223 * @returns {boolean} True if its an instance method
64224 * @private
64225 */
64226
64227
64228 function isInstanceMethod(node) {
64229 switch (node.type) {
64230 case "MethodDefinition":
64231 return !node.static && node.kind !== "constructor";
64232
64233 case "PropertyDefinition":
64234 return !node.static && enforceForClassFields;
64235
64236 default:
64237 return false;
64238 }
64239 }
64240 /**
64241 * Check if the node is an instance method not excluded by config
64242 * @param {ASTNode} node node to check
64243 * @returns {boolean} True if it is an instance method, and not excluded by config
64244 * @private
64245 */
64246
64247
64248 function isIncludedInstanceMethod(node) {
64249 if (isInstanceMethod(node)) {
64250 if (node.computed) {
64251 return true;
64252 }
64253
64254 const hashIfNeeded = node.key.type === "PrivateIdentifier" ? "#" : "";
64255 const name = node.key.type === "Literal" ? astUtils.getStaticStringValue(node.key) : node.key.name || "";
64256 return !exceptMethods.has(hashIfNeeded + name);
64257 }
64258
64259 return false;
64260 }
64261 /**
64262 * Checks if we are leaving a function that is a method, and reports if 'this' has not been used.
64263 * Static methods and the constructor are exempt.
64264 * Then pops the context off the stack.
64265 * @param {ASTNode} node A function node that was entered.
64266 * @returns {void}
64267 * @private
64268 */
64269
64270
64271 function exitFunction(node) {
64272 const methodUsesThis = popContext();
64273
64274 if (isIncludedInstanceMethod(node.parent) && !methodUsesThis) {
64275 context.report({
64276 node,
64277 loc: astUtils.getFunctionHeadLoc(node, context.getSourceCode()),
64278 messageId: "missingThis",
64279 data: {
64280 name: astUtils.getFunctionNameWithKind(node)
64281 }
64282 });
64283 }
64284 }
64285 /**
64286 * Mark the current context as having used 'this'.
64287 * @returns {void}
64288 * @private
64289 */
64290
64291
64292 function markThisUsed() {
64293 if (stack.length) {
64294 stack[stack.length - 1] = true;
64295 }
64296 }
64297
64298 return {
64299 FunctionDeclaration: enterFunction,
64300 "FunctionDeclaration:exit": exitFunction,
64301 FunctionExpression: enterFunction,
64302 "FunctionExpression:exit": exitFunction,
64303
64304 /*
64305 * Class field value are implicit functions.
64306 */
64307 "PropertyDefinition > *.key:exit": pushContext,
64308 "PropertyDefinition:exit": popContext,
64309
64310 /*
64311 * Class static blocks are implicit functions. They aren't required to use `this`,
64312 * but we have to push context so that it captures any use of `this` in the static block
64313 * separately from enclosing contexts, because static blocks have their own `this` and it
64314 * shouldn't count as used `this` in enclosing contexts.
64315 */
64316 StaticBlock: pushContext,
64317 "StaticBlock:exit": popContext,
64318 ThisExpression: markThisUsed,
64319 Super: markThisUsed,
64320 ...(enforceForClassFields && {
64321 "PropertyDefinition > ArrowFunctionExpression.value": enterFunction,
64322 "PropertyDefinition > ArrowFunctionExpression.value:exit": exitFunction
64323 })
64324 };
64325 }
64326
64327 };
64328
64329 /***/ }),
64330 /* 568 */
64331 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
64332
64333 "use strict";
64334 /**
64335 * @fileoverview Rule to forbid or enforce dangling commas.
64336 * @author Ian Christian Myers
64337 */
64338 //------------------------------------------------------------------------------
64339 // Requirements
64340 //------------------------------------------------------------------------------
64341
64342 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
64343 // Helpers
64344 //------------------------------------------------------------------------------
64345
64346
64347 const DEFAULT_OPTIONS = Object.freeze({
64348 arrays: "never",
64349 objects: "never",
64350 imports: "never",
64351 exports: "never",
64352 functions: "never"
64353 });
64354 /**
64355 * Checks whether or not a trailing comma is allowed in a given node.
64356 * If the `lastItem` is `RestElement` or `RestProperty`, it disallows trailing commas.
64357 * @param {ASTNode} lastItem The node of the last element in the given node.
64358 * @returns {boolean} `true` if a trailing comma is allowed.
64359 */
64360
64361 function isTrailingCommaAllowed(lastItem) {
64362 return !(lastItem.type === "RestElement" || lastItem.type === "RestProperty" || lastItem.type === "ExperimentalRestProperty");
64363 }
64364 /**
64365 * Normalize option value.
64366 * @param {string|Object|undefined} optionValue The 1st option value to normalize.
64367 * @param {number} ecmaVersion The normalized ECMAScript version.
64368 * @returns {Object} The normalized option value.
64369 */
64370
64371
64372 function normalizeOptions(optionValue, ecmaVersion) {
64373 if (typeof optionValue === "string") {
64374 return {
64375 arrays: optionValue,
64376 objects: optionValue,
64377 imports: optionValue,
64378 exports: optionValue,
64379 functions: !ecmaVersion || ecmaVersion < 8 ? "ignore" : optionValue
64380 };
64381 }
64382
64383 if (typeof optionValue === "object" && optionValue !== null) {
64384 return {
64385 arrays: optionValue.arrays || DEFAULT_OPTIONS.arrays,
64386 objects: optionValue.objects || DEFAULT_OPTIONS.objects,
64387 imports: optionValue.imports || DEFAULT_OPTIONS.imports,
64388 exports: optionValue.exports || DEFAULT_OPTIONS.exports,
64389 functions: optionValue.functions || DEFAULT_OPTIONS.functions
64390 };
64391 }
64392
64393 return DEFAULT_OPTIONS;
64394 } //------------------------------------------------------------------------------
64395 // Rule Definition
64396 //------------------------------------------------------------------------------
64397
64398
64399 module.exports = {
64400 meta: {
64401 type: "layout",
64402 docs: {
64403 description: "require or disallow trailing commas",
64404 recommended: false,
64405 url: "https://eslint.org/docs/rules/comma-dangle"
64406 },
64407 fixable: "code",
64408 schema: {
64409 definitions: {
64410 value: {
64411 enum: ["always-multiline", "always", "never", "only-multiline"]
64412 },
64413 valueWithIgnore: {
64414 enum: ["always-multiline", "always", "ignore", "never", "only-multiline"]
64415 }
64416 },
64417 type: "array",
64418 items: [{
64419 oneOf: [{
64420 $ref: "#/definitions/value"
64421 }, {
64422 type: "object",
64423 properties: {
64424 arrays: {
64425 $ref: "#/definitions/valueWithIgnore"
64426 },
64427 objects: {
64428 $ref: "#/definitions/valueWithIgnore"
64429 },
64430 imports: {
64431 $ref: "#/definitions/valueWithIgnore"
64432 },
64433 exports: {
64434 $ref: "#/definitions/valueWithIgnore"
64435 },
64436 functions: {
64437 $ref: "#/definitions/valueWithIgnore"
64438 }
64439 },
64440 additionalProperties: false
64441 }]
64442 }],
64443 additionalItems: false
64444 },
64445 messages: {
64446 unexpected: "Unexpected trailing comma.",
64447 missing: "Missing trailing comma."
64448 }
64449 },
64450
64451 create(context) {
64452 const options = normalizeOptions(context.options[0], context.parserOptions.ecmaVersion);
64453 const sourceCode = context.getSourceCode();
64454 /**
64455 * Gets the last item of the given node.
64456 * @param {ASTNode} node The node to get.
64457 * @returns {ASTNode|null} The last node or null.
64458 */
64459
64460 function getLastItem(node) {
64461 /**
64462 * Returns the last element of an array
64463 * @param {any[]} array The input array
64464 * @returns {any} The last element
64465 */
64466 function last(array) {
64467 return array[array.length - 1];
64468 }
64469
64470 switch (node.type) {
64471 case "ObjectExpression":
64472 case "ObjectPattern":
64473 return last(node.properties);
64474
64475 case "ArrayExpression":
64476 case "ArrayPattern":
64477 return last(node.elements);
64478
64479 case "ImportDeclaration":
64480 case "ExportNamedDeclaration":
64481 return last(node.specifiers);
64482
64483 case "FunctionDeclaration":
64484 case "FunctionExpression":
64485 case "ArrowFunctionExpression":
64486 return last(node.params);
64487
64488 case "CallExpression":
64489 case "NewExpression":
64490 return last(node.arguments);
64491
64492 default:
64493 return null;
64494 }
64495 }
64496 /**
64497 * Gets the trailing comma token of the given node.
64498 * If the trailing comma does not exist, this returns the token which is
64499 * the insertion point of the trailing comma token.
64500 * @param {ASTNode} node The node to get.
64501 * @param {ASTNode} lastItem The last item of the node.
64502 * @returns {Token} The trailing comma token or the insertion point.
64503 */
64504
64505
64506 function getTrailingToken(node, lastItem) {
64507 switch (node.type) {
64508 case "ObjectExpression":
64509 case "ArrayExpression":
64510 case "CallExpression":
64511 case "NewExpression":
64512 return sourceCode.getLastToken(node, 1);
64513
64514 default:
64515 {
64516 const nextToken = sourceCode.getTokenAfter(lastItem);
64517
64518 if (astUtils.isCommaToken(nextToken)) {
64519 return nextToken;
64520 }
64521
64522 return sourceCode.getLastToken(lastItem);
64523 }
64524 }
64525 }
64526 /**
64527 * Checks whether or not a given node is multiline.
64528 * This rule handles a given node as multiline when the closing parenthesis
64529 * and the last element are not on the same line.
64530 * @param {ASTNode} node A node to check.
64531 * @returns {boolean} `true` if the node is multiline.
64532 */
64533
64534
64535 function isMultiline(node) {
64536 const lastItem = getLastItem(node);
64537
64538 if (!lastItem) {
64539 return false;
64540 }
64541
64542 const penultimateToken = getTrailingToken(node, lastItem);
64543 const lastToken = sourceCode.getTokenAfter(penultimateToken);
64544 return lastToken.loc.end.line !== penultimateToken.loc.end.line;
64545 }
64546 /**
64547 * Reports a trailing comma if it exists.
64548 * @param {ASTNode} node A node to check. Its type is one of
64549 * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
64550 * ImportDeclaration, and ExportNamedDeclaration.
64551 * @returns {void}
64552 */
64553
64554
64555 function forbidTrailingComma(node) {
64556 const lastItem = getLastItem(node);
64557
64558 if (!lastItem || node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier") {
64559 return;
64560 }
64561
64562 const trailingToken = getTrailingToken(node, lastItem);
64563
64564 if (astUtils.isCommaToken(trailingToken)) {
64565 context.report({
64566 node: lastItem,
64567 loc: trailingToken.loc,
64568 messageId: "unexpected",
64569
64570 fix(fixer) {
64571 return fixer.remove(trailingToken);
64572 }
64573
64574 });
64575 }
64576 }
64577 /**
64578 * Reports the last element of a given node if it does not have a trailing
64579 * comma.
64580 *
64581 * If a given node is `ArrayPattern` which has `RestElement`, the trailing
64582 * comma is disallowed, so report if it exists.
64583 * @param {ASTNode} node A node to check. Its type is one of
64584 * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
64585 * ImportDeclaration, and ExportNamedDeclaration.
64586 * @returns {void}
64587 */
64588
64589
64590 function forceTrailingComma(node) {
64591 const lastItem = getLastItem(node);
64592
64593 if (!lastItem || node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier") {
64594 return;
64595 }
64596
64597 if (!isTrailingCommaAllowed(lastItem)) {
64598 forbidTrailingComma(node);
64599 return;
64600 }
64601
64602 const trailingToken = getTrailingToken(node, lastItem);
64603
64604 if (trailingToken.value !== ",") {
64605 context.report({
64606 node: lastItem,
64607 loc: {
64608 start: trailingToken.loc.end,
64609 end: astUtils.getNextLocation(sourceCode, trailingToken.loc.end)
64610 },
64611 messageId: "missing",
64612
64613 fix(fixer) {
64614 return fixer.insertTextAfter(trailingToken, ",");
64615 }
64616
64617 });
64618 }
64619 }
64620 /**
64621 * If a given node is multiline, reports the last element of a given node
64622 * when it does not have a trailing comma.
64623 * Otherwise, reports a trailing comma if it exists.
64624 * @param {ASTNode} node A node to check. Its type is one of
64625 * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
64626 * ImportDeclaration, and ExportNamedDeclaration.
64627 * @returns {void}
64628 */
64629
64630
64631 function forceTrailingCommaIfMultiline(node) {
64632 if (isMultiline(node)) {
64633 forceTrailingComma(node);
64634 } else {
64635 forbidTrailingComma(node);
64636 }
64637 }
64638 /**
64639 * Only if a given node is not multiline, reports the last element of a given node
64640 * when it does not have a trailing comma.
64641 * Otherwise, reports a trailing comma if it exists.
64642 * @param {ASTNode} node A node to check. Its type is one of
64643 * ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
64644 * ImportDeclaration, and ExportNamedDeclaration.
64645 * @returns {void}
64646 */
64647
64648
64649 function allowTrailingCommaIfMultiline(node) {
64650 if (!isMultiline(node)) {
64651 forbidTrailingComma(node);
64652 }
64653 }
64654
64655 const predicate = {
64656 always: forceTrailingComma,
64657 "always-multiline": forceTrailingCommaIfMultiline,
64658 "only-multiline": allowTrailingCommaIfMultiline,
64659 never: forbidTrailingComma,
64660 ignore: () => {}
64661 };
64662 return {
64663 ObjectExpression: predicate[options.objects],
64664 ObjectPattern: predicate[options.objects],
64665 ArrayExpression: predicate[options.arrays],
64666 ArrayPattern: predicate[options.arrays],
64667 ImportDeclaration: predicate[options.imports],
64668 ExportNamedDeclaration: predicate[options.exports],
64669 FunctionDeclaration: predicate[options.functions],
64670 FunctionExpression: predicate[options.functions],
64671 ArrowFunctionExpression: predicate[options.functions],
64672 CallExpression: predicate[options.functions],
64673 NewExpression: predicate[options.functions]
64674 };
64675 }
64676
64677 };
64678
64679 /***/ }),
64680 /* 569 */
64681 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
64682
64683 "use strict";
64684 /**
64685 * @fileoverview Comma spacing - validates spacing before and after comma
64686 * @author Vignesh Anand aka vegetableman.
64687 */
64688
64689
64690 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
64691 // Rule Definition
64692 //------------------------------------------------------------------------------
64693
64694
64695 module.exports = {
64696 meta: {
64697 type: "layout",
64698 docs: {
64699 description: "enforce consistent spacing before and after commas",
64700 recommended: false,
64701 url: "https://eslint.org/docs/rules/comma-spacing"
64702 },
64703 fixable: "whitespace",
64704 schema: [{
64705 type: "object",
64706 properties: {
64707 before: {
64708 type: "boolean",
64709 default: false
64710 },
64711 after: {
64712 type: "boolean",
64713 default: true
64714 }
64715 },
64716 additionalProperties: false
64717 }],
64718 messages: {
64719 missing: "A space is required {{loc}} ','.",
64720 unexpected: "There should be no space {{loc}} ','."
64721 }
64722 },
64723
64724 create(context) {
64725 const sourceCode = context.getSourceCode();
64726 const tokensAndComments = sourceCode.tokensAndComments;
64727 const options = {
64728 before: context.options[0] ? context.options[0].before : false,
64729 after: context.options[0] ? context.options[0].after : true
64730 }; //--------------------------------------------------------------------------
64731 // Helpers
64732 //--------------------------------------------------------------------------
64733 // list of comma tokens to ignore for the check of leading whitespace
64734
64735 const commaTokensToIgnore = [];
64736 /**
64737 * Reports a spacing error with an appropriate message.
64738 * @param {ASTNode} node The binary expression node to report.
64739 * @param {string} loc Is the error "before" or "after" the comma?
64740 * @param {ASTNode} otherNode The node at the left or right of `node`
64741 * @returns {void}
64742 * @private
64743 */
64744
64745 function report(node, loc, otherNode) {
64746 context.report({
64747 node,
64748
64749 fix(fixer) {
64750 if (options[loc]) {
64751 if (loc === "before") {
64752 return fixer.insertTextBefore(node, " ");
64753 }
64754
64755 return fixer.insertTextAfter(node, " ");
64756 }
64757
64758 let start, end;
64759 const newText = "";
64760
64761 if (loc === "before") {
64762 start = otherNode.range[1];
64763 end = node.range[0];
64764 } else {
64765 start = node.range[1];
64766 end = otherNode.range[0];
64767 }
64768
64769 return fixer.replaceTextRange([start, end], newText);
64770 },
64771
64772 messageId: options[loc] ? "missing" : "unexpected",
64773 data: {
64774 loc
64775 }
64776 });
64777 }
64778 /**
64779 * Validates the spacing around a comma token.
64780 * @param {Object} tokens The tokens to be validated.
64781 * @param {Token} tokens.comma The token representing the comma.
64782 * @param {Token} [tokens.left] The last token before the comma.
64783 * @param {Token} [tokens.right] The first token after the comma.
64784 * @param {Token|ASTNode} reportItem The item to use when reporting an error.
64785 * @returns {void}
64786 * @private
64787 */
64788
64789
64790 function validateCommaItemSpacing(tokens, reportItem) {
64791 if (tokens.left && astUtils.isTokenOnSameLine(tokens.left, tokens.comma) && options.before !== sourceCode.isSpaceBetweenTokens(tokens.left, tokens.comma)) {
64792 report(reportItem, "before", tokens.left);
64793 }
64794
64795 if (tokens.right && astUtils.isClosingParenToken(tokens.right)) {
64796 return;
64797 }
64798
64799 if (tokens.right && !options.after && tokens.right.type === "Line") {
64800 return;
64801 }
64802
64803 if (tokens.right && astUtils.isTokenOnSameLine(tokens.comma, tokens.right) && options.after !== sourceCode.isSpaceBetweenTokens(tokens.comma, tokens.right)) {
64804 report(reportItem, "after", tokens.right);
64805 }
64806 }
64807 /**
64808 * Adds null elements of the given ArrayExpression or ArrayPattern node to the ignore list.
64809 * @param {ASTNode} node An ArrayExpression or ArrayPattern node.
64810 * @returns {void}
64811 */
64812
64813
64814 function addNullElementsToIgnoreList(node) {
64815 let previousToken = sourceCode.getFirstToken(node);
64816 node.elements.forEach(element => {
64817 let token;
64818
64819 if (element === null) {
64820 token = sourceCode.getTokenAfter(previousToken);
64821
64822 if (astUtils.isCommaToken(token)) {
64823 commaTokensToIgnore.push(token);
64824 }
64825 } else {
64826 token = sourceCode.getTokenAfter(element);
64827 }
64828
64829 previousToken = token;
64830 });
64831 } //--------------------------------------------------------------------------
64832 // Public
64833 //--------------------------------------------------------------------------
64834
64835
64836 return {
64837 "Program:exit"() {
64838 tokensAndComments.forEach((token, i) => {
64839 if (!astUtils.isCommaToken(token)) {
64840 return;
64841 }
64842
64843 if (token && token.type === "JSXText") {
64844 return;
64845 }
64846
64847 const previousToken = tokensAndComments[i - 1];
64848 const nextToken = tokensAndComments[i + 1];
64849 validateCommaItemSpacing({
64850 comma: token,
64851 left: astUtils.isCommaToken(previousToken) || commaTokensToIgnore.includes(token) ? null : previousToken,
64852 right: astUtils.isCommaToken(nextToken) ? null : nextToken
64853 }, token);
64854 });
64855 },
64856
64857 ArrayExpression: addNullElementsToIgnoreList,
64858 ArrayPattern: addNullElementsToIgnoreList
64859 };
64860 }
64861
64862 };
64863
64864 /***/ }),
64865 /* 570 */
64866 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
64867
64868 "use strict";
64869 /**
64870 * @fileoverview Comma style - enforces comma styles of two types: last and first
64871 * @author Vignesh Anand aka vegetableman
64872 */
64873
64874
64875 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
64876 // Rule Definition
64877 //------------------------------------------------------------------------------
64878
64879
64880 module.exports = {
64881 meta: {
64882 type: "layout",
64883 docs: {
64884 description: "enforce consistent comma style",
64885 recommended: false,
64886 url: "https://eslint.org/docs/rules/comma-style"
64887 },
64888 fixable: "code",
64889 schema: [{
64890 enum: ["first", "last"]
64891 }, {
64892 type: "object",
64893 properties: {
64894 exceptions: {
64895 type: "object",
64896 additionalProperties: {
64897 type: "boolean"
64898 }
64899 }
64900 },
64901 additionalProperties: false
64902 }],
64903 messages: {
64904 unexpectedLineBeforeAndAfterComma: "Bad line breaking before and after ','.",
64905 expectedCommaFirst: "',' should be placed first.",
64906 expectedCommaLast: "',' should be placed last."
64907 }
64908 },
64909
64910 create(context) {
64911 const style = context.options[0] || "last",
64912 sourceCode = context.getSourceCode();
64913 const exceptions = {
64914 ArrayPattern: true,
64915 ArrowFunctionExpression: true,
64916 CallExpression: true,
64917 FunctionDeclaration: true,
64918 FunctionExpression: true,
64919 ImportDeclaration: true,
64920 ObjectPattern: true,
64921 NewExpression: true
64922 };
64923
64924 if (context.options.length === 2 && Object.prototype.hasOwnProperty.call(context.options[1], "exceptions")) {
64925 const keys = Object.keys(context.options[1].exceptions);
64926
64927 for (let i = 0; i < keys.length; i++) {
64928 exceptions[keys[i]] = context.options[1].exceptions[keys[i]];
64929 }
64930 } //--------------------------------------------------------------------------
64931 // Helpers
64932 //--------------------------------------------------------------------------
64933
64934 /**
64935 * Modified text based on the style
64936 * @param {string} styleType Style type
64937 * @param {string} text Source code text
64938 * @returns {string} modified text
64939 * @private
64940 */
64941
64942
64943 function getReplacedText(styleType, text) {
64944 switch (styleType) {
64945 case "between":
64946 return ",".concat(text.replace(astUtils.LINEBREAK_MATCHER, ""));
64947
64948 case "first":
64949 return "".concat(text, ",");
64950
64951 case "last":
64952 return ",".concat(text);
64953
64954 default:
64955 return "";
64956 }
64957 }
64958 /**
64959 * Determines the fixer function for a given style.
64960 * @param {string} styleType comma style
64961 * @param {ASTNode} previousItemToken The token to check.
64962 * @param {ASTNode} commaToken The token to check.
64963 * @param {ASTNode} currentItemToken The token to check.
64964 * @returns {Function} Fixer function
64965 * @private
64966 */
64967
64968
64969 function getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken) {
64970 const text = sourceCode.text.slice(previousItemToken.range[1], commaToken.range[0]) + sourceCode.text.slice(commaToken.range[1], currentItemToken.range[0]);
64971 const range = [previousItemToken.range[1], currentItemToken.range[0]];
64972 return function (fixer) {
64973 return fixer.replaceTextRange(range, getReplacedText(styleType, text));
64974 };
64975 }
64976 /**
64977 * Validates the spacing around single items in lists.
64978 * @param {Token} previousItemToken The last token from the previous item.
64979 * @param {Token} commaToken The token representing the comma.
64980 * @param {Token} currentItemToken The first token of the current item.
64981 * @param {Token} reportItem The item to use when reporting an error.
64982 * @returns {void}
64983 * @private
64984 */
64985
64986
64987 function validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem) {
64988 // if single line
64989 if (astUtils.isTokenOnSameLine(commaToken, currentItemToken) && astUtils.isTokenOnSameLine(previousItemToken, commaToken)) {// do nothing.
64990 } else if (!astUtils.isTokenOnSameLine(commaToken, currentItemToken) && !astUtils.isTokenOnSameLine(previousItemToken, commaToken)) {
64991 const comment = sourceCode.getCommentsAfter(commaToken)[0];
64992 const styleType = comment && comment.type === "Block" && astUtils.isTokenOnSameLine(commaToken, comment) ? style : "between"; // lone comma
64993
64994 context.report({
64995 node: reportItem,
64996 loc: commaToken.loc,
64997 messageId: "unexpectedLineBeforeAndAfterComma",
64998 fix: getFixerFunction(styleType, previousItemToken, commaToken, currentItemToken)
64999 });
65000 } else if (style === "first" && !astUtils.isTokenOnSameLine(commaToken, currentItemToken)) {
65001 context.report({
65002 node: reportItem,
65003 loc: commaToken.loc,
65004 messageId: "expectedCommaFirst",
65005 fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken)
65006 });
65007 } else if (style === "last" && astUtils.isTokenOnSameLine(commaToken, currentItemToken)) {
65008 context.report({
65009 node: reportItem,
65010 loc: commaToken.loc,
65011 messageId: "expectedCommaLast",
65012 fix: getFixerFunction(style, previousItemToken, commaToken, currentItemToken)
65013 });
65014 }
65015 }
65016 /**
65017 * Checks the comma placement with regards to a declaration/property/element
65018 * @param {ASTNode} node The binary expression node to check
65019 * @param {string} property The property of the node containing child nodes.
65020 * @private
65021 * @returns {void}
65022 */
65023
65024
65025 function validateComma(node, property) {
65026 const items = node[property],
65027 arrayLiteral = node.type === "ArrayExpression" || node.type === "ArrayPattern";
65028
65029 if (items.length > 1 || arrayLiteral) {
65030 // seed as opening [
65031 let previousItemToken = sourceCode.getFirstToken(node);
65032 items.forEach(item => {
65033 const commaToken = item ? sourceCode.getTokenBefore(item) : previousItemToken,
65034 currentItemToken = item ? sourceCode.getFirstToken(item) : sourceCode.getTokenAfter(commaToken),
65035 reportItem = item || currentItemToken;
65036 /*
65037 * This works by comparing three token locations:
65038 * - previousItemToken is the last token of the previous item
65039 * - commaToken is the location of the comma before the current item
65040 * - currentItemToken is the first token of the current item
65041 *
65042 * These values get switched around if item is undefined.
65043 * previousItemToken will refer to the last token not belonging
65044 * to the current item, which could be a comma or an opening
65045 * square bracket. currentItemToken could be a comma.
65046 *
65047 * All comparisons are done based on these tokens directly, so
65048 * they are always valid regardless of an undefined item.
65049 */
65050
65051 if (astUtils.isCommaToken(commaToken)) {
65052 validateCommaItemSpacing(previousItemToken, commaToken, currentItemToken, reportItem);
65053 }
65054
65055 if (item) {
65056 const tokenAfterItem = sourceCode.getTokenAfter(item, astUtils.isNotClosingParenToken);
65057 previousItemToken = tokenAfterItem ? sourceCode.getTokenBefore(tokenAfterItem) : sourceCode.ast.tokens[sourceCode.ast.tokens.length - 1];
65058 } else {
65059 previousItemToken = currentItemToken;
65060 }
65061 });
65062 /*
65063 * Special case for array literals that have empty last items, such
65064 * as [ 1, 2, ]. These arrays only have two items show up in the
65065 * AST, so we need to look at the token to verify that there's no
65066 * dangling comma.
65067 */
65068
65069 if (arrayLiteral) {
65070 const lastToken = sourceCode.getLastToken(node),
65071 nextToLastToken = sourceCode.getTokenBefore(lastToken);
65072
65073 if (astUtils.isCommaToken(nextToLastToken)) {
65074 validateCommaItemSpacing(sourceCode.getTokenBefore(nextToLastToken), nextToLastToken, lastToken, lastToken);
65075 }
65076 }
65077 }
65078 } //--------------------------------------------------------------------------
65079 // Public
65080 //--------------------------------------------------------------------------
65081
65082
65083 const nodes = {};
65084
65085 if (!exceptions.VariableDeclaration) {
65086 nodes.VariableDeclaration = function (node) {
65087 validateComma(node, "declarations");
65088 };
65089 }
65090
65091 if (!exceptions.ObjectExpression) {
65092 nodes.ObjectExpression = function (node) {
65093 validateComma(node, "properties");
65094 };
65095 }
65096
65097 if (!exceptions.ObjectPattern) {
65098 nodes.ObjectPattern = function (node) {
65099 validateComma(node, "properties");
65100 };
65101 }
65102
65103 if (!exceptions.ArrayExpression) {
65104 nodes.ArrayExpression = function (node) {
65105 validateComma(node, "elements");
65106 };
65107 }
65108
65109 if (!exceptions.ArrayPattern) {
65110 nodes.ArrayPattern = function (node) {
65111 validateComma(node, "elements");
65112 };
65113 }
65114
65115 if (!exceptions.FunctionDeclaration) {
65116 nodes.FunctionDeclaration = function (node) {
65117 validateComma(node, "params");
65118 };
65119 }
65120
65121 if (!exceptions.FunctionExpression) {
65122 nodes.FunctionExpression = function (node) {
65123 validateComma(node, "params");
65124 };
65125 }
65126
65127 if (!exceptions.ArrowFunctionExpression) {
65128 nodes.ArrowFunctionExpression = function (node) {
65129 validateComma(node, "params");
65130 };
65131 }
65132
65133 if (!exceptions.CallExpression) {
65134 nodes.CallExpression = function (node) {
65135 validateComma(node, "arguments");
65136 };
65137 }
65138
65139 if (!exceptions.ImportDeclaration) {
65140 nodes.ImportDeclaration = function (node) {
65141 validateComma(node, "specifiers");
65142 };
65143 }
65144
65145 if (!exceptions.NewExpression) {
65146 nodes.NewExpression = function (node) {
65147 validateComma(node, "arguments");
65148 };
65149 }
65150
65151 return nodes;
65152 }
65153
65154 };
65155
65156 /***/ }),
65157 /* 571 */
65158 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
65159
65160 "use strict";
65161 /**
65162 * @fileoverview Counts the cyclomatic complexity of each function of the script. See http://en.wikipedia.org/wiki/Cyclomatic_complexity.
65163 * Counts the number of if, conditional, for, while, try, switch/case,
65164 * @author Patrick Brosset
65165 */
65166 //------------------------------------------------------------------------------
65167 // Requirements
65168 //------------------------------------------------------------------------------
65169
65170 const astUtils = __webpack_require__(548);
65171
65172 const {
65173 upperCaseFirst
65174 } = __webpack_require__(572); //------------------------------------------------------------------------------
65175 // Rule Definition
65176 //------------------------------------------------------------------------------
65177
65178
65179 module.exports = {
65180 meta: {
65181 type: "suggestion",
65182 docs: {
65183 description: "enforce a maximum cyclomatic complexity allowed in a program",
65184 recommended: false,
65185 url: "https://eslint.org/docs/rules/complexity"
65186 },
65187 schema: [{
65188 oneOf: [{
65189 type: "integer",
65190 minimum: 0
65191 }, {
65192 type: "object",
65193 properties: {
65194 maximum: {
65195 type: "integer",
65196 minimum: 0
65197 },
65198 max: {
65199 type: "integer",
65200 minimum: 0
65201 }
65202 },
65203 additionalProperties: false
65204 }]
65205 }],
65206 messages: {
65207 complex: "{{name}} has a complexity of {{complexity}}. Maximum allowed is {{max}}."
65208 }
65209 },
65210
65211 create(context) {
65212 const option = context.options[0];
65213 let THRESHOLD = 20;
65214
65215 if (typeof option === "object" && (Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))) {
65216 THRESHOLD = option.maximum || option.max;
65217 } else if (typeof option === "number") {
65218 THRESHOLD = option;
65219 } //--------------------------------------------------------------------------
65220 // Helpers
65221 //--------------------------------------------------------------------------
65222 // Using a stack to store complexity per code path
65223
65224
65225 const complexities = [];
65226 /**
65227 * Increase the complexity of the code path in context
65228 * @returns {void}
65229 * @private
65230 */
65231
65232 function increaseComplexity() {
65233 complexities[complexities.length - 1]++;
65234 } //--------------------------------------------------------------------------
65235 // Public API
65236 //--------------------------------------------------------------------------
65237
65238
65239 return {
65240 onCodePathStart() {
65241 // The initial complexity is 1, representing one execution path in the CodePath
65242 complexities.push(1);
65243 },
65244
65245 // Each branching in the code adds 1 to the complexity
65246 CatchClause: increaseComplexity,
65247 ConditionalExpression: increaseComplexity,
65248 LogicalExpression: increaseComplexity,
65249 ForStatement: increaseComplexity,
65250 ForInStatement: increaseComplexity,
65251 ForOfStatement: increaseComplexity,
65252 IfStatement: increaseComplexity,
65253 WhileStatement: increaseComplexity,
65254 DoWhileStatement: increaseComplexity,
65255 // Avoid `default`
65256 "SwitchCase[test]": increaseComplexity,
65257
65258 // Logical assignment operators have short-circuiting behavior
65259 AssignmentExpression(node) {
65260 if (astUtils.isLogicalAssignmentOperator(node.operator)) {
65261 increaseComplexity();
65262 }
65263 },
65264
65265 onCodePathEnd(codePath, node) {
65266 const complexity = complexities.pop();
65267 /*
65268 * This rule only evaluates complexity of functions, so "program" is excluded.
65269 * Class field initializers and class static blocks are implicit functions. Therefore,
65270 * they shouldn't contribute to the enclosing function's complexity, but their
65271 * own complexity should be evaluated.
65272 */
65273
65274 if (codePath.origin !== "function" && codePath.origin !== "class-field-initializer" && codePath.origin !== "class-static-block") {
65275 return;
65276 }
65277
65278 if (complexity > THRESHOLD) {
65279 let name;
65280
65281 if (codePath.origin === "class-field-initializer") {
65282 name = "class field initializer";
65283 } else if (codePath.origin === "class-static-block") {
65284 name = "class static block";
65285 } else {
65286 name = astUtils.getFunctionNameWithKind(node);
65287 }
65288
65289 context.report({
65290 node,
65291 messageId: "complex",
65292 data: {
65293 name: upperCaseFirst(name),
65294 complexity,
65295 max: THRESHOLD
65296 }
65297 });
65298 }
65299 }
65300
65301 };
65302 }
65303
65304 };
65305
65306 /***/ }),
65307 /* 572 */
65308 /***/ ((module) => {
65309
65310 "use strict";
65311 /**
65312 * @fileoverview Utilities to operate on strings.
65313 * @author Stephen Wade
65314 */
65315
65316 /**
65317 * Converts the first letter of a string to uppercase.
65318 * @param {string} string The string to operate on
65319 * @returns {string} The converted string
65320 */
65321
65322 function upperCaseFirst(string) {
65323 if (string.length <= 1) {
65324 return string.toUpperCase();
65325 }
65326
65327 return string[0].toUpperCase() + string.slice(1);
65328 }
65329
65330 module.exports = {
65331 upperCaseFirst
65332 };
65333
65334 /***/ }),
65335 /* 573 */
65336 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
65337
65338 "use strict";
65339 /**
65340 * @fileoverview Disallows or enforces spaces inside computed properties.
65341 * @author Jamund Ferguson
65342 */
65343
65344
65345 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
65346 // Rule Definition
65347 //------------------------------------------------------------------------------
65348
65349
65350 module.exports = {
65351 meta: {
65352 type: "layout",
65353 docs: {
65354 description: "enforce consistent spacing inside computed property brackets",
65355 recommended: false,
65356 url: "https://eslint.org/docs/rules/computed-property-spacing"
65357 },
65358 fixable: "whitespace",
65359 schema: [{
65360 enum: ["always", "never"]
65361 }, {
65362 type: "object",
65363 properties: {
65364 enforceForClassMembers: {
65365 type: "boolean",
65366 default: true
65367 }
65368 },
65369 additionalProperties: false
65370 }],
65371 messages: {
65372 unexpectedSpaceBefore: "There should be no space before '{{tokenValue}}'.",
65373 unexpectedSpaceAfter: "There should be no space after '{{tokenValue}}'.",
65374 missingSpaceBefore: "A space is required before '{{tokenValue}}'.",
65375 missingSpaceAfter: "A space is required after '{{tokenValue}}'."
65376 }
65377 },
65378
65379 create(context) {
65380 const sourceCode = context.getSourceCode();
65381 const propertyNameMustBeSpaced = context.options[0] === "always"; // default is "never"
65382
65383 const enforceForClassMembers = !context.options[1] || context.options[1].enforceForClassMembers; //--------------------------------------------------------------------------
65384 // Helpers
65385 //--------------------------------------------------------------------------
65386
65387 /**
65388 * Reports that there shouldn't be a space after the first token
65389 * @param {ASTNode} node The node to report in the event of an error.
65390 * @param {Token} token The token to use for the report.
65391 * @param {Token} tokenAfter The token after `token`.
65392 * @returns {void}
65393 */
65394
65395 function reportNoBeginningSpace(node, token, tokenAfter) {
65396 context.report({
65397 node,
65398 loc: {
65399 start: token.loc.end,
65400 end: tokenAfter.loc.start
65401 },
65402 messageId: "unexpectedSpaceAfter",
65403 data: {
65404 tokenValue: token.value
65405 },
65406
65407 fix(fixer) {
65408 return fixer.removeRange([token.range[1], tokenAfter.range[0]]);
65409 }
65410
65411 });
65412 }
65413 /**
65414 * Reports that there shouldn't be a space before the last token
65415 * @param {ASTNode} node The node to report in the event of an error.
65416 * @param {Token} token The token to use for the report.
65417 * @param {Token} tokenBefore The token before `token`.
65418 * @returns {void}
65419 */
65420
65421
65422 function reportNoEndingSpace(node, token, tokenBefore) {
65423 context.report({
65424 node,
65425 loc: {
65426 start: tokenBefore.loc.end,
65427 end: token.loc.start
65428 },
65429 messageId: "unexpectedSpaceBefore",
65430 data: {
65431 tokenValue: token.value
65432 },
65433
65434 fix(fixer) {
65435 return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
65436 }
65437
65438 });
65439 }
65440 /**
65441 * Reports that there should be a space after the first token
65442 * @param {ASTNode} node The node to report in the event of an error.
65443 * @param {Token} token The token to use for the report.
65444 * @returns {void}
65445 */
65446
65447
65448 function reportRequiredBeginningSpace(node, token) {
65449 context.report({
65450 node,
65451 loc: token.loc,
65452 messageId: "missingSpaceAfter",
65453 data: {
65454 tokenValue: token.value
65455 },
65456
65457 fix(fixer) {
65458 return fixer.insertTextAfter(token, " ");
65459 }
65460
65461 });
65462 }
65463 /**
65464 * Reports that there should be a space before the last token
65465 * @param {ASTNode} node The node to report in the event of an error.
65466 * @param {Token} token The token to use for the report.
65467 * @returns {void}
65468 */
65469
65470
65471 function reportRequiredEndingSpace(node, token) {
65472 context.report({
65473 node,
65474 loc: token.loc,
65475 messageId: "missingSpaceBefore",
65476 data: {
65477 tokenValue: token.value
65478 },
65479
65480 fix(fixer) {
65481 return fixer.insertTextBefore(token, " ");
65482 }
65483
65484 });
65485 }
65486 /**
65487 * Returns a function that checks the spacing of a node on the property name
65488 * that was passed in.
65489 * @param {string} propertyName The property on the node to check for spacing
65490 * @returns {Function} A function that will check spacing on a node
65491 */
65492
65493
65494 function checkSpacing(propertyName) {
65495 return function (node) {
65496 if (!node.computed) {
65497 return;
65498 }
65499
65500 const property = node[propertyName];
65501 const before = sourceCode.getTokenBefore(property, astUtils.isOpeningBracketToken),
65502 first = sourceCode.getTokenAfter(before, {
65503 includeComments: true
65504 }),
65505 after = sourceCode.getTokenAfter(property, astUtils.isClosingBracketToken),
65506 last = sourceCode.getTokenBefore(after, {
65507 includeComments: true
65508 });
65509
65510 if (astUtils.isTokenOnSameLine(before, first)) {
65511 if (propertyNameMustBeSpaced) {
65512 if (!sourceCode.isSpaceBetweenTokens(before, first) && astUtils.isTokenOnSameLine(before, first)) {
65513 reportRequiredBeginningSpace(node, before);
65514 }
65515 } else {
65516 if (sourceCode.isSpaceBetweenTokens(before, first)) {
65517 reportNoBeginningSpace(node, before, first);
65518 }
65519 }
65520 }
65521
65522 if (astUtils.isTokenOnSameLine(last, after)) {
65523 if (propertyNameMustBeSpaced) {
65524 if (!sourceCode.isSpaceBetweenTokens(last, after) && astUtils.isTokenOnSameLine(last, after)) {
65525 reportRequiredEndingSpace(node, after);
65526 }
65527 } else {
65528 if (sourceCode.isSpaceBetweenTokens(last, after)) {
65529 reportNoEndingSpace(node, after, last);
65530 }
65531 }
65532 }
65533 };
65534 } //--------------------------------------------------------------------------
65535 // Public
65536 //--------------------------------------------------------------------------
65537
65538
65539 const listeners = {
65540 Property: checkSpacing("key"),
65541 MemberExpression: checkSpacing("property")
65542 };
65543
65544 if (enforceForClassMembers) {
65545 listeners.MethodDefinition = listeners.PropertyDefinition = listeners.Property;
65546 }
65547
65548 return listeners;
65549 }
65550
65551 };
65552
65553 /***/ }),
65554 /* 574 */
65555 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
65556
65557 "use strict";
65558 /**
65559 * @fileoverview Rule to flag consistent return values
65560 * @author Nicholas C. Zakas
65561 */
65562 //------------------------------------------------------------------------------
65563 // Requirements
65564 //------------------------------------------------------------------------------
65565
65566 const astUtils = __webpack_require__(548);
65567
65568 const {
65569 upperCaseFirst
65570 } = __webpack_require__(572); //------------------------------------------------------------------------------
65571 // Helpers
65572 //------------------------------------------------------------------------------
65573
65574 /**
65575 * Checks whether or not a given code path segment is unreachable.
65576 * @param {CodePathSegment} segment A CodePathSegment to check.
65577 * @returns {boolean} `true` if the segment is unreachable.
65578 */
65579
65580
65581 function isUnreachable(segment) {
65582 return !segment.reachable;
65583 }
65584 /**
65585 * Checks whether a given node is a `constructor` method in an ES6 class
65586 * @param {ASTNode} node A node to check
65587 * @returns {boolean} `true` if the node is a `constructor` method
65588 */
65589
65590
65591 function isClassConstructor(node) {
65592 return node.type === "FunctionExpression" && node.parent && node.parent.type === "MethodDefinition" && node.parent.kind === "constructor";
65593 } //------------------------------------------------------------------------------
65594 // Rule Definition
65595 //------------------------------------------------------------------------------
65596
65597
65598 module.exports = {
65599 meta: {
65600 type: "suggestion",
65601 docs: {
65602 description: "require `return` statements to either always or never specify values",
65603 recommended: false,
65604 url: "https://eslint.org/docs/rules/consistent-return"
65605 },
65606 schema: [{
65607 type: "object",
65608 properties: {
65609 treatUndefinedAsUnspecified: {
65610 type: "boolean",
65611 default: false
65612 }
65613 },
65614 additionalProperties: false
65615 }],
65616 messages: {
65617 missingReturn: "Expected to return a value at the end of {{name}}.",
65618 missingReturnValue: "{{name}} expected a return value.",
65619 unexpectedReturnValue: "{{name}} expected no return value."
65620 }
65621 },
65622
65623 create(context) {
65624 const options = context.options[0] || {};
65625 const treatUndefinedAsUnspecified = options.treatUndefinedAsUnspecified === true;
65626 let funcInfo = null;
65627 /**
65628 * Checks whether of not the implicit returning is consistent if the last
65629 * code path segment is reachable.
65630 * @param {ASTNode} node A program/function node to check.
65631 * @returns {void}
65632 */
65633
65634 function checkLastSegment(node) {
65635 let loc, name;
65636 /*
65637 * Skip if it expected no return value or unreachable.
65638 * When unreachable, all paths are returned or thrown.
65639 */
65640
65641 if (!funcInfo.hasReturnValue || funcInfo.codePath.currentSegments.every(isUnreachable) || astUtils.isES5Constructor(node) || isClassConstructor(node)) {
65642 return;
65643 } // Adjust a location and a message.
65644
65645
65646 if (node.type === "Program") {
65647 // The head of program.
65648 loc = {
65649 line: 1,
65650 column: 0
65651 };
65652 name = "program";
65653 } else if (node.type === "ArrowFunctionExpression") {
65654 // `=>` token
65655 loc = context.getSourceCode().getTokenBefore(node.body, astUtils.isArrowToken).loc;
65656 } else if (node.parent.type === "MethodDefinition" || node.parent.type === "Property" && node.parent.method) {
65657 // Method name.
65658 loc = node.parent.key.loc;
65659 } else {
65660 // Function name or `function` keyword.
65661 loc = (node.id || context.getSourceCode().getFirstToken(node)).loc;
65662 }
65663
65664 if (!name) {
65665 name = astUtils.getFunctionNameWithKind(node);
65666 } // Reports.
65667
65668
65669 context.report({
65670 node,
65671 loc,
65672 messageId: "missingReturn",
65673 data: {
65674 name
65675 }
65676 });
65677 }
65678
65679 return {
65680 // Initializes/Disposes state of each code path.
65681 onCodePathStart(codePath, node) {
65682 funcInfo = {
65683 upper: funcInfo,
65684 codePath,
65685 hasReturn: false,
65686 hasReturnValue: false,
65687 messageId: "",
65688 node
65689 };
65690 },
65691
65692 onCodePathEnd() {
65693 funcInfo = funcInfo.upper;
65694 },
65695
65696 // Reports a given return statement if it's inconsistent.
65697 ReturnStatement(node) {
65698 const argument = node.argument;
65699 let hasReturnValue = Boolean(argument);
65700
65701 if (treatUndefinedAsUnspecified && hasReturnValue) {
65702 hasReturnValue = !astUtils.isSpecificId(argument, "undefined") && argument.operator !== "void";
65703 }
65704
65705 if (!funcInfo.hasReturn) {
65706 funcInfo.hasReturn = true;
65707 funcInfo.hasReturnValue = hasReturnValue;
65708 funcInfo.messageId = hasReturnValue ? "missingReturnValue" : "unexpectedReturnValue";
65709 funcInfo.data = {
65710 name: funcInfo.node.type === "Program" ? "Program" : upperCaseFirst(astUtils.getFunctionNameWithKind(funcInfo.node))
65711 };
65712 } else if (funcInfo.hasReturnValue !== hasReturnValue) {
65713 context.report({
65714 node,
65715 messageId: funcInfo.messageId,
65716 data: funcInfo.data
65717 });
65718 }
65719 },
65720
65721 // Reports a given program/function if the implicit returning is not consistent.
65722 "Program:exit": checkLastSegment,
65723 "FunctionDeclaration:exit": checkLastSegment,
65724 "FunctionExpression:exit": checkLastSegment,
65725 "ArrowFunctionExpression:exit": checkLastSegment
65726 };
65727 }
65728
65729 };
65730
65731 /***/ }),
65732 /* 575 */
65733 /***/ ((module) => {
65734
65735 "use strict";
65736 /**
65737 * @fileoverview Rule to enforce consistent naming of "this" context variables
65738 * @author Raphael Pigulla
65739 */
65740 //------------------------------------------------------------------------------
65741 // Rule Definition
65742 //------------------------------------------------------------------------------
65743
65744 module.exports = {
65745 meta: {
65746 type: "suggestion",
65747 docs: {
65748 description: "enforce consistent naming when capturing the current execution context",
65749 recommended: false,
65750 url: "https://eslint.org/docs/rules/consistent-this"
65751 },
65752 schema: {
65753 type: "array",
65754 items: {
65755 type: "string",
65756 minLength: 1
65757 },
65758 uniqueItems: true
65759 },
65760 messages: {
65761 aliasNotAssignedToThis: "Designated alias '{{name}}' is not assigned to 'this'.",
65762 unexpectedAlias: "Unexpected alias '{{name}}' for 'this'."
65763 }
65764 },
65765
65766 create(context) {
65767 let aliases = [];
65768
65769 if (context.options.length === 0) {
65770 aliases.push("that");
65771 } else {
65772 aliases = context.options;
65773 }
65774 /**
65775 * Reports that a variable declarator or assignment expression is assigning
65776 * a non-'this' value to the specified alias.
65777 * @param {ASTNode} node The assigning node.
65778 * @param {string} name the name of the alias that was incorrectly used.
65779 * @returns {void}
65780 */
65781
65782
65783 function reportBadAssignment(node, name) {
65784 context.report({
65785 node,
65786 messageId: "aliasNotAssignedToThis",
65787 data: {
65788 name
65789 }
65790 });
65791 }
65792 /**
65793 * Checks that an assignment to an identifier only assigns 'this' to the
65794 * appropriate alias, and the alias is only assigned to 'this'.
65795 * @param {ASTNode} node The assigning node.
65796 * @param {Identifier} name The name of the variable assigned to.
65797 * @param {Expression} value The value of the assignment.
65798 * @returns {void}
65799 */
65800
65801
65802 function checkAssignment(node, name, value) {
65803 const isThis = value.type === "ThisExpression";
65804
65805 if (aliases.indexOf(name) !== -1) {
65806 if (!isThis || node.operator && node.operator !== "=") {
65807 reportBadAssignment(node, name);
65808 }
65809 } else if (isThis) {
65810 context.report({
65811 node,
65812 messageId: "unexpectedAlias",
65813 data: {
65814 name
65815 }
65816 });
65817 }
65818 }
65819 /**
65820 * Ensures that a variable declaration of the alias in a program or function
65821 * is assigned to the correct value.
65822 * @param {string} alias alias the check the assignment of.
65823 * @param {Object} scope scope of the current code we are checking.
65824 * @private
65825 * @returns {void}
65826 */
65827
65828
65829 function checkWasAssigned(alias, scope) {
65830 const variable = scope.set.get(alias);
65831
65832 if (!variable) {
65833 return;
65834 }
65835
65836 if (variable.defs.some(def => def.node.type === "VariableDeclarator" && def.node.init !== null)) {
65837 return;
65838 }
65839 /*
65840 * The alias has been declared and not assigned: check it was
65841 * assigned later in the same scope.
65842 */
65843
65844
65845 if (!variable.references.some(reference => {
65846 const write = reference.writeExpr;
65847 return reference.from === scope && write && write.type === "ThisExpression" && write.parent.operator === "=";
65848 })) {
65849 variable.defs.map(def => def.node).forEach(node => {
65850 reportBadAssignment(node, alias);
65851 });
65852 }
65853 }
65854 /**
65855 * Check each alias to ensure that is was assigned to the correct value.
65856 * @returns {void}
65857 */
65858
65859
65860 function ensureWasAssigned() {
65861 const scope = context.getScope();
65862 aliases.forEach(alias => {
65863 checkWasAssigned(alias, scope);
65864 });
65865 }
65866
65867 return {
65868 "Program:exit": ensureWasAssigned,
65869 "FunctionExpression:exit": ensureWasAssigned,
65870 "FunctionDeclaration:exit": ensureWasAssigned,
65871
65872 VariableDeclarator(node) {
65873 const id = node.id;
65874 const isDestructuring = id.type === "ArrayPattern" || id.type === "ObjectPattern";
65875
65876 if (node.init !== null && !isDestructuring) {
65877 checkAssignment(node, id.name, node.init);
65878 }
65879 },
65880
65881 AssignmentExpression(node) {
65882 if (node.left.type === "Identifier") {
65883 checkAssignment(node, node.left.name, node.right);
65884 }
65885 }
65886
65887 };
65888 }
65889
65890 };
65891
65892 /***/ }),
65893 /* 576 */
65894 /***/ ((module) => {
65895
65896 "use strict";
65897 /**
65898 * @fileoverview A rule to verify `super()` callings in constructor.
65899 * @author Toru Nagashima
65900 */
65901 //------------------------------------------------------------------------------
65902 // Helpers
65903 //------------------------------------------------------------------------------
65904
65905 /**
65906 * Checks whether a given code path segment is reachable or not.
65907 * @param {CodePathSegment} segment A code path segment to check.
65908 * @returns {boolean} `true` if the segment is reachable.
65909 */
65910
65911 function isReachable(segment) {
65912 return segment.reachable;
65913 }
65914 /**
65915 * Checks whether or not a given node is a constructor.
65916 * @param {ASTNode} node A node to check. This node type is one of
65917 * `Program`, `FunctionDeclaration`, `FunctionExpression`, and
65918 * `ArrowFunctionExpression`.
65919 * @returns {boolean} `true` if the node is a constructor.
65920 */
65921
65922
65923 function isConstructorFunction(node) {
65924 return node.type === "FunctionExpression" && node.parent.type === "MethodDefinition" && node.parent.kind === "constructor";
65925 }
65926 /**
65927 * Checks whether a given node can be a constructor or not.
65928 * @param {ASTNode} node A node to check.
65929 * @returns {boolean} `true` if the node can be a constructor.
65930 */
65931
65932
65933 function isPossibleConstructor(node) {
65934 if (!node) {
65935 return false;
65936 }
65937
65938 switch (node.type) {
65939 case "ClassExpression":
65940 case "FunctionExpression":
65941 case "ThisExpression":
65942 case "MemberExpression":
65943 case "CallExpression":
65944 case "NewExpression":
65945 case "ChainExpression":
65946 case "YieldExpression":
65947 case "TaggedTemplateExpression":
65948 case "MetaProperty":
65949 return true;
65950
65951 case "Identifier":
65952 return node.name !== "undefined";
65953
65954 case "AssignmentExpression":
65955 if (["=", "&&="].includes(node.operator)) {
65956 return isPossibleConstructor(node.right);
65957 }
65958
65959 if (["||=", "??="].includes(node.operator)) {
65960 return isPossibleConstructor(node.left) || isPossibleConstructor(node.right);
65961 }
65962 /**
65963 * All other assignment operators are mathematical assignment operators (arithmetic or bitwise).
65964 * An assignment expression with a mathematical operator can either evaluate to a primitive value,
65965 * or throw, depending on the operands. Thus, it cannot evaluate to a constructor function.
65966 */
65967
65968
65969 return false;
65970
65971 case "LogicalExpression":
65972 /*
65973 * If the && operator short-circuits, the left side was falsy and therefore not a constructor, and if
65974 * it doesn't short-circuit, it takes the value from the right side, so the right side must always be a
65975 * possible constructor. A future improvement could verify that the left side could be truthy by
65976 * excluding falsy literals.
65977 */
65978 if (node.operator === "&&") {
65979 return isPossibleConstructor(node.right);
65980 }
65981
65982 return isPossibleConstructor(node.left) || isPossibleConstructor(node.right);
65983
65984 case "ConditionalExpression":
65985 return isPossibleConstructor(node.alternate) || isPossibleConstructor(node.consequent);
65986
65987 case "SequenceExpression":
65988 {
65989 const lastExpression = node.expressions[node.expressions.length - 1];
65990 return isPossibleConstructor(lastExpression);
65991 }
65992
65993 default:
65994 return false;
65995 }
65996 } //------------------------------------------------------------------------------
65997 // Rule Definition
65998 //------------------------------------------------------------------------------
65999
66000
66001 module.exports = {
66002 meta: {
66003 type: "problem",
66004 docs: {
66005 description: "require `super()` calls in constructors",
66006 recommended: true,
66007 url: "https://eslint.org/docs/rules/constructor-super"
66008 },
66009 schema: [],
66010 messages: {
66011 missingSome: "Lacked a call of 'super()' in some code paths.",
66012 missingAll: "Expected to call 'super()'.",
66013 duplicate: "Unexpected duplicate 'super()'.",
66014 badSuper: "Unexpected 'super()' because 'super' is not a constructor.",
66015 unexpected: "Unexpected 'super()'."
66016 }
66017 },
66018
66019 create(context) {
66020 /*
66021 * {{hasExtends: boolean, scope: Scope, codePath: CodePath}[]}
66022 * Information for each constructor.
66023 * - upper: Information of the upper constructor.
66024 * - hasExtends: A flag which shows whether own class has a valid `extends`
66025 * part.
66026 * - scope: The scope of own class.
66027 * - codePath: The code path object of the constructor.
66028 */
66029 let funcInfo = null;
66030 /*
66031 * {Map<string, {calledInSomePaths: boolean, calledInEveryPaths: boolean}>}
66032 * Information for each code path segment.
66033 * - calledInSomePaths: A flag of be called `super()` in some code paths.
66034 * - calledInEveryPaths: A flag of be called `super()` in all code paths.
66035 * - validNodes:
66036 */
66037
66038 let segInfoMap = Object.create(null);
66039 /**
66040 * Gets the flag which shows `super()` is called in some paths.
66041 * @param {CodePathSegment} segment A code path segment to get.
66042 * @returns {boolean} The flag which shows `super()` is called in some paths
66043 */
66044
66045 function isCalledInSomePath(segment) {
66046 return segment.reachable && segInfoMap[segment.id].calledInSomePaths;
66047 }
66048 /**
66049 * Gets the flag which shows `super()` is called in all paths.
66050 * @param {CodePathSegment} segment A code path segment to get.
66051 * @returns {boolean} The flag which shows `super()` is called in all paths.
66052 */
66053
66054
66055 function isCalledInEveryPath(segment) {
66056 /*
66057 * If specific segment is the looped segment of the current segment,
66058 * skip the segment.
66059 * If not skipped, this never becomes true after a loop.
66060 */
66061 if (segment.nextSegments.length === 1 && segment.nextSegments[0].isLoopedPrevSegment(segment)) {
66062 return true;
66063 }
66064
66065 return segment.reachable && segInfoMap[segment.id].calledInEveryPaths;
66066 }
66067
66068 return {
66069 /**
66070 * Stacks a constructor information.
66071 * @param {CodePath} codePath A code path which was started.
66072 * @param {ASTNode} node The current node.
66073 * @returns {void}
66074 */
66075 onCodePathStart(codePath, node) {
66076 if (isConstructorFunction(node)) {
66077 // Class > ClassBody > MethodDefinition > FunctionExpression
66078 const classNode = node.parent.parent.parent;
66079 const superClass = classNode.superClass;
66080 funcInfo = {
66081 upper: funcInfo,
66082 isConstructor: true,
66083 hasExtends: Boolean(superClass),
66084 superIsConstructor: isPossibleConstructor(superClass),
66085 codePath
66086 };
66087 } else {
66088 funcInfo = {
66089 upper: funcInfo,
66090 isConstructor: false,
66091 hasExtends: false,
66092 superIsConstructor: false,
66093 codePath
66094 };
66095 }
66096 },
66097
66098 /**
66099 * Pops a constructor information.
66100 * And reports if `super()` lacked.
66101 * @param {CodePath} codePath A code path which was ended.
66102 * @param {ASTNode} node The current node.
66103 * @returns {void}
66104 */
66105 onCodePathEnd(codePath, node) {
66106 const hasExtends = funcInfo.hasExtends; // Pop.
66107
66108 funcInfo = funcInfo.upper;
66109
66110 if (!hasExtends) {
66111 return;
66112 } // Reports if `super()` lacked.
66113
66114
66115 const segments = codePath.returnedSegments;
66116 const calledInEveryPaths = segments.every(isCalledInEveryPath);
66117 const calledInSomePaths = segments.some(isCalledInSomePath);
66118
66119 if (!calledInEveryPaths) {
66120 context.report({
66121 messageId: calledInSomePaths ? "missingSome" : "missingAll",
66122 node: node.parent
66123 });
66124 }
66125 },
66126
66127 /**
66128 * Initialize information of a given code path segment.
66129 * @param {CodePathSegment} segment A code path segment to initialize.
66130 * @returns {void}
66131 */
66132 onCodePathSegmentStart(segment) {
66133 if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) {
66134 return;
66135 } // Initialize info.
66136
66137
66138 const info = segInfoMap[segment.id] = {
66139 calledInSomePaths: false,
66140 calledInEveryPaths: false,
66141 validNodes: []
66142 }; // When there are previous segments, aggregates these.
66143
66144 const prevSegments = segment.prevSegments;
66145
66146 if (prevSegments.length > 0) {
66147 info.calledInSomePaths = prevSegments.some(isCalledInSomePath);
66148 info.calledInEveryPaths = prevSegments.every(isCalledInEveryPath);
66149 }
66150 },
66151
66152 /**
66153 * Update information of the code path segment when a code path was
66154 * looped.
66155 * @param {CodePathSegment} fromSegment The code path segment of the
66156 * end of a loop.
66157 * @param {CodePathSegment} toSegment A code path segment of the head
66158 * of a loop.
66159 * @returns {void}
66160 */
66161 onCodePathSegmentLoop(fromSegment, toSegment) {
66162 if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) {
66163 return;
66164 } // Update information inside of the loop.
66165
66166
66167 const isRealLoop = toSegment.prevSegments.length >= 2;
66168 funcInfo.codePath.traverseSegments({
66169 first: toSegment,
66170 last: fromSegment
66171 }, segment => {
66172 const info = segInfoMap[segment.id];
66173 const prevSegments = segment.prevSegments; // Updates flags.
66174
66175 info.calledInSomePaths = prevSegments.some(isCalledInSomePath);
66176 info.calledInEveryPaths = prevSegments.every(isCalledInEveryPath); // If flags become true anew, reports the valid nodes.
66177
66178 if (info.calledInSomePaths || isRealLoop) {
66179 const nodes = info.validNodes;
66180 info.validNodes = [];
66181
66182 for (let i = 0; i < nodes.length; ++i) {
66183 const node = nodes[i];
66184 context.report({
66185 messageId: "duplicate",
66186 node
66187 });
66188 }
66189 }
66190 });
66191 },
66192
66193 /**
66194 * Checks for a call of `super()`.
66195 * @param {ASTNode} node A CallExpression node to check.
66196 * @returns {void}
66197 */
66198 "CallExpression:exit"(node) {
66199 if (!(funcInfo && funcInfo.isConstructor)) {
66200 return;
66201 } // Skips except `super()`.
66202
66203
66204 if (node.callee.type !== "Super") {
66205 return;
66206 } // Reports if needed.
66207
66208
66209 if (funcInfo.hasExtends) {
66210 const segments = funcInfo.codePath.currentSegments;
66211 let duplicate = false;
66212 let info = null;
66213
66214 for (let i = 0; i < segments.length; ++i) {
66215 const segment = segments[i];
66216
66217 if (segment.reachable) {
66218 info = segInfoMap[segment.id];
66219 duplicate = duplicate || info.calledInSomePaths;
66220 info.calledInSomePaths = info.calledInEveryPaths = true;
66221 }
66222 }
66223
66224 if (info) {
66225 if (duplicate) {
66226 context.report({
66227 messageId: "duplicate",
66228 node
66229 });
66230 } else if (!funcInfo.superIsConstructor) {
66231 context.report({
66232 messageId: "badSuper",
66233 node
66234 });
66235 } else {
66236 info.validNodes.push(node);
66237 }
66238 }
66239 } else if (funcInfo.codePath.currentSegments.some(isReachable)) {
66240 context.report({
66241 messageId: "unexpected",
66242 node
66243 });
66244 }
66245 },
66246
66247 /**
66248 * Set the mark to the returned path as `super()` was called.
66249 * @param {ASTNode} node A ReturnStatement node to check.
66250 * @returns {void}
66251 */
66252 ReturnStatement(node) {
66253 if (!(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends)) {
66254 return;
66255 } // Skips if no argument.
66256
66257
66258 if (!node.argument) {
66259 return;
66260 } // Returning argument is a substitute of 'super()'.
66261
66262
66263 const segments = funcInfo.codePath.currentSegments;
66264
66265 for (let i = 0; i < segments.length; ++i) {
66266 const segment = segments[i];
66267
66268 if (segment.reachable) {
66269 const info = segInfoMap[segment.id];
66270 info.calledInSomePaths = info.calledInEveryPaths = true;
66271 }
66272 }
66273 },
66274
66275 /**
66276 * Resets state.
66277 * @returns {void}
66278 */
66279 "Program:exit"() {
66280 segInfoMap = Object.create(null);
66281 }
66282
66283 };
66284 }
66285
66286 };
66287
66288 /***/ }),
66289 /* 577 */
66290 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
66291
66292 "use strict";
66293 /**
66294 * @fileoverview Rule to flag statements without curly braces
66295 * @author Nicholas C. Zakas
66296 */
66297 //------------------------------------------------------------------------------
66298 // Requirements
66299 //------------------------------------------------------------------------------
66300
66301 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
66302 // Rule Definition
66303 //------------------------------------------------------------------------------
66304
66305
66306 module.exports = {
66307 meta: {
66308 type: "suggestion",
66309 docs: {
66310 description: "enforce consistent brace style for all control statements",
66311 recommended: false,
66312 url: "https://eslint.org/docs/rules/curly"
66313 },
66314 schema: {
66315 anyOf: [{
66316 type: "array",
66317 items: [{
66318 enum: ["all"]
66319 }],
66320 minItems: 0,
66321 maxItems: 1
66322 }, {
66323 type: "array",
66324 items: [{
66325 enum: ["multi", "multi-line", "multi-or-nest"]
66326 }, {
66327 enum: ["consistent"]
66328 }],
66329 minItems: 0,
66330 maxItems: 2
66331 }]
66332 },
66333 fixable: "code",
66334 messages: {
66335 missingCurlyAfter: "Expected { after '{{name}}'.",
66336 missingCurlyAfterCondition: "Expected { after '{{name}}' condition.",
66337 unexpectedCurlyAfter: "Unnecessary { after '{{name}}'.",
66338 unexpectedCurlyAfterCondition: "Unnecessary { after '{{name}}' condition."
66339 }
66340 },
66341
66342 create(context) {
66343 const multiOnly = context.options[0] === "multi";
66344 const multiLine = context.options[0] === "multi-line";
66345 const multiOrNest = context.options[0] === "multi-or-nest";
66346 const consistent = context.options[1] === "consistent";
66347 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
66348 // Helpers
66349 //--------------------------------------------------------------------------
66350
66351 /**
66352 * Determines if a given node is a one-liner that's on the same line as it's preceding code.
66353 * @param {ASTNode} node The node to check.
66354 * @returns {boolean} True if the node is a one-liner that's on the same line as it's preceding code.
66355 * @private
66356 */
66357
66358 function isCollapsedOneLiner(node) {
66359 const before = sourceCode.getTokenBefore(node);
66360 const last = sourceCode.getLastToken(node);
66361 const lastExcludingSemicolon = astUtils.isSemicolonToken(last) ? sourceCode.getTokenBefore(last) : last;
66362 return before.loc.start.line === lastExcludingSemicolon.loc.end.line;
66363 }
66364 /**
66365 * Determines if a given node is a one-liner.
66366 * @param {ASTNode} node The node to check.
66367 * @returns {boolean} True if the node is a one-liner.
66368 * @private
66369 */
66370
66371
66372 function isOneLiner(node) {
66373 if (node.type === "EmptyStatement") {
66374 return true;
66375 }
66376
66377 const first = sourceCode.getFirstToken(node);
66378 const last = sourceCode.getLastToken(node);
66379 const lastExcludingSemicolon = astUtils.isSemicolonToken(last) ? sourceCode.getTokenBefore(last) : last;
66380 return first.loc.start.line === lastExcludingSemicolon.loc.end.line;
66381 }
66382 /**
66383 * Determines if the given node is a lexical declaration (let, const, function, or class)
66384 * @param {ASTNode} node The node to check
66385 * @returns {boolean} True if the node is a lexical declaration
66386 * @private
66387 */
66388
66389
66390 function isLexicalDeclaration(node) {
66391 if (node.type === "VariableDeclaration") {
66392 return node.kind === "const" || node.kind === "let";
66393 }
66394
66395 return node.type === "FunctionDeclaration" || node.type === "ClassDeclaration";
66396 }
66397 /**
66398 * Checks if the given token is an `else` token or not.
66399 * @param {Token} token The token to check.
66400 * @returns {boolean} `true` if the token is an `else` token.
66401 */
66402
66403
66404 function isElseKeywordToken(token) {
66405 return token.value === "else" && token.type === "Keyword";
66406 }
66407 /**
66408 * Determines whether the given node has an `else` keyword token as the first token after.
66409 * @param {ASTNode} node The node to check.
66410 * @returns {boolean} `true` if the node is followed by an `else` keyword token.
66411 */
66412
66413
66414 function isFollowedByElseKeyword(node) {
66415 const nextToken = sourceCode.getTokenAfter(node);
66416 return Boolean(nextToken) && isElseKeywordToken(nextToken);
66417 }
66418 /**
66419 * Determines if a semicolon needs to be inserted after removing a set of curly brackets, in order to avoid a SyntaxError.
66420 * @param {Token} closingBracket The } token
66421 * @returns {boolean} `true` if a semicolon needs to be inserted after the last statement in the block.
66422 */
66423
66424
66425 function needsSemicolon(closingBracket) {
66426 const tokenBefore = sourceCode.getTokenBefore(closingBracket);
66427 const tokenAfter = sourceCode.getTokenAfter(closingBracket);
66428 const lastBlockNode = sourceCode.getNodeByRangeIndex(tokenBefore.range[0]);
66429
66430 if (astUtils.isSemicolonToken(tokenBefore)) {
66431 // If the last statement already has a semicolon, don't add another one.
66432 return false;
66433 }
66434
66435 if (!tokenAfter) {
66436 // If there are no statements after this block, there is no need to add a semicolon.
66437 return false;
66438 }
66439
66440 if (lastBlockNode.type === "BlockStatement" && lastBlockNode.parent.type !== "FunctionExpression" && lastBlockNode.parent.type !== "ArrowFunctionExpression") {
66441 /*
66442 * If the last node surrounded by curly brackets is a BlockStatement (other than a FunctionExpression or an ArrowFunctionExpression),
66443 * don't insert a semicolon. Otherwise, the semicolon would be parsed as a separate statement, which would cause
66444 * a SyntaxError if it was followed by `else`.
66445 */
66446 return false;
66447 }
66448
66449 if (tokenBefore.loc.end.line === tokenAfter.loc.start.line) {
66450 // If the next token is on the same line, insert a semicolon.
66451 return true;
66452 }
66453
66454 if (/^[([/`+-]/u.test(tokenAfter.value)) {
66455 // If the next token starts with a character that would disrupt ASI, insert a semicolon.
66456 return true;
66457 }
66458
66459 if (tokenBefore.type === "Punctuator" && (tokenBefore.value === "++" || tokenBefore.value === "--")) {
66460 // If the last token is ++ or --, insert a semicolon to avoid disrupting ASI.
66461 return true;
66462 } // Otherwise, do not insert a semicolon.
66463
66464
66465 return false;
66466 }
66467 /**
66468 * Determines whether the code represented by the given node contains an `if` statement
66469 * that would become associated with an `else` keyword directly appended to that code.
66470 *
66471 * Examples where it returns `true`:
66472 *
66473 * if (a)
66474 * foo();
66475 *
66476 * if (a) {
66477 * foo();
66478 * }
66479 *
66480 * if (a)
66481 * foo();
66482 * else if (b)
66483 * bar();
66484 *
66485 * while (a)
66486 * if (b)
66487 * if(c)
66488 * foo();
66489 * else
66490 * bar();
66491 *
66492 * Examples where it returns `false`:
66493 *
66494 * if (a)
66495 * foo();
66496 * else
66497 * bar();
66498 *
66499 * while (a) {
66500 * if (b)
66501 * if(c)
66502 * foo();
66503 * else
66504 * bar();
66505 * }
66506 *
66507 * while (a)
66508 * if (b) {
66509 * if(c)
66510 * foo();
66511 * }
66512 * else
66513 * bar();
66514 * @param {ASTNode} node Node representing the code to check.
66515 * @returns {boolean} `true` if an `if` statement within the code would become associated with an `else` appended to that code.
66516 */
66517
66518
66519 function hasUnsafeIf(node) {
66520 switch (node.type) {
66521 case "IfStatement":
66522 if (!node.alternate) {
66523 return true;
66524 }
66525
66526 return hasUnsafeIf(node.alternate);
66527
66528 case "ForStatement":
66529 case "ForInStatement":
66530 case "ForOfStatement":
66531 case "LabeledStatement":
66532 case "WithStatement":
66533 case "WhileStatement":
66534 return hasUnsafeIf(node.body);
66535
66536 default:
66537 return false;
66538 }
66539 }
66540 /**
66541 * Determines whether the existing curly braces around the single statement are necessary to preserve the semantics of the code.
66542 * The braces, which make the given block body, are necessary in either of the following situations:
66543 *
66544 * 1. The statement is a lexical declaration.
66545 * 2. Without the braces, an `if` within the statement would become associated with an `else` after the closing brace:
66546 *
66547 * if (a) {
66548 * if (b)
66549 * foo();
66550 * }
66551 * else
66552 * bar();
66553 *
66554 * if (a)
66555 * while (b)
66556 * while (c) {
66557 * while (d)
66558 * if (e)
66559 * while(f)
66560 * foo();
66561 * }
66562 * else
66563 * bar();
66564 * @param {ASTNode} node `BlockStatement` body with exactly one statement directly inside. The statement can have its own nested statements.
66565 * @returns {boolean} `true` if the braces are necessary - removing them (replacing the given `BlockStatement` body with its single statement content)
66566 * would change the semantics of the code or produce a syntax error.
66567 */
66568
66569
66570 function areBracesNecessary(node) {
66571 const statement = node.body[0];
66572 return isLexicalDeclaration(statement) || hasUnsafeIf(statement) && isFollowedByElseKeyword(node);
66573 }
66574 /**
66575 * Prepares to check the body of a node to see if it's a block statement.
66576 * @param {ASTNode} node The node to report if there's a problem.
66577 * @param {ASTNode} body The body node to check for blocks.
66578 * @param {string} name The name to report if there's a problem.
66579 * @param {{ condition: boolean }} opts Options to pass to the report functions
66580 * @returns {Object} a prepared check object, with "actual", "expected", "check" properties.
66581 * "actual" will be `true` or `false` whether the body is already a block statement.
66582 * "expected" will be `true` or `false` if the body should be a block statement or not, or
66583 * `null` if it doesn't matter, depending on the rule options. It can be modified to change
66584 * the final behavior of "check".
66585 * "check" will be a function reporting appropriate problems depending on the other
66586 * properties.
66587 */
66588
66589
66590 function prepareCheck(node, body, name, opts) {
66591 const hasBlock = body.type === "BlockStatement";
66592 let expected = null;
66593
66594 if (hasBlock && (body.body.length !== 1 || areBracesNecessary(body))) {
66595 expected = true;
66596 } else if (multiOnly) {
66597 expected = false;
66598 } else if (multiLine) {
66599 if (!isCollapsedOneLiner(body)) {
66600 expected = true;
66601 } // otherwise, the body is allowed to have braces or not to have braces
66602
66603 } else if (multiOrNest) {
66604 if (hasBlock) {
66605 const statement = body.body[0];
66606 const leadingCommentsInBlock = sourceCode.getCommentsBefore(statement);
66607 expected = !isOneLiner(statement) || leadingCommentsInBlock.length > 0;
66608 } else {
66609 expected = !isOneLiner(body);
66610 }
66611 } else {
66612 // default "all"
66613 expected = true;
66614 }
66615
66616 return {
66617 actual: hasBlock,
66618 expected,
66619
66620 check() {
66621 if (this.expected !== null && this.expected !== this.actual) {
66622 if (this.expected) {
66623 context.report({
66624 node,
66625 loc: body.loc,
66626 messageId: opts && opts.condition ? "missingCurlyAfterCondition" : "missingCurlyAfter",
66627 data: {
66628 name
66629 },
66630 fix: fixer => fixer.replaceText(body, "{".concat(sourceCode.getText(body), "}"))
66631 });
66632 } else {
66633 context.report({
66634 node,
66635 loc: body.loc,
66636 messageId: opts && opts.condition ? "unexpectedCurlyAfterCondition" : "unexpectedCurlyAfter",
66637 data: {
66638 name
66639 },
66640
66641 fix(fixer) {
66642 /*
66643 * `do while` expressions sometimes need a space to be inserted after `do`.
66644 * e.g. `do{foo()} while (bar)` should be corrected to `do foo() while (bar)`
66645 */
66646 const needsPrecedingSpace = node.type === "DoWhileStatement" && sourceCode.getTokenBefore(body).range[1] === body.range[0] && !astUtils.canTokensBeAdjacent("do", sourceCode.getFirstToken(body, {
66647 skip: 1
66648 }));
66649 const openingBracket = sourceCode.getFirstToken(body);
66650 const closingBracket = sourceCode.getLastToken(body);
66651 const lastTokenInBlock = sourceCode.getTokenBefore(closingBracket);
66652
66653 if (needsSemicolon(closingBracket)) {
66654 /*
66655 * If removing braces would cause a SyntaxError due to multiple statements on the same line (or
66656 * change the semantics of the code due to ASI), don't perform a fix.
66657 */
66658 return null;
66659 }
66660
66661 const resultingBodyText = sourceCode.getText().slice(openingBracket.range[1], lastTokenInBlock.range[0]) + sourceCode.getText(lastTokenInBlock) + sourceCode.getText().slice(lastTokenInBlock.range[1], closingBracket.range[0]);
66662 return fixer.replaceText(body, (needsPrecedingSpace ? " " : "") + resultingBodyText);
66663 }
66664
66665 });
66666 }
66667 }
66668 }
66669
66670 };
66671 }
66672 /**
66673 * Prepares to check the bodies of a "if", "else if" and "else" chain.
66674 * @param {ASTNode} node The first IfStatement node of the chain.
66675 * @returns {Object[]} prepared checks for each body of the chain. See `prepareCheck` for more
66676 * information.
66677 */
66678
66679
66680 function prepareIfChecks(node) {
66681 const preparedChecks = [];
66682
66683 for (let currentNode = node; currentNode; currentNode = currentNode.alternate) {
66684 preparedChecks.push(prepareCheck(currentNode, currentNode.consequent, "if", {
66685 condition: true
66686 }));
66687
66688 if (currentNode.alternate && currentNode.alternate.type !== "IfStatement") {
66689 preparedChecks.push(prepareCheck(currentNode, currentNode.alternate, "else"));
66690 break;
66691 }
66692 }
66693
66694 if (consistent) {
66695 /*
66696 * If any node should have or already have braces, make sure they
66697 * all have braces.
66698 * If all nodes shouldn't have braces, make sure they don't.
66699 */
66700 const expected = preparedChecks.some(preparedCheck => {
66701 if (preparedCheck.expected !== null) {
66702 return preparedCheck.expected;
66703 }
66704
66705 return preparedCheck.actual;
66706 });
66707 preparedChecks.forEach(preparedCheck => {
66708 preparedCheck.expected = expected;
66709 });
66710 }
66711
66712 return preparedChecks;
66713 } //--------------------------------------------------------------------------
66714 // Public
66715 //--------------------------------------------------------------------------
66716
66717
66718 return {
66719 IfStatement(node) {
66720 const parent = node.parent;
66721 const isElseIf = parent.type === "IfStatement" && parent.alternate === node;
66722
66723 if (!isElseIf) {
66724 // This is a top `if`, check the whole `if-else-if` chain
66725 prepareIfChecks(node).forEach(preparedCheck => {
66726 preparedCheck.check();
66727 });
66728 } // Skip `else if`, it's already checked (when the top `if` was visited)
66729
66730 },
66731
66732 WhileStatement(node) {
66733 prepareCheck(node, node.body, "while", {
66734 condition: true
66735 }).check();
66736 },
66737
66738 DoWhileStatement(node) {
66739 prepareCheck(node, node.body, "do").check();
66740 },
66741
66742 ForStatement(node) {
66743 prepareCheck(node, node.body, "for", {
66744 condition: true
66745 }).check();
66746 },
66747
66748 ForInStatement(node) {
66749 prepareCheck(node, node.body, "for-in").check();
66750 },
66751
66752 ForOfStatement(node) {
66753 prepareCheck(node, node.body, "for-of").check();
66754 }
66755
66756 };
66757 }
66758
66759 };
66760
66761 /***/ }),
66762 /* 578 */
66763 /***/ ((module) => {
66764
66765 "use strict";
66766 /**
66767 * @fileoverview require default case in switch statements
66768 * @author Aliaksei Shytkin
66769 */
66770
66771
66772 const DEFAULT_COMMENT_PATTERN = /^no default$/iu; //------------------------------------------------------------------------------
66773 // Rule Definition
66774 //------------------------------------------------------------------------------
66775
66776 module.exports = {
66777 meta: {
66778 type: "suggestion",
66779 docs: {
66780 description: "require `default` cases in `switch` statements",
66781 recommended: false,
66782 url: "https://eslint.org/docs/rules/default-case"
66783 },
66784 schema: [{
66785 type: "object",
66786 properties: {
66787 commentPattern: {
66788 type: "string"
66789 }
66790 },
66791 additionalProperties: false
66792 }],
66793 messages: {
66794 missingDefaultCase: "Expected a default case."
66795 }
66796 },
66797
66798 create(context) {
66799 const options = context.options[0] || {};
66800 const commentPattern = options.commentPattern ? new RegExp(options.commentPattern, "u") : DEFAULT_COMMENT_PATTERN;
66801 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
66802 // Helpers
66803 //--------------------------------------------------------------------------
66804
66805 /**
66806 * Shortcut to get last element of array
66807 * @param {*[]} collection Array
66808 * @returns {any} Last element
66809 */
66810
66811 function last(collection) {
66812 return collection[collection.length - 1];
66813 } //--------------------------------------------------------------------------
66814 // Public
66815 //--------------------------------------------------------------------------
66816
66817
66818 return {
66819 SwitchStatement(node) {
66820 if (!node.cases.length) {
66821 /*
66822 * skip check of empty switch because there is no easy way
66823 * to extract comments inside it now
66824 */
66825 return;
66826 }
66827
66828 const hasDefault = node.cases.some(v => v.test === null);
66829
66830 if (!hasDefault) {
66831 let comment;
66832 const lastCase = last(node.cases);
66833 const comments = sourceCode.getCommentsAfter(lastCase);
66834
66835 if (comments.length) {
66836 comment = last(comments);
66837 }
66838
66839 if (!comment || !commentPattern.test(comment.value.trim())) {
66840 context.report({
66841 node,
66842 messageId: "missingDefaultCase"
66843 });
66844 }
66845 }
66846 }
66847
66848 };
66849 }
66850
66851 };
66852
66853 /***/ }),
66854 /* 579 */
66855 /***/ ((module) => {
66856
66857 "use strict";
66858 /**
66859 * @fileoverview Rule to enforce default clauses in switch statements to be last
66860 * @author Milos Djermanovic
66861 */
66862 //------------------------------------------------------------------------------
66863 // Rule Definition
66864 //------------------------------------------------------------------------------
66865
66866 module.exports = {
66867 meta: {
66868 type: "suggestion",
66869 docs: {
66870 description: "enforce default clauses in switch statements to be last",
66871 recommended: false,
66872 url: "https://eslint.org/docs/rules/default-case-last"
66873 },
66874 schema: [],
66875 messages: {
66876 notLast: "Default clause should be the last clause."
66877 }
66878 },
66879
66880 create(context) {
66881 return {
66882 SwitchStatement(node) {
66883 const cases = node.cases,
66884 indexOfDefault = cases.findIndex(c => c.test === null);
66885
66886 if (indexOfDefault !== -1 && indexOfDefault !== cases.length - 1) {
66887 const defaultClause = cases[indexOfDefault];
66888 context.report({
66889 node: defaultClause,
66890 messageId: "notLast"
66891 });
66892 }
66893 }
66894
66895 };
66896 }
66897
66898 };
66899
66900 /***/ }),
66901 /* 580 */
66902 /***/ ((module) => {
66903
66904 "use strict";
66905 /**
66906 * @fileoverview enforce default parameters to be last
66907 * @author Chiawen Chen
66908 */
66909
66910
66911 module.exports = {
66912 meta: {
66913 type: "suggestion",
66914 docs: {
66915 description: "enforce default parameters to be last",
66916 recommended: false,
66917 url: "https://eslint.org/docs/rules/default-param-last"
66918 },
66919 schema: [],
66920 messages: {
66921 shouldBeLast: "Default parameters should be last."
66922 }
66923 },
66924
66925 create(context) {
66926 /**
66927 * Handler for function contexts.
66928 * @param {ASTNode} node function node
66929 * @returns {void}
66930 */
66931 function handleFunction(node) {
66932 let hasSeenPlainParam = false;
66933
66934 for (let i = node.params.length - 1; i >= 0; i -= 1) {
66935 const param = node.params[i];
66936
66937 if (param.type !== "AssignmentPattern" && param.type !== "RestElement") {
66938 hasSeenPlainParam = true;
66939 continue;
66940 }
66941
66942 if (hasSeenPlainParam && param.type === "AssignmentPattern") {
66943 context.report({
66944 node: param,
66945 messageId: "shouldBeLast"
66946 });
66947 }
66948 }
66949 }
66950
66951 return {
66952 FunctionDeclaration: handleFunction,
66953 FunctionExpression: handleFunction,
66954 ArrowFunctionExpression: handleFunction
66955 };
66956 }
66957
66958 };
66959
66960 /***/ }),
66961 /* 581 */
66962 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
66963
66964 "use strict";
66965 /**
66966 * @fileoverview Validates newlines before and after dots
66967 * @author Greg Cochard
66968 */
66969
66970
66971 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
66972 // Rule Definition
66973 //------------------------------------------------------------------------------
66974
66975
66976 module.exports = {
66977 meta: {
66978 type: "layout",
66979 docs: {
66980 description: "enforce consistent newlines before and after dots",
66981 recommended: false,
66982 url: "https://eslint.org/docs/rules/dot-location"
66983 },
66984 schema: [{
66985 enum: ["object", "property"]
66986 }],
66987 fixable: "code",
66988 messages: {
66989 expectedDotAfterObject: "Expected dot to be on same line as object.",
66990 expectedDotBeforeProperty: "Expected dot to be on same line as property."
66991 }
66992 },
66993
66994 create(context) {
66995 const config = context.options[0]; // default to onObject if no preference is passed
66996
66997 const onObject = config === "object" || !config;
66998 const sourceCode = context.getSourceCode();
66999 /**
67000 * Reports if the dot between object and property is on the correct location.
67001 * @param {ASTNode} node The `MemberExpression` node.
67002 * @returns {void}
67003 */
67004
67005 function checkDotLocation(node) {
67006 const property = node.property;
67007 const dotToken = sourceCode.getTokenBefore(property);
67008
67009 if (onObject) {
67010 // `obj` expression can be parenthesized, but those paren tokens are not a part of the `obj` node.
67011 const tokenBeforeDot = sourceCode.getTokenBefore(dotToken);
67012
67013 if (!astUtils.isTokenOnSameLine(tokenBeforeDot, dotToken)) {
67014 context.report({
67015 node,
67016 loc: dotToken.loc,
67017 messageId: "expectedDotAfterObject",
67018
67019 *fix(fixer) {
67020 if (dotToken.value.startsWith(".") && astUtils.isDecimalIntegerNumericToken(tokenBeforeDot)) {
67021 yield fixer.insertTextAfter(tokenBeforeDot, " ".concat(dotToken.value));
67022 } else {
67023 yield fixer.insertTextAfter(tokenBeforeDot, dotToken.value);
67024 }
67025
67026 yield fixer.remove(dotToken);
67027 }
67028
67029 });
67030 }
67031 } else if (!astUtils.isTokenOnSameLine(dotToken, property)) {
67032 context.report({
67033 node,
67034 loc: dotToken.loc,
67035 messageId: "expectedDotBeforeProperty",
67036
67037 *fix(fixer) {
67038 yield fixer.remove(dotToken);
67039 yield fixer.insertTextBefore(property, dotToken.value);
67040 }
67041
67042 });
67043 }
67044 }
67045 /**
67046 * Checks the spacing of the dot within a member expression.
67047 * @param {ASTNode} node The node to check.
67048 * @returns {void}
67049 */
67050
67051
67052 function checkNode(node) {
67053 if (!node.computed) {
67054 checkDotLocation(node);
67055 }
67056 }
67057
67058 return {
67059 MemberExpression: checkNode
67060 };
67061 }
67062
67063 };
67064
67065 /***/ }),
67066 /* 582 */
67067 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
67068
67069 "use strict";
67070 /**
67071 * @fileoverview Rule to warn about using dot notation instead of square bracket notation when possible.
67072 * @author Josh Perez
67073 */
67074 //------------------------------------------------------------------------------
67075 // Requirements
67076 //------------------------------------------------------------------------------
67077
67078 const astUtils = __webpack_require__(548);
67079
67080 const keywords = __webpack_require__(583); //------------------------------------------------------------------------------
67081 // Rule Definition
67082 //------------------------------------------------------------------------------
67083
67084
67085 const validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/u; // `null` literal must be handled separately.
67086
67087 const literalTypesToCheck = new Set(["string", "boolean"]);
67088 module.exports = {
67089 meta: {
67090 type: "suggestion",
67091 docs: {
67092 description: "enforce dot notation whenever possible",
67093 recommended: false,
67094 url: "https://eslint.org/docs/rules/dot-notation"
67095 },
67096 schema: [{
67097 type: "object",
67098 properties: {
67099 allowKeywords: {
67100 type: "boolean",
67101 default: true
67102 },
67103 allowPattern: {
67104 type: "string",
67105 default: ""
67106 }
67107 },
67108 additionalProperties: false
67109 }],
67110 fixable: "code",
67111 messages: {
67112 useDot: "[{{key}}] is better written in dot notation.",
67113 useBrackets: ".{{key}} is a syntax error."
67114 }
67115 },
67116
67117 create(context) {
67118 const options = context.options[0] || {};
67119 const allowKeywords = options.allowKeywords === void 0 || options.allowKeywords;
67120 const sourceCode = context.getSourceCode();
67121 let allowPattern;
67122
67123 if (options.allowPattern) {
67124 allowPattern = new RegExp(options.allowPattern, "u");
67125 }
67126 /**
67127 * Check if the property is valid dot notation
67128 * @param {ASTNode} node The dot notation node
67129 * @param {string} value Value which is to be checked
67130 * @returns {void}
67131 */
67132
67133
67134 function checkComputedProperty(node, value) {
67135 if (validIdentifier.test(value) && (allowKeywords || keywords.indexOf(String(value)) === -1) && !(allowPattern && allowPattern.test(value))) {
67136 const formattedValue = node.property.type === "Literal" ? JSON.stringify(value) : "`".concat(value, "`");
67137 context.report({
67138 node: node.property,
67139 messageId: "useDot",
67140 data: {
67141 key: formattedValue
67142 },
67143
67144 *fix(fixer) {
67145 const leftBracket = sourceCode.getTokenAfter(node.object, astUtils.isOpeningBracketToken);
67146 const rightBracket = sourceCode.getLastToken(node);
67147 const nextToken = sourceCode.getTokenAfter(node); // Don't perform any fixes if there are comments inside the brackets.
67148
67149 if (sourceCode.commentsExistBetween(leftBracket, rightBracket)) {
67150 return;
67151 } // Replace the brackets by an identifier.
67152
67153
67154 if (!node.optional) {
67155 yield fixer.insertTextBefore(leftBracket, astUtils.isDecimalInteger(node.object) ? " ." : ".");
67156 }
67157
67158 yield fixer.replaceTextRange([leftBracket.range[0], rightBracket.range[1]], value); // Insert a space after the property if it will be connected to the next token.
67159
67160 if (nextToken && rightBracket.range[1] === nextToken.range[0] && !astUtils.canTokensBeAdjacent(String(value), nextToken)) {
67161 yield fixer.insertTextAfter(node, " ");
67162 }
67163 }
67164
67165 });
67166 }
67167 }
67168
67169 return {
67170 MemberExpression(node) {
67171 if (node.computed && node.property.type === "Literal" && (literalTypesToCheck.has(typeof node.property.value) || astUtils.isNullLiteral(node.property))) {
67172 checkComputedProperty(node, node.property.value);
67173 }
67174
67175 if (node.computed && node.property.type === "TemplateLiteral" && node.property.expressions.length === 0) {
67176 checkComputedProperty(node, node.property.quasis[0].value.cooked);
67177 }
67178
67179 if (!allowKeywords && !node.computed && node.property.type === "Identifier" && keywords.indexOf(String(node.property.name)) !== -1) {
67180 context.report({
67181 node: node.property,
67182 messageId: "useBrackets",
67183 data: {
67184 key: node.property.name
67185 },
67186
67187 *fix(fixer) {
67188 const dotToken = sourceCode.getTokenBefore(node.property); // A statement that starts with `let[` is parsed as a destructuring variable declaration, not a MemberExpression.
67189
67190 if (node.object.type === "Identifier" && node.object.name === "let" && !node.optional) {
67191 return;
67192 } // Don't perform any fixes if there are comments between the dot and the property name.
67193
67194
67195 if (sourceCode.commentsExistBetween(dotToken, node.property)) {
67196 return;
67197 } // Replace the identifier to brackets.
67198
67199
67200 if (!node.optional) {
67201 yield fixer.remove(dotToken);
67202 }
67203
67204 yield fixer.replaceText(node.property, "[\"".concat(node.property.name, "\"]"));
67205 }
67206
67207 });
67208 }
67209 }
67210
67211 };
67212 }
67213
67214 };
67215
67216 /***/ }),
67217 /* 583 */
67218 /***/ ((module) => {
67219
67220 "use strict";
67221 /**
67222 * @fileoverview A shared list of ES3 keywords.
67223 * @author Josh Perez
67224 */
67225
67226
67227 module.exports = ["abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with"];
67228
67229 /***/ }),
67230 /* 584 */
67231 /***/ ((module) => {
67232
67233 "use strict";
67234 /**
67235 * @fileoverview Require or disallow newline at the end of files
67236 * @author Nodeca Team <https://github.com/nodeca>
67237 */
67238 //------------------------------------------------------------------------------
67239 // Rule Definition
67240 //------------------------------------------------------------------------------
67241
67242 module.exports = {
67243 meta: {
67244 type: "layout",
67245 docs: {
67246 description: "require or disallow newline at the end of files",
67247 recommended: false,
67248 url: "https://eslint.org/docs/rules/eol-last"
67249 },
67250 fixable: "whitespace",
67251 schema: [{
67252 enum: ["always", "never", "unix", "windows"]
67253 }],
67254 messages: {
67255 missing: "Newline required at end of file but not found.",
67256 unexpected: "Newline not allowed at end of file."
67257 }
67258 },
67259
67260 create(context) {
67261 //--------------------------------------------------------------------------
67262 // Public
67263 //--------------------------------------------------------------------------
67264 return {
67265 Program: function checkBadEOF(node) {
67266 const sourceCode = context.getSourceCode(),
67267 src = sourceCode.getText(),
67268 lastLine = sourceCode.lines[sourceCode.lines.length - 1],
67269 location = {
67270 column: lastLine.length,
67271 line: sourceCode.lines.length
67272 },
67273 LF = "\n",
67274 CRLF = "\r".concat(LF),
67275 endsWithNewline = src.endsWith(LF);
67276 /*
67277 * Empty source is always valid: No content in file so we don't
67278 * need to lint for a newline on the last line of content.
67279 */
67280
67281 if (!src.length) {
67282 return;
67283 }
67284
67285 let mode = context.options[0] || "always",
67286 appendCRLF = false;
67287
67288 if (mode === "unix") {
67289 // `"unix"` should behave exactly as `"always"`
67290 mode = "always";
67291 }
67292
67293 if (mode === "windows") {
67294 // `"windows"` should behave exactly as `"always"`, but append CRLF in the fixer for backwards compatibility
67295 mode = "always";
67296 appendCRLF = true;
67297 }
67298
67299 if (mode === "always" && !endsWithNewline) {
67300 // File is not newline-terminated, but should be
67301 context.report({
67302 node,
67303 loc: location,
67304 messageId: "missing",
67305
67306 fix(fixer) {
67307 return fixer.insertTextAfterRange([0, src.length], appendCRLF ? CRLF : LF);
67308 }
67309
67310 });
67311 } else if (mode === "never" && endsWithNewline) {
67312 const secondLastLine = sourceCode.lines[sourceCode.lines.length - 2]; // File is newline-terminated, but shouldn't be
67313
67314 context.report({
67315 node,
67316 loc: {
67317 start: {
67318 line: sourceCode.lines.length - 1,
67319 column: secondLastLine.length
67320 },
67321 end: {
67322 line: sourceCode.lines.length,
67323 column: 0
67324 }
67325 },
67326 messageId: "unexpected",
67327
67328 fix(fixer) {
67329 const finalEOLs = /(?:\r?\n)+$/u,
67330 match = finalEOLs.exec(sourceCode.text),
67331 start = match.index,
67332 end = sourceCode.text.length;
67333 return fixer.replaceTextRange([start, end], "");
67334 }
67335
67336 });
67337 }
67338 }
67339 };
67340 }
67341
67342 };
67343
67344 /***/ }),
67345 /* 585 */
67346 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
67347
67348 "use strict";
67349 /**
67350 * @fileoverview Rule to flag statements that use != and == instead of !== and ===
67351 * @author Nicholas C. Zakas
67352 */
67353 //------------------------------------------------------------------------------
67354 // Requirements
67355 //------------------------------------------------------------------------------
67356
67357 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
67358 // Rule Definition
67359 //------------------------------------------------------------------------------
67360
67361
67362 module.exports = {
67363 meta: {
67364 type: "suggestion",
67365 docs: {
67366 description: "require the use of `===` and `!==`",
67367 recommended: false,
67368 url: "https://eslint.org/docs/rules/eqeqeq"
67369 },
67370 schema: {
67371 anyOf: [{
67372 type: "array",
67373 items: [{
67374 enum: ["always"]
67375 }, {
67376 type: "object",
67377 properties: {
67378 null: {
67379 enum: ["always", "never", "ignore"]
67380 }
67381 },
67382 additionalProperties: false
67383 }],
67384 additionalItems: false
67385 }, {
67386 type: "array",
67387 items: [{
67388 enum: ["smart", "allow-null"]
67389 }],
67390 additionalItems: false
67391 }]
67392 },
67393 fixable: "code",
67394 messages: {
67395 unexpected: "Expected '{{expectedOperator}}' and instead saw '{{actualOperator}}'."
67396 }
67397 },
67398
67399 create(context) {
67400 const config = context.options[0] || "always";
67401 const options = context.options[1] || {};
67402 const sourceCode = context.getSourceCode();
67403 const nullOption = config === "always" ? options.null || "always" : "ignore";
67404 const enforceRuleForNull = nullOption === "always";
67405 const enforceInverseRuleForNull = nullOption === "never";
67406 /**
67407 * Checks if an expression is a typeof expression
67408 * @param {ASTNode} node The node to check
67409 * @returns {boolean} if the node is a typeof expression
67410 */
67411
67412 function isTypeOf(node) {
67413 return node.type === "UnaryExpression" && node.operator === "typeof";
67414 }
67415 /**
67416 * Checks if either operand of a binary expression is a typeof operation
67417 * @param {ASTNode} node The node to check
67418 * @returns {boolean} if one of the operands is typeof
67419 * @private
67420 */
67421
67422
67423 function isTypeOfBinary(node) {
67424 return isTypeOf(node.left) || isTypeOf(node.right);
67425 }
67426 /**
67427 * Checks if operands are literals of the same type (via typeof)
67428 * @param {ASTNode} node The node to check
67429 * @returns {boolean} if operands are of same type
67430 * @private
67431 */
67432
67433
67434 function areLiteralsAndSameType(node) {
67435 return node.left.type === "Literal" && node.right.type === "Literal" && typeof node.left.value === typeof node.right.value;
67436 }
67437 /**
67438 * Checks if one of the operands is a literal null
67439 * @param {ASTNode} node The node to check
67440 * @returns {boolean} if operands are null
67441 * @private
67442 */
67443
67444
67445 function isNullCheck(node) {
67446 return astUtils.isNullLiteral(node.right) || astUtils.isNullLiteral(node.left);
67447 }
67448 /**
67449 * Reports a message for this rule.
67450 * @param {ASTNode} node The binary expression node that was checked
67451 * @param {string} expectedOperator The operator that was expected (either '==', '!=', '===', or '!==')
67452 * @returns {void}
67453 * @private
67454 */
67455
67456
67457 function report(node, expectedOperator) {
67458 const operatorToken = sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
67459 context.report({
67460 node,
67461 loc: operatorToken.loc,
67462 messageId: "unexpected",
67463 data: {
67464 expectedOperator,
67465 actualOperator: node.operator
67466 },
67467
67468 fix(fixer) {
67469 // If the comparison is a `typeof` comparison or both sides are literals with the same type, then it's safe to fix.
67470 if (isTypeOfBinary(node) || areLiteralsAndSameType(node)) {
67471 return fixer.replaceText(operatorToken, expectedOperator);
67472 }
67473
67474 return null;
67475 }
67476
67477 });
67478 }
67479
67480 return {
67481 BinaryExpression(node) {
67482 const isNull = isNullCheck(node);
67483
67484 if (node.operator !== "==" && node.operator !== "!=") {
67485 if (enforceInverseRuleForNull && isNull) {
67486 report(node, node.operator.slice(0, -1));
67487 }
67488
67489 return;
67490 }
67491
67492 if (config === "smart" && (isTypeOfBinary(node) || areLiteralsAndSameType(node) || isNull)) {
67493 return;
67494 }
67495
67496 if (!enforceRuleForNull && isNull) {
67497 return;
67498 }
67499
67500 report(node, "".concat(node.operator, "="));
67501 }
67502
67503 };
67504 }
67505
67506 };
67507
67508 /***/ }),
67509 /* 586 */
67510 /***/ ((module) => {
67511
67512 "use strict";
67513 /**
67514 * @fileoverview enforce "for" loop update clause moving the counter in the right direction.(for-direction)
67515 * @author Aladdin-ADD<hh_2013@foxmail.com>
67516 */
67517 //------------------------------------------------------------------------------
67518 // Rule Definition
67519 //------------------------------------------------------------------------------
67520
67521 module.exports = {
67522 meta: {
67523 type: "problem",
67524 docs: {
67525 description: "enforce \"for\" loop update clause moving the counter in the right direction.",
67526 recommended: true,
67527 url: "https://eslint.org/docs/rules/for-direction"
67528 },
67529 fixable: null,
67530 schema: [],
67531 messages: {
67532 incorrectDirection: "The update clause in this loop moves the variable in the wrong direction."
67533 }
67534 },
67535
67536 create(context) {
67537 /**
67538 * report an error.
67539 * @param {ASTNode} node the node to report.
67540 * @returns {void}
67541 */
67542 function report(node) {
67543 context.report({
67544 node,
67545 messageId: "incorrectDirection"
67546 });
67547 }
67548 /**
67549 * check the right side of the assignment
67550 * @param {ASTNode} update UpdateExpression to check
67551 * @param {int} dir expected direction that could either be turned around or invalidated
67552 * @returns {int} return dir, the negated dir or zero if it's not clear for identifiers
67553 */
67554
67555
67556 function getRightDirection(update, dir) {
67557 if (update.right.type === "UnaryExpression") {
67558 if (update.right.operator === "-") {
67559 return -dir;
67560 }
67561 } else if (update.right.type === "Identifier") {
67562 return 0;
67563 }
67564
67565 return dir;
67566 }
67567 /**
67568 * check UpdateExpression add/sub the counter
67569 * @param {ASTNode} update UpdateExpression to check
67570 * @param {string} counter variable name to check
67571 * @returns {int} if add return 1, if sub return -1, if nochange, return 0
67572 */
67573
67574
67575 function getUpdateDirection(update, counter) {
67576 if (update.argument.type === "Identifier" && update.argument.name === counter) {
67577 if (update.operator === "++") {
67578 return 1;
67579 }
67580
67581 if (update.operator === "--") {
67582 return -1;
67583 }
67584 }
67585
67586 return 0;
67587 }
67588 /**
67589 * check AssignmentExpression add/sub the counter
67590 * @param {ASTNode} update AssignmentExpression to check
67591 * @param {string} counter variable name to check
67592 * @returns {int} if add return 1, if sub return -1, if nochange, return 0
67593 */
67594
67595
67596 function getAssignmentDirection(update, counter) {
67597 if (update.left.name === counter) {
67598 if (update.operator === "+=") {
67599 return getRightDirection(update, 1);
67600 }
67601
67602 if (update.operator === "-=") {
67603 return getRightDirection(update, -1);
67604 }
67605 }
67606
67607 return 0;
67608 }
67609
67610 return {
67611 ForStatement(node) {
67612 if (node.test && node.test.type === "BinaryExpression" && node.test.left.type === "Identifier" && node.update) {
67613 const counter = node.test.left.name;
67614 const operator = node.test.operator;
67615 const update = node.update;
67616 let wrongDirection;
67617
67618 if (operator === "<" || operator === "<=") {
67619 wrongDirection = -1;
67620 } else if (operator === ">" || operator === ">=") {
67621 wrongDirection = 1;
67622 } else {
67623 return;
67624 }
67625
67626 if (update.type === "UpdateExpression") {
67627 if (getUpdateDirection(update, counter) === wrongDirection) {
67628 report(node);
67629 }
67630 } else if (update.type === "AssignmentExpression" && getAssignmentDirection(update, counter) === wrongDirection) {
67631 report(node);
67632 }
67633 }
67634 }
67635
67636 };
67637 }
67638
67639 };
67640
67641 /***/ }),
67642 /* 587 */
67643 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
67644
67645 "use strict";
67646 /**
67647 * @fileoverview Rule to control spacing within function calls
67648 * @author Matt DuVall <http://www.mattduvall.com>
67649 */
67650 //------------------------------------------------------------------------------
67651 // Requirements
67652 //------------------------------------------------------------------------------
67653
67654 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
67655 // Rule Definition
67656 //------------------------------------------------------------------------------
67657
67658
67659 module.exports = {
67660 meta: {
67661 type: "layout",
67662 docs: {
67663 description: "require or disallow spacing between function identifiers and their invocations",
67664 recommended: false,
67665 url: "https://eslint.org/docs/rules/func-call-spacing"
67666 },
67667 fixable: "whitespace",
67668 schema: {
67669 anyOf: [{
67670 type: "array",
67671 items: [{
67672 enum: ["never"]
67673 }],
67674 minItems: 0,
67675 maxItems: 1
67676 }, {
67677 type: "array",
67678 items: [{
67679 enum: ["always"]
67680 }, {
67681 type: "object",
67682 properties: {
67683 allowNewlines: {
67684 type: "boolean"
67685 }
67686 },
67687 additionalProperties: false
67688 }],
67689 minItems: 0,
67690 maxItems: 2
67691 }]
67692 },
67693 messages: {
67694 unexpectedWhitespace: "Unexpected whitespace between function name and paren.",
67695 unexpectedNewline: "Unexpected newline between function name and paren.",
67696 missing: "Missing space between function name and paren."
67697 }
67698 },
67699
67700 create(context) {
67701 const never = context.options[0] !== "always";
67702 const allowNewlines = !never && context.options[1] && context.options[1].allowNewlines;
67703 const sourceCode = context.getSourceCode();
67704 const text = sourceCode.getText();
67705 /**
67706 * Check if open space is present in a function name
67707 * @param {ASTNode} node node to evaluate
67708 * @param {Token} leftToken The last token of the callee. This may be the closing parenthesis that encloses the callee.
67709 * @param {Token} rightToken Tha first token of the arguments. this is the opening parenthesis that encloses the arguments.
67710 * @returns {void}
67711 * @private
67712 */
67713
67714 function checkSpacing(node, leftToken, rightToken) {
67715 const textBetweenTokens = text.slice(leftToken.range[1], rightToken.range[0]).replace(/\/\*.*?\*\//gu, "");
67716 const hasWhitespace = /\s/u.test(textBetweenTokens);
67717 const hasNewline = hasWhitespace && astUtils.LINEBREAK_MATCHER.test(textBetweenTokens);
67718 /*
67719 * never allowNewlines hasWhitespace hasNewline message
67720 * F F F F Missing space between function name and paren.
67721 * F F F T (Invalid `!hasWhitespace && hasNewline`)
67722 * F F T T Unexpected newline between function name and paren.
67723 * F F T F (OK)
67724 * F T T F (OK)
67725 * F T T T (OK)
67726 * F T F T (Invalid `!hasWhitespace && hasNewline`)
67727 * F T F F Missing space between function name and paren.
67728 * T T F F (Invalid `never && allowNewlines`)
67729 * T T F T (Invalid `!hasWhitespace && hasNewline`)
67730 * T T T T (Invalid `never && allowNewlines`)
67731 * T T T F (Invalid `never && allowNewlines`)
67732 * T F T F Unexpected space between function name and paren.
67733 * T F T T Unexpected space between function name and paren.
67734 * T F F T (Invalid `!hasWhitespace && hasNewline`)
67735 * T F F F (OK)
67736 *
67737 * T T Unexpected space between function name and paren.
67738 * F F Missing space between function name and paren.
67739 * F F T Unexpected newline between function name and paren.
67740 */
67741
67742 if (never && hasWhitespace) {
67743 context.report({
67744 node,
67745 loc: {
67746 start: leftToken.loc.end,
67747 end: {
67748 line: rightToken.loc.start.line,
67749 column: rightToken.loc.start.column - 1
67750 }
67751 },
67752 messageId: "unexpectedWhitespace",
67753
67754 fix(fixer) {
67755 // Don't remove comments.
67756 if (sourceCode.commentsExistBetween(leftToken, rightToken)) {
67757 return null;
67758 } // If `?.` exists, it doesn't hide no-unexpected-multiline errors
67759
67760
67761 if (node.optional) {
67762 return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], "?.");
67763 }
67764 /*
67765 * Only autofix if there is no newline
67766 * https://github.com/eslint/eslint/issues/7787
67767 */
67768
67769
67770 if (hasNewline) {
67771 return null;
67772 }
67773
67774 return fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
67775 }
67776
67777 });
67778 } else if (!never && !hasWhitespace) {
67779 context.report({
67780 node,
67781 loc: {
67782 start: {
67783 line: leftToken.loc.end.line,
67784 column: leftToken.loc.end.column - 1
67785 },
67786 end: rightToken.loc.start
67787 },
67788 messageId: "missing",
67789
67790 fix(fixer) {
67791 if (node.optional) {
67792 return null; // Not sure if inserting a space to either before/after `?.` token.
67793 }
67794
67795 return fixer.insertTextBefore(rightToken, " ");
67796 }
67797
67798 });
67799 } else if (!never && !allowNewlines && hasNewline) {
67800 context.report({
67801 node,
67802 loc: {
67803 start: leftToken.loc.end,
67804 end: rightToken.loc.start
67805 },
67806 messageId: "unexpectedNewline",
67807
67808 fix(fixer) {
67809 /*
67810 * Only autofix if there is no newline
67811 * https://github.com/eslint/eslint/issues/7787
67812 * But if `?.` exists, it doesn't hide no-unexpected-multiline errors
67813 */
67814 if (!node.optional) {
67815 return null;
67816 } // Don't remove comments.
67817
67818
67819 if (sourceCode.commentsExistBetween(leftToken, rightToken)) {
67820 return null;
67821 }
67822
67823 const range = [leftToken.range[1], rightToken.range[0]];
67824 const qdToken = sourceCode.getTokenAfter(leftToken);
67825
67826 if (qdToken.range[0] === leftToken.range[1]) {
67827 return fixer.replaceTextRange(range, "?. ");
67828 }
67829
67830 if (qdToken.range[1] === rightToken.range[0]) {
67831 return fixer.replaceTextRange(range, " ?.");
67832 }
67833
67834 return fixer.replaceTextRange(range, " ?. ");
67835 }
67836
67837 });
67838 }
67839 }
67840
67841 return {
67842 "CallExpression, NewExpression"(node) {
67843 const lastToken = sourceCode.getLastToken(node);
67844 const lastCalleeToken = sourceCode.getLastToken(node.callee);
67845 const parenToken = sourceCode.getFirstTokenBetween(lastCalleeToken, lastToken, astUtils.isOpeningParenToken);
67846 const prevToken = parenToken && sourceCode.getTokenBefore(parenToken, astUtils.isNotQuestionDotToken); // Parens in NewExpression are optional
67847
67848 if (!(parenToken && parenToken.range[1] < node.range[1])) {
67849 return;
67850 }
67851
67852 checkSpacing(node, prevToken, parenToken);
67853 },
67854
67855 ImportExpression(node) {
67856 const leftToken = sourceCode.getFirstToken(node);
67857 const rightToken = sourceCode.getTokenAfter(leftToken);
67858 checkSpacing(node, leftToken, rightToken);
67859 }
67860
67861 };
67862 }
67863
67864 };
67865
67866 /***/ }),
67867 /* 588 */
67868 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
67869
67870 "use strict";
67871 /**
67872 * @fileoverview Rule to require function names to match the name of the variable or property to which they are assigned.
67873 * @author Annie Zhang, Pavel Strashkin
67874 */
67875 //--------------------------------------------------------------------------
67876 // Requirements
67877 //--------------------------------------------------------------------------
67878
67879 const astUtils = __webpack_require__(548);
67880
67881 const esutils = __webpack_require__(549); //--------------------------------------------------------------------------
67882 // Helpers
67883 //--------------------------------------------------------------------------
67884
67885 /**
67886 * Determines if a pattern is `module.exports` or `module["exports"]`
67887 * @param {ASTNode} pattern The left side of the AssignmentExpression
67888 * @returns {boolean} True if the pattern is `module.exports` or `module["exports"]`
67889 */
67890
67891
67892 function isModuleExports(pattern) {
67893 if (pattern.type === "MemberExpression" && pattern.object.type === "Identifier" && pattern.object.name === "module") {
67894 // module.exports
67895 if (pattern.property.type === "Identifier" && pattern.property.name === "exports") {
67896 return true;
67897 } // module["exports"]
67898
67899
67900 if (pattern.property.type === "Literal" && pattern.property.value === "exports") {
67901 return true;
67902 }
67903 }
67904
67905 return false;
67906 }
67907 /**
67908 * Determines if a string name is a valid identifier
67909 * @param {string} name The string to be checked
67910 * @param {int} ecmaVersion The ECMAScript version if specified in the parserOptions config
67911 * @returns {boolean} True if the string is a valid identifier
67912 */
67913
67914
67915 function isIdentifier(name, ecmaVersion) {
67916 if (ecmaVersion >= 6) {
67917 return esutils.keyword.isIdentifierES6(name);
67918 }
67919
67920 return esutils.keyword.isIdentifierES5(name);
67921 } //------------------------------------------------------------------------------
67922 // Rule Definition
67923 //------------------------------------------------------------------------------
67924
67925
67926 const alwaysOrNever = {
67927 enum: ["always", "never"]
67928 };
67929 const optionsObject = {
67930 type: "object",
67931 properties: {
67932 considerPropertyDescriptor: {
67933 type: "boolean"
67934 },
67935 includeCommonJSModuleExports: {
67936 type: "boolean"
67937 }
67938 },
67939 additionalProperties: false
67940 };
67941 module.exports = {
67942 meta: {
67943 type: "suggestion",
67944 docs: {
67945 description: "require function names to match the name of the variable or property to which they are assigned",
67946 recommended: false,
67947 url: "https://eslint.org/docs/rules/func-name-matching"
67948 },
67949 schema: {
67950 anyOf: [{
67951 type: "array",
67952 additionalItems: false,
67953 items: [alwaysOrNever, optionsObject]
67954 }, {
67955 type: "array",
67956 additionalItems: false,
67957 items: [optionsObject]
67958 }]
67959 },
67960 messages: {
67961 matchProperty: "Function name `{{funcName}}` should match property name `{{name}}`.",
67962 matchVariable: "Function name `{{funcName}}` should match variable name `{{name}}`.",
67963 notMatchProperty: "Function name `{{funcName}}` should not match property name `{{name}}`.",
67964 notMatchVariable: "Function name `{{funcName}}` should not match variable name `{{name}}`."
67965 }
67966 },
67967
67968 create(context) {
67969 const options = (typeof context.options[0] === "object" ? context.options[0] : context.options[1]) || {};
67970 const nameMatches = typeof context.options[0] === "string" ? context.options[0] : "always";
67971 const considerPropertyDescriptor = options.considerPropertyDescriptor;
67972 const includeModuleExports = options.includeCommonJSModuleExports;
67973 const ecmaVersion = context.parserOptions && context.parserOptions.ecmaVersion ? context.parserOptions.ecmaVersion : 5;
67974 /**
67975 * Check whether node is a certain CallExpression.
67976 * @param {string} objName object name
67977 * @param {string} funcName function name
67978 * @param {ASTNode} node The node to check
67979 * @returns {boolean} `true` if node matches CallExpression
67980 */
67981
67982 function isPropertyCall(objName, funcName, node) {
67983 if (!node) {
67984 return false;
67985 }
67986
67987 return node.type === "CallExpression" && astUtils.isSpecificMemberAccess(node.callee, objName, funcName);
67988 }
67989 /**
67990 * Compares identifiers based on the nameMatches option
67991 * @param {string} x the first identifier
67992 * @param {string} y the second identifier
67993 * @returns {boolean} whether the two identifiers should warn.
67994 */
67995
67996
67997 function shouldWarn(x, y) {
67998 return nameMatches === "always" && x !== y || nameMatches === "never" && x === y;
67999 }
68000 /**
68001 * Reports
68002 * @param {ASTNode} node The node to report
68003 * @param {string} name The variable or property name
68004 * @param {string} funcName The function name
68005 * @param {boolean} isProp True if the reported node is a property assignment
68006 * @returns {void}
68007 */
68008
68009
68010 function report(node, name, funcName, isProp) {
68011 let messageId;
68012
68013 if (nameMatches === "always" && isProp) {
68014 messageId = "matchProperty";
68015 } else if (nameMatches === "always") {
68016 messageId = "matchVariable";
68017 } else if (isProp) {
68018 messageId = "notMatchProperty";
68019 } else {
68020 messageId = "notMatchVariable";
68021 }
68022
68023 context.report({
68024 node,
68025 messageId,
68026 data: {
68027 name,
68028 funcName
68029 }
68030 });
68031 }
68032 /**
68033 * Determines whether a given node is a string literal
68034 * @param {ASTNode} node The node to check
68035 * @returns {boolean} `true` if the node is a string literal
68036 */
68037
68038
68039 function isStringLiteral(node) {
68040 return node.type === "Literal" && typeof node.value === "string";
68041 } //--------------------------------------------------------------------------
68042 // Public
68043 //--------------------------------------------------------------------------
68044
68045
68046 return {
68047 VariableDeclarator(node) {
68048 if (!node.init || node.init.type !== "FunctionExpression" || node.id.type !== "Identifier") {
68049 return;
68050 }
68051
68052 if (node.init.id && shouldWarn(node.id.name, node.init.id.name)) {
68053 report(node, node.id.name, node.init.id.name, false);
68054 }
68055 },
68056
68057 AssignmentExpression(node) {
68058 if (node.right.type !== "FunctionExpression" || node.left.computed && node.left.property.type !== "Literal" || !includeModuleExports && isModuleExports(node.left) || node.left.type !== "Identifier" && node.left.type !== "MemberExpression") {
68059 return;
68060 }
68061
68062 const isProp = node.left.type === "MemberExpression";
68063 const name = isProp ? astUtils.getStaticPropertyName(node.left) : node.left.name;
68064
68065 if (node.right.id && name && isIdentifier(name) && shouldWarn(name, node.right.id.name)) {
68066 report(node, name, node.right.id.name, isProp);
68067 }
68068 },
68069
68070 "Property, PropertyDefinition[value]"(node) {
68071 if (!(node.value.type === "FunctionExpression" && node.value.id)) {
68072 return;
68073 }
68074
68075 if (node.key.type === "Identifier" && !node.computed) {
68076 const functionName = node.value.id.name;
68077 let propertyName = node.key.name;
68078
68079 if (considerPropertyDescriptor && propertyName === "value" && node.parent.type === "ObjectExpression") {
68080 if (isPropertyCall("Object", "defineProperty", node.parent.parent) || isPropertyCall("Reflect", "defineProperty", node.parent.parent)) {
68081 const property = node.parent.parent.arguments[1];
68082
68083 if (isStringLiteral(property) && shouldWarn(property.value, functionName)) {
68084 report(node, property.value, functionName, true);
68085 }
68086 } else if (isPropertyCall("Object", "defineProperties", node.parent.parent.parent.parent)) {
68087 propertyName = node.parent.parent.key.name;
68088
68089 if (!node.parent.parent.computed && shouldWarn(propertyName, functionName)) {
68090 report(node, propertyName, functionName, true);
68091 }
68092 } else if (isPropertyCall("Object", "create", node.parent.parent.parent.parent)) {
68093 propertyName = node.parent.parent.key.name;
68094
68095 if (!node.parent.parent.computed && shouldWarn(propertyName, functionName)) {
68096 report(node, propertyName, functionName, true);
68097 }
68098 } else if (shouldWarn(propertyName, functionName)) {
68099 report(node, propertyName, functionName, true);
68100 }
68101 } else if (shouldWarn(propertyName, functionName)) {
68102 report(node, propertyName, functionName, true);
68103 }
68104
68105 return;
68106 }
68107
68108 if (isStringLiteral(node.key) && isIdentifier(node.key.value, ecmaVersion) && shouldWarn(node.key.value, node.value.id.name)) {
68109 report(node, node.key.value, node.value.id.name, true);
68110 }
68111 }
68112
68113 };
68114 }
68115
68116 };
68117
68118 /***/ }),
68119 /* 589 */
68120 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
68121
68122 "use strict";
68123 /**
68124 * @fileoverview Rule to warn when a function expression does not have a name.
68125 * @author Kyle T. Nunery
68126 */
68127 //------------------------------------------------------------------------------
68128 // Requirements
68129 //------------------------------------------------------------------------------
68130
68131 const astUtils = __webpack_require__(548);
68132 /**
68133 * Checks whether or not a given variable is a function name.
68134 * @param {eslint-scope.Variable} variable A variable to check.
68135 * @returns {boolean} `true` if the variable is a function name.
68136 */
68137
68138
68139 function isFunctionName(variable) {
68140 return variable && variable.defs[0].type === "FunctionName";
68141 } //------------------------------------------------------------------------------
68142 // Rule Definition
68143 //------------------------------------------------------------------------------
68144
68145
68146 module.exports = {
68147 meta: {
68148 type: "suggestion",
68149 docs: {
68150 description: "require or disallow named `function` expressions",
68151 recommended: false,
68152 url: "https://eslint.org/docs/rules/func-names"
68153 },
68154 schema: {
68155 definitions: {
68156 value: {
68157 enum: ["always", "as-needed", "never"]
68158 }
68159 },
68160 items: [{
68161 $ref: "#/definitions/value"
68162 }, {
68163 type: "object",
68164 properties: {
68165 generators: {
68166 $ref: "#/definitions/value"
68167 }
68168 },
68169 additionalProperties: false
68170 }]
68171 },
68172 messages: {
68173 unnamed: "Unexpected unnamed {{name}}.",
68174 named: "Unexpected named {{name}}."
68175 }
68176 },
68177
68178 create(context) {
68179 const sourceCode = context.getSourceCode();
68180 /**
68181 * Returns the config option for the given node.
68182 * @param {ASTNode} node A node to get the config for.
68183 * @returns {string} The config option.
68184 */
68185
68186 function getConfigForNode(node) {
68187 if (node.generator && context.options.length > 1 && context.options[1].generators) {
68188 return context.options[1].generators;
68189 }
68190
68191 return context.options[0] || "always";
68192 }
68193 /**
68194 * Determines whether the current FunctionExpression node is a get, set, or
68195 * shorthand method in an object literal or a class.
68196 * @param {ASTNode} node A node to check.
68197 * @returns {boolean} True if the node is a get, set, or shorthand method.
68198 */
68199
68200
68201 function isObjectOrClassMethod(node) {
68202 const parent = node.parent;
68203 return parent.type === "MethodDefinition" || parent.type === "Property" && (parent.method || parent.kind === "get" || parent.kind === "set");
68204 }
68205 /**
68206 * Determines whether the current FunctionExpression node has a name that would be
68207 * inferred from context in a conforming ES6 environment.
68208 * @param {ASTNode} node A node to check.
68209 * @returns {boolean} True if the node would have a name assigned automatically.
68210 */
68211
68212
68213 function hasInferredName(node) {
68214 const parent = node.parent;
68215 return isObjectOrClassMethod(node) || parent.type === "VariableDeclarator" && parent.id.type === "Identifier" && parent.init === node || parent.type === "Property" && parent.value === node || parent.type === "PropertyDefinition" && parent.value === node || parent.type === "AssignmentExpression" && parent.left.type === "Identifier" && parent.right === node || parent.type === "AssignmentPattern" && parent.left.type === "Identifier" && parent.right === node;
68216 }
68217 /**
68218 * Reports that an unnamed function should be named
68219 * @param {ASTNode} node The node to report in the event of an error.
68220 * @returns {void}
68221 */
68222
68223
68224 function reportUnexpectedUnnamedFunction(node) {
68225 context.report({
68226 node,
68227 messageId: "unnamed",
68228 loc: astUtils.getFunctionHeadLoc(node, sourceCode),
68229 data: {
68230 name: astUtils.getFunctionNameWithKind(node)
68231 }
68232 });
68233 }
68234 /**
68235 * Reports that a named function should be unnamed
68236 * @param {ASTNode} node The node to report in the event of an error.
68237 * @returns {void}
68238 */
68239
68240
68241 function reportUnexpectedNamedFunction(node) {
68242 context.report({
68243 node,
68244 messageId: "named",
68245 loc: astUtils.getFunctionHeadLoc(node, sourceCode),
68246 data: {
68247 name: astUtils.getFunctionNameWithKind(node)
68248 }
68249 });
68250 }
68251 /**
68252 * The listener for function nodes.
68253 * @param {ASTNode} node function node
68254 * @returns {void}
68255 */
68256
68257
68258 function handleFunction(node) {
68259 // Skip recursive functions.
68260 const nameVar = context.getDeclaredVariables(node)[0];
68261
68262 if (isFunctionName(nameVar) && nameVar.references.length > 0) {
68263 return;
68264 }
68265
68266 const hasName = Boolean(node.id && node.id.name);
68267 const config = getConfigForNode(node);
68268
68269 if (config === "never") {
68270 if (hasName && node.type !== "FunctionDeclaration") {
68271 reportUnexpectedNamedFunction(node);
68272 }
68273 } else if (config === "as-needed") {
68274 if (!hasName && !hasInferredName(node)) {
68275 reportUnexpectedUnnamedFunction(node);
68276 }
68277 } else {
68278 if (!hasName && !isObjectOrClassMethod(node)) {
68279 reportUnexpectedUnnamedFunction(node);
68280 }
68281 }
68282 }
68283
68284 return {
68285 "FunctionExpression:exit": handleFunction,
68286 "ExportDefaultDeclaration > FunctionDeclaration": handleFunction
68287 };
68288 }
68289
68290 };
68291
68292 /***/ }),
68293 /* 590 */
68294 /***/ ((module) => {
68295
68296 "use strict";
68297 /**
68298 * @fileoverview Rule to enforce a particular function style
68299 * @author Nicholas C. Zakas
68300 */
68301 //------------------------------------------------------------------------------
68302 // Rule Definition
68303 //------------------------------------------------------------------------------
68304
68305 module.exports = {
68306 meta: {
68307 type: "suggestion",
68308 docs: {
68309 description: "enforce the consistent use of either `function` declarations or expressions",
68310 recommended: false,
68311 url: "https://eslint.org/docs/rules/func-style"
68312 },
68313 schema: [{
68314 enum: ["declaration", "expression"]
68315 }, {
68316 type: "object",
68317 properties: {
68318 allowArrowFunctions: {
68319 type: "boolean",
68320 default: false
68321 }
68322 },
68323 additionalProperties: false
68324 }],
68325 messages: {
68326 expression: "Expected a function expression.",
68327 declaration: "Expected a function declaration."
68328 }
68329 },
68330
68331 create(context) {
68332 const style = context.options[0],
68333 allowArrowFunctions = context.options[1] && context.options[1].allowArrowFunctions,
68334 enforceDeclarations = style === "declaration",
68335 stack = [];
68336 const nodesToCheck = {
68337 FunctionDeclaration(node) {
68338 stack.push(false);
68339
68340 if (!enforceDeclarations && node.parent.type !== "ExportDefaultDeclaration") {
68341 context.report({
68342 node,
68343 messageId: "expression"
68344 });
68345 }
68346 },
68347
68348 "FunctionDeclaration:exit"() {
68349 stack.pop();
68350 },
68351
68352 FunctionExpression(node) {
68353 stack.push(false);
68354
68355 if (enforceDeclarations && node.parent.type === "VariableDeclarator") {
68356 context.report({
68357 node: node.parent,
68358 messageId: "declaration"
68359 });
68360 }
68361 },
68362
68363 "FunctionExpression:exit"() {
68364 stack.pop();
68365 },
68366
68367 ThisExpression() {
68368 if (stack.length > 0) {
68369 stack[stack.length - 1] = true;
68370 }
68371 }
68372
68373 };
68374
68375 if (!allowArrowFunctions) {
68376 nodesToCheck.ArrowFunctionExpression = function () {
68377 stack.push(false);
68378 };
68379
68380 nodesToCheck["ArrowFunctionExpression:exit"] = function (node) {
68381 const hasThisExpr = stack.pop();
68382
68383 if (enforceDeclarations && !hasThisExpr && node.parent.type === "VariableDeclarator") {
68384 context.report({
68385 node: node.parent,
68386 messageId: "declaration"
68387 });
68388 }
68389 };
68390 }
68391
68392 return nodesToCheck;
68393 }
68394
68395 };
68396
68397 /***/ }),
68398 /* 591 */
68399 /***/ ((module) => {
68400
68401 "use strict";
68402 /**
68403 * @fileoverview Rule to enforce line breaks between arguments of a function call
68404 * @author Alexey Gonchar <https://github.com/finico>
68405 */
68406 //------------------------------------------------------------------------------
68407 // Rule Definition
68408 //------------------------------------------------------------------------------
68409
68410 module.exports = {
68411 meta: {
68412 type: "layout",
68413 docs: {
68414 description: "enforce line breaks between arguments of a function call",
68415 recommended: false,
68416 url: "https://eslint.org/docs/rules/function-call-argument-newline"
68417 },
68418 fixable: "whitespace",
68419 schema: [{
68420 enum: ["always", "never", "consistent"]
68421 }],
68422 messages: {
68423 unexpectedLineBreak: "There should be no line break here.",
68424 missingLineBreak: "There should be a line break after this argument."
68425 }
68426 },
68427
68428 create(context) {
68429 const sourceCode = context.getSourceCode();
68430 const checkers = {
68431 unexpected: {
68432 messageId: "unexpectedLineBreak",
68433 check: (prevToken, currentToken) => prevToken.loc.end.line !== currentToken.loc.start.line,
68434 createFix: (token, tokenBefore) => fixer => fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " ")
68435 },
68436 missing: {
68437 messageId: "missingLineBreak",
68438 check: (prevToken, currentToken) => prevToken.loc.end.line === currentToken.loc.start.line,
68439 createFix: (token, tokenBefore) => fixer => fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n")
68440 }
68441 };
68442 /**
68443 * Check all arguments for line breaks in the CallExpression
68444 * @param {CallExpression} node node to evaluate
68445 * @param {{ messageId: string, check: Function }} checker selected checker
68446 * @returns {void}
68447 * @private
68448 */
68449
68450 function checkArguments(node, checker) {
68451 for (let i = 1; i < node.arguments.length; i++) {
68452 const prevArgToken = sourceCode.getLastToken(node.arguments[i - 1]);
68453 const currentArgToken = sourceCode.getFirstToken(node.arguments[i]);
68454
68455 if (checker.check(prevArgToken, currentArgToken)) {
68456 const tokenBefore = sourceCode.getTokenBefore(currentArgToken, {
68457 includeComments: true
68458 });
68459 const hasLineCommentBefore = tokenBefore.type === "Line";
68460 context.report({
68461 node,
68462 loc: {
68463 start: tokenBefore.loc.end,
68464 end: currentArgToken.loc.start
68465 },
68466 messageId: checker.messageId,
68467 fix: hasLineCommentBefore ? null : checker.createFix(currentArgToken, tokenBefore)
68468 });
68469 }
68470 }
68471 }
68472 /**
68473 * Check if open space is present in a function name
68474 * @param {CallExpression} node node to evaluate
68475 * @returns {void}
68476 * @private
68477 */
68478
68479
68480 function check(node) {
68481 if (node.arguments.length < 2) {
68482 return;
68483 }
68484
68485 const option = context.options[0] || "always";
68486
68487 if (option === "never") {
68488 checkArguments(node, checkers.unexpected);
68489 } else if (option === "always") {
68490 checkArguments(node, checkers.missing);
68491 } else if (option === "consistent") {
68492 const firstArgToken = sourceCode.getLastToken(node.arguments[0]);
68493 const secondArgToken = sourceCode.getFirstToken(node.arguments[1]);
68494
68495 if (firstArgToken.loc.end.line === secondArgToken.loc.start.line) {
68496 checkArguments(node, checkers.unexpected);
68497 } else {
68498 checkArguments(node, checkers.missing);
68499 }
68500 }
68501 }
68502
68503 return {
68504 CallExpression: check,
68505 NewExpression: check
68506 };
68507 }
68508
68509 };
68510
68511 /***/ }),
68512 /* 592 */
68513 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
68514
68515 "use strict";
68516 /**
68517 * @fileoverview enforce consistent line breaks inside function parentheses
68518 * @author Teddy Katz
68519 */
68520 //------------------------------------------------------------------------------
68521 // Requirements
68522 //------------------------------------------------------------------------------
68523
68524 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
68525 // Rule Definition
68526 //------------------------------------------------------------------------------
68527
68528
68529 module.exports = {
68530 meta: {
68531 type: "layout",
68532 docs: {
68533 description: "enforce consistent line breaks inside function parentheses",
68534 recommended: false,
68535 url: "https://eslint.org/docs/rules/function-paren-newline"
68536 },
68537 fixable: "whitespace",
68538 schema: [{
68539 oneOf: [{
68540 enum: ["always", "never", "consistent", "multiline", "multiline-arguments"]
68541 }, {
68542 type: "object",
68543 properties: {
68544 minItems: {
68545 type: "integer",
68546 minimum: 0
68547 }
68548 },
68549 additionalProperties: false
68550 }]
68551 }],
68552 messages: {
68553 expectedBefore: "Expected newline before ')'.",
68554 expectedAfter: "Expected newline after '('.",
68555 expectedBetween: "Expected newline between arguments/params.",
68556 unexpectedBefore: "Unexpected newline before ')'.",
68557 unexpectedAfter: "Unexpected newline after '('."
68558 }
68559 },
68560
68561 create(context) {
68562 const sourceCode = context.getSourceCode();
68563 const rawOption = context.options[0] || "multiline";
68564 const multilineOption = rawOption === "multiline";
68565 const multilineArgumentsOption = rawOption === "multiline-arguments";
68566 const consistentOption = rawOption === "consistent";
68567 let minItems;
68568
68569 if (typeof rawOption === "object") {
68570 minItems = rawOption.minItems;
68571 } else if (rawOption === "always") {
68572 minItems = 0;
68573 } else if (rawOption === "never") {
68574 minItems = Infinity;
68575 } else {
68576 minItems = null;
68577 } //----------------------------------------------------------------------
68578 // Helpers
68579 //----------------------------------------------------------------------
68580
68581 /**
68582 * Determines whether there should be newlines inside function parens
68583 * @param {ASTNode[]} elements The arguments or parameters in the list
68584 * @param {boolean} hasLeftNewline `true` if the left paren has a newline in the current code.
68585 * @returns {boolean} `true` if there should be newlines inside the function parens
68586 */
68587
68588
68589 function shouldHaveNewlines(elements, hasLeftNewline) {
68590 if (multilineArgumentsOption && elements.length === 1) {
68591 return hasLeftNewline;
68592 }
68593
68594 if (multilineOption || multilineArgumentsOption) {
68595 return elements.some((element, index) => index !== elements.length - 1 && element.loc.end.line !== elements[index + 1].loc.start.line);
68596 }
68597
68598 if (consistentOption) {
68599 return hasLeftNewline;
68600 }
68601
68602 return elements.length >= minItems;
68603 }
68604 /**
68605 * Validates parens
68606 * @param {Object} parens An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token
68607 * @param {ASTNode[]} elements The arguments or parameters in the list
68608 * @returns {void}
68609 */
68610
68611
68612 function validateParens(parens, elements) {
68613 const leftParen = parens.leftParen;
68614 const rightParen = parens.rightParen;
68615 const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen);
68616 const tokenBeforeRightParen = sourceCode.getTokenBefore(rightParen);
68617 const hasLeftNewline = !astUtils.isTokenOnSameLine(leftParen, tokenAfterLeftParen);
68618 const hasRightNewline = !astUtils.isTokenOnSameLine(tokenBeforeRightParen, rightParen);
68619 const needsNewlines = shouldHaveNewlines(elements, hasLeftNewline);
68620
68621 if (hasLeftNewline && !needsNewlines) {
68622 context.report({
68623 node: leftParen,
68624 messageId: "unexpectedAfter",
68625
68626 fix(fixer) {
68627 return sourceCode.getText().slice(leftParen.range[1], tokenAfterLeftParen.range[0]).trim() // If there is a comment between the ( and the first element, don't do a fix.
68628 ? null : fixer.removeRange([leftParen.range[1], tokenAfterLeftParen.range[0]]);
68629 }
68630
68631 });
68632 } else if (!hasLeftNewline && needsNewlines) {
68633 context.report({
68634 node: leftParen,
68635 messageId: "expectedAfter",
68636 fix: fixer => fixer.insertTextAfter(leftParen, "\n")
68637 });
68638 }
68639
68640 if (hasRightNewline && !needsNewlines) {
68641 context.report({
68642 node: rightParen,
68643 messageId: "unexpectedBefore",
68644
68645 fix(fixer) {
68646 return sourceCode.getText().slice(tokenBeforeRightParen.range[1], rightParen.range[0]).trim() // If there is a comment between the last element and the ), don't do a fix.
68647 ? null : fixer.removeRange([tokenBeforeRightParen.range[1], rightParen.range[0]]);
68648 }
68649
68650 });
68651 } else if (!hasRightNewline && needsNewlines) {
68652 context.report({
68653 node: rightParen,
68654 messageId: "expectedBefore",
68655 fix: fixer => fixer.insertTextBefore(rightParen, "\n")
68656 });
68657 }
68658 }
68659 /**
68660 * Validates a list of arguments or parameters
68661 * @param {Object} parens An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token
68662 * @param {ASTNode[]} elements The arguments or parameters in the list
68663 * @returns {void}
68664 */
68665
68666
68667 function validateArguments(parens, elements) {
68668 const leftParen = parens.leftParen;
68669 const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen);
68670 const hasLeftNewline = !astUtils.isTokenOnSameLine(leftParen, tokenAfterLeftParen);
68671 const needsNewlines = shouldHaveNewlines(elements, hasLeftNewline);
68672
68673 for (let i = 0; i <= elements.length - 2; i++) {
68674 const currentElement = elements[i];
68675 const nextElement = elements[i + 1];
68676 const hasNewLine = currentElement.loc.end.line !== nextElement.loc.start.line;
68677
68678 if (!hasNewLine && needsNewlines) {
68679 context.report({
68680 node: currentElement,
68681 messageId: "expectedBetween",
68682 fix: fixer => fixer.insertTextBefore(nextElement, "\n")
68683 });
68684 }
68685 }
68686 }
68687 /**
68688 * Gets the left paren and right paren tokens of a node.
68689 * @param {ASTNode} node The node with parens
68690 * @throws {TypeError} Unexecpted node type.
68691 * @returns {Object} An object with keys `leftParen` for the left paren token, and `rightParen` for the right paren token.
68692 * Can also return `null` if an expression has no parens (e.g. a NewExpression with no arguments, or an ArrowFunctionExpression
68693 * with a single parameter)
68694 */
68695
68696
68697 function getParenTokens(node) {
68698 switch (node.type) {
68699 case "NewExpression":
68700 if (!node.arguments.length && !(astUtils.isOpeningParenToken(sourceCode.getLastToken(node, {
68701 skip: 1
68702 })) && astUtils.isClosingParenToken(sourceCode.getLastToken(node)))) {
68703 // If the NewExpression does not have parens (e.g. `new Foo`), return null.
68704 return null;
68705 }
68706
68707 // falls through
68708
68709 case "CallExpression":
68710 return {
68711 leftParen: sourceCode.getTokenAfter(node.callee, astUtils.isOpeningParenToken),
68712 rightParen: sourceCode.getLastToken(node)
68713 };
68714
68715 case "FunctionDeclaration":
68716 case "FunctionExpression":
68717 {
68718 const leftParen = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken);
68719 const rightParen = node.params.length ? sourceCode.getTokenAfter(node.params[node.params.length - 1], astUtils.isClosingParenToken) : sourceCode.getTokenAfter(leftParen);
68720 return {
68721 leftParen,
68722 rightParen
68723 };
68724 }
68725
68726 case "ArrowFunctionExpression":
68727 {
68728 const firstToken = sourceCode.getFirstToken(node, {
68729 skip: node.async ? 1 : 0
68730 });
68731
68732 if (!astUtils.isOpeningParenToken(firstToken)) {
68733 // If the ArrowFunctionExpression has a single param without parens, return null.
68734 return null;
68735 }
68736
68737 return {
68738 leftParen: firstToken,
68739 rightParen: sourceCode.getTokenBefore(node.body, astUtils.isClosingParenToken)
68740 };
68741 }
68742
68743 case "ImportExpression":
68744 {
68745 const leftParen = sourceCode.getFirstToken(node, 1);
68746 const rightParen = sourceCode.getLastToken(node);
68747 return {
68748 leftParen,
68749 rightParen
68750 };
68751 }
68752
68753 default:
68754 throw new TypeError("unexpected node with type ".concat(node.type));
68755 }
68756 } //----------------------------------------------------------------------
68757 // Public
68758 //----------------------------------------------------------------------
68759
68760
68761 return {
68762 [["ArrowFunctionExpression", "CallExpression", "FunctionDeclaration", "FunctionExpression", "ImportExpression", "NewExpression"]](node) {
68763 const parens = getParenTokens(node);
68764 let params;
68765
68766 if (node.type === "ImportExpression") {
68767 params = [node.source];
68768 } else if (astUtils.isFunction(node)) {
68769 params = node.params;
68770 } else {
68771 params = node.arguments;
68772 }
68773
68774 if (parens) {
68775 validateParens(parens, params);
68776
68777 if (multilineArgumentsOption) {
68778 validateArguments(parens, params);
68779 }
68780 }
68781 }
68782
68783 };
68784 }
68785
68786 };
68787
68788 /***/ }),
68789 /* 593 */
68790 /***/ ((module) => {
68791
68792 "use strict";
68793 /**
68794 * @fileoverview Rule to check the spacing around the * in generator functions.
68795 * @author Jamund Ferguson
68796 */
68797 //------------------------------------------------------------------------------
68798 // Rule Definition
68799 //------------------------------------------------------------------------------
68800
68801 const OVERRIDE_SCHEMA = {
68802 oneOf: [{
68803 enum: ["before", "after", "both", "neither"]
68804 }, {
68805 type: "object",
68806 properties: {
68807 before: {
68808 type: "boolean"
68809 },
68810 after: {
68811 type: "boolean"
68812 }
68813 },
68814 additionalProperties: false
68815 }]
68816 };
68817 module.exports = {
68818 meta: {
68819 type: "layout",
68820 docs: {
68821 description: "enforce consistent spacing around `*` operators in generator functions",
68822 recommended: false,
68823 url: "https://eslint.org/docs/rules/generator-star-spacing"
68824 },
68825 fixable: "whitespace",
68826 schema: [{
68827 oneOf: [{
68828 enum: ["before", "after", "both", "neither"]
68829 }, {
68830 type: "object",
68831 properties: {
68832 before: {
68833 type: "boolean"
68834 },
68835 after: {
68836 type: "boolean"
68837 },
68838 named: OVERRIDE_SCHEMA,
68839 anonymous: OVERRIDE_SCHEMA,
68840 method: OVERRIDE_SCHEMA
68841 },
68842 additionalProperties: false
68843 }]
68844 }],
68845 messages: {
68846 missingBefore: "Missing space before *.",
68847 missingAfter: "Missing space after *.",
68848 unexpectedBefore: "Unexpected space before *.",
68849 unexpectedAfter: "Unexpected space after *."
68850 }
68851 },
68852
68853 create(context) {
68854 const optionDefinitions = {
68855 before: {
68856 before: true,
68857 after: false
68858 },
68859 after: {
68860 before: false,
68861 after: true
68862 },
68863 both: {
68864 before: true,
68865 after: true
68866 },
68867 neither: {
68868 before: false,
68869 after: false
68870 }
68871 };
68872 /**
68873 * Returns resolved option definitions based on an option and defaults
68874 * @param {any} option The option object or string value
68875 * @param {Object} defaults The defaults to use if options are not present
68876 * @returns {Object} the resolved object definition
68877 */
68878
68879 function optionToDefinition(option, defaults) {
68880 if (!option) {
68881 return defaults;
68882 }
68883
68884 return typeof option === "string" ? optionDefinitions[option] : Object.assign({}, defaults, option);
68885 }
68886
68887 const modes = function (option) {
68888 const defaults = optionToDefinition(option, optionDefinitions.before);
68889 return {
68890 named: optionToDefinition(option.named, defaults),
68891 anonymous: optionToDefinition(option.anonymous, defaults),
68892 method: optionToDefinition(option.method, defaults)
68893 };
68894 }(context.options[0] || {});
68895
68896 const sourceCode = context.getSourceCode();
68897 /**
68898 * Checks if the given token is a star token or not.
68899 * @param {Token} token The token to check.
68900 * @returns {boolean} `true` if the token is a star token.
68901 */
68902
68903 function isStarToken(token) {
68904 return token.value === "*" && token.type === "Punctuator";
68905 }
68906 /**
68907 * Gets the generator star token of the given function node.
68908 * @param {ASTNode} node The function node to get.
68909 * @returns {Token} Found star token.
68910 */
68911
68912
68913 function getStarToken(node) {
68914 return sourceCode.getFirstToken(node.parent.method || node.parent.type === "MethodDefinition" ? node.parent : node, isStarToken);
68915 }
68916 /**
68917 * capitalize a given string.
68918 * @param {string} str the given string.
68919 * @returns {string} the capitalized string.
68920 */
68921
68922
68923 function capitalize(str) {
68924 return str[0].toUpperCase() + str.slice(1);
68925 }
68926 /**
68927 * Checks the spacing between two tokens before or after the star token.
68928 * @param {string} kind Either "named", "anonymous", or "method"
68929 * @param {string} side Either "before" or "after".
68930 * @param {Token} leftToken `function` keyword token if side is "before", or
68931 * star token if side is "after".
68932 * @param {Token} rightToken Star token if side is "before", or identifier
68933 * token if side is "after".
68934 * @returns {void}
68935 */
68936
68937
68938 function checkSpacing(kind, side, leftToken, rightToken) {
68939 if (!!(rightToken.range[0] - leftToken.range[1]) !== modes[kind][side]) {
68940 const after = leftToken.value === "*";
68941 const spaceRequired = modes[kind][side];
68942 const node = after ? leftToken : rightToken;
68943 const messageId = "".concat(spaceRequired ? "missing" : "unexpected").concat(capitalize(side));
68944 context.report({
68945 node,
68946 messageId,
68947
68948 fix(fixer) {
68949 if (spaceRequired) {
68950 if (after) {
68951 return fixer.insertTextAfter(node, " ");
68952 }
68953
68954 return fixer.insertTextBefore(node, " ");
68955 }
68956
68957 return fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
68958 }
68959
68960 });
68961 }
68962 }
68963 /**
68964 * Enforces the spacing around the star if node is a generator function.
68965 * @param {ASTNode} node A function expression or declaration node.
68966 * @returns {void}
68967 */
68968
68969
68970 function checkFunction(node) {
68971 if (!node.generator) {
68972 return;
68973 }
68974
68975 const starToken = getStarToken(node);
68976 const prevToken = sourceCode.getTokenBefore(starToken);
68977 const nextToken = sourceCode.getTokenAfter(starToken);
68978 let kind = "named";
68979
68980 if (node.parent.type === "MethodDefinition" || node.parent.type === "Property" && node.parent.method) {
68981 kind = "method";
68982 } else if (!node.id) {
68983 kind = "anonymous";
68984 } // Only check before when preceded by `function`|`static` keyword
68985
68986
68987 if (!(kind === "method" && starToken === sourceCode.getFirstToken(node.parent))) {
68988 checkSpacing(kind, "before", prevToken, starToken);
68989 }
68990
68991 checkSpacing(kind, "after", starToken, nextToken);
68992 }
68993
68994 return {
68995 FunctionDeclaration: checkFunction,
68996 FunctionExpression: checkFunction
68997 };
68998 }
68999
69000 };
69001
69002 /***/ }),
69003 /* 594 */
69004 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
69005
69006 "use strict";
69007 /**
69008 * @fileoverview Enforces that a return statement is present in property getters.
69009 * @author Aladdin-ADD(hh_2013@foxmail.com)
69010 */
69011 //------------------------------------------------------------------------------
69012 // Requirements
69013 //------------------------------------------------------------------------------
69014
69015 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
69016 // Helpers
69017 //------------------------------------------------------------------------------
69018
69019
69020 const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u;
69021 /**
69022 * Checks a given code path segment is reachable.
69023 * @param {CodePathSegment} segment A segment to check.
69024 * @returns {boolean} `true` if the segment is reachable.
69025 */
69026
69027 function isReachable(segment) {
69028 return segment.reachable;
69029 } //------------------------------------------------------------------------------
69030 // Rule Definition
69031 //------------------------------------------------------------------------------
69032
69033
69034 module.exports = {
69035 meta: {
69036 type: "problem",
69037 docs: {
69038 description: "enforce `return` statements in getters",
69039 recommended: true,
69040 url: "https://eslint.org/docs/rules/getter-return"
69041 },
69042 fixable: null,
69043 schema: [{
69044 type: "object",
69045 properties: {
69046 allowImplicit: {
69047 type: "boolean",
69048 default: false
69049 }
69050 },
69051 additionalProperties: false
69052 }],
69053 messages: {
69054 expected: "Expected to return a value in {{name}}.",
69055 expectedAlways: "Expected {{name}} to always return a value."
69056 }
69057 },
69058
69059 create(context) {
69060 const options = context.options[0] || {
69061 allowImplicit: false
69062 };
69063 const sourceCode = context.getSourceCode();
69064 let funcInfo = {
69065 upper: null,
69066 codePath: null,
69067 hasReturn: false,
69068 shouldCheck: false,
69069 node: null
69070 };
69071 /**
69072 * Checks whether or not the last code path segment is reachable.
69073 * Then reports this function if the segment is reachable.
69074 *
69075 * If the last code path segment is reachable, there are paths which are not
69076 * returned or thrown.
69077 * @param {ASTNode} node A node to check.
69078 * @returns {void}
69079 */
69080
69081 function checkLastSegment(node) {
69082 if (funcInfo.shouldCheck && funcInfo.codePath.currentSegments.some(isReachable)) {
69083 context.report({
69084 node,
69085 loc: astUtils.getFunctionHeadLoc(node, sourceCode),
69086 messageId: funcInfo.hasReturn ? "expectedAlways" : "expected",
69087 data: {
69088 name: astUtils.getFunctionNameWithKind(funcInfo.node)
69089 }
69090 });
69091 }
69092 }
69093 /**
69094 * Checks whether a node means a getter function.
69095 * @param {ASTNode} node a node to check.
69096 * @returns {boolean} if node means a getter, return true; else return false.
69097 */
69098
69099
69100 function isGetter(node) {
69101 const parent = node.parent;
69102
69103 if (TARGET_NODE_TYPE.test(node.type) && node.body.type === "BlockStatement") {
69104 if (parent.kind === "get") {
69105 return true;
69106 }
69107
69108 if (parent.type === "Property" && astUtils.getStaticPropertyName(parent) === "get" && parent.parent.type === "ObjectExpression") {
69109 // Object.defineProperty()
69110 if (parent.parent.parent.type === "CallExpression" && astUtils.getStaticPropertyName(parent.parent.parent.callee) === "defineProperty") {
69111 return true;
69112 } // Object.defineProperties()
69113
69114
69115 if (parent.parent.parent.type === "Property" && parent.parent.parent.parent.type === "ObjectExpression" && parent.parent.parent.parent.parent.type === "CallExpression" && astUtils.getStaticPropertyName(parent.parent.parent.parent.parent.callee) === "defineProperties") {
69116 return true;
69117 }
69118 }
69119 }
69120
69121 return false;
69122 }
69123
69124 return {
69125 // Stacks this function's information.
69126 onCodePathStart(codePath, node) {
69127 funcInfo = {
69128 upper: funcInfo,
69129 codePath,
69130 hasReturn: false,
69131 shouldCheck: isGetter(node),
69132 node
69133 };
69134 },
69135
69136 // Pops this function's information.
69137 onCodePathEnd() {
69138 funcInfo = funcInfo.upper;
69139 },
69140
69141 // Checks the return statement is valid.
69142 ReturnStatement(node) {
69143 if (funcInfo.shouldCheck) {
69144 funcInfo.hasReturn = true; // if allowImplicit: false, should also check node.argument
69145
69146 if (!options.allowImplicit && !node.argument) {
69147 context.report({
69148 node,
69149 messageId: "expected",
69150 data: {
69151 name: astUtils.getFunctionNameWithKind(funcInfo.node)
69152 }
69153 });
69154 }
69155 }
69156 },
69157
69158 // Reports a given function if the last path is reachable.
69159 "FunctionExpression:exit": checkLastSegment,
69160 "ArrowFunctionExpression:exit": checkLastSegment
69161 };
69162 }
69163
69164 };
69165
69166 /***/ }),
69167 /* 595 */
69168 /***/ ((module) => {
69169
69170 "use strict";
69171 /**
69172 * @fileoverview Rule for disallowing require() outside of the top-level module context
69173 * @author Jamund Ferguson
69174 * @deprecated in ESLint v7.0.0
69175 */
69176
69177
69178 const ACCEPTABLE_PARENTS = ["AssignmentExpression", "VariableDeclarator", "MemberExpression", "ExpressionStatement", "CallExpression", "ConditionalExpression", "Program", "VariableDeclaration", "ChainExpression"];
69179 /**
69180 * Finds the eslint-scope reference in the given scope.
69181 * @param {Object} scope The scope to search.
69182 * @param {ASTNode} node The identifier node.
69183 * @returns {Reference|null} Returns the found reference or null if none were found.
69184 */
69185
69186 function findReference(scope, node) {
69187 const references = scope.references.filter(reference => reference.identifier.range[0] === node.range[0] && reference.identifier.range[1] === node.range[1]);
69188 /* istanbul ignore else: correctly returns null */
69189
69190 if (references.length === 1) {
69191 return references[0];
69192 }
69193
69194 return null;
69195 }
69196 /**
69197 * Checks if the given identifier node is shadowed in the given scope.
69198 * @param {Object} scope The current scope.
69199 * @param {ASTNode} node The identifier node to check.
69200 * @returns {boolean} Whether or not the name is shadowed.
69201 */
69202
69203
69204 function isShadowed(scope, node) {
69205 const reference = findReference(scope, node);
69206 return reference && reference.resolved && reference.resolved.defs.length > 0;
69207 }
69208
69209 module.exports = {
69210 meta: {
69211 deprecated: true,
69212 replacedBy: [],
69213 type: "suggestion",
69214 docs: {
69215 description: "require `require()` calls to be placed at top-level module scope",
69216 recommended: false,
69217 url: "https://eslint.org/docs/rules/global-require"
69218 },
69219 schema: [],
69220 messages: {
69221 unexpected: "Unexpected require()."
69222 }
69223 },
69224
69225 create(context) {
69226 return {
69227 CallExpression(node) {
69228 const currentScope = context.getScope();
69229
69230 if (node.callee.name === "require" && !isShadowed(currentScope, node.callee)) {
69231 const isGoodRequire = context.getAncestors().every(parent => ACCEPTABLE_PARENTS.indexOf(parent.type) > -1);
69232
69233 if (!isGoodRequire) {
69234 context.report({
69235 node,
69236 messageId: "unexpected"
69237 });
69238 }
69239 }
69240 }
69241
69242 };
69243 }
69244
69245 };
69246
69247 /***/ }),
69248 /* 596 */
69249 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
69250
69251 "use strict";
69252 /**
69253 * @fileoverview Rule to require grouped accessor pairs in object literals and classes
69254 * @author Milos Djermanovic
69255 */
69256 //------------------------------------------------------------------------------
69257 // Requirements
69258 //------------------------------------------------------------------------------
69259
69260 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
69261 // Typedefs
69262 //------------------------------------------------------------------------------
69263
69264 /**
69265 * Property name if it can be computed statically, otherwise the list of the tokens of the key node.
69266 * @typedef {string|Token[]} Key
69267 */
69268
69269 /**
69270 * Accessor nodes with the same key.
69271 * @typedef {Object} AccessorData
69272 * @property {Key} key Accessor's key
69273 * @property {ASTNode[]} getters List of getter nodes.
69274 * @property {ASTNode[]} setters List of setter nodes.
69275 */
69276 //------------------------------------------------------------------------------
69277 // Helpers
69278 //------------------------------------------------------------------------------
69279
69280 /**
69281 * Checks whether or not the given lists represent the equal tokens in the same order.
69282 * Tokens are compared by their properties, not by instance.
69283 * @param {Token[]} left First list of tokens.
69284 * @param {Token[]} right Second list of tokens.
69285 * @returns {boolean} `true` if the lists have same tokens.
69286 */
69287
69288
69289 function areEqualTokenLists(left, right) {
69290 if (left.length !== right.length) {
69291 return false;
69292 }
69293
69294 for (let i = 0; i < left.length; i++) {
69295 const leftToken = left[i],
69296 rightToken = right[i];
69297
69298 if (leftToken.type !== rightToken.type || leftToken.value !== rightToken.value) {
69299 return false;
69300 }
69301 }
69302
69303 return true;
69304 }
69305 /**
69306 * Checks whether or not the given keys are equal.
69307 * @param {Key} left First key.
69308 * @param {Key} right Second key.
69309 * @returns {boolean} `true` if the keys are equal.
69310 */
69311
69312
69313 function areEqualKeys(left, right) {
69314 if (typeof left === "string" && typeof right === "string") {
69315 // Statically computed names.
69316 return left === right;
69317 }
69318
69319 if (Array.isArray(left) && Array.isArray(right)) {
69320 // Token lists.
69321 return areEqualTokenLists(left, right);
69322 }
69323
69324 return false;
69325 }
69326 /**
69327 * Checks whether or not a given node is of an accessor kind ('get' or 'set').
69328 * @param {ASTNode} node A node to check.
69329 * @returns {boolean} `true` if the node is of an accessor kind.
69330 */
69331
69332
69333 function isAccessorKind(node) {
69334 return node.kind === "get" || node.kind === "set";
69335 } //------------------------------------------------------------------------------
69336 // Rule Definition
69337 //------------------------------------------------------------------------------
69338
69339
69340 module.exports = {
69341 meta: {
69342 type: "suggestion",
69343 docs: {
69344 description: "require grouped accessor pairs in object literals and classes",
69345 recommended: false,
69346 url: "https://eslint.org/docs/rules/grouped-accessor-pairs"
69347 },
69348 schema: [{
69349 enum: ["anyOrder", "getBeforeSet", "setBeforeGet"]
69350 }],
69351 messages: {
69352 notGrouped: "Accessor pair {{ formerName }} and {{ latterName }} should be grouped.",
69353 invalidOrder: "Expected {{ latterName }} to be before {{ formerName }}."
69354 }
69355 },
69356
69357 create(context) {
69358 const order = context.options[0] || "anyOrder";
69359 const sourceCode = context.getSourceCode();
69360 /**
69361 * Reports the given accessor pair.
69362 * @param {string} messageId messageId to report.
69363 * @param {ASTNode} formerNode getter/setter node that is defined before `latterNode`.
69364 * @param {ASTNode} latterNode getter/setter node that is defined after `formerNode`.
69365 * @returns {void}
69366 * @private
69367 */
69368
69369 function report(messageId, formerNode, latterNode) {
69370 context.report({
69371 node: latterNode,
69372 messageId,
69373 loc: astUtils.getFunctionHeadLoc(latterNode.value, sourceCode),
69374 data: {
69375 formerName: astUtils.getFunctionNameWithKind(formerNode.value),
69376 latterName: astUtils.getFunctionNameWithKind(latterNode.value)
69377 }
69378 });
69379 }
69380 /**
69381 * Creates a new `AccessorData` object for the given getter or setter node.
69382 * @param {ASTNode} node A getter or setter node.
69383 * @returns {AccessorData} New `AccessorData` object that contains the given node.
69384 * @private
69385 */
69386
69387
69388 function createAccessorData(node) {
69389 const name = astUtils.getStaticPropertyName(node);
69390 const key = name !== null ? name : sourceCode.getTokens(node.key);
69391 return {
69392 key,
69393 getters: node.kind === "get" ? [node] : [],
69394 setters: node.kind === "set" ? [node] : []
69395 };
69396 }
69397 /**
69398 * Merges the given `AccessorData` object into the given accessors list.
69399 * @param {AccessorData[]} accessors The list to merge into.
69400 * @param {AccessorData} accessorData The object to merge.
69401 * @returns {AccessorData[]} The same instance with the merged object.
69402 * @private
69403 */
69404
69405
69406 function mergeAccessorData(accessors, accessorData) {
69407 const equalKeyElement = accessors.find(a => areEqualKeys(a.key, accessorData.key));
69408
69409 if (equalKeyElement) {
69410 equalKeyElement.getters.push(...accessorData.getters);
69411 equalKeyElement.setters.push(...accessorData.setters);
69412 } else {
69413 accessors.push(accessorData);
69414 }
69415
69416 return accessors;
69417 }
69418 /**
69419 * Checks accessor pairs in the given list of nodes.
69420 * @param {ASTNode[]} nodes The list to check.
69421 * @param {Function} shouldCheck – Predicate that returns `true` if the node should be checked.
69422 * @returns {void}
69423 * @private
69424 */
69425
69426
69427 function checkList(nodes, shouldCheck) {
69428 const accessors = nodes.filter(shouldCheck).filter(isAccessorKind).map(createAccessorData).reduce(mergeAccessorData, []);
69429
69430 for (const {
69431 getters,
69432 setters
69433 } of accessors) {
69434 // Don't report accessor properties that have duplicate getters or setters.
69435 if (getters.length === 1 && setters.length === 1) {
69436 const [getter] = getters,
69437 [setter] = setters,
69438 getterIndex = nodes.indexOf(getter),
69439 setterIndex = nodes.indexOf(setter),
69440 formerNode = getterIndex < setterIndex ? getter : setter,
69441 latterNode = getterIndex < setterIndex ? setter : getter;
69442
69443 if (Math.abs(getterIndex - setterIndex) > 1) {
69444 report("notGrouped", formerNode, latterNode);
69445 } else if (order === "getBeforeSet" && getterIndex > setterIndex || order === "setBeforeGet" && getterIndex < setterIndex) {
69446 report("invalidOrder", formerNode, latterNode);
69447 }
69448 }
69449 }
69450 }
69451
69452 return {
69453 ObjectExpression(node) {
69454 checkList(node.properties, n => n.type === "Property");
69455 },
69456
69457 ClassBody(node) {
69458 checkList(node.body, n => n.type === "MethodDefinition" && !n.static);
69459 checkList(node.body, n => n.type === "MethodDefinition" && n.static);
69460 }
69461
69462 };
69463 }
69464
69465 };
69466
69467 /***/ }),
69468 /* 597 */
69469 /***/ ((module) => {
69470
69471 "use strict";
69472 /**
69473 * @fileoverview Rule to flag for-in loops without if statements inside
69474 * @author Nicholas C. Zakas
69475 */
69476 //------------------------------------------------------------------------------
69477 // Rule Definition
69478 //------------------------------------------------------------------------------
69479
69480 module.exports = {
69481 meta: {
69482 type: "suggestion",
69483 docs: {
69484 description: "require `for-in` loops to include an `if` statement",
69485 recommended: false,
69486 url: "https://eslint.org/docs/rules/guard-for-in"
69487 },
69488 schema: [],
69489 messages: {
69490 wrap: "The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype."
69491 }
69492 },
69493
69494 create(context) {
69495 return {
69496 ForInStatement(node) {
69497 const body = node.body; // empty statement
69498
69499 if (body.type === "EmptyStatement") {
69500 return;
69501 } // if statement
69502
69503
69504 if (body.type === "IfStatement") {
69505 return;
69506 } // empty block
69507
69508
69509 if (body.type === "BlockStatement" && body.body.length === 0) {
69510 return;
69511 } // block with just if statement
69512
69513
69514 if (body.type === "BlockStatement" && body.body.length === 1 && body.body[0].type === "IfStatement") {
69515 return;
69516 } // block that starts with if statement
69517
69518
69519 if (body.type === "BlockStatement" && body.body.length >= 1 && body.body[0].type === "IfStatement") {
69520 const i = body.body[0]; // ... whose consequent is a continue
69521
69522 if (i.consequent.type === "ContinueStatement") {
69523 return;
69524 } // ... whose consequent is a block that contains only a continue
69525
69526
69527 if (i.consequent.type === "BlockStatement" && i.consequent.body.length === 1 && i.consequent.body[0].type === "ContinueStatement") {
69528 return;
69529 }
69530 }
69531
69532 context.report({
69533 node,
69534 messageId: "wrap"
69535 });
69536 }
69537
69538 };
69539 }
69540
69541 };
69542
69543 /***/ }),
69544 /* 598 */
69545 /***/ ((module) => {
69546
69547 "use strict";
69548 /**
69549 * @fileoverview Ensure handling of errors when we know they exist.
69550 * @author Jamund Ferguson
69551 * @deprecated in ESLint v7.0.0
69552 */
69553 //------------------------------------------------------------------------------
69554 // Rule Definition
69555 //------------------------------------------------------------------------------
69556
69557 module.exports = {
69558 meta: {
69559 deprecated: true,
69560 replacedBy: [],
69561 type: "suggestion",
69562 docs: {
69563 description: "require error handling in callbacks",
69564 recommended: false,
69565 url: "https://eslint.org/docs/rules/handle-callback-err"
69566 },
69567 schema: [{
69568 type: "string"
69569 }],
69570 messages: {
69571 expected: "Expected error to be handled."
69572 }
69573 },
69574
69575 create(context) {
69576 const errorArgument = context.options[0] || "err";
69577 /**
69578 * Checks if the given argument should be interpreted as a regexp pattern.
69579 * @param {string} stringToCheck The string which should be checked.
69580 * @returns {boolean} Whether or not the string should be interpreted as a pattern.
69581 */
69582
69583 function isPattern(stringToCheck) {
69584 const firstChar = stringToCheck[0];
69585 return firstChar === "^";
69586 }
69587 /**
69588 * Checks if the given name matches the configured error argument.
69589 * @param {string} name The name which should be compared.
69590 * @returns {boolean} Whether or not the given name matches the configured error variable name.
69591 */
69592
69593
69594 function matchesConfiguredErrorName(name) {
69595 if (isPattern(errorArgument)) {
69596 const regexp = new RegExp(errorArgument, "u");
69597 return regexp.test(name);
69598 }
69599
69600 return name === errorArgument;
69601 }
69602 /**
69603 * Get the parameters of a given function scope.
69604 * @param {Object} scope The function scope.
69605 * @returns {Array} All parameters of the given scope.
69606 */
69607
69608
69609 function getParameters(scope) {
69610 return scope.variables.filter(variable => variable.defs[0] && variable.defs[0].type === "Parameter");
69611 }
69612 /**
69613 * Check to see if we're handling the error object properly.
69614 * @param {ASTNode} node The AST node to check.
69615 * @returns {void}
69616 */
69617
69618
69619 function checkForError(node) {
69620 const scope = context.getScope(),
69621 parameters = getParameters(scope),
69622 firstParameter = parameters[0];
69623
69624 if (firstParameter && matchesConfiguredErrorName(firstParameter.name)) {
69625 if (firstParameter.references.length === 0) {
69626 context.report({
69627 node,
69628 messageId: "expected"
69629 });
69630 }
69631 }
69632 }
69633
69634 return {
69635 FunctionDeclaration: checkForError,
69636 FunctionExpression: checkForError,
69637 ArrowFunctionExpression: checkForError
69638 };
69639 }
69640
69641 };
69642
69643 /***/ }),
69644 /* 599 */
69645 /***/ ((module) => {
69646
69647 "use strict";
69648 /**
69649 * @fileoverview Rule that warns when identifier names that are
69650 * specified in the configuration are used.
69651 * @author Keith Cirkel (http://keithcirkel.co.uk)
69652 * @deprecated in ESLint v7.5.0
69653 */
69654 //------------------------------------------------------------------------------
69655 // Helpers
69656 //------------------------------------------------------------------------------
69657
69658 /**
69659 * Checks whether the given node represents assignment target in a normal assignment or destructuring.
69660 * @param {ASTNode} node The node to check.
69661 * @returns {boolean} `true` if the node is assignment target.
69662 */
69663
69664 function isAssignmentTarget(node) {
69665 const parent = node.parent;
69666 return (// normal assignment
69667 parent.type === "AssignmentExpression" && parent.left === node || // destructuring
69668 parent.type === "ArrayPattern" || parent.type === "RestElement" || parent.type === "Property" && parent.value === node && parent.parent.type === "ObjectPattern" || parent.type === "AssignmentPattern" && parent.left === node
69669 );
69670 }
69671 /**
69672 * Checks whether the given node represents an imported name that is renamed in the same import/export specifier.
69673 *
69674 * Examples:
69675 * import { a as b } from 'mod'; // node `a` is renamed import
69676 * export { a as b } from 'mod'; // node `a` is renamed import
69677 * @param {ASTNode} node `Identifier` node to check.
69678 * @returns {boolean} `true` if the node is a renamed import.
69679 */
69680
69681
69682 function isRenamedImport(node) {
69683 const parent = node.parent;
69684 return parent.type === "ImportSpecifier" && parent.imported !== parent.local && parent.imported === node || parent.type === "ExportSpecifier" && parent.parent.source && // re-export
69685 parent.local !== parent.exported && parent.local === node;
69686 }
69687 /**
69688 * Checks whether the given node is a renamed identifier node in an ObjectPattern destructuring.
69689 *
69690 * Examples:
69691 * const { a : b } = foo; // node `a` is renamed node.
69692 * @param {ASTNode} node `Identifier` node to check.
69693 * @returns {boolean} `true` if the node is a renamed node in an ObjectPattern destructuring.
69694 */
69695
69696
69697 function isRenamedInDestructuring(node) {
69698 const parent = node.parent;
69699 return !parent.computed && parent.type === "Property" && parent.parent.type === "ObjectPattern" && parent.value !== node && parent.key === node;
69700 }
69701 /**
69702 * Checks whether the given node represents shorthand definition of a property in an object literal.
69703 * @param {ASTNode} node `Identifier` node to check.
69704 * @returns {boolean} `true` if the node is a shorthand property definition.
69705 */
69706
69707
69708 function isShorthandPropertyDefinition(node) {
69709 const parent = node.parent;
69710 return parent.type === "Property" && parent.parent.type === "ObjectExpression" && parent.shorthand;
69711 } //------------------------------------------------------------------------------
69712 // Rule Definition
69713 //------------------------------------------------------------------------------
69714
69715
69716 module.exports = {
69717 meta: {
69718 deprecated: true,
69719 replacedBy: ["id-denylist"],
69720 type: "suggestion",
69721 docs: {
69722 description: "disallow specified identifiers",
69723 recommended: false,
69724 url: "https://eslint.org/docs/rules/id-blacklist"
69725 },
69726 schema: {
69727 type: "array",
69728 items: {
69729 type: "string"
69730 },
69731 uniqueItems: true
69732 },
69733 messages: {
69734 restricted: "Identifier '{{name}}' is restricted."
69735 }
69736 },
69737
69738 create(context) {
69739 const denyList = new Set(context.options);
69740 const reportedNodes = new Set();
69741 let globalScope;
69742 /**
69743 * Checks whether the given name is restricted.
69744 * @param {string} name The name to check.
69745 * @returns {boolean} `true` if the name is restricted.
69746 * @private
69747 */
69748
69749 function isRestricted(name) {
69750 return denyList.has(name);
69751 }
69752 /**
69753 * Checks whether the given node represents a reference to a global variable that is not declared in the source code.
69754 * These identifiers will be allowed, as it is assumed that user has no control over the names of external global variables.
69755 * @param {ASTNode} node `Identifier` node to check.
69756 * @returns {boolean} `true` if the node is a reference to a global variable.
69757 */
69758
69759
69760 function isReferenceToGlobalVariable(node) {
69761 const variable = globalScope.set.get(node.name);
69762 return variable && variable.defs.length === 0 && variable.references.some(ref => ref.identifier === node);
69763 }
69764 /**
69765 * Determines whether the given node should be checked.
69766 * @param {ASTNode} node `Identifier` node.
69767 * @returns {boolean} `true` if the node should be checked.
69768 */
69769
69770
69771 function shouldCheck(node) {
69772 const parent = node.parent;
69773 /*
69774 * Member access has special rules for checking property names.
69775 * Read access to a property with a restricted name is allowed, because it can be on an object that user has no control over.
69776 * Write access isn't allowed, because it potentially creates a new property with a restricted name.
69777 */
69778
69779 if (parent.type === "MemberExpression" && parent.property === node && !parent.computed) {
69780 return isAssignmentTarget(parent);
69781 }
69782
69783 return parent.type !== "CallExpression" && parent.type !== "NewExpression" && !isRenamedImport(node) && !isRenamedInDestructuring(node) && !(isReferenceToGlobalVariable(node) && !isShorthandPropertyDefinition(node));
69784 }
69785 /**
69786 * Reports an AST node as a rule violation.
69787 * @param {ASTNode} node The node to report.
69788 * @returns {void}
69789 * @private
69790 */
69791
69792
69793 function report(node) {
69794 /*
69795 * We used the range instead of the node because it's possible
69796 * for the same identifier to be represented by two different
69797 * nodes, with the most clear example being shorthand properties:
69798 * { foo }
69799 * In this case, "foo" is represented by one node for the name
69800 * and one for the value. The only way to know they are the same
69801 * is to look at the range.
69802 */
69803 if (!reportedNodes.has(node.range.toString())) {
69804 context.report({
69805 node,
69806 messageId: "restricted",
69807 data: {
69808 name: node.name
69809 }
69810 });
69811 reportedNodes.add(node.range.toString());
69812 }
69813 }
69814
69815 return {
69816 Program() {
69817 globalScope = context.getScope();
69818 },
69819
69820 Identifier(node) {
69821 if (isRestricted(node.name) && shouldCheck(node)) {
69822 report(node);
69823 }
69824 }
69825
69826 };
69827 }
69828
69829 };
69830
69831 /***/ }),
69832 /* 600 */
69833 /***/ ((module) => {
69834
69835 "use strict";
69836 /**
69837 * @fileoverview Rule that warns when identifier names that are
69838 * specified in the configuration are used.
69839 * @author Keith Cirkel (http://keithcirkel.co.uk)
69840 */
69841 //------------------------------------------------------------------------------
69842 // Helpers
69843 //------------------------------------------------------------------------------
69844
69845 /**
69846 * Checks whether the given node represents assignment target in a normal assignment or destructuring.
69847 * @param {ASTNode} node The node to check.
69848 * @returns {boolean} `true` if the node is assignment target.
69849 */
69850
69851 function isAssignmentTarget(node) {
69852 const parent = node.parent;
69853 return (// normal assignment
69854 parent.type === "AssignmentExpression" && parent.left === node || // destructuring
69855 parent.type === "ArrayPattern" || parent.type === "RestElement" || parent.type === "Property" && parent.value === node && parent.parent.type === "ObjectPattern" || parent.type === "AssignmentPattern" && parent.left === node
69856 );
69857 }
69858 /**
69859 * Checks whether the given node represents an imported name that is renamed in the same import/export specifier.
69860 *
69861 * Examples:
69862 * import { a as b } from 'mod'; // node `a` is renamed import
69863 * export { a as b } from 'mod'; // node `a` is renamed import
69864 * @param {ASTNode} node `Identifier` node to check.
69865 * @returns {boolean} `true` if the node is a renamed import.
69866 */
69867
69868
69869 function isRenamedImport(node) {
69870 const parent = node.parent;
69871 return parent.type === "ImportSpecifier" && parent.imported !== parent.local && parent.imported === node || parent.type === "ExportSpecifier" && parent.parent.source && // re-export
69872 parent.local !== parent.exported && parent.local === node;
69873 }
69874 /**
69875 * Checks whether the given node is an ObjectPattern destructuring.
69876 *
69877 * Examples:
69878 * const { a : b } = foo;
69879 * @param {ASTNode} node `Identifier` node to check.
69880 * @returns {boolean} `true` if the node is in an ObjectPattern destructuring.
69881 */
69882
69883
69884 function isPropertyNameInDestructuring(node) {
69885 const parent = node.parent;
69886 return !parent.computed && parent.type === "Property" && parent.parent.type === "ObjectPattern" && parent.key === node;
69887 } //------------------------------------------------------------------------------
69888 // Rule Definition
69889 //------------------------------------------------------------------------------
69890
69891
69892 module.exports = {
69893 meta: {
69894 type: "suggestion",
69895 docs: {
69896 description: "disallow specified identifiers",
69897 recommended: false,
69898 url: "https://eslint.org/docs/rules/id-denylist"
69899 },
69900 schema: {
69901 type: "array",
69902 items: {
69903 type: "string"
69904 },
69905 uniqueItems: true
69906 },
69907 messages: {
69908 restricted: "Identifier '{{name}}' is restricted.",
69909 restrictedPrivate: "Identifier '#{{name}}' is restricted."
69910 }
69911 },
69912
69913 create(context) {
69914 const denyList = new Set(context.options);
69915 const reportedNodes = new Set();
69916 let globalScope;
69917 /**
69918 * Checks whether the given name is restricted.
69919 * @param {string} name The name to check.
69920 * @returns {boolean} `true` if the name is restricted.
69921 * @private
69922 */
69923
69924 function isRestricted(name) {
69925 return denyList.has(name);
69926 }
69927 /**
69928 * Checks whether the given node represents a reference to a global variable that is not declared in the source code.
69929 * These identifiers will be allowed, as it is assumed that user has no control over the names of external global variables.
69930 * @param {ASTNode} node `Identifier` node to check.
69931 * @returns {boolean} `true` if the node is a reference to a global variable.
69932 */
69933
69934
69935 function isReferenceToGlobalVariable(node) {
69936 const variable = globalScope.set.get(node.name);
69937 return variable && variable.defs.length === 0 && variable.references.some(ref => ref.identifier === node);
69938 }
69939 /**
69940 * Determines whether the given node should be checked.
69941 * @param {ASTNode} node `Identifier` node.
69942 * @returns {boolean} `true` if the node should be checked.
69943 */
69944
69945
69946 function shouldCheck(node) {
69947 const parent = node.parent;
69948 /*
69949 * Member access has special rules for checking property names.
69950 * Read access to a property with a restricted name is allowed, because it can be on an object that user has no control over.
69951 * Write access isn't allowed, because it potentially creates a new property with a restricted name.
69952 */
69953
69954 if (parent.type === "MemberExpression" && parent.property === node && !parent.computed) {
69955 return isAssignmentTarget(parent);
69956 }
69957
69958 return parent.type !== "CallExpression" && parent.type !== "NewExpression" && !isRenamedImport(node) && !isPropertyNameInDestructuring(node) && !isReferenceToGlobalVariable(node);
69959 }
69960 /**
69961 * Reports an AST node as a rule violation.
69962 * @param {ASTNode} node The node to report.
69963 * @returns {void}
69964 * @private
69965 */
69966
69967
69968 function report(node) {
69969 /*
69970 * We used the range instead of the node because it's possible
69971 * for the same identifier to be represented by two different
69972 * nodes, with the most clear example being shorthand properties:
69973 * { foo }
69974 * In this case, "foo" is represented by one node for the name
69975 * and one for the value. The only way to know they are the same
69976 * is to look at the range.
69977 */
69978 if (!reportedNodes.has(node.range.toString())) {
69979 const isPrivate = node.type === "PrivateIdentifier";
69980 context.report({
69981 node,
69982 messageId: isPrivate ? "restrictedPrivate" : "restricted",
69983 data: {
69984 name: node.name
69985 }
69986 });
69987 reportedNodes.add(node.range.toString());
69988 }
69989 }
69990
69991 return {
69992 Program() {
69993 globalScope = context.getScope();
69994 },
69995
69996 [["Identifier", "PrivateIdentifier"]](node) {
69997 if (isRestricted(node.name) && shouldCheck(node)) {
69998 report(node);
69999 }
70000 }
70001
70002 };
70003 }
70004
70005 };
70006
70007 /***/ }),
70008 /* 601 */
70009 /***/ ((module) => {
70010
70011 "use strict";
70012 /**
70013 * @fileoverview Rule that warns when identifier names are shorter or longer
70014 * than the values provided in configuration.
70015 * @author Burak Yigit Kaya aka BYK
70016 */
70017 //------------------------------------------------------------------------------
70018 // Rule Definition
70019 //------------------------------------------------------------------------------
70020
70021 module.exports = {
70022 meta: {
70023 type: "suggestion",
70024 docs: {
70025 description: "enforce minimum and maximum identifier lengths",
70026 recommended: false,
70027 url: "https://eslint.org/docs/rules/id-length"
70028 },
70029 schema: [{
70030 type: "object",
70031 properties: {
70032 min: {
70033 type: "integer",
70034 default: 2
70035 },
70036 max: {
70037 type: "integer"
70038 },
70039 exceptions: {
70040 type: "array",
70041 uniqueItems: true,
70042 items: {
70043 type: "string"
70044 }
70045 },
70046 exceptionPatterns: {
70047 type: "array",
70048 uniqueItems: true,
70049 items: {
70050 type: "string"
70051 }
70052 },
70053 properties: {
70054 enum: ["always", "never"]
70055 }
70056 },
70057 additionalProperties: false
70058 }],
70059 messages: {
70060 tooShort: "Identifier name '{{name}}' is too short (< {{min}}).",
70061 tooShortPrivate: "Identifier name '#{{name}}' is too short (< {{min}}).",
70062 tooLong: "Identifier name '{{name}}' is too long (> {{max}}).",
70063 tooLongPrivate: "Identifier name #'{{name}}' is too long (> {{max}})."
70064 }
70065 },
70066
70067 create(context) {
70068 const options = context.options[0] || {};
70069 const minLength = typeof options.min !== "undefined" ? options.min : 2;
70070 const maxLength = typeof options.max !== "undefined" ? options.max : Infinity;
70071 const properties = options.properties !== "never";
70072 const exceptions = new Set(options.exceptions);
70073 const exceptionPatterns = (options.exceptionPatterns || []).map(pattern => new RegExp(pattern, "u"));
70074 const reportedNodes = new Set();
70075 /**
70076 * Checks if a string matches the provided exception patterns
70077 * @param {string} name The string to check.
70078 * @returns {boolean} if the string is a match
70079 * @private
70080 */
70081
70082 function matchesExceptionPattern(name) {
70083 return exceptionPatterns.some(pattern => pattern.test(name));
70084 }
70085
70086 const SUPPORTED_EXPRESSIONS = {
70087 MemberExpression: properties && function (parent) {
70088 return !parent.computed && ( // regular property assignment
70089 parent.parent.left === parent && parent.parent.type === "AssignmentExpression" || // or the last identifier in an ObjectPattern destructuring
70090 parent.parent.type === "Property" && parent.parent.value === parent && parent.parent.parent.type === "ObjectPattern" && parent.parent.parent.parent.left === parent.parent.parent);
70091 },
70092
70093 AssignmentPattern(parent, node) {
70094 return parent.left === node;
70095 },
70096
70097 VariableDeclarator(parent, node) {
70098 return parent.id === node;
70099 },
70100
70101 Property(parent, node) {
70102 if (parent.parent.type === "ObjectPattern") {
70103 const isKeyAndValueSame = parent.value.name === parent.key.name;
70104 return !isKeyAndValueSame && parent.value === node || isKeyAndValueSame && parent.key === node && properties;
70105 }
70106
70107 return properties && !parent.computed && parent.key.name === node.name;
70108 },
70109
70110 ImportDefaultSpecifier: true,
70111 RestElement: true,
70112 FunctionExpression: true,
70113 ArrowFunctionExpression: true,
70114 ClassDeclaration: true,
70115 FunctionDeclaration: true,
70116 MethodDefinition: true,
70117 PropertyDefinition: true,
70118 CatchClause: true,
70119 ArrayPattern: true
70120 };
70121 return {
70122 [["Identifier", "PrivateIdentifier"]](node) {
70123 const name = node.name;
70124 const parent = node.parent;
70125 const isShort = name.length < minLength;
70126 const isLong = name.length > maxLength;
70127
70128 if (!(isShort || isLong) || exceptions.has(name) || matchesExceptionPattern(name)) {
70129 return; // Nothing to report
70130 }
70131
70132 const isValidExpression = SUPPORTED_EXPRESSIONS[parent.type];
70133 /*
70134 * We used the range instead of the node because it's possible
70135 * for the same identifier to be represented by two different
70136 * nodes, with the most clear example being shorthand properties:
70137 * { foo }
70138 * In this case, "foo" is represented by one node for the name
70139 * and one for the value. The only way to know they are the same
70140 * is to look at the range.
70141 */
70142
70143 if (isValidExpression && !reportedNodes.has(node.range.toString()) && (isValidExpression === true || isValidExpression(parent, node))) {
70144 reportedNodes.add(node.range.toString());
70145 let messageId = isShort ? "tooShort" : "tooLong";
70146
70147 if (node.type === "PrivateIdentifier") {
70148 messageId += "Private";
70149 }
70150
70151 context.report({
70152 node,
70153 messageId,
70154 data: {
70155 name,
70156 min: minLength,
70157 max: maxLength
70158 }
70159 });
70160 }
70161 }
70162
70163 };
70164 }
70165
70166 };
70167
70168 /***/ }),
70169 /* 602 */
70170 /***/ ((module) => {
70171
70172 "use strict";
70173 /**
70174 * @fileoverview Rule to flag non-matching identifiers
70175 * @author Matthieu Larcher
70176 */
70177 //------------------------------------------------------------------------------
70178 // Rule Definition
70179 //------------------------------------------------------------------------------
70180
70181 module.exports = {
70182 meta: {
70183 type: "suggestion",
70184 docs: {
70185 description: "require identifiers to match a specified regular expression",
70186 recommended: false,
70187 url: "https://eslint.org/docs/rules/id-match"
70188 },
70189 schema: [{
70190 type: "string"
70191 }, {
70192 type: "object",
70193 properties: {
70194 properties: {
70195 type: "boolean",
70196 default: false
70197 },
70198 classFields: {
70199 type: "boolean",
70200 default: false
70201 },
70202 onlyDeclarations: {
70203 type: "boolean",
70204 default: false
70205 },
70206 ignoreDestructuring: {
70207 type: "boolean",
70208 default: false
70209 }
70210 },
70211 additionalProperties: false
70212 }],
70213 messages: {
70214 notMatch: "Identifier '{{name}}' does not match the pattern '{{pattern}}'.",
70215 notMatchPrivate: "Identifier '#{{name}}' does not match the pattern '{{pattern}}'."
70216 }
70217 },
70218
70219 create(context) {
70220 //--------------------------------------------------------------------------
70221 // Options
70222 //--------------------------------------------------------------------------
70223 const pattern = context.options[0] || "^.+$",
70224 regexp = new RegExp(pattern, "u");
70225 const options = context.options[1] || {},
70226 checkProperties = !!options.properties,
70227 checkClassFields = !!options.classFields,
70228 onlyDeclarations = !!options.onlyDeclarations,
70229 ignoreDestructuring = !!options.ignoreDestructuring; //--------------------------------------------------------------------------
70230 // Helpers
70231 //--------------------------------------------------------------------------
70232 // contains reported nodes to avoid reporting twice on destructuring with shorthand notation
70233
70234 const reportedNodes = new Set();
70235 const ALLOWED_PARENT_TYPES = new Set(["CallExpression", "NewExpression"]);
70236 const DECLARATION_TYPES = new Set(["FunctionDeclaration", "VariableDeclarator"]);
70237 const IMPORT_TYPES = new Set(["ImportSpecifier", "ImportNamespaceSpecifier", "ImportDefaultSpecifier"]);
70238 /**
70239 * Checks if a string matches the provided pattern
70240 * @param {string} name The string to check.
70241 * @returns {boolean} if the string is a match
70242 * @private
70243 */
70244
70245 function isInvalid(name) {
70246 return !regexp.test(name);
70247 }
70248 /**
70249 * Checks if a parent of a node is an ObjectPattern.
70250 * @param {ASTNode} node The node to check.
70251 * @returns {boolean} if the node is inside an ObjectPattern
70252 * @private
70253 */
70254
70255
70256 function isInsideObjectPattern(node) {
70257 let {
70258 parent
70259 } = node;
70260
70261 while (parent) {
70262 if (parent.type === "ObjectPattern") {
70263 return true;
70264 }
70265
70266 parent = parent.parent;
70267 }
70268
70269 return false;
70270 }
70271 /**
70272 * Verifies if we should report an error or not based on the effective
70273 * parent node and the identifier name.
70274 * @param {ASTNode} effectiveParent The effective parent node of the node to be reported
70275 * @param {string} name The identifier name of the identifier node
70276 * @returns {boolean} whether an error should be reported or not
70277 */
70278
70279
70280 function shouldReport(effectiveParent, name) {
70281 return (!onlyDeclarations || DECLARATION_TYPES.has(effectiveParent.type)) && !ALLOWED_PARENT_TYPES.has(effectiveParent.type) && isInvalid(name);
70282 }
70283 /**
70284 * Reports an AST node as a rule violation.
70285 * @param {ASTNode} node The node to report.
70286 * @returns {void}
70287 * @private
70288 */
70289
70290
70291 function report(node) {
70292 /*
70293 * We used the range instead of the node because it's possible
70294 * for the same identifier to be represented by two different
70295 * nodes, with the most clear example being shorthand properties:
70296 * { foo }
70297 * In this case, "foo" is represented by one node for the name
70298 * and one for the value. The only way to know they are the same
70299 * is to look at the range.
70300 */
70301 if (!reportedNodes.has(node.range.toString())) {
70302 const messageId = node.type === "PrivateIdentifier" ? "notMatchPrivate" : "notMatch";
70303 context.report({
70304 node,
70305 messageId,
70306 data: {
70307 name: node.name,
70308 pattern
70309 }
70310 });
70311 reportedNodes.add(node.range.toString());
70312 }
70313 }
70314
70315 return {
70316 Identifier(node) {
70317 const name = node.name,
70318 parent = node.parent,
70319 effectiveParent = parent.type === "MemberExpression" ? parent.parent : parent;
70320
70321 if (parent.type === "MemberExpression") {
70322 if (!checkProperties) {
70323 return;
70324 } // Always check object names
70325
70326
70327 if (parent.object.type === "Identifier" && parent.object.name === name) {
70328 if (isInvalid(name)) {
70329 report(node);
70330 } // Report AssignmentExpressions left side's assigned variable id
70331
70332 } else if (effectiveParent.type === "AssignmentExpression" && effectiveParent.left.type === "MemberExpression" && effectiveParent.left.property.name === node.name) {
70333 if (isInvalid(name)) {
70334 report(node);
70335 } // Report AssignmentExpressions only if they are the left side of the assignment
70336
70337 } else if (effectiveParent.type === "AssignmentExpression" && effectiveParent.right.type !== "MemberExpression") {
70338 if (isInvalid(name)) {
70339 report(node);
70340 }
70341 }
70342 /*
70343 * Properties have their own rules, and
70344 * AssignmentPattern nodes can be treated like Properties:
70345 * e.g.: const { no_camelcased = false } = bar;
70346 */
70347
70348 } else if (parent.type === "Property" || parent.type === "AssignmentPattern") {
70349 if (parent.parent && parent.parent.type === "ObjectPattern") {
70350 if (!ignoreDestructuring && parent.shorthand && parent.value.left && isInvalid(name)) {
70351 report(node);
70352 }
70353
70354 const assignmentKeyEqualsValue = parent.key.name === parent.value.name; // prevent checking righthand side of destructured object
70355
70356 if (!assignmentKeyEqualsValue && parent.key === node) {
70357 return;
70358 }
70359
70360 const valueIsInvalid = parent.value.name && isInvalid(name); // ignore destructuring if the option is set, unless a new identifier is created
70361
70362 if (valueIsInvalid && !(assignmentKeyEqualsValue && ignoreDestructuring)) {
70363 report(node);
70364 }
70365 } // never check properties or always ignore destructuring
70366
70367
70368 if (!checkProperties || ignoreDestructuring && isInsideObjectPattern(node)) {
70369 return;
70370 } // don't check right hand side of AssignmentExpression to prevent duplicate warnings
70371
70372
70373 if (parent.right !== node && shouldReport(effectiveParent, name)) {
70374 report(node);
70375 } // Check if it's an import specifier
70376
70377 } else if (IMPORT_TYPES.has(parent.type)) {
70378 // Report only if the local imported identifier is invalid
70379 if (parent.local && parent.local.name === node.name && isInvalid(name)) {
70380 report(node);
70381 }
70382 } else if (parent.type === "PropertyDefinition") {
70383 if (checkClassFields && isInvalid(name)) {
70384 report(node);
70385 } // Report anything that is invalid that isn't a CallExpression
70386
70387 } else if (shouldReport(effectiveParent, name)) {
70388 report(node);
70389 }
70390 },
70391
70392 "PrivateIdentifier"(node) {
70393 const isClassField = node.parent.type === "PropertyDefinition";
70394
70395 if (isClassField && !checkClassFields) {
70396 return;
70397 }
70398
70399 if (isInvalid(node.name)) {
70400 report(node);
70401 }
70402 }
70403
70404 };
70405 }
70406
70407 };
70408
70409 /***/ }),
70410 /* 603 */
70411 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
70412
70413 "use strict";
70414 /**
70415 * @fileoverview enforce the location of arrow function bodies
70416 * @author Sharmila Jesupaul
70417 */
70418
70419
70420 const {
70421 isCommentToken,
70422 isNotOpeningParenToken
70423 } = __webpack_require__(548); //------------------------------------------------------------------------------
70424 // Rule Definition
70425 //------------------------------------------------------------------------------
70426
70427
70428 module.exports = {
70429 meta: {
70430 type: "layout",
70431 docs: {
70432 description: "enforce the location of arrow function bodies",
70433 recommended: false,
70434 url: "https://eslint.org/docs/rules/implicit-arrow-linebreak"
70435 },
70436 fixable: "whitespace",
70437 schema: [{
70438 enum: ["beside", "below"]
70439 }],
70440 messages: {
70441 expected: "Expected a linebreak before this expression.",
70442 unexpected: "Expected no linebreak before this expression."
70443 }
70444 },
70445
70446 create(context) {
70447 const sourceCode = context.getSourceCode();
70448 const option = context.options[0] || "beside";
70449 /**
70450 * Validates the location of an arrow function body
70451 * @param {ASTNode} node The arrow function body
70452 * @returns {void}
70453 */
70454
70455 function validateExpression(node) {
70456 if (node.body.type === "BlockStatement") {
70457 return;
70458 }
70459
70460 const arrowToken = sourceCode.getTokenBefore(node.body, isNotOpeningParenToken);
70461 const firstTokenOfBody = sourceCode.getTokenAfter(arrowToken);
70462
70463 if (arrowToken.loc.end.line === firstTokenOfBody.loc.start.line && option === "below") {
70464 context.report({
70465 node: firstTokenOfBody,
70466 messageId: "expected",
70467 fix: fixer => fixer.insertTextBefore(firstTokenOfBody, "\n")
70468 });
70469 } else if (arrowToken.loc.end.line !== firstTokenOfBody.loc.start.line && option === "beside") {
70470 context.report({
70471 node: firstTokenOfBody,
70472 messageId: "unexpected",
70473
70474 fix(fixer) {
70475 if (sourceCode.getFirstTokenBetween(arrowToken, firstTokenOfBody, {
70476 includeComments: true,
70477 filter: isCommentToken
70478 })) {
70479 return null;
70480 }
70481
70482 return fixer.replaceTextRange([arrowToken.range[1], firstTokenOfBody.range[0]], " ");
70483 }
70484
70485 });
70486 }
70487 } //----------------------------------------------------------------------
70488 // Public
70489 //----------------------------------------------------------------------
70490
70491
70492 return {
70493 ArrowFunctionExpression: node => validateExpression(node)
70494 };
70495 }
70496
70497 };
70498
70499 /***/ }),
70500 /* 604 */
70501 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
70502
70503 "use strict";
70504 /**
70505 * @fileoverview This rule sets a specific indentation style and width for your code
70506 *
70507 * @author Teddy Katz
70508 * @author Vitaly Puzrin
70509 * @author Gyandeep Singh
70510 */
70511 //------------------------------------------------------------------------------
70512 // Requirements
70513 //------------------------------------------------------------------------------
70514
70515 const createTree = __webpack_require__(605);
70516
70517 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
70518 // Rule Definition
70519 //------------------------------------------------------------------------------
70520
70521
70522 const KNOWN_NODES = new Set(["AssignmentExpression", "AssignmentPattern", "ArrayExpression", "ArrayPattern", "ArrowFunctionExpression", "AwaitExpression", "BlockStatement", "BinaryExpression", "BreakStatement", "CallExpression", "CatchClause", "ChainExpression", "ClassBody", "ClassDeclaration", "ClassExpression", "ConditionalExpression", "ContinueStatement", "DoWhileStatement", "DebuggerStatement", "EmptyStatement", "ExperimentalRestProperty", "ExperimentalSpreadProperty", "ExpressionStatement", "ForStatement", "ForInStatement", "ForOfStatement", "FunctionDeclaration", "FunctionExpression", "Identifier", "IfStatement", "Literal", "LabeledStatement", "LogicalExpression", "MemberExpression", "MetaProperty", "MethodDefinition", "NewExpression", "ObjectExpression", "ObjectPattern", "PrivateIdentifier", "Program", "Property", "PropertyDefinition", "RestElement", "ReturnStatement", "SequenceExpression", "SpreadElement", "StaticBlock", "Super", "SwitchCase", "SwitchStatement", "TaggedTemplateExpression", "TemplateElement", "TemplateLiteral", "ThisExpression", "ThrowStatement", "TryStatement", "UnaryExpression", "UpdateExpression", "VariableDeclaration", "VariableDeclarator", "WhileStatement", "WithStatement", "YieldExpression", "JSXFragment", "JSXOpeningFragment", "JSXClosingFragment", "JSXIdentifier", "JSXNamespacedName", "JSXMemberExpression", "JSXEmptyExpression", "JSXExpressionContainer", "JSXElement", "JSXClosingElement", "JSXOpeningElement", "JSXAttribute", "JSXSpreadAttribute", "JSXText", "ExportDefaultDeclaration", "ExportNamedDeclaration", "ExportAllDeclaration", "ExportSpecifier", "ImportDeclaration", "ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier", "ImportExpression"]);
70523 /*
70524 * General rule strategy:
70525 * 1. An OffsetStorage instance stores a map of desired offsets, where each token has a specified offset from another
70526 * specified token or to the first column.
70527 * 2. As the AST is traversed, modify the desired offsets of tokens accordingly. For example, when entering a
70528 * BlockStatement, offset all of the tokens in the BlockStatement by 1 indent level from the opening curly
70529 * brace of the BlockStatement.
70530 * 3. After traversing the AST, calculate the expected indentation levels of every token according to the
70531 * OffsetStorage container.
70532 * 4. For each line, compare the expected indentation of the first token to the actual indentation in the file,
70533 * and report the token if the two values are not equal.
70534 */
70535
70536 /**
70537 * A mutable balanced binary search tree that stores (key, value) pairs. The keys are numeric, and must be unique.
70538 * This is intended to be a generic wrapper around a balanced binary search tree library, so that the underlying implementation
70539 * can easily be swapped out.
70540 */
70541
70542 class BinarySearchTree {
70543 /**
70544 * Creates an empty tree
70545 */
70546 constructor() {
70547 this._rbTree = createTree();
70548 }
70549 /**
70550 * Inserts an entry into the tree.
70551 * @param {number} key The entry's key
70552 * @param {any} value The entry's value
70553 * @returns {void}
70554 */
70555
70556
70557 insert(key, value) {
70558 const iterator = this._rbTree.find(key);
70559
70560 if (iterator.valid) {
70561 this._rbTree = iterator.update(value);
70562 } else {
70563 this._rbTree = this._rbTree.insert(key, value);
70564 }
70565 }
70566 /**
70567 * Finds the entry with the largest key less than or equal to the provided key
70568 * @param {number} key The provided key
70569 * @returns {{key: number, value: *}|null} The found entry, or null if no such entry exists.
70570 */
70571
70572
70573 findLe(key) {
70574 const iterator = this._rbTree.le(key);
70575
70576 return iterator && {
70577 key: iterator.key,
70578 value: iterator.value
70579 };
70580 }
70581 /**
70582 * Deletes all of the keys in the interval [start, end)
70583 * @param {number} start The start of the range
70584 * @param {number} end The end of the range
70585 * @returns {void}
70586 */
70587
70588
70589 deleteRange(start, end) {
70590 // Exit without traversing the tree if the range has zero size.
70591 if (start === end) {
70592 return;
70593 }
70594
70595 const iterator = this._rbTree.ge(start);
70596
70597 while (iterator.valid && iterator.key < end) {
70598 this._rbTree = this._rbTree.remove(iterator.key);
70599 iterator.next();
70600 }
70601 }
70602
70603 }
70604 /**
70605 * A helper class to get token-based info related to indentation
70606 */
70607
70608
70609 class TokenInfo {
70610 /**
70611 * @param {SourceCode} sourceCode A SourceCode object
70612 */
70613 constructor(sourceCode) {
70614 this.sourceCode = sourceCode;
70615 this.firstTokensByLineNumber = sourceCode.tokensAndComments.reduce((map, token) => {
70616 if (!map.has(token.loc.start.line)) {
70617 map.set(token.loc.start.line, token);
70618 }
70619
70620 if (!map.has(token.loc.end.line) && sourceCode.text.slice(token.range[1] - token.loc.end.column, token.range[1]).trim()) {
70621 map.set(token.loc.end.line, token);
70622 }
70623
70624 return map;
70625 }, new Map());
70626 }
70627 /**
70628 * Gets the first token on a given token's line
70629 * @param {Token|ASTNode} token a node or token
70630 * @returns {Token} The first token on the given line
70631 */
70632
70633
70634 getFirstTokenOfLine(token) {
70635 return this.firstTokensByLineNumber.get(token.loc.start.line);
70636 }
70637 /**
70638 * Determines whether a token is the first token in its line
70639 * @param {Token} token The token
70640 * @returns {boolean} `true` if the token is the first on its line
70641 */
70642
70643
70644 isFirstTokenOfLine(token) {
70645 return this.getFirstTokenOfLine(token) === token;
70646 }
70647 /**
70648 * Get the actual indent of a token
70649 * @param {Token} token Token to examine. This should be the first token on its line.
70650 * @returns {string} The indentation characters that precede the token
70651 */
70652
70653
70654 getTokenIndent(token) {
70655 return this.sourceCode.text.slice(token.range[0] - token.loc.start.column, token.range[0]);
70656 }
70657
70658 }
70659 /**
70660 * A class to store information on desired offsets of tokens from each other
70661 */
70662
70663
70664 class OffsetStorage {
70665 /**
70666 * @param {TokenInfo} tokenInfo a TokenInfo instance
70667 * @param {number} indentSize The desired size of each indentation level
70668 * @param {string} indentType The indentation character
70669 */
70670 constructor(tokenInfo, indentSize, indentType) {
70671 this._tokenInfo = tokenInfo;
70672 this._indentSize = indentSize;
70673 this._indentType = indentType;
70674 this._tree = new BinarySearchTree();
70675
70676 this._tree.insert(0, {
70677 offset: 0,
70678 from: null,
70679 force: false
70680 });
70681
70682 this._lockedFirstTokens = new WeakMap();
70683 this._desiredIndentCache = new WeakMap();
70684 this._ignoredTokens = new WeakSet();
70685 }
70686
70687 _getOffsetDescriptor(token) {
70688 return this._tree.findLe(token.range[0]).value;
70689 }
70690 /**
70691 * Sets the offset column of token B to match the offset column of token A.
70692 * - **WARNING**: This matches a *column*, even if baseToken is not the first token on its line. In
70693 * most cases, `setDesiredOffset` should be used instead.
70694 * @param {Token} baseToken The first token
70695 * @param {Token} offsetToken The second token, whose offset should be matched to the first token
70696 * @returns {void}
70697 */
70698
70699
70700 matchOffsetOf(baseToken, offsetToken) {
70701 /*
70702 * lockedFirstTokens is a map from a token whose indentation is controlled by the "first" option to
70703 * the token that it depends on. For example, with the `ArrayExpression: first` option, the first
70704 * token of each element in the array after the first will be mapped to the first token of the first
70705 * element. The desired indentation of each of these tokens is computed based on the desired indentation
70706 * of the "first" element, rather than through the normal offset mechanism.
70707 */
70708 this._lockedFirstTokens.set(offsetToken, baseToken);
70709 }
70710 /**
70711 * Sets the desired offset of a token.
70712 *
70713 * This uses a line-based offset collapsing behavior to handle tokens on the same line.
70714 * For example, consider the following two cases:
70715 *
70716 * (
70717 * [
70718 * bar
70719 * ]
70720 * )
70721 *
70722 * ([
70723 * bar
70724 * ])
70725 *
70726 * Based on the first case, it's clear that the `bar` token needs to have an offset of 1 indent level (4 spaces) from
70727 * the `[` token, and the `[` token has to have an offset of 1 indent level from the `(` token. Since the `(` token is
70728 * the first on its line (with an indent of 0 spaces), the `bar` token needs to be offset by 2 indent levels (8 spaces)
70729 * from the start of its line.
70730 *
70731 * However, in the second case `bar` should only be indented by 4 spaces. This is because the offset of 1 indent level
70732 * between the `(` and the `[` tokens gets "collapsed" because the two tokens are on the same line. As a result, the
70733 * `(` token is mapped to the `[` token with an offset of 0, and the rule correctly decides that `bar` should be indented
70734 * by 1 indent level from the start of the line.
70735 *
70736 * This is useful because rule listeners can usually just call `setDesiredOffset` for all the tokens in the node,
70737 * without needing to check which lines those tokens are on.
70738 *
70739 * Note that since collapsing only occurs when two tokens are on the same line, there are a few cases where non-intuitive
70740 * behavior can occur. For example, consider the following cases:
70741 *
70742 * foo(
70743 * ).
70744 * bar(
70745 * baz
70746 * )
70747 *
70748 * foo(
70749 * ).bar(
70750 * baz
70751 * )
70752 *
70753 * Based on the first example, it would seem that `bar` should be offset by 1 indent level from `foo`, and `baz`
70754 * should be offset by 1 indent level from `bar`. However, this is not correct, because it would result in `baz`
70755 * being indented by 2 indent levels in the second case (since `foo`, `bar`, and `baz` are all on separate lines, no
70756 * collapsing would occur).
70757 *
70758 * Instead, the correct way would be to offset `baz` by 1 level from `bar`, offset `bar` by 1 level from the `)`, and
70759 * offset the `)` by 0 levels from `foo`. This ensures that the offset between `bar` and the `)` are correctly collapsed
70760 * in the second case.
70761 * @param {Token} token The token
70762 * @param {Token} fromToken The token that `token` should be offset from
70763 * @param {number} offset The desired indent level
70764 * @returns {void}
70765 */
70766
70767
70768 setDesiredOffset(token, fromToken, offset) {
70769 return this.setDesiredOffsets(token.range, fromToken, offset);
70770 }
70771 /**
70772 * Sets the desired offset of all tokens in a range
70773 * It's common for node listeners in this file to need to apply the same offset to a large, contiguous range of tokens.
70774 * Moreover, the offset of any given token is usually updated multiple times (roughly once for each node that contains
70775 * it). This means that the offset of each token is updated O(AST depth) times.
70776 * It would not be performant to store and update the offsets for each token independently, because the rule would end
70777 * up having a time complexity of O(number of tokens * AST depth), which is quite slow for large files.
70778 *
70779 * Instead, the offset tree is represented as a collection of contiguous offset ranges in a file. For example, the following
70780 * list could represent the state of the offset tree at a given point:
70781 *
70782 * - Tokens starting in the interval [0, 15) are aligned with the beginning of the file
70783 * - Tokens starting in the interval [15, 30) are offset by 1 indent level from the `bar` token
70784 * - Tokens starting in the interval [30, 43) are offset by 1 indent level from the `foo` token
70785 * - Tokens starting in the interval [43, 820) are offset by 2 indent levels from the `bar` token
70786 * - Tokens starting in the interval [820, ∞) are offset by 1 indent level from the `baz` token
70787 *
70788 * The `setDesiredOffsets` methods inserts ranges like the ones above. The third line above would be inserted by using:
70789 * `setDesiredOffsets([30, 43], fooToken, 1);`
70790 * @param {[number, number]} range A [start, end] pair. All tokens with range[0] <= token.start < range[1] will have the offset applied.
70791 * @param {Token} fromToken The token that this is offset from
70792 * @param {number} offset The desired indent level
70793 * @param {boolean} force `true` if this offset should not use the normal collapsing behavior. This should almost always be false.
70794 * @returns {void}
70795 */
70796
70797
70798 setDesiredOffsets(range, fromToken, offset, force) {
70799 /*
70800 * Offset ranges are stored as a collection of nodes, where each node maps a numeric key to an offset
70801 * descriptor. The tree for the example above would have the following nodes:
70802 *
70803 * * key: 0, value: { offset: 0, from: null }
70804 * * key: 15, value: { offset: 1, from: barToken }
70805 * * key: 30, value: { offset: 1, from: fooToken }
70806 * * key: 43, value: { offset: 2, from: barToken }
70807 * * key: 820, value: { offset: 1, from: bazToken }
70808 *
70809 * To find the offset descriptor for any given token, one needs to find the node with the largest key
70810 * which is <= token.start. To make this operation fast, the nodes are stored in a balanced binary
70811 * search tree indexed by key.
70812 */
70813 const descriptorToInsert = {
70814 offset,
70815 from: fromToken,
70816 force
70817 };
70818
70819 const descriptorAfterRange = this._tree.findLe(range[1]).value;
70820
70821 const fromTokenIsInRange = fromToken && fromToken.range[0] >= range[0] && fromToken.range[1] <= range[1];
70822
70823 const fromTokenDescriptor = fromTokenIsInRange && this._getOffsetDescriptor(fromToken); // First, remove any existing nodes in the range from the tree.
70824
70825
70826 this._tree.deleteRange(range[0] + 1, range[1]); // Insert a new node into the tree for this range
70827
70828
70829 this._tree.insert(range[0], descriptorToInsert);
70830 /*
70831 * To avoid circular offset dependencies, keep the `fromToken` token mapped to whatever it was mapped to previously,
70832 * even if it's in the current range.
70833 */
70834
70835
70836 if (fromTokenIsInRange) {
70837 this._tree.insert(fromToken.range[0], fromTokenDescriptor);
70838
70839 this._tree.insert(fromToken.range[1], descriptorToInsert);
70840 }
70841 /*
70842 * To avoid modifying the offset of tokens after the range, insert another node to keep the offset of the following
70843 * tokens the same as it was before.
70844 */
70845
70846
70847 this._tree.insert(range[1], descriptorAfterRange);
70848 }
70849 /**
70850 * Gets the desired indent of a token
70851 * @param {Token} token The token
70852 * @returns {string} The desired indent of the token
70853 */
70854
70855
70856 getDesiredIndent(token) {
70857 if (!this._desiredIndentCache.has(token)) {
70858 if (this._ignoredTokens.has(token)) {
70859 /*
70860 * If the token is ignored, use the actual indent of the token as the desired indent.
70861 * This ensures that no errors are reported for this token.
70862 */
70863 this._desiredIndentCache.set(token, this._tokenInfo.getTokenIndent(token));
70864 } else if (this._lockedFirstTokens.has(token)) {
70865 const firstToken = this._lockedFirstTokens.get(token);
70866
70867 this._desiredIndentCache.set(token, // (indentation for the first element's line)
70868 this.getDesiredIndent(this._tokenInfo.getFirstTokenOfLine(firstToken)) + // (space between the start of the first element's line and the first element)
70869 this._indentType.repeat(firstToken.loc.start.column - this._tokenInfo.getFirstTokenOfLine(firstToken).loc.start.column));
70870 } else {
70871 const offsetInfo = this._getOffsetDescriptor(token);
70872
70873 const offset = offsetInfo.from && offsetInfo.from.loc.start.line === token.loc.start.line && !/^\s*?\n/u.test(token.value) && !offsetInfo.force ? 0 : offsetInfo.offset * this._indentSize;
70874
70875 this._desiredIndentCache.set(token, (offsetInfo.from ? this.getDesiredIndent(offsetInfo.from) : "") + this._indentType.repeat(offset));
70876 }
70877 }
70878
70879 return this._desiredIndentCache.get(token);
70880 }
70881 /**
70882 * Ignores a token, preventing it from being reported.
70883 * @param {Token} token The token
70884 * @returns {void}
70885 */
70886
70887
70888 ignoreToken(token) {
70889 if (this._tokenInfo.isFirstTokenOfLine(token)) {
70890 this._ignoredTokens.add(token);
70891 }
70892 }
70893 /**
70894 * Gets the first token that the given token's indentation is dependent on
70895 * @param {Token} token The token
70896 * @returns {Token} The token that the given token depends on, or `null` if the given token is at the top level
70897 */
70898
70899
70900 getFirstDependency(token) {
70901 return this._getOffsetDescriptor(token).from;
70902 }
70903
70904 }
70905
70906 const ELEMENT_LIST_SCHEMA = {
70907 oneOf: [{
70908 type: "integer",
70909 minimum: 0
70910 }, {
70911 enum: ["first", "off"]
70912 }]
70913 };
70914 module.exports = {
70915 meta: {
70916 type: "layout",
70917 docs: {
70918 description: "enforce consistent indentation",
70919 recommended: false,
70920 url: "https://eslint.org/docs/rules/indent"
70921 },
70922 fixable: "whitespace",
70923 schema: [{
70924 oneOf: [{
70925 enum: ["tab"]
70926 }, {
70927 type: "integer",
70928 minimum: 0
70929 }]
70930 }, {
70931 type: "object",
70932 properties: {
70933 SwitchCase: {
70934 type: "integer",
70935 minimum: 0,
70936 default: 0
70937 },
70938 VariableDeclarator: {
70939 oneOf: [ELEMENT_LIST_SCHEMA, {
70940 type: "object",
70941 properties: {
70942 var: ELEMENT_LIST_SCHEMA,
70943 let: ELEMENT_LIST_SCHEMA,
70944 const: ELEMENT_LIST_SCHEMA
70945 },
70946 additionalProperties: false
70947 }]
70948 },
70949 outerIIFEBody: {
70950 oneOf: [{
70951 type: "integer",
70952 minimum: 0
70953 }, {
70954 enum: ["off"]
70955 }]
70956 },
70957 MemberExpression: {
70958 oneOf: [{
70959 type: "integer",
70960 minimum: 0
70961 }, {
70962 enum: ["off"]
70963 }]
70964 },
70965 FunctionDeclaration: {
70966 type: "object",
70967 properties: {
70968 parameters: ELEMENT_LIST_SCHEMA,
70969 body: {
70970 type: "integer",
70971 minimum: 0
70972 }
70973 },
70974 additionalProperties: false
70975 },
70976 FunctionExpression: {
70977 type: "object",
70978 properties: {
70979 parameters: ELEMENT_LIST_SCHEMA,
70980 body: {
70981 type: "integer",
70982 minimum: 0
70983 }
70984 },
70985 additionalProperties: false
70986 },
70987 StaticBlock: {
70988 type: "object",
70989 properties: {
70990 body: {
70991 type: "integer",
70992 minimum: 0
70993 }
70994 },
70995 additionalProperties: false
70996 },
70997 CallExpression: {
70998 type: "object",
70999 properties: {
71000 arguments: ELEMENT_LIST_SCHEMA
71001 },
71002 additionalProperties: false
71003 },
71004 ArrayExpression: ELEMENT_LIST_SCHEMA,
71005 ObjectExpression: ELEMENT_LIST_SCHEMA,
71006 ImportDeclaration: ELEMENT_LIST_SCHEMA,
71007 flatTernaryExpressions: {
71008 type: "boolean",
71009 default: false
71010 },
71011 offsetTernaryExpressions: {
71012 type: "boolean",
71013 default: false
71014 },
71015 ignoredNodes: {
71016 type: "array",
71017 items: {
71018 type: "string",
71019 not: {
71020 pattern: ":exit$"
71021 }
71022 }
71023 },
71024 ignoreComments: {
71025 type: "boolean",
71026 default: false
71027 }
71028 },
71029 additionalProperties: false
71030 }],
71031 messages: {
71032 wrongIndentation: "Expected indentation of {{expected}} but found {{actual}}."
71033 }
71034 },
71035
71036 create(context) {
71037 const DEFAULT_VARIABLE_INDENT = 1;
71038 const DEFAULT_PARAMETER_INDENT = 1;
71039 const DEFAULT_FUNCTION_BODY_INDENT = 1;
71040 let indentType = "space";
71041 let indentSize = 4;
71042 const options = {
71043 SwitchCase: 0,
71044 VariableDeclarator: {
71045 var: DEFAULT_VARIABLE_INDENT,
71046 let: DEFAULT_VARIABLE_INDENT,
71047 const: DEFAULT_VARIABLE_INDENT
71048 },
71049 outerIIFEBody: 1,
71050 FunctionDeclaration: {
71051 parameters: DEFAULT_PARAMETER_INDENT,
71052 body: DEFAULT_FUNCTION_BODY_INDENT
71053 },
71054 FunctionExpression: {
71055 parameters: DEFAULT_PARAMETER_INDENT,
71056 body: DEFAULT_FUNCTION_BODY_INDENT
71057 },
71058 StaticBlock: {
71059 body: DEFAULT_FUNCTION_BODY_INDENT
71060 },
71061 CallExpression: {
71062 arguments: DEFAULT_PARAMETER_INDENT
71063 },
71064 MemberExpression: 1,
71065 ArrayExpression: 1,
71066 ObjectExpression: 1,
71067 ImportDeclaration: 1,
71068 flatTernaryExpressions: false,
71069 ignoredNodes: [],
71070 ignoreComments: false
71071 };
71072
71073 if (context.options.length) {
71074 if (context.options[0] === "tab") {
71075 indentSize = 1;
71076 indentType = "tab";
71077 } else {
71078 indentSize = context.options[0];
71079 indentType = "space";
71080 }
71081
71082 if (context.options[1]) {
71083 Object.assign(options, context.options[1]);
71084
71085 if (typeof options.VariableDeclarator === "number" || options.VariableDeclarator === "first") {
71086 options.VariableDeclarator = {
71087 var: options.VariableDeclarator,
71088 let: options.VariableDeclarator,
71089 const: options.VariableDeclarator
71090 };
71091 }
71092 }
71093 }
71094
71095 const sourceCode = context.getSourceCode();
71096 const tokenInfo = new TokenInfo(sourceCode);
71097 const offsets = new OffsetStorage(tokenInfo, indentSize, indentType === "space" ? " " : "\t");
71098 const parameterParens = new WeakSet();
71099 /**
71100 * Creates an error message for a line, given the expected/actual indentation.
71101 * @param {int} expectedAmount The expected amount of indentation characters for this line
71102 * @param {int} actualSpaces The actual number of indentation spaces that were found on this line
71103 * @param {int} actualTabs The actual number of indentation tabs that were found on this line
71104 * @returns {string} An error message for this line
71105 */
71106
71107 function createErrorMessageData(expectedAmount, actualSpaces, actualTabs) {
71108 const expectedStatement = "".concat(expectedAmount, " ").concat(indentType).concat(expectedAmount === 1 ? "" : "s"); // e.g. "2 tabs"
71109
71110 const foundSpacesWord = "space".concat(actualSpaces === 1 ? "" : "s"); // e.g. "space"
71111
71112 const foundTabsWord = "tab".concat(actualTabs === 1 ? "" : "s"); // e.g. "tabs"
71113
71114 let foundStatement;
71115
71116 if (actualSpaces > 0) {
71117 /*
71118 * Abbreviate the message if the expected indentation is also spaces.
71119 * e.g. 'Expected 4 spaces but found 2' rather than 'Expected 4 spaces but found 2 spaces'
71120 */
71121 foundStatement = indentType === "space" ? actualSpaces : "".concat(actualSpaces, " ").concat(foundSpacesWord);
71122 } else if (actualTabs > 0) {
71123 foundStatement = indentType === "tab" ? actualTabs : "".concat(actualTabs, " ").concat(foundTabsWord);
71124 } else {
71125 foundStatement = "0";
71126 }
71127
71128 return {
71129 expected: expectedStatement,
71130 actual: foundStatement
71131 };
71132 }
71133 /**
71134 * Reports a given indent violation
71135 * @param {Token} token Token violating the indent rule
71136 * @param {string} neededIndent Expected indentation string
71137 * @returns {void}
71138 */
71139
71140
71141 function report(token, neededIndent) {
71142 const actualIndent = Array.from(tokenInfo.getTokenIndent(token));
71143 const numSpaces = actualIndent.filter(char => char === " ").length;
71144 const numTabs = actualIndent.filter(char => char === "\t").length;
71145 context.report({
71146 node: token,
71147 messageId: "wrongIndentation",
71148 data: createErrorMessageData(neededIndent.length, numSpaces, numTabs),
71149 loc: {
71150 start: {
71151 line: token.loc.start.line,
71152 column: 0
71153 },
71154 end: {
71155 line: token.loc.start.line,
71156 column: token.loc.start.column
71157 }
71158 },
71159
71160 fix(fixer) {
71161 const range = [token.range[0] - token.loc.start.column, token.range[0]];
71162 const newText = neededIndent;
71163 return fixer.replaceTextRange(range, newText);
71164 }
71165
71166 });
71167 }
71168 /**
71169 * Checks if a token's indentation is correct
71170 * @param {Token} token Token to examine
71171 * @param {string} desiredIndent Desired indentation of the string
71172 * @returns {boolean} `true` if the token's indentation is correct
71173 */
71174
71175
71176 function validateTokenIndent(token, desiredIndent) {
71177 const indentation = tokenInfo.getTokenIndent(token);
71178 return indentation === desiredIndent || // To avoid conflicts with no-mixed-spaces-and-tabs, don't report mixed spaces and tabs.
71179 indentation.includes(" ") && indentation.includes("\t");
71180 }
71181 /**
71182 * Check to see if the node is a file level IIFE
71183 * @param {ASTNode} node The function node to check.
71184 * @returns {boolean} True if the node is the outer IIFE
71185 */
71186
71187
71188 function isOuterIIFE(node) {
71189 /*
71190 * Verify that the node is an IIFE
71191 */
71192 if (!node.parent || node.parent.type !== "CallExpression" || node.parent.callee !== node) {
71193 return false;
71194 }
71195 /*
71196 * Navigate legal ancestors to determine whether this IIFE is outer.
71197 * A "legal ancestor" is an expression or statement that causes the function to get executed immediately.
71198 * For example, `!(function(){})()` is an outer IIFE even though it is preceded by a ! operator.
71199 */
71200
71201
71202 let statement = node.parent && node.parent.parent;
71203
71204 while (statement.type === "UnaryExpression" && ["!", "~", "+", "-"].indexOf(statement.operator) > -1 || statement.type === "AssignmentExpression" || statement.type === "LogicalExpression" || statement.type === "SequenceExpression" || statement.type === "VariableDeclarator") {
71205 statement = statement.parent;
71206 }
71207
71208 return (statement.type === "ExpressionStatement" || statement.type === "VariableDeclaration") && statement.parent.type === "Program";
71209 }
71210 /**
71211 * Counts the number of linebreaks that follow the last non-whitespace character in a string
71212 * @param {string} string The string to check
71213 * @returns {number} The number of JavaScript linebreaks that follow the last non-whitespace character,
71214 * or the total number of linebreaks if the string is all whitespace.
71215 */
71216
71217
71218 function countTrailingLinebreaks(string) {
71219 const trailingWhitespace = string.match(/\s*$/u)[0];
71220 const linebreakMatches = trailingWhitespace.match(astUtils.createGlobalLinebreakMatcher());
71221 return linebreakMatches === null ? 0 : linebreakMatches.length;
71222 }
71223 /**
71224 * Check indentation for lists of elements (arrays, objects, function params)
71225 * @param {ASTNode[]} elements List of elements that should be offset
71226 * @param {Token} startToken The start token of the list that element should be aligned against, e.g. '['
71227 * @param {Token} endToken The end token of the list, e.g. ']'
71228 * @param {number|string} offset The amount that the elements should be offset
71229 * @returns {void}
71230 */
71231
71232
71233 function addElementListIndent(elements, startToken, endToken, offset) {
71234 /**
71235 * Gets the first token of a given element, including surrounding parentheses.
71236 * @param {ASTNode} element A node in the `elements` list
71237 * @returns {Token} The first token of this element
71238 */
71239 function getFirstToken(element) {
71240 let token = sourceCode.getTokenBefore(element);
71241
71242 while (astUtils.isOpeningParenToken(token) && token !== startToken) {
71243 token = sourceCode.getTokenBefore(token);
71244 }
71245
71246 return sourceCode.getTokenAfter(token);
71247 } // Run through all the tokens in the list, and offset them by one indent level (mainly for comments, other things will end up overridden)
71248
71249
71250 offsets.setDesiredOffsets([startToken.range[1], endToken.range[0]], startToken, typeof offset === "number" ? offset : 1);
71251 offsets.setDesiredOffset(endToken, startToken, 0); // If the preference is "first" but there is no first element (e.g. sparse arrays w/ empty first slot), fall back to 1 level.
71252
71253 if (offset === "first" && elements.length && !elements[0]) {
71254 return;
71255 }
71256
71257 elements.forEach((element, index) => {
71258 if (!element) {
71259 // Skip holes in arrays
71260 return;
71261 }
71262
71263 if (offset === "off") {
71264 // Ignore the first token of every element if the "off" option is used
71265 offsets.ignoreToken(getFirstToken(element));
71266 } // Offset the following elements correctly relative to the first element
71267
71268
71269 if (index === 0) {
71270 return;
71271 }
71272
71273 if (offset === "first" && tokenInfo.isFirstTokenOfLine(getFirstToken(element))) {
71274 offsets.matchOffsetOf(getFirstToken(elements[0]), getFirstToken(element));
71275 } else {
71276 const previousElement = elements[index - 1];
71277 const firstTokenOfPreviousElement = previousElement && getFirstToken(previousElement);
71278 const previousElementLastToken = previousElement && sourceCode.getLastToken(previousElement);
71279
71280 if (previousElement && previousElementLastToken.loc.end.line - countTrailingLinebreaks(previousElementLastToken.value) > startToken.loc.end.line) {
71281 offsets.setDesiredOffsets([previousElement.range[1], element.range[1]], firstTokenOfPreviousElement, 0);
71282 }
71283 }
71284 });
71285 }
71286 /**
71287 * Check and decide whether to check for indentation for blockless nodes
71288 * Scenarios are for or while statements without braces around them
71289 * @param {ASTNode} node node to examine
71290 * @returns {void}
71291 */
71292
71293
71294 function addBlocklessNodeIndent(node) {
71295 if (node.type !== "BlockStatement") {
71296 const lastParentToken = sourceCode.getTokenBefore(node, astUtils.isNotOpeningParenToken);
71297 let firstBodyToken = sourceCode.getFirstToken(node);
71298 let lastBodyToken = sourceCode.getLastToken(node);
71299
71300 while (astUtils.isOpeningParenToken(sourceCode.getTokenBefore(firstBodyToken)) && astUtils.isClosingParenToken(sourceCode.getTokenAfter(lastBodyToken))) {
71301 firstBodyToken = sourceCode.getTokenBefore(firstBodyToken);
71302 lastBodyToken = sourceCode.getTokenAfter(lastBodyToken);
71303 }
71304
71305 offsets.setDesiredOffsets([firstBodyToken.range[0], lastBodyToken.range[1]], lastParentToken, 1);
71306 /*
71307 * For blockless nodes with semicolon-first style, don't indent the semicolon.
71308 * e.g.
71309 * if (foo) bar()
71310 * ; [1, 2, 3].map(foo)
71311 */
71312
71313 const lastToken = sourceCode.getLastToken(node);
71314
71315 if (node.type !== "EmptyStatement" && astUtils.isSemicolonToken(lastToken)) {
71316 offsets.setDesiredOffset(lastToken, lastParentToken, 0);
71317 }
71318 }
71319 }
71320 /**
71321 * Checks the indentation for nodes that are like function calls (`CallExpression` and `NewExpression`)
71322 * @param {ASTNode} node A CallExpression or NewExpression node
71323 * @returns {void}
71324 */
71325
71326
71327 function addFunctionCallIndent(node) {
71328 let openingParen;
71329
71330 if (node.arguments.length) {
71331 openingParen = sourceCode.getFirstTokenBetween(node.callee, node.arguments[0], astUtils.isOpeningParenToken);
71332 } else {
71333 openingParen = sourceCode.getLastToken(node, 1);
71334 }
71335
71336 const closingParen = sourceCode.getLastToken(node);
71337 parameterParens.add(openingParen);
71338 parameterParens.add(closingParen);
71339 /*
71340 * If `?.` token exists, set desired offset for that.
71341 * This logic is copied from `MemberExpression`'s.
71342 */
71343
71344 if (node.optional) {
71345 const dotToken = sourceCode.getTokenAfter(node.callee, astUtils.isQuestionDotToken);
71346 const calleeParenCount = sourceCode.getTokensBetween(node.callee, dotToken, {
71347 filter: astUtils.isClosingParenToken
71348 }).length;
71349 const firstTokenOfCallee = calleeParenCount ? sourceCode.getTokenBefore(node.callee, {
71350 skip: calleeParenCount - 1
71351 }) : sourceCode.getFirstToken(node.callee);
71352 const lastTokenOfCallee = sourceCode.getTokenBefore(dotToken);
71353 const offsetBase = lastTokenOfCallee.loc.end.line === openingParen.loc.start.line ? lastTokenOfCallee : firstTokenOfCallee;
71354 offsets.setDesiredOffset(dotToken, offsetBase, 1);
71355 }
71356
71357 const offsetAfterToken = node.callee.type === "TaggedTemplateExpression" ? sourceCode.getFirstToken(node.callee.quasi) : openingParen;
71358 const offsetToken = sourceCode.getTokenBefore(offsetAfterToken);
71359 offsets.setDesiredOffset(openingParen, offsetToken, 0);
71360 addElementListIndent(node.arguments, openingParen, closingParen, options.CallExpression.arguments);
71361 }
71362 /**
71363 * Checks the indentation of parenthesized values, given a list of tokens in a program
71364 * @param {Token[]} tokens A list of tokens
71365 * @returns {void}
71366 */
71367
71368
71369 function addParensIndent(tokens) {
71370 const parenStack = [];
71371 const parenPairs = [];
71372 tokens.forEach(nextToken => {
71373 // Accumulate a list of parenthesis pairs
71374 if (astUtils.isOpeningParenToken(nextToken)) {
71375 parenStack.push(nextToken);
71376 } else if (astUtils.isClosingParenToken(nextToken)) {
71377 parenPairs.unshift({
71378 left: parenStack.pop(),
71379 right: nextToken
71380 });
71381 }
71382 });
71383 parenPairs.forEach(pair => {
71384 const leftParen = pair.left;
71385 const rightParen = pair.right; // We only want to handle parens around expressions, so exclude parentheses that are in function parameters and function call arguments.
71386
71387 if (!parameterParens.has(leftParen) && !parameterParens.has(rightParen)) {
71388 const parenthesizedTokens = new Set(sourceCode.getTokensBetween(leftParen, rightParen));
71389 parenthesizedTokens.forEach(token => {
71390 if (!parenthesizedTokens.has(offsets.getFirstDependency(token))) {
71391 offsets.setDesiredOffset(token, leftParen, 1);
71392 }
71393 });
71394 }
71395
71396 offsets.setDesiredOffset(rightParen, leftParen, 0);
71397 });
71398 }
71399 /**
71400 * Ignore all tokens within an unknown node whose offset do not depend
71401 * on another token's offset within the unknown node
71402 * @param {ASTNode} node Unknown Node
71403 * @returns {void}
71404 */
71405
71406
71407 function ignoreNode(node) {
71408 const unknownNodeTokens = new Set(sourceCode.getTokens(node, {
71409 includeComments: true
71410 }));
71411 unknownNodeTokens.forEach(token => {
71412 if (!unknownNodeTokens.has(offsets.getFirstDependency(token))) {
71413 const firstTokenOfLine = tokenInfo.getFirstTokenOfLine(token);
71414
71415 if (token === firstTokenOfLine) {
71416 offsets.ignoreToken(token);
71417 } else {
71418 offsets.setDesiredOffset(token, firstTokenOfLine, 0);
71419 }
71420 }
71421 });
71422 }
71423 /**
71424 * Check whether the given token is on the first line of a statement.
71425 * @param {Token} token The token to check.
71426 * @param {ASTNode} leafNode The expression node that the token belongs directly.
71427 * @returns {boolean} `true` if the token is on the first line of a statement.
71428 */
71429
71430
71431 function isOnFirstLineOfStatement(token, leafNode) {
71432 let node = leafNode;
71433
71434 while (node.parent && !node.parent.type.endsWith("Statement") && !node.parent.type.endsWith("Declaration")) {
71435 node = node.parent;
71436 }
71437
71438 node = node.parent;
71439 return !node || node.loc.start.line === token.loc.start.line;
71440 }
71441 /**
71442 * Check whether there are any blank (whitespace-only) lines between
71443 * two tokens on separate lines.
71444 * @param {Token} firstToken The first token.
71445 * @param {Token} secondToken The second token.
71446 * @returns {boolean} `true` if the tokens are on separate lines and
71447 * there exists a blank line between them, `false` otherwise.
71448 */
71449
71450
71451 function hasBlankLinesBetween(firstToken, secondToken) {
71452 const firstTokenLine = firstToken.loc.end.line;
71453 const secondTokenLine = secondToken.loc.start.line;
71454
71455 if (firstTokenLine === secondTokenLine || firstTokenLine === secondTokenLine - 1) {
71456 return false;
71457 }
71458
71459 for (let line = firstTokenLine + 1; line < secondTokenLine; ++line) {
71460 if (!tokenInfo.firstTokensByLineNumber.has(line)) {
71461 return true;
71462 }
71463 }
71464
71465 return false;
71466 }
71467
71468 const ignoredNodeFirstTokens = new Set();
71469 const baseOffsetListeners = {
71470 "ArrayExpression, ArrayPattern"(node) {
71471 const openingBracket = sourceCode.getFirstToken(node);
71472 const closingBracket = sourceCode.getTokenAfter([...node.elements].reverse().find(_ => _) || openingBracket, astUtils.isClosingBracketToken);
71473 addElementListIndent(node.elements, openingBracket, closingBracket, options.ArrayExpression);
71474 },
71475
71476 "ObjectExpression, ObjectPattern"(node) {
71477 const openingCurly = sourceCode.getFirstToken(node);
71478 const closingCurly = sourceCode.getTokenAfter(node.properties.length ? node.properties[node.properties.length - 1] : openingCurly, astUtils.isClosingBraceToken);
71479 addElementListIndent(node.properties, openingCurly, closingCurly, options.ObjectExpression);
71480 },
71481
71482 ArrowFunctionExpression(node) {
71483 const maybeOpeningParen = sourceCode.getFirstToken(node, {
71484 skip: node.async ? 1 : 0
71485 });
71486
71487 if (astUtils.isOpeningParenToken(maybeOpeningParen)) {
71488 const openingParen = maybeOpeningParen;
71489 const closingParen = sourceCode.getTokenBefore(node.body, astUtils.isClosingParenToken);
71490 parameterParens.add(openingParen);
71491 parameterParens.add(closingParen);
71492 addElementListIndent(node.params, openingParen, closingParen, options.FunctionExpression.parameters);
71493 }
71494
71495 addBlocklessNodeIndent(node.body);
71496 },
71497
71498 AssignmentExpression(node) {
71499 const operator = sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
71500 offsets.setDesiredOffsets([operator.range[0], node.range[1]], sourceCode.getLastToken(node.left), 1);
71501 offsets.ignoreToken(operator);
71502 offsets.ignoreToken(sourceCode.getTokenAfter(operator));
71503 },
71504
71505 "BinaryExpression, LogicalExpression"(node) {
71506 const operator = sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
71507 /*
71508 * For backwards compatibility, don't check BinaryExpression indents, e.g.
71509 * var foo = bar &&
71510 * baz;
71511 */
71512
71513 const tokenAfterOperator = sourceCode.getTokenAfter(operator);
71514 offsets.ignoreToken(operator);
71515 offsets.ignoreToken(tokenAfterOperator);
71516 offsets.setDesiredOffset(tokenAfterOperator, operator, 0);
71517 },
71518
71519 "BlockStatement, ClassBody"(node) {
71520 let blockIndentLevel;
71521
71522 if (node.parent && isOuterIIFE(node.parent)) {
71523 blockIndentLevel = options.outerIIFEBody;
71524 } else if (node.parent && (node.parent.type === "FunctionExpression" || node.parent.type === "ArrowFunctionExpression")) {
71525 blockIndentLevel = options.FunctionExpression.body;
71526 } else if (node.parent && node.parent.type === "FunctionDeclaration") {
71527 blockIndentLevel = options.FunctionDeclaration.body;
71528 } else {
71529 blockIndentLevel = 1;
71530 }
71531 /*
71532 * For blocks that aren't lone statements, ensure that the opening curly brace
71533 * is aligned with the parent.
71534 */
71535
71536
71537 if (!astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) {
71538 offsets.setDesiredOffset(sourceCode.getFirstToken(node), sourceCode.getFirstToken(node.parent), 0);
71539 }
71540
71541 addElementListIndent(node.body, sourceCode.getFirstToken(node), sourceCode.getLastToken(node), blockIndentLevel);
71542 },
71543
71544 CallExpression: addFunctionCallIndent,
71545
71546 "ClassDeclaration[superClass], ClassExpression[superClass]"(node) {
71547 const classToken = sourceCode.getFirstToken(node);
71548 const extendsToken = sourceCode.getTokenBefore(node.superClass, astUtils.isNotOpeningParenToken);
71549 offsets.setDesiredOffsets([extendsToken.range[0], node.body.range[0]], classToken, 1);
71550 },
71551
71552 ConditionalExpression(node) {
71553 const firstToken = sourceCode.getFirstToken(node); // `flatTernaryExpressions` option is for the following style:
71554 // var a =
71555 // foo > 0 ? bar :
71556 // foo < 0 ? baz :
71557 // /*else*/ qiz ;
71558
71559 if (!options.flatTernaryExpressions || !astUtils.isTokenOnSameLine(node.test, node.consequent) || isOnFirstLineOfStatement(firstToken, node)) {
71560 const questionMarkToken = sourceCode.getFirstTokenBetween(node.test, node.consequent, token => token.type === "Punctuator" && token.value === "?");
71561 const colonToken = sourceCode.getFirstTokenBetween(node.consequent, node.alternate, token => token.type === "Punctuator" && token.value === ":");
71562 const firstConsequentToken = sourceCode.getTokenAfter(questionMarkToken);
71563 const lastConsequentToken = sourceCode.getTokenBefore(colonToken);
71564 const firstAlternateToken = sourceCode.getTokenAfter(colonToken);
71565 offsets.setDesiredOffset(questionMarkToken, firstToken, 1);
71566 offsets.setDesiredOffset(colonToken, firstToken, 1);
71567 offsets.setDesiredOffset(firstConsequentToken, firstToken, firstConsequentToken.type === "Punctuator" && options.offsetTernaryExpressions ? 2 : 1);
71568 /*
71569 * The alternate and the consequent should usually have the same indentation.
71570 * If they share part of a line, align the alternate against the first token of the consequent.
71571 * This allows the alternate to be indented correctly in cases like this:
71572 * foo ? (
71573 * bar
71574 * ) : ( // this '(' is aligned with the '(' above, so it's considered to be aligned with `foo`
71575 * baz // as a result, `baz` is offset by 1 rather than 2
71576 * )
71577 */
71578
71579 if (lastConsequentToken.loc.end.line === firstAlternateToken.loc.start.line) {
71580 offsets.setDesiredOffset(firstAlternateToken, firstConsequentToken, 0);
71581 } else {
71582 /**
71583 * If the alternate and consequent do not share part of a line, offset the alternate from the first
71584 * token of the conditional expression. For example:
71585 * foo ? bar
71586 * : baz
71587 *
71588 * If `baz` were aligned with `bar` rather than being offset by 1 from `foo`, `baz` would end up
71589 * having no expected indentation.
71590 */
71591 offsets.setDesiredOffset(firstAlternateToken, firstToken, firstAlternateToken.type === "Punctuator" && options.offsetTernaryExpressions ? 2 : 1);
71592 }
71593 }
71594 },
71595
71596 "DoWhileStatement, WhileStatement, ForInStatement, ForOfStatement": node => addBlocklessNodeIndent(node.body),
71597
71598 ExportNamedDeclaration(node) {
71599 if (node.declaration === null) {
71600 const closingCurly = sourceCode.getLastToken(node, astUtils.isClosingBraceToken); // Indent the specifiers in `export {foo, bar, baz}`
71601
71602 addElementListIndent(node.specifiers, sourceCode.getFirstToken(node, {
71603 skip: 1
71604 }), closingCurly, 1);
71605
71606 if (node.source) {
71607 // Indent everything after and including the `from` token in `export {foo, bar, baz} from 'qux'`
71608 offsets.setDesiredOffsets([closingCurly.range[1], node.range[1]], sourceCode.getFirstToken(node), 1);
71609 }
71610 }
71611 },
71612
71613 ForStatement(node) {
71614 const forOpeningParen = sourceCode.getFirstToken(node, 1);
71615
71616 if (node.init) {
71617 offsets.setDesiredOffsets(node.init.range, forOpeningParen, 1);
71618 }
71619
71620 if (node.test) {
71621 offsets.setDesiredOffsets(node.test.range, forOpeningParen, 1);
71622 }
71623
71624 if (node.update) {
71625 offsets.setDesiredOffsets(node.update.range, forOpeningParen, 1);
71626 }
71627
71628 addBlocklessNodeIndent(node.body);
71629 },
71630
71631 "FunctionDeclaration, FunctionExpression"(node) {
71632 const closingParen = sourceCode.getTokenBefore(node.body);
71633 const openingParen = sourceCode.getTokenBefore(node.params.length ? node.params[0] : closingParen);
71634 parameterParens.add(openingParen);
71635 parameterParens.add(closingParen);
71636 addElementListIndent(node.params, openingParen, closingParen, options[node.type].parameters);
71637 },
71638
71639 IfStatement(node) {
71640 addBlocklessNodeIndent(node.consequent);
71641
71642 if (node.alternate && node.alternate.type !== "IfStatement") {
71643 addBlocklessNodeIndent(node.alternate);
71644 }
71645 },
71646
71647 ImportDeclaration(node) {
71648 if (node.specifiers.some(specifier => specifier.type === "ImportSpecifier")) {
71649 const openingCurly = sourceCode.getFirstToken(node, astUtils.isOpeningBraceToken);
71650 const closingCurly = sourceCode.getLastToken(node, astUtils.isClosingBraceToken);
71651 addElementListIndent(node.specifiers.filter(specifier => specifier.type === "ImportSpecifier"), openingCurly, closingCurly, options.ImportDeclaration);
71652 }
71653
71654 const fromToken = sourceCode.getLastToken(node, token => token.type === "Identifier" && token.value === "from");
71655 const sourceToken = sourceCode.getLastToken(node, token => token.type === "String");
71656 const semiToken = sourceCode.getLastToken(node, token => token.type === "Punctuator" && token.value === ";");
71657
71658 if (fromToken) {
71659 const end = semiToken && semiToken.range[1] === sourceToken.range[1] ? node.range[1] : sourceToken.range[1];
71660 offsets.setDesiredOffsets([fromToken.range[0], end], sourceCode.getFirstToken(node), 1);
71661 }
71662 },
71663
71664 ImportExpression(node) {
71665 const openingParen = sourceCode.getFirstToken(node, 1);
71666 const closingParen = sourceCode.getLastToken(node);
71667 parameterParens.add(openingParen);
71668 parameterParens.add(closingParen);
71669 offsets.setDesiredOffset(openingParen, sourceCode.getTokenBefore(openingParen), 0);
71670 addElementListIndent([node.source], openingParen, closingParen, options.CallExpression.arguments);
71671 },
71672
71673 "MemberExpression, JSXMemberExpression, MetaProperty"(node) {
71674 const object = node.type === "MetaProperty" ? node.meta : node.object;
71675 const firstNonObjectToken = sourceCode.getFirstTokenBetween(object, node.property, astUtils.isNotClosingParenToken);
71676 const secondNonObjectToken = sourceCode.getTokenAfter(firstNonObjectToken);
71677 const objectParenCount = sourceCode.getTokensBetween(object, node.property, {
71678 filter: astUtils.isClosingParenToken
71679 }).length;
71680 const firstObjectToken = objectParenCount ? sourceCode.getTokenBefore(object, {
71681 skip: objectParenCount - 1
71682 }) : sourceCode.getFirstToken(object);
71683 const lastObjectToken = sourceCode.getTokenBefore(firstNonObjectToken);
71684 const firstPropertyToken = node.computed ? firstNonObjectToken : secondNonObjectToken;
71685
71686 if (node.computed) {
71687 // For computed MemberExpressions, match the closing bracket with the opening bracket.
71688 offsets.setDesiredOffset(sourceCode.getLastToken(node), firstNonObjectToken, 0);
71689 offsets.setDesiredOffsets(node.property.range, firstNonObjectToken, 1);
71690 }
71691 /*
71692 * If the object ends on the same line that the property starts, match against the last token
71693 * of the object, to ensure that the MemberExpression is not indented.
71694 *
71695 * Otherwise, match against the first token of the object, e.g.
71696 * foo
71697 * .bar
71698 * .baz // <-- offset by 1 from `foo`
71699 */
71700
71701
71702 const offsetBase = lastObjectToken.loc.end.line === firstPropertyToken.loc.start.line ? lastObjectToken : firstObjectToken;
71703
71704 if (typeof options.MemberExpression === "number") {
71705 // Match the dot (for non-computed properties) or the opening bracket (for computed properties) against the object.
71706 offsets.setDesiredOffset(firstNonObjectToken, offsetBase, options.MemberExpression);
71707 /*
71708 * For computed MemberExpressions, match the first token of the property against the opening bracket.
71709 * Otherwise, match the first token of the property against the object.
71710 */
71711
71712 offsets.setDesiredOffset(secondNonObjectToken, node.computed ? firstNonObjectToken : offsetBase, options.MemberExpression);
71713 } else {
71714 // If the MemberExpression option is off, ignore the dot and the first token of the property.
71715 offsets.ignoreToken(firstNonObjectToken);
71716 offsets.ignoreToken(secondNonObjectToken); // To ignore the property indentation, ensure that the property tokens depend on the ignored tokens.
71717
71718 offsets.setDesiredOffset(firstNonObjectToken, offsetBase, 0);
71719 offsets.setDesiredOffset(secondNonObjectToken, firstNonObjectToken, 0);
71720 }
71721 },
71722
71723 NewExpression(node) {
71724 // Only indent the arguments if the NewExpression has parens (e.g. `new Foo(bar)` or `new Foo()`, but not `new Foo`
71725 if (node.arguments.length > 0 || astUtils.isClosingParenToken(sourceCode.getLastToken(node)) && astUtils.isOpeningParenToken(sourceCode.getLastToken(node, 1))) {
71726 addFunctionCallIndent(node);
71727 }
71728 },
71729
71730 Property(node) {
71731 if (!node.shorthand && !node.method && node.kind === "init") {
71732 const colon = sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isColonToken);
71733 offsets.ignoreToken(sourceCode.getTokenAfter(colon));
71734 }
71735 },
71736
71737 PropertyDefinition(node) {
71738 const firstToken = sourceCode.getFirstToken(node);
71739 const maybeSemicolonToken = sourceCode.getLastToken(node);
71740 let keyLastToken = null; // Indent key.
71741
71742 if (node.computed) {
71743 const bracketTokenL = sourceCode.getTokenBefore(node.key, astUtils.isOpeningBracketToken);
71744 const bracketTokenR = keyLastToken = sourceCode.getTokenAfter(node.key, astUtils.isClosingBracketToken);
71745 const keyRange = [bracketTokenL.range[1], bracketTokenR.range[0]];
71746
71747 if (bracketTokenL !== firstToken) {
71748 offsets.setDesiredOffset(bracketTokenL, firstToken, 0);
71749 }
71750
71751 offsets.setDesiredOffsets(keyRange, bracketTokenL, 1);
71752 offsets.setDesiredOffset(bracketTokenR, bracketTokenL, 0);
71753 } else {
71754 const idToken = keyLastToken = sourceCode.getFirstToken(node.key);
71755
71756 if (idToken !== firstToken) {
71757 offsets.setDesiredOffset(idToken, firstToken, 1);
71758 }
71759 } // Indent initializer.
71760
71761
71762 if (node.value) {
71763 const eqToken = sourceCode.getTokenBefore(node.value, astUtils.isEqToken);
71764 const valueToken = sourceCode.getTokenAfter(eqToken);
71765 offsets.setDesiredOffset(eqToken, keyLastToken, 1);
71766 offsets.setDesiredOffset(valueToken, eqToken, 1);
71767
71768 if (astUtils.isSemicolonToken(maybeSemicolonToken)) {
71769 offsets.setDesiredOffset(maybeSemicolonToken, eqToken, 1);
71770 }
71771 } else if (astUtils.isSemicolonToken(maybeSemicolonToken)) {
71772 offsets.setDesiredOffset(maybeSemicolonToken, keyLastToken, 1);
71773 }
71774 },
71775
71776 StaticBlock(node) {
71777 const openingCurly = sourceCode.getFirstToken(node, {
71778 skip: 1
71779 }); // skip the `static` token
71780
71781 const closingCurly = sourceCode.getLastToken(node);
71782 addElementListIndent(node.body, openingCurly, closingCurly, options.StaticBlock.body);
71783 },
71784
71785 SwitchStatement(node) {
71786 const openingCurly = sourceCode.getTokenAfter(node.discriminant, astUtils.isOpeningBraceToken);
71787 const closingCurly = sourceCode.getLastToken(node);
71788 offsets.setDesiredOffsets([openingCurly.range[1], closingCurly.range[0]], openingCurly, options.SwitchCase);
71789
71790 if (node.cases.length) {
71791 sourceCode.getTokensBetween(node.cases[node.cases.length - 1], closingCurly, {
71792 includeComments: true,
71793 filter: astUtils.isCommentToken
71794 }).forEach(token => offsets.ignoreToken(token));
71795 }
71796 },
71797
71798 SwitchCase(node) {
71799 if (!(node.consequent.length === 1 && node.consequent[0].type === "BlockStatement")) {
71800 const caseKeyword = sourceCode.getFirstToken(node);
71801 const tokenAfterCurrentCase = sourceCode.getTokenAfter(node);
71802 offsets.setDesiredOffsets([caseKeyword.range[1], tokenAfterCurrentCase.range[0]], caseKeyword, 1);
71803 }
71804 },
71805
71806 TemplateLiteral(node) {
71807 node.expressions.forEach((expression, index) => {
71808 const previousQuasi = node.quasis[index];
71809 const nextQuasi = node.quasis[index + 1];
71810 const tokenToAlignFrom = previousQuasi.loc.start.line === previousQuasi.loc.end.line ? sourceCode.getFirstToken(previousQuasi) : null;
71811 offsets.setDesiredOffsets([previousQuasi.range[1], nextQuasi.range[0]], tokenToAlignFrom, 1);
71812 offsets.setDesiredOffset(sourceCode.getFirstToken(nextQuasi), tokenToAlignFrom, 0);
71813 });
71814 },
71815
71816 VariableDeclaration(node) {
71817 let variableIndent = Object.prototype.hasOwnProperty.call(options.VariableDeclarator, node.kind) ? options.VariableDeclarator[node.kind] : DEFAULT_VARIABLE_INDENT;
71818 const firstToken = sourceCode.getFirstToken(node),
71819 lastToken = sourceCode.getLastToken(node);
71820
71821 if (options.VariableDeclarator[node.kind] === "first") {
71822 if (node.declarations.length > 1) {
71823 addElementListIndent(node.declarations, firstToken, lastToken, "first");
71824 return;
71825 }
71826
71827 variableIndent = DEFAULT_VARIABLE_INDENT;
71828 }
71829
71830 if (node.declarations[node.declarations.length - 1].loc.start.line > node.loc.start.line) {
71831 /*
71832 * VariableDeclarator indentation is a bit different from other forms of indentation, in that the
71833 * indentation of an opening bracket sometimes won't match that of a closing bracket. For example,
71834 * the following indentations are correct:
71835 *
71836 * var foo = {
71837 * ok: true
71838 * };
71839 *
71840 * var foo = {
71841 * ok: true,
71842 * },
71843 * bar = 1;
71844 *
71845 * Account for when exiting the AST (after indentations have already been set for the nodes in
71846 * the declaration) by manually increasing the indentation level of the tokens in this declarator
71847 * on the same line as the start of the declaration, provided that there are declarators that
71848 * follow this one.
71849 */
71850 offsets.setDesiredOffsets(node.range, firstToken, variableIndent, true);
71851 } else {
71852 offsets.setDesiredOffsets(node.range, firstToken, variableIndent);
71853 }
71854
71855 if (astUtils.isSemicolonToken(lastToken)) {
71856 offsets.ignoreToken(lastToken);
71857 }
71858 },
71859
71860 VariableDeclarator(node) {
71861 if (node.init) {
71862 const equalOperator = sourceCode.getTokenBefore(node.init, astUtils.isNotOpeningParenToken);
71863 const tokenAfterOperator = sourceCode.getTokenAfter(equalOperator);
71864 offsets.ignoreToken(equalOperator);
71865 offsets.ignoreToken(tokenAfterOperator);
71866 offsets.setDesiredOffsets([tokenAfterOperator.range[0], node.range[1]], equalOperator, 1);
71867 offsets.setDesiredOffset(equalOperator, sourceCode.getLastToken(node.id), 0);
71868 }
71869 },
71870
71871 "JSXAttribute[value]"(node) {
71872 const equalsToken = sourceCode.getFirstTokenBetween(node.name, node.value, token => token.type === "Punctuator" && token.value === "=");
71873 offsets.setDesiredOffsets([equalsToken.range[0], node.value.range[1]], sourceCode.getFirstToken(node.name), 1);
71874 },
71875
71876 JSXElement(node) {
71877 if (node.closingElement) {
71878 addElementListIndent(node.children, sourceCode.getFirstToken(node.openingElement), sourceCode.getFirstToken(node.closingElement), 1);
71879 }
71880 },
71881
71882 JSXOpeningElement(node) {
71883 const firstToken = sourceCode.getFirstToken(node);
71884 let closingToken;
71885
71886 if (node.selfClosing) {
71887 closingToken = sourceCode.getLastToken(node, {
71888 skip: 1
71889 });
71890 offsets.setDesiredOffset(sourceCode.getLastToken(node), closingToken, 0);
71891 } else {
71892 closingToken = sourceCode.getLastToken(node);
71893 }
71894
71895 offsets.setDesiredOffsets(node.name.range, sourceCode.getFirstToken(node));
71896 addElementListIndent(node.attributes, firstToken, closingToken, 1);
71897 },
71898
71899 JSXClosingElement(node) {
71900 const firstToken = sourceCode.getFirstToken(node);
71901 offsets.setDesiredOffsets(node.name.range, firstToken, 1);
71902 },
71903
71904 JSXFragment(node) {
71905 const firstOpeningToken = sourceCode.getFirstToken(node.openingFragment);
71906 const firstClosingToken = sourceCode.getFirstToken(node.closingFragment);
71907 addElementListIndent(node.children, firstOpeningToken, firstClosingToken, 1);
71908 },
71909
71910 JSXOpeningFragment(node) {
71911 const firstToken = sourceCode.getFirstToken(node);
71912 const closingToken = sourceCode.getLastToken(node);
71913 offsets.setDesiredOffsets(node.range, firstToken, 1);
71914 offsets.matchOffsetOf(firstToken, closingToken);
71915 },
71916
71917 JSXClosingFragment(node) {
71918 const firstToken = sourceCode.getFirstToken(node);
71919 const slashToken = sourceCode.getLastToken(node, {
71920 skip: 1
71921 });
71922 const closingToken = sourceCode.getLastToken(node);
71923 const tokenToMatch = astUtils.isTokenOnSameLine(slashToken, closingToken) ? slashToken : closingToken;
71924 offsets.setDesiredOffsets(node.range, firstToken, 1);
71925 offsets.matchOffsetOf(firstToken, tokenToMatch);
71926 },
71927
71928 JSXExpressionContainer(node) {
71929 const openingCurly = sourceCode.getFirstToken(node);
71930 const closingCurly = sourceCode.getLastToken(node);
71931 offsets.setDesiredOffsets([openingCurly.range[1], closingCurly.range[0]], openingCurly, 1);
71932 },
71933
71934 JSXSpreadAttribute(node) {
71935 const openingCurly = sourceCode.getFirstToken(node);
71936 const closingCurly = sourceCode.getLastToken(node);
71937 offsets.setDesiredOffsets([openingCurly.range[1], closingCurly.range[0]], openingCurly, 1);
71938 },
71939
71940 "*"(node) {
71941 const firstToken = sourceCode.getFirstToken(node); // Ensure that the children of every node are indented at least as much as the first token.
71942
71943 if (firstToken && !ignoredNodeFirstTokens.has(firstToken)) {
71944 offsets.setDesiredOffsets(node.range, firstToken, 0);
71945 }
71946 }
71947
71948 };
71949 const listenerCallQueue = [];
71950 /*
71951 * To ignore the indentation of a node:
71952 * 1. Don't call the node's listener when entering it (if it has a listener)
71953 * 2. Don't set any offsets against the first token of the node.
71954 * 3. Call `ignoreNode` on the node sometime after exiting it and before validating offsets.
71955 */
71956
71957 const offsetListeners = {};
71958
71959 for (const [selector, listener] of Object.entries(baseOffsetListeners)) {
71960 /*
71961 * Offset listener calls are deferred until traversal is finished, and are called as
71962 * part of the final `Program:exit` listener. This is necessary because a node might
71963 * be matched by multiple selectors.
71964 *
71965 * Example: Suppose there is an offset listener for `Identifier`, and the user has
71966 * specified in configuration that `MemberExpression > Identifier` should be ignored.
71967 * Due to selector specificity rules, the `Identifier` listener will get called first. However,
71968 * if a given Identifier node is supposed to be ignored, then the `Identifier` offset listener
71969 * should not have been called at all. Without doing extra selector matching, we don't know
71970 * whether the Identifier matches the `MemberExpression > Identifier` selector until the
71971 * `MemberExpression > Identifier` listener is called.
71972 *
71973 * To avoid this, the `Identifier` listener isn't called until traversal finishes and all
71974 * ignored nodes are known.
71975 */
71976 offsetListeners[selector] = node => listenerCallQueue.push({
71977 listener,
71978 node
71979 });
71980 } // For each ignored node selector, set up a listener to collect it into the `ignoredNodes` set.
71981
71982
71983 const ignoredNodes = new Set();
71984 /**
71985 * Ignores a node
71986 * @param {ASTNode} node The node to ignore
71987 * @returns {void}
71988 */
71989
71990 function addToIgnoredNodes(node) {
71991 ignoredNodes.add(node);
71992 ignoredNodeFirstTokens.add(sourceCode.getFirstToken(node));
71993 }
71994
71995 const ignoredNodeListeners = options.ignoredNodes.reduce((listeners, ignoredSelector) => Object.assign(listeners, {
71996 [ignoredSelector]: addToIgnoredNodes
71997 }), {});
71998 /*
71999 * Join the listeners, and add a listener to verify that all tokens actually have the correct indentation
72000 * at the end.
72001 *
72002 * Using Object.assign will cause some offset listeners to be overwritten if the same selector also appears
72003 * in `ignoredNodeListeners`. This isn't a problem because all of the matching nodes will be ignored,
72004 * so those listeners wouldn't be called anyway.
72005 */
72006
72007 return Object.assign(offsetListeners, ignoredNodeListeners, {
72008 "*:exit"(node) {
72009 // If a node's type is nonstandard, we can't tell how its children should be offset, so ignore it.
72010 if (!KNOWN_NODES.has(node.type)) {
72011 addToIgnoredNodes(node);
72012 }
72013 },
72014
72015 "Program:exit"() {
72016 // If ignoreComments option is enabled, ignore all comment tokens.
72017 if (options.ignoreComments) {
72018 sourceCode.getAllComments().forEach(comment => offsets.ignoreToken(comment));
72019 } // Invoke the queued offset listeners for the nodes that aren't ignored.
72020
72021
72022 listenerCallQueue.filter(nodeInfo => !ignoredNodes.has(nodeInfo.node)).forEach(nodeInfo => nodeInfo.listener(nodeInfo.node)); // Update the offsets for ignored nodes to prevent their child tokens from being reported.
72023
72024 ignoredNodes.forEach(ignoreNode);
72025 addParensIndent(sourceCode.ast.tokens);
72026 /*
72027 * Create a Map from (tokenOrComment) => (precedingToken).
72028 * This is necessary because sourceCode.getTokenBefore does not handle a comment as an argument correctly.
72029 */
72030
72031 const precedingTokens = sourceCode.ast.comments.reduce((commentMap, comment) => {
72032 const tokenOrCommentBefore = sourceCode.getTokenBefore(comment, {
72033 includeComments: true
72034 });
72035 return commentMap.set(comment, commentMap.has(tokenOrCommentBefore) ? commentMap.get(tokenOrCommentBefore) : tokenOrCommentBefore);
72036 }, new WeakMap());
72037 sourceCode.lines.forEach((line, lineIndex) => {
72038 const lineNumber = lineIndex + 1;
72039
72040 if (!tokenInfo.firstTokensByLineNumber.has(lineNumber)) {
72041 // Don't check indentation on blank lines
72042 return;
72043 }
72044
72045 const firstTokenOfLine = tokenInfo.firstTokensByLineNumber.get(lineNumber);
72046
72047 if (firstTokenOfLine.loc.start.line !== lineNumber) {
72048 // Don't check the indentation of multi-line tokens (e.g. template literals or block comments) twice.
72049 return;
72050 }
72051
72052 if (astUtils.isCommentToken(firstTokenOfLine)) {
72053 const tokenBefore = precedingTokens.get(firstTokenOfLine);
72054 const tokenAfter = tokenBefore ? sourceCode.getTokenAfter(tokenBefore) : sourceCode.ast.tokens[0];
72055 const mayAlignWithBefore = tokenBefore && !hasBlankLinesBetween(tokenBefore, firstTokenOfLine);
72056 const mayAlignWithAfter = tokenAfter && !hasBlankLinesBetween(firstTokenOfLine, tokenAfter);
72057 /*
72058 * If a comment precedes a line that begins with a semicolon token, align to that token, i.e.
72059 *
72060 * let foo
72061 * // comment
72062 * ;(async () => {})()
72063 */
72064
72065 if (tokenAfter && astUtils.isSemicolonToken(tokenAfter) && !astUtils.isTokenOnSameLine(firstTokenOfLine, tokenAfter)) {
72066 offsets.setDesiredOffset(firstTokenOfLine, tokenAfter, 0);
72067 } // If a comment matches the expected indentation of the token immediately before or after, don't report it.
72068
72069
72070 if (mayAlignWithBefore && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenBefore)) || mayAlignWithAfter && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenAfter))) {
72071 return;
72072 }
72073 } // If the token matches the expected indentation, don't report it.
72074
72075
72076 if (validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(firstTokenOfLine))) {
72077 return;
72078 } // Otherwise, report the token/comment.
72079
72080
72081 report(firstTokenOfLine, offsets.getDesiredIndent(firstTokenOfLine));
72082 });
72083 }
72084
72085 });
72086 }
72087
72088 };
72089
72090 /***/ }),
72091 /* 605 */
72092 /***/ ((module) => {
72093
72094 "use strict";
72095
72096
72097 module.exports = createRBTree;
72098 var RED = 0;
72099 var BLACK = 1;
72100
72101 function RBNode(color, key, value, left, right, count) {
72102 this._color = color;
72103 this.key = key;
72104 this.value = value;
72105 this.left = left;
72106 this.right = right;
72107 this._count = count;
72108 }
72109
72110 function cloneNode(node) {
72111 return new RBNode(node._color, node.key, node.value, node.left, node.right, node._count);
72112 }
72113
72114 function repaint(color, node) {
72115 return new RBNode(color, node.key, node.value, node.left, node.right, node._count);
72116 }
72117
72118 function recount(node) {
72119 node._count = 1 + (node.left ? node.left._count : 0) + (node.right ? node.right._count : 0);
72120 }
72121
72122 function RedBlackTree(compare, root) {
72123 this._compare = compare;
72124 this.root = root;
72125 }
72126
72127 var proto = RedBlackTree.prototype;
72128 Object.defineProperty(proto, "keys", {
72129 get: function () {
72130 var result = [];
72131 this.forEach(function (k, v) {
72132 result.push(k);
72133 });
72134 return result;
72135 }
72136 });
72137 Object.defineProperty(proto, "values", {
72138 get: function () {
72139 var result = [];
72140 this.forEach(function (k, v) {
72141 result.push(v);
72142 });
72143 return result;
72144 }
72145 }); //Returns the number of nodes in the tree
72146
72147 Object.defineProperty(proto, "length", {
72148 get: function () {
72149 if (this.root) {
72150 return this.root._count;
72151 }
72152
72153 return 0;
72154 }
72155 }); //Insert a new item into the tree
72156
72157 proto.insert = function (key, value) {
72158 var cmp = this._compare; //Find point to insert new node at
72159
72160 var n = this.root;
72161 var n_stack = [];
72162 var d_stack = [];
72163
72164 while (n) {
72165 var d = cmp(key, n.key);
72166 n_stack.push(n);
72167 d_stack.push(d);
72168
72169 if (d <= 0) {
72170 n = n.left;
72171 } else {
72172 n = n.right;
72173 }
72174 } //Rebuild path to leaf node
72175
72176
72177 n_stack.push(new RBNode(RED, key, value, null, null, 1));
72178
72179 for (var s = n_stack.length - 2; s >= 0; --s) {
72180 var n = n_stack[s];
72181
72182 if (d_stack[s] <= 0) {
72183 n_stack[s] = new RBNode(n._color, n.key, n.value, n_stack[s + 1], n.right, n._count + 1);
72184 } else {
72185 n_stack[s] = new RBNode(n._color, n.key, n.value, n.left, n_stack[s + 1], n._count + 1);
72186 }
72187 } //Rebalance tree using rotations
72188 //console.log("start insert", key, d_stack)
72189
72190
72191 for (var s = n_stack.length - 1; s > 1; --s) {
72192 var p = n_stack[s - 1];
72193 var n = n_stack[s];
72194
72195 if (p._color === BLACK || n._color === BLACK) {
72196 break;
72197 }
72198
72199 var pp = n_stack[s - 2];
72200
72201 if (pp.left === p) {
72202 if (p.left === n) {
72203 var y = pp.right;
72204
72205 if (y && y._color === RED) {
72206 //console.log("LLr")
72207 p._color = BLACK;
72208 pp.right = repaint(BLACK, y);
72209 pp._color = RED;
72210 s -= 1;
72211 } else {
72212 //console.log("LLb")
72213 pp._color = RED;
72214 pp.left = p.right;
72215 p._color = BLACK;
72216 p.right = pp;
72217 n_stack[s - 2] = p;
72218 n_stack[s - 1] = n;
72219 recount(pp);
72220 recount(p);
72221
72222 if (s >= 3) {
72223 var ppp = n_stack[s - 3];
72224
72225 if (ppp.left === pp) {
72226 ppp.left = p;
72227 } else {
72228 ppp.right = p;
72229 }
72230 }
72231
72232 break;
72233 }
72234 } else {
72235 var y = pp.right;
72236
72237 if (y && y._color === RED) {
72238 //console.log("LRr")
72239 p._color = BLACK;
72240 pp.right = repaint(BLACK, y);
72241 pp._color = RED;
72242 s -= 1;
72243 } else {
72244 //console.log("LRb")
72245 p.right = n.left;
72246 pp._color = RED;
72247 pp.left = n.right;
72248 n._color = BLACK;
72249 n.left = p;
72250 n.right = pp;
72251 n_stack[s - 2] = n;
72252 n_stack[s - 1] = p;
72253 recount(pp);
72254 recount(p);
72255 recount(n);
72256
72257 if (s >= 3) {
72258 var ppp = n_stack[s - 3];
72259
72260 if (ppp.left === pp) {
72261 ppp.left = n;
72262 } else {
72263 ppp.right = n;
72264 }
72265 }
72266
72267 break;
72268 }
72269 }
72270 } else {
72271 if (p.right === n) {
72272 var y = pp.left;
72273
72274 if (y && y._color === RED) {
72275 //console.log("RRr", y.key)
72276 p._color = BLACK;
72277 pp.left = repaint(BLACK, y);
72278 pp._color = RED;
72279 s -= 1;
72280 } else {
72281 //console.log("RRb")
72282 pp._color = RED;
72283 pp.right = p.left;
72284 p._color = BLACK;
72285 p.left = pp;
72286 n_stack[s - 2] = p;
72287 n_stack[s - 1] = n;
72288 recount(pp);
72289 recount(p);
72290
72291 if (s >= 3) {
72292 var ppp = n_stack[s - 3];
72293
72294 if (ppp.right === pp) {
72295 ppp.right = p;
72296 } else {
72297 ppp.left = p;
72298 }
72299 }
72300
72301 break;
72302 }
72303 } else {
72304 var y = pp.left;
72305
72306 if (y && y._color === RED) {
72307 //console.log("RLr")
72308 p._color = BLACK;
72309 pp.left = repaint(BLACK, y);
72310 pp._color = RED;
72311 s -= 1;
72312 } else {
72313 //console.log("RLb")
72314 p.left = n.right;
72315 pp._color = RED;
72316 pp.right = n.left;
72317 n._color = BLACK;
72318 n.right = p;
72319 n.left = pp;
72320 n_stack[s - 2] = n;
72321 n_stack[s - 1] = p;
72322 recount(pp);
72323 recount(p);
72324 recount(n);
72325
72326 if (s >= 3) {
72327 var ppp = n_stack[s - 3];
72328
72329 if (ppp.right === pp) {
72330 ppp.right = n;
72331 } else {
72332 ppp.left = n;
72333 }
72334 }
72335
72336 break;
72337 }
72338 }
72339 }
72340 } //Return new tree
72341
72342
72343 n_stack[0]._color = BLACK;
72344 return new RedBlackTree(cmp, n_stack[0]);
72345 }; //Visit all nodes inorder
72346
72347
72348 function doVisitFull(visit, node) {
72349 if (node.left) {
72350 var v = doVisitFull(visit, node.left);
72351
72352 if (v) {
72353 return v;
72354 }
72355 }
72356
72357 var v = visit(node.key, node.value);
72358
72359 if (v) {
72360 return v;
72361 }
72362
72363 if (node.right) {
72364 return doVisitFull(visit, node.right);
72365 }
72366 } //Visit half nodes in order
72367
72368
72369 function doVisitHalf(lo, compare, visit, node) {
72370 var l = compare(lo, node.key);
72371
72372 if (l <= 0) {
72373 if (node.left) {
72374 var v = doVisitHalf(lo, compare, visit, node.left);
72375
72376 if (v) {
72377 return v;
72378 }
72379 }
72380
72381 var v = visit(node.key, node.value);
72382
72383 if (v) {
72384 return v;
72385 }
72386 }
72387
72388 if (node.right) {
72389 return doVisitHalf(lo, compare, visit, node.right);
72390 }
72391 } //Visit all nodes within a range
72392
72393
72394 function doVisit(lo, hi, compare, visit, node) {
72395 var l = compare(lo, node.key);
72396 var h = compare(hi, node.key);
72397 var v;
72398
72399 if (l <= 0) {
72400 if (node.left) {
72401 v = doVisit(lo, hi, compare, visit, node.left);
72402
72403 if (v) {
72404 return v;
72405 }
72406 }
72407
72408 if (h > 0) {
72409 v = visit(node.key, node.value);
72410
72411 if (v) {
72412 return v;
72413 }
72414 }
72415 }
72416
72417 if (h > 0 && node.right) {
72418 return doVisit(lo, hi, compare, visit, node.right);
72419 }
72420 }
72421
72422 proto.forEach = function rbTreeForEach(visit, lo, hi) {
72423 if (!this.root) {
72424 return;
72425 }
72426
72427 switch (arguments.length) {
72428 case 1:
72429 return doVisitFull(visit, this.root);
72430 break;
72431
72432 case 2:
72433 return doVisitHalf(lo, this._compare, visit, this.root);
72434 break;
72435
72436 case 3:
72437 if (this._compare(lo, hi) >= 0) {
72438 return;
72439 }
72440
72441 return doVisit(lo, hi, this._compare, visit, this.root);
72442 break;
72443 }
72444 }; //First item in list
72445
72446
72447 Object.defineProperty(proto, "begin", {
72448 get: function () {
72449 var stack = [];
72450 var n = this.root;
72451
72452 while (n) {
72453 stack.push(n);
72454 n = n.left;
72455 }
72456
72457 return new RedBlackTreeIterator(this, stack);
72458 }
72459 }); //Last item in list
72460
72461 Object.defineProperty(proto, "end", {
72462 get: function () {
72463 var stack = [];
72464 var n = this.root;
72465
72466 while (n) {
72467 stack.push(n);
72468 n = n.right;
72469 }
72470
72471 return new RedBlackTreeIterator(this, stack);
72472 }
72473 }); //Find the ith item in the tree
72474
72475 proto.at = function (idx) {
72476 if (idx < 0) {
72477 return new RedBlackTreeIterator(this, []);
72478 }
72479
72480 var n = this.root;
72481 var stack = [];
72482
72483 while (true) {
72484 stack.push(n);
72485
72486 if (n.left) {
72487 if (idx < n.left._count) {
72488 n = n.left;
72489 continue;
72490 }
72491
72492 idx -= n.left._count;
72493 }
72494
72495 if (!idx) {
72496 return new RedBlackTreeIterator(this, stack);
72497 }
72498
72499 idx -= 1;
72500
72501 if (n.right) {
72502 if (idx >= n.right._count) {
72503 break;
72504 }
72505
72506 n = n.right;
72507 } else {
72508 break;
72509 }
72510 }
72511
72512 return new RedBlackTreeIterator(this, []);
72513 };
72514
72515 proto.ge = function (key) {
72516 var cmp = this._compare;
72517 var n = this.root;
72518 var stack = [];
72519 var last_ptr = 0;
72520
72521 while (n) {
72522 var d = cmp(key, n.key);
72523 stack.push(n);
72524
72525 if (d <= 0) {
72526 last_ptr = stack.length;
72527 }
72528
72529 if (d <= 0) {
72530 n = n.left;
72531 } else {
72532 n = n.right;
72533 }
72534 }
72535
72536 stack.length = last_ptr;
72537 return new RedBlackTreeIterator(this, stack);
72538 };
72539
72540 proto.gt = function (key) {
72541 var cmp = this._compare;
72542 var n = this.root;
72543 var stack = [];
72544 var last_ptr = 0;
72545
72546 while (n) {
72547 var d = cmp(key, n.key);
72548 stack.push(n);
72549
72550 if (d < 0) {
72551 last_ptr = stack.length;
72552 }
72553
72554 if (d < 0) {
72555 n = n.left;
72556 } else {
72557 n = n.right;
72558 }
72559 }
72560
72561 stack.length = last_ptr;
72562 return new RedBlackTreeIterator(this, stack);
72563 };
72564
72565 proto.lt = function (key) {
72566 var cmp = this._compare;
72567 var n = this.root;
72568 var stack = [];
72569 var last_ptr = 0;
72570
72571 while (n) {
72572 var d = cmp(key, n.key);
72573 stack.push(n);
72574
72575 if (d > 0) {
72576 last_ptr = stack.length;
72577 }
72578
72579 if (d <= 0) {
72580 n = n.left;
72581 } else {
72582 n = n.right;
72583 }
72584 }
72585
72586 stack.length = last_ptr;
72587 return new RedBlackTreeIterator(this, stack);
72588 };
72589
72590 proto.le = function (key) {
72591 var cmp = this._compare;
72592 var n = this.root;
72593 var stack = [];
72594 var last_ptr = 0;
72595
72596 while (n) {
72597 var d = cmp(key, n.key);
72598 stack.push(n);
72599
72600 if (d >= 0) {
72601 last_ptr = stack.length;
72602 }
72603
72604 if (d < 0) {
72605 n = n.left;
72606 } else {
72607 n = n.right;
72608 }
72609 }
72610
72611 stack.length = last_ptr;
72612 return new RedBlackTreeIterator(this, stack);
72613 }; //Finds the item with key if it exists
72614
72615
72616 proto.find = function (key) {
72617 var cmp = this._compare;
72618 var n = this.root;
72619 var stack = [];
72620
72621 while (n) {
72622 var d = cmp(key, n.key);
72623 stack.push(n);
72624
72625 if (d === 0) {
72626 return new RedBlackTreeIterator(this, stack);
72627 }
72628
72629 if (d <= 0) {
72630 n = n.left;
72631 } else {
72632 n = n.right;
72633 }
72634 }
72635
72636 return new RedBlackTreeIterator(this, []);
72637 }; //Removes item with key from tree
72638
72639
72640 proto.remove = function (key) {
72641 var iter = this.find(key);
72642
72643 if (iter) {
72644 return iter.remove();
72645 }
72646
72647 return this;
72648 }; //Returns the item at `key`
72649
72650
72651 proto.get = function (key) {
72652 var cmp = this._compare;
72653 var n = this.root;
72654
72655 while (n) {
72656 var d = cmp(key, n.key);
72657
72658 if (d === 0) {
72659 return n.value;
72660 }
72661
72662 if (d <= 0) {
72663 n = n.left;
72664 } else {
72665 n = n.right;
72666 }
72667 }
72668
72669 return;
72670 }; //Iterator for red black tree
72671
72672
72673 function RedBlackTreeIterator(tree, stack) {
72674 this.tree = tree;
72675 this._stack = stack;
72676 }
72677
72678 var iproto = RedBlackTreeIterator.prototype; //Test if iterator is valid
72679
72680 Object.defineProperty(iproto, "valid", {
72681 get: function () {
72682 return this._stack.length > 0;
72683 }
72684 }); //Node of the iterator
72685
72686 Object.defineProperty(iproto, "node", {
72687 get: function () {
72688 if (this._stack.length > 0) {
72689 return this._stack[this._stack.length - 1];
72690 }
72691
72692 return null;
72693 },
72694 enumerable: true
72695 }); //Makes a copy of an iterator
72696
72697 iproto.clone = function () {
72698 return new RedBlackTreeIterator(this.tree, this._stack.slice());
72699 }; //Swaps two nodes
72700
72701
72702 function swapNode(n, v) {
72703 n.key = v.key;
72704 n.value = v.value;
72705 n.left = v.left;
72706 n.right = v.right;
72707 n._color = v._color;
72708 n._count = v._count;
72709 } //Fix up a double black node in a tree
72710
72711
72712 function fixDoubleBlack(stack) {
72713 var n, p, s, z;
72714
72715 for (var i = stack.length - 1; i >= 0; --i) {
72716 n = stack[i];
72717
72718 if (i === 0) {
72719 n._color = BLACK;
72720 return;
72721 } //console.log("visit node:", n.key, i, stack[i].key, stack[i-1].key)
72722
72723
72724 p = stack[i - 1];
72725
72726 if (p.left === n) {
72727 //console.log("left child")
72728 s = p.right;
72729
72730 if (s.right && s.right._color === RED) {
72731 //console.log("case 1: right sibling child red")
72732 s = p.right = cloneNode(s);
72733 z = s.right = cloneNode(s.right);
72734 p.right = s.left;
72735 s.left = p;
72736 s.right = z;
72737 s._color = p._color;
72738 n._color = BLACK;
72739 p._color = BLACK;
72740 z._color = BLACK;
72741 recount(p);
72742 recount(s);
72743
72744 if (i > 1) {
72745 var pp = stack[i - 2];
72746
72747 if (pp.left === p) {
72748 pp.left = s;
72749 } else {
72750 pp.right = s;
72751 }
72752 }
72753
72754 stack[i - 1] = s;
72755 return;
72756 } else if (s.left && s.left._color === RED) {
72757 //console.log("case 1: left sibling child red")
72758 s = p.right = cloneNode(s);
72759 z = s.left = cloneNode(s.left);
72760 p.right = z.left;
72761 s.left = z.right;
72762 z.left = p;
72763 z.right = s;
72764 z._color = p._color;
72765 p._color = BLACK;
72766 s._color = BLACK;
72767 n._color = BLACK;
72768 recount(p);
72769 recount(s);
72770 recount(z);
72771
72772 if (i > 1) {
72773 var pp = stack[i - 2];
72774
72775 if (pp.left === p) {
72776 pp.left = z;
72777 } else {
72778 pp.right = z;
72779 }
72780 }
72781
72782 stack[i - 1] = z;
72783 return;
72784 }
72785
72786 if (s._color === BLACK) {
72787 if (p._color === RED) {
72788 //console.log("case 2: black sibling, red parent", p.right.value)
72789 p._color = BLACK;
72790 p.right = repaint(RED, s);
72791 return;
72792 } else {
72793 //console.log("case 2: black sibling, black parent", p.right.value)
72794 p.right = repaint(RED, s);
72795 continue;
72796 }
72797 } else {
72798 //console.log("case 3: red sibling")
72799 s = cloneNode(s);
72800 p.right = s.left;
72801 s.left = p;
72802 s._color = p._color;
72803 p._color = RED;
72804 recount(p);
72805 recount(s);
72806
72807 if (i > 1) {
72808 var pp = stack[i - 2];
72809
72810 if (pp.left === p) {
72811 pp.left = s;
72812 } else {
72813 pp.right = s;
72814 }
72815 }
72816
72817 stack[i - 1] = s;
72818 stack[i] = p;
72819
72820 if (i + 1 < stack.length) {
72821 stack[i + 1] = n;
72822 } else {
72823 stack.push(n);
72824 }
72825
72826 i = i + 2;
72827 }
72828 } else {
72829 //console.log("right child")
72830 s = p.left;
72831
72832 if (s.left && s.left._color === RED) {
72833 //console.log("case 1: left sibling child red", p.value, p._color)
72834 s = p.left = cloneNode(s);
72835 z = s.left = cloneNode(s.left);
72836 p.left = s.right;
72837 s.right = p;
72838 s.left = z;
72839 s._color = p._color;
72840 n._color = BLACK;
72841 p._color = BLACK;
72842 z._color = BLACK;
72843 recount(p);
72844 recount(s);
72845
72846 if (i > 1) {
72847 var pp = stack[i - 2];
72848
72849 if (pp.right === p) {
72850 pp.right = s;
72851 } else {
72852 pp.left = s;
72853 }
72854 }
72855
72856 stack[i - 1] = s;
72857 return;
72858 } else if (s.right && s.right._color === RED) {
72859 //console.log("case 1: right sibling child red")
72860 s = p.left = cloneNode(s);
72861 z = s.right = cloneNode(s.right);
72862 p.left = z.right;
72863 s.right = z.left;
72864 z.right = p;
72865 z.left = s;
72866 z._color = p._color;
72867 p._color = BLACK;
72868 s._color = BLACK;
72869 n._color = BLACK;
72870 recount(p);
72871 recount(s);
72872 recount(z);
72873
72874 if (i > 1) {
72875 var pp = stack[i - 2];
72876
72877 if (pp.right === p) {
72878 pp.right = z;
72879 } else {
72880 pp.left = z;
72881 }
72882 }
72883
72884 stack[i - 1] = z;
72885 return;
72886 }
72887
72888 if (s._color === BLACK) {
72889 if (p._color === RED) {
72890 //console.log("case 2: black sibling, red parent")
72891 p._color = BLACK;
72892 p.left = repaint(RED, s);
72893 return;
72894 } else {
72895 //console.log("case 2: black sibling, black parent")
72896 p.left = repaint(RED, s);
72897 continue;
72898 }
72899 } else {
72900 //console.log("case 3: red sibling")
72901 s = cloneNode(s);
72902 p.left = s.right;
72903 s.right = p;
72904 s._color = p._color;
72905 p._color = RED;
72906 recount(p);
72907 recount(s);
72908
72909 if (i > 1) {
72910 var pp = stack[i - 2];
72911
72912 if (pp.right === p) {
72913 pp.right = s;
72914 } else {
72915 pp.left = s;
72916 }
72917 }
72918
72919 stack[i - 1] = s;
72920 stack[i] = p;
72921
72922 if (i + 1 < stack.length) {
72923 stack[i + 1] = n;
72924 } else {
72925 stack.push(n);
72926 }
72927
72928 i = i + 2;
72929 }
72930 }
72931 }
72932 } //Removes item at iterator from tree
72933
72934
72935 iproto.remove = function () {
72936 var stack = this._stack;
72937
72938 if (stack.length === 0) {
72939 return this.tree;
72940 } //First copy path to node
72941
72942
72943 var cstack = new Array(stack.length);
72944 var n = stack[stack.length - 1];
72945 cstack[cstack.length - 1] = new RBNode(n._color, n.key, n.value, n.left, n.right, n._count);
72946
72947 for (var i = stack.length - 2; i >= 0; --i) {
72948 var n = stack[i];
72949
72950 if (n.left === stack[i + 1]) {
72951 cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i + 1], n.right, n._count);
72952 } else {
72953 cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i + 1], n._count);
72954 }
72955 } //Get node
72956
72957
72958 n = cstack[cstack.length - 1]; //console.log("start remove: ", n.value)
72959 //If not leaf, then swap with previous node
72960
72961 if (n.left && n.right) {
72962 //console.log("moving to leaf")
72963 //First walk to previous leaf
72964 var split = cstack.length;
72965 n = n.left;
72966
72967 while (n.right) {
72968 cstack.push(n);
72969 n = n.right;
72970 } //Copy path to leaf
72971
72972
72973 var v = cstack[split - 1];
72974 cstack.push(new RBNode(n._color, v.key, v.value, n.left, n.right, n._count));
72975 cstack[split - 1].key = n.key;
72976 cstack[split - 1].value = n.value; //Fix up stack
72977
72978 for (var i = cstack.length - 2; i >= split; --i) {
72979 n = cstack[i];
72980 cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i + 1], n._count);
72981 }
72982
72983 cstack[split - 1].left = cstack[split];
72984 } //console.log("stack=", cstack.map(function(v) { return v.value }))
72985 //Remove leaf node
72986
72987
72988 n = cstack[cstack.length - 1];
72989
72990 if (n._color === RED) {
72991 //Easy case: removing red leaf
72992 //console.log("RED leaf")
72993 var p = cstack[cstack.length - 2];
72994
72995 if (p.left === n) {
72996 p.left = null;
72997 } else if (p.right === n) {
72998 p.right = null;
72999 }
73000
73001 cstack.pop();
73002
73003 for (var i = 0; i < cstack.length; ++i) {
73004 cstack[i]._count--;
73005 }
73006
73007 return new RedBlackTree(this.tree._compare, cstack[0]);
73008 } else {
73009 if (n.left || n.right) {
73010 //Second easy case: Single child black parent
73011 //console.log("BLACK single child")
73012 if (n.left) {
73013 swapNode(n, n.left);
73014 } else if (n.right) {
73015 swapNode(n, n.right);
73016 } //Child must be red, so repaint it black to balance color
73017
73018
73019 n._color = BLACK;
73020
73021 for (var i = 0; i < cstack.length - 1; ++i) {
73022 cstack[i]._count--;
73023 }
73024
73025 return new RedBlackTree(this.tree._compare, cstack[0]);
73026 } else if (cstack.length === 1) {
73027 //Third easy case: root
73028 //console.log("ROOT")
73029 return new RedBlackTree(this.tree._compare, null);
73030 } else {
73031 //Hard case: Repaint n, and then do some nasty stuff
73032 //console.log("BLACK leaf no children")
73033 for (var i = 0; i < cstack.length; ++i) {
73034 cstack[i]._count--;
73035 }
73036
73037 var parent = cstack[cstack.length - 2];
73038 fixDoubleBlack(cstack); //Fix up links
73039
73040 if (parent.left === n) {
73041 parent.left = null;
73042 } else {
73043 parent.right = null;
73044 }
73045 }
73046 }
73047
73048 return new RedBlackTree(this.tree._compare, cstack[0]);
73049 }; //Returns key
73050
73051
73052 Object.defineProperty(iproto, "key", {
73053 get: function () {
73054 if (this._stack.length > 0) {
73055 return this._stack[this._stack.length - 1].key;
73056 }
73057
73058 return;
73059 },
73060 enumerable: true
73061 }); //Returns value
73062
73063 Object.defineProperty(iproto, "value", {
73064 get: function () {
73065 if (this._stack.length > 0) {
73066 return this._stack[this._stack.length - 1].value;
73067 }
73068
73069 return;
73070 },
73071 enumerable: true
73072 }); //Returns the position of this iterator in the sorted list
73073
73074 Object.defineProperty(iproto, "index", {
73075 get: function () {
73076 var idx = 0;
73077 var stack = this._stack;
73078
73079 if (stack.length === 0) {
73080 var r = this.tree.root;
73081
73082 if (r) {
73083 return r._count;
73084 }
73085
73086 return 0;
73087 } else if (stack[stack.length - 1].left) {
73088 idx = stack[stack.length - 1].left._count;
73089 }
73090
73091 for (var s = stack.length - 2; s >= 0; --s) {
73092 if (stack[s + 1] === stack[s].right) {
73093 ++idx;
73094
73095 if (stack[s].left) {
73096 idx += stack[s].left._count;
73097 }
73098 }
73099 }
73100
73101 return idx;
73102 },
73103 enumerable: true
73104 }); //Advances iterator to next element in list
73105
73106 iproto.next = function () {
73107 var stack = this._stack;
73108
73109 if (stack.length === 0) {
73110 return;
73111 }
73112
73113 var n = stack[stack.length - 1];
73114
73115 if (n.right) {
73116 n = n.right;
73117
73118 while (n) {
73119 stack.push(n);
73120 n = n.left;
73121 }
73122 } else {
73123 stack.pop();
73124
73125 while (stack.length > 0 && stack[stack.length - 1].right === n) {
73126 n = stack[stack.length - 1];
73127 stack.pop();
73128 }
73129 }
73130 }; //Checks if iterator is at end of tree
73131
73132
73133 Object.defineProperty(iproto, "hasNext", {
73134 get: function () {
73135 var stack = this._stack;
73136
73137 if (stack.length === 0) {
73138 return false;
73139 }
73140
73141 if (stack[stack.length - 1].right) {
73142 return true;
73143 }
73144
73145 for (var s = stack.length - 1; s > 0; --s) {
73146 if (stack[s - 1].left === stack[s]) {
73147 return true;
73148 }
73149 }
73150
73151 return false;
73152 }
73153 }); //Update value
73154
73155 iproto.update = function (value) {
73156 var stack = this._stack;
73157
73158 if (stack.length === 0) {
73159 throw new Error("Can't update empty node!");
73160 }
73161
73162 var cstack = new Array(stack.length);
73163 var n = stack[stack.length - 1];
73164 cstack[cstack.length - 1] = new RBNode(n._color, n.key, value, n.left, n.right, n._count);
73165
73166 for (var i = stack.length - 2; i >= 0; --i) {
73167 n = stack[i];
73168
73169 if (n.left === stack[i + 1]) {
73170 cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i + 1], n.right, n._count);
73171 } else {
73172 cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i + 1], n._count);
73173 }
73174 }
73175
73176 return new RedBlackTree(this.tree._compare, cstack[0]);
73177 }; //Moves iterator backward one element
73178
73179
73180 iproto.prev = function () {
73181 var stack = this._stack;
73182
73183 if (stack.length === 0) {
73184 return;
73185 }
73186
73187 var n = stack[stack.length - 1];
73188
73189 if (n.left) {
73190 n = n.left;
73191
73192 while (n) {
73193 stack.push(n);
73194 n = n.right;
73195 }
73196 } else {
73197 stack.pop();
73198
73199 while (stack.length > 0 && stack[stack.length - 1].left === n) {
73200 n = stack[stack.length - 1];
73201 stack.pop();
73202 }
73203 }
73204 }; //Checks if iterator is at start of tree
73205
73206
73207 Object.defineProperty(iproto, "hasPrev", {
73208 get: function () {
73209 var stack = this._stack;
73210
73211 if (stack.length === 0) {
73212 return false;
73213 }
73214
73215 if (stack[stack.length - 1].left) {
73216 return true;
73217 }
73218
73219 for (var s = stack.length - 1; s > 0; --s) {
73220 if (stack[s - 1].right === stack[s]) {
73221 return true;
73222 }
73223 }
73224
73225 return false;
73226 }
73227 }); //Default comparison function
73228
73229 function defaultCompare(a, b) {
73230 if (a < b) {
73231 return -1;
73232 }
73233
73234 if (a > b) {
73235 return 1;
73236 }
73237
73238 return 0;
73239 } //Build a tree
73240
73241
73242 function createRBTree(compare) {
73243 return new RedBlackTree(compare || defaultCompare, null);
73244 }
73245
73246 /***/ }),
73247 /* 606 */
73248 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
73249
73250 "use strict";
73251 /**
73252 * @fileoverview This option sets a specific tab width for your code
73253 *
73254 * This rule has been ported and modified from nodeca.
73255 * @author Vitaly Puzrin
73256 * @author Gyandeep Singh
73257 * @deprecated in ESLint v4.0.0
73258 */
73259 //------------------------------------------------------------------------------
73260 // Requirements
73261 //------------------------------------------------------------------------------
73262
73263 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
73264 // Rule Definition
73265 //------------------------------------------------------------------------------
73266
73267 /* istanbul ignore next: this rule has known coverage issues, but it's deprecated and shouldn't be updated in the future anyway. */
73268
73269
73270 module.exports = {
73271 meta: {
73272 type: "layout",
73273 docs: {
73274 description: "enforce consistent indentation",
73275 recommended: false,
73276 url: "https://eslint.org/docs/rules/indent-legacy"
73277 },
73278 deprecated: true,
73279 replacedBy: ["indent"],
73280 fixable: "whitespace",
73281 schema: [{
73282 oneOf: [{
73283 enum: ["tab"]
73284 }, {
73285 type: "integer",
73286 minimum: 0
73287 }]
73288 }, {
73289 type: "object",
73290 properties: {
73291 SwitchCase: {
73292 type: "integer",
73293 minimum: 0
73294 },
73295 VariableDeclarator: {
73296 oneOf: [{
73297 type: "integer",
73298 minimum: 0
73299 }, {
73300 type: "object",
73301 properties: {
73302 var: {
73303 type: "integer",
73304 minimum: 0
73305 },
73306 let: {
73307 type: "integer",
73308 minimum: 0
73309 },
73310 const: {
73311 type: "integer",
73312 minimum: 0
73313 }
73314 }
73315 }]
73316 },
73317 outerIIFEBody: {
73318 type: "integer",
73319 minimum: 0
73320 },
73321 MemberExpression: {
73322 type: "integer",
73323 minimum: 0
73324 },
73325 FunctionDeclaration: {
73326 type: "object",
73327 properties: {
73328 parameters: {
73329 oneOf: [{
73330 type: "integer",
73331 minimum: 0
73332 }, {
73333 enum: ["first"]
73334 }]
73335 },
73336 body: {
73337 type: "integer",
73338 minimum: 0
73339 }
73340 }
73341 },
73342 FunctionExpression: {
73343 type: "object",
73344 properties: {
73345 parameters: {
73346 oneOf: [{
73347 type: "integer",
73348 minimum: 0
73349 }, {
73350 enum: ["first"]
73351 }]
73352 },
73353 body: {
73354 type: "integer",
73355 minimum: 0
73356 }
73357 }
73358 },
73359 CallExpression: {
73360 type: "object",
73361 properties: {
73362 parameters: {
73363 oneOf: [{
73364 type: "integer",
73365 minimum: 0
73366 }, {
73367 enum: ["first"]
73368 }]
73369 }
73370 }
73371 },
73372 ArrayExpression: {
73373 oneOf: [{
73374 type: "integer",
73375 minimum: 0
73376 }, {
73377 enum: ["first"]
73378 }]
73379 },
73380 ObjectExpression: {
73381 oneOf: [{
73382 type: "integer",
73383 minimum: 0
73384 }, {
73385 enum: ["first"]
73386 }]
73387 }
73388 },
73389 additionalProperties: false
73390 }],
73391 messages: {
73392 expected: "Expected indentation of {{expected}} but found {{actual}}."
73393 }
73394 },
73395
73396 create(context) {
73397 const DEFAULT_VARIABLE_INDENT = 1;
73398 const DEFAULT_PARAMETER_INDENT = null; // For backwards compatibility, don't check parameter indentation unless specified in the config
73399
73400 const DEFAULT_FUNCTION_BODY_INDENT = 1;
73401 let indentType = "space";
73402 let indentSize = 4;
73403 const options = {
73404 SwitchCase: 0,
73405 VariableDeclarator: {
73406 var: DEFAULT_VARIABLE_INDENT,
73407 let: DEFAULT_VARIABLE_INDENT,
73408 const: DEFAULT_VARIABLE_INDENT
73409 },
73410 outerIIFEBody: null,
73411 FunctionDeclaration: {
73412 parameters: DEFAULT_PARAMETER_INDENT,
73413 body: DEFAULT_FUNCTION_BODY_INDENT
73414 },
73415 FunctionExpression: {
73416 parameters: DEFAULT_PARAMETER_INDENT,
73417 body: DEFAULT_FUNCTION_BODY_INDENT
73418 },
73419 CallExpression: {
73420 arguments: DEFAULT_PARAMETER_INDENT
73421 },
73422 ArrayExpression: 1,
73423 ObjectExpression: 1
73424 };
73425 const sourceCode = context.getSourceCode();
73426
73427 if (context.options.length) {
73428 if (context.options[0] === "tab") {
73429 indentSize = 1;
73430 indentType = "tab";
73431 } else
73432 /* istanbul ignore else : this will be caught by options validation */
73433 if (typeof context.options[0] === "number") {
73434 indentSize = context.options[0];
73435 indentType = "space";
73436 }
73437
73438 if (context.options[1]) {
73439 const opts = context.options[1];
73440 options.SwitchCase = opts.SwitchCase || 0;
73441 const variableDeclaratorRules = opts.VariableDeclarator;
73442
73443 if (typeof variableDeclaratorRules === "number") {
73444 options.VariableDeclarator = {
73445 var: variableDeclaratorRules,
73446 let: variableDeclaratorRules,
73447 const: variableDeclaratorRules
73448 };
73449 } else if (typeof variableDeclaratorRules === "object") {
73450 Object.assign(options.VariableDeclarator, variableDeclaratorRules);
73451 }
73452
73453 if (typeof opts.outerIIFEBody === "number") {
73454 options.outerIIFEBody = opts.outerIIFEBody;
73455 }
73456
73457 if (typeof opts.MemberExpression === "number") {
73458 options.MemberExpression = opts.MemberExpression;
73459 }
73460
73461 if (typeof opts.FunctionDeclaration === "object") {
73462 Object.assign(options.FunctionDeclaration, opts.FunctionDeclaration);
73463 }
73464
73465 if (typeof opts.FunctionExpression === "object") {
73466 Object.assign(options.FunctionExpression, opts.FunctionExpression);
73467 }
73468
73469 if (typeof opts.CallExpression === "object") {
73470 Object.assign(options.CallExpression, opts.CallExpression);
73471 }
73472
73473 if (typeof opts.ArrayExpression === "number" || typeof opts.ArrayExpression === "string") {
73474 options.ArrayExpression = opts.ArrayExpression;
73475 }
73476
73477 if (typeof opts.ObjectExpression === "number" || typeof opts.ObjectExpression === "string") {
73478 options.ObjectExpression = opts.ObjectExpression;
73479 }
73480 }
73481 }
73482
73483 const caseIndentStore = {};
73484 /**
73485 * Creates an error message for a line, given the expected/actual indentation.
73486 * @param {int} expectedAmount The expected amount of indentation characters for this line
73487 * @param {int} actualSpaces The actual number of indentation spaces that were found on this line
73488 * @param {int} actualTabs The actual number of indentation tabs that were found on this line
73489 * @returns {string} An error message for this line
73490 */
73491
73492 function createErrorMessageData(expectedAmount, actualSpaces, actualTabs) {
73493 const expectedStatement = "".concat(expectedAmount, " ").concat(indentType).concat(expectedAmount === 1 ? "" : "s"); // e.g. "2 tabs"
73494
73495 const foundSpacesWord = "space".concat(actualSpaces === 1 ? "" : "s"); // e.g. "space"
73496
73497 const foundTabsWord = "tab".concat(actualTabs === 1 ? "" : "s"); // e.g. "tabs"
73498
73499 let foundStatement;
73500
73501 if (actualSpaces > 0 && actualTabs > 0) {
73502 foundStatement = "".concat(actualSpaces, " ").concat(foundSpacesWord, " and ").concat(actualTabs, " ").concat(foundTabsWord); // e.g. "1 space and 2 tabs"
73503 } else if (actualSpaces > 0) {
73504 /*
73505 * Abbreviate the message if the expected indentation is also spaces.
73506 * e.g. 'Expected 4 spaces but found 2' rather than 'Expected 4 spaces but found 2 spaces'
73507 */
73508 foundStatement = indentType === "space" ? actualSpaces : "".concat(actualSpaces, " ").concat(foundSpacesWord);
73509 } else if (actualTabs > 0) {
73510 foundStatement = indentType === "tab" ? actualTabs : "".concat(actualTabs, " ").concat(foundTabsWord);
73511 } else {
73512 foundStatement = "0";
73513 }
73514
73515 return {
73516 expected: expectedStatement,
73517 actual: foundStatement
73518 };
73519 }
73520 /**
73521 * Reports a given indent violation
73522 * @param {ASTNode} node Node violating the indent rule
73523 * @param {int} needed Expected indentation character count
73524 * @param {int} gottenSpaces Indentation space count in the actual node/code
73525 * @param {int} gottenTabs Indentation tab count in the actual node/code
73526 * @param {Object} [loc] Error line and column location
73527 * @param {boolean} isLastNodeCheck Is the error for last node check
73528 * @returns {void}
73529 */
73530
73531
73532 function report(node, needed, gottenSpaces, gottenTabs, loc, isLastNodeCheck) {
73533 if (gottenSpaces && gottenTabs) {
73534 // To avoid conflicts with `no-mixed-spaces-and-tabs`, don't report lines that have both spaces and tabs.
73535 return;
73536 }
73537
73538 const desiredIndent = (indentType === "space" ? " " : "\t").repeat(needed);
73539 const textRange = isLastNodeCheck ? [node.range[1] - node.loc.end.column, node.range[1] - node.loc.end.column + gottenSpaces + gottenTabs] : [node.range[0] - node.loc.start.column, node.range[0] - node.loc.start.column + gottenSpaces + gottenTabs];
73540 context.report({
73541 node,
73542 loc,
73543 messageId: "expected",
73544 data: createErrorMessageData(needed, gottenSpaces, gottenTabs),
73545 fix: fixer => fixer.replaceTextRange(textRange, desiredIndent)
73546 });
73547 }
73548 /**
73549 * Get the actual indent of node
73550 * @param {ASTNode|Token} node Node to examine
73551 * @param {boolean} [byLastLine=false] get indent of node's last line
73552 * @returns {Object} The node's indent. Contains keys `space` and `tab`, representing the indent of each character. Also
73553 * contains keys `goodChar` and `badChar`, where `goodChar` is the amount of the user's desired indentation character, and
73554 * `badChar` is the amount of the other indentation character.
73555 */
73556
73557
73558 function getNodeIndent(node, byLastLine) {
73559 const token = byLastLine ? sourceCode.getLastToken(node) : sourceCode.getFirstToken(node);
73560 const srcCharsBeforeNode = sourceCode.getText(token, token.loc.start.column).split("");
73561 const indentChars = srcCharsBeforeNode.slice(0, srcCharsBeforeNode.findIndex(char => char !== " " && char !== "\t"));
73562 const spaces = indentChars.filter(char => char === " ").length;
73563 const tabs = indentChars.filter(char => char === "\t").length;
73564 return {
73565 space: spaces,
73566 tab: tabs,
73567 goodChar: indentType === "space" ? spaces : tabs,
73568 badChar: indentType === "space" ? tabs : spaces
73569 };
73570 }
73571 /**
73572 * Checks node is the first in its own start line. By default it looks by start line.
73573 * @param {ASTNode} node The node to check
73574 * @param {boolean} [byEndLocation=false] Lookup based on start position or end
73575 * @returns {boolean} true if its the first in the its start line
73576 */
73577
73578
73579 function isNodeFirstInLine(node, byEndLocation) {
73580 const firstToken = byEndLocation === true ? sourceCode.getLastToken(node, 1) : sourceCode.getTokenBefore(node),
73581 startLine = byEndLocation === true ? node.loc.end.line : node.loc.start.line,
73582 endLine = firstToken ? firstToken.loc.end.line : -1;
73583 return startLine !== endLine;
73584 }
73585 /**
73586 * Check indent for node
73587 * @param {ASTNode} node Node to check
73588 * @param {int} neededIndent needed indent
73589 * @returns {void}
73590 */
73591
73592
73593 function checkNodeIndent(node, neededIndent) {
73594 const actualIndent = getNodeIndent(node, false);
73595
73596 if (node.type !== "ArrayExpression" && node.type !== "ObjectExpression" && (actualIndent.goodChar !== neededIndent || actualIndent.badChar !== 0) && isNodeFirstInLine(node)) {
73597 report(node, neededIndent, actualIndent.space, actualIndent.tab);
73598 }
73599
73600 if (node.type === "IfStatement" && node.alternate) {
73601 const elseToken = sourceCode.getTokenBefore(node.alternate);
73602 checkNodeIndent(elseToken, neededIndent);
73603
73604 if (!isNodeFirstInLine(node.alternate)) {
73605 checkNodeIndent(node.alternate, neededIndent);
73606 }
73607 }
73608
73609 if (node.type === "TryStatement" && node.handler) {
73610 const catchToken = sourceCode.getFirstToken(node.handler);
73611 checkNodeIndent(catchToken, neededIndent);
73612 }
73613
73614 if (node.type === "TryStatement" && node.finalizer) {
73615 const finallyToken = sourceCode.getTokenBefore(node.finalizer);
73616 checkNodeIndent(finallyToken, neededIndent);
73617 }
73618
73619 if (node.type === "DoWhileStatement") {
73620 const whileToken = sourceCode.getTokenAfter(node.body);
73621 checkNodeIndent(whileToken, neededIndent);
73622 }
73623 }
73624 /**
73625 * Check indent for nodes list
73626 * @param {ASTNode[]} nodes list of node objects
73627 * @param {int} indent needed indent
73628 * @returns {void}
73629 */
73630
73631
73632 function checkNodesIndent(nodes, indent) {
73633 nodes.forEach(node => checkNodeIndent(node, indent));
73634 }
73635 /**
73636 * Check last node line indent this detects, that block closed correctly
73637 * @param {ASTNode} node Node to examine
73638 * @param {int} lastLineIndent needed indent
73639 * @returns {void}
73640 */
73641
73642
73643 function checkLastNodeLineIndent(node, lastLineIndent) {
73644 const lastToken = sourceCode.getLastToken(node);
73645 const endIndent = getNodeIndent(lastToken, true);
73646
73647 if ((endIndent.goodChar !== lastLineIndent || endIndent.badChar !== 0) && isNodeFirstInLine(node, true)) {
73648 report(node, lastLineIndent, endIndent.space, endIndent.tab, {
73649 line: lastToken.loc.start.line,
73650 column: lastToken.loc.start.column
73651 }, true);
73652 }
73653 }
73654 /**
73655 * Check last node line indent this detects, that block closed correctly
73656 * This function for more complicated return statement case, where closing parenthesis may be followed by ';'
73657 * @param {ASTNode} node Node to examine
73658 * @param {int} firstLineIndent first line needed indent
73659 * @returns {void}
73660 */
73661
73662
73663 function checkLastReturnStatementLineIndent(node, firstLineIndent) {
73664 /*
73665 * in case if return statement ends with ');' we have traverse back to ')'
73666 * otherwise we'll measure indent for ';' and replace ')'
73667 */
73668 const lastToken = sourceCode.getLastToken(node, astUtils.isClosingParenToken);
73669 const textBeforeClosingParenthesis = sourceCode.getText(lastToken, lastToken.loc.start.column).slice(0, -1);
73670
73671 if (textBeforeClosingParenthesis.trim()) {
73672 // There are tokens before the closing paren, don't report this case
73673 return;
73674 }
73675
73676 const endIndent = getNodeIndent(lastToken, true);
73677
73678 if (endIndent.goodChar !== firstLineIndent) {
73679 report(node, firstLineIndent, endIndent.space, endIndent.tab, {
73680 line: lastToken.loc.start.line,
73681 column: lastToken.loc.start.column
73682 }, true);
73683 }
73684 }
73685 /**
73686 * Check first node line indent is correct
73687 * @param {ASTNode} node Node to examine
73688 * @param {int} firstLineIndent needed indent
73689 * @returns {void}
73690 */
73691
73692
73693 function checkFirstNodeLineIndent(node, firstLineIndent) {
73694 const startIndent = getNodeIndent(node, false);
73695
73696 if ((startIndent.goodChar !== firstLineIndent || startIndent.badChar !== 0) && isNodeFirstInLine(node)) {
73697 report(node, firstLineIndent, startIndent.space, startIndent.tab, {
73698 line: node.loc.start.line,
73699 column: node.loc.start.column
73700 });
73701 }
73702 }
73703 /**
73704 * Returns a parent node of given node based on a specified type
73705 * if not present then return null
73706 * @param {ASTNode} node node to examine
73707 * @param {string} type type that is being looked for
73708 * @param {string} stopAtList end points for the evaluating code
73709 * @returns {ASTNode|void} if found then node otherwise null
73710 */
73711
73712
73713 function getParentNodeByType(node, type, stopAtList) {
73714 let parent = node.parent;
73715 const stopAtSet = new Set(stopAtList || ["Program"]);
73716
73717 while (parent.type !== type && !stopAtSet.has(parent.type) && parent.type !== "Program") {
73718 parent = parent.parent;
73719 }
73720
73721 return parent.type === type ? parent : null;
73722 }
73723 /**
73724 * Returns the VariableDeclarator based on the current node
73725 * if not present then return null
73726 * @param {ASTNode} node node to examine
73727 * @returns {ASTNode|void} if found then node otherwise null
73728 */
73729
73730
73731 function getVariableDeclaratorNode(node) {
73732 return getParentNodeByType(node, "VariableDeclarator");
73733 }
73734 /**
73735 * Check to see if the node is part of the multi-line variable declaration.
73736 * Also if its on the same line as the varNode
73737 * @param {ASTNode} node node to check
73738 * @param {ASTNode} varNode variable declaration node to check against
73739 * @returns {boolean} True if all the above condition satisfy
73740 */
73741
73742
73743 function isNodeInVarOnTop(node, varNode) {
73744 return varNode && varNode.parent.loc.start.line === node.loc.start.line && varNode.parent.declarations.length > 1;
73745 }
73746 /**
73747 * Check to see if the argument before the callee node is multi-line and
73748 * there should only be 1 argument before the callee node
73749 * @param {ASTNode} node node to check
73750 * @returns {boolean} True if arguments are multi-line
73751 */
73752
73753
73754 function isArgBeforeCalleeNodeMultiline(node) {
73755 const parent = node.parent;
73756
73757 if (parent.arguments.length >= 2 && parent.arguments[1] === node) {
73758 return parent.arguments[0].loc.end.line > parent.arguments[0].loc.start.line;
73759 }
73760
73761 return false;
73762 }
73763 /**
73764 * Check to see if the node is a file level IIFE
73765 * @param {ASTNode} node The function node to check.
73766 * @returns {boolean} True if the node is the outer IIFE
73767 */
73768
73769
73770 function isOuterIIFE(node) {
73771 const parent = node.parent;
73772 let stmt = parent.parent;
73773 /*
73774 * Verify that the node is an IIEF
73775 */
73776
73777 if (parent.type !== "CallExpression" || parent.callee !== node) {
73778 return false;
73779 }
73780 /*
73781 * Navigate legal ancestors to determine whether this IIEF is outer
73782 */
73783
73784
73785 while (stmt.type === "UnaryExpression" && (stmt.operator === "!" || stmt.operator === "~" || stmt.operator === "+" || stmt.operator === "-") || stmt.type === "AssignmentExpression" || stmt.type === "LogicalExpression" || stmt.type === "SequenceExpression" || stmt.type === "VariableDeclarator") {
73786 stmt = stmt.parent;
73787 }
73788
73789 return (stmt.type === "ExpressionStatement" || stmt.type === "VariableDeclaration") && stmt.parent && stmt.parent.type === "Program";
73790 }
73791 /**
73792 * Check indent for function block content
73793 * @param {ASTNode} node A BlockStatement node that is inside of a function.
73794 * @returns {void}
73795 */
73796
73797
73798 function checkIndentInFunctionBlock(node) {
73799 /*
73800 * Search first caller in chain.
73801 * Ex.:
73802 *
73803 * Models <- Identifier
73804 * .User
73805 * .find()
73806 * .exec(function() {
73807 * // function body
73808 * });
73809 *
73810 * Looks for 'Models'
73811 */
73812 const calleeNode = node.parent; // FunctionExpression
73813
73814 let indent;
73815
73816 if (calleeNode.parent && (calleeNode.parent.type === "Property" || calleeNode.parent.type === "ArrayExpression")) {
73817 // If function is part of array or object, comma can be put at left
73818 indent = getNodeIndent(calleeNode, false).goodChar;
73819 } else {
73820 // If function is standalone, simple calculate indent
73821 indent = getNodeIndent(calleeNode).goodChar;
73822 }
73823
73824 if (calleeNode.parent.type === "CallExpression") {
73825 const calleeParent = calleeNode.parent;
73826
73827 if (calleeNode.type !== "FunctionExpression" && calleeNode.type !== "ArrowFunctionExpression") {
73828 if (calleeParent && calleeParent.loc.start.line < node.loc.start.line) {
73829 indent = getNodeIndent(calleeParent).goodChar;
73830 }
73831 } else {
73832 if (isArgBeforeCalleeNodeMultiline(calleeNode) && calleeParent.callee.loc.start.line === calleeParent.callee.loc.end.line && !isNodeFirstInLine(calleeNode)) {
73833 indent = getNodeIndent(calleeParent).goodChar;
73834 }
73835 }
73836 }
73837 /*
73838 * function body indent should be indent + indent size, unless this
73839 * is a FunctionDeclaration, FunctionExpression, or outer IIFE and the corresponding options are enabled.
73840 */
73841
73842
73843 let functionOffset = indentSize;
73844
73845 if (options.outerIIFEBody !== null && isOuterIIFE(calleeNode)) {
73846 functionOffset = options.outerIIFEBody * indentSize;
73847 } else if (calleeNode.type === "FunctionExpression") {
73848 functionOffset = options.FunctionExpression.body * indentSize;
73849 } else if (calleeNode.type === "FunctionDeclaration") {
73850 functionOffset = options.FunctionDeclaration.body * indentSize;
73851 }
73852
73853 indent += functionOffset; // check if the node is inside a variable
73854
73855 const parentVarNode = getVariableDeclaratorNode(node);
73856
73857 if (parentVarNode && isNodeInVarOnTop(node, parentVarNode)) {
73858 indent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
73859 }
73860
73861 if (node.body.length > 0) {
73862 checkNodesIndent(node.body, indent);
73863 }
73864
73865 checkLastNodeLineIndent(node, indent - functionOffset);
73866 }
73867 /**
73868 * Checks if the given node starts and ends on the same line
73869 * @param {ASTNode} node The node to check
73870 * @returns {boolean} Whether or not the block starts and ends on the same line.
73871 */
73872
73873
73874 function isSingleLineNode(node) {
73875 const lastToken = sourceCode.getLastToken(node),
73876 startLine = node.loc.start.line,
73877 endLine = lastToken.loc.end.line;
73878 return startLine === endLine;
73879 }
73880 /**
73881 * Check indent for array block content or object block content
73882 * @param {ASTNode} node node to examine
73883 * @returns {void}
73884 */
73885
73886
73887 function checkIndentInArrayOrObjectBlock(node) {
73888 // Skip inline
73889 if (isSingleLineNode(node)) {
73890 return;
73891 }
73892
73893 let elements = node.type === "ArrayExpression" ? node.elements : node.properties; // filter out empty elements example would be [ , 2] so remove first element as espree considers it as null
73894
73895 elements = elements.filter(elem => elem !== null);
73896 let nodeIndent;
73897 let elementsIndent;
73898 const parentVarNode = getVariableDeclaratorNode(node); // TODO - come up with a better strategy in future
73899
73900 if (isNodeFirstInLine(node)) {
73901 const parent = node.parent;
73902 nodeIndent = getNodeIndent(parent).goodChar;
73903
73904 if (!parentVarNode || parentVarNode.loc.start.line !== node.loc.start.line) {
73905 if (parent.type !== "VariableDeclarator" || parentVarNode === parentVarNode.parent.declarations[0]) {
73906 if (parent.type === "VariableDeclarator" && parentVarNode.loc.start.line === parent.loc.start.line) {
73907 nodeIndent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
73908 } else if (parent.type === "ObjectExpression" || parent.type === "ArrayExpression") {
73909 const parentElements = node.parent.type === "ObjectExpression" ? node.parent.properties : node.parent.elements;
73910
73911 if (parentElements[0] && parentElements[0].loc.start.line === parent.loc.start.line && parentElements[0].loc.end.line !== parent.loc.start.line) {
73912 /*
73913 * If the first element of the array spans multiple lines, don't increase the expected indentation of the rest.
73914 * e.g. [{
73915 * foo: 1
73916 * },
73917 * {
73918 * bar: 1
73919 * }]
73920 * the second object is not indented.
73921 */
73922 } else if (typeof options[parent.type] === "number") {
73923 nodeIndent += options[parent.type] * indentSize;
73924 } else {
73925 nodeIndent = parentElements[0].loc.start.column;
73926 }
73927 } else if (parent.type === "CallExpression" || parent.type === "NewExpression") {
73928 if (typeof options.CallExpression.arguments === "number") {
73929 nodeIndent += options.CallExpression.arguments * indentSize;
73930 } else if (options.CallExpression.arguments === "first") {
73931 if (parent.arguments.indexOf(node) !== -1) {
73932 nodeIndent = parent.arguments[0].loc.start.column;
73933 }
73934 } else {
73935 nodeIndent += indentSize;
73936 }
73937 } else if (parent.type === "LogicalExpression" || parent.type === "ArrowFunctionExpression") {
73938 nodeIndent += indentSize;
73939 }
73940 }
73941 }
73942
73943 checkFirstNodeLineIndent(node, nodeIndent);
73944 } else {
73945 nodeIndent = getNodeIndent(node).goodChar;
73946 }
73947
73948 if (options[node.type] === "first") {
73949 elementsIndent = elements.length ? elements[0].loc.start.column : 0; // If there are no elements, elementsIndent doesn't matter.
73950 } else {
73951 elementsIndent = nodeIndent + indentSize * options[node.type];
73952 }
73953 /*
73954 * Check if the node is a multiple variable declaration; if so, then
73955 * make sure indentation takes that into account.
73956 */
73957
73958
73959 if (isNodeInVarOnTop(node, parentVarNode)) {
73960 elementsIndent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
73961 }
73962
73963 checkNodesIndent(elements, elementsIndent);
73964
73965 if (elements.length > 0) {
73966 // Skip last block line check if last item in same line
73967 if (elements[elements.length - 1].loc.end.line === node.loc.end.line) {
73968 return;
73969 }
73970 }
73971
73972 checkLastNodeLineIndent(node, nodeIndent + (isNodeInVarOnTop(node, parentVarNode) ? options.VariableDeclarator[parentVarNode.parent.kind] * indentSize : 0));
73973 }
73974 /**
73975 * Check if the node or node body is a BlockStatement or not
73976 * @param {ASTNode} node node to test
73977 * @returns {boolean} True if it or its body is a block statement
73978 */
73979
73980
73981 function isNodeBodyBlock(node) {
73982 return node.type === "BlockStatement" || node.type === "ClassBody" || node.body && node.body.type === "BlockStatement" || node.consequent && node.consequent.type === "BlockStatement";
73983 }
73984 /**
73985 * Check indentation for blocks
73986 * @param {ASTNode} node node to check
73987 * @returns {void}
73988 */
73989
73990
73991 function blockIndentationCheck(node) {
73992 // Skip inline blocks
73993 if (isSingleLineNode(node)) {
73994 return;
73995 }
73996
73997 if (node.parent && (node.parent.type === "FunctionExpression" || node.parent.type === "FunctionDeclaration" || node.parent.type === "ArrowFunctionExpression")) {
73998 checkIndentInFunctionBlock(node);
73999 return;
74000 }
74001
74002 let indent;
74003 let nodesToCheck = [];
74004 /*
74005 * For this statements we should check indent from statement beginning,
74006 * not from the beginning of the block.
74007 */
74008
74009 const statementsWithProperties = ["IfStatement", "WhileStatement", "ForStatement", "ForInStatement", "ForOfStatement", "DoWhileStatement", "ClassDeclaration", "TryStatement"];
74010
74011 if (node.parent && statementsWithProperties.indexOf(node.parent.type) !== -1 && isNodeBodyBlock(node)) {
74012 indent = getNodeIndent(node.parent).goodChar;
74013 } else if (node.parent && node.parent.type === "CatchClause") {
74014 indent = getNodeIndent(node.parent.parent).goodChar;
74015 } else {
74016 indent = getNodeIndent(node).goodChar;
74017 }
74018
74019 if (node.type === "IfStatement" && node.consequent.type !== "BlockStatement") {
74020 nodesToCheck = [node.consequent];
74021 } else if (Array.isArray(node.body)) {
74022 nodesToCheck = node.body;
74023 } else {
74024 nodesToCheck = [node.body];
74025 }
74026
74027 if (nodesToCheck.length > 0) {
74028 checkNodesIndent(nodesToCheck, indent + indentSize);
74029 }
74030
74031 if (node.type === "BlockStatement") {
74032 checkLastNodeLineIndent(node, indent);
74033 }
74034 }
74035 /**
74036 * Filter out the elements which are on the same line of each other or the node.
74037 * basically have only 1 elements from each line except the variable declaration line.
74038 * @param {ASTNode} node Variable declaration node
74039 * @returns {ASTNode[]} Filtered elements
74040 */
74041
74042
74043 function filterOutSameLineVars(node) {
74044 return node.declarations.reduce((finalCollection, elem) => {
74045 const lastElem = finalCollection[finalCollection.length - 1];
74046
74047 if (elem.loc.start.line !== node.loc.start.line && !lastElem || lastElem && lastElem.loc.start.line !== elem.loc.start.line) {
74048 finalCollection.push(elem);
74049 }
74050
74051 return finalCollection;
74052 }, []);
74053 }
74054 /**
74055 * Check indentation for variable declarations
74056 * @param {ASTNode} node node to examine
74057 * @returns {void}
74058 */
74059
74060
74061 function checkIndentInVariableDeclarations(node) {
74062 const elements = filterOutSameLineVars(node);
74063 const nodeIndent = getNodeIndent(node).goodChar;
74064 const lastElement = elements[elements.length - 1];
74065 const elementsIndent = nodeIndent + indentSize * options.VariableDeclarator[node.kind];
74066 checkNodesIndent(elements, elementsIndent); // Only check the last line if there is any token after the last item
74067
74068 if (sourceCode.getLastToken(node).loc.end.line <= lastElement.loc.end.line) {
74069 return;
74070 }
74071
74072 const tokenBeforeLastElement = sourceCode.getTokenBefore(lastElement);
74073
74074 if (tokenBeforeLastElement.value === ",") {
74075 // Special case for comma-first syntax where the semicolon is indented
74076 checkLastNodeLineIndent(node, getNodeIndent(tokenBeforeLastElement).goodChar);
74077 } else {
74078 checkLastNodeLineIndent(node, elementsIndent - indentSize);
74079 }
74080 }
74081 /**
74082 * Check and decide whether to check for indentation for blockless nodes
74083 * Scenarios are for or while statements without braces around them
74084 * @param {ASTNode} node node to examine
74085 * @returns {void}
74086 */
74087
74088
74089 function blockLessNodes(node) {
74090 if (node.body.type !== "BlockStatement") {
74091 blockIndentationCheck(node);
74092 }
74093 }
74094 /**
74095 * Returns the expected indentation for the case statement
74096 * @param {ASTNode} node node to examine
74097 * @param {int} [providedSwitchIndent] indent for switch statement
74098 * @returns {int} indent size
74099 */
74100
74101
74102 function expectedCaseIndent(node, providedSwitchIndent) {
74103 const switchNode = node.type === "SwitchStatement" ? node : node.parent;
74104 const switchIndent = typeof providedSwitchIndent === "undefined" ? getNodeIndent(switchNode).goodChar : providedSwitchIndent;
74105 let caseIndent;
74106
74107 if (caseIndentStore[switchNode.loc.start.line]) {
74108 return caseIndentStore[switchNode.loc.start.line];
74109 }
74110
74111 if (switchNode.cases.length > 0 && options.SwitchCase === 0) {
74112 caseIndent = switchIndent;
74113 } else {
74114 caseIndent = switchIndent + indentSize * options.SwitchCase;
74115 }
74116
74117 caseIndentStore[switchNode.loc.start.line] = caseIndent;
74118 return caseIndent;
74119 }
74120 /**
74121 * Checks whether a return statement is wrapped in ()
74122 * @param {ASTNode} node node to examine
74123 * @returns {boolean} the result
74124 */
74125
74126
74127 function isWrappedInParenthesis(node) {
74128 const regex = /^return\s*?\(\s*?\);*?/u;
74129 const statementWithoutArgument = sourceCode.getText(node).replace(sourceCode.getText(node.argument), "");
74130 return regex.test(statementWithoutArgument);
74131 }
74132
74133 return {
74134 Program(node) {
74135 if (node.body.length > 0) {
74136 // Root nodes should have no indent
74137 checkNodesIndent(node.body, getNodeIndent(node).goodChar);
74138 }
74139 },
74140
74141 ClassBody: blockIndentationCheck,
74142 BlockStatement: blockIndentationCheck,
74143 WhileStatement: blockLessNodes,
74144 ForStatement: blockLessNodes,
74145 ForInStatement: blockLessNodes,
74146 ForOfStatement: blockLessNodes,
74147 DoWhileStatement: blockLessNodes,
74148
74149 IfStatement(node) {
74150 if (node.consequent.type !== "BlockStatement" && node.consequent.loc.start.line > node.loc.start.line) {
74151 blockIndentationCheck(node);
74152 }
74153 },
74154
74155 VariableDeclaration(node) {
74156 if (node.declarations[node.declarations.length - 1].loc.start.line > node.declarations[0].loc.start.line) {
74157 checkIndentInVariableDeclarations(node);
74158 }
74159 },
74160
74161 ObjectExpression(node) {
74162 checkIndentInArrayOrObjectBlock(node);
74163 },
74164
74165 ArrayExpression(node) {
74166 checkIndentInArrayOrObjectBlock(node);
74167 },
74168
74169 MemberExpression(node) {
74170 if (typeof options.MemberExpression === "undefined") {
74171 return;
74172 }
74173
74174 if (isSingleLineNode(node)) {
74175 return;
74176 }
74177 /*
74178 * The typical layout of variable declarations and assignments
74179 * alter the expectation of correct indentation. Skip them.
74180 * TODO: Add appropriate configuration options for variable
74181 * declarations and assignments.
74182 */
74183
74184
74185 if (getParentNodeByType(node, "VariableDeclarator", ["FunctionExpression", "ArrowFunctionExpression"])) {
74186 return;
74187 }
74188
74189 if (getParentNodeByType(node, "AssignmentExpression", ["FunctionExpression"])) {
74190 return;
74191 }
74192
74193 const propertyIndent = getNodeIndent(node).goodChar + indentSize * options.MemberExpression;
74194 const checkNodes = [node.property];
74195 const dot = sourceCode.getTokenBefore(node.property);
74196
74197 if (dot.type === "Punctuator" && dot.value === ".") {
74198 checkNodes.push(dot);
74199 }
74200
74201 checkNodesIndent(checkNodes, propertyIndent);
74202 },
74203
74204 SwitchStatement(node) {
74205 // Switch is not a 'BlockStatement'
74206 const switchIndent = getNodeIndent(node).goodChar;
74207 const caseIndent = expectedCaseIndent(node, switchIndent);
74208 checkNodesIndent(node.cases, caseIndent);
74209 checkLastNodeLineIndent(node, switchIndent);
74210 },
74211
74212 SwitchCase(node) {
74213 // Skip inline cases
74214 if (isSingleLineNode(node)) {
74215 return;
74216 }
74217
74218 const caseIndent = expectedCaseIndent(node);
74219 checkNodesIndent(node.consequent, caseIndent + indentSize);
74220 },
74221
74222 FunctionDeclaration(node) {
74223 if (isSingleLineNode(node)) {
74224 return;
74225 }
74226
74227 if (options.FunctionDeclaration.parameters === "first" && node.params.length) {
74228 checkNodesIndent(node.params.slice(1), node.params[0].loc.start.column);
74229 } else if (options.FunctionDeclaration.parameters !== null) {
74230 checkNodesIndent(node.params, getNodeIndent(node).goodChar + indentSize * options.FunctionDeclaration.parameters);
74231 }
74232 },
74233
74234 FunctionExpression(node) {
74235 if (isSingleLineNode(node)) {
74236 return;
74237 }
74238
74239 if (options.FunctionExpression.parameters === "first" && node.params.length) {
74240 checkNodesIndent(node.params.slice(1), node.params[0].loc.start.column);
74241 } else if (options.FunctionExpression.parameters !== null) {
74242 checkNodesIndent(node.params, getNodeIndent(node).goodChar + indentSize * options.FunctionExpression.parameters);
74243 }
74244 },
74245
74246 ReturnStatement(node) {
74247 if (isSingleLineNode(node)) {
74248 return;
74249 }
74250
74251 const firstLineIndent = getNodeIndent(node).goodChar; // in case if return statement is wrapped in parenthesis
74252
74253 if (isWrappedInParenthesis(node)) {
74254 checkLastReturnStatementLineIndent(node, firstLineIndent);
74255 } else {
74256 checkNodeIndent(node, firstLineIndent);
74257 }
74258 },
74259
74260 CallExpression(node) {
74261 if (isSingleLineNode(node)) {
74262 return;
74263 }
74264
74265 if (options.CallExpression.arguments === "first" && node.arguments.length) {
74266 checkNodesIndent(node.arguments.slice(1), node.arguments[0].loc.start.column);
74267 } else if (options.CallExpression.arguments !== null) {
74268 checkNodesIndent(node.arguments, getNodeIndent(node).goodChar + indentSize * options.CallExpression.arguments);
74269 }
74270 }
74271
74272 };
74273 }
74274
74275 };
74276
74277 /***/ }),
74278 /* 607 */
74279 /***/ ((module) => {
74280
74281 "use strict";
74282 /**
74283 * @fileoverview A rule to control the style of variable initializations.
74284 * @author Colin Ihrig
74285 */
74286 //------------------------------------------------------------------------------
74287 // Helpers
74288 //------------------------------------------------------------------------------
74289
74290 /**
74291 * Checks whether or not a given node is a for loop.
74292 * @param {ASTNode} block A node to check.
74293 * @returns {boolean} `true` when the node is a for loop.
74294 */
74295
74296 function isForLoop(block) {
74297 return block.type === "ForInStatement" || block.type === "ForOfStatement" || block.type === "ForStatement";
74298 }
74299 /**
74300 * Checks whether or not a given declarator node has its initializer.
74301 * @param {ASTNode} node A declarator node to check.
74302 * @returns {boolean} `true` when the node has its initializer.
74303 */
74304
74305
74306 function isInitialized(node) {
74307 const declaration = node.parent;
74308 const block = declaration.parent;
74309
74310 if (isForLoop(block)) {
74311 if (block.type === "ForStatement") {
74312 return block.init === declaration;
74313 }
74314
74315 return block.left === declaration;
74316 }
74317
74318 return Boolean(node.init);
74319 } //------------------------------------------------------------------------------
74320 // Rule Definition
74321 //------------------------------------------------------------------------------
74322
74323
74324 module.exports = {
74325 meta: {
74326 type: "suggestion",
74327 docs: {
74328 description: "require or disallow initialization in variable declarations",
74329 recommended: false,
74330 url: "https://eslint.org/docs/rules/init-declarations"
74331 },
74332 schema: {
74333 anyOf: [{
74334 type: "array",
74335 items: [{
74336 enum: ["always"]
74337 }],
74338 minItems: 0,
74339 maxItems: 1
74340 }, {
74341 type: "array",
74342 items: [{
74343 enum: ["never"]
74344 }, {
74345 type: "object",
74346 properties: {
74347 ignoreForLoopInit: {
74348 type: "boolean"
74349 }
74350 },
74351 additionalProperties: false
74352 }],
74353 minItems: 0,
74354 maxItems: 2
74355 }]
74356 },
74357 messages: {
74358 initialized: "Variable '{{idName}}' should be initialized on declaration.",
74359 notInitialized: "Variable '{{idName}}' should not be initialized on declaration."
74360 }
74361 },
74362
74363 create(context) {
74364 const MODE_ALWAYS = "always",
74365 MODE_NEVER = "never";
74366 const mode = context.options[0] || MODE_ALWAYS;
74367 const params = context.options[1] || {}; //--------------------------------------------------------------------------
74368 // Public API
74369 //--------------------------------------------------------------------------
74370
74371 return {
74372 "VariableDeclaration:exit"(node) {
74373 const kind = node.kind,
74374 declarations = node.declarations;
74375
74376 for (let i = 0; i < declarations.length; ++i) {
74377 const declaration = declarations[i],
74378 id = declaration.id,
74379 initialized = isInitialized(declaration),
74380 isIgnoredForLoop = params.ignoreForLoopInit && isForLoop(node.parent);
74381 let messageId = "";
74382
74383 if (mode === MODE_ALWAYS && !initialized) {
74384 messageId = "initialized";
74385 } else if (mode === MODE_NEVER && kind !== "const" && initialized && !isIgnoredForLoop) {
74386 messageId = "notInitialized";
74387 }
74388
74389 if (id.type === "Identifier" && messageId) {
74390 context.report({
74391 node: declaration,
74392 messageId,
74393 data: {
74394 idName: id.name
74395 }
74396 });
74397 }
74398 }
74399 }
74400
74401 };
74402 }
74403
74404 };
74405
74406 /***/ }),
74407 /* 608 */
74408 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
74409
74410 "use strict";
74411 /**
74412 * @fileoverview A rule to ensure consistent quotes used in jsx syntax.
74413 * @author Mathias Schreck <https://github.com/lo1tuma>
74414 */
74415 //------------------------------------------------------------------------------
74416 // Requirements
74417 //------------------------------------------------------------------------------
74418
74419 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
74420 // Constants
74421 //------------------------------------------------------------------------------
74422
74423
74424 const QUOTE_SETTINGS = {
74425 "prefer-double": {
74426 quote: "\"",
74427 description: "singlequote",
74428
74429 convert(str) {
74430 return str.replace(/'/gu, "\"");
74431 }
74432
74433 },
74434 "prefer-single": {
74435 quote: "'",
74436 description: "doublequote",
74437
74438 convert(str) {
74439 return str.replace(/"/gu, "'");
74440 }
74441
74442 }
74443 }; //------------------------------------------------------------------------------
74444 // Rule Definition
74445 //------------------------------------------------------------------------------
74446
74447 module.exports = {
74448 meta: {
74449 type: "layout",
74450 docs: {
74451 description: "enforce the consistent use of either double or single quotes in JSX attributes",
74452 recommended: false,
74453 url: "https://eslint.org/docs/rules/jsx-quotes"
74454 },
74455 fixable: "whitespace",
74456 schema: [{
74457 enum: ["prefer-single", "prefer-double"]
74458 }],
74459 messages: {
74460 unexpected: "Unexpected usage of {{description}}."
74461 }
74462 },
74463
74464 create(context) {
74465 const quoteOption = context.options[0] || "prefer-double",
74466 setting = QUOTE_SETTINGS[quoteOption];
74467 /**
74468 * Checks if the given string literal node uses the expected quotes
74469 * @param {ASTNode} node A string literal node.
74470 * @returns {boolean} Whether or not the string literal used the expected quotes.
74471 * @public
74472 */
74473
74474 function usesExpectedQuotes(node) {
74475 return node.value.indexOf(setting.quote) !== -1 || astUtils.isSurroundedBy(node.raw, setting.quote);
74476 }
74477
74478 return {
74479 JSXAttribute(node) {
74480 const attributeValue = node.value;
74481
74482 if (attributeValue && astUtils.isStringLiteral(attributeValue) && !usesExpectedQuotes(attributeValue)) {
74483 context.report({
74484 node: attributeValue,
74485 messageId: "unexpected",
74486 data: {
74487 description: setting.description
74488 },
74489
74490 fix(fixer) {
74491 return fixer.replaceText(attributeValue, setting.convert(attributeValue.raw));
74492 }
74493
74494 });
74495 }
74496 }
74497
74498 };
74499 }
74500
74501 };
74502
74503 /***/ }),
74504 /* 609 */
74505 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
74506
74507 "use strict";
74508 /**
74509 * @fileoverview Rule to specify spacing of object literal keys and values
74510 * @author Brandon Mills
74511 */
74512 //------------------------------------------------------------------------------
74513 // Requirements
74514 //------------------------------------------------------------------------------
74515
74516 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
74517 // Helpers
74518 //------------------------------------------------------------------------------
74519
74520 /**
74521 * Checks whether a string contains a line terminator as defined in
74522 * http://www.ecma-international.org/ecma-262/5.1/#sec-7.3
74523 * @param {string} str String to test.
74524 * @returns {boolean} True if str contains a line terminator.
74525 */
74526
74527
74528 function containsLineTerminator(str) {
74529 return astUtils.LINEBREAK_MATCHER.test(str);
74530 }
74531 /**
74532 * Gets the last element of an array.
74533 * @param {Array} arr An array.
74534 * @returns {any} Last element of arr.
74535 */
74536
74537
74538 function last(arr) {
74539 return arr[arr.length - 1];
74540 }
74541 /**
74542 * Checks whether a node is contained on a single line.
74543 * @param {ASTNode} node AST Node being evaluated.
74544 * @returns {boolean} True if the node is a single line.
74545 */
74546
74547
74548 function isSingleLine(node) {
74549 return node.loc.end.line === node.loc.start.line;
74550 }
74551 /**
74552 * Checks whether the properties on a single line.
74553 * @param {ASTNode[]} properties List of Property AST nodes.
74554 * @returns {boolean} True if all properties is on a single line.
74555 */
74556
74557
74558 function isSingleLineProperties(properties) {
74559 const [firstProp] = properties,
74560 lastProp = last(properties);
74561 return firstProp.loc.start.line === lastProp.loc.end.line;
74562 }
74563 /**
74564 * Initializes a single option property from the configuration with defaults for undefined values
74565 * @param {Object} toOptions Object to be initialized
74566 * @param {Object} fromOptions Object to be initialized from
74567 * @returns {Object} The object with correctly initialized options and values
74568 */
74569
74570
74571 function initOptionProperty(toOptions, fromOptions) {
74572 toOptions.mode = fromOptions.mode || "strict"; // Set value of beforeColon
74573
74574 if (typeof fromOptions.beforeColon !== "undefined") {
74575 toOptions.beforeColon = +fromOptions.beforeColon;
74576 } else {
74577 toOptions.beforeColon = 0;
74578 } // Set value of afterColon
74579
74580
74581 if (typeof fromOptions.afterColon !== "undefined") {
74582 toOptions.afterColon = +fromOptions.afterColon;
74583 } else {
74584 toOptions.afterColon = 1;
74585 } // Set align if exists
74586
74587
74588 if (typeof fromOptions.align !== "undefined") {
74589 if (typeof fromOptions.align === "object") {
74590 toOptions.align = fromOptions.align;
74591 } else {
74592 // "string"
74593 toOptions.align = {
74594 on: fromOptions.align,
74595 mode: toOptions.mode,
74596 beforeColon: toOptions.beforeColon,
74597 afterColon: toOptions.afterColon
74598 };
74599 }
74600 }
74601
74602 return toOptions;
74603 }
74604 /**
74605 * Initializes all the option values (singleLine, multiLine and align) from the configuration with defaults for undefined values
74606 * @param {Object} toOptions Object to be initialized
74607 * @param {Object} fromOptions Object to be initialized from
74608 * @returns {Object} The object with correctly initialized options and values
74609 */
74610
74611
74612 function initOptions(toOptions, fromOptions) {
74613 if (typeof fromOptions.align === "object") {
74614 // Initialize the alignment configuration
74615 toOptions.align = initOptionProperty({}, fromOptions.align);
74616 toOptions.align.on = fromOptions.align.on || "colon";
74617 toOptions.align.mode = fromOptions.align.mode || "strict";
74618 toOptions.multiLine = initOptionProperty({}, fromOptions.multiLine || fromOptions);
74619 toOptions.singleLine = initOptionProperty({}, fromOptions.singleLine || fromOptions);
74620 } else {
74621 // string or undefined
74622 toOptions.multiLine = initOptionProperty({}, fromOptions.multiLine || fromOptions);
74623 toOptions.singleLine = initOptionProperty({}, fromOptions.singleLine || fromOptions); // If alignment options are defined in multiLine, pull them out into the general align configuration
74624
74625 if (toOptions.multiLine.align) {
74626 toOptions.align = {
74627 on: toOptions.multiLine.align.on,
74628 mode: toOptions.multiLine.align.mode || toOptions.multiLine.mode,
74629 beforeColon: toOptions.multiLine.align.beforeColon,
74630 afterColon: toOptions.multiLine.align.afterColon
74631 };
74632 }
74633 }
74634
74635 return toOptions;
74636 } //------------------------------------------------------------------------------
74637 // Rule Definition
74638 //------------------------------------------------------------------------------
74639
74640
74641 module.exports = {
74642 meta: {
74643 type: "layout",
74644 docs: {
74645 description: "enforce consistent spacing between keys and values in object literal properties",
74646 recommended: false,
74647 url: "https://eslint.org/docs/rules/key-spacing"
74648 },
74649 fixable: "whitespace",
74650 schema: [{
74651 anyOf: [{
74652 type: "object",
74653 properties: {
74654 align: {
74655 anyOf: [{
74656 enum: ["colon", "value"]
74657 }, {
74658 type: "object",
74659 properties: {
74660 mode: {
74661 enum: ["strict", "minimum"]
74662 },
74663 on: {
74664 enum: ["colon", "value"]
74665 },
74666 beforeColon: {
74667 type: "boolean"
74668 },
74669 afterColon: {
74670 type: "boolean"
74671 }
74672 },
74673 additionalProperties: false
74674 }]
74675 },
74676 mode: {
74677 enum: ["strict", "minimum"]
74678 },
74679 beforeColon: {
74680 type: "boolean"
74681 },
74682 afterColon: {
74683 type: "boolean"
74684 }
74685 },
74686 additionalProperties: false
74687 }, {
74688 type: "object",
74689 properties: {
74690 singleLine: {
74691 type: "object",
74692 properties: {
74693 mode: {
74694 enum: ["strict", "minimum"]
74695 },
74696 beforeColon: {
74697 type: "boolean"
74698 },
74699 afterColon: {
74700 type: "boolean"
74701 }
74702 },
74703 additionalProperties: false
74704 },
74705 multiLine: {
74706 type: "object",
74707 properties: {
74708 align: {
74709 anyOf: [{
74710 enum: ["colon", "value"]
74711 }, {
74712 type: "object",
74713 properties: {
74714 mode: {
74715 enum: ["strict", "minimum"]
74716 },
74717 on: {
74718 enum: ["colon", "value"]
74719 },
74720 beforeColon: {
74721 type: "boolean"
74722 },
74723 afterColon: {
74724 type: "boolean"
74725 }
74726 },
74727 additionalProperties: false
74728 }]
74729 },
74730 mode: {
74731 enum: ["strict", "minimum"]
74732 },
74733 beforeColon: {
74734 type: "boolean"
74735 },
74736 afterColon: {
74737 type: "boolean"
74738 }
74739 },
74740 additionalProperties: false
74741 }
74742 },
74743 additionalProperties: false
74744 }, {
74745 type: "object",
74746 properties: {
74747 singleLine: {
74748 type: "object",
74749 properties: {
74750 mode: {
74751 enum: ["strict", "minimum"]
74752 },
74753 beforeColon: {
74754 type: "boolean"
74755 },
74756 afterColon: {
74757 type: "boolean"
74758 }
74759 },
74760 additionalProperties: false
74761 },
74762 multiLine: {
74763 type: "object",
74764 properties: {
74765 mode: {
74766 enum: ["strict", "minimum"]
74767 },
74768 beforeColon: {
74769 type: "boolean"
74770 },
74771 afterColon: {
74772 type: "boolean"
74773 }
74774 },
74775 additionalProperties: false
74776 },
74777 align: {
74778 type: "object",
74779 properties: {
74780 mode: {
74781 enum: ["strict", "minimum"]
74782 },
74783 on: {
74784 enum: ["colon", "value"]
74785 },
74786 beforeColon: {
74787 type: "boolean"
74788 },
74789 afterColon: {
74790 type: "boolean"
74791 }
74792 },
74793 additionalProperties: false
74794 }
74795 },
74796 additionalProperties: false
74797 }]
74798 }],
74799 messages: {
74800 extraKey: "Extra space after {{computed}}key '{{key}}'.",
74801 extraValue: "Extra space before value for {{computed}}key '{{key}}'.",
74802 missingKey: "Missing space after {{computed}}key '{{key}}'.",
74803 missingValue: "Missing space before value for {{computed}}key '{{key}}'."
74804 }
74805 },
74806
74807 create(context) {
74808 /**
74809 * OPTIONS
74810 * "key-spacing": [2, {
74811 * beforeColon: false,
74812 * afterColon: true,
74813 * align: "colon" // Optional, or "value"
74814 * }
74815 */
74816 const options = context.options[0] || {},
74817 ruleOptions = initOptions({}, options),
74818 multiLineOptions = ruleOptions.multiLine,
74819 singleLineOptions = ruleOptions.singleLine,
74820 alignmentOptions = ruleOptions.align || null;
74821 const sourceCode = context.getSourceCode();
74822 /**
74823 * Checks whether a property is a member of the property group it follows.
74824 * @param {ASTNode} lastMember The last Property known to be in the group.
74825 * @param {ASTNode} candidate The next Property that might be in the group.
74826 * @returns {boolean} True if the candidate property is part of the group.
74827 */
74828
74829 function continuesPropertyGroup(lastMember, candidate) {
74830 const groupEndLine = lastMember.loc.start.line,
74831 candidateStartLine = candidate.loc.start.line;
74832
74833 if (candidateStartLine - groupEndLine <= 1) {
74834 return true;
74835 }
74836 /*
74837 * Check that the first comment is adjacent to the end of the group, the
74838 * last comment is adjacent to the candidate property, and that successive
74839 * comments are adjacent to each other.
74840 */
74841
74842
74843 const leadingComments = sourceCode.getCommentsBefore(candidate);
74844
74845 if (leadingComments.length && leadingComments[0].loc.start.line - groupEndLine <= 1 && candidateStartLine - last(leadingComments).loc.end.line <= 1) {
74846 for (let i = 1; i < leadingComments.length; i++) {
74847 if (leadingComments[i].loc.start.line - leadingComments[i - 1].loc.end.line > 1) {
74848 return false;
74849 }
74850 }
74851
74852 return true;
74853 }
74854
74855 return false;
74856 }
74857 /**
74858 * Determines if the given property is key-value property.
74859 * @param {ASTNode} property Property node to check.
74860 * @returns {boolean} Whether the property is a key-value property.
74861 */
74862
74863
74864 function isKeyValueProperty(property) {
74865 return !(property.method || property.shorthand || property.kind !== "init" || property.type !== "Property" // Could be "ExperimentalSpreadProperty" or "SpreadElement"
74866 );
74867 }
74868 /**
74869 * Starting from the given a node (a property.key node here) looks forward
74870 * until it finds the last token before a colon punctuator and returns it.
74871 * @param {ASTNode} node The node to start looking from.
74872 * @returns {ASTNode} The last token before a colon punctuator.
74873 */
74874
74875
74876 function getLastTokenBeforeColon(node) {
74877 const colonToken = sourceCode.getTokenAfter(node, astUtils.isColonToken);
74878 return sourceCode.getTokenBefore(colonToken);
74879 }
74880 /**
74881 * Starting from the given a node (a property.key node here) looks forward
74882 * until it finds the colon punctuator and returns it.
74883 * @param {ASTNode} node The node to start looking from.
74884 * @returns {ASTNode} The colon punctuator.
74885 */
74886
74887
74888 function getNextColon(node) {
74889 return sourceCode.getTokenAfter(node, astUtils.isColonToken);
74890 }
74891 /**
74892 * Gets an object literal property's key as the identifier name or string value.
74893 * @param {ASTNode} property Property node whose key to retrieve.
74894 * @returns {string} The property's key.
74895 */
74896
74897
74898 function getKey(property) {
74899 const key = property.key;
74900
74901 if (property.computed) {
74902 return sourceCode.getText().slice(key.range[0], key.range[1]);
74903 }
74904
74905 return astUtils.getStaticPropertyName(property);
74906 }
74907 /**
74908 * Reports an appropriately-formatted error if spacing is incorrect on one
74909 * side of the colon.
74910 * @param {ASTNode} property Key-value pair in an object literal.
74911 * @param {string} side Side being verified - either "key" or "value".
74912 * @param {string} whitespace Actual whitespace string.
74913 * @param {int} expected Expected whitespace length.
74914 * @param {string} mode Value of the mode as "strict" or "minimum"
74915 * @returns {void}
74916 */
74917
74918
74919 function report(property, side, whitespace, expected, mode) {
74920 const diff = whitespace.length - expected;
74921
74922 if ((diff && mode === "strict" || diff < 0 && mode === "minimum" || diff > 0 && !expected && mode === "minimum") && !(expected && containsLineTerminator(whitespace))) {
74923 const nextColon = getNextColon(property.key),
74924 tokenBeforeColon = sourceCode.getTokenBefore(nextColon, {
74925 includeComments: true
74926 }),
74927 tokenAfterColon = sourceCode.getTokenAfter(nextColon, {
74928 includeComments: true
74929 }),
74930 isKeySide = side === "key",
74931 isExtra = diff > 0,
74932 diffAbs = Math.abs(diff),
74933 spaces = Array(diffAbs + 1).join(" ");
74934 const locStart = isKeySide ? tokenBeforeColon.loc.end : nextColon.loc.start;
74935 const locEnd = isKeySide ? nextColon.loc.start : tokenAfterColon.loc.start;
74936 const missingLoc = isKeySide ? tokenBeforeColon.loc : tokenAfterColon.loc;
74937 const loc = isExtra ? {
74938 start: locStart,
74939 end: locEnd
74940 } : missingLoc;
74941 let fix;
74942
74943 if (isExtra) {
74944 let range; // Remove whitespace
74945
74946 if (isKeySide) {
74947 range = [tokenBeforeColon.range[1], tokenBeforeColon.range[1] + diffAbs];
74948 } else {
74949 range = [tokenAfterColon.range[0] - diffAbs, tokenAfterColon.range[0]];
74950 }
74951
74952 fix = function (fixer) {
74953 return fixer.removeRange(range);
74954 };
74955 } else {
74956 // Add whitespace
74957 if (isKeySide) {
74958 fix = function (fixer) {
74959 return fixer.insertTextAfter(tokenBeforeColon, spaces);
74960 };
74961 } else {
74962 fix = function (fixer) {
74963 return fixer.insertTextBefore(tokenAfterColon, spaces);
74964 };
74965 }
74966 }
74967
74968 let messageId = "";
74969
74970 if (isExtra) {
74971 messageId = side === "key" ? "extraKey" : "extraValue";
74972 } else {
74973 messageId = side === "key" ? "missingKey" : "missingValue";
74974 }
74975
74976 context.report({
74977 node: property[side],
74978 loc,
74979 messageId,
74980 data: {
74981 computed: property.computed ? "computed " : "",
74982 key: getKey(property)
74983 },
74984 fix
74985 });
74986 }
74987 }
74988 /**
74989 * Gets the number of characters in a key, including quotes around string
74990 * keys and braces around computed property keys.
74991 * @param {ASTNode} property Property of on object literal.
74992 * @returns {int} Width of the key.
74993 */
74994
74995
74996 function getKeyWidth(property) {
74997 const startToken = sourceCode.getFirstToken(property);
74998 const endToken = getLastTokenBeforeColon(property.key);
74999 return endToken.range[1] - startToken.range[0];
75000 }
75001 /**
75002 * Gets the whitespace around the colon in an object literal property.
75003 * @param {ASTNode} property Property node from an object literal.
75004 * @returns {Object} Whitespace before and after the property's colon.
75005 */
75006
75007
75008 function getPropertyWhitespace(property) {
75009 const whitespace = /(\s*):(\s*)/u.exec(sourceCode.getText().slice(property.key.range[1], property.value.range[0]));
75010
75011 if (whitespace) {
75012 return {
75013 beforeColon: whitespace[1],
75014 afterColon: whitespace[2]
75015 };
75016 }
75017
75018 return null;
75019 }
75020 /**
75021 * Creates groups of properties.
75022 * @param {ASTNode} node ObjectExpression node being evaluated.
75023 * @returns {Array<ASTNode[]>} Groups of property AST node lists.
75024 */
75025
75026
75027 function createGroups(node) {
75028 if (node.properties.length === 1) {
75029 return [node.properties];
75030 }
75031
75032 return node.properties.reduce((groups, property) => {
75033 const currentGroup = last(groups),
75034 prev = last(currentGroup);
75035
75036 if (!prev || continuesPropertyGroup(prev, property)) {
75037 currentGroup.push(property);
75038 } else {
75039 groups.push([property]);
75040 }
75041
75042 return groups;
75043 }, [[]]);
75044 }
75045 /**
75046 * Verifies correct vertical alignment of a group of properties.
75047 * @param {ASTNode[]} properties List of Property AST nodes.
75048 * @returns {void}
75049 */
75050
75051
75052 function verifyGroupAlignment(properties) {
75053 const length = properties.length,
75054 widths = properties.map(getKeyWidth),
75055 // Width of keys, including quotes
75056 align = alignmentOptions.on; // "value" or "colon"
75057
75058 let targetWidth = Math.max(...widths),
75059 beforeColon,
75060 afterColon,
75061 mode;
75062
75063 if (alignmentOptions && length > 1) {
75064 // When aligning values within a group, use the alignment configuration.
75065 beforeColon = alignmentOptions.beforeColon;
75066 afterColon = alignmentOptions.afterColon;
75067 mode = alignmentOptions.mode;
75068 } else {
75069 beforeColon = multiLineOptions.beforeColon;
75070 afterColon = multiLineOptions.afterColon;
75071 mode = alignmentOptions.mode;
75072 } // Conditionally include one space before or after colon
75073
75074
75075 targetWidth += align === "colon" ? beforeColon : afterColon;
75076
75077 for (let i = 0; i < length; i++) {
75078 const property = properties[i];
75079 const whitespace = getPropertyWhitespace(property);
75080
75081 if (whitespace) {
75082 // Object literal getters/setters lack a colon
75083 const width = widths[i];
75084
75085 if (align === "value") {
75086 report(property, "key", whitespace.beforeColon, beforeColon, mode);
75087 report(property, "value", whitespace.afterColon, targetWidth - width, mode);
75088 } else {
75089 // align = "colon"
75090 report(property, "key", whitespace.beforeColon, targetWidth - width, mode);
75091 report(property, "value", whitespace.afterColon, afterColon, mode);
75092 }
75093 }
75094 }
75095 }
75096 /**
75097 * Verifies spacing of property conforms to specified options.
75098 * @param {ASTNode} node Property node being evaluated.
75099 * @param {Object} lineOptions Configured singleLine or multiLine options
75100 * @returns {void}
75101 */
75102
75103
75104 function verifySpacing(node, lineOptions) {
75105 const actual = getPropertyWhitespace(node);
75106
75107 if (actual) {
75108 // Object literal getters/setters lack colons
75109 report(node, "key", actual.beforeColon, lineOptions.beforeColon, lineOptions.mode);
75110 report(node, "value", actual.afterColon, lineOptions.afterColon, lineOptions.mode);
75111 }
75112 }
75113 /**
75114 * Verifies spacing of each property in a list.
75115 * @param {ASTNode[]} properties List of Property AST nodes.
75116 * @param {Object} lineOptions Configured singleLine or multiLine options
75117 * @returns {void}
75118 */
75119
75120
75121 function verifyListSpacing(properties, lineOptions) {
75122 const length = properties.length;
75123
75124 for (let i = 0; i < length; i++) {
75125 verifySpacing(properties[i], lineOptions);
75126 }
75127 }
75128 /**
75129 * Verifies vertical alignment, taking into account groups of properties.
75130 * @param {ASTNode} node ObjectExpression node being evaluated.
75131 * @returns {void}
75132 */
75133
75134
75135 function verifyAlignment(node) {
75136 createGroups(node).forEach(group => {
75137 const properties = group.filter(isKeyValueProperty);
75138
75139 if (properties.length > 0 && isSingleLineProperties(properties)) {
75140 verifyListSpacing(properties, multiLineOptions);
75141 } else {
75142 verifyGroupAlignment(properties);
75143 }
75144 });
75145 } //--------------------------------------------------------------------------
75146 // Public API
75147 //--------------------------------------------------------------------------
75148
75149
75150 if (alignmentOptions) {
75151 // Verify vertical alignment
75152 return {
75153 ObjectExpression(node) {
75154 if (isSingleLine(node)) {
75155 verifyListSpacing(node.properties.filter(isKeyValueProperty), singleLineOptions);
75156 } else {
75157 verifyAlignment(node);
75158 }
75159 }
75160
75161 };
75162 } // Obey beforeColon and afterColon in each property as configured
75163
75164
75165 return {
75166 Property(node) {
75167 verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions);
75168 }
75169
75170 };
75171 }
75172
75173 };
75174
75175 /***/ }),
75176 /* 610 */
75177 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
75178
75179 "use strict";
75180 /**
75181 * @fileoverview Rule to enforce spacing before and after keywords.
75182 * @author Toru Nagashima
75183 */
75184 //------------------------------------------------------------------------------
75185 // Requirements
75186 //------------------------------------------------------------------------------
75187
75188 const astUtils = __webpack_require__(548),
75189 keywords = __webpack_require__(583); //------------------------------------------------------------------------------
75190 // Constants
75191 //------------------------------------------------------------------------------
75192
75193
75194 const PREV_TOKEN = /^[)\]}>]$/u;
75195 const NEXT_TOKEN = /^(?:[([{<~!]|\+\+?|--?)$/u;
75196 const PREV_TOKEN_M = /^[)\]}>*]$/u;
75197 const NEXT_TOKEN_M = /^[{*]$/u;
75198 const TEMPLATE_OPEN_PAREN = /\$\{$/u;
75199 const TEMPLATE_CLOSE_PAREN = /^\}/u;
75200 const CHECK_TYPE = /^(?:JSXElement|RegularExpression|String|Template|PrivateIdentifier)$/u;
75201 const KEYS = keywords.concat(["as", "async", "await", "from", "get", "let", "of", "set", "yield"]); // check duplications.
75202
75203 (function () {
75204 KEYS.sort();
75205
75206 for (let i = 1; i < KEYS.length; ++i) {
75207 if (KEYS[i] === KEYS[i - 1]) {
75208 throw new Error("Duplication was found in the keyword list: ".concat(KEYS[i]));
75209 }
75210 }
75211 })(); //------------------------------------------------------------------------------
75212 // Helpers
75213 //------------------------------------------------------------------------------
75214
75215 /**
75216 * Checks whether or not a given token is a "Template" token ends with "${".
75217 * @param {Token} token A token to check.
75218 * @returns {boolean} `true` if the token is a "Template" token ends with "${".
75219 */
75220
75221
75222 function isOpenParenOfTemplate(token) {
75223 return token.type === "Template" && TEMPLATE_OPEN_PAREN.test(token.value);
75224 }
75225 /**
75226 * Checks whether or not a given token is a "Template" token starts with "}".
75227 * @param {Token} token A token to check.
75228 * @returns {boolean} `true` if the token is a "Template" token starts with "}".
75229 */
75230
75231
75232 function isCloseParenOfTemplate(token) {
75233 return token.type === "Template" && TEMPLATE_CLOSE_PAREN.test(token.value);
75234 } //------------------------------------------------------------------------------
75235 // Rule Definition
75236 //------------------------------------------------------------------------------
75237
75238
75239 module.exports = {
75240 meta: {
75241 type: "layout",
75242 docs: {
75243 description: "enforce consistent spacing before and after keywords",
75244 recommended: false,
75245 url: "https://eslint.org/docs/rules/keyword-spacing"
75246 },
75247 fixable: "whitespace",
75248 schema: [{
75249 type: "object",
75250 properties: {
75251 before: {
75252 type: "boolean",
75253 default: true
75254 },
75255 after: {
75256 type: "boolean",
75257 default: true
75258 },
75259 overrides: {
75260 type: "object",
75261 properties: KEYS.reduce((retv, key) => {
75262 retv[key] = {
75263 type: "object",
75264 properties: {
75265 before: {
75266 type: "boolean"
75267 },
75268 after: {
75269 type: "boolean"
75270 }
75271 },
75272 additionalProperties: false
75273 };
75274 return retv;
75275 }, {}),
75276 additionalProperties: false
75277 }
75278 },
75279 additionalProperties: false
75280 }],
75281 messages: {
75282 expectedBefore: "Expected space(s) before \"{{value}}\".",
75283 expectedAfter: "Expected space(s) after \"{{value}}\".",
75284 unexpectedBefore: "Unexpected space(s) before \"{{value}}\".",
75285 unexpectedAfter: "Unexpected space(s) after \"{{value}}\"."
75286 }
75287 },
75288
75289 create(context) {
75290 const sourceCode = context.getSourceCode();
75291 const tokensToIgnore = new WeakSet();
75292 /**
75293 * Reports a given token if there are not space(s) before the token.
75294 * @param {Token} token A token to report.
75295 * @param {RegExp} pattern A pattern of the previous token to check.
75296 * @returns {void}
75297 */
75298
75299 function expectSpaceBefore(token, pattern) {
75300 const prevToken = sourceCode.getTokenBefore(token);
75301
75302 if (prevToken && (CHECK_TYPE.test(prevToken.type) || pattern.test(prevToken.value)) && !isOpenParenOfTemplate(prevToken) && !tokensToIgnore.has(prevToken) && astUtils.isTokenOnSameLine(prevToken, token) && !sourceCode.isSpaceBetweenTokens(prevToken, token)) {
75303 context.report({
75304 loc: token.loc,
75305 messageId: "expectedBefore",
75306 data: token,
75307
75308 fix(fixer) {
75309 return fixer.insertTextBefore(token, " ");
75310 }
75311
75312 });
75313 }
75314 }
75315 /**
75316 * Reports a given token if there are space(s) before the token.
75317 * @param {Token} token A token to report.
75318 * @param {RegExp} pattern A pattern of the previous token to check.
75319 * @returns {void}
75320 */
75321
75322
75323 function unexpectSpaceBefore(token, pattern) {
75324 const prevToken = sourceCode.getTokenBefore(token);
75325
75326 if (prevToken && (CHECK_TYPE.test(prevToken.type) || pattern.test(prevToken.value)) && !isOpenParenOfTemplate(prevToken) && !tokensToIgnore.has(prevToken) && astUtils.isTokenOnSameLine(prevToken, token) && sourceCode.isSpaceBetweenTokens(prevToken, token)) {
75327 context.report({
75328 loc: {
75329 start: prevToken.loc.end,
75330 end: token.loc.start
75331 },
75332 messageId: "unexpectedBefore",
75333 data: token,
75334
75335 fix(fixer) {
75336 return fixer.removeRange([prevToken.range[1], token.range[0]]);
75337 }
75338
75339 });
75340 }
75341 }
75342 /**
75343 * Reports a given token if there are not space(s) after the token.
75344 * @param {Token} token A token to report.
75345 * @param {RegExp} pattern A pattern of the next token to check.
75346 * @returns {void}
75347 */
75348
75349
75350 function expectSpaceAfter(token, pattern) {
75351 const nextToken = sourceCode.getTokenAfter(token);
75352
75353 if (nextToken && (CHECK_TYPE.test(nextToken.type) || pattern.test(nextToken.value)) && !isCloseParenOfTemplate(nextToken) && !tokensToIgnore.has(nextToken) && astUtils.isTokenOnSameLine(token, nextToken) && !sourceCode.isSpaceBetweenTokens(token, nextToken)) {
75354 context.report({
75355 loc: token.loc,
75356 messageId: "expectedAfter",
75357 data: token,
75358
75359 fix(fixer) {
75360 return fixer.insertTextAfter(token, " ");
75361 }
75362
75363 });
75364 }
75365 }
75366 /**
75367 * Reports a given token if there are space(s) after the token.
75368 * @param {Token} token A token to report.
75369 * @param {RegExp} pattern A pattern of the next token to check.
75370 * @returns {void}
75371 */
75372
75373
75374 function unexpectSpaceAfter(token, pattern) {
75375 const nextToken = sourceCode.getTokenAfter(token);
75376
75377 if (nextToken && (CHECK_TYPE.test(nextToken.type) || pattern.test(nextToken.value)) && !isCloseParenOfTemplate(nextToken) && !tokensToIgnore.has(nextToken) && astUtils.isTokenOnSameLine(token, nextToken) && sourceCode.isSpaceBetweenTokens(token, nextToken)) {
75378 context.report({
75379 loc: {
75380 start: token.loc.end,
75381 end: nextToken.loc.start
75382 },
75383 messageId: "unexpectedAfter",
75384 data: token,
75385
75386 fix(fixer) {
75387 return fixer.removeRange([token.range[1], nextToken.range[0]]);
75388 }
75389
75390 });
75391 }
75392 }
75393 /**
75394 * Parses the option object and determines check methods for each keyword.
75395 * @param {Object|undefined} options The option object to parse.
75396 * @returns {Object} - Normalized option object.
75397 * Keys are keywords (there are for every keyword).
75398 * Values are instances of `{"before": function, "after": function}`.
75399 */
75400
75401
75402 function parseOptions() {
75403 let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
75404 const before = options.before !== false;
75405 const after = options.after !== false;
75406 const defaultValue = {
75407 before: before ? expectSpaceBefore : unexpectSpaceBefore,
75408 after: after ? expectSpaceAfter : unexpectSpaceAfter
75409 };
75410 const overrides = options && options.overrides || {};
75411 const retv = Object.create(null);
75412
75413 for (let i = 0; i < KEYS.length; ++i) {
75414 const key = KEYS[i];
75415 const override = overrides[key];
75416
75417 if (override) {
75418 const thisBefore = "before" in override ? override.before : before;
75419 const thisAfter = "after" in override ? override.after : after;
75420 retv[key] = {
75421 before: thisBefore ? expectSpaceBefore : unexpectSpaceBefore,
75422 after: thisAfter ? expectSpaceAfter : unexpectSpaceAfter
75423 };
75424 } else {
75425 retv[key] = defaultValue;
75426 }
75427 }
75428
75429 return retv;
75430 }
75431
75432 const checkMethodMap = parseOptions(context.options[0]);
75433 /**
75434 * Reports a given token if usage of spacing followed by the token is
75435 * invalid.
75436 * @param {Token} token A token to report.
75437 * @param {RegExp} [pattern] Optional. A pattern of the previous
75438 * token to check.
75439 * @returns {void}
75440 */
75441
75442 function checkSpacingBefore(token, pattern) {
75443 checkMethodMap[token.value].before(token, pattern || PREV_TOKEN);
75444 }
75445 /**
75446 * Reports a given token if usage of spacing preceded by the token is
75447 * invalid.
75448 * @param {Token} token A token to report.
75449 * @param {RegExp} [pattern] Optional. A pattern of the next
75450 * token to check.
75451 * @returns {void}
75452 */
75453
75454
75455 function checkSpacingAfter(token, pattern) {
75456 checkMethodMap[token.value].after(token, pattern || NEXT_TOKEN);
75457 }
75458 /**
75459 * Reports a given token if usage of spacing around the token is invalid.
75460 * @param {Token} token A token to report.
75461 * @returns {void}
75462 */
75463
75464
75465 function checkSpacingAround(token) {
75466 checkSpacingBefore(token);
75467 checkSpacingAfter(token);
75468 }
75469 /**
75470 * Reports the first token of a given node if the first token is a keyword
75471 * and usage of spacing around the token is invalid.
75472 * @param {ASTNode|null} node A node to report.
75473 * @returns {void}
75474 */
75475
75476
75477 function checkSpacingAroundFirstToken(node) {
75478 const firstToken = node && sourceCode.getFirstToken(node);
75479
75480 if (firstToken && firstToken.type === "Keyword") {
75481 checkSpacingAround(firstToken);
75482 }
75483 }
75484 /**
75485 * Reports the first token of a given node if the first token is a keyword
75486 * and usage of spacing followed by the token is invalid.
75487 *
75488 * This is used for unary operators (e.g. `typeof`), `function`, and `super`.
75489 * Other rules are handling usage of spacing preceded by those keywords.
75490 * @param {ASTNode|null} node A node to report.
75491 * @returns {void}
75492 */
75493
75494
75495 function checkSpacingBeforeFirstToken(node) {
75496 const firstToken = node && sourceCode.getFirstToken(node);
75497
75498 if (firstToken && firstToken.type === "Keyword") {
75499 checkSpacingBefore(firstToken);
75500 }
75501 }
75502 /**
75503 * Reports the previous token of a given node if the token is a keyword and
75504 * usage of spacing around the token is invalid.
75505 * @param {ASTNode|null} node A node to report.
75506 * @returns {void}
75507 */
75508
75509
75510 function checkSpacingAroundTokenBefore(node) {
75511 if (node) {
75512 const token = sourceCode.getTokenBefore(node, astUtils.isKeywordToken);
75513 checkSpacingAround(token);
75514 }
75515 }
75516 /**
75517 * Reports `async` or `function` keywords of a given node if usage of
75518 * spacing around those keywords is invalid.
75519 * @param {ASTNode} node A node to report.
75520 * @returns {void}
75521 */
75522
75523
75524 function checkSpacingForFunction(node) {
75525 const firstToken = node && sourceCode.getFirstToken(node);
75526
75527 if (firstToken && (firstToken.type === "Keyword" && firstToken.value === "function" || firstToken.value === "async")) {
75528 checkSpacingBefore(firstToken);
75529 }
75530 }
75531 /**
75532 * Reports `class` and `extends` keywords of a given node if usage of
75533 * spacing around those keywords is invalid.
75534 * @param {ASTNode} node A node to report.
75535 * @returns {void}
75536 */
75537
75538
75539 function checkSpacingForClass(node) {
75540 checkSpacingAroundFirstToken(node);
75541 checkSpacingAroundTokenBefore(node.superClass);
75542 }
75543 /**
75544 * Reports `if` and `else` keywords of a given node if usage of spacing
75545 * around those keywords is invalid.
75546 * @param {ASTNode} node A node to report.
75547 * @returns {void}
75548 */
75549
75550
75551 function checkSpacingForIfStatement(node) {
75552 checkSpacingAroundFirstToken(node);
75553 checkSpacingAroundTokenBefore(node.alternate);
75554 }
75555 /**
75556 * Reports `try`, `catch`, and `finally` keywords of a given node if usage
75557 * of spacing around those keywords is invalid.
75558 * @param {ASTNode} node A node to report.
75559 * @returns {void}
75560 */
75561
75562
75563 function checkSpacingForTryStatement(node) {
75564 checkSpacingAroundFirstToken(node);
75565 checkSpacingAroundFirstToken(node.handler);
75566 checkSpacingAroundTokenBefore(node.finalizer);
75567 }
75568 /**
75569 * Reports `do` and `while` keywords of a given node if usage of spacing
75570 * around those keywords is invalid.
75571 * @param {ASTNode} node A node to report.
75572 * @returns {void}
75573 */
75574
75575
75576 function checkSpacingForDoWhileStatement(node) {
75577 checkSpacingAroundFirstToken(node);
75578 checkSpacingAroundTokenBefore(node.test);
75579 }
75580 /**
75581 * Reports `for` and `in` keywords of a given node if usage of spacing
75582 * around those keywords is invalid.
75583 * @param {ASTNode} node A node to report.
75584 * @returns {void}
75585 */
75586
75587
75588 function checkSpacingForForInStatement(node) {
75589 checkSpacingAroundFirstToken(node);
75590 const inToken = sourceCode.getTokenBefore(node.right, astUtils.isNotOpeningParenToken);
75591 const previousToken = sourceCode.getTokenBefore(inToken);
75592
75593 if (previousToken.type !== "PrivateIdentifier") {
75594 checkSpacingBefore(inToken);
75595 }
75596
75597 checkSpacingAfter(inToken);
75598 }
75599 /**
75600 * Reports `for` and `of` keywords of a given node if usage of spacing
75601 * around those keywords is invalid.
75602 * @param {ASTNode} node A node to report.
75603 * @returns {void}
75604 */
75605
75606
75607 function checkSpacingForForOfStatement(node) {
75608 if (node.await) {
75609 checkSpacingBefore(sourceCode.getFirstToken(node, 0));
75610 checkSpacingAfter(sourceCode.getFirstToken(node, 1));
75611 } else {
75612 checkSpacingAroundFirstToken(node);
75613 }
75614
75615 const ofToken = sourceCode.getTokenBefore(node.right, astUtils.isNotOpeningParenToken);
75616 const previousToken = sourceCode.getTokenBefore(ofToken);
75617
75618 if (previousToken.type !== "PrivateIdentifier") {
75619 checkSpacingBefore(ofToken);
75620 }
75621
75622 checkSpacingAfter(ofToken);
75623 }
75624 /**
75625 * Reports `import`, `export`, `as`, and `from` keywords of a given node if
75626 * usage of spacing around those keywords is invalid.
75627 *
75628 * This rule handles the `*` token in module declarations.
75629 *
75630 * import*as A from "./a"; /*error Expected space(s) after "import".
75631 * error Expected space(s) before "as".
75632 * @param {ASTNode} node A node to report.
75633 * @returns {void}
75634 */
75635
75636
75637 function checkSpacingForModuleDeclaration(node) {
75638 const firstToken = sourceCode.getFirstToken(node);
75639 checkSpacingBefore(firstToken, PREV_TOKEN_M);
75640 checkSpacingAfter(firstToken, NEXT_TOKEN_M);
75641
75642 if (node.type === "ExportDefaultDeclaration") {
75643 checkSpacingAround(sourceCode.getTokenAfter(firstToken));
75644 }
75645
75646 if (node.type === "ExportAllDeclaration" && node.exported) {
75647 const asToken = sourceCode.getTokenBefore(node.exported);
75648 checkSpacingBefore(asToken, PREV_TOKEN_M);
75649 }
75650
75651 if (node.source) {
75652 const fromToken = sourceCode.getTokenBefore(node.source);
75653 checkSpacingBefore(fromToken, PREV_TOKEN_M);
75654 checkSpacingAfter(fromToken, NEXT_TOKEN_M);
75655 }
75656 }
75657 /**
75658 * Reports `as` keyword of a given node if usage of spacing around this
75659 * keyword is invalid.
75660 * @param {ASTNode} node A node to report.
75661 * @returns {void}
75662 */
75663
75664
75665 function checkSpacingForImportNamespaceSpecifier(node) {
75666 const asToken = sourceCode.getFirstToken(node, 1);
75667 checkSpacingBefore(asToken, PREV_TOKEN_M);
75668 }
75669 /**
75670 * Reports `static`, `get`, and `set` keywords of a given node if usage of
75671 * spacing around those keywords is invalid.
75672 * @param {ASTNode} node A node to report.
75673 * @throws {Error} If unable to find token get, set, or async beside method name.
75674 * @returns {void}
75675 */
75676
75677
75678 function checkSpacingForProperty(node) {
75679 if (node.static) {
75680 checkSpacingAroundFirstToken(node);
75681 }
75682
75683 if (node.kind === "get" || node.kind === "set" || (node.method || node.type === "MethodDefinition") && node.value.async) {
75684 const token = sourceCode.getTokenBefore(node.key, tok => {
75685 switch (tok.value) {
75686 case "get":
75687 case "set":
75688 case "async":
75689 return true;
75690
75691 default:
75692 return false;
75693 }
75694 });
75695
75696 if (!token) {
75697 throw new Error("Failed to find token get, set, or async beside method name");
75698 }
75699
75700 checkSpacingAround(token);
75701 }
75702 }
75703 /**
75704 * Reports `await` keyword of a given node if usage of spacing before
75705 * this keyword is invalid.
75706 * @param {ASTNode} node A node to report.
75707 * @returns {void}
75708 */
75709
75710
75711 function checkSpacingForAwaitExpression(node) {
75712 checkSpacingBefore(sourceCode.getFirstToken(node));
75713 }
75714
75715 return {
75716 // Statements
75717 DebuggerStatement: checkSpacingAroundFirstToken,
75718 WithStatement: checkSpacingAroundFirstToken,
75719 // Statements - Control flow
75720 BreakStatement: checkSpacingAroundFirstToken,
75721 ContinueStatement: checkSpacingAroundFirstToken,
75722 ReturnStatement: checkSpacingAroundFirstToken,
75723 ThrowStatement: checkSpacingAroundFirstToken,
75724 TryStatement: checkSpacingForTryStatement,
75725 // Statements - Choice
75726 IfStatement: checkSpacingForIfStatement,
75727 SwitchStatement: checkSpacingAroundFirstToken,
75728 SwitchCase: checkSpacingAroundFirstToken,
75729 // Statements - Loops
75730 DoWhileStatement: checkSpacingForDoWhileStatement,
75731 ForInStatement: checkSpacingForForInStatement,
75732 ForOfStatement: checkSpacingForForOfStatement,
75733 ForStatement: checkSpacingAroundFirstToken,
75734 WhileStatement: checkSpacingAroundFirstToken,
75735 // Statements - Declarations
75736 ClassDeclaration: checkSpacingForClass,
75737 ExportNamedDeclaration: checkSpacingForModuleDeclaration,
75738 ExportDefaultDeclaration: checkSpacingForModuleDeclaration,
75739 ExportAllDeclaration: checkSpacingForModuleDeclaration,
75740 FunctionDeclaration: checkSpacingForFunction,
75741 ImportDeclaration: checkSpacingForModuleDeclaration,
75742 VariableDeclaration: checkSpacingAroundFirstToken,
75743 // Expressions
75744 ArrowFunctionExpression: checkSpacingForFunction,
75745 AwaitExpression: checkSpacingForAwaitExpression,
75746 ClassExpression: checkSpacingForClass,
75747 FunctionExpression: checkSpacingForFunction,
75748 NewExpression: checkSpacingBeforeFirstToken,
75749 Super: checkSpacingBeforeFirstToken,
75750 ThisExpression: checkSpacingBeforeFirstToken,
75751 UnaryExpression: checkSpacingBeforeFirstToken,
75752 YieldExpression: checkSpacingBeforeFirstToken,
75753 // Others
75754 ImportNamespaceSpecifier: checkSpacingForImportNamespaceSpecifier,
75755 MethodDefinition: checkSpacingForProperty,
75756 PropertyDefinition: checkSpacingForProperty,
75757 StaticBlock: checkSpacingAroundFirstToken,
75758 Property: checkSpacingForProperty,
75759
75760 // To avoid conflicts with `space-infix-ops`, e.g. `a > this.b`
75761 "BinaryExpression[operator='>']"(node) {
75762 const operatorToken = sourceCode.getTokenBefore(node.right, astUtils.isNotOpeningParenToken);
75763 tokensToIgnore.add(operatorToken);
75764 }
75765
75766 };
75767 }
75768
75769 };
75770
75771 /***/ }),
75772 /* 611 */
75773 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
75774
75775 "use strict";
75776 /**
75777 * @fileoverview Rule to enforce the position of line comments
75778 * @author Alberto Rodríguez
75779 */
75780
75781
75782 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
75783 // Rule Definition
75784 //------------------------------------------------------------------------------
75785
75786
75787 module.exports = {
75788 meta: {
75789 type: "layout",
75790 docs: {
75791 description: "enforce position of line comments",
75792 recommended: false,
75793 url: "https://eslint.org/docs/rules/line-comment-position"
75794 },
75795 schema: [{
75796 oneOf: [{
75797 enum: ["above", "beside"]
75798 }, {
75799 type: "object",
75800 properties: {
75801 position: {
75802 enum: ["above", "beside"]
75803 },
75804 ignorePattern: {
75805 type: "string"
75806 },
75807 applyDefaultPatterns: {
75808 type: "boolean"
75809 },
75810 applyDefaultIgnorePatterns: {
75811 type: "boolean"
75812 }
75813 },
75814 additionalProperties: false
75815 }]
75816 }],
75817 messages: {
75818 above: "Expected comment to be above code.",
75819 beside: "Expected comment to be beside code."
75820 }
75821 },
75822
75823 create(context) {
75824 const options = context.options[0];
75825 let above,
75826 ignorePattern,
75827 applyDefaultIgnorePatterns = true;
75828
75829 if (!options || typeof options === "string") {
75830 above = !options || options === "above";
75831 } else {
75832 above = !options.position || options.position === "above";
75833 ignorePattern = options.ignorePattern;
75834
75835 if (Object.prototype.hasOwnProperty.call(options, "applyDefaultIgnorePatterns")) {
75836 applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns;
75837 } else {
75838 applyDefaultIgnorePatterns = options.applyDefaultPatterns !== false;
75839 }
75840 }
75841
75842 const defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN;
75843 const fallThroughRegExp = /^\s*falls?\s?through/u;
75844 const customIgnoreRegExp = new RegExp(ignorePattern, "u");
75845 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
75846 // Public
75847 //--------------------------------------------------------------------------
75848
75849 return {
75850 Program() {
75851 const comments = sourceCode.getAllComments();
75852 comments.filter(token => token.type === "Line").forEach(node => {
75853 if (applyDefaultIgnorePatterns && (defaultIgnoreRegExp.test(node.value) || fallThroughRegExp.test(node.value))) {
75854 return;
75855 }
75856
75857 if (ignorePattern && customIgnoreRegExp.test(node.value)) {
75858 return;
75859 }
75860
75861 const previous = sourceCode.getTokenBefore(node, {
75862 includeComments: true
75863 });
75864 const isOnSameLine = previous && previous.loc.end.line === node.loc.start.line;
75865
75866 if (above) {
75867 if (isOnSameLine) {
75868 context.report({
75869 node,
75870 messageId: "above"
75871 });
75872 }
75873 } else {
75874 if (!isOnSameLine) {
75875 context.report({
75876 node,
75877 messageId: "beside"
75878 });
75879 }
75880 }
75881 });
75882 }
75883
75884 };
75885 }
75886
75887 };
75888
75889 /***/ }),
75890 /* 612 */
75891 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
75892
75893 "use strict";
75894 /**
75895 * @fileoverview Rule to enforce a single linebreak style.
75896 * @author Erik Mueller
75897 */
75898 //------------------------------------------------------------------------------
75899 // Requirements
75900 //------------------------------------------------------------------------------
75901
75902 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
75903 // Rule Definition
75904 //------------------------------------------------------------------------------
75905
75906
75907 module.exports = {
75908 meta: {
75909 type: "layout",
75910 docs: {
75911 description: "enforce consistent linebreak style",
75912 recommended: false,
75913 url: "https://eslint.org/docs/rules/linebreak-style"
75914 },
75915 fixable: "whitespace",
75916 schema: [{
75917 enum: ["unix", "windows"]
75918 }],
75919 messages: {
75920 expectedLF: "Expected linebreaks to be 'LF' but found 'CRLF'.",
75921 expectedCRLF: "Expected linebreaks to be 'CRLF' but found 'LF'."
75922 }
75923 },
75924
75925 create(context) {
75926 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
75927 // Helpers
75928 //--------------------------------------------------------------------------
75929
75930 /**
75931 * Builds a fix function that replaces text at the specified range in the source text.
75932 * @param {int[]} range The range to replace
75933 * @param {string} text The text to insert.
75934 * @returns {Function} Fixer function
75935 * @private
75936 */
75937
75938 function createFix(range, text) {
75939 return function (fixer) {
75940 return fixer.replaceTextRange(range, text);
75941 };
75942 } //--------------------------------------------------------------------------
75943 // Public
75944 //--------------------------------------------------------------------------
75945
75946
75947 return {
75948 Program: function checkForLinebreakStyle(node) {
75949 const linebreakStyle = context.options[0] || "unix",
75950 expectedLF = linebreakStyle === "unix",
75951 expectedLFChars = expectedLF ? "\n" : "\r\n",
75952 source = sourceCode.getText(),
75953 pattern = astUtils.createGlobalLinebreakMatcher();
75954 let match;
75955 let i = 0;
75956
75957 while ((match = pattern.exec(source)) !== null) {
75958 i++;
75959
75960 if (match[0] === expectedLFChars) {
75961 continue;
75962 }
75963
75964 const index = match.index;
75965 const range = [index, index + match[0].length];
75966 context.report({
75967 node,
75968 loc: {
75969 start: {
75970 line: i,
75971 column: sourceCode.lines[i - 1].length
75972 },
75973 end: {
75974 line: i + 1,
75975 column: 0
75976 }
75977 },
75978 messageId: expectedLF ? "expectedLF" : "expectedCRLF",
75979 fix: createFix(range, expectedLFChars)
75980 });
75981 }
75982 }
75983 };
75984 }
75985
75986 };
75987
75988 /***/ }),
75989 /* 613 */
75990 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
75991
75992 "use strict";
75993 /**
75994 * @fileoverview Enforces empty lines around comments.
75995 * @author Jamund Ferguson
75996 */
75997 //------------------------------------------------------------------------------
75998 // Requirements
75999 //------------------------------------------------------------------------------
76000
76001 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
76002 // Helpers
76003 //------------------------------------------------------------------------------
76004
76005 /**
76006 * Return an array with with any line numbers that are empty.
76007 * @param {Array} lines An array of each line of the file.
76008 * @returns {Array} An array of line numbers.
76009 */
76010
76011
76012 function getEmptyLineNums(lines) {
76013 const emptyLines = lines.map((line, i) => ({
76014 code: line.trim(),
76015 num: i + 1
76016 })).filter(line => !line.code).map(line => line.num);
76017 return emptyLines;
76018 }
76019 /**
76020 * Return an array with with any line numbers that contain comments.
76021 * @param {Array} comments An array of comment tokens.
76022 * @returns {Array} An array of line numbers.
76023 */
76024
76025
76026 function getCommentLineNums(comments) {
76027 const lines = [];
76028 comments.forEach(token => {
76029 const start = token.loc.start.line;
76030 const end = token.loc.end.line;
76031 lines.push(start, end);
76032 });
76033 return lines;
76034 } //------------------------------------------------------------------------------
76035 // Rule Definition
76036 //------------------------------------------------------------------------------
76037
76038
76039 module.exports = {
76040 meta: {
76041 type: "layout",
76042 docs: {
76043 description: "require empty lines around comments",
76044 recommended: false,
76045 url: "https://eslint.org/docs/rules/lines-around-comment"
76046 },
76047 fixable: "whitespace",
76048 schema: [{
76049 type: "object",
76050 properties: {
76051 beforeBlockComment: {
76052 type: "boolean",
76053 default: true
76054 },
76055 afterBlockComment: {
76056 type: "boolean",
76057 default: false
76058 },
76059 beforeLineComment: {
76060 type: "boolean",
76061 default: false
76062 },
76063 afterLineComment: {
76064 type: "boolean",
76065 default: false
76066 },
76067 allowBlockStart: {
76068 type: "boolean",
76069 default: false
76070 },
76071 allowBlockEnd: {
76072 type: "boolean",
76073 default: false
76074 },
76075 allowClassStart: {
76076 type: "boolean"
76077 },
76078 allowClassEnd: {
76079 type: "boolean"
76080 },
76081 allowObjectStart: {
76082 type: "boolean"
76083 },
76084 allowObjectEnd: {
76085 type: "boolean"
76086 },
76087 allowArrayStart: {
76088 type: "boolean"
76089 },
76090 allowArrayEnd: {
76091 type: "boolean"
76092 },
76093 ignorePattern: {
76094 type: "string"
76095 },
76096 applyDefaultIgnorePatterns: {
76097 type: "boolean"
76098 }
76099 },
76100 additionalProperties: false
76101 }],
76102 messages: {
76103 after: "Expected line after comment.",
76104 before: "Expected line before comment."
76105 }
76106 },
76107
76108 create(context) {
76109 const options = Object.assign({}, context.options[0]);
76110 const ignorePattern = options.ignorePattern;
76111 const defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN;
76112 const customIgnoreRegExp = new RegExp(ignorePattern, "u");
76113 const applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false;
76114 options.beforeBlockComment = typeof options.beforeBlockComment !== "undefined" ? options.beforeBlockComment : true;
76115 const sourceCode = context.getSourceCode();
76116 const lines = sourceCode.lines,
76117 numLines = lines.length + 1,
76118 comments = sourceCode.getAllComments(),
76119 commentLines = getCommentLineNums(comments),
76120 emptyLines = getEmptyLineNums(lines),
76121 commentAndEmptyLines = commentLines.concat(emptyLines);
76122 /**
76123 * Returns whether or not comments are on lines starting with or ending with code
76124 * @param {token} token The comment token to check.
76125 * @returns {boolean} True if the comment is not alone.
76126 */
76127
76128 function codeAroundComment(token) {
76129 let currentToken = token;
76130
76131 do {
76132 currentToken = sourceCode.getTokenBefore(currentToken, {
76133 includeComments: true
76134 });
76135 } while (currentToken && astUtils.isCommentToken(currentToken));
76136
76137 if (currentToken && astUtils.isTokenOnSameLine(currentToken, token)) {
76138 return true;
76139 }
76140
76141 currentToken = token;
76142
76143 do {
76144 currentToken = sourceCode.getTokenAfter(currentToken, {
76145 includeComments: true
76146 });
76147 } while (currentToken && astUtils.isCommentToken(currentToken));
76148
76149 if (currentToken && astUtils.isTokenOnSameLine(token, currentToken)) {
76150 return true;
76151 }
76152
76153 return false;
76154 }
76155 /**
76156 * Returns whether or not comments are inside a node type or not.
76157 * @param {ASTNode} parent The Comment parent node.
76158 * @param {string} nodeType The parent type to check against.
76159 * @returns {boolean} True if the comment is inside nodeType.
76160 */
76161
76162
76163 function isParentNodeType(parent, nodeType) {
76164 return parent.type === nodeType || parent.body && parent.body.type === nodeType || parent.consequent && parent.consequent.type === nodeType;
76165 }
76166 /**
76167 * Returns the parent node that contains the given token.
76168 * @param {token} token The token to check.
76169 * @returns {ASTNode|null} The parent node that contains the given token.
76170 */
76171
76172
76173 function getParentNodeOfToken(token) {
76174 const node = sourceCode.getNodeByRangeIndex(token.range[0]);
76175 /*
76176 * For the purpose of this rule, the comment token is in a `StaticBlock` node only
76177 * if it's inside the braces of that `StaticBlock` node.
76178 *
76179 * Example where this function returns `null`:
76180 *
76181 * static
76182 * // comment
76183 * {
76184 * }
76185 *
76186 * Example where this function returns `StaticBlock` node:
76187 *
76188 * static
76189 * {
76190 * // comment
76191 * }
76192 *
76193 */
76194
76195 if (node && node.type === "StaticBlock") {
76196 const openingBrace = sourceCode.getFirstToken(node, {
76197 skip: 1
76198 }); // skip the `static` token
76199
76200 return token.range[0] >= openingBrace.range[0] ? node : null;
76201 }
76202
76203 return node;
76204 }
76205 /**
76206 * Returns whether or not comments are at the parent start or not.
76207 * @param {token} token The Comment token.
76208 * @param {string} nodeType The parent type to check against.
76209 * @returns {boolean} True if the comment is at parent start.
76210 */
76211
76212
76213 function isCommentAtParentStart(token, nodeType) {
76214 const parent = getParentNodeOfToken(token);
76215
76216 if (parent && isParentNodeType(parent, nodeType)) {
76217 const parentStartNodeOrToken = parent.type === "StaticBlock" ? sourceCode.getFirstToken(parent, {
76218 skip: 1
76219 }) // opening brace of the static block
76220 : parent;
76221 return token.loc.start.line - parentStartNodeOrToken.loc.start.line === 1;
76222 }
76223
76224 return false;
76225 }
76226 /**
76227 * Returns whether or not comments are at the parent end or not.
76228 * @param {token} token The Comment token.
76229 * @param {string} nodeType The parent type to check against.
76230 * @returns {boolean} True if the comment is at parent end.
76231 */
76232
76233
76234 function isCommentAtParentEnd(token, nodeType) {
76235 const parent = getParentNodeOfToken(token);
76236 return !!parent && isParentNodeType(parent, nodeType) && parent.loc.end.line - token.loc.end.line === 1;
76237 }
76238 /**
76239 * Returns whether or not comments are at the block start or not.
76240 * @param {token} token The Comment token.
76241 * @returns {boolean} True if the comment is at block start.
76242 */
76243
76244
76245 function isCommentAtBlockStart(token) {
76246 return isCommentAtParentStart(token, "ClassBody") || isCommentAtParentStart(token, "BlockStatement") || isCommentAtParentStart(token, "StaticBlock") || isCommentAtParentStart(token, "SwitchCase");
76247 }
76248 /**
76249 * Returns whether or not comments are at the block end or not.
76250 * @param {token} token The Comment token.
76251 * @returns {boolean} True if the comment is at block end.
76252 */
76253
76254
76255 function isCommentAtBlockEnd(token) {
76256 return isCommentAtParentEnd(token, "ClassBody") || isCommentAtParentEnd(token, "BlockStatement") || isCommentAtParentEnd(token, "StaticBlock") || isCommentAtParentEnd(token, "SwitchCase") || isCommentAtParentEnd(token, "SwitchStatement");
76257 }
76258 /**
76259 * Returns whether or not comments are at the class start or not.
76260 * @param {token} token The Comment token.
76261 * @returns {boolean} True if the comment is at class start.
76262 */
76263
76264
76265 function isCommentAtClassStart(token) {
76266 return isCommentAtParentStart(token, "ClassBody");
76267 }
76268 /**
76269 * Returns whether or not comments are at the class end or not.
76270 * @param {token} token The Comment token.
76271 * @returns {boolean} True if the comment is at class end.
76272 */
76273
76274
76275 function isCommentAtClassEnd(token) {
76276 return isCommentAtParentEnd(token, "ClassBody");
76277 }
76278 /**
76279 * Returns whether or not comments are at the object start or not.
76280 * @param {token} token The Comment token.
76281 * @returns {boolean} True if the comment is at object start.
76282 */
76283
76284
76285 function isCommentAtObjectStart(token) {
76286 return isCommentAtParentStart(token, "ObjectExpression") || isCommentAtParentStart(token, "ObjectPattern");
76287 }
76288 /**
76289 * Returns whether or not comments are at the object end or not.
76290 * @param {token} token The Comment token.
76291 * @returns {boolean} True if the comment is at object end.
76292 */
76293
76294
76295 function isCommentAtObjectEnd(token) {
76296 return isCommentAtParentEnd(token, "ObjectExpression") || isCommentAtParentEnd(token, "ObjectPattern");
76297 }
76298 /**
76299 * Returns whether or not comments are at the array start or not.
76300 * @param {token} token The Comment token.
76301 * @returns {boolean} True if the comment is at array start.
76302 */
76303
76304
76305 function isCommentAtArrayStart(token) {
76306 return isCommentAtParentStart(token, "ArrayExpression") || isCommentAtParentStart(token, "ArrayPattern");
76307 }
76308 /**
76309 * Returns whether or not comments are at the array end or not.
76310 * @param {token} token The Comment token.
76311 * @returns {boolean} True if the comment is at array end.
76312 */
76313
76314
76315 function isCommentAtArrayEnd(token) {
76316 return isCommentAtParentEnd(token, "ArrayExpression") || isCommentAtParentEnd(token, "ArrayPattern");
76317 }
76318 /**
76319 * Checks if a comment token has lines around it (ignores inline comments)
76320 * @param {token} token The Comment token.
76321 * @param {Object} opts Options to determine the newline.
76322 * @param {boolean} opts.after Should have a newline after this line.
76323 * @param {boolean} opts.before Should have a newline before this line.
76324 * @returns {void}
76325 */
76326
76327
76328 function checkForEmptyLine(token, opts) {
76329 if (applyDefaultIgnorePatterns && defaultIgnoreRegExp.test(token.value)) {
76330 return;
76331 }
76332
76333 if (ignorePattern && customIgnoreRegExp.test(token.value)) {
76334 return;
76335 }
76336
76337 let after = opts.after,
76338 before = opts.before;
76339 const prevLineNum = token.loc.start.line - 1,
76340 nextLineNum = token.loc.end.line + 1,
76341 commentIsNotAlone = codeAroundComment(token);
76342 const blockStartAllowed = options.allowBlockStart && isCommentAtBlockStart(token) && !(options.allowClassStart === false && isCommentAtClassStart(token)),
76343 blockEndAllowed = options.allowBlockEnd && isCommentAtBlockEnd(token) && !(options.allowClassEnd === false && isCommentAtClassEnd(token)),
76344 classStartAllowed = options.allowClassStart && isCommentAtClassStart(token),
76345 classEndAllowed = options.allowClassEnd && isCommentAtClassEnd(token),
76346 objectStartAllowed = options.allowObjectStart && isCommentAtObjectStart(token),
76347 objectEndAllowed = options.allowObjectEnd && isCommentAtObjectEnd(token),
76348 arrayStartAllowed = options.allowArrayStart && isCommentAtArrayStart(token),
76349 arrayEndAllowed = options.allowArrayEnd && isCommentAtArrayEnd(token);
76350 const exceptionStartAllowed = blockStartAllowed || classStartAllowed || objectStartAllowed || arrayStartAllowed;
76351 const exceptionEndAllowed = blockEndAllowed || classEndAllowed || objectEndAllowed || arrayEndAllowed; // ignore top of the file and bottom of the file
76352
76353 if (prevLineNum < 1) {
76354 before = false;
76355 }
76356
76357 if (nextLineNum >= numLines) {
76358 after = false;
76359 } // we ignore all inline comments
76360
76361
76362 if (commentIsNotAlone) {
76363 return;
76364 }
76365
76366 const previousTokenOrComment = sourceCode.getTokenBefore(token, {
76367 includeComments: true
76368 });
76369 const nextTokenOrComment = sourceCode.getTokenAfter(token, {
76370 includeComments: true
76371 }); // check for newline before
76372
76373 if (!exceptionStartAllowed && before && !commentAndEmptyLines.includes(prevLineNum) && !(astUtils.isCommentToken(previousTokenOrComment) && astUtils.isTokenOnSameLine(previousTokenOrComment, token))) {
76374 const lineStart = token.range[0] - token.loc.start.column;
76375 const range = [lineStart, lineStart];
76376 context.report({
76377 node: token,
76378 messageId: "before",
76379
76380 fix(fixer) {
76381 return fixer.insertTextBeforeRange(range, "\n");
76382 }
76383
76384 });
76385 } // check for newline after
76386
76387
76388 if (!exceptionEndAllowed && after && !commentAndEmptyLines.includes(nextLineNum) && !(astUtils.isCommentToken(nextTokenOrComment) && astUtils.isTokenOnSameLine(token, nextTokenOrComment))) {
76389 context.report({
76390 node: token,
76391 messageId: "after",
76392
76393 fix(fixer) {
76394 return fixer.insertTextAfter(token, "\n");
76395 }
76396
76397 });
76398 }
76399 } //--------------------------------------------------------------------------
76400 // Public
76401 //--------------------------------------------------------------------------
76402
76403
76404 return {
76405 Program() {
76406 comments.forEach(token => {
76407 if (token.type === "Line") {
76408 if (options.beforeLineComment || options.afterLineComment) {
76409 checkForEmptyLine(token, {
76410 after: options.afterLineComment,
76411 before: options.beforeLineComment
76412 });
76413 }
76414 } else if (token.type === "Block") {
76415 if (options.beforeBlockComment || options.afterBlockComment) {
76416 checkForEmptyLine(token, {
76417 after: options.afterBlockComment,
76418 before: options.beforeBlockComment
76419 });
76420 }
76421 }
76422 });
76423 }
76424
76425 };
76426 }
76427
76428 };
76429
76430 /***/ }),
76431 /* 614 */
76432 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
76433
76434 "use strict";
76435 /**
76436 * @fileoverview Require or disallow newlines around directives.
76437 * @author Kai Cataldo
76438 * @deprecated in ESLint v4.0.0
76439 */
76440
76441
76442 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
76443 // Rule Definition
76444 //------------------------------------------------------------------------------
76445
76446
76447 module.exports = {
76448 meta: {
76449 type: "layout",
76450 docs: {
76451 description: "require or disallow newlines around directives",
76452 recommended: false,
76453 url: "https://eslint.org/docs/rules/lines-around-directive"
76454 },
76455 schema: [{
76456 oneOf: [{
76457 enum: ["always", "never"]
76458 }, {
76459 type: "object",
76460 properties: {
76461 before: {
76462 enum: ["always", "never"]
76463 },
76464 after: {
76465 enum: ["always", "never"]
76466 }
76467 },
76468 additionalProperties: false,
76469 minProperties: 2
76470 }]
76471 }],
76472 fixable: "whitespace",
76473 messages: {
76474 expected: "Expected newline {{location}} \"{{value}}\" directive.",
76475 unexpected: "Unexpected newline {{location}} \"{{value}}\" directive."
76476 },
76477 deprecated: true,
76478 replacedBy: ["padding-line-between-statements"]
76479 },
76480
76481 create(context) {
76482 const sourceCode = context.getSourceCode();
76483 const config = context.options[0] || "always";
76484 const expectLineBefore = typeof config === "string" ? config : config.before;
76485 const expectLineAfter = typeof config === "string" ? config : config.after; //--------------------------------------------------------------------------
76486 // Helpers
76487 //--------------------------------------------------------------------------
76488
76489 /**
76490 * Check if node is preceded by a blank newline.
76491 * @param {ASTNode} node Node to check.
76492 * @returns {boolean} Whether or not the passed in node is preceded by a blank newline.
76493 */
76494
76495 function hasNewlineBefore(node) {
76496 const tokenBefore = sourceCode.getTokenBefore(node, {
76497 includeComments: true
76498 });
76499 const tokenLineBefore = tokenBefore ? tokenBefore.loc.end.line : 0;
76500 return node.loc.start.line - tokenLineBefore >= 2;
76501 }
76502 /**
76503 * Gets the last token of a node that is on the same line as the rest of the node.
76504 * This will usually be the last token of the node, but it will be the second-to-last token if the node has a trailing
76505 * semicolon on a different line.
76506 * @param {ASTNode} node A directive node
76507 * @returns {Token} The last token of the node on the line
76508 */
76509
76510
76511 function getLastTokenOnLine(node) {
76512 const lastToken = sourceCode.getLastToken(node);
76513 const secondToLastToken = sourceCode.getTokenBefore(lastToken);
76514 return astUtils.isSemicolonToken(lastToken) && lastToken.loc.start.line > secondToLastToken.loc.end.line ? secondToLastToken : lastToken;
76515 }
76516 /**
76517 * Check if node is followed by a blank newline.
76518 * @param {ASTNode} node Node to check.
76519 * @returns {boolean} Whether or not the passed in node is followed by a blank newline.
76520 */
76521
76522
76523 function hasNewlineAfter(node) {
76524 const lastToken = getLastTokenOnLine(node);
76525 const tokenAfter = sourceCode.getTokenAfter(lastToken, {
76526 includeComments: true
76527 });
76528 return tokenAfter.loc.start.line - lastToken.loc.end.line >= 2;
76529 }
76530 /**
76531 * Report errors for newlines around directives.
76532 * @param {ASTNode} node Node to check.
76533 * @param {string} location Whether the error was found before or after the directive.
76534 * @param {boolean} expected Whether or not a newline was expected or unexpected.
76535 * @returns {void}
76536 */
76537
76538
76539 function reportError(node, location, expected) {
76540 context.report({
76541 node,
76542 messageId: expected ? "expected" : "unexpected",
76543 data: {
76544 value: node.expression.value,
76545 location
76546 },
76547
76548 fix(fixer) {
76549 const lastToken = getLastTokenOnLine(node);
76550
76551 if (expected) {
76552 return location === "before" ? fixer.insertTextBefore(node, "\n") : fixer.insertTextAfter(lastToken, "\n");
76553 }
76554
76555 return fixer.removeRange(location === "before" ? [node.range[0] - 1, node.range[0]] : [lastToken.range[1], lastToken.range[1] + 1]);
76556 }
76557
76558 });
76559 }
76560 /**
76561 * Check lines around directives in node
76562 * @param {ASTNode} node node to check
76563 * @returns {void}
76564 */
76565
76566
76567 function checkDirectives(node) {
76568 const directives = astUtils.getDirectivePrologue(node);
76569
76570 if (!directives.length) {
76571 return;
76572 }
76573
76574 const firstDirective = directives[0];
76575 const leadingComments = sourceCode.getCommentsBefore(firstDirective);
76576 /*
76577 * Only check before the first directive if it is preceded by a comment or if it is at the top of
76578 * the file and expectLineBefore is set to "never". This is to not force a newline at the top of
76579 * the file if there are no comments as well as for compatibility with padded-blocks.
76580 */
76581
76582 if (leadingComments.length) {
76583 if (expectLineBefore === "always" && !hasNewlineBefore(firstDirective)) {
76584 reportError(firstDirective, "before", true);
76585 }
76586
76587 if (expectLineBefore === "never" && hasNewlineBefore(firstDirective)) {
76588 reportError(firstDirective, "before", false);
76589 }
76590 } else if (node.type === "Program" && expectLineBefore === "never" && !leadingComments.length && hasNewlineBefore(firstDirective)) {
76591 reportError(firstDirective, "before", false);
76592 }
76593
76594 const lastDirective = directives[directives.length - 1];
76595 const statements = node.type === "Program" ? node.body : node.body.body;
76596 /*
76597 * Do not check after the last directive if the body only
76598 * contains a directive prologue and isn't followed by a comment to ensure
76599 * this rule behaves well with padded-blocks.
76600 */
76601
76602 if (lastDirective === statements[statements.length - 1] && !lastDirective.trailingComments) {
76603 return;
76604 }
76605
76606 if (expectLineAfter === "always" && !hasNewlineAfter(lastDirective)) {
76607 reportError(lastDirective, "after", true);
76608 }
76609
76610 if (expectLineAfter === "never" && hasNewlineAfter(lastDirective)) {
76611 reportError(lastDirective, "after", false);
76612 }
76613 } //--------------------------------------------------------------------------
76614 // Public
76615 //--------------------------------------------------------------------------
76616
76617
76618 return {
76619 Program: checkDirectives,
76620 FunctionDeclaration: checkDirectives,
76621 FunctionExpression: checkDirectives,
76622 ArrowFunctionExpression: checkDirectives
76623 };
76624 }
76625
76626 };
76627
76628 /***/ }),
76629 /* 615 */
76630 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
76631
76632 "use strict";
76633 /**
76634 * @fileoverview Rule to check empty newline between class members
76635 * @author 薛定谔的猫<hh_2013@foxmail.com>
76636 */
76637 //------------------------------------------------------------------------------
76638 // Requirements
76639 //------------------------------------------------------------------------------
76640
76641 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
76642 // Rule Definition
76643 //------------------------------------------------------------------------------
76644
76645
76646 module.exports = {
76647 meta: {
76648 type: "layout",
76649 docs: {
76650 description: "require or disallow an empty line between class members",
76651 recommended: false,
76652 url: "https://eslint.org/docs/rules/lines-between-class-members"
76653 },
76654 fixable: "whitespace",
76655 schema: [{
76656 enum: ["always", "never"]
76657 }, {
76658 type: "object",
76659 properties: {
76660 exceptAfterSingleLine: {
76661 type: "boolean",
76662 default: false
76663 }
76664 },
76665 additionalProperties: false
76666 }],
76667 messages: {
76668 never: "Unexpected blank line between class members.",
76669 always: "Expected blank line between class members."
76670 }
76671 },
76672
76673 create(context) {
76674 const options = [];
76675 options[0] = context.options[0] || "always";
76676 options[1] = context.options[1] || {
76677 exceptAfterSingleLine: false
76678 };
76679 const sourceCode = context.getSourceCode();
76680 /**
76681 * Gets a pair of tokens that should be used to check lines between two class member nodes.
76682 *
76683 * In most cases, this returns the very last token of the current node and
76684 * the very first token of the next node.
76685 * For example:
76686 *
76687 * class C {
76688 * x = 1; // curLast: `;` nextFirst: `in`
76689 * in = 2
76690 * }
76691 *
76692 * There is only one exception. If the given node ends with a semicolon, and it looks like
76693 * a semicolon-less style's semicolon - one that is not on the same line as the preceding
76694 * token, but is on the line where the next class member starts - this returns the preceding
76695 * token and the semicolon as boundary tokens.
76696 * For example:
76697 *
76698 * class C {
76699 * x = 1 // curLast: `1` nextFirst: `;`
76700 * ;in = 2
76701 * }
76702 * When determining the desired layout of the code, we should treat this semicolon as
76703 * a part of the next class member node instead of the one it technically belongs to.
76704 * @param {ASTNode} curNode Current class member node.
76705 * @param {ASTNode} nextNode Next class member node.
76706 * @returns {Token} The actual last token of `node`.
76707 * @private
76708 */
76709
76710 function getBoundaryTokens(curNode, nextNode) {
76711 const lastToken = sourceCode.getLastToken(curNode);
76712 const prevToken = sourceCode.getTokenBefore(lastToken);
76713 const nextToken = sourceCode.getFirstToken(nextNode); // skip possible lone `;` between nodes
76714
76715 const isSemicolonLessStyle = astUtils.isSemicolonToken(lastToken) && !astUtils.isTokenOnSameLine(prevToken, lastToken) && astUtils.isTokenOnSameLine(lastToken, nextToken);
76716 return isSemicolonLessStyle ? {
76717 curLast: prevToken,
76718 nextFirst: lastToken
76719 } : {
76720 curLast: lastToken,
76721 nextFirst: nextToken
76722 };
76723 }
76724 /**
76725 * Return the last token among the consecutive tokens that have no exceed max line difference in between, before the first token in the next member.
76726 * @param {Token} prevLastToken The last token in the previous member node.
76727 * @param {Token} nextFirstToken The first token in the next member node.
76728 * @param {number} maxLine The maximum number of allowed line difference between consecutive tokens.
76729 * @returns {Token} The last token among the consecutive tokens.
76730 */
76731
76732
76733 function findLastConsecutiveTokenAfter(prevLastToken, nextFirstToken, maxLine) {
76734 const after = sourceCode.getTokenAfter(prevLastToken, {
76735 includeComments: true
76736 });
76737
76738 if (after !== nextFirstToken && after.loc.start.line - prevLastToken.loc.end.line <= maxLine) {
76739 return findLastConsecutiveTokenAfter(after, nextFirstToken, maxLine);
76740 }
76741
76742 return prevLastToken;
76743 }
76744 /**
76745 * Return the first token among the consecutive tokens that have no exceed max line difference in between, after the last token in the previous member.
76746 * @param {Token} nextFirstToken The first token in the next member node.
76747 * @param {Token} prevLastToken The last token in the previous member node.
76748 * @param {number} maxLine The maximum number of allowed line difference between consecutive tokens.
76749 * @returns {Token} The first token among the consecutive tokens.
76750 */
76751
76752
76753 function findFirstConsecutiveTokenBefore(nextFirstToken, prevLastToken, maxLine) {
76754 const before = sourceCode.getTokenBefore(nextFirstToken, {
76755 includeComments: true
76756 });
76757
76758 if (before !== prevLastToken && nextFirstToken.loc.start.line - before.loc.end.line <= maxLine) {
76759 return findFirstConsecutiveTokenBefore(before, prevLastToken, maxLine);
76760 }
76761
76762 return nextFirstToken;
76763 }
76764 /**
76765 * Checks if there is a token or comment between two tokens.
76766 * @param {Token} before The token before.
76767 * @param {Token} after The token after.
76768 * @returns {boolean} True if there is a token or comment between two tokens.
76769 */
76770
76771
76772 function hasTokenOrCommentBetween(before, after) {
76773 return sourceCode.getTokensBetween(before, after, {
76774 includeComments: true
76775 }).length !== 0;
76776 }
76777
76778 return {
76779 ClassBody(node) {
76780 const body = node.body;
76781
76782 for (let i = 0; i < body.length - 1; i++) {
76783 const curFirst = sourceCode.getFirstToken(body[i]);
76784 const {
76785 curLast,
76786 nextFirst
76787 } = getBoundaryTokens(body[i], body[i + 1]);
76788 const isMulti = !astUtils.isTokenOnSameLine(curFirst, curLast);
76789 const skip = !isMulti && options[1].exceptAfterSingleLine;
76790 const beforePadding = findLastConsecutiveTokenAfter(curLast, nextFirst, 1);
76791 const afterPadding = findFirstConsecutiveTokenBefore(nextFirst, curLast, 1);
76792 const isPadded = afterPadding.loc.start.line - beforePadding.loc.end.line > 1;
76793 const hasTokenInPadding = hasTokenOrCommentBetween(beforePadding, afterPadding);
76794 const curLineLastToken = findLastConsecutiveTokenAfter(curLast, nextFirst, 0);
76795
76796 if (options[0] === "always" && !skip && !isPadded || options[0] === "never" && isPadded) {
76797 context.report({
76798 node: body[i + 1],
76799 messageId: isPadded ? "never" : "always",
76800
76801 fix(fixer) {
76802 if (hasTokenInPadding) {
76803 return null;
76804 }
76805
76806 return isPadded ? fixer.replaceTextRange([beforePadding.range[1], afterPadding.range[0]], "\n") : fixer.insertTextAfter(curLineLastToken, "\n");
76807 }
76808
76809 });
76810 }
76811 }
76812 }
76813
76814 };
76815 }
76816
76817 };
76818
76819 /***/ }),
76820 /* 616 */
76821 /***/ ((module) => {
76822
76823 "use strict";
76824 /**
76825 * @fileoverview Enforce a maximum number of classes per file
76826 * @author James Garbutt <https://github.com/43081j>
76827 */
76828 //------------------------------------------------------------------------------
76829 // Requirements
76830 //------------------------------------------------------------------------------
76831 //------------------------------------------------------------------------------
76832 // Rule Definition
76833 //------------------------------------------------------------------------------
76834
76835 module.exports = {
76836 meta: {
76837 type: "suggestion",
76838 docs: {
76839 description: "enforce a maximum number of classes per file",
76840 recommended: false,
76841 url: "https://eslint.org/docs/rules/max-classes-per-file"
76842 },
76843 schema: [{
76844 oneOf: [{
76845 type: "integer",
76846 minimum: 1
76847 }, {
76848 type: "object",
76849 properties: {
76850 ignoreExpressions: {
76851 type: "boolean"
76852 },
76853 max: {
76854 type: "integer",
76855 minimum: 1
76856 }
76857 },
76858 additionalProperties: false
76859 }]
76860 }],
76861 messages: {
76862 maximumExceeded: "File has too many classes ({{ classCount }}). Maximum allowed is {{ max }}."
76863 }
76864 },
76865
76866 create(context) {
76867 const [option = {}] = context.options;
76868 const [ignoreExpressions, max] = typeof option === "number" ? [false, option || 1] : [option.ignoreExpressions, option.max || 1];
76869 let classCount = 0;
76870 return {
76871 Program() {
76872 classCount = 0;
76873 },
76874
76875 "Program:exit"(node) {
76876 if (classCount > max) {
76877 context.report({
76878 node,
76879 messageId: "maximumExceeded",
76880 data: {
76881 classCount,
76882 max
76883 }
76884 });
76885 }
76886 },
76887
76888 "ClassDeclaration"() {
76889 classCount++;
76890 },
76891
76892 "ClassExpression"() {
76893 if (!ignoreExpressions) {
76894 classCount++;
76895 }
76896 }
76897
76898 };
76899 }
76900
76901 };
76902
76903 /***/ }),
76904 /* 617 */
76905 /***/ ((module) => {
76906
76907 "use strict";
76908 /**
76909 * @fileoverview A rule to set the maximum depth block can be nested in a function.
76910 * @author Ian Christian Myers
76911 */
76912 //------------------------------------------------------------------------------
76913 // Rule Definition
76914 //------------------------------------------------------------------------------
76915
76916 module.exports = {
76917 meta: {
76918 type: "suggestion",
76919 docs: {
76920 description: "enforce a maximum depth that blocks can be nested",
76921 recommended: false,
76922 url: "https://eslint.org/docs/rules/max-depth"
76923 },
76924 schema: [{
76925 oneOf: [{
76926 type: "integer",
76927 minimum: 0
76928 }, {
76929 type: "object",
76930 properties: {
76931 maximum: {
76932 type: "integer",
76933 minimum: 0
76934 },
76935 max: {
76936 type: "integer",
76937 minimum: 0
76938 }
76939 },
76940 additionalProperties: false
76941 }]
76942 }],
76943 messages: {
76944 tooDeeply: "Blocks are nested too deeply ({{depth}}). Maximum allowed is {{maxDepth}}."
76945 }
76946 },
76947
76948 create(context) {
76949 //--------------------------------------------------------------------------
76950 // Helpers
76951 //--------------------------------------------------------------------------
76952 const functionStack = [],
76953 option = context.options[0];
76954 let maxDepth = 4;
76955
76956 if (typeof option === "object" && (Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))) {
76957 maxDepth = option.maximum || option.max;
76958 }
76959
76960 if (typeof option === "number") {
76961 maxDepth = option;
76962 }
76963 /**
76964 * When parsing a new function, store it in our function stack
76965 * @returns {void}
76966 * @private
76967 */
76968
76969
76970 function startFunction() {
76971 functionStack.push(0);
76972 }
76973 /**
76974 * When parsing is done then pop out the reference
76975 * @returns {void}
76976 * @private
76977 */
76978
76979
76980 function endFunction() {
76981 functionStack.pop();
76982 }
76983 /**
76984 * Save the block and Evaluate the node
76985 * @param {ASTNode} node node to evaluate
76986 * @returns {void}
76987 * @private
76988 */
76989
76990
76991 function pushBlock(node) {
76992 const len = ++functionStack[functionStack.length - 1];
76993
76994 if (len > maxDepth) {
76995 context.report({
76996 node,
76997 messageId: "tooDeeply",
76998 data: {
76999 depth: len,
77000 maxDepth
77001 }
77002 });
77003 }
77004 }
77005 /**
77006 * Pop the saved block
77007 * @returns {void}
77008 * @private
77009 */
77010
77011
77012 function popBlock() {
77013 functionStack[functionStack.length - 1]--;
77014 } //--------------------------------------------------------------------------
77015 // Public API
77016 //--------------------------------------------------------------------------
77017
77018
77019 return {
77020 Program: startFunction,
77021 FunctionDeclaration: startFunction,
77022 FunctionExpression: startFunction,
77023 ArrowFunctionExpression: startFunction,
77024 StaticBlock: startFunction,
77025
77026 IfStatement(node) {
77027 if (node.parent.type !== "IfStatement") {
77028 pushBlock(node);
77029 }
77030 },
77031
77032 SwitchStatement: pushBlock,
77033 TryStatement: pushBlock,
77034 DoWhileStatement: pushBlock,
77035 WhileStatement: pushBlock,
77036 WithStatement: pushBlock,
77037 ForStatement: pushBlock,
77038 ForInStatement: pushBlock,
77039 ForOfStatement: pushBlock,
77040 "IfStatement:exit": popBlock,
77041 "SwitchStatement:exit": popBlock,
77042 "TryStatement:exit": popBlock,
77043 "DoWhileStatement:exit": popBlock,
77044 "WhileStatement:exit": popBlock,
77045 "WithStatement:exit": popBlock,
77046 "ForStatement:exit": popBlock,
77047 "ForInStatement:exit": popBlock,
77048 "ForOfStatement:exit": popBlock,
77049 "FunctionDeclaration:exit": endFunction,
77050 "FunctionExpression:exit": endFunction,
77051 "ArrowFunctionExpression:exit": endFunction,
77052 "StaticBlock:exit": endFunction,
77053 "Program:exit": endFunction
77054 };
77055 }
77056
77057 };
77058
77059 /***/ }),
77060 /* 618 */
77061 /***/ ((module) => {
77062
77063 "use strict";
77064 /**
77065 * @fileoverview Rule to check for max length on a line.
77066 * @author Matt DuVall <http://www.mattduvall.com>
77067 */
77068 //------------------------------------------------------------------------------
77069 // Constants
77070 //------------------------------------------------------------------------------
77071
77072 const OPTIONS_SCHEMA = {
77073 type: "object",
77074 properties: {
77075 code: {
77076 type: "integer",
77077 minimum: 0
77078 },
77079 comments: {
77080 type: "integer",
77081 minimum: 0
77082 },
77083 tabWidth: {
77084 type: "integer",
77085 minimum: 0
77086 },
77087 ignorePattern: {
77088 type: "string"
77089 },
77090 ignoreComments: {
77091 type: "boolean"
77092 },
77093 ignoreStrings: {
77094 type: "boolean"
77095 },
77096 ignoreUrls: {
77097 type: "boolean"
77098 },
77099 ignoreTemplateLiterals: {
77100 type: "boolean"
77101 },
77102 ignoreRegExpLiterals: {
77103 type: "boolean"
77104 },
77105 ignoreTrailingComments: {
77106 type: "boolean"
77107 }
77108 },
77109 additionalProperties: false
77110 };
77111 const OPTIONS_OR_INTEGER_SCHEMA = {
77112 anyOf: [OPTIONS_SCHEMA, {
77113 type: "integer",
77114 minimum: 0
77115 }]
77116 }; //------------------------------------------------------------------------------
77117 // Rule Definition
77118 //------------------------------------------------------------------------------
77119
77120 module.exports = {
77121 meta: {
77122 type: "layout",
77123 docs: {
77124 description: "enforce a maximum line length",
77125 recommended: false,
77126 url: "https://eslint.org/docs/rules/max-len"
77127 },
77128 schema: [OPTIONS_OR_INTEGER_SCHEMA, OPTIONS_OR_INTEGER_SCHEMA, OPTIONS_SCHEMA],
77129 messages: {
77130 max: "This line has a length of {{lineLength}}. Maximum allowed is {{maxLength}}.",
77131 maxComment: "This line has a comment length of {{lineLength}}. Maximum allowed is {{maxCommentLength}}."
77132 }
77133 },
77134
77135 create(context) {
77136 /*
77137 * Inspired by http://tools.ietf.org/html/rfc3986#appendix-B, however:
77138 * - They're matching an entire string that we know is a URI
77139 * - We're matching part of a string where we think there *might* be a URL
77140 * - We're only concerned about URLs, as picking out any URI would cause
77141 * too many false positives
77142 * - We don't care about matching the entire URL, any small segment is fine
77143 */
77144 const URL_REGEXP = /[^:/?#]:\/\/[^?#]/u;
77145 const sourceCode = context.getSourceCode();
77146 /**
77147 * Computes the length of a line that may contain tabs. The width of each
77148 * tab will be the number of spaces to the next tab stop.
77149 * @param {string} line The line.
77150 * @param {int} tabWidth The width of each tab stop in spaces.
77151 * @returns {int} The computed line length.
77152 * @private
77153 */
77154
77155 function computeLineLength(line, tabWidth) {
77156 let extraCharacterCount = 0;
77157 line.replace(/\t/gu, (match, offset) => {
77158 const totalOffset = offset + extraCharacterCount,
77159 previousTabStopOffset = tabWidth ? totalOffset % tabWidth : 0,
77160 spaceCount = tabWidth - previousTabStopOffset;
77161 extraCharacterCount += spaceCount - 1; // -1 for the replaced tab
77162 });
77163 return Array.from(line).length + extraCharacterCount;
77164 } // The options object must be the last option specified…
77165
77166
77167 const options = Object.assign({}, context.options[context.options.length - 1]); // …but max code length…
77168
77169 if (typeof context.options[0] === "number") {
77170 options.code = context.options[0];
77171 } // …and tabWidth can be optionally specified directly as integers.
77172
77173
77174 if (typeof context.options[1] === "number") {
77175 options.tabWidth = context.options[1];
77176 }
77177
77178 const maxLength = typeof options.code === "number" ? options.code : 80,
77179 tabWidth = typeof options.tabWidth === "number" ? options.tabWidth : 4,
77180 ignoreComments = !!options.ignoreComments,
77181 ignoreStrings = !!options.ignoreStrings,
77182 ignoreTemplateLiterals = !!options.ignoreTemplateLiterals,
77183 ignoreRegExpLiterals = !!options.ignoreRegExpLiterals,
77184 ignoreTrailingComments = !!options.ignoreTrailingComments || !!options.ignoreComments,
77185 ignoreUrls = !!options.ignoreUrls,
77186 maxCommentLength = options.comments;
77187 let ignorePattern = options.ignorePattern || null;
77188
77189 if (ignorePattern) {
77190 ignorePattern = new RegExp(ignorePattern, "u");
77191 } //--------------------------------------------------------------------------
77192 // Helpers
77193 //--------------------------------------------------------------------------
77194
77195 /**
77196 * Tells if a given comment is trailing: it starts on the current line and
77197 * extends to or past the end of the current line.
77198 * @param {string} line The source line we want to check for a trailing comment on
77199 * @param {number} lineNumber The one-indexed line number for line
77200 * @param {ASTNode} comment The comment to inspect
77201 * @returns {boolean} If the comment is trailing on the given line
77202 */
77203
77204
77205 function isTrailingComment(line, lineNumber, comment) {
77206 return comment && comment.loc.start.line === lineNumber && lineNumber <= comment.loc.end.line && (comment.loc.end.line > lineNumber || comment.loc.end.column === line.length);
77207 }
77208 /**
77209 * Tells if a comment encompasses the entire line.
77210 * @param {string} line The source line with a trailing comment
77211 * @param {number} lineNumber The one-indexed line number this is on
77212 * @param {ASTNode} comment The comment to remove
77213 * @returns {boolean} If the comment covers the entire line
77214 */
77215
77216
77217 function isFullLineComment(line, lineNumber, comment) {
77218 const start = comment.loc.start,
77219 end = comment.loc.end,
77220 isFirstTokenOnLine = !line.slice(0, comment.loc.start.column).trim();
77221 return comment && (start.line < lineNumber || start.line === lineNumber && isFirstTokenOnLine) && (end.line > lineNumber || end.line === lineNumber && end.column === line.length);
77222 }
77223 /**
77224 * Check if a node is a JSXEmptyExpression contained in a single line JSXExpressionContainer.
77225 * @param {ASTNode} node A node to check.
77226 * @returns {boolean} True if the node is a JSXEmptyExpression contained in a single line JSXExpressionContainer.
77227 */
77228
77229
77230 function isJSXEmptyExpressionInSingleLineContainer(node) {
77231 if (!node || !node.parent || node.type !== "JSXEmptyExpression" || node.parent.type !== "JSXExpressionContainer") {
77232 return false;
77233 }
77234
77235 const parent = node.parent;
77236 return parent.loc.start.line === parent.loc.end.line;
77237 }
77238 /**
77239 * Gets the line after the comment and any remaining trailing whitespace is
77240 * stripped.
77241 * @param {string} line The source line with a trailing comment
77242 * @param {ASTNode} comment The comment to remove
77243 * @returns {string} Line without comment and trailing whitespace
77244 */
77245
77246
77247 function stripTrailingComment(line, comment) {
77248 // loc.column is zero-indexed
77249 return line.slice(0, comment.loc.start.column).replace(/\s+$/u, "");
77250 }
77251 /**
77252 * Ensure that an array exists at [key] on `object`, and add `value` to it.
77253 * @param {Object} object the object to mutate
77254 * @param {string} key the object's key
77255 * @param {any} value the value to add
77256 * @returns {void}
77257 * @private
77258 */
77259
77260
77261 function ensureArrayAndPush(object, key, value) {
77262 if (!Array.isArray(object[key])) {
77263 object[key] = [];
77264 }
77265
77266 object[key].push(value);
77267 }
77268 /**
77269 * Retrieves an array containing all strings (" or ') in the source code.
77270 * @returns {ASTNode[]} An array of string nodes.
77271 */
77272
77273
77274 function getAllStrings() {
77275 return sourceCode.ast.tokens.filter(token => token.type === "String" || token.type === "JSXText" && sourceCode.getNodeByRangeIndex(token.range[0] - 1).type === "JSXAttribute");
77276 }
77277 /**
77278 * Retrieves an array containing all template literals in the source code.
77279 * @returns {ASTNode[]} An array of template literal nodes.
77280 */
77281
77282
77283 function getAllTemplateLiterals() {
77284 return sourceCode.ast.tokens.filter(token => token.type === "Template");
77285 }
77286 /**
77287 * Retrieves an array containing all RegExp literals in the source code.
77288 * @returns {ASTNode[]} An array of RegExp literal nodes.
77289 */
77290
77291
77292 function getAllRegExpLiterals() {
77293 return sourceCode.ast.tokens.filter(token => token.type === "RegularExpression");
77294 }
77295 /**
77296 * A reducer to group an AST node by line number, both start and end.
77297 * @param {Object} acc the accumulator
77298 * @param {ASTNode} node the AST node in question
77299 * @returns {Object} the modified accumulator
77300 * @private
77301 */
77302
77303
77304 function groupByLineNumber(acc, node) {
77305 for (let i = node.loc.start.line; i <= node.loc.end.line; ++i) {
77306 ensureArrayAndPush(acc, i, node);
77307 }
77308
77309 return acc;
77310 }
77311 /**
77312 * Returns an array of all comments in the source code.
77313 * If the element in the array is a JSXEmptyExpression contained with a single line JSXExpressionContainer,
77314 * the element is changed with JSXExpressionContainer node.
77315 * @returns {ASTNode[]} An array of comment nodes
77316 */
77317
77318
77319 function getAllComments() {
77320 const comments = [];
77321 sourceCode.getAllComments().forEach(commentNode => {
77322 const containingNode = sourceCode.getNodeByRangeIndex(commentNode.range[0]);
77323
77324 if (isJSXEmptyExpressionInSingleLineContainer(containingNode)) {
77325 // push a unique node only
77326 if (comments[comments.length - 1] !== containingNode.parent) {
77327 comments.push(containingNode.parent);
77328 }
77329 } else {
77330 comments.push(commentNode);
77331 }
77332 });
77333 return comments;
77334 }
77335 /**
77336 * Check the program for max length
77337 * @param {ASTNode} node Node to examine
77338 * @returns {void}
77339 * @private
77340 */
77341
77342
77343 function checkProgramForMaxLength(node) {
77344 // split (honors line-ending)
77345 const lines = sourceCode.lines,
77346 // list of comments to ignore
77347 comments = ignoreComments || maxCommentLength || ignoreTrailingComments ? getAllComments() : []; // we iterate over comments in parallel with the lines
77348
77349 let commentsIndex = 0;
77350 const strings = getAllStrings();
77351 const stringsByLine = strings.reduce(groupByLineNumber, {});
77352 const templateLiterals = getAllTemplateLiterals();
77353 const templateLiteralsByLine = templateLiterals.reduce(groupByLineNumber, {});
77354 const regExpLiterals = getAllRegExpLiterals();
77355 const regExpLiteralsByLine = regExpLiterals.reduce(groupByLineNumber, {});
77356 lines.forEach((line, i) => {
77357 // i is zero-indexed, line numbers are one-indexed
77358 const lineNumber = i + 1;
77359 /*
77360 * if we're checking comment length; we need to know whether this
77361 * line is a comment
77362 */
77363
77364 let lineIsComment = false;
77365 let textToMeasure;
77366 /*
77367 * We can short-circuit the comment checks if we're already out of
77368 * comments to check.
77369 */
77370
77371 if (commentsIndex < comments.length) {
77372 let comment = null; // iterate over comments until we find one past the current line
77373
77374 do {
77375 comment = comments[++commentsIndex];
77376 } while (comment && comment.loc.start.line <= lineNumber); // and step back by one
77377
77378
77379 comment = comments[--commentsIndex];
77380
77381 if (isFullLineComment(line, lineNumber, comment)) {
77382 lineIsComment = true;
77383 textToMeasure = line;
77384 } else if (ignoreTrailingComments && isTrailingComment(line, lineNumber, comment)) {
77385 textToMeasure = stripTrailingComment(line, comment); // ignore multiple trailing comments in the same line
77386
77387 let lastIndex = commentsIndex;
77388
77389 while (isTrailingComment(textToMeasure, lineNumber, comments[--lastIndex])) {
77390 textToMeasure = stripTrailingComment(textToMeasure, comments[lastIndex]);
77391 }
77392 } else {
77393 textToMeasure = line;
77394 }
77395 } else {
77396 textToMeasure = line;
77397 }
77398
77399 if (ignorePattern && ignorePattern.test(textToMeasure) || ignoreUrls && URL_REGEXP.test(textToMeasure) || ignoreStrings && stringsByLine[lineNumber] || ignoreTemplateLiterals && templateLiteralsByLine[lineNumber] || ignoreRegExpLiterals && regExpLiteralsByLine[lineNumber]) {
77400 // ignore this line
77401 return;
77402 }
77403
77404 const lineLength = computeLineLength(textToMeasure, tabWidth);
77405 const commentLengthApplies = lineIsComment && maxCommentLength;
77406
77407 if (lineIsComment && ignoreComments) {
77408 return;
77409 }
77410
77411 const loc = {
77412 start: {
77413 line: lineNumber,
77414 column: 0
77415 },
77416 end: {
77417 line: lineNumber,
77418 column: textToMeasure.length
77419 }
77420 };
77421
77422 if (commentLengthApplies) {
77423 if (lineLength > maxCommentLength) {
77424 context.report({
77425 node,
77426 loc,
77427 messageId: "maxComment",
77428 data: {
77429 lineLength,
77430 maxCommentLength
77431 }
77432 });
77433 }
77434 } else if (lineLength > maxLength) {
77435 context.report({
77436 node,
77437 loc,
77438 messageId: "max",
77439 data: {
77440 lineLength,
77441 maxLength
77442 }
77443 });
77444 }
77445 });
77446 } //--------------------------------------------------------------------------
77447 // Public API
77448 //--------------------------------------------------------------------------
77449
77450
77451 return {
77452 Program: checkProgramForMaxLength
77453 };
77454 }
77455
77456 };
77457
77458 /***/ }),
77459 /* 619 */
77460 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
77461
77462 "use strict";
77463 /**
77464 * @fileoverview enforce a maximum file length
77465 * @author Alberto Rodríguez
77466 */
77467 //------------------------------------------------------------------------------
77468 // Requirements
77469 //------------------------------------------------------------------------------
77470
77471 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
77472 // Helpers
77473 //------------------------------------------------------------------------------
77474
77475 /**
77476 * Creates an array of numbers from `start` up to, but not including, `end`
77477 * @param {number} start The start of the range
77478 * @param {number} end The end of the range
77479 * @returns {number[]} The range of numbers
77480 */
77481
77482
77483 function range(start, end) {
77484 return [...Array(end - start).keys()].map(x => x + start);
77485 } //------------------------------------------------------------------------------
77486 // Rule Definition
77487 //------------------------------------------------------------------------------
77488
77489
77490 module.exports = {
77491 meta: {
77492 type: "suggestion",
77493 docs: {
77494 description: "enforce a maximum number of lines per file",
77495 recommended: false,
77496 url: "https://eslint.org/docs/rules/max-lines"
77497 },
77498 schema: [{
77499 oneOf: [{
77500 type: "integer",
77501 minimum: 0
77502 }, {
77503 type: "object",
77504 properties: {
77505 max: {
77506 type: "integer",
77507 minimum: 0
77508 },
77509 skipComments: {
77510 type: "boolean"
77511 },
77512 skipBlankLines: {
77513 type: "boolean"
77514 }
77515 },
77516 additionalProperties: false
77517 }]
77518 }],
77519 messages: {
77520 exceed: "File has too many lines ({{actual}}). Maximum allowed is {{max}}."
77521 }
77522 },
77523
77524 create(context) {
77525 const option = context.options[0];
77526 let max = 300;
77527
77528 if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max")) {
77529 max = option.max;
77530 } else if (typeof option === "number") {
77531 max = option;
77532 }
77533
77534 const skipComments = option && option.skipComments;
77535 const skipBlankLines = option && option.skipBlankLines;
77536 const sourceCode = context.getSourceCode();
77537 /**
77538 * Returns whether or not a token is a comment node type
77539 * @param {Token} token The token to check
77540 * @returns {boolean} True if the token is a comment node
77541 */
77542
77543 function isCommentNodeType(token) {
77544 return token && (token.type === "Block" || token.type === "Line");
77545 }
77546 /**
77547 * Returns the line numbers of a comment that don't have any code on the same line
77548 * @param {Node} comment The comment node to check
77549 * @returns {number[]} The line numbers
77550 */
77551
77552
77553 function getLinesWithoutCode(comment) {
77554 let start = comment.loc.start.line;
77555 let end = comment.loc.end.line;
77556 let token;
77557 token = comment;
77558
77559 do {
77560 token = sourceCode.getTokenBefore(token, {
77561 includeComments: true
77562 });
77563 } while (isCommentNodeType(token));
77564
77565 if (token && astUtils.isTokenOnSameLine(token, comment)) {
77566 start += 1;
77567 }
77568
77569 token = comment;
77570
77571 do {
77572 token = sourceCode.getTokenAfter(token, {
77573 includeComments: true
77574 });
77575 } while (isCommentNodeType(token));
77576
77577 if (token && astUtils.isTokenOnSameLine(comment, token)) {
77578 end -= 1;
77579 }
77580
77581 if (start <= end) {
77582 return range(start, end + 1);
77583 }
77584
77585 return [];
77586 }
77587
77588 return {
77589 "Program:exit"() {
77590 let lines = sourceCode.lines.map((text, i) => ({
77591 lineNumber: i + 1,
77592 text
77593 }));
77594 /*
77595 * If file ends with a linebreak, `sourceCode.lines` will have one extra empty line at the end.
77596 * That isn't a real line, so we shouldn't count it.
77597 */
77598
77599 if (lines.length > 1 && lines[lines.length - 1].text === "") {
77600 lines.pop();
77601 }
77602
77603 if (skipBlankLines) {
77604 lines = lines.filter(l => l.text.trim() !== "");
77605 }
77606
77607 if (skipComments) {
77608 const comments = sourceCode.getAllComments();
77609 const commentLines = comments.flatMap(getLinesWithoutCode);
77610 lines = lines.filter(l => !commentLines.includes(l.lineNumber));
77611 }
77612
77613 if (lines.length > max) {
77614 const loc = {
77615 start: {
77616 line: lines[max].lineNumber,
77617 column: 0
77618 },
77619 end: {
77620 line: sourceCode.lines.length,
77621 column: sourceCode.lines[sourceCode.lines.length - 1].length
77622 }
77623 };
77624 context.report({
77625 loc,
77626 messageId: "exceed",
77627 data: {
77628 max,
77629 actual: lines.length
77630 }
77631 });
77632 }
77633 }
77634
77635 };
77636 }
77637
77638 };
77639
77640 /***/ }),
77641 /* 620 */
77642 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
77643
77644 "use strict";
77645 /**
77646 * @fileoverview A rule to set the maximum number of line of code in a function.
77647 * @author Pete Ward <peteward44@gmail.com>
77648 */
77649 //------------------------------------------------------------------------------
77650 // Requirements
77651 //------------------------------------------------------------------------------
77652
77653 const astUtils = __webpack_require__(548);
77654
77655 const {
77656 upperCaseFirst
77657 } = __webpack_require__(572); //------------------------------------------------------------------------------
77658 // Constants
77659 //------------------------------------------------------------------------------
77660
77661
77662 const OPTIONS_SCHEMA = {
77663 type: "object",
77664 properties: {
77665 max: {
77666 type: "integer",
77667 minimum: 0
77668 },
77669 skipComments: {
77670 type: "boolean"
77671 },
77672 skipBlankLines: {
77673 type: "boolean"
77674 },
77675 IIFEs: {
77676 type: "boolean"
77677 }
77678 },
77679 additionalProperties: false
77680 };
77681 const OPTIONS_OR_INTEGER_SCHEMA = {
77682 oneOf: [OPTIONS_SCHEMA, {
77683 type: "integer",
77684 minimum: 1
77685 }]
77686 };
77687 /**
77688 * Given a list of comment nodes, return a map with numeric keys (source code line numbers) and comment token values.
77689 * @param {Array} comments An array of comment nodes.
77690 * @returns {Map<string, Node>} A map with numeric keys (source code line numbers) and comment token values.
77691 */
77692
77693 function getCommentLineNumbers(comments) {
77694 const map = new Map();
77695 comments.forEach(comment => {
77696 for (let i = comment.loc.start.line; i <= comment.loc.end.line; i++) {
77697 map.set(i, comment);
77698 }
77699 });
77700 return map;
77701 } //------------------------------------------------------------------------------
77702 // Rule Definition
77703 //------------------------------------------------------------------------------
77704
77705
77706 module.exports = {
77707 meta: {
77708 type: "suggestion",
77709 docs: {
77710 description: "enforce a maximum number of lines of code in a function",
77711 recommended: false,
77712 url: "https://eslint.org/docs/rules/max-lines-per-function"
77713 },
77714 schema: [OPTIONS_OR_INTEGER_SCHEMA],
77715 messages: {
77716 exceed: "{{name}} has too many lines ({{lineCount}}). Maximum allowed is {{maxLines}}."
77717 }
77718 },
77719
77720 create(context) {
77721 const sourceCode = context.getSourceCode();
77722 const lines = sourceCode.lines;
77723 const option = context.options[0];
77724 let maxLines = 50;
77725 let skipComments = false;
77726 let skipBlankLines = false;
77727 let IIFEs = false;
77728
77729 if (typeof option === "object") {
77730 maxLines = typeof option.max === "number" ? option.max : 50;
77731 skipComments = !!option.skipComments;
77732 skipBlankLines = !!option.skipBlankLines;
77733 IIFEs = !!option.IIFEs;
77734 } else if (typeof option === "number") {
77735 maxLines = option;
77736 }
77737
77738 const commentLineNumbers = getCommentLineNumbers(sourceCode.getAllComments()); //--------------------------------------------------------------------------
77739 // Helpers
77740 //--------------------------------------------------------------------------
77741
77742 /**
77743 * Tells if a comment encompasses the entire line.
77744 * @param {string} line The source line with a trailing comment
77745 * @param {number} lineNumber The one-indexed line number this is on
77746 * @param {ASTNode} comment The comment to remove
77747 * @returns {boolean} If the comment covers the entire line
77748 */
77749
77750 function isFullLineComment(line, lineNumber, comment) {
77751 const start = comment.loc.start,
77752 end = comment.loc.end,
77753 isFirstTokenOnLine = start.line === lineNumber && !line.slice(0, start.column).trim(),
77754 isLastTokenOnLine = end.line === lineNumber && !line.slice(end.column).trim();
77755 return comment && (start.line < lineNumber || isFirstTokenOnLine) && (end.line > lineNumber || isLastTokenOnLine);
77756 }
77757 /**
77758 * Identifies is a node is a FunctionExpression which is part of an IIFE
77759 * @param {ASTNode} node Node to test
77760 * @returns {boolean} True if it's an IIFE
77761 */
77762
77763
77764 function isIIFE(node) {
77765 return (node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node;
77766 }
77767 /**
77768 * Identifies is a node is a FunctionExpression which is embedded within a MethodDefinition or Property
77769 * @param {ASTNode} node Node to test
77770 * @returns {boolean} True if it's a FunctionExpression embedded within a MethodDefinition or Property
77771 */
77772
77773
77774 function isEmbedded(node) {
77775 if (!node.parent) {
77776 return false;
77777 }
77778
77779 if (node !== node.parent.value) {
77780 return false;
77781 }
77782
77783 if (node.parent.type === "MethodDefinition") {
77784 return true;
77785 }
77786
77787 if (node.parent.type === "Property") {
77788 return node.parent.method === true || node.parent.kind === "get" || node.parent.kind === "set";
77789 }
77790
77791 return false;
77792 }
77793 /**
77794 * Count the lines in the function
77795 * @param {ASTNode} funcNode Function AST node
77796 * @returns {void}
77797 * @private
77798 */
77799
77800
77801 function processFunction(funcNode) {
77802 const node = isEmbedded(funcNode) ? funcNode.parent : funcNode;
77803
77804 if (!IIFEs && isIIFE(node)) {
77805 return;
77806 }
77807
77808 let lineCount = 0;
77809
77810 for (let i = node.loc.start.line - 1; i < node.loc.end.line; ++i) {
77811 const line = lines[i];
77812
77813 if (skipComments) {
77814 if (commentLineNumbers.has(i + 1) && isFullLineComment(line, i + 1, commentLineNumbers.get(i + 1))) {
77815 continue;
77816 }
77817 }
77818
77819 if (skipBlankLines) {
77820 if (line.match(/^\s*$/u)) {
77821 continue;
77822 }
77823 }
77824
77825 lineCount++;
77826 }
77827
77828 if (lineCount > maxLines) {
77829 const name = upperCaseFirst(astUtils.getFunctionNameWithKind(funcNode));
77830 context.report({
77831 node,
77832 messageId: "exceed",
77833 data: {
77834 name,
77835 lineCount,
77836 maxLines
77837 }
77838 });
77839 }
77840 } //--------------------------------------------------------------------------
77841 // Public API
77842 //--------------------------------------------------------------------------
77843
77844
77845 return {
77846 FunctionDeclaration: processFunction,
77847 FunctionExpression: processFunction,
77848 ArrowFunctionExpression: processFunction
77849 };
77850 }
77851
77852 };
77853
77854 /***/ }),
77855 /* 621 */
77856 /***/ ((module) => {
77857
77858 "use strict";
77859 /**
77860 * @fileoverview Rule to enforce a maximum number of nested callbacks.
77861 * @author Ian Christian Myers
77862 */
77863 //------------------------------------------------------------------------------
77864 // Rule Definition
77865 //------------------------------------------------------------------------------
77866
77867 module.exports = {
77868 meta: {
77869 type: "suggestion",
77870 docs: {
77871 description: "enforce a maximum depth that callbacks can be nested",
77872 recommended: false,
77873 url: "https://eslint.org/docs/rules/max-nested-callbacks"
77874 },
77875 schema: [{
77876 oneOf: [{
77877 type: "integer",
77878 minimum: 0
77879 }, {
77880 type: "object",
77881 properties: {
77882 maximum: {
77883 type: "integer",
77884 minimum: 0
77885 },
77886 max: {
77887 type: "integer",
77888 minimum: 0
77889 }
77890 },
77891 additionalProperties: false
77892 }]
77893 }],
77894 messages: {
77895 exceed: "Too many nested callbacks ({{num}}). Maximum allowed is {{max}}."
77896 }
77897 },
77898
77899 create(context) {
77900 //--------------------------------------------------------------------------
77901 // Constants
77902 //--------------------------------------------------------------------------
77903 const option = context.options[0];
77904 let THRESHOLD = 10;
77905
77906 if (typeof option === "object" && (Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))) {
77907 THRESHOLD = option.maximum || option.max;
77908 } else if (typeof option === "number") {
77909 THRESHOLD = option;
77910 } //--------------------------------------------------------------------------
77911 // Helpers
77912 //--------------------------------------------------------------------------
77913
77914
77915 const callbackStack = [];
77916 /**
77917 * Checks a given function node for too many callbacks.
77918 * @param {ASTNode} node The node to check.
77919 * @returns {void}
77920 * @private
77921 */
77922
77923 function checkFunction(node) {
77924 const parent = node.parent;
77925
77926 if (parent.type === "CallExpression") {
77927 callbackStack.push(node);
77928 }
77929
77930 if (callbackStack.length > THRESHOLD) {
77931 const opts = {
77932 num: callbackStack.length,
77933 max: THRESHOLD
77934 };
77935 context.report({
77936 node,
77937 messageId: "exceed",
77938 data: opts
77939 });
77940 }
77941 }
77942 /**
77943 * Pops the call stack.
77944 * @returns {void}
77945 * @private
77946 */
77947
77948
77949 function popStack() {
77950 callbackStack.pop();
77951 } //--------------------------------------------------------------------------
77952 // Public API
77953 //--------------------------------------------------------------------------
77954
77955
77956 return {
77957 ArrowFunctionExpression: checkFunction,
77958 "ArrowFunctionExpression:exit": popStack,
77959 FunctionExpression: checkFunction,
77960 "FunctionExpression:exit": popStack
77961 };
77962 }
77963
77964 };
77965
77966 /***/ }),
77967 /* 622 */
77968 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
77969
77970 "use strict";
77971 /**
77972 * @fileoverview Rule to flag when a function has too many parameters
77973 * @author Ilya Volodin
77974 */
77975 //------------------------------------------------------------------------------
77976 // Requirements
77977 //------------------------------------------------------------------------------
77978
77979 const astUtils = __webpack_require__(548);
77980
77981 const {
77982 upperCaseFirst
77983 } = __webpack_require__(572); //------------------------------------------------------------------------------
77984 // Rule Definition
77985 //------------------------------------------------------------------------------
77986
77987
77988 module.exports = {
77989 meta: {
77990 type: "suggestion",
77991 docs: {
77992 description: "enforce a maximum number of parameters in function definitions",
77993 recommended: false,
77994 url: "https://eslint.org/docs/rules/max-params"
77995 },
77996 schema: [{
77997 oneOf: [{
77998 type: "integer",
77999 minimum: 0
78000 }, {
78001 type: "object",
78002 properties: {
78003 maximum: {
78004 type: "integer",
78005 minimum: 0
78006 },
78007 max: {
78008 type: "integer",
78009 minimum: 0
78010 }
78011 },
78012 additionalProperties: false
78013 }]
78014 }],
78015 messages: {
78016 exceed: "{{name}} has too many parameters ({{count}}). Maximum allowed is {{max}}."
78017 }
78018 },
78019
78020 create(context) {
78021 const sourceCode = context.getSourceCode();
78022 const option = context.options[0];
78023 let numParams = 3;
78024
78025 if (typeof option === "object" && (Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))) {
78026 numParams = option.maximum || option.max;
78027 }
78028
78029 if (typeof option === "number") {
78030 numParams = option;
78031 }
78032 /**
78033 * Checks a function to see if it has too many parameters.
78034 * @param {ASTNode} node The node to check.
78035 * @returns {void}
78036 * @private
78037 */
78038
78039
78040 function checkFunction(node) {
78041 if (node.params.length > numParams) {
78042 context.report({
78043 loc: astUtils.getFunctionHeadLoc(node, sourceCode),
78044 node,
78045 messageId: "exceed",
78046 data: {
78047 name: upperCaseFirst(astUtils.getFunctionNameWithKind(node)),
78048 count: node.params.length,
78049 max: numParams
78050 }
78051 });
78052 }
78053 }
78054
78055 return {
78056 FunctionDeclaration: checkFunction,
78057 ArrowFunctionExpression: checkFunction,
78058 FunctionExpression: checkFunction
78059 };
78060 }
78061
78062 };
78063
78064 /***/ }),
78065 /* 623 */
78066 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
78067
78068 "use strict";
78069 /**
78070 * @fileoverview A rule to set the maximum number of statements in a function.
78071 * @author Ian Christian Myers
78072 */
78073 //------------------------------------------------------------------------------
78074 // Requirements
78075 //------------------------------------------------------------------------------
78076
78077 const astUtils = __webpack_require__(548);
78078
78079 const {
78080 upperCaseFirst
78081 } = __webpack_require__(572); //------------------------------------------------------------------------------
78082 // Rule Definition
78083 //------------------------------------------------------------------------------
78084
78085
78086 module.exports = {
78087 meta: {
78088 type: "suggestion",
78089 docs: {
78090 description: "enforce a maximum number of statements allowed in function blocks",
78091 recommended: false,
78092 url: "https://eslint.org/docs/rules/max-statements"
78093 },
78094 schema: [{
78095 oneOf: [{
78096 type: "integer",
78097 minimum: 0
78098 }, {
78099 type: "object",
78100 properties: {
78101 maximum: {
78102 type: "integer",
78103 minimum: 0
78104 },
78105 max: {
78106 type: "integer",
78107 minimum: 0
78108 }
78109 },
78110 additionalProperties: false
78111 }]
78112 }, {
78113 type: "object",
78114 properties: {
78115 ignoreTopLevelFunctions: {
78116 type: "boolean"
78117 }
78118 },
78119 additionalProperties: false
78120 }],
78121 messages: {
78122 exceed: "{{name}} has too many statements ({{count}}). Maximum allowed is {{max}}."
78123 }
78124 },
78125
78126 create(context) {
78127 //--------------------------------------------------------------------------
78128 // Helpers
78129 //--------------------------------------------------------------------------
78130 const functionStack = [],
78131 option = context.options[0],
78132 ignoreTopLevelFunctions = context.options[1] && context.options[1].ignoreTopLevelFunctions || false,
78133 topLevelFunctions = [];
78134 let maxStatements = 10;
78135
78136 if (typeof option === "object" && (Object.prototype.hasOwnProperty.call(option, "maximum") || Object.prototype.hasOwnProperty.call(option, "max"))) {
78137 maxStatements = option.maximum || option.max;
78138 } else if (typeof option === "number") {
78139 maxStatements = option;
78140 }
78141 /**
78142 * Reports a node if it has too many statements
78143 * @param {ASTNode} node node to evaluate
78144 * @param {int} count Number of statements in node
78145 * @param {int} max Maximum number of statements allowed
78146 * @returns {void}
78147 * @private
78148 */
78149
78150
78151 function reportIfTooManyStatements(node, count, max) {
78152 if (count > max) {
78153 const name = upperCaseFirst(astUtils.getFunctionNameWithKind(node));
78154 context.report({
78155 node,
78156 messageId: "exceed",
78157 data: {
78158 name,
78159 count,
78160 max
78161 }
78162 });
78163 }
78164 }
78165 /**
78166 * When parsing a new function, store it in our function stack
78167 * @returns {void}
78168 * @private
78169 */
78170
78171
78172 function startFunction() {
78173 functionStack.push(0);
78174 }
78175 /**
78176 * Evaluate the node at the end of function
78177 * @param {ASTNode} node node to evaluate
78178 * @returns {void}
78179 * @private
78180 */
78181
78182
78183 function endFunction(node) {
78184 const count = functionStack.pop();
78185 /*
78186 * This rule does not apply to class static blocks, but we have to track them so
78187 * that stataments in them do not count as statements in the enclosing function.
78188 */
78189
78190 if (node.type === "StaticBlock") {
78191 return;
78192 }
78193
78194 if (ignoreTopLevelFunctions && functionStack.length === 0) {
78195 topLevelFunctions.push({
78196 node,
78197 count
78198 });
78199 } else {
78200 reportIfTooManyStatements(node, count, maxStatements);
78201 }
78202 }
78203 /**
78204 * Increment the count of the functions
78205 * @param {ASTNode} node node to evaluate
78206 * @returns {void}
78207 * @private
78208 */
78209
78210
78211 function countStatements(node) {
78212 functionStack[functionStack.length - 1] += node.body.length;
78213 } //--------------------------------------------------------------------------
78214 // Public API
78215 //--------------------------------------------------------------------------
78216
78217
78218 return {
78219 FunctionDeclaration: startFunction,
78220 FunctionExpression: startFunction,
78221 ArrowFunctionExpression: startFunction,
78222 StaticBlock: startFunction,
78223 BlockStatement: countStatements,
78224 "FunctionDeclaration:exit": endFunction,
78225 "FunctionExpression:exit": endFunction,
78226 "ArrowFunctionExpression:exit": endFunction,
78227 "StaticBlock:exit": endFunction,
78228
78229 "Program:exit"() {
78230 if (topLevelFunctions.length === 1) {
78231 return;
78232 }
78233
78234 topLevelFunctions.forEach(element => {
78235 const count = element.count;
78236 const node = element.node;
78237 reportIfTooManyStatements(node, count, maxStatements);
78238 });
78239 }
78240
78241 };
78242 }
78243
78244 };
78245
78246 /***/ }),
78247 /* 624 */
78248 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
78249
78250 "use strict";
78251 /**
78252 * @fileoverview Specify the maximum number of statements allowed per line.
78253 * @author Kenneth Williams
78254 */
78255 //------------------------------------------------------------------------------
78256 // Requirements
78257 //------------------------------------------------------------------------------
78258
78259 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
78260 // Rule Definition
78261 //------------------------------------------------------------------------------
78262
78263
78264 module.exports = {
78265 meta: {
78266 type: "layout",
78267 docs: {
78268 description: "enforce a maximum number of statements allowed per line",
78269 recommended: false,
78270 url: "https://eslint.org/docs/rules/max-statements-per-line"
78271 },
78272 schema: [{
78273 type: "object",
78274 properties: {
78275 max: {
78276 type: "integer",
78277 minimum: 1,
78278 default: 1
78279 }
78280 },
78281 additionalProperties: false
78282 }],
78283 messages: {
78284 exceed: "This line has {{numberOfStatementsOnThisLine}} {{statements}}. Maximum allowed is {{maxStatementsPerLine}}."
78285 }
78286 },
78287
78288 create(context) {
78289 const sourceCode = context.getSourceCode(),
78290 options = context.options[0] || {},
78291 maxStatementsPerLine = typeof options.max !== "undefined" ? options.max : 1;
78292 let lastStatementLine = 0,
78293 numberOfStatementsOnThisLine = 0,
78294 firstExtraStatement; //--------------------------------------------------------------------------
78295 // Helpers
78296 //--------------------------------------------------------------------------
78297
78298 const SINGLE_CHILD_ALLOWED = /^(?:(?:DoWhile|For|ForIn|ForOf|If|Labeled|While)Statement|Export(?:Default|Named)Declaration)$/u;
78299 /**
78300 * Reports with the first extra statement, and clears it.
78301 * @returns {void}
78302 */
78303
78304 function reportFirstExtraStatementAndClear() {
78305 if (firstExtraStatement) {
78306 context.report({
78307 node: firstExtraStatement,
78308 messageId: "exceed",
78309 data: {
78310 numberOfStatementsOnThisLine,
78311 maxStatementsPerLine,
78312 statements: numberOfStatementsOnThisLine === 1 ? "statement" : "statements"
78313 }
78314 });
78315 }
78316
78317 firstExtraStatement = null;
78318 }
78319 /**
78320 * Gets the actual last token of a given node.
78321 * @param {ASTNode} node A node to get. This is a node except EmptyStatement.
78322 * @returns {Token} The actual last token.
78323 */
78324
78325
78326 function getActualLastToken(node) {
78327 return sourceCode.getLastToken(node, astUtils.isNotSemicolonToken);
78328 }
78329 /**
78330 * Addresses a given node.
78331 * It updates the state of this rule, then reports the node if the node violated this rule.
78332 * @param {ASTNode} node A node to check.
78333 * @returns {void}
78334 */
78335
78336
78337 function enterStatement(node) {
78338 const line = node.loc.start.line;
78339 /*
78340 * Skip to allow non-block statements if this is direct child of control statements.
78341 * `if (a) foo();` is counted as 1.
78342 * But `if (a) foo(); else foo();` should be counted as 2.
78343 */
78344
78345 if (SINGLE_CHILD_ALLOWED.test(node.parent.type) && node.parent.alternate !== node) {
78346 return;
78347 } // Update state.
78348
78349
78350 if (line === lastStatementLine) {
78351 numberOfStatementsOnThisLine += 1;
78352 } else {
78353 reportFirstExtraStatementAndClear();
78354 numberOfStatementsOnThisLine = 1;
78355 lastStatementLine = line;
78356 } // Reports if the node violated this rule.
78357
78358
78359 if (numberOfStatementsOnThisLine === maxStatementsPerLine + 1) {
78360 firstExtraStatement = firstExtraStatement || node;
78361 }
78362 }
78363 /**
78364 * Updates the state of this rule with the end line of leaving node to check with the next statement.
78365 * @param {ASTNode} node A node to check.
78366 * @returns {void}
78367 */
78368
78369
78370 function leaveStatement(node) {
78371 const line = getActualLastToken(node).loc.end.line; // Update state.
78372
78373 if (line !== lastStatementLine) {
78374 reportFirstExtraStatementAndClear();
78375 numberOfStatementsOnThisLine = 1;
78376 lastStatementLine = line;
78377 }
78378 } //--------------------------------------------------------------------------
78379 // Public API
78380 //--------------------------------------------------------------------------
78381
78382
78383 return {
78384 BreakStatement: enterStatement,
78385 ClassDeclaration: enterStatement,
78386 ContinueStatement: enterStatement,
78387 DebuggerStatement: enterStatement,
78388 DoWhileStatement: enterStatement,
78389 ExpressionStatement: enterStatement,
78390 ForInStatement: enterStatement,
78391 ForOfStatement: enterStatement,
78392 ForStatement: enterStatement,
78393 FunctionDeclaration: enterStatement,
78394 IfStatement: enterStatement,
78395 ImportDeclaration: enterStatement,
78396 LabeledStatement: enterStatement,
78397 ReturnStatement: enterStatement,
78398 SwitchStatement: enterStatement,
78399 ThrowStatement: enterStatement,
78400 TryStatement: enterStatement,
78401 VariableDeclaration: enterStatement,
78402 WhileStatement: enterStatement,
78403 WithStatement: enterStatement,
78404 ExportNamedDeclaration: enterStatement,
78405 ExportDefaultDeclaration: enterStatement,
78406 ExportAllDeclaration: enterStatement,
78407 "BreakStatement:exit": leaveStatement,
78408 "ClassDeclaration:exit": leaveStatement,
78409 "ContinueStatement:exit": leaveStatement,
78410 "DebuggerStatement:exit": leaveStatement,
78411 "DoWhileStatement:exit": leaveStatement,
78412 "ExpressionStatement:exit": leaveStatement,
78413 "ForInStatement:exit": leaveStatement,
78414 "ForOfStatement:exit": leaveStatement,
78415 "ForStatement:exit": leaveStatement,
78416 "FunctionDeclaration:exit": leaveStatement,
78417 "IfStatement:exit": leaveStatement,
78418 "ImportDeclaration:exit": leaveStatement,
78419 "LabeledStatement:exit": leaveStatement,
78420 "ReturnStatement:exit": leaveStatement,
78421 "SwitchStatement:exit": leaveStatement,
78422 "ThrowStatement:exit": leaveStatement,
78423 "TryStatement:exit": leaveStatement,
78424 "VariableDeclaration:exit": leaveStatement,
78425 "WhileStatement:exit": leaveStatement,
78426 "WithStatement:exit": leaveStatement,
78427 "ExportNamedDeclaration:exit": leaveStatement,
78428 "ExportDefaultDeclaration:exit": leaveStatement,
78429 "ExportAllDeclaration:exit": leaveStatement,
78430 "Program:exit": reportFirstExtraStatementAndClear
78431 };
78432 }
78433
78434 };
78435
78436 /***/ }),
78437 /* 625 */
78438 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
78439
78440 "use strict";
78441 /**
78442 * @fileoverview enforce a particular style for multiline comments
78443 * @author Teddy Katz
78444 */
78445
78446
78447 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
78448 // Rule Definition
78449 //------------------------------------------------------------------------------
78450
78451
78452 module.exports = {
78453 meta: {
78454 type: "suggestion",
78455 docs: {
78456 description: "enforce a particular style for multiline comments",
78457 recommended: false,
78458 url: "https://eslint.org/docs/rules/multiline-comment-style"
78459 },
78460 fixable: "whitespace",
78461 schema: [{
78462 enum: ["starred-block", "separate-lines", "bare-block"]
78463 }],
78464 messages: {
78465 expectedBlock: "Expected a block comment instead of consecutive line comments.",
78466 expectedBareBlock: "Expected a block comment without padding stars.",
78467 startNewline: "Expected a linebreak after '/*'.",
78468 endNewline: "Expected a linebreak before '*/'.",
78469 missingStar: "Expected a '*' at the start of this line.",
78470 alignment: "Expected this line to be aligned with the start of the comment.",
78471 expectedLines: "Expected multiple line comments instead of a block comment."
78472 }
78473 },
78474
78475 create(context) {
78476 const sourceCode = context.getSourceCode();
78477 const option = context.options[0] || "starred-block"; //----------------------------------------------------------------------
78478 // Helpers
78479 //----------------------------------------------------------------------
78480
78481 /**
78482 * Checks if a comment line is starred.
78483 * @param {string} line A string representing a comment line.
78484 * @returns {boolean} Whether or not the comment line is starred.
78485 */
78486
78487 function isStarredCommentLine(line) {
78488 return /^\s*\*/u.test(line);
78489 }
78490 /**
78491 * Checks if a comment group is in starred-block form.
78492 * @param {Token[]} commentGroup A group of comments, containing either multiple line comments or a single block comment.
78493 * @returns {boolean} Whether or not the comment group is in starred block form.
78494 */
78495
78496
78497 function isStarredBlockComment(_ref) {
78498 let [firstComment] = _ref;
78499
78500 if (firstComment.type !== "Block") {
78501 return false;
78502 }
78503
78504 const lines = firstComment.value.split(astUtils.LINEBREAK_MATCHER); // The first and last lines can only contain whitespace.
78505
78506 return lines.length > 0 && lines.every((line, i) => (i === 0 || i === lines.length - 1 ? /^\s*$/u : /^\s*\*/u).test(line));
78507 }
78508 /**
78509 * Checks if a comment group is in JSDoc form.
78510 * @param {Token[]} commentGroup A group of comments, containing either multiple line comments or a single block comment.
78511 * @returns {boolean} Whether or not the comment group is in JSDoc form.
78512 */
78513
78514
78515 function isJSDocComment(_ref2) {
78516 let [firstComment] = _ref2;
78517
78518 if (firstComment.type !== "Block") {
78519 return false;
78520 }
78521
78522 const lines = firstComment.value.split(astUtils.LINEBREAK_MATCHER);
78523 return /^\*\s*$/u.test(lines[0]) && lines.slice(1, -1).every(line => /^\s* /u.test(line)) && /^\s*$/u.test(lines[lines.length - 1]);
78524 }
78525 /**
78526 * Processes a comment group that is currently in separate-line form, calculating the offset for each line.
78527 * @param {Token[]} commentGroup A group of comments containing multiple line comments.
78528 * @returns {string[]} An array of the processed lines.
78529 */
78530
78531
78532 function processSeparateLineComments(commentGroup) {
78533 const allLinesHaveLeadingSpace = commentGroup.map(_ref3 => {
78534 let {
78535 value
78536 } = _ref3;
78537 return value;
78538 }).filter(line => line.trim().length).every(line => line.startsWith(" "));
78539 return commentGroup.map(_ref4 => {
78540 let {
78541 value
78542 } = _ref4;
78543 return allLinesHaveLeadingSpace ? value.replace(/^ /u, "") : value;
78544 });
78545 }
78546 /**
78547 * Processes a comment group that is currently in starred-block form, calculating the offset for each line.
78548 * @param {Token} comment A single block comment token in starred-block form.
78549 * @returns {string[]} An array of the processed lines.
78550 */
78551
78552
78553 function processStarredBlockComment(comment) {
78554 const lines = comment.value.split(astUtils.LINEBREAK_MATCHER).filter((line, i, linesArr) => !(i === 0 || i === linesArr.length - 1)).map(line => line.replace(/^\s*$/u, ""));
78555 const allLinesHaveLeadingSpace = lines.map(line => line.replace(/\s*\*/u, "")).filter(line => line.trim().length).every(line => line.startsWith(" "));
78556 return lines.map(line => line.replace(allLinesHaveLeadingSpace ? /\s*\* ?/u : /\s*\*/u, ""));
78557 }
78558 /**
78559 * Processes a comment group that is currently in bare-block form, calculating the offset for each line.
78560 * @param {Token} comment A single block comment token in bare-block form.
78561 * @returns {string[]} An array of the processed lines.
78562 */
78563
78564
78565 function processBareBlockComment(comment) {
78566 const lines = comment.value.split(astUtils.LINEBREAK_MATCHER).map(line => line.replace(/^\s*$/u, ""));
78567 const leadingWhitespace = "".concat(sourceCode.text.slice(comment.range[0] - comment.loc.start.column, comment.range[0]), " ");
78568 let offset = "";
78569 /*
78570 * Calculate the offset of the least indented line and use that as the basis for offsetting all the lines.
78571 * The first line should not be checked because it is inline with the opening block comment delimiter.
78572 */
78573
78574 for (const [i, line] of lines.entries()) {
78575 if (!line.trim().length || i === 0) {
78576 continue;
78577 }
78578
78579 const [, lineOffset] = line.match(/^(\s*\*?\s*)/u);
78580
78581 if (lineOffset.length < leadingWhitespace.length) {
78582 const newOffset = leadingWhitespace.slice(lineOffset.length - leadingWhitespace.length);
78583
78584 if (newOffset.length > offset.length) {
78585 offset = newOffset;
78586 }
78587 }
78588 }
78589
78590 return lines.map(line => {
78591 const match = line.match(/^(\s*\*?\s*)(.*)/u);
78592 const [, lineOffset, lineContents] = match;
78593
78594 if (lineOffset.length > leadingWhitespace.length) {
78595 return "".concat(lineOffset.slice(leadingWhitespace.length - (offset.length + lineOffset.length))).concat(lineContents);
78596 }
78597
78598 if (lineOffset.length < leadingWhitespace.length) {
78599 return "".concat(lineOffset.slice(leadingWhitespace.length)).concat(lineContents);
78600 }
78601
78602 return lineContents;
78603 });
78604 }
78605 /**
78606 * Gets a list of comment lines in a group, formatting leading whitespace as necessary.
78607 * @param {Token[]} commentGroup A group of comments containing either multiple line comments or a single block comment.
78608 * @returns {string[]} A list of comment lines.
78609 */
78610
78611
78612 function getCommentLines(commentGroup) {
78613 const [firstComment] = commentGroup;
78614
78615 if (firstComment.type === "Line") {
78616 return processSeparateLineComments(commentGroup);
78617 }
78618
78619 if (isStarredBlockComment(commentGroup)) {
78620 return processStarredBlockComment(firstComment);
78621 }
78622
78623 return processBareBlockComment(firstComment);
78624 }
78625 /**
78626 * Gets the initial offset (whitespace) from the beginning of a line to a given comment token.
78627 * @param {Token} comment The token to check.
78628 * @returns {string} The offset from the beginning of a line to the token.
78629 */
78630
78631
78632 function getInitialOffset(comment) {
78633 return sourceCode.text.slice(comment.range[0] - comment.loc.start.column, comment.range[0]);
78634 }
78635 /**
78636 * Converts a comment into starred-block form
78637 * @param {Token} firstComment The first comment of the group being converted
78638 * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
78639 * @returns {string} A representation of the comment value in starred-block form, excluding start and end markers
78640 */
78641
78642
78643 function convertToStarredBlock(firstComment, commentLinesList) {
78644 const initialOffset = getInitialOffset(firstComment);
78645 return "/*\n".concat(commentLinesList.map(line => "".concat(initialOffset, " * ").concat(line)).join("\n"), "\n").concat(initialOffset, " */");
78646 }
78647 /**
78648 * Converts a comment into separate-line form
78649 * @param {Token} firstComment The first comment of the group being converted
78650 * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
78651 * @returns {string} A representation of the comment value in separate-line form
78652 */
78653
78654
78655 function convertToSeparateLines(firstComment, commentLinesList) {
78656 return commentLinesList.map(line => "// ".concat(line)).join("\n".concat(getInitialOffset(firstComment)));
78657 }
78658 /**
78659 * Converts a comment into bare-block form
78660 * @param {Token} firstComment The first comment of the group being converted
78661 * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
78662 * @returns {string} A representation of the comment value in bare-block form
78663 */
78664
78665
78666 function convertToBlock(firstComment, commentLinesList) {
78667 return "/* ".concat(commentLinesList.join("\n".concat(getInitialOffset(firstComment), " ")), " */");
78668 }
78669 /**
78670 * Each method checks a group of comments to see if it's valid according to the given option.
78671 * @param {Token[]} commentGroup A list of comments that appear together. This will either contain a single
78672 * block comment or multiple line comments.
78673 * @returns {void}
78674 */
78675
78676
78677 const commentGroupCheckers = {
78678 "starred-block"(commentGroup) {
78679 const [firstComment] = commentGroup;
78680 const commentLines = getCommentLines(commentGroup);
78681
78682 if (commentLines.some(value => value.includes("*/"))) {
78683 return;
78684 }
78685
78686 if (commentGroup.length > 1) {
78687 context.report({
78688 loc: {
78689 start: firstComment.loc.start,
78690 end: commentGroup[commentGroup.length - 1].loc.end
78691 },
78692 messageId: "expectedBlock",
78693
78694 fix(fixer) {
78695 const range = [firstComment.range[0], commentGroup[commentGroup.length - 1].range[1]];
78696 return commentLines.some(value => value.startsWith("/")) ? null : fixer.replaceTextRange(range, convertToStarredBlock(firstComment, commentLines));
78697 }
78698
78699 });
78700 } else {
78701 const lines = firstComment.value.split(astUtils.LINEBREAK_MATCHER);
78702 const expectedLeadingWhitespace = getInitialOffset(firstComment);
78703 const expectedLinePrefix = "".concat(expectedLeadingWhitespace, " *");
78704
78705 if (!/^\*?\s*$/u.test(lines[0])) {
78706 const start = firstComment.value.startsWith("*") ? firstComment.range[0] + 1 : firstComment.range[0];
78707 context.report({
78708 loc: {
78709 start: firstComment.loc.start,
78710 end: {
78711 line: firstComment.loc.start.line,
78712 column: firstComment.loc.start.column + 2
78713 }
78714 },
78715 messageId: "startNewline",
78716 fix: fixer => fixer.insertTextAfterRange([start, start + 2], "\n".concat(expectedLinePrefix))
78717 });
78718 }
78719
78720 if (!/^\s*$/u.test(lines[lines.length - 1])) {
78721 context.report({
78722 loc: {
78723 start: {
78724 line: firstComment.loc.end.line,
78725 column: firstComment.loc.end.column - 2
78726 },
78727 end: firstComment.loc.end
78728 },
78729 messageId: "endNewline",
78730 fix: fixer => fixer.replaceTextRange([firstComment.range[1] - 2, firstComment.range[1]], "\n".concat(expectedLinePrefix, "/"))
78731 });
78732 }
78733
78734 for (let lineNumber = firstComment.loc.start.line + 1; lineNumber <= firstComment.loc.end.line; lineNumber++) {
78735 const lineText = sourceCode.lines[lineNumber - 1];
78736 const errorType = isStarredCommentLine(lineText) ? "alignment" : "missingStar";
78737
78738 if (!lineText.startsWith(expectedLinePrefix)) {
78739 context.report({
78740 loc: {
78741 start: {
78742 line: lineNumber,
78743 column: 0
78744 },
78745 end: {
78746 line: lineNumber,
78747 column: lineText.length
78748 }
78749 },
78750 messageId: errorType,
78751
78752 fix(fixer) {
78753 const lineStartIndex = sourceCode.getIndexFromLoc({
78754 line: lineNumber,
78755 column: 0
78756 });
78757
78758 if (errorType === "alignment") {
78759 const [, commentTextPrefix = ""] = lineText.match(/^(\s*\*)/u) || [];
78760 const commentTextStartIndex = lineStartIndex + commentTextPrefix.length;
78761 return fixer.replaceTextRange([lineStartIndex, commentTextStartIndex], expectedLinePrefix);
78762 }
78763
78764 const [, commentTextPrefix = ""] = lineText.match(/^(\s*)/u) || [];
78765 const commentTextStartIndex = lineStartIndex + commentTextPrefix.length;
78766 let offset;
78767
78768 for (const [idx, line] of lines.entries()) {
78769 if (!/\S+/u.test(line)) {
78770 continue;
78771 }
78772
78773 const lineTextToAlignWith = sourceCode.lines[firstComment.loc.start.line - 1 + idx];
78774 const [, prefix = "", initialOffset = ""] = lineTextToAlignWith.match(/^(\s*(?:\/?\*)?(\s*))/u) || [];
78775 offset = "".concat(commentTextPrefix.slice(prefix.length)).concat(initialOffset);
78776
78777 if (/^\s*\//u.test(lineText) && offset.length === 0) {
78778 offset += " ";
78779 }
78780
78781 break;
78782 }
78783
78784 return fixer.replaceTextRange([lineStartIndex, commentTextStartIndex], "".concat(expectedLinePrefix).concat(offset));
78785 }
78786
78787 });
78788 }
78789 }
78790 }
78791 },
78792
78793 "separate-lines"(commentGroup) {
78794 const [firstComment] = commentGroup;
78795
78796 if (firstComment.type !== "Block" || isJSDocComment(commentGroup)) {
78797 return;
78798 }
78799
78800 const commentLines = getCommentLines(commentGroup);
78801 const tokenAfter = sourceCode.getTokenAfter(firstComment, {
78802 includeComments: true
78803 });
78804
78805 if (tokenAfter && firstComment.loc.end.line === tokenAfter.loc.start.line) {
78806 return;
78807 }
78808
78809 context.report({
78810 loc: {
78811 start: firstComment.loc.start,
78812 end: {
78813 line: firstComment.loc.start.line,
78814 column: firstComment.loc.start.column + 2
78815 }
78816 },
78817 messageId: "expectedLines",
78818
78819 fix(fixer) {
78820 return fixer.replaceText(firstComment, convertToSeparateLines(firstComment, commentLines));
78821 }
78822
78823 });
78824 },
78825
78826 "bare-block"(commentGroup) {
78827 if (isJSDocComment(commentGroup)) {
78828 return;
78829 }
78830
78831 const [firstComment] = commentGroup;
78832 const commentLines = getCommentLines(commentGroup); // Disallows consecutive line comments in favor of using a block comment.
78833
78834 if (firstComment.type === "Line" && commentLines.length > 1 && !commentLines.some(value => value.includes("*/"))) {
78835 context.report({
78836 loc: {
78837 start: firstComment.loc.start,
78838 end: commentGroup[commentGroup.length - 1].loc.end
78839 },
78840 messageId: "expectedBlock",
78841
78842 fix(fixer) {
78843 return fixer.replaceTextRange([firstComment.range[0], commentGroup[commentGroup.length - 1].range[1]], convertToBlock(firstComment, commentLines));
78844 }
78845
78846 });
78847 } // Prohibits block comments from having a * at the beginning of each line.
78848
78849
78850 if (isStarredBlockComment(commentGroup)) {
78851 context.report({
78852 loc: {
78853 start: firstComment.loc.start,
78854 end: {
78855 line: firstComment.loc.start.line,
78856 column: firstComment.loc.start.column + 2
78857 }
78858 },
78859 messageId: "expectedBareBlock",
78860
78861 fix(fixer) {
78862 return fixer.replaceText(firstComment, convertToBlock(firstComment, commentLines));
78863 }
78864
78865 });
78866 }
78867 }
78868
78869 }; //----------------------------------------------------------------------
78870 // Public
78871 //----------------------------------------------------------------------
78872
78873 return {
78874 Program() {
78875 return sourceCode.getAllComments().filter(comment => comment.type !== "Shebang").filter(comment => !astUtils.COMMENTS_IGNORE_PATTERN.test(comment.value)).filter(comment => {
78876 const tokenBefore = sourceCode.getTokenBefore(comment, {
78877 includeComments: true
78878 });
78879 return !tokenBefore || tokenBefore.loc.end.line < comment.loc.start.line;
78880 }).reduce((commentGroups, comment, index, commentList) => {
78881 const tokenBefore = sourceCode.getTokenBefore(comment, {
78882 includeComments: true
78883 });
78884
78885 if (comment.type === "Line" && index && commentList[index - 1].type === "Line" && tokenBefore && tokenBefore.loc.end.line === comment.loc.start.line - 1 && tokenBefore === commentList[index - 1]) {
78886 commentGroups[commentGroups.length - 1].push(comment);
78887 } else {
78888 commentGroups.push([comment]);
78889 }
78890
78891 return commentGroups;
78892 }, []).filter(commentGroup => !(commentGroup.length === 1 && commentGroup[0].loc.start.line === commentGroup[0].loc.end.line)).forEach(commentGroupCheckers[option]);
78893 }
78894
78895 };
78896 }
78897
78898 };
78899
78900 /***/ }),
78901 /* 626 */
78902 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
78903
78904 "use strict";
78905 /**
78906 * @fileoverview Enforce newlines between operands of ternary expressions
78907 * @author Kai Cataldo
78908 */
78909
78910
78911 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
78912 // Rule Definition
78913 //------------------------------------------------------------------------------
78914
78915
78916 module.exports = {
78917 meta: {
78918 type: "layout",
78919 docs: {
78920 description: "enforce newlines between operands of ternary expressions",
78921 recommended: false,
78922 url: "https://eslint.org/docs/rules/multiline-ternary"
78923 },
78924 schema: [{
78925 enum: ["always", "always-multiline", "never"]
78926 }],
78927 messages: {
78928 expectedTestCons: "Expected newline between test and consequent of ternary expression.",
78929 expectedConsAlt: "Expected newline between consequent and alternate of ternary expression.",
78930 unexpectedTestCons: "Unexpected newline between test and consequent of ternary expression.",
78931 unexpectedConsAlt: "Unexpected newline between consequent and alternate of ternary expression."
78932 },
78933 fixable: "whitespace"
78934 },
78935
78936 create(context) {
78937 const sourceCode = context.getSourceCode();
78938 const option = context.options[0];
78939 const multiline = option !== "never";
78940 const allowSingleLine = option === "always-multiline"; //--------------------------------------------------------------------------
78941 // Public
78942 //--------------------------------------------------------------------------
78943
78944 return {
78945 ConditionalExpression(node) {
78946 const questionToken = sourceCode.getTokenAfter(node.test, astUtils.isNotClosingParenToken);
78947 const colonToken = sourceCode.getTokenAfter(node.consequent, astUtils.isNotClosingParenToken);
78948 const firstTokenOfTest = sourceCode.getFirstToken(node);
78949 const lastTokenOfTest = sourceCode.getTokenBefore(questionToken);
78950 const firstTokenOfConsequent = sourceCode.getTokenAfter(questionToken);
78951 const lastTokenOfConsequent = sourceCode.getTokenBefore(colonToken);
78952 const firstTokenOfAlternate = sourceCode.getTokenAfter(colonToken);
78953 const areTestAndConsequentOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfTest, firstTokenOfConsequent);
78954 const areConsequentAndAlternateOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfConsequent, firstTokenOfAlternate);
78955 const hasComments = !!sourceCode.getCommentsInside(node).length;
78956
78957 if (!multiline) {
78958 if (!areTestAndConsequentOnSameLine) {
78959 context.report({
78960 node: node.test,
78961 loc: {
78962 start: firstTokenOfTest.loc.start,
78963 end: lastTokenOfTest.loc.end
78964 },
78965 messageId: "unexpectedTestCons",
78966 fix: fixer => {
78967 if (hasComments) {
78968 return null;
78969 }
78970
78971 const fixers = [];
78972 const areTestAndQuestionOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfTest, questionToken);
78973 const areQuestionAndConsOnSameLine = astUtils.isTokenOnSameLine(questionToken, firstTokenOfConsequent);
78974
78975 if (!areTestAndQuestionOnSameLine) {
78976 fixers.push(fixer.removeRange([lastTokenOfTest.range[1], questionToken.range[0]]));
78977 }
78978
78979 if (!areQuestionAndConsOnSameLine) {
78980 fixers.push(fixer.removeRange([questionToken.range[1], firstTokenOfConsequent.range[0]]));
78981 }
78982
78983 return fixers;
78984 }
78985 });
78986 }
78987
78988 if (!areConsequentAndAlternateOnSameLine) {
78989 context.report({
78990 node: node.consequent,
78991 loc: {
78992 start: firstTokenOfConsequent.loc.start,
78993 end: lastTokenOfConsequent.loc.end
78994 },
78995 messageId: "unexpectedConsAlt",
78996 fix: fixer => {
78997 if (hasComments) {
78998 return null;
78999 }
79000
79001 const fixers = [];
79002 const areConsAndColonOnSameLine = astUtils.isTokenOnSameLine(lastTokenOfConsequent, colonToken);
79003 const areColonAndAltOnSameLine = astUtils.isTokenOnSameLine(colonToken, firstTokenOfAlternate);
79004
79005 if (!areConsAndColonOnSameLine) {
79006 fixers.push(fixer.removeRange([lastTokenOfConsequent.range[1], colonToken.range[0]]));
79007 }
79008
79009 if (!areColonAndAltOnSameLine) {
79010 fixers.push(fixer.removeRange([colonToken.range[1], firstTokenOfAlternate.range[0]]));
79011 }
79012
79013 return fixers;
79014 }
79015 });
79016 }
79017 } else {
79018 if (allowSingleLine && node.loc.start.line === node.loc.end.line) {
79019 return;
79020 }
79021
79022 if (areTestAndConsequentOnSameLine) {
79023 context.report({
79024 node: node.test,
79025 loc: {
79026 start: firstTokenOfTest.loc.start,
79027 end: lastTokenOfTest.loc.end
79028 },
79029 messageId: "expectedTestCons",
79030 fix: fixer => hasComments ? null : fixer.replaceTextRange([lastTokenOfTest.range[1], questionToken.range[0]], "\n")
79031 });
79032 }
79033
79034 if (areConsequentAndAlternateOnSameLine) {
79035 context.report({
79036 node: node.consequent,
79037 loc: {
79038 start: firstTokenOfConsequent.loc.start,
79039 end: lastTokenOfConsequent.loc.end
79040 },
79041 messageId: "expectedConsAlt",
79042 fix: fixer => hasComments ? null : fixer.replaceTextRange([lastTokenOfConsequent.range[1], colonToken.range[0]], "\n")
79043 });
79044 }
79045 }
79046 }
79047
79048 };
79049 }
79050
79051 };
79052
79053 /***/ }),
79054 /* 627 */
79055 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
79056
79057 "use strict";
79058 /**
79059 * @fileoverview Rule to flag use of constructors without capital letters
79060 * @author Nicholas C. Zakas
79061 */
79062 //------------------------------------------------------------------------------
79063 // Requirements
79064 //------------------------------------------------------------------------------
79065
79066 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
79067 // Helpers
79068 //------------------------------------------------------------------------------
79069
79070
79071 const CAPS_ALLOWED = ["Array", "Boolean", "Date", "Error", "Function", "Number", "Object", "RegExp", "String", "Symbol", "BigInt"];
79072 /**
79073 * Ensure that if the key is provided, it must be an array.
79074 * @param {Object} obj Object to check with `key`.
79075 * @param {string} key Object key to check on `obj`.
79076 * @param {any} fallback If obj[key] is not present, this will be returned.
79077 * @throws {TypeError} If key is not an own array type property of `obj`.
79078 * @returns {string[]} Returns obj[key] if it's an Array, otherwise `fallback`
79079 */
79080
79081 function checkArray(obj, key, fallback) {
79082 /* istanbul ignore if */
79083 if (Object.prototype.hasOwnProperty.call(obj, key) && !Array.isArray(obj[key])) {
79084 throw new TypeError("".concat(key, ", if provided, must be an Array"));
79085 }
79086
79087 return obj[key] || fallback;
79088 }
79089 /**
79090 * A reducer function to invert an array to an Object mapping the string form of the key, to `true`.
79091 * @param {Object} map Accumulator object for the reduce.
79092 * @param {string} key Object key to set to `true`.
79093 * @returns {Object} Returns the updated Object for further reduction.
79094 */
79095
79096
79097 function invert(map, key) {
79098 map[key] = true;
79099 return map;
79100 }
79101 /**
79102 * Creates an object with the cap is new exceptions as its keys and true as their values.
79103 * @param {Object} config Rule configuration
79104 * @returns {Object} Object with cap is new exceptions.
79105 */
79106
79107
79108 function calculateCapIsNewExceptions(config) {
79109 let capIsNewExceptions = checkArray(config, "capIsNewExceptions", CAPS_ALLOWED);
79110
79111 if (capIsNewExceptions !== CAPS_ALLOWED) {
79112 capIsNewExceptions = capIsNewExceptions.concat(CAPS_ALLOWED);
79113 }
79114
79115 return capIsNewExceptions.reduce(invert, {});
79116 } //------------------------------------------------------------------------------
79117 // Rule Definition
79118 //------------------------------------------------------------------------------
79119
79120
79121 module.exports = {
79122 meta: {
79123 type: "suggestion",
79124 docs: {
79125 description: "require constructor names to begin with a capital letter",
79126 recommended: false,
79127 url: "https://eslint.org/docs/rules/new-cap"
79128 },
79129 schema: [{
79130 type: "object",
79131 properties: {
79132 newIsCap: {
79133 type: "boolean",
79134 default: true
79135 },
79136 capIsNew: {
79137 type: "boolean",
79138 default: true
79139 },
79140 newIsCapExceptions: {
79141 type: "array",
79142 items: {
79143 type: "string"
79144 }
79145 },
79146 newIsCapExceptionPattern: {
79147 type: "string"
79148 },
79149 capIsNewExceptions: {
79150 type: "array",
79151 items: {
79152 type: "string"
79153 }
79154 },
79155 capIsNewExceptionPattern: {
79156 type: "string"
79157 },
79158 properties: {
79159 type: "boolean",
79160 default: true
79161 }
79162 },
79163 additionalProperties: false
79164 }],
79165 messages: {
79166 upper: "A function with a name starting with an uppercase letter should only be used as a constructor.",
79167 lower: "A constructor name should not start with a lowercase letter."
79168 }
79169 },
79170
79171 create(context) {
79172 const config = Object.assign({}, context.options[0]);
79173 config.newIsCap = config.newIsCap !== false;
79174 config.capIsNew = config.capIsNew !== false;
79175 const skipProperties = config.properties === false;
79176 const newIsCapExceptions = checkArray(config, "newIsCapExceptions", []).reduce(invert, {});
79177 const newIsCapExceptionPattern = config.newIsCapExceptionPattern ? new RegExp(config.newIsCapExceptionPattern, "u") : null;
79178 const capIsNewExceptions = calculateCapIsNewExceptions(config);
79179 const capIsNewExceptionPattern = config.capIsNewExceptionPattern ? new RegExp(config.capIsNewExceptionPattern, "u") : null;
79180 const listeners = {};
79181 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
79182 // Helpers
79183 //--------------------------------------------------------------------------
79184
79185 /**
79186 * Get exact callee name from expression
79187 * @param {ASTNode} node CallExpression or NewExpression node
79188 * @returns {string} name
79189 */
79190
79191 function extractNameFromExpression(node) {
79192 return node.callee.type === "Identifier" ? node.callee.name : astUtils.getStaticPropertyName(node.callee) || "";
79193 }
79194 /**
79195 * Returns the capitalization state of the string -
79196 * Whether the first character is uppercase, lowercase, or non-alphabetic
79197 * @param {string} str String
79198 * @returns {string} capitalization state: "non-alpha", "lower", or "upper"
79199 */
79200
79201
79202 function getCap(str) {
79203 const firstChar = str.charAt(0);
79204 const firstCharLower = firstChar.toLowerCase();
79205 const firstCharUpper = firstChar.toUpperCase();
79206
79207 if (firstCharLower === firstCharUpper) {
79208 // char has no uppercase variant, so it's non-alphabetic
79209 return "non-alpha";
79210 }
79211
79212 if (firstChar === firstCharLower) {
79213 return "lower";
79214 }
79215
79216 return "upper";
79217 }
79218 /**
79219 * Check if capitalization is allowed for a CallExpression
79220 * @param {Object} allowedMap Object mapping calleeName to a Boolean
79221 * @param {ASTNode} node CallExpression node
79222 * @param {string} calleeName Capitalized callee name from a CallExpression
79223 * @param {Object} pattern RegExp object from options pattern
79224 * @returns {boolean} Returns true if the callee may be capitalized
79225 */
79226
79227
79228 function isCapAllowed(allowedMap, node, calleeName, pattern) {
79229 const sourceText = sourceCode.getText(node.callee);
79230
79231 if (allowedMap[calleeName] || allowedMap[sourceText]) {
79232 return true;
79233 }
79234
79235 if (pattern && pattern.test(sourceText)) {
79236 return true;
79237 }
79238
79239 const callee = astUtils.skipChainExpression(node.callee);
79240
79241 if (calleeName === "UTC" && callee.type === "MemberExpression") {
79242 // allow if callee is Date.UTC
79243 return callee.object.type === "Identifier" && callee.object.name === "Date";
79244 }
79245
79246 return skipProperties && callee.type === "MemberExpression";
79247 }
79248 /**
79249 * Reports the given messageId for the given node. The location will be the start of the property or the callee.
79250 * @param {ASTNode} node CallExpression or NewExpression node.
79251 * @param {string} messageId The messageId to report.
79252 * @returns {void}
79253 */
79254
79255
79256 function report(node, messageId) {
79257 let callee = astUtils.skipChainExpression(node.callee);
79258
79259 if (callee.type === "MemberExpression") {
79260 callee = callee.property;
79261 }
79262
79263 context.report({
79264 node,
79265 loc: callee.loc,
79266 messageId
79267 });
79268 } //--------------------------------------------------------------------------
79269 // Public
79270 //--------------------------------------------------------------------------
79271
79272
79273 if (config.newIsCap) {
79274 listeners.NewExpression = function (node) {
79275 const constructorName = extractNameFromExpression(node);
79276
79277 if (constructorName) {
79278 const capitalization = getCap(constructorName);
79279 const isAllowed = capitalization !== "lower" || isCapAllowed(newIsCapExceptions, node, constructorName, newIsCapExceptionPattern);
79280
79281 if (!isAllowed) {
79282 report(node, "lower");
79283 }
79284 }
79285 };
79286 }
79287
79288 if (config.capIsNew) {
79289 listeners.CallExpression = function (node) {
79290 const calleeName = extractNameFromExpression(node);
79291
79292 if (calleeName) {
79293 const capitalization = getCap(calleeName);
79294 const isAllowed = capitalization !== "upper" || isCapAllowed(capIsNewExceptions, node, calleeName, capIsNewExceptionPattern);
79295
79296 if (!isAllowed) {
79297 report(node, "upper");
79298 }
79299 }
79300 };
79301 }
79302
79303 return listeners;
79304 }
79305
79306 };
79307
79308 /***/ }),
79309 /* 628 */
79310 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
79311
79312 "use strict";
79313 /**
79314 * @fileoverview Rule to flag when using constructor without parentheses
79315 * @author Ilya Volodin
79316 */
79317 //------------------------------------------------------------------------------
79318 // Requirements
79319 //------------------------------------------------------------------------------
79320
79321 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
79322 // Helpers
79323 //------------------------------------------------------------------------------
79324 //------------------------------------------------------------------------------
79325 // Rule Definition
79326 //------------------------------------------------------------------------------
79327
79328
79329 module.exports = {
79330 meta: {
79331 type: "layout",
79332 docs: {
79333 description: "enforce or disallow parentheses when invoking a constructor with no arguments",
79334 recommended: false,
79335 url: "https://eslint.org/docs/rules/new-parens"
79336 },
79337 fixable: "code",
79338 schema: {
79339 anyOf: [{
79340 type: "array",
79341 items: [{
79342 enum: ["always", "never"]
79343 }],
79344 minItems: 0,
79345 maxItems: 1
79346 }]
79347 },
79348 messages: {
79349 missing: "Missing '()' invoking a constructor.",
79350 unnecessary: "Unnecessary '()' invoking a constructor with no arguments."
79351 }
79352 },
79353
79354 create(context) {
79355 const options = context.options;
79356 const always = options[0] !== "never"; // Default is always
79357
79358 const sourceCode = context.getSourceCode();
79359 return {
79360 NewExpression(node) {
79361 if (node.arguments.length !== 0) {
79362 return; // if there are arguments, there have to be parens
79363 }
79364
79365 const lastToken = sourceCode.getLastToken(node);
79366 const hasLastParen = lastToken && astUtils.isClosingParenToken(lastToken); // `hasParens` is true only if the new expression ends with its own parens, e.g., new new foo() does not end with its own parens
79367
79368 const hasParens = hasLastParen && astUtils.isOpeningParenToken(sourceCode.getTokenBefore(lastToken)) && node.callee.range[1] < node.range[1];
79369
79370 if (always) {
79371 if (!hasParens) {
79372 context.report({
79373 node,
79374 messageId: "missing",
79375 fix: fixer => fixer.insertTextAfter(node, "()")
79376 });
79377 }
79378 } else {
79379 if (hasParens) {
79380 context.report({
79381 node,
79382 messageId: "unnecessary",
79383 fix: fixer => [fixer.remove(sourceCode.getTokenBefore(lastToken)), fixer.remove(lastToken), fixer.insertTextBefore(node, "("), fixer.insertTextAfter(node, ")")]
79384 });
79385 }
79386 }
79387 }
79388
79389 };
79390 }
79391
79392 };
79393
79394 /***/ }),
79395 /* 629 */
79396 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
79397
79398 "use strict";
79399 /**
79400 * @fileoverview Rule to check empty newline after "var" statement
79401 * @author Gopal Venkatesan
79402 * @deprecated in ESLint v4.0.0
79403 */
79404 //------------------------------------------------------------------------------
79405 // Requirements
79406 //------------------------------------------------------------------------------
79407
79408 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
79409 // Rule Definition
79410 //------------------------------------------------------------------------------
79411
79412
79413 module.exports = {
79414 meta: {
79415 type: "layout",
79416 docs: {
79417 description: "require or disallow an empty line after variable declarations",
79418 recommended: false,
79419 url: "https://eslint.org/docs/rules/newline-after-var"
79420 },
79421 schema: [{
79422 enum: ["never", "always"]
79423 }],
79424 fixable: "whitespace",
79425 messages: {
79426 expected: "Expected blank line after variable declarations.",
79427 unexpected: "Unexpected blank line after variable declarations."
79428 },
79429 deprecated: true,
79430 replacedBy: ["padding-line-between-statements"]
79431 },
79432
79433 create(context) {
79434 const sourceCode = context.getSourceCode(); // Default `mode` to "always".
79435
79436 const mode = context.options[0] === "never" ? "never" : "always"; // Cache starting and ending line numbers of comments for faster lookup
79437
79438 const commentEndLine = sourceCode.getAllComments().reduce((result, token) => {
79439 result[token.loc.start.line] = token.loc.end.line;
79440 return result;
79441 }, {}); //--------------------------------------------------------------------------
79442 // Helpers
79443 //--------------------------------------------------------------------------
79444
79445 /**
79446 * Gets a token from the given node to compare line to the next statement.
79447 *
79448 * In general, the token is the last token of the node. However, the token is the second last token if the following conditions satisfy.
79449 *
79450 * - The last token is semicolon.
79451 * - The semicolon is on a different line from the previous token of the semicolon.
79452 *
79453 * This behavior would address semicolon-less style code. e.g.:
79454 *
79455 * var foo = 1
79456 *
79457 * ;(a || b).doSomething()
79458 * @param {ASTNode} node The node to get.
79459 * @returns {Token} The token to compare line to the next statement.
79460 */
79461
79462 function getLastToken(node) {
79463 const lastToken = sourceCode.getLastToken(node);
79464
79465 if (lastToken.type === "Punctuator" && lastToken.value === ";") {
79466 const prevToken = sourceCode.getTokenBefore(lastToken);
79467
79468 if (prevToken.loc.end.line !== lastToken.loc.start.line) {
79469 return prevToken;
79470 }
79471 }
79472
79473 return lastToken;
79474 }
79475 /**
79476 * Determine if provided keyword is a variable declaration
79477 * @private
79478 * @param {string} keyword keyword to test
79479 * @returns {boolean} True if `keyword` is a type of var
79480 */
79481
79482
79483 function isVar(keyword) {
79484 return keyword === "var" || keyword === "let" || keyword === "const";
79485 }
79486 /**
79487 * Determine if provided keyword is a variant of for specifiers
79488 * @private
79489 * @param {string} keyword keyword to test
79490 * @returns {boolean} True if `keyword` is a variant of for specifier
79491 */
79492
79493
79494 function isForTypeSpecifier(keyword) {
79495 return keyword === "ForStatement" || keyword === "ForInStatement" || keyword === "ForOfStatement";
79496 }
79497 /**
79498 * Determine if provided keyword is an export specifiers
79499 * @private
79500 * @param {string} nodeType nodeType to test
79501 * @returns {boolean} True if `nodeType` is an export specifier
79502 */
79503
79504
79505 function isExportSpecifier(nodeType) {
79506 return nodeType === "ExportNamedDeclaration" || nodeType === "ExportSpecifier" || nodeType === "ExportDefaultDeclaration" || nodeType === "ExportAllDeclaration";
79507 }
79508 /**
79509 * Determine if provided node is the last of their parent block.
79510 * @private
79511 * @param {ASTNode} node node to test
79512 * @returns {boolean} True if `node` is last of their parent block.
79513 */
79514
79515
79516 function isLastNode(node) {
79517 const token = sourceCode.getTokenAfter(node);
79518 return !token || token.type === "Punctuator" && token.value === "}";
79519 }
79520 /**
79521 * Gets the last line of a group of consecutive comments
79522 * @param {number} commentStartLine The starting line of the group
79523 * @returns {number} The number of the last comment line of the group
79524 */
79525
79526
79527 function getLastCommentLineOfBlock(commentStartLine) {
79528 const currentCommentEnd = commentEndLine[commentStartLine];
79529 return commentEndLine[currentCommentEnd + 1] ? getLastCommentLineOfBlock(currentCommentEnd + 1) : currentCommentEnd;
79530 }
79531 /**
79532 * Determine if a token starts more than one line after a comment ends
79533 * @param {token} token The token being checked
79534 * @param {integer} commentStartLine The line number on which the comment starts
79535 * @returns {boolean} True if `token` does not start immediately after a comment
79536 */
79537
79538
79539 function hasBlankLineAfterComment(token, commentStartLine) {
79540 return token.loc.start.line > getLastCommentLineOfBlock(commentStartLine) + 1;
79541 }
79542 /**
79543 * Checks that a blank line exists after a variable declaration when mode is
79544 * set to "always", or checks that there is no blank line when mode is set
79545 * to "never"
79546 * @private
79547 * @param {ASTNode} node `VariableDeclaration` node to test
79548 * @returns {void}
79549 */
79550
79551
79552 function checkForBlankLine(node) {
79553 /*
79554 * lastToken is the last token on the node's line. It will usually also be the last token of the node, but it will
79555 * sometimes be second-last if there is a semicolon on a different line.
79556 */
79557 const lastToken = getLastToken(node),
79558
79559 /*
79560 * If lastToken is the last token of the node, nextToken should be the token after the node. Otherwise, nextToken
79561 * is the last token of the node.
79562 */
79563 nextToken = lastToken === sourceCode.getLastToken(node) ? sourceCode.getTokenAfter(node) : sourceCode.getLastToken(node),
79564 nextLineNum = lastToken.loc.end.line + 1; // Ignore if there is no following statement
79565
79566 if (!nextToken) {
79567 return;
79568 } // Ignore if parent of node is a for variant
79569
79570
79571 if (isForTypeSpecifier(node.parent.type)) {
79572 return;
79573 } // Ignore if parent of node is an export specifier
79574
79575
79576 if (isExportSpecifier(node.parent.type)) {
79577 return;
79578 }
79579 /*
79580 * Some coding styles use multiple `var` statements, so do nothing if
79581 * the next token is a `var` statement.
79582 */
79583
79584
79585 if (nextToken.type === "Keyword" && isVar(nextToken.value)) {
79586 return;
79587 } // Ignore if it is last statement in a block
79588
79589
79590 if (isLastNode(node)) {
79591 return;
79592 } // Next statement is not a `var`...
79593
79594
79595 const noNextLineToken = nextToken.loc.start.line > nextLineNum;
79596 const hasNextLineComment = typeof commentEndLine[nextLineNum] !== "undefined";
79597
79598 if (mode === "never" && noNextLineToken && !hasNextLineComment) {
79599 context.report({
79600 node,
79601 messageId: "unexpected",
79602 data: {
79603 identifier: node.name
79604 },
79605
79606 fix(fixer) {
79607 const linesBetween = sourceCode.getText().slice(lastToken.range[1], nextToken.range[0]).split(astUtils.LINEBREAK_MATCHER);
79608 return fixer.replaceTextRange([lastToken.range[1], nextToken.range[0]], "".concat(linesBetween.slice(0, -1).join(""), "\n").concat(linesBetween[linesBetween.length - 1]));
79609 }
79610
79611 });
79612 } // Token on the next line, or comment without blank line
79613
79614
79615 if (mode === "always" && (!noNextLineToken || hasNextLineComment && !hasBlankLineAfterComment(nextToken, nextLineNum))) {
79616 context.report({
79617 node,
79618 messageId: "expected",
79619 data: {
79620 identifier: node.name
79621 },
79622
79623 fix(fixer) {
79624 if ((noNextLineToken ? getLastCommentLineOfBlock(nextLineNum) : lastToken.loc.end.line) === nextToken.loc.start.line) {
79625 return fixer.insertTextBefore(nextToken, "\n\n");
79626 }
79627
79628 return fixer.insertTextBeforeRange([nextToken.range[0] - nextToken.loc.start.column, nextToken.range[1]], "\n");
79629 }
79630
79631 });
79632 }
79633 } //--------------------------------------------------------------------------
79634 // Public
79635 //--------------------------------------------------------------------------
79636
79637
79638 return {
79639 VariableDeclaration: checkForBlankLine
79640 };
79641 }
79642
79643 };
79644
79645 /***/ }),
79646 /* 630 */
79647 /***/ ((module) => {
79648
79649 "use strict";
79650 /**
79651 * @fileoverview Rule to require newlines before `return` statement
79652 * @author Kai Cataldo
79653 * @deprecated in ESLint v4.0.0
79654 */
79655 //------------------------------------------------------------------------------
79656 // Rule Definition
79657 //------------------------------------------------------------------------------
79658
79659 module.exports = {
79660 meta: {
79661 type: "layout",
79662 docs: {
79663 description: "require an empty line before `return` statements",
79664 recommended: false,
79665 url: "https://eslint.org/docs/rules/newline-before-return"
79666 },
79667 fixable: "whitespace",
79668 schema: [],
79669 messages: {
79670 expected: "Expected newline before return statement."
79671 },
79672 deprecated: true,
79673 replacedBy: ["padding-line-between-statements"]
79674 },
79675
79676 create(context) {
79677 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
79678 // Helpers
79679 //--------------------------------------------------------------------------
79680
79681 /**
79682 * Tests whether node is preceded by supplied tokens
79683 * @param {ASTNode} node node to check
79684 * @param {Array} testTokens array of tokens to test against
79685 * @returns {boolean} Whether or not the node is preceded by one of the supplied tokens
79686 * @private
79687 */
79688
79689 function isPrecededByTokens(node, testTokens) {
79690 const tokenBefore = sourceCode.getTokenBefore(node);
79691 return testTokens.some(token => tokenBefore.value === token);
79692 }
79693 /**
79694 * Checks whether node is the first node after statement or in block
79695 * @param {ASTNode} node node to check
79696 * @returns {boolean} Whether or not the node is the first node after statement or in block
79697 * @private
79698 */
79699
79700
79701 function isFirstNode(node) {
79702 const parentType = node.parent.type;
79703
79704 if (node.parent.body) {
79705 return Array.isArray(node.parent.body) ? node.parent.body[0] === node : node.parent.body === node;
79706 }
79707
79708 if (parentType === "IfStatement") {
79709 return isPrecededByTokens(node, ["else", ")"]);
79710 }
79711
79712 if (parentType === "DoWhileStatement") {
79713 return isPrecededByTokens(node, ["do"]);
79714 }
79715
79716 if (parentType === "SwitchCase") {
79717 return isPrecededByTokens(node, [":"]);
79718 }
79719
79720 return isPrecededByTokens(node, [")"]);
79721 }
79722 /**
79723 * Returns the number of lines of comments that precede the node
79724 * @param {ASTNode} node node to check for overlapping comments
79725 * @param {number} lineNumTokenBefore line number of previous token, to check for overlapping comments
79726 * @returns {number} Number of lines of comments that precede the node
79727 * @private
79728 */
79729
79730
79731 function calcCommentLines(node, lineNumTokenBefore) {
79732 const comments = sourceCode.getCommentsBefore(node);
79733 let numLinesComments = 0;
79734
79735 if (!comments.length) {
79736 return numLinesComments;
79737 }
79738
79739 comments.forEach(comment => {
79740 numLinesComments++;
79741
79742 if (comment.type === "Block") {
79743 numLinesComments += comment.loc.end.line - comment.loc.start.line;
79744 } // avoid counting lines with inline comments twice
79745
79746
79747 if (comment.loc.start.line === lineNumTokenBefore) {
79748 numLinesComments--;
79749 }
79750
79751 if (comment.loc.end.line === node.loc.start.line) {
79752 numLinesComments--;
79753 }
79754 });
79755 return numLinesComments;
79756 }
79757 /**
79758 * Returns the line number of the token before the node that is passed in as an argument
79759 * @param {ASTNode} node The node to use as the start of the calculation
79760 * @returns {number} Line number of the token before `node`
79761 * @private
79762 */
79763
79764
79765 function getLineNumberOfTokenBefore(node) {
79766 const tokenBefore = sourceCode.getTokenBefore(node);
79767 let lineNumTokenBefore;
79768 /**
79769 * Global return (at the beginning of a script) is a special case.
79770 * If there is no token before `return`, then we expect no line
79771 * break before the return. Comments are allowed to occupy lines
79772 * before the global return, just no blank lines.
79773 * Setting lineNumTokenBefore to zero in that case results in the
79774 * desired behavior.
79775 */
79776
79777 if (tokenBefore) {
79778 lineNumTokenBefore = tokenBefore.loc.end.line;
79779 } else {
79780 lineNumTokenBefore = 0; // global return at beginning of script
79781 }
79782
79783 return lineNumTokenBefore;
79784 }
79785 /**
79786 * Checks whether node is preceded by a newline
79787 * @param {ASTNode} node node to check
79788 * @returns {boolean} Whether or not the node is preceded by a newline
79789 * @private
79790 */
79791
79792
79793 function hasNewlineBefore(node) {
79794 const lineNumNode = node.loc.start.line;
79795 const lineNumTokenBefore = getLineNumberOfTokenBefore(node);
79796 const commentLines = calcCommentLines(node, lineNumTokenBefore);
79797 return lineNumNode - lineNumTokenBefore - commentLines > 1;
79798 }
79799 /**
79800 * Checks whether it is safe to apply a fix to a given return statement.
79801 *
79802 * The fix is not considered safe if the given return statement has leading comments,
79803 * as we cannot safely determine if the newline should be added before or after the comments.
79804 * For more information, see: https://github.com/eslint/eslint/issues/5958#issuecomment-222767211
79805 * @param {ASTNode} node The return statement node to check.
79806 * @returns {boolean} `true` if it can fix the node.
79807 * @private
79808 */
79809
79810
79811 function canFix(node) {
79812 const leadingComments = sourceCode.getCommentsBefore(node);
79813 const lastLeadingComment = leadingComments[leadingComments.length - 1];
79814 const tokenBefore = sourceCode.getTokenBefore(node);
79815
79816 if (leadingComments.length === 0) {
79817 return true;
79818 }
79819 /*
79820 * if the last leading comment ends in the same line as the previous token and
79821 * does not share a line with the `return` node, we can consider it safe to fix.
79822 * Example:
79823 * function a() {
79824 * var b; //comment
79825 * return;
79826 * }
79827 */
79828
79829
79830 if (lastLeadingComment.loc.end.line === tokenBefore.loc.end.line && lastLeadingComment.loc.end.line !== node.loc.start.line) {
79831 return true;
79832 }
79833
79834 return false;
79835 } //--------------------------------------------------------------------------
79836 // Public
79837 //--------------------------------------------------------------------------
79838
79839
79840 return {
79841 ReturnStatement(node) {
79842 if (!isFirstNode(node) && !hasNewlineBefore(node)) {
79843 context.report({
79844 node,
79845 messageId: "expected",
79846
79847 fix(fixer) {
79848 if (canFix(node)) {
79849 const tokenBefore = sourceCode.getTokenBefore(node);
79850 const newlines = node.loc.start.line === tokenBefore.loc.end.line ? "\n\n" : "\n";
79851 return fixer.insertTextBefore(node, newlines);
79852 }
79853
79854 return null;
79855 }
79856
79857 });
79858 }
79859 }
79860
79861 };
79862 }
79863
79864 };
79865
79866 /***/ }),
79867 /* 631 */
79868 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
79869
79870 "use strict";
79871 /**
79872 * @fileoverview Rule to ensure newline per method call when chaining calls
79873 * @author Rajendra Patil
79874 * @author Burak Yigit Kaya
79875 */
79876
79877
79878 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
79879 // Rule Definition
79880 //------------------------------------------------------------------------------
79881
79882
79883 module.exports = {
79884 meta: {
79885 type: "layout",
79886 docs: {
79887 description: "require a newline after each call in a method chain",
79888 recommended: false,
79889 url: "https://eslint.org/docs/rules/newline-per-chained-call"
79890 },
79891 fixable: "whitespace",
79892 schema: [{
79893 type: "object",
79894 properties: {
79895 ignoreChainWithDepth: {
79896 type: "integer",
79897 minimum: 1,
79898 maximum: 10,
79899 default: 2
79900 }
79901 },
79902 additionalProperties: false
79903 }],
79904 messages: {
79905 expected: "Expected line break before `{{callee}}`."
79906 }
79907 },
79908
79909 create(context) {
79910 const options = context.options[0] || {},
79911 ignoreChainWithDepth = options.ignoreChainWithDepth || 2;
79912 const sourceCode = context.getSourceCode();
79913 /**
79914 * Get the prefix of a given MemberExpression node.
79915 * If the MemberExpression node is a computed value it returns a
79916 * left bracket. If not it returns a period.
79917 * @param {ASTNode} node A MemberExpression node to get
79918 * @returns {string} The prefix of the node.
79919 */
79920
79921 function getPrefix(node) {
79922 if (node.computed) {
79923 if (node.optional) {
79924 return "?.[";
79925 }
79926
79927 return "[";
79928 }
79929
79930 if (node.optional) {
79931 return "?.";
79932 }
79933
79934 return ".";
79935 }
79936 /**
79937 * Gets the property text of a given MemberExpression node.
79938 * If the text is multiline, this returns only the first line.
79939 * @param {ASTNode} node A MemberExpression node to get.
79940 * @returns {string} The property text of the node.
79941 */
79942
79943
79944 function getPropertyText(node) {
79945 const prefix = getPrefix(node);
79946 const lines = sourceCode.getText(node.property).split(astUtils.LINEBREAK_MATCHER);
79947 const suffix = node.computed && lines.length === 1 ? "]" : "";
79948 return prefix + lines[0] + suffix;
79949 }
79950
79951 return {
79952 "CallExpression:exit"(node) {
79953 const callee = astUtils.skipChainExpression(node.callee);
79954
79955 if (callee.type !== "MemberExpression") {
79956 return;
79957 }
79958
79959 let parent = astUtils.skipChainExpression(callee.object);
79960 let depth = 1;
79961
79962 while (parent && parent.callee) {
79963 depth += 1;
79964 parent = astUtils.skipChainExpression(astUtils.skipChainExpression(parent.callee).object);
79965 }
79966
79967 if (depth > ignoreChainWithDepth && astUtils.isTokenOnSameLine(callee.object, callee.property)) {
79968 const firstTokenAfterObject = sourceCode.getTokenAfter(callee.object, astUtils.isNotClosingParenToken);
79969 context.report({
79970 node: callee.property,
79971 loc: {
79972 start: firstTokenAfterObject.loc.start,
79973 end: callee.loc.end
79974 },
79975 messageId: "expected",
79976 data: {
79977 callee: getPropertyText(callee)
79978 },
79979
79980 fix(fixer) {
79981 return fixer.insertTextBefore(firstTokenAfterObject, "\n");
79982 }
79983
79984 });
79985 }
79986 }
79987
79988 };
79989 }
79990
79991 };
79992
79993 /***/ }),
79994 /* 632 */
79995 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
79996
79997 "use strict";
79998 /**
79999 * @fileoverview Rule to flag use of alert, confirm, prompt
80000 * @author Nicholas C. Zakas
80001 */
80002 //------------------------------------------------------------------------------
80003 // Requirements
80004 //------------------------------------------------------------------------------
80005
80006 const {
80007 getStaticPropertyName: getPropertyName,
80008 getVariableByName,
80009 skipChainExpression
80010 } = __webpack_require__(548); //------------------------------------------------------------------------------
80011 // Helpers
80012 //------------------------------------------------------------------------------
80013
80014 /**
80015 * Checks if the given name is a prohibited identifier.
80016 * @param {string} name The name to check
80017 * @returns {boolean} Whether or not the name is prohibited.
80018 */
80019
80020
80021 function isProhibitedIdentifier(name) {
80022 return /^(alert|confirm|prompt)$/u.test(name);
80023 }
80024 /**
80025 * Finds the eslint-scope reference in the given scope.
80026 * @param {Object} scope The scope to search.
80027 * @param {ASTNode} node The identifier node.
80028 * @returns {Reference|null} Returns the found reference or null if none were found.
80029 */
80030
80031
80032 function findReference(scope, node) {
80033 const references = scope.references.filter(reference => reference.identifier.range[0] === node.range[0] && reference.identifier.range[1] === node.range[1]);
80034
80035 if (references.length === 1) {
80036 return references[0];
80037 }
80038
80039 return null;
80040 }
80041 /**
80042 * Checks if the given identifier node is shadowed in the given scope.
80043 * @param {Object} scope The current scope.
80044 * @param {string} node The identifier node to check
80045 * @returns {boolean} Whether or not the name is shadowed.
80046 */
80047
80048
80049 function isShadowed(scope, node) {
80050 const reference = findReference(scope, node);
80051 return reference && reference.resolved && reference.resolved.defs.length > 0;
80052 }
80053 /**
80054 * Checks if the given identifier node is a ThisExpression in the global scope or the global window property.
80055 * @param {Object} scope The current scope.
80056 * @param {string} node The identifier node to check
80057 * @returns {boolean} Whether or not the node is a reference to the global object.
80058 */
80059
80060
80061 function isGlobalThisReferenceOrGlobalWindow(scope, node) {
80062 if (scope.type === "global" && node.type === "ThisExpression") {
80063 return true;
80064 }
80065
80066 if (node.type === "Identifier" && (node.name === "window" || node.name === "globalThis" && getVariableByName(scope, "globalThis"))) {
80067 return !isShadowed(scope, node);
80068 }
80069
80070 return false;
80071 } //------------------------------------------------------------------------------
80072 // Rule Definition
80073 //------------------------------------------------------------------------------
80074
80075
80076 module.exports = {
80077 meta: {
80078 type: "suggestion",
80079 docs: {
80080 description: "disallow the use of `alert`, `confirm`, and `prompt`",
80081 recommended: false,
80082 url: "https://eslint.org/docs/rules/no-alert"
80083 },
80084 schema: [],
80085 messages: {
80086 unexpected: "Unexpected {{name}}."
80087 }
80088 },
80089
80090 create(context) {
80091 return {
80092 CallExpression(node) {
80093 const callee = skipChainExpression(node.callee),
80094 currentScope = context.getScope(); // without window.
80095
80096 if (callee.type === "Identifier") {
80097 const name = callee.name;
80098
80099 if (!isShadowed(currentScope, callee) && isProhibitedIdentifier(callee.name)) {
80100 context.report({
80101 node,
80102 messageId: "unexpected",
80103 data: {
80104 name
80105 }
80106 });
80107 }
80108 } else if (callee.type === "MemberExpression" && isGlobalThisReferenceOrGlobalWindow(currentScope, callee.object)) {
80109 const name = getPropertyName(callee);
80110
80111 if (isProhibitedIdentifier(name)) {
80112 context.report({
80113 node,
80114 messageId: "unexpected",
80115 data: {
80116 name
80117 }
80118 });
80119 }
80120 }
80121 }
80122
80123 };
80124 }
80125
80126 };
80127
80128 /***/ }),
80129 /* 633 */
80130 /***/ ((module) => {
80131
80132 "use strict";
80133 /**
80134 * @fileoverview Disallow construction of dense arrays using the Array constructor
80135 * @author Matt DuVall <http://www.mattduvall.com/>
80136 */
80137 //------------------------------------------------------------------------------
80138 // Rule Definition
80139 //------------------------------------------------------------------------------
80140
80141 module.exports = {
80142 meta: {
80143 type: "suggestion",
80144 docs: {
80145 description: "disallow `Array` constructors",
80146 recommended: false,
80147 url: "https://eslint.org/docs/rules/no-array-constructor"
80148 },
80149 schema: [],
80150 messages: {
80151 preferLiteral: "The array literal notation [] is preferable."
80152 }
80153 },
80154
80155 create(context) {
80156 /**
80157 * Disallow construction of dense arrays using the Array constructor
80158 * @param {ASTNode} node node to evaluate
80159 * @returns {void}
80160 * @private
80161 */
80162 function check(node) {
80163 if (node.arguments.length !== 1 && node.callee.type === "Identifier" && node.callee.name === "Array") {
80164 context.report({
80165 node,
80166 messageId: "preferLiteral"
80167 });
80168 }
80169 }
80170
80171 return {
80172 CallExpression: check,
80173 NewExpression: check
80174 };
80175 }
80176
80177 };
80178
80179 /***/ }),
80180 /* 634 */
80181 /***/ ((module) => {
80182
80183 "use strict";
80184 /**
80185 * @fileoverview disallow using an async function as a Promise executor
80186 * @author Teddy Katz
80187 */
80188 //------------------------------------------------------------------------------
80189 // Rule Definition
80190 //------------------------------------------------------------------------------
80191
80192 module.exports = {
80193 meta: {
80194 type: "problem",
80195 docs: {
80196 description: "disallow using an async function as a Promise executor",
80197 recommended: true,
80198 url: "https://eslint.org/docs/rules/no-async-promise-executor"
80199 },
80200 fixable: null,
80201 schema: [],
80202 messages: {
80203 async: "Promise executor functions should not be async."
80204 }
80205 },
80206
80207 create(context) {
80208 return {
80209 "NewExpression[callee.name='Promise'][arguments.0.async=true]"(node) {
80210 context.report({
80211 node: context.getSourceCode().getFirstToken(node.arguments[0], token => token.value === "async"),
80212 messageId: "async"
80213 });
80214 }
80215
80216 };
80217 }
80218
80219 };
80220
80221 /***/ }),
80222 /* 635 */
80223 /***/ ((module) => {
80224
80225 "use strict";
80226 /**
80227 * @fileoverview Rule to disallow uses of await inside of loops.
80228 * @author Nat Mote (nmote)
80229 */
80230
80231 /**
80232 * Check whether it should stop traversing ancestors at the given node.
80233 * @param {ASTNode} node A node to check.
80234 * @returns {boolean} `true` if it should stop traversing.
80235 */
80236
80237 function isBoundary(node) {
80238 const t = node.type;
80239 return t === "FunctionDeclaration" || t === "FunctionExpression" || t === "ArrowFunctionExpression" ||
80240 /*
80241 * Don't report the await expressions on for-await-of loop since it's
80242 * asynchronous iteration intentionally.
80243 */
80244 t === "ForOfStatement" && node.await === true;
80245 }
80246 /**
80247 * Check whether the given node is in loop.
80248 * @param {ASTNode} node A node to check.
80249 * @param {ASTNode} parent A parent node to check.
80250 * @returns {boolean} `true` if the node is in loop.
80251 */
80252
80253
80254 function isLooped(node, parent) {
80255 switch (parent.type) {
80256 case "ForStatement":
80257 return node === parent.test || node === parent.update || node === parent.body;
80258
80259 case "ForOfStatement":
80260 case "ForInStatement":
80261 return node === parent.body;
80262
80263 case "WhileStatement":
80264 case "DoWhileStatement":
80265 return node === parent.test || node === parent.body;
80266
80267 default:
80268 return false;
80269 }
80270 }
80271
80272 module.exports = {
80273 meta: {
80274 type: "problem",
80275 docs: {
80276 description: "disallow `await` inside of loops",
80277 recommended: false,
80278 url: "https://eslint.org/docs/rules/no-await-in-loop"
80279 },
80280 schema: [],
80281 messages: {
80282 unexpectedAwait: "Unexpected `await` inside a loop."
80283 }
80284 },
80285
80286 create(context) {
80287 /**
80288 * Validate an await expression.
80289 * @param {ASTNode} awaitNode An AwaitExpression or ForOfStatement node to validate.
80290 * @returns {void}
80291 */
80292 function validate(awaitNode) {
80293 if (awaitNode.type === "ForOfStatement" && !awaitNode.await) {
80294 return;
80295 }
80296
80297 let node = awaitNode;
80298 let parent = node.parent;
80299
80300 while (parent && !isBoundary(parent)) {
80301 if (isLooped(node, parent)) {
80302 context.report({
80303 node: awaitNode,
80304 messageId: "unexpectedAwait"
80305 });
80306 return;
80307 }
80308
80309 node = parent;
80310 parent = parent.parent;
80311 }
80312 }
80313
80314 return {
80315 AwaitExpression: validate,
80316 ForOfStatement: validate
80317 };
80318 }
80319
80320 };
80321
80322 /***/ }),
80323 /* 636 */
80324 /***/ ((module) => {
80325
80326 "use strict";
80327 /**
80328 * @fileoverview Rule to flag bitwise identifiers
80329 * @author Nicholas C. Zakas
80330 */
80331
80332 /*
80333 *
80334 * Set of bitwise operators.
80335 *
80336 */
80337
80338 const BITWISE_OPERATORS = ["^", "|", "&", "<<", ">>", ">>>", "^=", "|=", "&=", "<<=", ">>=", ">>>=", "~"]; //------------------------------------------------------------------------------
80339 // Rule Definition
80340 //------------------------------------------------------------------------------
80341
80342 module.exports = {
80343 meta: {
80344 type: "suggestion",
80345 docs: {
80346 description: "disallow bitwise operators",
80347 recommended: false,
80348 url: "https://eslint.org/docs/rules/no-bitwise"
80349 },
80350 schema: [{
80351 type: "object",
80352 properties: {
80353 allow: {
80354 type: "array",
80355 items: {
80356 enum: BITWISE_OPERATORS
80357 },
80358 uniqueItems: true
80359 },
80360 int32Hint: {
80361 type: "boolean",
80362 default: false
80363 }
80364 },
80365 additionalProperties: false
80366 }],
80367 messages: {
80368 unexpected: "Unexpected use of '{{operator}}'."
80369 }
80370 },
80371
80372 create(context) {
80373 const options = context.options[0] || {};
80374 const allowed = options.allow || [];
80375 const int32Hint = options.int32Hint === true;
80376 /**
80377 * Reports an unexpected use of a bitwise operator.
80378 * @param {ASTNode} node Node which contains the bitwise operator.
80379 * @returns {void}
80380 */
80381
80382 function report(node) {
80383 context.report({
80384 node,
80385 messageId: "unexpected",
80386 data: {
80387 operator: node.operator
80388 }
80389 });
80390 }
80391 /**
80392 * Checks if the given node has a bitwise operator.
80393 * @param {ASTNode} node The node to check.
80394 * @returns {boolean} Whether or not the node has a bitwise operator.
80395 */
80396
80397
80398 function hasBitwiseOperator(node) {
80399 return BITWISE_OPERATORS.indexOf(node.operator) !== -1;
80400 }
80401 /**
80402 * Checks if exceptions were provided, e.g. `{ allow: ['~', '|'] }`.
80403 * @param {ASTNode} node The node to check.
80404 * @returns {boolean} Whether or not the node has a bitwise operator.
80405 */
80406
80407
80408 function allowedOperator(node) {
80409 return allowed.indexOf(node.operator) !== -1;
80410 }
80411 /**
80412 * Checks if the given bitwise operator is used for integer typecasting, i.e. "|0"
80413 * @param {ASTNode} node The node to check.
80414 * @returns {boolean} whether the node is used in integer typecasting.
80415 */
80416
80417
80418 function isInt32Hint(node) {
80419 return int32Hint && node.operator === "|" && node.right && node.right.type === "Literal" && node.right.value === 0;
80420 }
80421 /**
80422 * Report if the given node contains a bitwise operator.
80423 * @param {ASTNode} node The node to check.
80424 * @returns {void}
80425 */
80426
80427
80428 function checkNodeForBitwiseOperator(node) {
80429 if (hasBitwiseOperator(node) && !allowedOperator(node) && !isInt32Hint(node)) {
80430 report(node);
80431 }
80432 }
80433
80434 return {
80435 AssignmentExpression: checkNodeForBitwiseOperator,
80436 BinaryExpression: checkNodeForBitwiseOperator,
80437 UnaryExpression: checkNodeForBitwiseOperator
80438 };
80439 }
80440
80441 };
80442
80443 /***/ }),
80444 /* 637 */
80445 /***/ ((module) => {
80446
80447 "use strict";
80448 /**
80449 * @fileoverview disallow use of the Buffer() constructor
80450 * @author Teddy Katz
80451 * @deprecated in ESLint v7.0.0
80452 */
80453 //------------------------------------------------------------------------------
80454 // Rule Definition
80455 //------------------------------------------------------------------------------
80456
80457 module.exports = {
80458 meta: {
80459 deprecated: true,
80460 replacedBy: [],
80461 type: "problem",
80462 docs: {
80463 description: "disallow use of the `Buffer()` constructor",
80464 recommended: false,
80465 url: "https://eslint.org/docs/rules/no-buffer-constructor"
80466 },
80467 schema: [],
80468 messages: {
80469 deprecated: "{{expr}} is deprecated. Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead."
80470 }
80471 },
80472
80473 create(context) {
80474 //----------------------------------------------------------------------
80475 // Public
80476 //----------------------------------------------------------------------
80477 return {
80478 "CallExpression[callee.name='Buffer'], NewExpression[callee.name='Buffer']"(node) {
80479 context.report({
80480 node,
80481 messageId: "deprecated",
80482 data: {
80483 expr: node.type === "CallExpression" ? "Buffer()" : "new Buffer()"
80484 }
80485 });
80486 }
80487
80488 };
80489 }
80490
80491 };
80492
80493 /***/ }),
80494 /* 638 */
80495 /***/ ((module) => {
80496
80497 "use strict";
80498 /**
80499 * @fileoverview Rule to flag use of arguments.callee and arguments.caller.
80500 * @author Nicholas C. Zakas
80501 */
80502 //------------------------------------------------------------------------------
80503 // Rule Definition
80504 //------------------------------------------------------------------------------
80505
80506 module.exports = {
80507 meta: {
80508 type: "suggestion",
80509 docs: {
80510 description: "disallow the use of `arguments.caller` or `arguments.callee`",
80511 recommended: false,
80512 url: "https://eslint.org/docs/rules/no-caller"
80513 },
80514 schema: [],
80515 messages: {
80516 unexpected: "Avoid arguments.{{prop}}."
80517 }
80518 },
80519
80520 create(context) {
80521 return {
80522 MemberExpression(node) {
80523 const objectName = node.object.name,
80524 propertyName = node.property.name;
80525
80526 if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/u)) {
80527 context.report({
80528 node,
80529 messageId: "unexpected",
80530 data: {
80531 prop: propertyName
80532 }
80533 });
80534 }
80535 }
80536
80537 };
80538 }
80539
80540 };
80541
80542 /***/ }),
80543 /* 639 */
80544 /***/ ((module) => {
80545
80546 "use strict";
80547 /**
80548 * @fileoverview Rule to flag use of an lexical declarations inside a case clause
80549 * @author Erik Arvidsson
80550 */
80551 //------------------------------------------------------------------------------
80552 // Rule Definition
80553 //------------------------------------------------------------------------------
80554
80555 module.exports = {
80556 meta: {
80557 type: "suggestion",
80558 docs: {
80559 description: "disallow lexical declarations in case clauses",
80560 recommended: true,
80561 url: "https://eslint.org/docs/rules/no-case-declarations"
80562 },
80563 schema: [],
80564 messages: {
80565 unexpected: "Unexpected lexical declaration in case block."
80566 }
80567 },
80568
80569 create(context) {
80570 /**
80571 * Checks whether or not a node is a lexical declaration.
80572 * @param {ASTNode} node A direct child statement of a switch case.
80573 * @returns {boolean} Whether or not the node is a lexical declaration.
80574 */
80575 function isLexicalDeclaration(node) {
80576 switch (node.type) {
80577 case "FunctionDeclaration":
80578 case "ClassDeclaration":
80579 return true;
80580
80581 case "VariableDeclaration":
80582 return node.kind !== "var";
80583
80584 default:
80585 return false;
80586 }
80587 }
80588
80589 return {
80590 SwitchCase(node) {
80591 for (let i = 0; i < node.consequent.length; i++) {
80592 const statement = node.consequent[i];
80593
80594 if (isLexicalDeclaration(statement)) {
80595 context.report({
80596 node: statement,
80597 messageId: "unexpected"
80598 });
80599 }
80600 }
80601 }
80602
80603 };
80604 }
80605
80606 };
80607
80608 /***/ }),
80609 /* 640 */
80610 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
80611
80612 "use strict";
80613 /**
80614 * @fileoverview Rule to flag variable leak in CatchClauses in IE 8 and earlier
80615 * @author Ian Christian Myers
80616 * @deprecated in ESLint v5.1.0
80617 */
80618 //------------------------------------------------------------------------------
80619 // Requirements
80620 //------------------------------------------------------------------------------
80621
80622 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
80623 // Rule Definition
80624 //------------------------------------------------------------------------------
80625
80626
80627 module.exports = {
80628 meta: {
80629 type: "suggestion",
80630 docs: {
80631 description: "disallow `catch` clause parameters from shadowing variables in the outer scope",
80632 recommended: false,
80633 url: "https://eslint.org/docs/rules/no-catch-shadow"
80634 },
80635 replacedBy: ["no-shadow"],
80636 deprecated: true,
80637 schema: [],
80638 messages: {
80639 mutable: "Value of '{{name}}' may be overwritten in IE 8 and earlier."
80640 }
80641 },
80642
80643 create(context) {
80644 //--------------------------------------------------------------------------
80645 // Helpers
80646 //--------------------------------------------------------------------------
80647
80648 /**
80649 * Check if the parameters are been shadowed
80650 * @param {Object} scope current scope
80651 * @param {string} name parameter name
80652 * @returns {boolean} True is its been shadowed
80653 */
80654 function paramIsShadowing(scope, name) {
80655 return astUtils.getVariableByName(scope, name) !== null;
80656 } //--------------------------------------------------------------------------
80657 // Public API
80658 //--------------------------------------------------------------------------
80659
80660
80661 return {
80662 "CatchClause[param!=null]"(node) {
80663 let scope = context.getScope();
80664 /*
80665 * When ecmaVersion >= 6, CatchClause creates its own scope
80666 * so start from one upper scope to exclude the current node
80667 */
80668
80669 if (scope.block === node) {
80670 scope = scope.upper;
80671 }
80672
80673 if (paramIsShadowing(scope, node.param.name)) {
80674 context.report({
80675 node,
80676 messageId: "mutable",
80677 data: {
80678 name: node.param.name
80679 }
80680 });
80681 }
80682 }
80683
80684 };
80685 }
80686
80687 };
80688
80689 /***/ }),
80690 /* 641 */
80691 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
80692
80693 "use strict";
80694 /**
80695 * @fileoverview A rule to disallow modifying variables of class declarations
80696 * @author Toru Nagashima
80697 */
80698
80699
80700 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
80701 // Rule Definition
80702 //------------------------------------------------------------------------------
80703
80704
80705 module.exports = {
80706 meta: {
80707 type: "problem",
80708 docs: {
80709 description: "disallow reassigning class members",
80710 recommended: true,
80711 url: "https://eslint.org/docs/rules/no-class-assign"
80712 },
80713 schema: [],
80714 messages: {
80715 class: "'{{name}}' is a class."
80716 }
80717 },
80718
80719 create(context) {
80720 /**
80721 * Finds and reports references that are non initializer and writable.
80722 * @param {Variable} variable A variable to check.
80723 * @returns {void}
80724 */
80725 function checkVariable(variable) {
80726 astUtils.getModifyingReferences(variable.references).forEach(reference => {
80727 context.report({
80728 node: reference.identifier,
80729 messageId: "class",
80730 data: {
80731 name: reference.identifier.name
80732 }
80733 });
80734 });
80735 }
80736 /**
80737 * Finds and reports references that are non initializer and writable.
80738 * @param {ASTNode} node A ClassDeclaration/ClassExpression node to check.
80739 * @returns {void}
80740 */
80741
80742
80743 function checkForClass(node) {
80744 context.getDeclaredVariables(node).forEach(checkVariable);
80745 }
80746
80747 return {
80748 ClassDeclaration: checkForClass,
80749 ClassExpression: checkForClass
80750 };
80751 }
80752
80753 };
80754
80755 /***/ }),
80756 /* 642 */
80757 /***/ ((module) => {
80758
80759 "use strict";
80760 /**
80761 * @fileoverview The rule should warn against code that tries to compare against -0.
80762 * @author Aladdin-ADD <hh_2013@foxmail.com>
80763 */
80764 //------------------------------------------------------------------------------
80765 // Rule Definition
80766 //------------------------------------------------------------------------------
80767
80768 module.exports = {
80769 meta: {
80770 type: "problem",
80771 docs: {
80772 description: "disallow comparing against -0",
80773 recommended: true,
80774 url: "https://eslint.org/docs/rules/no-compare-neg-zero"
80775 },
80776 fixable: null,
80777 schema: [],
80778 messages: {
80779 unexpected: "Do not use the '{{operator}}' operator to compare against -0."
80780 }
80781 },
80782
80783 create(context) {
80784 //--------------------------------------------------------------------------
80785 // Helpers
80786 //--------------------------------------------------------------------------
80787
80788 /**
80789 * Checks a given node is -0
80790 * @param {ASTNode} node A node to check.
80791 * @returns {boolean} `true` if the node is -0.
80792 */
80793 function isNegZero(node) {
80794 return node.type === "UnaryExpression" && node.operator === "-" && node.argument.type === "Literal" && node.argument.value === 0;
80795 }
80796
80797 const OPERATORS_TO_CHECK = new Set([">", ">=", "<", "<=", "==", "===", "!=", "!=="]);
80798 return {
80799 BinaryExpression(node) {
80800 if (OPERATORS_TO_CHECK.has(node.operator)) {
80801 if (isNegZero(node.left) || isNegZero(node.right)) {
80802 context.report({
80803 node,
80804 messageId: "unexpected",
80805 data: {
80806 operator: node.operator
80807 }
80808 });
80809 }
80810 }
80811 }
80812
80813 };
80814 }
80815
80816 };
80817
80818 /***/ }),
80819 /* 643 */
80820 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
80821
80822 "use strict";
80823 /**
80824 * @fileoverview Rule to flag assignment in a conditional statement's test expression
80825 * @author Stephen Murray <spmurrayzzz>
80826 */
80827 //------------------------------------------------------------------------------
80828 // Requirements
80829 //------------------------------------------------------------------------------
80830
80831 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
80832 // Helpers
80833 //------------------------------------------------------------------------------
80834
80835
80836 const TEST_CONDITION_PARENT_TYPES = new Set(["IfStatement", "WhileStatement", "DoWhileStatement", "ForStatement", "ConditionalExpression"]);
80837 const NODE_DESCRIPTIONS = {
80838 DoWhileStatement: "a 'do...while' statement",
80839 ForStatement: "a 'for' statement",
80840 IfStatement: "an 'if' statement",
80841 WhileStatement: "a 'while' statement"
80842 }; //------------------------------------------------------------------------------
80843 // Rule Definition
80844 //------------------------------------------------------------------------------
80845
80846 module.exports = {
80847 meta: {
80848 type: "problem",
80849 docs: {
80850 description: "disallow assignment operators in conditional expressions",
80851 recommended: true,
80852 url: "https://eslint.org/docs/rules/no-cond-assign"
80853 },
80854 schema: [{
80855 enum: ["except-parens", "always"]
80856 }],
80857 messages: {
80858 unexpected: "Unexpected assignment within {{type}}.",
80859 // must match JSHint's error message
80860 missing: "Expected a conditional expression and instead saw an assignment."
80861 }
80862 },
80863
80864 create(context) {
80865 const prohibitAssign = context.options[0] || "except-parens";
80866 const sourceCode = context.getSourceCode();
80867 /**
80868 * Check whether an AST node is the test expression for a conditional statement.
80869 * @param {!Object} node The node to test.
80870 * @returns {boolean} `true` if the node is the text expression for a conditional statement; otherwise, `false`.
80871 */
80872
80873 function isConditionalTestExpression(node) {
80874 return node.parent && TEST_CONDITION_PARENT_TYPES.has(node.parent.type) && node === node.parent.test;
80875 }
80876 /**
80877 * Given an AST node, perform a bottom-up search for the first ancestor that represents a conditional statement.
80878 * @param {!Object} node The node to use at the start of the search.
80879 * @returns {?Object} The closest ancestor node that represents a conditional statement.
80880 */
80881
80882
80883 function findConditionalAncestor(node) {
80884 let currentAncestor = node;
80885
80886 do {
80887 if (isConditionalTestExpression(currentAncestor)) {
80888 return currentAncestor.parent;
80889 }
80890 } while ((currentAncestor = currentAncestor.parent) && !astUtils.isFunction(currentAncestor));
80891
80892 return null;
80893 }
80894 /**
80895 * Check whether the code represented by an AST node is enclosed in two sets of parentheses.
80896 * @param {!Object} node The node to test.
80897 * @returns {boolean} `true` if the code is enclosed in two sets of parentheses; otherwise, `false`.
80898 */
80899
80900
80901 function isParenthesisedTwice(node) {
80902 const previousToken = sourceCode.getTokenBefore(node, 1),
80903 nextToken = sourceCode.getTokenAfter(node, 1);
80904 return astUtils.isParenthesised(sourceCode, node) && previousToken && astUtils.isOpeningParenToken(previousToken) && previousToken.range[1] <= node.range[0] && astUtils.isClosingParenToken(nextToken) && nextToken.range[0] >= node.range[1];
80905 }
80906 /**
80907 * Check a conditional statement's test expression for top-level assignments that are not enclosed in parentheses.
80908 * @param {!Object} node The node for the conditional statement.
80909 * @returns {void}
80910 */
80911
80912
80913 function testForAssign(node) {
80914 if (node.test && node.test.type === "AssignmentExpression" && (node.type === "ForStatement" ? !astUtils.isParenthesised(sourceCode, node.test) : !isParenthesisedTwice(node.test))) {
80915 context.report({
80916 node: node.test,
80917 messageId: "missing"
80918 });
80919 }
80920 }
80921 /**
80922 * Check whether an assignment expression is descended from a conditional statement's test expression.
80923 * @param {!Object} node The node for the assignment expression.
80924 * @returns {void}
80925 */
80926
80927
80928 function testForConditionalAncestor(node) {
80929 const ancestor = findConditionalAncestor(node);
80930
80931 if (ancestor) {
80932 context.report({
80933 node,
80934 messageId: "unexpected",
80935 data: {
80936 type: NODE_DESCRIPTIONS[ancestor.type] || ancestor.type
80937 }
80938 });
80939 }
80940 }
80941
80942 if (prohibitAssign === "always") {
80943 return {
80944 AssignmentExpression: testForConditionalAncestor
80945 };
80946 }
80947
80948 return {
80949 DoWhileStatement: testForAssign,
80950 ForStatement: testForAssign,
80951 IfStatement: testForAssign,
80952 WhileStatement: testForAssign,
80953 ConditionalExpression: testForAssign
80954 };
80955 }
80956
80957 };
80958
80959 /***/ }),
80960 /* 644 */
80961 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
80962
80963 "use strict";
80964 /**
80965 * @fileoverview A rule to warn against using arrow functions when they could be
80966 * confused with comparisons
80967 * @author Jxck <https://github.com/Jxck>
80968 */
80969
80970
80971 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
80972 // Helpers
80973 //------------------------------------------------------------------------------
80974
80975 /**
80976 * Checks whether or not a node is a conditional expression.
80977 * @param {ASTNode} node node to test
80978 * @returns {boolean} `true` if the node is a conditional expression.
80979 */
80980
80981
80982 function isConditional(node) {
80983 return node && node.type === "ConditionalExpression";
80984 } //------------------------------------------------------------------------------
80985 // Rule Definition
80986 //------------------------------------------------------------------------------
80987
80988
80989 module.exports = {
80990 meta: {
80991 type: "suggestion",
80992 docs: {
80993 description: "disallow arrow functions where they could be confused with comparisons",
80994 recommended: false,
80995 url: "https://eslint.org/docs/rules/no-confusing-arrow"
80996 },
80997 fixable: "code",
80998 schema: [{
80999 type: "object",
81000 properties: {
81001 allowParens: {
81002 type: "boolean",
81003 default: true
81004 }
81005 },
81006 additionalProperties: false
81007 }],
81008 messages: {
81009 confusing: "Arrow function used ambiguously with a conditional expression."
81010 }
81011 },
81012
81013 create(context) {
81014 const config = context.options[0] || {};
81015 const allowParens = config.allowParens || config.allowParens === void 0;
81016 const sourceCode = context.getSourceCode();
81017 /**
81018 * Reports if an arrow function contains an ambiguous conditional.
81019 * @param {ASTNode} node A node to check and report.
81020 * @returns {void}
81021 */
81022
81023 function checkArrowFunc(node) {
81024 const body = node.body;
81025
81026 if (isConditional(body) && !(allowParens && astUtils.isParenthesised(sourceCode, body))) {
81027 context.report({
81028 node,
81029 messageId: "confusing",
81030
81031 fix(fixer) {
81032 // if `allowParens` is not set to true don't bother wrapping in parens
81033 return allowParens && fixer.replaceText(node.body, "(".concat(sourceCode.getText(node.body), ")"));
81034 }
81035
81036 });
81037 }
81038 }
81039
81040 return {
81041 ArrowFunctionExpression: checkArrowFunc
81042 };
81043 }
81044
81045 };
81046
81047 /***/ }),
81048 /* 645 */
81049 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
81050
81051 "use strict";
81052 /**
81053 * @fileoverview Rule to flag use of console object
81054 * @author Nicholas C. Zakas
81055 */
81056 //------------------------------------------------------------------------------
81057 // Requirements
81058 //------------------------------------------------------------------------------
81059
81060 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
81061 // Rule Definition
81062 //------------------------------------------------------------------------------
81063
81064
81065 module.exports = {
81066 meta: {
81067 type: "suggestion",
81068 docs: {
81069 description: "disallow the use of `console`",
81070 recommended: false,
81071 url: "https://eslint.org/docs/rules/no-console"
81072 },
81073 schema: [{
81074 type: "object",
81075 properties: {
81076 allow: {
81077 type: "array",
81078 items: {
81079 type: "string"
81080 },
81081 minItems: 1,
81082 uniqueItems: true
81083 }
81084 },
81085 additionalProperties: false
81086 }],
81087 messages: {
81088 unexpected: "Unexpected console statement."
81089 }
81090 },
81091
81092 create(context) {
81093 const options = context.options[0] || {};
81094 const allowed = options.allow || [];
81095 /**
81096 * Checks whether the given reference is 'console' or not.
81097 * @param {eslint-scope.Reference} reference The reference to check.
81098 * @returns {boolean} `true` if the reference is 'console'.
81099 */
81100
81101 function isConsole(reference) {
81102 const id = reference.identifier;
81103 return id && id.name === "console";
81104 }
81105 /**
81106 * Checks whether the property name of the given MemberExpression node
81107 * is allowed by options or not.
81108 * @param {ASTNode} node The MemberExpression node to check.
81109 * @returns {boolean} `true` if the property name of the node is allowed.
81110 */
81111
81112
81113 function isAllowed(node) {
81114 const propertyName = astUtils.getStaticPropertyName(node);
81115 return propertyName && allowed.indexOf(propertyName) !== -1;
81116 }
81117 /**
81118 * Checks whether the given reference is a member access which is not
81119 * allowed by options or not.
81120 * @param {eslint-scope.Reference} reference The reference to check.
81121 * @returns {boolean} `true` if the reference is a member access which
81122 * is not allowed by options.
81123 */
81124
81125
81126 function isMemberAccessExceptAllowed(reference) {
81127 const node = reference.identifier;
81128 const parent = node.parent;
81129 return parent.type === "MemberExpression" && parent.object === node && !isAllowed(parent);
81130 }
81131 /**
81132 * Reports the given reference as a violation.
81133 * @param {eslint-scope.Reference} reference The reference to report.
81134 * @returns {void}
81135 */
81136
81137
81138 function report(reference) {
81139 const node = reference.identifier.parent;
81140 context.report({
81141 node,
81142 loc: node.loc,
81143 messageId: "unexpected"
81144 });
81145 }
81146
81147 return {
81148 "Program:exit"() {
81149 const scope = context.getScope();
81150 const consoleVar = astUtils.getVariableByName(scope, "console");
81151 const shadowed = consoleVar && consoleVar.defs.length > 0;
81152 /*
81153 * 'scope.through' includes all references to undefined
81154 * variables. If the variable 'console' is not defined, it uses
81155 * 'scope.through'.
81156 */
81157
81158 const references = consoleVar ? consoleVar.references : scope.through.filter(isConsole);
81159
81160 if (!shadowed) {
81161 references.filter(isMemberAccessExceptAllowed).forEach(report);
81162 }
81163 }
81164
81165 };
81166 }
81167
81168 };
81169
81170 /***/ }),
81171 /* 646 */
81172 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
81173
81174 "use strict";
81175 /**
81176 * @fileoverview A rule to disallow modifying variables that are declared using `const`
81177 * @author Toru Nagashima
81178 */
81179
81180
81181 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
81182 // Rule Definition
81183 //------------------------------------------------------------------------------
81184
81185
81186 module.exports = {
81187 meta: {
81188 type: "problem",
81189 docs: {
81190 description: "disallow reassigning `const` variables",
81191 recommended: true,
81192 url: "https://eslint.org/docs/rules/no-const-assign"
81193 },
81194 schema: [],
81195 messages: {
81196 const: "'{{name}}' is constant."
81197 }
81198 },
81199
81200 create(context) {
81201 /**
81202 * Finds and reports references that are non initializer and writable.
81203 * @param {Variable} variable A variable to check.
81204 * @returns {void}
81205 */
81206 function checkVariable(variable) {
81207 astUtils.getModifyingReferences(variable.references).forEach(reference => {
81208 context.report({
81209 node: reference.identifier,
81210 messageId: "const",
81211 data: {
81212 name: reference.identifier.name
81213 }
81214 });
81215 });
81216 }
81217
81218 return {
81219 VariableDeclaration(node) {
81220 if (node.kind === "const") {
81221 context.getDeclaredVariables(node).forEach(checkVariable);
81222 }
81223 }
81224
81225 };
81226 }
81227
81228 };
81229
81230 /***/ }),
81231 /* 647 */
81232 /***/ ((module) => {
81233
81234 "use strict";
81235 /**
81236 * @fileoverview Rule to flag use constant conditions
81237 * @author Christian Schulz <http://rndm.de>
81238 */
81239 //------------------------------------------------------------------------------
81240 // Helpers
81241 //------------------------------------------------------------------------------
81242 //------------------------------------------------------------------------------
81243 // Rule Definition
81244 //------------------------------------------------------------------------------
81245
81246 module.exports = {
81247 meta: {
81248 type: "problem",
81249 docs: {
81250 description: "disallow constant expressions in conditions",
81251 recommended: true,
81252 url: "https://eslint.org/docs/rules/no-constant-condition"
81253 },
81254 schema: [{
81255 type: "object",
81256 properties: {
81257 checkLoops: {
81258 type: "boolean",
81259 default: true
81260 }
81261 },
81262 additionalProperties: false
81263 }],
81264 messages: {
81265 unexpected: "Unexpected constant condition."
81266 }
81267 },
81268
81269 create(context) {
81270 const options = context.options[0] || {},
81271 checkLoops = options.checkLoops !== false,
81272 loopSetStack = [];
81273 let loopsInCurrentScope = new Set(); //--------------------------------------------------------------------------
81274 // Helpers
81275 //--------------------------------------------------------------------------
81276
81277 /**
81278 * Returns literal's value converted to the Boolean type
81279 * @param {ASTNode} node any `Literal` node
81280 * @returns {boolean | null} `true` when node is truthy, `false` when node is falsy,
81281 * `null` when it cannot be determined.
81282 */
81283
81284 function getBooleanValue(node) {
81285 if (node.value === null) {
81286 /*
81287 * it might be a null literal or bigint/regex literal in unsupported environments .
81288 * https://github.com/estree/estree/blob/14df8a024956ea289bd55b9c2226a1d5b8a473ee/es5.md#regexpliteral
81289 * https://github.com/estree/estree/blob/14df8a024956ea289bd55b9c2226a1d5b8a473ee/es2020.md#bigintliteral
81290 */
81291 if (node.raw === "null") {
81292 return false;
81293 } // regex is always truthy
81294
81295
81296 if (typeof node.regex === "object") {
81297 return true;
81298 }
81299
81300 return null;
81301 }
81302
81303 return !!node.value;
81304 }
81305 /**
81306 * Checks if a branch node of LogicalExpression short circuits the whole condition
81307 * @param {ASTNode} node The branch of main condition which needs to be checked
81308 * @param {string} operator The operator of the main LogicalExpression.
81309 * @returns {boolean} true when condition short circuits whole condition
81310 */
81311
81312
81313 function isLogicalIdentity(node, operator) {
81314 switch (node.type) {
81315 case "Literal":
81316 return operator === "||" && getBooleanValue(node) === true || operator === "&&" && getBooleanValue(node) === false;
81317
81318 case "UnaryExpression":
81319 return operator === "&&" && node.operator === "void";
81320
81321 case "LogicalExpression":
81322 /*
81323 * handles `a && false || b`
81324 * `false` is an identity element of `&&` but not `||`
81325 */
81326 return operator === node.operator && (isLogicalIdentity(node.left, operator) || isLogicalIdentity(node.right, operator));
81327
81328 case "AssignmentExpression":
81329 return ["||=", "&&="].includes(node.operator) && operator === node.operator.slice(0, -1) && isLogicalIdentity(node.right, operator);
81330 // no default
81331 }
81332
81333 return false;
81334 }
81335 /**
81336 * Checks if a node has a constant truthiness value.
81337 * @param {ASTNode} node The AST node to check.
81338 * @param {boolean} inBooleanPosition `false` if checking branch of a condition.
81339 * `true` in all other cases
81340 * @returns {Bool} true when node's truthiness is constant
81341 * @private
81342 */
81343
81344
81345 function isConstant(node, inBooleanPosition) {
81346 // node.elements can return null values in the case of sparse arrays ex. [,]
81347 if (!node) {
81348 return true;
81349 }
81350
81351 switch (node.type) {
81352 case "Literal":
81353 case "ArrowFunctionExpression":
81354 case "FunctionExpression":
81355 case "ObjectExpression":
81356 return true;
81357
81358 case "TemplateLiteral":
81359 return inBooleanPosition && node.quasis.some(quasi => quasi.value.cooked.length) || node.expressions.every(exp => isConstant(exp, inBooleanPosition));
81360
81361 case "ArrayExpression":
81362 {
81363 if (node.parent.type === "BinaryExpression" && node.parent.operator === "+") {
81364 return node.elements.every(element => isConstant(element, false));
81365 }
81366
81367 return true;
81368 }
81369
81370 case "UnaryExpression":
81371 if (node.operator === "void" || node.operator === "typeof" && inBooleanPosition) {
81372 return true;
81373 }
81374
81375 if (node.operator === "!") {
81376 return isConstant(node.argument, true);
81377 }
81378
81379 return isConstant(node.argument, false);
81380
81381 case "BinaryExpression":
81382 return isConstant(node.left, false) && isConstant(node.right, false) && node.operator !== "in";
81383
81384 case "LogicalExpression":
81385 {
81386 const isLeftConstant = isConstant(node.left, inBooleanPosition);
81387 const isRightConstant = isConstant(node.right, inBooleanPosition);
81388 const isLeftShortCircuit = isLeftConstant && isLogicalIdentity(node.left, node.operator);
81389 const isRightShortCircuit = inBooleanPosition && isRightConstant && isLogicalIdentity(node.right, node.operator);
81390 return isLeftConstant && isRightConstant || isLeftShortCircuit || isRightShortCircuit;
81391 }
81392
81393 case "AssignmentExpression":
81394 if (node.operator === "=") {
81395 return isConstant(node.right, inBooleanPosition);
81396 }
81397
81398 if (["||=", "&&="].includes(node.operator) && inBooleanPosition) {
81399 return isLogicalIdentity(node.right, node.operator.slice(0, -1));
81400 }
81401
81402 return false;
81403
81404 case "SequenceExpression":
81405 return isConstant(node.expressions[node.expressions.length - 1], inBooleanPosition);
81406 // no default
81407 }
81408
81409 return false;
81410 }
81411 /**
81412 * Tracks when the given node contains a constant condition.
81413 * @param {ASTNode} node The AST node to check.
81414 * @returns {void}
81415 * @private
81416 */
81417
81418
81419 function trackConstantConditionLoop(node) {
81420 if (node.test && isConstant(node.test, true)) {
81421 loopsInCurrentScope.add(node);
81422 }
81423 }
81424 /**
81425 * Reports when the set contains the given constant condition node
81426 * @param {ASTNode} node The AST node to check.
81427 * @returns {void}
81428 * @private
81429 */
81430
81431
81432 function checkConstantConditionLoopInSet(node) {
81433 if (loopsInCurrentScope.has(node)) {
81434 loopsInCurrentScope.delete(node);
81435 context.report({
81436 node: node.test,
81437 messageId: "unexpected"
81438 });
81439 }
81440 }
81441 /**
81442 * Reports when the given node contains a constant condition.
81443 * @param {ASTNode} node The AST node to check.
81444 * @returns {void}
81445 * @private
81446 */
81447
81448
81449 function reportIfConstant(node) {
81450 if (node.test && isConstant(node.test, true)) {
81451 context.report({
81452 node: node.test,
81453 messageId: "unexpected"
81454 });
81455 }
81456 }
81457 /**
81458 * Stores current set of constant loops in loopSetStack temporarily
81459 * and uses a new set to track constant loops
81460 * @returns {void}
81461 * @private
81462 */
81463
81464
81465 function enterFunction() {
81466 loopSetStack.push(loopsInCurrentScope);
81467 loopsInCurrentScope = new Set();
81468 }
81469 /**
81470 * Reports when the set still contains stored constant conditions
81471 * @returns {void}
81472 * @private
81473 */
81474
81475
81476 function exitFunction() {
81477 loopsInCurrentScope = loopSetStack.pop();
81478 }
81479 /**
81480 * Checks node when checkLoops option is enabled
81481 * @param {ASTNode} node The AST node to check.
81482 * @returns {void}
81483 * @private
81484 */
81485
81486
81487 function checkLoop(node) {
81488 if (checkLoops) {
81489 trackConstantConditionLoop(node);
81490 }
81491 } //--------------------------------------------------------------------------
81492 // Public
81493 //--------------------------------------------------------------------------
81494
81495
81496 return {
81497 ConditionalExpression: reportIfConstant,
81498 IfStatement: reportIfConstant,
81499 WhileStatement: checkLoop,
81500 "WhileStatement:exit": checkConstantConditionLoopInSet,
81501 DoWhileStatement: checkLoop,
81502 "DoWhileStatement:exit": checkConstantConditionLoopInSet,
81503 ForStatement: checkLoop,
81504 "ForStatement > .test": node => checkLoop(node.parent),
81505 "ForStatement:exit": checkConstantConditionLoopInSet,
81506 FunctionDeclaration: enterFunction,
81507 "FunctionDeclaration:exit": exitFunction,
81508 FunctionExpression: enterFunction,
81509 "FunctionExpression:exit": exitFunction,
81510 YieldExpression: () => loopsInCurrentScope.clear()
81511 };
81512 }
81513
81514 };
81515
81516 /***/ }),
81517 /* 648 */
81518 /***/ ((module) => {
81519
81520 "use strict";
81521 /**
81522 * @fileoverview Rule to disallow returning value from constructor.
81523 * @author Pig Fang <https://github.com/g-plane>
81524 */
81525 //------------------------------------------------------------------------------
81526 // Rule Definition
81527 //------------------------------------------------------------------------------
81528
81529 module.exports = {
81530 meta: {
81531 type: "problem",
81532 docs: {
81533 description: "disallow returning value from constructor",
81534 recommended: false,
81535 url: "https://eslint.org/docs/rules/no-constructor-return"
81536 },
81537 schema: {},
81538 fixable: null,
81539 messages: {
81540 unexpected: "Unexpected return statement in constructor."
81541 }
81542 },
81543
81544 create(context) {
81545 const stack = [];
81546 return {
81547 onCodePathStart(_, node) {
81548 stack.push(node);
81549 },
81550
81551 onCodePathEnd() {
81552 stack.pop();
81553 },
81554
81555 ReturnStatement(node) {
81556 const last = stack[stack.length - 1];
81557
81558 if (!last.parent) {
81559 return;
81560 }
81561
81562 if (last.parent.type === "MethodDefinition" && last.parent.kind === "constructor" && (node.parent.parent === last || node.argument)) {
81563 context.report({
81564 node,
81565 messageId: "unexpected"
81566 });
81567 }
81568 }
81569
81570 };
81571 }
81572
81573 };
81574
81575 /***/ }),
81576 /* 649 */
81577 /***/ ((module) => {
81578
81579 "use strict";
81580 /**
81581 * @fileoverview Rule to flag use of continue statement
81582 * @author Borislav Zhivkov
81583 */
81584 //------------------------------------------------------------------------------
81585 // Rule Definition
81586 //------------------------------------------------------------------------------
81587
81588 module.exports = {
81589 meta: {
81590 type: "suggestion",
81591 docs: {
81592 description: "disallow `continue` statements",
81593 recommended: false,
81594 url: "https://eslint.org/docs/rules/no-continue"
81595 },
81596 schema: [],
81597 messages: {
81598 unexpected: "Unexpected use of continue statement."
81599 }
81600 },
81601
81602 create(context) {
81603 return {
81604 ContinueStatement(node) {
81605 context.report({
81606 node,
81607 messageId: "unexpected"
81608 });
81609 }
81610
81611 };
81612 }
81613
81614 };
81615
81616 /***/ }),
81617 /* 650 */
81618 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
81619
81620 "use strict";
81621 /**
81622 * @fileoverview Rule to forbid control characters from regular expressions.
81623 * @author Nicholas C. Zakas
81624 */
81625
81626
81627 const RegExpValidator = (__webpack_require__(651).RegExpValidator);
81628
81629 const collector = new class {
81630 constructor() {
81631 this._source = "";
81632 this._controlChars = [];
81633 this._validator = new RegExpValidator(this);
81634 }
81635
81636 onPatternEnter() {
81637 this._controlChars = [];
81638 }
81639
81640 onCharacter(start, end, cp) {
81641 if (cp >= 0x00 && cp <= 0x1F && (this._source.codePointAt(start) === cp || this._source.slice(start, end).startsWith("\\x") || this._source.slice(start, end).startsWith("\\u"))) {
81642 this._controlChars.push("\\x".concat("0".concat(cp.toString(16)).slice(-2)));
81643 }
81644 }
81645
81646 collectControlChars(regexpStr) {
81647 try {
81648 this._source = regexpStr;
81649
81650 this._validator.validatePattern(regexpStr); // Call onCharacter hook
81651
81652 } catch {// Ignore syntax errors in RegExp.
81653 }
81654
81655 return this._controlChars;
81656 }
81657
81658 }(); //------------------------------------------------------------------------------
81659 // Rule Definition
81660 //------------------------------------------------------------------------------
81661
81662 module.exports = {
81663 meta: {
81664 type: "problem",
81665 docs: {
81666 description: "disallow control characters in regular expressions",
81667 recommended: true,
81668 url: "https://eslint.org/docs/rules/no-control-regex"
81669 },
81670 schema: [],
81671 messages: {
81672 unexpected: "Unexpected control character(s) in regular expression: {{controlChars}}."
81673 }
81674 },
81675
81676 create(context) {
81677 /**
81678 * Get the regex expression
81679 * @param {ASTNode} node node to evaluate
81680 * @returns {RegExp|null} Regex if found else null
81681 * @private
81682 */
81683 function getRegExpPattern(node) {
81684 if (node.regex) {
81685 return node.regex.pattern;
81686 }
81687
81688 if (typeof node.value === "string" && (node.parent.type === "NewExpression" || node.parent.type === "CallExpression") && node.parent.callee.type === "Identifier" && node.parent.callee.name === "RegExp" && node.parent.arguments[0] === node) {
81689 return node.value;
81690 }
81691
81692 return null;
81693 }
81694
81695 return {
81696 Literal(node) {
81697 const pattern = getRegExpPattern(node);
81698
81699 if (pattern) {
81700 const controlCharacters = collector.collectControlChars(pattern);
81701
81702 if (controlCharacters.length > 0) {
81703 context.report({
81704 node,
81705 messageId: "unexpected",
81706 data: {
81707 controlChars: controlCharacters.join(", ")
81708 }
81709 });
81710 }
81711 }
81712 }
81713
81714 };
81715 }
81716
81717 };
81718
81719 /***/ }),
81720 /* 651 */
81721 /***/ ((__unused_webpack_module, exports) => {
81722
81723 "use strict";
81724 /*! @author Toru Nagashima <https://github.com/mysticatea> */
81725
81726
81727 Object.defineProperty(exports, "__esModule", ({
81728 value: true
81729 }));
81730 var ast = /*#__PURE__*/Object.freeze({});
81731 let largeIdStartRanges = undefined;
81732 let largeIdContinueRanges = undefined;
81733
81734 function isIdStart(cp) {
81735 if (cp < 0x41) return false;
81736 if (cp < 0x5b) return true;
81737 if (cp < 0x61) return false;
81738 if (cp < 0x7b) return true;
81739 return isLargeIdStart(cp);
81740 }
81741
81742 function isIdContinue(cp) {
81743 if (cp < 0x30) return false;
81744 if (cp < 0x3a) return true;
81745 if (cp < 0x41) return false;
81746 if (cp < 0x5b) return true;
81747 if (cp === 0x5f) return true;
81748 if (cp < 0x61) return false;
81749 if (cp < 0x7b) return true;
81750 return isLargeIdStart(cp) || isLargeIdContinue(cp);
81751 }
81752
81753 function isLargeIdStart(cp) {
81754 return isInRange(cp, largeIdStartRanges || (largeIdStartRanges = initLargeIdStartRanges()));
81755 }
81756
81757 function isLargeIdContinue(cp) {
81758 return isInRange(cp, largeIdContinueRanges || (largeIdContinueRanges = initLargeIdContinueRanges()));
81759 }
81760
81761 function initLargeIdStartRanges() {
81762 return restoreRanges("4q 0 b 0 5 0 6 m 2 u 2 cp 5 b f 4 8 0 2 0 3m 4 2 1 3 3 2 0 7 0 2 2 2 0 2 j 2 2a 2 3u 9 4l 2 11 3 0 7 14 20 q 5 3 1a 16 10 1 2 2q 2 0 g 1 8 1 b 2 3 0 h 0 2 t u 2g c 0 p w a 1 5 0 6 l 5 0 a 0 4 0 o o 8 a 1i k 2 h 1p 1h 4 0 j 0 8 9 g f 5 7 3 1 3 l 2 6 2 0 4 3 4 0 h 0 e 1 2 2 f 1 b 0 9 5 5 1 3 l 2 6 2 1 2 1 2 1 w 3 2 0 k 2 h 8 2 2 2 l 2 6 2 1 2 4 4 0 j 0 g 1 o 0 c 7 3 1 3 l 2 6 2 1 2 4 4 0 v 1 2 2 g 0 i 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 b n 0 1h 7 2 2 2 m 2 f 4 0 r 2 6 1 v 0 5 7 2 2 2 m 2 9 2 4 4 0 x 0 2 1 g 1 i 8 2 2 2 14 3 0 h 0 6 2 9 2 p 5 6 h 4 n 2 8 2 0 3 6 1n 1b 2 1 d 6 1n 1 2 0 2 4 2 n 2 0 2 9 2 1 a 0 3 4 2 0 m 3 x 0 1s 7 2 z s 4 38 16 l 0 h 5 5 3 4 0 4 1 8 2 5 c d 0 i 11 2 0 6 0 3 16 2 98 2 3 3 6 2 0 2 3 3 14 2 3 3 w 2 3 3 6 2 0 2 3 3 e 2 1k 2 3 3 1u 12 f h 2d 3 5 4 h7 3 g 2 p 6 22 4 a 8 c 2 3 f h f h f c 2 2 g 1f 10 0 5 0 1w 2g 8 14 2 0 6 1x b u 1e t 3 4 c 17 5 p 1j m a 1g 2b 0 2m 1a i 6 1k t e 1 b 17 r z 16 2 b z 3 8 8 16 3 2 16 3 2 5 2 1 4 0 6 5b 1t 7p 3 5 3 11 3 5 3 7 2 0 2 0 2 0 2 u 3 1g 2 6 2 0 4 2 2 6 4 3 3 5 5 c 6 2 2 6 39 0 e 0 h c 2u 0 5 0 3 9 2 0 3 5 7 0 2 0 2 0 2 f 3 3 6 4 5 0 i 14 22g 1a 2 1a 2 3o 7 3 4 1 d 11 2 0 6 0 3 1j 8 0 h m a 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 fb 2 q 8 8 4 3 4 5 2d 5 4 2 2h 2 3 6 16 2 2l i v 1d f e9 533 1t g70 4 wc 1w 19 3 7g 4 f b 1 l 1a h u 3 27 14 8 3 2u 3 1g 3 8 17 c 2 2 2 3 2 m u 1f f 1d 1r 5 4 0 2 1 c r b m q s 8 1a t 0 h 4 2 9 b 4 2 14 o 2 2 7 l m 4 0 4 1d 2 0 4 1 3 4 3 0 2 0 p 2 3 a 8 2 d 5 3 5 3 5 a 6 2 6 2 16 2 d 7 36 u 8mb d m 5 1c 6it a5 3 2x 13 6 d 4 6 0 2 9 2 c 2 4 2 0 2 1 2 1 2 2z y a2 j 1r 3 1h 15 b 39 4 2 3q 11 p 7 p c 2g 4 5 3 5 3 5 3 2 10 b 2 p 2 i 2 1 2 e 3 d z 3e 1y 1g 7g s 4 1c 1c v e t 6 11 b t 3 z 5 7 2 4 17 4d j z 5 z 5 13 9 1f 4d 8m a l b 7 49 5 3 0 2 17 2 1 4 0 3 m b m a u 1u i 2 1 b l b p 1z 1j 7 1 1t 0 g 3 2 2 2 s 17 s 4 s 10 7 2 r s 1h b l b i e h 33 20 1k 1e e 1e e z 9p 15 7 1 27 s b 0 9 l 2z k s m d 1g 24 18 x o r z u 0 3 0 9 y 4 0 d 1b f 3 m 0 2 0 10 h 2 o 2d 6 2 0 2 3 2 e 2 9 8 1a 13 7 3 1 3 l 2 6 2 1 2 4 4 0 j 0 d 4 4f 1g j 3 l 2 v 1b l 1 2 0 55 1a 16 3 11 1b l 0 1o 16 e 0 20 q 6e 17 39 1r w 7 3 0 3 7 2 1 2 n g 0 2 0 2n 7 3 12 h 0 2 0 t 0 b 13 8 0 m 0 c 19 k 0 z 1k 7c 8 2 10 i 0 1e t 35 6 2 1 2 11 m 0 q 5 2 1 2 v f 0 94 i 5a 0 28 pl 2v 32 i 5f 24d tq 34i g6 6nu fs 8 u 36 t j 1b h 3 w k 6 i j5 1r 3l 22 6 0 1v c 1t 1 2 0 t 4qf 9 yd 17 8 6wo 7y 1e 2 i 3 9 az 1s5 2y 6 c 4 8 8 9 4mf 2c 2 1y 2 1 3 0 3 1 3 3 2 b 2 0 2 6 2 1s 2 3 3 7 2 6 2 r 2 3 2 4 2 0 4 6 2 9f 3 o 2 o 2 u 2 o 2 u 2 o 2 u 2 o 2 u 2 o 2 7 1th 18 b 6 h 0 aa 17 105 5g 1o 1v 8 0 xh 3 2 q 2 1 2 0 3 0 2 9 2 3 2 0 2 0 7 0 5 0 2 0 2 0 2 2 2 1 2 0 3 0 2 0 2 0 2 0 2 0 2 1 2 0 3 3 2 6 2 3 2 3 2 0 2 9 2 g 6 2 2 4 2 g 3et wyl z 378 c 65 3 4g1 f 5rk 2e8 f1 15v 3t6");
81763 }
81764
81765 function initLargeIdContinueRanges() {
81766 return restoreRanges("53 0 g9 33 o 0 70 4 7e 18 2 0 2 1 2 1 2 0 21 a 1d u 7 0 2u 6 3 5 3 1 2 3 3 9 o 0 v q 2k a g 9 y 8 a 0 p 3 2 8 2 2 2 4 18 2 3c e 2 w 1j 2 2 h 2 6 b 1 3 9 i 2 1l 0 2 6 3 1 3 2 a 0 b 1 3 9 f 0 3 2 1l 0 2 4 5 1 3 2 4 0 l b 4 0 c 2 1l 0 2 7 2 2 2 2 l 1 3 9 b 5 2 2 1l 0 2 6 3 1 3 2 8 2 b 1 3 9 j 0 1o 4 4 2 2 3 a 0 f 9 h 4 1m 6 2 2 2 3 8 1 c 1 3 9 i 2 1l 0 2 6 2 2 2 3 8 1 c 1 3 9 h 3 1k 1 2 6 2 2 2 3 a 0 b 1 3 9 i 2 1z 0 5 5 2 0 2 7 7 9 3 1 1q 0 3 6 d 7 2 9 2g 0 3 8 c 5 3 9 1r 1 7 9 c 0 2 0 2 0 5 1 1e j 2 1 6 a 2 z a 0 2t j 2 9 d 3 5 2 2 2 3 6 4 3 e b 2 e jk 2 a 8 pt 2 u 2 u 1 v 1 1t v a 0 3 9 y 2 3 9 40 0 3b b 5 b b 9 3l a 1p 4 1m 9 2 s 3 a 7 9 n d 2 1 1s 4 1c g c 9 i 8 d 2 v c 3 9 19 d 1d j 9 9 7 9 3b 2 2 k 5 0 7 0 3 2 5j 1l 2 4 g0 1 k 0 3g c 5 0 4 b 2db 2 3y 0 2p v ff 5 2y 1 n7q 9 1y 0 5 9 x 1 29 1 7l 0 4 0 5 0 o 4 5 0 2c 1 1f h b 9 7 h e a t 7 q c 19 3 1c d g 9 c 0 b 9 1c d d 0 9 1 3 9 y 2 1f 0 2 2 3 1 6 1 2 0 16 4 6 1 6l 7 2 1 3 9 fmt 0 ki f h f 4 1 p 2 5d 9 12 0 ji 0 6b 0 46 4 86 9 120 2 2 1 6 3 15 2 5 0 4m 1 fy 3 9 9 aa 1 4a a 4w 2 1i e w 9 g 3 1a a 1i 9 7 2 11 d 2 9 6 1 19 0 d 2 1d d 9 3 2 b 2b b 7 0 4h b 6 9 7 3 1k 1 2 6 3 1 3 2 a 0 b 1 3 6 4 4 5d h a 9 5 0 2a j d 9 5y 6 3 8 s 1 2b g g 9 2a c 9 9 2c e 5 9 6r e 4m 9 1z 5 2 1 3 3 2 0 2 1 d 9 3c 6 3 6 4 0 t 9 15 6 2 3 9 0 a a 1b f ba 7 2 7 h 9 1l l 2 d 3f 5 4 0 2 1 2 6 2 0 9 9 1d 4 2 1 2 4 9 9 96 3 ewa 9 3r 4 1o 6 q 9 s6 0 2 1i 8 3 2a 0 c 1 f58 1 43r 4 4 5 9 7 3 6 v 3 45 2 13e 1d e9 1i 5 1d 9 0 f 0 n 4 2 e 11t 6 2 g 3 6 2 1 2 4 7a 6 a 9 bn d 15j 6 32 6 6 9 3o7 9 gvt3 6n");
81767 }
81768
81769 function isInRange(cp, ranges) {
81770 let l = 0,
81771 r = ranges.length / 2 | 0,
81772 i = 0,
81773 min = 0,
81774 max = 0;
81775
81776 while (l < r) {
81777 i = (l + r) / 2 | 0;
81778 min = ranges[2 * i];
81779 max = ranges[2 * i + 1];
81780
81781 if (cp < min) {
81782 r = i;
81783 } else if (cp > max) {
81784 l = i + 1;
81785 } else {
81786 return true;
81787 }
81788 }
81789
81790 return false;
81791 }
81792
81793 function restoreRanges(data) {
81794 let last = 0;
81795 return data.split(" ").map(s => last += parseInt(s, 36) | 0);
81796 }
81797
81798 class DataSet {
81799 constructor(raw2018, raw2019, raw2020, raw2021) {
81800 this._raw2018 = raw2018;
81801 this._raw2019 = raw2019;
81802 this._raw2020 = raw2020;
81803 this._raw2021 = raw2021;
81804 }
81805
81806 get es2018() {
81807 return this._set2018 || (this._set2018 = new Set(this._raw2018.split(" ")));
81808 }
81809
81810 get es2019() {
81811 return this._set2019 || (this._set2019 = new Set(this._raw2019.split(" ")));
81812 }
81813
81814 get es2020() {
81815 return this._set2020 || (this._set2020 = new Set(this._raw2020.split(" ")));
81816 }
81817
81818 get es2021() {
81819 return this._set2021 || (this._set2021 = new Set(this._raw2021.split(" ")));
81820 }
81821
81822 }
81823
81824 const gcNameSet = new Set(["General_Category", "gc"]);
81825 const scNameSet = new Set(["Script", "Script_Extensions", "sc", "scx"]);
81826 const gcValueSets = new DataSet("C Cased_Letter Cc Cf Close_Punctuation Cn Co Combining_Mark Connector_Punctuation Control Cs Currency_Symbol Dash_Punctuation Decimal_Number Enclosing_Mark Final_Punctuation Format Initial_Punctuation L LC Letter Letter_Number Line_Separator Ll Lm Lo Lowercase_Letter Lt Lu M Mark Math_Symbol Mc Me Mn Modifier_Letter Modifier_Symbol N Nd Nl No Nonspacing_Mark Number Open_Punctuation Other Other_Letter Other_Number Other_Punctuation Other_Symbol P Paragraph_Separator Pc Pd Pe Pf Pi Po Private_Use Ps Punctuation S Sc Separator Sk Sm So Space_Separator Spacing_Mark Surrogate Symbol Titlecase_Letter Unassigned Uppercase_Letter Z Zl Zp Zs cntrl digit punct", "", "", "");
81827 const scValueSets = new DataSet("Adlam Adlm Aghb Ahom Anatolian_Hieroglyphs Arab Arabic Armenian Armi Armn Avestan Avst Bali Balinese Bamu Bamum Bass Bassa_Vah Batak Batk Beng Bengali Bhaiksuki Bhks Bopo Bopomofo Brah Brahmi Brai Braille Bugi Buginese Buhd Buhid Cakm Canadian_Aboriginal Cans Cari Carian Caucasian_Albanian Chakma Cham Cher Cherokee Common Copt Coptic Cprt Cuneiform Cypriot Cyrillic Cyrl Deseret Deva Devanagari Dsrt Dupl Duployan Egyp Egyptian_Hieroglyphs Elba Elbasan Ethi Ethiopic Geor Georgian Glag Glagolitic Gonm Goth Gothic Gran Grantha Greek Grek Gujarati Gujr Gurmukhi Guru Han Hang Hangul Hani Hano Hanunoo Hatr Hatran Hebr Hebrew Hira Hiragana Hluw Hmng Hung Imperial_Aramaic Inherited Inscriptional_Pahlavi Inscriptional_Parthian Ital Java Javanese Kaithi Kali Kana Kannada Katakana Kayah_Li Khar Kharoshthi Khmer Khmr Khoj Khojki Khudawadi Knda Kthi Lana Lao Laoo Latin Latn Lepc Lepcha Limb Limbu Lina Linb Linear_A Linear_B Lisu Lyci Lycian Lydi Lydian Mahajani Mahj Malayalam Mand Mandaic Mani Manichaean Marc Marchen Masaram_Gondi Meetei_Mayek Mend Mende_Kikakui Merc Mero Meroitic_Cursive Meroitic_Hieroglyphs Miao Mlym Modi Mong Mongolian Mro Mroo Mtei Mult Multani Myanmar Mymr Nabataean Narb Nbat New_Tai_Lue Newa Nko Nkoo Nshu Nushu Ogam Ogham Ol_Chiki Olck Old_Hungarian Old_Italic Old_North_Arabian Old_Permic Old_Persian Old_South_Arabian Old_Turkic Oriya Orkh Orya Osage Osge Osma Osmanya Pahawh_Hmong Palm Palmyrene Pau_Cin_Hau Pauc Perm Phag Phags_Pa Phli Phlp Phnx Phoenician Plrd Prti Psalter_Pahlavi Qaac Qaai Rejang Rjng Runic Runr Samaritan Samr Sarb Saur Saurashtra Sgnw Sharada Shavian Shaw Shrd Sidd Siddham SignWriting Sind Sinh Sinhala Sora Sora_Sompeng Soyo Soyombo Sund Sundanese Sylo Syloti_Nagri Syrc Syriac Tagalog Tagb Tagbanwa Tai_Le Tai_Tham Tai_Viet Takr Takri Tale Talu Tamil Taml Tang Tangut Tavt Telu Telugu Tfng Tglg Thaa Thaana Thai Tibetan Tibt Tifinagh Tirh Tirhuta Ugar Ugaritic Vai Vaii Wara Warang_Citi Xpeo Xsux Yi Yiii Zanabazar_Square Zanb Zinh Zyyy", "Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo", "Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho", "Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi");
81828 const binPropertySets = new DataSet("AHex ASCII ASCII_Hex_Digit Alpha Alphabetic Any Assigned Bidi_C Bidi_Control Bidi_M Bidi_Mirrored CI CWCF CWCM CWKCF CWL CWT CWU Case_Ignorable Cased Changes_When_Casefolded Changes_When_Casemapped Changes_When_Lowercased Changes_When_NFKC_Casefolded Changes_When_Titlecased Changes_When_Uppercased DI Dash Default_Ignorable_Code_Point Dep Deprecated Dia Diacritic Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Ext Extender Gr_Base Gr_Ext Grapheme_Base Grapheme_Extend Hex Hex_Digit IDC IDS IDSB IDST IDS_Binary_Operator IDS_Trinary_Operator ID_Continue ID_Start Ideo Ideographic Join_C Join_Control LOE Logical_Order_Exception Lower Lowercase Math NChar Noncharacter_Code_Point Pat_Syn Pat_WS Pattern_Syntax Pattern_White_Space QMark Quotation_Mark RI Radical Regional_Indicator SD STerm Sentence_Terminal Soft_Dotted Term Terminal_Punctuation UIdeo Unified_Ideograph Upper Uppercase VS Variation_Selector White_Space XIDC XIDS XID_Continue XID_Start space", "Extended_Pictographic", "", "EBase EComp EMod EPres ExtPict");
81829
81830 function isValidUnicodeProperty(version, name, value) {
81831 if (gcNameSet.has(name)) {
81832 return version >= 2018 && gcValueSets.es2018.has(value);
81833 }
81834
81835 if (scNameSet.has(name)) {
81836 return version >= 2018 && scValueSets.es2018.has(value) || version >= 2019 && scValueSets.es2019.has(value) || version >= 2020 && scValueSets.es2020.has(value) || version >= 2021 && scValueSets.es2021.has(value);
81837 }
81838
81839 return false;
81840 }
81841
81842 function isValidLoneUnicodeProperty(version, value) {
81843 return version >= 2018 && binPropertySets.es2018.has(value) || version >= 2019 && binPropertySets.es2019.has(value) || version >= 2021 && binPropertySets.es2021.has(value);
81844 }
81845
81846 const Backspace = 0x08;
81847 const CharacterTabulation = 0x09;
81848 const LineFeed = 0x0a;
81849 const LineTabulation = 0x0b;
81850 const FormFeed = 0x0c;
81851 const CarriageReturn = 0x0d;
81852 const ExclamationMark = 0x21;
81853 const DollarSign = 0x24;
81854 const LeftParenthesis = 0x28;
81855 const RightParenthesis = 0x29;
81856 const Asterisk = 0x2a;
81857 const PlusSign = 0x2b;
81858 const Comma = 0x2c;
81859 const HyphenMinus = 0x2d;
81860 const FullStop = 0x2e;
81861 const Solidus = 0x2f;
81862 const DigitZero = 0x30;
81863 const DigitOne = 0x31;
81864 const DigitSeven = 0x37;
81865 const DigitNine = 0x39;
81866 const Colon = 0x3a;
81867 const LessThanSign = 0x3c;
81868 const EqualsSign = 0x3d;
81869 const GreaterThanSign = 0x3e;
81870 const QuestionMark = 0x3f;
81871 const LatinCapitalLetterA = 0x41;
81872 const LatinCapitalLetterB = 0x42;
81873 const LatinCapitalLetterD = 0x44;
81874 const LatinCapitalLetterF = 0x46;
81875 const LatinCapitalLetterP = 0x50;
81876 const LatinCapitalLetterS = 0x53;
81877 const LatinCapitalLetterW = 0x57;
81878 const LatinCapitalLetterZ = 0x5a;
81879 const LowLine = 0x5f;
81880 const LatinSmallLetterA = 0x61;
81881 const LatinSmallLetterB = 0x62;
81882 const LatinSmallLetterC = 0x63;
81883 const LatinSmallLetterD = 0x64;
81884 const LatinSmallLetterF = 0x66;
81885 const LatinSmallLetterG = 0x67;
81886 const LatinSmallLetterI = 0x69;
81887 const LatinSmallLetterK = 0x6b;
81888 const LatinSmallLetterM = 0x6d;
81889 const LatinSmallLetterN = 0x6e;
81890 const LatinSmallLetterP = 0x70;
81891 const LatinSmallLetterR = 0x72;
81892 const LatinSmallLetterS = 0x73;
81893 const LatinSmallLetterT = 0x74;
81894 const LatinSmallLetterU = 0x75;
81895 const LatinSmallLetterV = 0x76;
81896 const LatinSmallLetterW = 0x77;
81897 const LatinSmallLetterX = 0x78;
81898 const LatinSmallLetterY = 0x79;
81899 const LatinSmallLetterZ = 0x7a;
81900 const LeftSquareBracket = 0x5b;
81901 const ReverseSolidus = 0x5c;
81902 const RightSquareBracket = 0x5d;
81903 const CircumflexAccent = 0x5e;
81904 const LeftCurlyBracket = 0x7b;
81905 const VerticalLine = 0x7c;
81906 const RightCurlyBracket = 0x7d;
81907 const ZeroWidthNonJoiner = 0x200c;
81908 const ZeroWidthJoiner = 0x200d;
81909 const LineSeparator = 0x2028;
81910 const ParagraphSeparator = 0x2029;
81911 const MinCodePoint = 0x00;
81912 const MaxCodePoint = 0x10ffff;
81913
81914 function isLatinLetter(code) {
81915 return code >= LatinCapitalLetterA && code <= LatinCapitalLetterZ || code >= LatinSmallLetterA && code <= LatinSmallLetterZ;
81916 }
81917
81918 function isDecimalDigit(code) {
81919 return code >= DigitZero && code <= DigitNine;
81920 }
81921
81922 function isOctalDigit(code) {
81923 return code >= DigitZero && code <= DigitSeven;
81924 }
81925
81926 function isHexDigit(code) {
81927 return code >= DigitZero && code <= DigitNine || code >= LatinCapitalLetterA && code <= LatinCapitalLetterF || code >= LatinSmallLetterA && code <= LatinSmallLetterF;
81928 }
81929
81930 function isLineTerminator(code) {
81931 return code === LineFeed || code === CarriageReturn || code === LineSeparator || code === ParagraphSeparator;
81932 }
81933
81934 function isValidUnicode(code) {
81935 return code >= MinCodePoint && code <= MaxCodePoint;
81936 }
81937
81938 function digitToInt(code) {
81939 if (code >= LatinSmallLetterA && code <= LatinSmallLetterF) {
81940 return code - LatinSmallLetterA + 10;
81941 }
81942
81943 if (code >= LatinCapitalLetterA && code <= LatinCapitalLetterF) {
81944 return code - LatinCapitalLetterA + 10;
81945 }
81946
81947 return code - DigitZero;
81948 }
81949
81950 function isLeadSurrogate(code) {
81951 return code >= 0xd800 && code <= 0xdbff;
81952 }
81953
81954 function isTrailSurrogate(code) {
81955 return code >= 0xdc00 && code <= 0xdfff;
81956 }
81957
81958 function combineSurrogatePair(lead, trail) {
81959 return (lead - 0xd800) * 0x400 + (trail - 0xdc00) + 0x10000;
81960 }
81961
81962 const legacyImpl = {
81963 at(s, end, i) {
81964 return i < end ? s.charCodeAt(i) : -1;
81965 },
81966
81967 width(c) {
81968 return 1;
81969 }
81970
81971 };
81972 const unicodeImpl = {
81973 at(s, end, i) {
81974 return i < end ? s.codePointAt(i) : -1;
81975 },
81976
81977 width(c) {
81978 return c > 0xffff ? 2 : 1;
81979 }
81980
81981 };
81982
81983 class Reader {
81984 constructor() {
81985 this._impl = legacyImpl;
81986 this._s = "";
81987 this._i = 0;
81988 this._end = 0;
81989 this._cp1 = -1;
81990 this._w1 = 1;
81991 this._cp2 = -1;
81992 this._w2 = 1;
81993 this._cp3 = -1;
81994 this._w3 = 1;
81995 this._cp4 = -1;
81996 }
81997
81998 get source() {
81999 return this._s;
82000 }
82001
82002 get index() {
82003 return this._i;
82004 }
82005
82006 get currentCodePoint() {
82007 return this._cp1;
82008 }
82009
82010 get nextCodePoint() {
82011 return this._cp2;
82012 }
82013
82014 get nextCodePoint2() {
82015 return this._cp3;
82016 }
82017
82018 get nextCodePoint3() {
82019 return this._cp4;
82020 }
82021
82022 reset(source, start, end, uFlag) {
82023 this._impl = uFlag ? unicodeImpl : legacyImpl;
82024 this._s = source;
82025 this._end = end;
82026 this.rewind(start);
82027 }
82028
82029 rewind(index) {
82030 const impl = this._impl;
82031 this._i = index;
82032 this._cp1 = impl.at(this._s, this._end, index);
82033 this._w1 = impl.width(this._cp1);
82034 this._cp2 = impl.at(this._s, this._end, index + this._w1);
82035 this._w2 = impl.width(this._cp2);
82036 this._cp3 = impl.at(this._s, this._end, index + this._w1 + this._w2);
82037 this._w3 = impl.width(this._cp3);
82038 this._cp4 = impl.at(this._s, this._end, index + this._w1 + this._w2 + this._w3);
82039 }
82040
82041 advance() {
82042 if (this._cp1 !== -1) {
82043 const impl = this._impl;
82044 this._i += this._w1;
82045 this._cp1 = this._cp2;
82046 this._w1 = this._w2;
82047 this._cp2 = this._cp3;
82048 this._w2 = impl.width(this._cp2);
82049 this._cp3 = this._cp4;
82050 this._w3 = impl.width(this._cp3);
82051 this._cp4 = impl.at(this._s, this._end, this._i + this._w1 + this._w2 + this._w3);
82052 }
82053 }
82054
82055 eat(cp) {
82056 if (this._cp1 === cp) {
82057 this.advance();
82058 return true;
82059 }
82060
82061 return false;
82062 }
82063
82064 eat2(cp1, cp2) {
82065 if (this._cp1 === cp1 && this._cp2 === cp2) {
82066 this.advance();
82067 this.advance();
82068 return true;
82069 }
82070
82071 return false;
82072 }
82073
82074 eat3(cp1, cp2, cp3) {
82075 if (this._cp1 === cp1 && this._cp2 === cp2 && this._cp3 === cp3) {
82076 this.advance();
82077 this.advance();
82078 this.advance();
82079 return true;
82080 }
82081
82082 return false;
82083 }
82084
82085 }
82086
82087 class RegExpSyntaxError extends SyntaxError {
82088 constructor(source, uFlag, index, message) {
82089 if (source) {
82090 if (!source.startsWith("/")) {
82091 source = "/".concat(source, "/").concat(uFlag ? "u" : "");
82092 }
82093
82094 source = ": ".concat(source);
82095 }
82096
82097 super("Invalid regular expression".concat(source, ": ").concat(message));
82098 this.index = index;
82099 }
82100
82101 }
82102
82103 function isSyntaxCharacter(cp) {
82104 return cp === CircumflexAccent || cp === DollarSign || cp === ReverseSolidus || cp === FullStop || cp === Asterisk || cp === PlusSign || cp === QuestionMark || cp === LeftParenthesis || cp === RightParenthesis || cp === LeftSquareBracket || cp === RightSquareBracket || cp === LeftCurlyBracket || cp === RightCurlyBracket || cp === VerticalLine;
82105 }
82106
82107 function isRegExpIdentifierStart(cp) {
82108 return isIdStart(cp) || cp === DollarSign || cp === LowLine;
82109 }
82110
82111 function isRegExpIdentifierPart(cp) {
82112 return isIdContinue(cp) || cp === DollarSign || cp === LowLine || cp === ZeroWidthNonJoiner || cp === ZeroWidthJoiner;
82113 }
82114
82115 function isUnicodePropertyNameCharacter(cp) {
82116 return isLatinLetter(cp) || cp === LowLine;
82117 }
82118
82119 function isUnicodePropertyValueCharacter(cp) {
82120 return isUnicodePropertyNameCharacter(cp) || isDecimalDigit(cp);
82121 }
82122
82123 class RegExpValidator {
82124 constructor(options) {
82125 this._reader = new Reader();
82126 this._uFlag = false;
82127 this._nFlag = false;
82128 this._lastIntValue = 0;
82129 this._lastMinValue = 0;
82130 this._lastMaxValue = 0;
82131 this._lastStrValue = "";
82132 this._lastKeyValue = "";
82133 this._lastValValue = "";
82134 this._lastAssertionIsQuantifiable = false;
82135 this._numCapturingParens = 0;
82136 this._groupNames = new Set();
82137 this._backreferenceNames = new Set();
82138 this._options = options || {};
82139 }
82140
82141 validateLiteral(source) {
82142 let start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
82143 let end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : source.length;
82144 this._uFlag = this._nFlag = false;
82145 this.reset(source, start, end);
82146 this.onLiteralEnter(start);
82147
82148 if (this.eat(Solidus) && this.eatRegExpBody() && this.eat(Solidus)) {
82149 const flagStart = this.index;
82150 const uFlag = source.includes("u", flagStart);
82151 this.validateFlags(source, flagStart, end);
82152 this.validatePattern(source, start + 1, flagStart - 1, uFlag);
82153 } else if (start >= end) {
82154 this.raise("Empty");
82155 } else {
82156 const c = String.fromCodePoint(this.currentCodePoint);
82157 this.raise("Unexpected character '".concat(c, "'"));
82158 }
82159
82160 this.onLiteralLeave(start, end);
82161 }
82162
82163 validateFlags(source) {
82164 let start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
82165 let end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : source.length;
82166 const existingFlags = new Set();
82167 let global = false;
82168 let ignoreCase = false;
82169 let multiline = false;
82170 let sticky = false;
82171 let unicode = false;
82172 let dotAll = false;
82173 let hasIndices = false;
82174
82175 for (let i = start; i < end; ++i) {
82176 const flag = source.charCodeAt(i);
82177
82178 if (existingFlags.has(flag)) {
82179 this.raise("Duplicated flag '".concat(source[i], "'"));
82180 }
82181
82182 existingFlags.add(flag);
82183
82184 if (flag === LatinSmallLetterG) {
82185 global = true;
82186 } else if (flag === LatinSmallLetterI) {
82187 ignoreCase = true;
82188 } else if (flag === LatinSmallLetterM) {
82189 multiline = true;
82190 } else if (flag === LatinSmallLetterU && this.ecmaVersion >= 2015) {
82191 unicode = true;
82192 } else if (flag === LatinSmallLetterY && this.ecmaVersion >= 2015) {
82193 sticky = true;
82194 } else if (flag === LatinSmallLetterS && this.ecmaVersion >= 2018) {
82195 dotAll = true;
82196 } else if (flag === LatinSmallLetterD && this.ecmaVersion >= 2022) {
82197 hasIndices = true;
82198 } else {
82199 this.raise("Invalid flag '".concat(source[i], "'"));
82200 }
82201 }
82202
82203 this.onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll, hasIndices);
82204 }
82205
82206 validatePattern(source) {
82207 let start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
82208 let end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : source.length;
82209 let uFlag = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
82210 this._uFlag = uFlag && this.ecmaVersion >= 2015;
82211 this._nFlag = uFlag && this.ecmaVersion >= 2018;
82212 this.reset(source, start, end);
82213 this.consumePattern();
82214
82215 if (!this._nFlag && this.ecmaVersion >= 2018 && this._groupNames.size > 0) {
82216 this._nFlag = true;
82217 this.rewind(start);
82218 this.consumePattern();
82219 }
82220 }
82221
82222 get strict() {
82223 return Boolean(this._options.strict || this._uFlag);
82224 }
82225
82226 get ecmaVersion() {
82227 return this._options.ecmaVersion || 2022;
82228 }
82229
82230 onLiteralEnter(start) {
82231 if (this._options.onLiteralEnter) {
82232 this._options.onLiteralEnter(start);
82233 }
82234 }
82235
82236 onLiteralLeave(start, end) {
82237 if (this._options.onLiteralLeave) {
82238 this._options.onLiteralLeave(start, end);
82239 }
82240 }
82241
82242 onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll, hasIndices) {
82243 if (this._options.onFlags) {
82244 this._options.onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll, hasIndices);
82245 }
82246 }
82247
82248 onPatternEnter(start) {
82249 if (this._options.onPatternEnter) {
82250 this._options.onPatternEnter(start);
82251 }
82252 }
82253
82254 onPatternLeave(start, end) {
82255 if (this._options.onPatternLeave) {
82256 this._options.onPatternLeave(start, end);
82257 }
82258 }
82259
82260 onDisjunctionEnter(start) {
82261 if (this._options.onDisjunctionEnter) {
82262 this._options.onDisjunctionEnter(start);
82263 }
82264 }
82265
82266 onDisjunctionLeave(start, end) {
82267 if (this._options.onDisjunctionLeave) {
82268 this._options.onDisjunctionLeave(start, end);
82269 }
82270 }
82271
82272 onAlternativeEnter(start, index) {
82273 if (this._options.onAlternativeEnter) {
82274 this._options.onAlternativeEnter(start, index);
82275 }
82276 }
82277
82278 onAlternativeLeave(start, end, index) {
82279 if (this._options.onAlternativeLeave) {
82280 this._options.onAlternativeLeave(start, end, index);
82281 }
82282 }
82283
82284 onGroupEnter(start) {
82285 if (this._options.onGroupEnter) {
82286 this._options.onGroupEnter(start);
82287 }
82288 }
82289
82290 onGroupLeave(start, end) {
82291 if (this._options.onGroupLeave) {
82292 this._options.onGroupLeave(start, end);
82293 }
82294 }
82295
82296 onCapturingGroupEnter(start, name) {
82297 if (this._options.onCapturingGroupEnter) {
82298 this._options.onCapturingGroupEnter(start, name);
82299 }
82300 }
82301
82302 onCapturingGroupLeave(start, end, name) {
82303 if (this._options.onCapturingGroupLeave) {
82304 this._options.onCapturingGroupLeave(start, end, name);
82305 }
82306 }
82307
82308 onQuantifier(start, end, min, max, greedy) {
82309 if (this._options.onQuantifier) {
82310 this._options.onQuantifier(start, end, min, max, greedy);
82311 }
82312 }
82313
82314 onLookaroundAssertionEnter(start, kind, negate) {
82315 if (this._options.onLookaroundAssertionEnter) {
82316 this._options.onLookaroundAssertionEnter(start, kind, negate);
82317 }
82318 }
82319
82320 onLookaroundAssertionLeave(start, end, kind, negate) {
82321 if (this._options.onLookaroundAssertionLeave) {
82322 this._options.onLookaroundAssertionLeave(start, end, kind, negate);
82323 }
82324 }
82325
82326 onEdgeAssertion(start, end, kind) {
82327 if (this._options.onEdgeAssertion) {
82328 this._options.onEdgeAssertion(start, end, kind);
82329 }
82330 }
82331
82332 onWordBoundaryAssertion(start, end, kind, negate) {
82333 if (this._options.onWordBoundaryAssertion) {
82334 this._options.onWordBoundaryAssertion(start, end, kind, negate);
82335 }
82336 }
82337
82338 onAnyCharacterSet(start, end, kind) {
82339 if (this._options.onAnyCharacterSet) {
82340 this._options.onAnyCharacterSet(start, end, kind);
82341 }
82342 }
82343
82344 onEscapeCharacterSet(start, end, kind, negate) {
82345 if (this._options.onEscapeCharacterSet) {
82346 this._options.onEscapeCharacterSet(start, end, kind, negate);
82347 }
82348 }
82349
82350 onUnicodePropertyCharacterSet(start, end, kind, key, value, negate) {
82351 if (this._options.onUnicodePropertyCharacterSet) {
82352 this._options.onUnicodePropertyCharacterSet(start, end, kind, key, value, negate);
82353 }
82354 }
82355
82356 onCharacter(start, end, value) {
82357 if (this._options.onCharacter) {
82358 this._options.onCharacter(start, end, value);
82359 }
82360 }
82361
82362 onBackreference(start, end, ref) {
82363 if (this._options.onBackreference) {
82364 this._options.onBackreference(start, end, ref);
82365 }
82366 }
82367
82368 onCharacterClassEnter(start, negate) {
82369 if (this._options.onCharacterClassEnter) {
82370 this._options.onCharacterClassEnter(start, negate);
82371 }
82372 }
82373
82374 onCharacterClassLeave(start, end, negate) {
82375 if (this._options.onCharacterClassLeave) {
82376 this._options.onCharacterClassLeave(start, end, negate);
82377 }
82378 }
82379
82380 onCharacterClassRange(start, end, min, max) {
82381 if (this._options.onCharacterClassRange) {
82382 this._options.onCharacterClassRange(start, end, min, max);
82383 }
82384 }
82385
82386 get source() {
82387 return this._reader.source;
82388 }
82389
82390 get index() {
82391 return this._reader.index;
82392 }
82393
82394 get currentCodePoint() {
82395 return this._reader.currentCodePoint;
82396 }
82397
82398 get nextCodePoint() {
82399 return this._reader.nextCodePoint;
82400 }
82401
82402 get nextCodePoint2() {
82403 return this._reader.nextCodePoint2;
82404 }
82405
82406 get nextCodePoint3() {
82407 return this._reader.nextCodePoint3;
82408 }
82409
82410 reset(source, start, end) {
82411 this._reader.reset(source, start, end, this._uFlag);
82412 }
82413
82414 rewind(index) {
82415 this._reader.rewind(index);
82416 }
82417
82418 advance() {
82419 this._reader.advance();
82420 }
82421
82422 eat(cp) {
82423 return this._reader.eat(cp);
82424 }
82425
82426 eat2(cp1, cp2) {
82427 return this._reader.eat2(cp1, cp2);
82428 }
82429
82430 eat3(cp1, cp2, cp3) {
82431 return this._reader.eat3(cp1, cp2, cp3);
82432 }
82433
82434 raise(message) {
82435 throw new RegExpSyntaxError(this.source, this._uFlag, this.index, message);
82436 }
82437
82438 eatRegExpBody() {
82439 const start = this.index;
82440 let inClass = false;
82441 let escaped = false;
82442
82443 for (;;) {
82444 const cp = this.currentCodePoint;
82445
82446 if (cp === -1 || isLineTerminator(cp)) {
82447 const kind = inClass ? "character class" : "regular expression";
82448 this.raise("Unterminated ".concat(kind));
82449 }
82450
82451 if (escaped) {
82452 escaped = false;
82453 } else if (cp === ReverseSolidus) {
82454 escaped = true;
82455 } else if (cp === LeftSquareBracket) {
82456 inClass = true;
82457 } else if (cp === RightSquareBracket) {
82458 inClass = false;
82459 } else if (cp === Solidus && !inClass || cp === Asterisk && this.index === start) {
82460 break;
82461 }
82462
82463 this.advance();
82464 }
82465
82466 return this.index !== start;
82467 }
82468
82469 consumePattern() {
82470 const start = this.index;
82471 this._numCapturingParens = this.countCapturingParens();
82472
82473 this._groupNames.clear();
82474
82475 this._backreferenceNames.clear();
82476
82477 this.onPatternEnter(start);
82478 this.consumeDisjunction();
82479 const cp = this.currentCodePoint;
82480
82481 if (this.currentCodePoint !== -1) {
82482 if (cp === RightParenthesis) {
82483 this.raise("Unmatched ')'");
82484 }
82485
82486 if (cp === ReverseSolidus) {
82487 this.raise("\\ at end of pattern");
82488 }
82489
82490 if (cp === RightSquareBracket || cp === RightCurlyBracket) {
82491 this.raise("Lone quantifier brackets");
82492 }
82493
82494 const c = String.fromCodePoint(cp);
82495 this.raise("Unexpected character '".concat(c, "'"));
82496 }
82497
82498 for (const name of this._backreferenceNames) {
82499 if (!this._groupNames.has(name)) {
82500 this.raise("Invalid named capture referenced");
82501 }
82502 }
82503
82504 this.onPatternLeave(start, this.index);
82505 }
82506
82507 countCapturingParens() {
82508 const start = this.index;
82509 let inClass = false;
82510 let escaped = false;
82511 let count = 0;
82512 let cp = 0;
82513
82514 while ((cp = this.currentCodePoint) !== -1) {
82515 if (escaped) {
82516 escaped = false;
82517 } else if (cp === ReverseSolidus) {
82518 escaped = true;
82519 } else if (cp === LeftSquareBracket) {
82520 inClass = true;
82521 } else if (cp === RightSquareBracket) {
82522 inClass = false;
82523 } else if (cp === LeftParenthesis && !inClass && (this.nextCodePoint !== QuestionMark || this.nextCodePoint2 === LessThanSign && this.nextCodePoint3 !== EqualsSign && this.nextCodePoint3 !== ExclamationMark)) {
82524 count += 1;
82525 }
82526
82527 this.advance();
82528 }
82529
82530 this.rewind(start);
82531 return count;
82532 }
82533
82534 consumeDisjunction() {
82535 const start = this.index;
82536 let i = 0;
82537 this.onDisjunctionEnter(start);
82538
82539 do {
82540 this.consumeAlternative(i++);
82541 } while (this.eat(VerticalLine));
82542
82543 if (this.consumeQuantifier(true)) {
82544 this.raise("Nothing to repeat");
82545 }
82546
82547 if (this.eat(LeftCurlyBracket)) {
82548 this.raise("Lone quantifier brackets");
82549 }
82550
82551 this.onDisjunctionLeave(start, this.index);
82552 }
82553
82554 consumeAlternative(i) {
82555 const start = this.index;
82556 this.onAlternativeEnter(start, i);
82557
82558 while (this.currentCodePoint !== -1 && this.consumeTerm()) {}
82559
82560 this.onAlternativeLeave(start, this.index, i);
82561 }
82562
82563 consumeTerm() {
82564 if (this._uFlag || this.strict) {
82565 return this.consumeAssertion() || this.consumeAtom() && this.consumeOptionalQuantifier();
82566 }
82567
82568 return this.consumeAssertion() && (!this._lastAssertionIsQuantifiable || this.consumeOptionalQuantifier()) || this.consumeExtendedAtom() && this.consumeOptionalQuantifier();
82569 }
82570
82571 consumeOptionalQuantifier() {
82572 this.consumeQuantifier();
82573 return true;
82574 }
82575
82576 consumeAssertion() {
82577 const start = this.index;
82578 this._lastAssertionIsQuantifiable = false;
82579
82580 if (this.eat(CircumflexAccent)) {
82581 this.onEdgeAssertion(start, this.index, "start");
82582 return true;
82583 }
82584
82585 if (this.eat(DollarSign)) {
82586 this.onEdgeAssertion(start, this.index, "end");
82587 return true;
82588 }
82589
82590 if (this.eat2(ReverseSolidus, LatinCapitalLetterB)) {
82591 this.onWordBoundaryAssertion(start, this.index, "word", true);
82592 return true;
82593 }
82594
82595 if (this.eat2(ReverseSolidus, LatinSmallLetterB)) {
82596 this.onWordBoundaryAssertion(start, this.index, "word", false);
82597 return true;
82598 }
82599
82600 if (this.eat2(LeftParenthesis, QuestionMark)) {
82601 const lookbehind = this.ecmaVersion >= 2018 && this.eat(LessThanSign);
82602 let negate = false;
82603
82604 if (this.eat(EqualsSign) || (negate = this.eat(ExclamationMark))) {
82605 const kind = lookbehind ? "lookbehind" : "lookahead";
82606 this.onLookaroundAssertionEnter(start, kind, negate);
82607 this.consumeDisjunction();
82608
82609 if (!this.eat(RightParenthesis)) {
82610 this.raise("Unterminated group");
82611 }
82612
82613 this._lastAssertionIsQuantifiable = !lookbehind && !this.strict;
82614 this.onLookaroundAssertionLeave(start, this.index, kind, negate);
82615 return true;
82616 }
82617
82618 this.rewind(start);
82619 }
82620
82621 return false;
82622 }
82623
82624 consumeQuantifier() {
82625 let noConsume = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
82626 const start = this.index;
82627 let min = 0;
82628 let max = 0;
82629 let greedy = false;
82630
82631 if (this.eat(Asterisk)) {
82632 min = 0;
82633 max = Number.POSITIVE_INFINITY;
82634 } else if (this.eat(PlusSign)) {
82635 min = 1;
82636 max = Number.POSITIVE_INFINITY;
82637 } else if (this.eat(QuestionMark)) {
82638 min = 0;
82639 max = 1;
82640 } else if (this.eatBracedQuantifier(noConsume)) {
82641 min = this._lastMinValue;
82642 max = this._lastMaxValue;
82643 } else {
82644 return false;
82645 }
82646
82647 greedy = !this.eat(QuestionMark);
82648
82649 if (!noConsume) {
82650 this.onQuantifier(start, this.index, min, max, greedy);
82651 }
82652
82653 return true;
82654 }
82655
82656 eatBracedQuantifier(noError) {
82657 const start = this.index;
82658
82659 if (this.eat(LeftCurlyBracket)) {
82660 this._lastMinValue = 0;
82661 this._lastMaxValue = Number.POSITIVE_INFINITY;
82662
82663 if (this.eatDecimalDigits()) {
82664 this._lastMinValue = this._lastMaxValue = this._lastIntValue;
82665
82666 if (this.eat(Comma)) {
82667 this._lastMaxValue = this.eatDecimalDigits() ? this._lastIntValue : Number.POSITIVE_INFINITY;
82668 }
82669
82670 if (this.eat(RightCurlyBracket)) {
82671 if (!noError && this._lastMaxValue < this._lastMinValue) {
82672 this.raise("numbers out of order in {} quantifier");
82673 }
82674
82675 return true;
82676 }
82677 }
82678
82679 if (!noError && (this._uFlag || this.strict)) {
82680 this.raise("Incomplete quantifier");
82681 }
82682
82683 this.rewind(start);
82684 }
82685
82686 return false;
82687 }
82688
82689 consumeAtom() {
82690 return this.consumePatternCharacter() || this.consumeDot() || this.consumeReverseSolidusAtomEscape() || this.consumeCharacterClass() || this.consumeUncapturingGroup() || this.consumeCapturingGroup();
82691 }
82692
82693 consumeDot() {
82694 if (this.eat(FullStop)) {
82695 this.onAnyCharacterSet(this.index - 1, this.index, "any");
82696 return true;
82697 }
82698
82699 return false;
82700 }
82701
82702 consumeReverseSolidusAtomEscape() {
82703 const start = this.index;
82704
82705 if (this.eat(ReverseSolidus)) {
82706 if (this.consumeAtomEscape()) {
82707 return true;
82708 }
82709
82710 this.rewind(start);
82711 }
82712
82713 return false;
82714 }
82715
82716 consumeUncapturingGroup() {
82717 const start = this.index;
82718
82719 if (this.eat3(LeftParenthesis, QuestionMark, Colon)) {
82720 this.onGroupEnter(start);
82721 this.consumeDisjunction();
82722
82723 if (!this.eat(RightParenthesis)) {
82724 this.raise("Unterminated group");
82725 }
82726
82727 this.onGroupLeave(start, this.index);
82728 return true;
82729 }
82730
82731 return false;
82732 }
82733
82734 consumeCapturingGroup() {
82735 const start = this.index;
82736
82737 if (this.eat(LeftParenthesis)) {
82738 let name = null;
82739
82740 if (this.ecmaVersion >= 2018) {
82741 if (this.consumeGroupSpecifier()) {
82742 name = this._lastStrValue;
82743 }
82744 } else if (this.currentCodePoint === QuestionMark) {
82745 this.raise("Invalid group");
82746 }
82747
82748 this.onCapturingGroupEnter(start, name);
82749 this.consumeDisjunction();
82750
82751 if (!this.eat(RightParenthesis)) {
82752 this.raise("Unterminated group");
82753 }
82754
82755 this.onCapturingGroupLeave(start, this.index, name);
82756 return true;
82757 }
82758
82759 return false;
82760 }
82761
82762 consumeExtendedAtom() {
82763 return this.consumeDot() || this.consumeReverseSolidusAtomEscape() || this.consumeReverseSolidusFollowedByC() || this.consumeCharacterClass() || this.consumeUncapturingGroup() || this.consumeCapturingGroup() || this.consumeInvalidBracedQuantifier() || this.consumeExtendedPatternCharacter();
82764 }
82765
82766 consumeReverseSolidusFollowedByC() {
82767 const start = this.index;
82768
82769 if (this.currentCodePoint === ReverseSolidus && this.nextCodePoint === LatinSmallLetterC) {
82770 this._lastIntValue = this.currentCodePoint;
82771 this.advance();
82772 this.onCharacter(start, this.index, ReverseSolidus);
82773 return true;
82774 }
82775
82776 return false;
82777 }
82778
82779 consumeInvalidBracedQuantifier() {
82780 if (this.eatBracedQuantifier(true)) {
82781 this.raise("Nothing to repeat");
82782 }
82783
82784 return false;
82785 }
82786
82787 consumePatternCharacter() {
82788 const start = this.index;
82789 const cp = this.currentCodePoint;
82790
82791 if (cp !== -1 && !isSyntaxCharacter(cp)) {
82792 this.advance();
82793 this.onCharacter(start, this.index, cp);
82794 return true;
82795 }
82796
82797 return false;
82798 }
82799
82800 consumeExtendedPatternCharacter() {
82801 const start = this.index;
82802 const cp = this.currentCodePoint;
82803
82804 if (cp !== -1 && cp !== CircumflexAccent && cp !== DollarSign && cp !== ReverseSolidus && cp !== FullStop && cp !== Asterisk && cp !== PlusSign && cp !== QuestionMark && cp !== LeftParenthesis && cp !== RightParenthesis && cp !== LeftSquareBracket && cp !== VerticalLine) {
82805 this.advance();
82806 this.onCharacter(start, this.index, cp);
82807 return true;
82808 }
82809
82810 return false;
82811 }
82812
82813 consumeGroupSpecifier() {
82814 if (this.eat(QuestionMark)) {
82815 if (this.eatGroupName()) {
82816 if (!this._groupNames.has(this._lastStrValue)) {
82817 this._groupNames.add(this._lastStrValue);
82818
82819 return true;
82820 }
82821
82822 this.raise("Duplicate capture group name");
82823 }
82824
82825 this.raise("Invalid group");
82826 }
82827
82828 return false;
82829 }
82830
82831 consumeAtomEscape() {
82832 if (this.consumeBackreference() || this.consumeCharacterClassEscape() || this.consumeCharacterEscape() || this._nFlag && this.consumeKGroupName()) {
82833 return true;
82834 }
82835
82836 if (this.strict || this._uFlag) {
82837 this.raise("Invalid escape");
82838 }
82839
82840 return false;
82841 }
82842
82843 consumeBackreference() {
82844 const start = this.index;
82845
82846 if (this.eatDecimalEscape()) {
82847 const n = this._lastIntValue;
82848
82849 if (n <= this._numCapturingParens) {
82850 this.onBackreference(start - 1, this.index, n);
82851 return true;
82852 }
82853
82854 if (this.strict || this._uFlag) {
82855 this.raise("Invalid escape");
82856 }
82857
82858 this.rewind(start);
82859 }
82860
82861 return false;
82862 }
82863
82864 consumeCharacterClassEscape() {
82865 const start = this.index;
82866
82867 if (this.eat(LatinSmallLetterD)) {
82868 this._lastIntValue = -1;
82869 this.onEscapeCharacterSet(start - 1, this.index, "digit", false);
82870 return true;
82871 }
82872
82873 if (this.eat(LatinCapitalLetterD)) {
82874 this._lastIntValue = -1;
82875 this.onEscapeCharacterSet(start - 1, this.index, "digit", true);
82876 return true;
82877 }
82878
82879 if (this.eat(LatinSmallLetterS)) {
82880 this._lastIntValue = -1;
82881 this.onEscapeCharacterSet(start - 1, this.index, "space", false);
82882 return true;
82883 }
82884
82885 if (this.eat(LatinCapitalLetterS)) {
82886 this._lastIntValue = -1;
82887 this.onEscapeCharacterSet(start - 1, this.index, "space", true);
82888 return true;
82889 }
82890
82891 if (this.eat(LatinSmallLetterW)) {
82892 this._lastIntValue = -1;
82893 this.onEscapeCharacterSet(start - 1, this.index, "word", false);
82894 return true;
82895 }
82896
82897 if (this.eat(LatinCapitalLetterW)) {
82898 this._lastIntValue = -1;
82899 this.onEscapeCharacterSet(start - 1, this.index, "word", true);
82900 return true;
82901 }
82902
82903 let negate = false;
82904
82905 if (this._uFlag && this.ecmaVersion >= 2018 && (this.eat(LatinSmallLetterP) || (negate = this.eat(LatinCapitalLetterP)))) {
82906 this._lastIntValue = -1;
82907
82908 if (this.eat(LeftCurlyBracket) && this.eatUnicodePropertyValueExpression() && this.eat(RightCurlyBracket)) {
82909 this.onUnicodePropertyCharacterSet(start - 1, this.index, "property", this._lastKeyValue, this._lastValValue || null, negate);
82910 return true;
82911 }
82912
82913 this.raise("Invalid property name");
82914 }
82915
82916 return false;
82917 }
82918
82919 consumeCharacterEscape() {
82920 const start = this.index;
82921
82922 if (this.eatControlEscape() || this.eatCControlLetter() || this.eatZero() || this.eatHexEscapeSequence() || this.eatRegExpUnicodeEscapeSequence() || !this.strict && !this._uFlag && this.eatLegacyOctalEscapeSequence() || this.eatIdentityEscape()) {
82923 this.onCharacter(start - 1, this.index, this._lastIntValue);
82924 return true;
82925 }
82926
82927 return false;
82928 }
82929
82930 consumeKGroupName() {
82931 const start = this.index;
82932
82933 if (this.eat(LatinSmallLetterK)) {
82934 if (this.eatGroupName()) {
82935 const groupName = this._lastStrValue;
82936
82937 this._backreferenceNames.add(groupName);
82938
82939 this.onBackreference(start - 1, this.index, groupName);
82940 return true;
82941 }
82942
82943 this.raise("Invalid named reference");
82944 }
82945
82946 return false;
82947 }
82948
82949 consumeCharacterClass() {
82950 const start = this.index;
82951
82952 if (this.eat(LeftSquareBracket)) {
82953 const negate = this.eat(CircumflexAccent);
82954 this.onCharacterClassEnter(start, negate);
82955 this.consumeClassRanges();
82956
82957 if (!this.eat(RightSquareBracket)) {
82958 this.raise("Unterminated character class");
82959 }
82960
82961 this.onCharacterClassLeave(start, this.index, negate);
82962 return true;
82963 }
82964
82965 return false;
82966 }
82967
82968 consumeClassRanges() {
82969 const strict = this.strict || this._uFlag;
82970
82971 for (;;) {
82972 const rangeStart = this.index;
82973
82974 if (!this.consumeClassAtom()) {
82975 break;
82976 }
82977
82978 const min = this._lastIntValue;
82979
82980 if (!this.eat(HyphenMinus)) {
82981 continue;
82982 }
82983
82984 this.onCharacter(this.index - 1, this.index, HyphenMinus);
82985
82986 if (!this.consumeClassAtom()) {
82987 break;
82988 }
82989
82990 const max = this._lastIntValue;
82991
82992 if (min === -1 || max === -1) {
82993 if (strict) {
82994 this.raise("Invalid character class");
82995 }
82996
82997 continue;
82998 }
82999
83000 if (min > max) {
83001 this.raise("Range out of order in character class");
83002 }
83003
83004 this.onCharacterClassRange(rangeStart, this.index, min, max);
83005 }
83006 }
83007
83008 consumeClassAtom() {
83009 const start = this.index;
83010 const cp = this.currentCodePoint;
83011
83012 if (cp !== -1 && cp !== ReverseSolidus && cp !== RightSquareBracket) {
83013 this.advance();
83014 this._lastIntValue = cp;
83015 this.onCharacter(start, this.index, this._lastIntValue);
83016 return true;
83017 }
83018
83019 if (this.eat(ReverseSolidus)) {
83020 if (this.consumeClassEscape()) {
83021 return true;
83022 }
83023
83024 if (!this.strict && this.currentCodePoint === LatinSmallLetterC) {
83025 this._lastIntValue = ReverseSolidus;
83026 this.onCharacter(start, this.index, this._lastIntValue);
83027 return true;
83028 }
83029
83030 if (this.strict || this._uFlag) {
83031 this.raise("Invalid escape");
83032 }
83033
83034 this.rewind(start);
83035 }
83036
83037 return false;
83038 }
83039
83040 consumeClassEscape() {
83041 const start = this.index;
83042
83043 if (this.eat(LatinSmallLetterB)) {
83044 this._lastIntValue = Backspace;
83045 this.onCharacter(start - 1, this.index, this._lastIntValue);
83046 return true;
83047 }
83048
83049 if (this._uFlag && this.eat(HyphenMinus)) {
83050 this._lastIntValue = HyphenMinus;
83051 this.onCharacter(start - 1, this.index, this._lastIntValue);
83052 return true;
83053 }
83054
83055 let cp = 0;
83056
83057 if (!this.strict && !this._uFlag && this.currentCodePoint === LatinSmallLetterC && (isDecimalDigit(cp = this.nextCodePoint) || cp === LowLine)) {
83058 this.advance();
83059 this.advance();
83060 this._lastIntValue = cp % 0x20;
83061 this.onCharacter(start - 1, this.index, this._lastIntValue);
83062 return true;
83063 }
83064
83065 return this.consumeCharacterClassEscape() || this.consumeCharacterEscape();
83066 }
83067
83068 eatGroupName() {
83069 if (this.eat(LessThanSign)) {
83070 if (this.eatRegExpIdentifierName() && this.eat(GreaterThanSign)) {
83071 return true;
83072 }
83073
83074 this.raise("Invalid capture group name");
83075 }
83076
83077 return false;
83078 }
83079
83080 eatRegExpIdentifierName() {
83081 if (this.eatRegExpIdentifierStart()) {
83082 this._lastStrValue = String.fromCodePoint(this._lastIntValue);
83083
83084 while (this.eatRegExpIdentifierPart()) {
83085 this._lastStrValue += String.fromCodePoint(this._lastIntValue);
83086 }
83087
83088 return true;
83089 }
83090
83091 return false;
83092 }
83093
83094 eatRegExpIdentifierStart() {
83095 const start = this.index;
83096 const forceUFlag = !this._uFlag && this.ecmaVersion >= 2020;
83097 let cp = this.currentCodePoint;
83098 this.advance();
83099
83100 if (cp === ReverseSolidus && this.eatRegExpUnicodeEscapeSequence(forceUFlag)) {
83101 cp = this._lastIntValue;
83102 } else if (forceUFlag && isLeadSurrogate(cp) && isTrailSurrogate(this.currentCodePoint)) {
83103 cp = combineSurrogatePair(cp, this.currentCodePoint);
83104 this.advance();
83105 }
83106
83107 if (isRegExpIdentifierStart(cp)) {
83108 this._lastIntValue = cp;
83109 return true;
83110 }
83111
83112 if (this.index !== start) {
83113 this.rewind(start);
83114 }
83115
83116 return false;
83117 }
83118
83119 eatRegExpIdentifierPart() {
83120 const start = this.index;
83121 const forceUFlag = !this._uFlag && this.ecmaVersion >= 2020;
83122 let cp = this.currentCodePoint;
83123 this.advance();
83124
83125 if (cp === ReverseSolidus && this.eatRegExpUnicodeEscapeSequence(forceUFlag)) {
83126 cp = this._lastIntValue;
83127 } else if (forceUFlag && isLeadSurrogate(cp) && isTrailSurrogate(this.currentCodePoint)) {
83128 cp = combineSurrogatePair(cp, this.currentCodePoint);
83129 this.advance();
83130 }
83131
83132 if (isRegExpIdentifierPart(cp)) {
83133 this._lastIntValue = cp;
83134 return true;
83135 }
83136
83137 if (this.index !== start) {
83138 this.rewind(start);
83139 }
83140
83141 return false;
83142 }
83143
83144 eatCControlLetter() {
83145 const start = this.index;
83146
83147 if (this.eat(LatinSmallLetterC)) {
83148 if (this.eatControlLetter()) {
83149 return true;
83150 }
83151
83152 this.rewind(start);
83153 }
83154
83155 return false;
83156 }
83157
83158 eatZero() {
83159 if (this.currentCodePoint === DigitZero && !isDecimalDigit(this.nextCodePoint)) {
83160 this._lastIntValue = 0;
83161 this.advance();
83162 return true;
83163 }
83164
83165 return false;
83166 }
83167
83168 eatControlEscape() {
83169 if (this.eat(LatinSmallLetterF)) {
83170 this._lastIntValue = FormFeed;
83171 return true;
83172 }
83173
83174 if (this.eat(LatinSmallLetterN)) {
83175 this._lastIntValue = LineFeed;
83176 return true;
83177 }
83178
83179 if (this.eat(LatinSmallLetterR)) {
83180 this._lastIntValue = CarriageReturn;
83181 return true;
83182 }
83183
83184 if (this.eat(LatinSmallLetterT)) {
83185 this._lastIntValue = CharacterTabulation;
83186 return true;
83187 }
83188
83189 if (this.eat(LatinSmallLetterV)) {
83190 this._lastIntValue = LineTabulation;
83191 return true;
83192 }
83193
83194 return false;
83195 }
83196
83197 eatControlLetter() {
83198 const cp = this.currentCodePoint;
83199
83200 if (isLatinLetter(cp)) {
83201 this.advance();
83202 this._lastIntValue = cp % 0x20;
83203 return true;
83204 }
83205
83206 return false;
83207 }
83208
83209 eatRegExpUnicodeEscapeSequence() {
83210 let forceUFlag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
83211 const start = this.index;
83212 const uFlag = forceUFlag || this._uFlag;
83213
83214 if (this.eat(LatinSmallLetterU)) {
83215 if (uFlag && this.eatRegExpUnicodeSurrogatePairEscape() || this.eatFixedHexDigits(4) || uFlag && this.eatRegExpUnicodeCodePointEscape()) {
83216 return true;
83217 }
83218
83219 if (this.strict || uFlag) {
83220 this.raise("Invalid unicode escape");
83221 }
83222
83223 this.rewind(start);
83224 }
83225
83226 return false;
83227 }
83228
83229 eatRegExpUnicodeSurrogatePairEscape() {
83230 const start = this.index;
83231
83232 if (this.eatFixedHexDigits(4)) {
83233 const lead = this._lastIntValue;
83234
83235 if (isLeadSurrogate(lead) && this.eat(ReverseSolidus) && this.eat(LatinSmallLetterU) && this.eatFixedHexDigits(4)) {
83236 const trail = this._lastIntValue;
83237
83238 if (isTrailSurrogate(trail)) {
83239 this._lastIntValue = combineSurrogatePair(lead, trail);
83240 return true;
83241 }
83242 }
83243
83244 this.rewind(start);
83245 }
83246
83247 return false;
83248 }
83249
83250 eatRegExpUnicodeCodePointEscape() {
83251 const start = this.index;
83252
83253 if (this.eat(LeftCurlyBracket) && this.eatHexDigits() && this.eat(RightCurlyBracket) && isValidUnicode(this._lastIntValue)) {
83254 return true;
83255 }
83256
83257 this.rewind(start);
83258 return false;
83259 }
83260
83261 eatIdentityEscape() {
83262 const cp = this.currentCodePoint;
83263
83264 if (this.isValidIdentityEscape(cp)) {
83265 this._lastIntValue = cp;
83266 this.advance();
83267 return true;
83268 }
83269
83270 return false;
83271 }
83272
83273 isValidIdentityEscape(cp) {
83274 if (cp === -1) {
83275 return false;
83276 }
83277
83278 if (this._uFlag) {
83279 return isSyntaxCharacter(cp) || cp === Solidus;
83280 }
83281
83282 if (this.strict) {
83283 return !isIdContinue(cp);
83284 }
83285
83286 if (this._nFlag) {
83287 return !(cp === LatinSmallLetterC || cp === LatinSmallLetterK);
83288 }
83289
83290 return cp !== LatinSmallLetterC;
83291 }
83292
83293 eatDecimalEscape() {
83294 this._lastIntValue = 0;
83295 let cp = this.currentCodePoint;
83296
83297 if (cp >= DigitOne && cp <= DigitNine) {
83298 do {
83299 this._lastIntValue = 10 * this._lastIntValue + (cp - DigitZero);
83300 this.advance();
83301 } while ((cp = this.currentCodePoint) >= DigitZero && cp <= DigitNine);
83302
83303 return true;
83304 }
83305
83306 return false;
83307 }
83308
83309 eatUnicodePropertyValueExpression() {
83310 const start = this.index;
83311
83312 if (this.eatUnicodePropertyName() && this.eat(EqualsSign)) {
83313 this._lastKeyValue = this._lastStrValue;
83314
83315 if (this.eatUnicodePropertyValue()) {
83316 this._lastValValue = this._lastStrValue;
83317
83318 if (isValidUnicodeProperty(this.ecmaVersion, this._lastKeyValue, this._lastValValue)) {
83319 return true;
83320 }
83321
83322 this.raise("Invalid property name");
83323 }
83324 }
83325
83326 this.rewind(start);
83327
83328 if (this.eatLoneUnicodePropertyNameOrValue()) {
83329 const nameOrValue = this._lastStrValue;
83330
83331 if (isValidUnicodeProperty(this.ecmaVersion, "General_Category", nameOrValue)) {
83332 this._lastKeyValue = "General_Category";
83333 this._lastValValue = nameOrValue;
83334 return true;
83335 }
83336
83337 if (isValidLoneUnicodeProperty(this.ecmaVersion, nameOrValue)) {
83338 this._lastKeyValue = nameOrValue;
83339 this._lastValValue = "";
83340 return true;
83341 }
83342
83343 this.raise("Invalid property name");
83344 }
83345
83346 return false;
83347 }
83348
83349 eatUnicodePropertyName() {
83350 this._lastStrValue = "";
83351
83352 while (isUnicodePropertyNameCharacter(this.currentCodePoint)) {
83353 this._lastStrValue += String.fromCodePoint(this.currentCodePoint);
83354 this.advance();
83355 }
83356
83357 return this._lastStrValue !== "";
83358 }
83359
83360 eatUnicodePropertyValue() {
83361 this._lastStrValue = "";
83362
83363 while (isUnicodePropertyValueCharacter(this.currentCodePoint)) {
83364 this._lastStrValue += String.fromCodePoint(this.currentCodePoint);
83365 this.advance();
83366 }
83367
83368 return this._lastStrValue !== "";
83369 }
83370
83371 eatLoneUnicodePropertyNameOrValue() {
83372 return this.eatUnicodePropertyValue();
83373 }
83374
83375 eatHexEscapeSequence() {
83376 const start = this.index;
83377
83378 if (this.eat(LatinSmallLetterX)) {
83379 if (this.eatFixedHexDigits(2)) {
83380 return true;
83381 }
83382
83383 if (this._uFlag || this.strict) {
83384 this.raise("Invalid escape");
83385 }
83386
83387 this.rewind(start);
83388 }
83389
83390 return false;
83391 }
83392
83393 eatDecimalDigits() {
83394 const start = this.index;
83395 this._lastIntValue = 0;
83396
83397 while (isDecimalDigit(this.currentCodePoint)) {
83398 this._lastIntValue = 10 * this._lastIntValue + digitToInt(this.currentCodePoint);
83399 this.advance();
83400 }
83401
83402 return this.index !== start;
83403 }
83404
83405 eatHexDigits() {
83406 const start = this.index;
83407 this._lastIntValue = 0;
83408
83409 while (isHexDigit(this.currentCodePoint)) {
83410 this._lastIntValue = 16 * this._lastIntValue + digitToInt(this.currentCodePoint);
83411 this.advance();
83412 }
83413
83414 return this.index !== start;
83415 }
83416
83417 eatLegacyOctalEscapeSequence() {
83418 if (this.eatOctalDigit()) {
83419 const n1 = this._lastIntValue;
83420
83421 if (this.eatOctalDigit()) {
83422 const n2 = this._lastIntValue;
83423
83424 if (n1 <= 3 && this.eatOctalDigit()) {
83425 this._lastIntValue = n1 * 64 + n2 * 8 + this._lastIntValue;
83426 } else {
83427 this._lastIntValue = n1 * 8 + n2;
83428 }
83429 } else {
83430 this._lastIntValue = n1;
83431 }
83432
83433 return true;
83434 }
83435
83436 return false;
83437 }
83438
83439 eatOctalDigit() {
83440 const cp = this.currentCodePoint;
83441
83442 if (isOctalDigit(cp)) {
83443 this.advance();
83444 this._lastIntValue = cp - DigitZero;
83445 return true;
83446 }
83447
83448 this._lastIntValue = 0;
83449 return false;
83450 }
83451
83452 eatFixedHexDigits(length) {
83453 const start = this.index;
83454 this._lastIntValue = 0;
83455
83456 for (let i = 0; i < length; ++i) {
83457 const cp = this.currentCodePoint;
83458
83459 if (!isHexDigit(cp)) {
83460 this.rewind(start);
83461 return false;
83462 }
83463
83464 this._lastIntValue = 16 * this._lastIntValue + digitToInt(cp);
83465 this.advance();
83466 }
83467
83468 return true;
83469 }
83470
83471 }
83472
83473 const DummyPattern = {};
83474 const DummyFlags = {};
83475 const DummyCapturingGroup = {};
83476
83477 class RegExpParserState {
83478 constructor(options) {
83479 this._node = DummyPattern;
83480 this._flags = DummyFlags;
83481 this._backreferences = [];
83482 this._capturingGroups = [];
83483 this.source = "";
83484 this.strict = Boolean(options && options.strict);
83485 this.ecmaVersion = options && options.ecmaVersion || 2022;
83486 }
83487
83488 get pattern() {
83489 if (this._node.type !== "Pattern") {
83490 throw new Error("UnknownError");
83491 }
83492
83493 return this._node;
83494 }
83495
83496 get flags() {
83497 if (this._flags.type !== "Flags") {
83498 throw new Error("UnknownError");
83499 }
83500
83501 return this._flags;
83502 }
83503
83504 onFlags(start, end, global, ignoreCase, multiline, unicode, sticky, dotAll, hasIndices) {
83505 this._flags = {
83506 type: "Flags",
83507 parent: null,
83508 start,
83509 end,
83510 raw: this.source.slice(start, end),
83511 global,
83512 ignoreCase,
83513 multiline,
83514 unicode,
83515 sticky,
83516 dotAll,
83517 hasIndices
83518 };
83519 }
83520
83521 onPatternEnter(start) {
83522 this._node = {
83523 type: "Pattern",
83524 parent: null,
83525 start,
83526 end: start,
83527 raw: "",
83528 alternatives: []
83529 };
83530 this._backreferences.length = 0;
83531 this._capturingGroups.length = 0;
83532 }
83533
83534 onPatternLeave(start, end) {
83535 this._node.end = end;
83536 this._node.raw = this.source.slice(start, end);
83537
83538 for (const reference of this._backreferences) {
83539 const ref = reference.ref;
83540 const group = typeof ref === "number" ? this._capturingGroups[ref - 1] : this._capturingGroups.find(g => g.name === ref);
83541 reference.resolved = group;
83542 group.references.push(reference);
83543 }
83544 }
83545
83546 onAlternativeEnter(start) {
83547 const parent = this._node;
83548
83549 if (parent.type !== "Assertion" && parent.type !== "CapturingGroup" && parent.type !== "Group" && parent.type !== "Pattern") {
83550 throw new Error("UnknownError");
83551 }
83552
83553 this._node = {
83554 type: "Alternative",
83555 parent,
83556 start,
83557 end: start,
83558 raw: "",
83559 elements: []
83560 };
83561 parent.alternatives.push(this._node);
83562 }
83563
83564 onAlternativeLeave(start, end) {
83565 const node = this._node;
83566
83567 if (node.type !== "Alternative") {
83568 throw new Error("UnknownError");
83569 }
83570
83571 node.end = end;
83572 node.raw = this.source.slice(start, end);
83573 this._node = node.parent;
83574 }
83575
83576 onGroupEnter(start) {
83577 const parent = this._node;
83578
83579 if (parent.type !== "Alternative") {
83580 throw new Error("UnknownError");
83581 }
83582
83583 this._node = {
83584 type: "Group",
83585 parent,
83586 start,
83587 end: start,
83588 raw: "",
83589 alternatives: []
83590 };
83591 parent.elements.push(this._node);
83592 }
83593
83594 onGroupLeave(start, end) {
83595 const node = this._node;
83596
83597 if (node.type !== "Group" || node.parent.type !== "Alternative") {
83598 throw new Error("UnknownError");
83599 }
83600
83601 node.end = end;
83602 node.raw = this.source.slice(start, end);
83603 this._node = node.parent;
83604 }
83605
83606 onCapturingGroupEnter(start, name) {
83607 const parent = this._node;
83608
83609 if (parent.type !== "Alternative") {
83610 throw new Error("UnknownError");
83611 }
83612
83613 this._node = {
83614 type: "CapturingGroup",
83615 parent,
83616 start,
83617 end: start,
83618 raw: "",
83619 name,
83620 alternatives: [],
83621 references: []
83622 };
83623 parent.elements.push(this._node);
83624
83625 this._capturingGroups.push(this._node);
83626 }
83627
83628 onCapturingGroupLeave(start, end) {
83629 const node = this._node;
83630
83631 if (node.type !== "CapturingGroup" || node.parent.type !== "Alternative") {
83632 throw new Error("UnknownError");
83633 }
83634
83635 node.end = end;
83636 node.raw = this.source.slice(start, end);
83637 this._node = node.parent;
83638 }
83639
83640 onQuantifier(start, end, min, max, greedy) {
83641 const parent = this._node;
83642
83643 if (parent.type !== "Alternative") {
83644 throw new Error("UnknownError");
83645 }
83646
83647 const element = parent.elements.pop();
83648
83649 if (element == null || element.type === "Quantifier" || element.type === "Assertion" && element.kind !== "lookahead") {
83650 throw new Error("UnknownError");
83651 }
83652
83653 const node = {
83654 type: "Quantifier",
83655 parent,
83656 start: element.start,
83657 end,
83658 raw: this.source.slice(element.start, end),
83659 min,
83660 max,
83661 greedy,
83662 element
83663 };
83664 parent.elements.push(node);
83665 element.parent = node;
83666 }
83667
83668 onLookaroundAssertionEnter(start, kind, negate) {
83669 const parent = this._node;
83670
83671 if (parent.type !== "Alternative") {
83672 throw new Error("UnknownError");
83673 }
83674
83675 const node = this._node = {
83676 type: "Assertion",
83677 parent,
83678 start,
83679 end: start,
83680 raw: "",
83681 kind,
83682 negate,
83683 alternatives: []
83684 };
83685 parent.elements.push(node);
83686 }
83687
83688 onLookaroundAssertionLeave(start, end) {
83689 const node = this._node;
83690
83691 if (node.type !== "Assertion" || node.parent.type !== "Alternative") {
83692 throw new Error("UnknownError");
83693 }
83694
83695 node.end = end;
83696 node.raw = this.source.slice(start, end);
83697 this._node = node.parent;
83698 }
83699
83700 onEdgeAssertion(start, end, kind) {
83701 const parent = this._node;
83702
83703 if (parent.type !== "Alternative") {
83704 throw new Error("UnknownError");
83705 }
83706
83707 parent.elements.push({
83708 type: "Assertion",
83709 parent,
83710 start,
83711 end,
83712 raw: this.source.slice(start, end),
83713 kind
83714 });
83715 }
83716
83717 onWordBoundaryAssertion(start, end, kind, negate) {
83718 const parent = this._node;
83719
83720 if (parent.type !== "Alternative") {
83721 throw new Error("UnknownError");
83722 }
83723
83724 parent.elements.push({
83725 type: "Assertion",
83726 parent,
83727 start,
83728 end,
83729 raw: this.source.slice(start, end),
83730 kind,
83731 negate
83732 });
83733 }
83734
83735 onAnyCharacterSet(start, end, kind) {
83736 const parent = this._node;
83737
83738 if (parent.type !== "Alternative") {
83739 throw new Error("UnknownError");
83740 }
83741
83742 parent.elements.push({
83743 type: "CharacterSet",
83744 parent,
83745 start,
83746 end,
83747 raw: this.source.slice(start, end),
83748 kind
83749 });
83750 }
83751
83752 onEscapeCharacterSet(start, end, kind, negate) {
83753 const parent = this._node;
83754
83755 if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
83756 throw new Error("UnknownError");
83757 }
83758
83759 parent.elements.push({
83760 type: "CharacterSet",
83761 parent,
83762 start,
83763 end,
83764 raw: this.source.slice(start, end),
83765 kind,
83766 negate
83767 });
83768 }
83769
83770 onUnicodePropertyCharacterSet(start, end, kind, key, value, negate) {
83771 const parent = this._node;
83772
83773 if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
83774 throw new Error("UnknownError");
83775 }
83776
83777 parent.elements.push({
83778 type: "CharacterSet",
83779 parent,
83780 start,
83781 end,
83782 raw: this.source.slice(start, end),
83783 kind,
83784 key,
83785 value,
83786 negate
83787 });
83788 }
83789
83790 onCharacter(start, end, value) {
83791 const parent = this._node;
83792
83793 if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
83794 throw new Error("UnknownError");
83795 }
83796
83797 parent.elements.push({
83798 type: "Character",
83799 parent,
83800 start,
83801 end,
83802 raw: this.source.slice(start, end),
83803 value
83804 });
83805 }
83806
83807 onBackreference(start, end, ref) {
83808 const parent = this._node;
83809
83810 if (parent.type !== "Alternative") {
83811 throw new Error("UnknownError");
83812 }
83813
83814 const node = {
83815 type: "Backreference",
83816 parent,
83817 start,
83818 end,
83819 raw: this.source.slice(start, end),
83820 ref,
83821 resolved: DummyCapturingGroup
83822 };
83823 parent.elements.push(node);
83824
83825 this._backreferences.push(node);
83826 }
83827
83828 onCharacterClassEnter(start, negate) {
83829 const parent = this._node;
83830
83831 if (parent.type !== "Alternative") {
83832 throw new Error("UnknownError");
83833 }
83834
83835 this._node = {
83836 type: "CharacterClass",
83837 parent,
83838 start,
83839 end: start,
83840 raw: "",
83841 negate,
83842 elements: []
83843 };
83844 parent.elements.push(this._node);
83845 }
83846
83847 onCharacterClassLeave(start, end) {
83848 const node = this._node;
83849
83850 if (node.type !== "CharacterClass" || node.parent.type !== "Alternative") {
83851 throw new Error("UnknownError");
83852 }
83853
83854 node.end = end;
83855 node.raw = this.source.slice(start, end);
83856 this._node = node.parent;
83857 }
83858
83859 onCharacterClassRange(start, end) {
83860 const parent = this._node;
83861
83862 if (parent.type !== "CharacterClass") {
83863 throw new Error("UnknownError");
83864 }
83865
83866 const elements = parent.elements;
83867 const max = elements.pop();
83868 const hyphen = elements.pop();
83869 const min = elements.pop();
83870
83871 if (!min || !max || !hyphen || min.type !== "Character" || max.type !== "Character" || hyphen.type !== "Character" || hyphen.value !== HyphenMinus) {
83872 throw new Error("UnknownError");
83873 }
83874
83875 const node = {
83876 type: "CharacterClassRange",
83877 parent,
83878 start,
83879 end,
83880 raw: this.source.slice(start, end),
83881 min,
83882 max
83883 };
83884 min.parent = node;
83885 max.parent = node;
83886 elements.push(node);
83887 }
83888
83889 }
83890
83891 class RegExpParser {
83892 constructor(options) {
83893 this._state = new RegExpParserState(options);
83894 this._validator = new RegExpValidator(this._state);
83895 }
83896
83897 parseLiteral(source) {
83898 let start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
83899 let end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : source.length;
83900 this._state.source = source;
83901
83902 this._validator.validateLiteral(source, start, end);
83903
83904 const pattern = this._state.pattern;
83905 const flags = this._state.flags;
83906 const literal = {
83907 type: "RegExpLiteral",
83908 parent: null,
83909 start,
83910 end,
83911 raw: source,
83912 pattern,
83913 flags
83914 };
83915 pattern.parent = literal;
83916 flags.parent = literal;
83917 return literal;
83918 }
83919
83920 parseFlags(source) {
83921 let start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
83922 let end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : source.length;
83923 this._state.source = source;
83924
83925 this._validator.validateFlags(source, start, end);
83926
83927 return this._state.flags;
83928 }
83929
83930 parsePattern(source) {
83931 let start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
83932 let end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : source.length;
83933 let uFlag = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
83934 this._state.source = source;
83935
83936 this._validator.validatePattern(source, start, end, uFlag);
83937
83938 return this._state.pattern;
83939 }
83940
83941 }
83942
83943 class RegExpVisitor {
83944 constructor(handlers) {
83945 this._handlers = handlers;
83946 }
83947
83948 visit(node) {
83949 switch (node.type) {
83950 case "Alternative":
83951 this.visitAlternative(node);
83952 break;
83953
83954 case "Assertion":
83955 this.visitAssertion(node);
83956 break;
83957
83958 case "Backreference":
83959 this.visitBackreference(node);
83960 break;
83961
83962 case "CapturingGroup":
83963 this.visitCapturingGroup(node);
83964 break;
83965
83966 case "Character":
83967 this.visitCharacter(node);
83968 break;
83969
83970 case "CharacterClass":
83971 this.visitCharacterClass(node);
83972 break;
83973
83974 case "CharacterClassRange":
83975 this.visitCharacterClassRange(node);
83976 break;
83977
83978 case "CharacterSet":
83979 this.visitCharacterSet(node);
83980 break;
83981
83982 case "Flags":
83983 this.visitFlags(node);
83984 break;
83985
83986 case "Group":
83987 this.visitGroup(node);
83988 break;
83989
83990 case "Pattern":
83991 this.visitPattern(node);
83992 break;
83993
83994 case "Quantifier":
83995 this.visitQuantifier(node);
83996 break;
83997
83998 case "RegExpLiteral":
83999 this.visitRegExpLiteral(node);
84000 break;
84001
84002 default:
84003 throw new Error("Unknown type: ".concat(node.type));
84004 }
84005 }
84006
84007 visitAlternative(node) {
84008 if (this._handlers.onAlternativeEnter) {
84009 this._handlers.onAlternativeEnter(node);
84010 }
84011
84012 node.elements.forEach(this.visit, this);
84013
84014 if (this._handlers.onAlternativeLeave) {
84015 this._handlers.onAlternativeLeave(node);
84016 }
84017 }
84018
84019 visitAssertion(node) {
84020 if (this._handlers.onAssertionEnter) {
84021 this._handlers.onAssertionEnter(node);
84022 }
84023
84024 if (node.kind === "lookahead" || node.kind === "lookbehind") {
84025 node.alternatives.forEach(this.visit, this);
84026 }
84027
84028 if (this._handlers.onAssertionLeave) {
84029 this._handlers.onAssertionLeave(node);
84030 }
84031 }
84032
84033 visitBackreference(node) {
84034 if (this._handlers.onBackreferenceEnter) {
84035 this._handlers.onBackreferenceEnter(node);
84036 }
84037
84038 if (this._handlers.onBackreferenceLeave) {
84039 this._handlers.onBackreferenceLeave(node);
84040 }
84041 }
84042
84043 visitCapturingGroup(node) {
84044 if (this._handlers.onCapturingGroupEnter) {
84045 this._handlers.onCapturingGroupEnter(node);
84046 }
84047
84048 node.alternatives.forEach(this.visit, this);
84049
84050 if (this._handlers.onCapturingGroupLeave) {
84051 this._handlers.onCapturingGroupLeave(node);
84052 }
84053 }
84054
84055 visitCharacter(node) {
84056 if (this._handlers.onCharacterEnter) {
84057 this._handlers.onCharacterEnter(node);
84058 }
84059
84060 if (this._handlers.onCharacterLeave) {
84061 this._handlers.onCharacterLeave(node);
84062 }
84063 }
84064
84065 visitCharacterClass(node) {
84066 if (this._handlers.onCharacterClassEnter) {
84067 this._handlers.onCharacterClassEnter(node);
84068 }
84069
84070 node.elements.forEach(this.visit, this);
84071
84072 if (this._handlers.onCharacterClassLeave) {
84073 this._handlers.onCharacterClassLeave(node);
84074 }
84075 }
84076
84077 visitCharacterClassRange(node) {
84078 if (this._handlers.onCharacterClassRangeEnter) {
84079 this._handlers.onCharacterClassRangeEnter(node);
84080 }
84081
84082 this.visitCharacter(node.min);
84083 this.visitCharacter(node.max);
84084
84085 if (this._handlers.onCharacterClassRangeLeave) {
84086 this._handlers.onCharacterClassRangeLeave(node);
84087 }
84088 }
84089
84090 visitCharacterSet(node) {
84091 if (this._handlers.onCharacterSetEnter) {
84092 this._handlers.onCharacterSetEnter(node);
84093 }
84094
84095 if (this._handlers.onCharacterSetLeave) {
84096 this._handlers.onCharacterSetLeave(node);
84097 }
84098 }
84099
84100 visitFlags(node) {
84101 if (this._handlers.onFlagsEnter) {
84102 this._handlers.onFlagsEnter(node);
84103 }
84104
84105 if (this._handlers.onFlagsLeave) {
84106 this._handlers.onFlagsLeave(node);
84107 }
84108 }
84109
84110 visitGroup(node) {
84111 if (this._handlers.onGroupEnter) {
84112 this._handlers.onGroupEnter(node);
84113 }
84114
84115 node.alternatives.forEach(this.visit, this);
84116
84117 if (this._handlers.onGroupLeave) {
84118 this._handlers.onGroupLeave(node);
84119 }
84120 }
84121
84122 visitPattern(node) {
84123 if (this._handlers.onPatternEnter) {
84124 this._handlers.onPatternEnter(node);
84125 }
84126
84127 node.alternatives.forEach(this.visit, this);
84128
84129 if (this._handlers.onPatternLeave) {
84130 this._handlers.onPatternLeave(node);
84131 }
84132 }
84133
84134 visitQuantifier(node) {
84135 if (this._handlers.onQuantifierEnter) {
84136 this._handlers.onQuantifierEnter(node);
84137 }
84138
84139 this.visit(node.element);
84140
84141 if (this._handlers.onQuantifierLeave) {
84142 this._handlers.onQuantifierLeave(node);
84143 }
84144 }
84145
84146 visitRegExpLiteral(node) {
84147 if (this._handlers.onRegExpLiteralEnter) {
84148 this._handlers.onRegExpLiteralEnter(node);
84149 }
84150
84151 this.visitPattern(node.pattern);
84152 this.visitFlags(node.flags);
84153
84154 if (this._handlers.onRegExpLiteralLeave) {
84155 this._handlers.onRegExpLiteralLeave(node);
84156 }
84157 }
84158
84159 }
84160
84161 function parseRegExpLiteral(source, options) {
84162 return new RegExpParser(options).parseLiteral(String(source));
84163 }
84164
84165 function validateRegExpLiteral(source, options) {
84166 return new RegExpValidator(options).validateLiteral(source);
84167 }
84168
84169 function visitRegExpAST(node, handlers) {
84170 new RegExpVisitor(handlers).visit(node);
84171 }
84172
84173 exports.AST = ast;
84174 exports.RegExpParser = RegExpParser;
84175 exports.RegExpValidator = RegExpValidator;
84176 exports.parseRegExpLiteral = parseRegExpLiteral;
84177 exports.validateRegExpLiteral = validateRegExpLiteral;
84178 exports.visitRegExpAST = visitRegExpAST;
84179
84180 /***/ }),
84181 /* 652 */
84182 /***/ ((module) => {
84183
84184 "use strict";
84185 /**
84186 * @fileoverview Rule to flag use of a debugger statement
84187 * @author Nicholas C. Zakas
84188 */
84189 //------------------------------------------------------------------------------
84190 // Rule Definition
84191 //------------------------------------------------------------------------------
84192
84193 module.exports = {
84194 meta: {
84195 type: "problem",
84196 docs: {
84197 description: "disallow the use of `debugger`",
84198 recommended: true,
84199 url: "https://eslint.org/docs/rules/no-debugger"
84200 },
84201 fixable: null,
84202 schema: [],
84203 messages: {
84204 unexpected: "Unexpected 'debugger' statement."
84205 }
84206 },
84207
84208 create(context) {
84209 return {
84210 DebuggerStatement(node) {
84211 context.report({
84212 node,
84213 messageId: "unexpected"
84214 });
84215 }
84216
84217 };
84218 }
84219
84220 };
84221
84222 /***/ }),
84223 /* 653 */
84224 /***/ ((module) => {
84225
84226 "use strict";
84227 /**
84228 * @fileoverview Rule to flag when deleting variables
84229 * @author Ilya Volodin
84230 */
84231 //------------------------------------------------------------------------------
84232 // Rule Definition
84233 //------------------------------------------------------------------------------
84234
84235 module.exports = {
84236 meta: {
84237 type: "suggestion",
84238 docs: {
84239 description: "disallow deleting variables",
84240 recommended: true,
84241 url: "https://eslint.org/docs/rules/no-delete-var"
84242 },
84243 schema: [],
84244 messages: {
84245 unexpected: "Variables should not be deleted."
84246 }
84247 },
84248
84249 create(context) {
84250 return {
84251 UnaryExpression(node) {
84252 if (node.operator === "delete" && node.argument.type === "Identifier") {
84253 context.report({
84254 node,
84255 messageId: "unexpected"
84256 });
84257 }
84258 }
84259
84260 };
84261 }
84262
84263 };
84264
84265 /***/ }),
84266 /* 654 */
84267 /***/ ((module) => {
84268
84269 "use strict";
84270 /**
84271 * @fileoverview Rule to check for ambiguous div operator in regexes
84272 * @author Matt DuVall <http://www.mattduvall.com>
84273 */
84274 //------------------------------------------------------------------------------
84275 // Rule Definition
84276 //------------------------------------------------------------------------------
84277
84278 module.exports = {
84279 meta: {
84280 type: "suggestion",
84281 docs: {
84282 description: "disallow division operators explicitly at the beginning of regular expressions",
84283 recommended: false,
84284 url: "https://eslint.org/docs/rules/no-div-regex"
84285 },
84286 fixable: "code",
84287 schema: [],
84288 messages: {
84289 unexpected: "A regular expression literal can be confused with '/='."
84290 }
84291 },
84292
84293 create(context) {
84294 const sourceCode = context.getSourceCode();
84295 return {
84296 Literal(node) {
84297 const token = sourceCode.getFirstToken(node);
84298
84299 if (token.type === "RegularExpression" && token.value[1] === "=") {
84300 context.report({
84301 node,
84302 messageId: "unexpected",
84303
84304 fix(fixer) {
84305 return fixer.replaceTextRange([token.range[0] + 1, token.range[0] + 2], "[=]");
84306 }
84307
84308 });
84309 }
84310 }
84311
84312 };
84313 }
84314
84315 };
84316
84317 /***/ }),
84318 /* 655 */
84319 /***/ ((module) => {
84320
84321 "use strict";
84322 /**
84323 * @fileoverview Rule to flag duplicate arguments
84324 * @author Jamund Ferguson
84325 */
84326 //------------------------------------------------------------------------------
84327 // Rule Definition
84328 //------------------------------------------------------------------------------
84329
84330 module.exports = {
84331 meta: {
84332 type: "problem",
84333 docs: {
84334 description: "disallow duplicate arguments in `function` definitions",
84335 recommended: true,
84336 url: "https://eslint.org/docs/rules/no-dupe-args"
84337 },
84338 schema: [],
84339 messages: {
84340 unexpected: "Duplicate param '{{name}}'."
84341 }
84342 },
84343
84344 create(context) {
84345 //--------------------------------------------------------------------------
84346 // Helpers
84347 //--------------------------------------------------------------------------
84348
84349 /**
84350 * Checks whether or not a given definition is a parameter's.
84351 * @param {eslint-scope.DefEntry} def A definition to check.
84352 * @returns {boolean} `true` if the definition is a parameter's.
84353 */
84354 function isParameter(def) {
84355 return def.type === "Parameter";
84356 }
84357 /**
84358 * Determines if a given node has duplicate parameters.
84359 * @param {ASTNode} node The node to check.
84360 * @returns {void}
84361 * @private
84362 */
84363
84364
84365 function checkParams(node) {
84366 const variables = context.getDeclaredVariables(node);
84367
84368 for (let i = 0; i < variables.length; ++i) {
84369 const variable = variables[i]; // Checks and reports duplications.
84370
84371 const defs = variable.defs.filter(isParameter);
84372
84373 if (defs.length >= 2) {
84374 context.report({
84375 node,
84376 messageId: "unexpected",
84377 data: {
84378 name: variable.name
84379 }
84380 });
84381 }
84382 }
84383 } //--------------------------------------------------------------------------
84384 // Public API
84385 //--------------------------------------------------------------------------
84386
84387
84388 return {
84389 FunctionDeclaration: checkParams,
84390 FunctionExpression: checkParams
84391 };
84392 }
84393
84394 };
84395
84396 /***/ }),
84397 /* 656 */
84398 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
84399
84400 "use strict";
84401 /**
84402 * @fileoverview A rule to disallow duplicate name in class members.
84403 * @author Toru Nagashima
84404 */
84405
84406
84407 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
84408 // Rule Definition
84409 //------------------------------------------------------------------------------
84410
84411
84412 module.exports = {
84413 meta: {
84414 type: "problem",
84415 docs: {
84416 description: "disallow duplicate class members",
84417 recommended: true,
84418 url: "https://eslint.org/docs/rules/no-dupe-class-members"
84419 },
84420 schema: [],
84421 messages: {
84422 unexpected: "Duplicate name '{{name}}'."
84423 }
84424 },
84425
84426 create(context) {
84427 let stack = [];
84428 /**
84429 * Gets state of a given member name.
84430 * @param {string} name A name of a member.
84431 * @param {boolean} isStatic A flag which specifies that is a static member.
84432 * @returns {Object} A state of a given member name.
84433 * - retv.init {boolean} A flag which shows the name is declared as normal member.
84434 * - retv.get {boolean} A flag which shows the name is declared as getter.
84435 * - retv.set {boolean} A flag which shows the name is declared as setter.
84436 */
84437
84438 function getState(name, isStatic) {
84439 const stateMap = stack[stack.length - 1];
84440 const key = "$".concat(name); // to avoid "__proto__".
84441
84442 if (!stateMap[key]) {
84443 stateMap[key] = {
84444 nonStatic: {
84445 init: false,
84446 get: false,
84447 set: false
84448 },
84449 static: {
84450 init: false,
84451 get: false,
84452 set: false
84453 }
84454 };
84455 }
84456
84457 return stateMap[key][isStatic ? "static" : "nonStatic"];
84458 }
84459
84460 return {
84461 // Initializes the stack of state of member declarations.
84462 Program() {
84463 stack = [];
84464 },
84465
84466 // Initializes state of member declarations for the class.
84467 ClassBody() {
84468 stack.push(Object.create(null));
84469 },
84470
84471 // Disposes the state for the class.
84472 "ClassBody:exit"() {
84473 stack.pop();
84474 },
84475
84476 // Reports the node if its name has been declared already.
84477 "MethodDefinition, PropertyDefinition"(node) {
84478 const name = astUtils.getStaticPropertyName(node);
84479 const kind = node.type === "MethodDefinition" ? node.kind : "field";
84480
84481 if (name === null || kind === "constructor") {
84482 return;
84483 }
84484
84485 const state = getState(name, node.static);
84486 let isDuplicate = false;
84487
84488 if (kind === "get") {
84489 isDuplicate = state.init || state.get;
84490 state.get = true;
84491 } else if (kind === "set") {
84492 isDuplicate = state.init || state.set;
84493 state.set = true;
84494 } else {
84495 isDuplicate = state.init || state.get || state.set;
84496 state.init = true;
84497 }
84498
84499 if (isDuplicate) {
84500 context.report({
84501 node,
84502 messageId: "unexpected",
84503 data: {
84504 name
84505 }
84506 });
84507 }
84508 }
84509
84510 };
84511 }
84512
84513 };
84514
84515 /***/ }),
84516 /* 657 */
84517 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
84518
84519 "use strict";
84520 /**
84521 * @fileoverview Rule to disallow duplicate conditions in if-else-if chains
84522 * @author Milos Djermanovic
84523 */
84524 //------------------------------------------------------------------------------
84525 // Requirements
84526 //------------------------------------------------------------------------------
84527
84528 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
84529 // Helpers
84530 //------------------------------------------------------------------------------
84531
84532 /**
84533 * Determines whether the first given array is a subset of the second given array.
84534 * @param {Function} comparator A function to compare two elements, should return `true` if they are equal.
84535 * @param {Array} arrA The array to compare from.
84536 * @param {Array} arrB The array to compare against.
84537 * @returns {boolean} `true` if the array `arrA` is a subset of the array `arrB`.
84538 */
84539
84540
84541 function isSubsetByComparator(comparator, arrA, arrB) {
84542 return arrA.every(a => arrB.some(b => comparator(a, b)));
84543 }
84544 /**
84545 * Splits the given node by the given logical operator.
84546 * @param {string} operator Logical operator `||` or `&&`.
84547 * @param {ASTNode} node The node to split.
84548 * @returns {ASTNode[]} Array of conditions that makes the node when joined by the operator.
84549 */
84550
84551
84552 function splitByLogicalOperator(operator, node) {
84553 if (node.type === "LogicalExpression" && node.operator === operator) {
84554 return [...splitByLogicalOperator(operator, node.left), ...splitByLogicalOperator(operator, node.right)];
84555 }
84556
84557 return [node];
84558 }
84559
84560 const splitByOr = splitByLogicalOperator.bind(null, "||");
84561 const splitByAnd = splitByLogicalOperator.bind(null, "&&"); //------------------------------------------------------------------------------
84562 // Rule Definition
84563 //------------------------------------------------------------------------------
84564
84565 module.exports = {
84566 meta: {
84567 type: "problem",
84568 docs: {
84569 description: "disallow duplicate conditions in if-else-if chains",
84570 recommended: true,
84571 url: "https://eslint.org/docs/rules/no-dupe-else-if"
84572 },
84573 schema: [],
84574 messages: {
84575 unexpected: "This branch can never execute. Its condition is a duplicate or covered by previous conditions in the if-else-if chain."
84576 }
84577 },
84578
84579 create(context) {
84580 const sourceCode = context.getSourceCode();
84581 /**
84582 * Determines whether the two given nodes are considered to be equal. In particular, given that the nodes
84583 * represent expressions in a boolean context, `||` and `&&` can be considered as commutative operators.
84584 * @param {ASTNode} a First node.
84585 * @param {ASTNode} b Second node.
84586 * @returns {boolean} `true` if the nodes are considered to be equal.
84587 */
84588
84589 function equal(a, b) {
84590 if (a.type !== b.type) {
84591 return false;
84592 }
84593
84594 if (a.type === "LogicalExpression" && (a.operator === "||" || a.operator === "&&") && a.operator === b.operator) {
84595 return equal(a.left, b.left) && equal(a.right, b.right) || equal(a.left, b.right) && equal(a.right, b.left);
84596 }
84597
84598 return astUtils.equalTokens(a, b, sourceCode);
84599 }
84600
84601 const isSubset = isSubsetByComparator.bind(null, equal);
84602 return {
84603 IfStatement(node) {
84604 const test = node.test,
84605 conditionsToCheck = test.type === "LogicalExpression" && test.operator === "&&" ? [test, ...splitByAnd(test)] : [test];
84606 let current = node,
84607 listToCheck = conditionsToCheck.map(c => splitByOr(c).map(splitByAnd));
84608
84609 while (current.parent && current.parent.type === "IfStatement" && current.parent.alternate === current) {
84610 current = current.parent;
84611 const currentOrOperands = splitByOr(current.test).map(splitByAnd);
84612 listToCheck = listToCheck.map(orOperands => orOperands.filter(orOperand => !currentOrOperands.some(currentOrOperand => isSubset(currentOrOperand, orOperand))));
84613
84614 if (listToCheck.some(orOperands => orOperands.length === 0)) {
84615 context.report({
84616 node: test,
84617 messageId: "unexpected"
84618 });
84619 break;
84620 }
84621 }
84622 }
84623
84624 };
84625 }
84626
84627 };
84628
84629 /***/ }),
84630 /* 658 */
84631 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
84632
84633 "use strict";
84634 /**
84635 * @fileoverview Rule to flag use of duplicate keys in an object.
84636 * @author Ian Christian Myers
84637 */
84638 //------------------------------------------------------------------------------
84639 // Requirements
84640 //------------------------------------------------------------------------------
84641
84642 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
84643 // Helpers
84644 //------------------------------------------------------------------------------
84645
84646
84647 const GET_KIND = /^(?:init|get)$/u;
84648 const SET_KIND = /^(?:init|set)$/u;
84649 /**
84650 * The class which stores properties' information of an object.
84651 */
84652
84653 class ObjectInfo {
84654 /**
84655 * @param {ObjectInfo|null} upper The information of the outer object.
84656 * @param {ASTNode} node The ObjectExpression node of this information.
84657 */
84658 constructor(upper, node) {
84659 this.upper = upper;
84660 this.node = node;
84661 this.properties = new Map();
84662 }
84663 /**
84664 * Gets the information of the given Property node.
84665 * @param {ASTNode} node The Property node to get.
84666 * @returns {{get: boolean, set: boolean}} The information of the property.
84667 */
84668
84669
84670 getPropertyInfo(node) {
84671 const name = astUtils.getStaticPropertyName(node);
84672
84673 if (!this.properties.has(name)) {
84674 this.properties.set(name, {
84675 get: false,
84676 set: false
84677 });
84678 }
84679
84680 return this.properties.get(name);
84681 }
84682 /**
84683 * Checks whether the given property has been defined already or not.
84684 * @param {ASTNode} node The Property node to check.
84685 * @returns {boolean} `true` if the property has been defined.
84686 */
84687
84688
84689 isPropertyDefined(node) {
84690 const entry = this.getPropertyInfo(node);
84691 return GET_KIND.test(node.kind) && entry.get || SET_KIND.test(node.kind) && entry.set;
84692 }
84693 /**
84694 * Defines the given property.
84695 * @param {ASTNode} node The Property node to define.
84696 * @returns {void}
84697 */
84698
84699
84700 defineProperty(node) {
84701 const entry = this.getPropertyInfo(node);
84702
84703 if (GET_KIND.test(node.kind)) {
84704 entry.get = true;
84705 }
84706
84707 if (SET_KIND.test(node.kind)) {
84708 entry.set = true;
84709 }
84710 }
84711
84712 } //------------------------------------------------------------------------------
84713 // Rule Definition
84714 //------------------------------------------------------------------------------
84715
84716
84717 module.exports = {
84718 meta: {
84719 type: "problem",
84720 docs: {
84721 description: "disallow duplicate keys in object literals",
84722 recommended: true,
84723 url: "https://eslint.org/docs/rules/no-dupe-keys"
84724 },
84725 schema: [],
84726 messages: {
84727 unexpected: "Duplicate key '{{name}}'."
84728 }
84729 },
84730
84731 create(context) {
84732 let info = null;
84733 return {
84734 ObjectExpression(node) {
84735 info = new ObjectInfo(info, node);
84736 },
84737
84738 "ObjectExpression:exit"() {
84739 info = info.upper;
84740 },
84741
84742 Property(node) {
84743 const name = astUtils.getStaticPropertyName(node); // Skip destructuring.
84744
84745 if (node.parent.type !== "ObjectExpression") {
84746 return;
84747 } // Skip if the name is not static.
84748
84749
84750 if (name === null) {
84751 return;
84752 } // Reports if the name is defined already.
84753
84754
84755 if (info.isPropertyDefined(node)) {
84756 context.report({
84757 node: info.node,
84758 loc: node.key.loc,
84759 messageId: "unexpected",
84760 data: {
84761 name
84762 }
84763 });
84764 } // Update info.
84765
84766
84767 info.defineProperty(node);
84768 }
84769
84770 };
84771 }
84772
84773 };
84774
84775 /***/ }),
84776 /* 659 */
84777 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
84778
84779 "use strict";
84780 /**
84781 * @fileoverview Rule to disallow a duplicate case label.
84782 * @author Dieter Oberkofler
84783 * @author Burak Yigit Kaya
84784 */
84785 //------------------------------------------------------------------------------
84786 // Requirements
84787 //------------------------------------------------------------------------------
84788
84789 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
84790 // Rule Definition
84791 //------------------------------------------------------------------------------
84792
84793
84794 module.exports = {
84795 meta: {
84796 type: "problem",
84797 docs: {
84798 description: "disallow duplicate case labels",
84799 recommended: true,
84800 url: "https://eslint.org/docs/rules/no-duplicate-case"
84801 },
84802 schema: [],
84803 messages: {
84804 unexpected: "Duplicate case label."
84805 }
84806 },
84807
84808 create(context) {
84809 const sourceCode = context.getSourceCode();
84810 /**
84811 * Determines whether the two given nodes are considered to be equal.
84812 * @param {ASTNode} a First node.
84813 * @param {ASTNode} b Second node.
84814 * @returns {boolean} `true` if the nodes are considered to be equal.
84815 */
84816
84817 function equal(a, b) {
84818 if (a.type !== b.type) {
84819 return false;
84820 }
84821
84822 return astUtils.equalTokens(a, b, sourceCode);
84823 }
84824
84825 return {
84826 SwitchStatement(node) {
84827 const previousTests = [];
84828
84829 for (const switchCase of node.cases) {
84830 if (switchCase.test) {
84831 const test = switchCase.test;
84832
84833 if (previousTests.some(previousTest => equal(previousTest, test))) {
84834 context.report({
84835 node: switchCase,
84836 messageId: "unexpected"
84837 });
84838 } else {
84839 previousTests.push(test);
84840 }
84841 }
84842 }
84843 }
84844
84845 };
84846 }
84847
84848 };
84849
84850 /***/ }),
84851 /* 660 */
84852 /***/ ((module) => {
84853
84854 "use strict";
84855 /**
84856 * @fileoverview Restrict usage of duplicate imports.
84857 * @author Simen Bekkhus
84858 */
84859 //------------------------------------------------------------------------------
84860 // Helpers
84861 //------------------------------------------------------------------------------
84862
84863 const NAMED_TYPES = ["ImportSpecifier", "ExportSpecifier"];
84864 const NAMESPACE_TYPES = ["ImportNamespaceSpecifier", "ExportNamespaceSpecifier"]; //------------------------------------------------------------------------------
84865 // Rule Definition
84866 //------------------------------------------------------------------------------
84867
84868 /**
84869 * Check if an import/export type belongs to (ImportSpecifier|ExportSpecifier) or (ImportNamespaceSpecifier|ExportNamespaceSpecifier).
84870 * @param {string} importExportType An import/export type to check.
84871 * @param {string} type Can be "named" or "namespace"
84872 * @returns {boolean} True if import/export type belongs to (ImportSpecifier|ExportSpecifier) or (ImportNamespaceSpecifier|ExportNamespaceSpecifier) and false if it doesn't.
84873 */
84874
84875 function isImportExportSpecifier(importExportType, type) {
84876 const arrayToCheck = type === "named" ? NAMED_TYPES : NAMESPACE_TYPES;
84877 return arrayToCheck.includes(importExportType);
84878 }
84879 /**
84880 * Return the type of (import|export).
84881 * @param {ASTNode} node A node to get.
84882 * @returns {string} The type of the (import|export).
84883 */
84884
84885
84886 function getImportExportType(node) {
84887 if (node.specifiers && node.specifiers.length > 0) {
84888 const nodeSpecifiers = node.specifiers;
84889 const index = nodeSpecifiers.findIndex(_ref => {
84890 let {
84891 type
84892 } = _ref;
84893 return isImportExportSpecifier(type, "named") || isImportExportSpecifier(type, "namespace");
84894 });
84895 const i = index > -1 ? index : 0;
84896 return nodeSpecifiers[i].type;
84897 }
84898
84899 if (node.type === "ExportAllDeclaration") {
84900 if (node.exported) {
84901 return "ExportNamespaceSpecifier";
84902 }
84903
84904 return "ExportAll";
84905 }
84906
84907 return "SideEffectImport";
84908 }
84909 /**
84910 * Returns a boolean indicates if two (import|export) can be merged
84911 * @param {ASTNode} node1 A node to check.
84912 * @param {ASTNode} node2 A node to check.
84913 * @returns {boolean} True if two (import|export) can be merged, false if they can't.
84914 */
84915
84916
84917 function isImportExportCanBeMerged(node1, node2) {
84918 const importExportType1 = getImportExportType(node1);
84919 const importExportType2 = getImportExportType(node2);
84920
84921 if (importExportType1 === "ExportAll" && importExportType2 !== "ExportAll" && importExportType2 !== "SideEffectImport" || importExportType1 !== "ExportAll" && importExportType1 !== "SideEffectImport" && importExportType2 === "ExportAll") {
84922 return false;
84923 }
84924
84925 if (isImportExportSpecifier(importExportType1, "namespace") && isImportExportSpecifier(importExportType2, "named") || isImportExportSpecifier(importExportType2, "namespace") && isImportExportSpecifier(importExportType1, "named")) {
84926 return false;
84927 }
84928
84929 return true;
84930 }
84931 /**
84932 * Returns a boolean if we should report (import|export).
84933 * @param {ASTNode} node A node to be reported or not.
84934 * @param {[ASTNode]} previousNodes An array contains previous nodes of the module imported or exported.
84935 * @returns {boolean} True if the (import|export) should be reported.
84936 */
84937
84938
84939 function shouldReportImportExport(node, previousNodes) {
84940 let i = 0;
84941
84942 while (i < previousNodes.length) {
84943 if (isImportExportCanBeMerged(node, previousNodes[i])) {
84944 return true;
84945 }
84946
84947 i++;
84948 }
84949
84950 return false;
84951 }
84952 /**
84953 * Returns array contains only nodes with declarations types equal to type.
84954 * @param {[{node: ASTNode, declarationType: string}]} nodes An array contains objects, each object contains a node and a declaration type.
84955 * @param {string} type Declaration type.
84956 * @returns {[ASTNode]} An array contains only nodes with declarations types equal to type.
84957 */
84958
84959
84960 function getNodesByDeclarationType(nodes, type) {
84961 return nodes.filter(_ref2 => {
84962 let {
84963 declarationType
84964 } = _ref2;
84965 return declarationType === type;
84966 }).map(_ref3 => {
84967 let {
84968 node
84969 } = _ref3;
84970 return node;
84971 });
84972 }
84973 /**
84974 * Returns the name of the module imported or re-exported.
84975 * @param {ASTNode} node A node to get.
84976 * @returns {string} The name of the module, or empty string if no name.
84977 */
84978
84979
84980 function getModule(node) {
84981 if (node && node.source && node.source.value) {
84982 return node.source.value.trim();
84983 }
84984
84985 return "";
84986 }
84987 /**
84988 * Checks if the (import|export) can be merged with at least one import or one export, and reports if so.
84989 * @param {RuleContext} context The ESLint rule context object.
84990 * @param {ASTNode} node A node to get.
84991 * @param {Map} modules A Map object contains as a key a module name and as value an array contains objects, each object contains a node and a declaration type.
84992 * @param {string} declarationType A declaration type can be an import or export.
84993 * @param {boolean} includeExports Whether or not to check for exports in addition to imports.
84994 * @returns {void} No return value.
84995 */
84996
84997
84998 function checkAndReport(context, node, modules, declarationType, includeExports) {
84999 const module = getModule(node);
85000
85001 if (modules.has(module)) {
85002 const previousNodes = modules.get(module);
85003 const messagesIds = [];
85004 const importNodes = getNodesByDeclarationType(previousNodes, "import");
85005 let exportNodes;
85006
85007 if (includeExports) {
85008 exportNodes = getNodesByDeclarationType(previousNodes, "export");
85009 }
85010
85011 if (declarationType === "import") {
85012 if (shouldReportImportExport(node, importNodes)) {
85013 messagesIds.push("import");
85014 }
85015
85016 if (includeExports) {
85017 if (shouldReportImportExport(node, exportNodes)) {
85018 messagesIds.push("importAs");
85019 }
85020 }
85021 } else if (declarationType === "export") {
85022 if (shouldReportImportExport(node, exportNodes)) {
85023 messagesIds.push("export");
85024 }
85025
85026 if (shouldReportImportExport(node, importNodes)) {
85027 messagesIds.push("exportAs");
85028 }
85029 }
85030
85031 messagesIds.forEach(messageId => context.report({
85032 node,
85033 messageId,
85034 data: {
85035 module
85036 }
85037 }));
85038 }
85039 }
85040 /**
85041 * @callback nodeCallback
85042 * @param {ASTNode} node A node to handle.
85043 */
85044
85045 /**
85046 * Returns a function handling the (imports|exports) of a given file
85047 * @param {RuleContext} context The ESLint rule context object.
85048 * @param {Map} modules A Map object contains as a key a module name and as value an array contains objects, each object contains a node and a declaration type.
85049 * @param {string} declarationType A declaration type can be an import or export.
85050 * @param {boolean} includeExports Whether or not to check for exports in addition to imports.
85051 * @returns {nodeCallback} A function passed to ESLint to handle the statement.
85052 */
85053
85054
85055 function handleImportsExports(context, modules, declarationType, includeExports) {
85056 return function (node) {
85057 const module = getModule(node);
85058
85059 if (module) {
85060 checkAndReport(context, node, modules, declarationType, includeExports);
85061 const currentNode = {
85062 node,
85063 declarationType
85064 };
85065 let nodes = [currentNode];
85066
85067 if (modules.has(module)) {
85068 const previousNodes = modules.get(module);
85069 nodes = [...previousNodes, currentNode];
85070 }
85071
85072 modules.set(module, nodes);
85073 }
85074 };
85075 }
85076
85077 module.exports = {
85078 meta: {
85079 type: "problem",
85080 docs: {
85081 description: "disallow duplicate module imports",
85082 recommended: false,
85083 url: "https://eslint.org/docs/rules/no-duplicate-imports"
85084 },
85085 schema: [{
85086 type: "object",
85087 properties: {
85088 includeExports: {
85089 type: "boolean",
85090 default: false
85091 }
85092 },
85093 additionalProperties: false
85094 }],
85095 messages: {
85096 import: "'{{module}}' import is duplicated.",
85097 importAs: "'{{module}}' import is duplicated as export.",
85098 export: "'{{module}}' export is duplicated.",
85099 exportAs: "'{{module}}' export is duplicated as import."
85100 }
85101 },
85102
85103 create(context) {
85104 const includeExports = (context.options[0] || {}).includeExports,
85105 modules = new Map();
85106 const handlers = {
85107 ImportDeclaration: handleImportsExports(context, modules, "import", includeExports)
85108 };
85109
85110 if (includeExports) {
85111 handlers.ExportNamedDeclaration = handleImportsExports(context, modules, "export", includeExports);
85112 handlers.ExportAllDeclaration = handleImportsExports(context, modules, "export", includeExports);
85113 }
85114
85115 return handlers;
85116 }
85117
85118 };
85119
85120 /***/ }),
85121 /* 661 */
85122 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
85123
85124 "use strict";
85125 /**
85126 * @fileoverview Rule to flag `else` after a `return` in `if`
85127 * @author Ian Christian Myers
85128 */
85129 //------------------------------------------------------------------------------
85130 // Requirements
85131 //------------------------------------------------------------------------------
85132
85133 const astUtils = __webpack_require__(548);
85134
85135 const FixTracker = __webpack_require__(662); //------------------------------------------------------------------------------
85136 // Rule Definition
85137 //------------------------------------------------------------------------------
85138
85139
85140 module.exports = {
85141 meta: {
85142 type: "suggestion",
85143 docs: {
85144 description: "disallow `else` blocks after `return` statements in `if` statements",
85145 recommended: false,
85146 url: "https://eslint.org/docs/rules/no-else-return"
85147 },
85148 schema: [{
85149 type: "object",
85150 properties: {
85151 allowElseIf: {
85152 type: "boolean",
85153 default: true
85154 }
85155 },
85156 additionalProperties: false
85157 }],
85158 fixable: "code",
85159 messages: {
85160 unexpected: "Unnecessary 'else' after 'return'."
85161 }
85162 },
85163
85164 create(context) {
85165 //--------------------------------------------------------------------------
85166 // Helpers
85167 //--------------------------------------------------------------------------
85168
85169 /**
85170 * Checks whether the given names can be safely used to declare block-scoped variables
85171 * in the given scope. Name collisions can produce redeclaration syntax errors,
85172 * or silently change references and modify behavior of the original code.
85173 *
85174 * This is not a generic function. In particular, it is assumed that the scope is a function scope or
85175 * a function's inner scope, and that the names can be valid identifiers in the given scope.
85176 * @param {string[]} names Array of variable names.
85177 * @param {eslint-scope.Scope} scope Function scope or a function's inner scope.
85178 * @returns {boolean} True if all names can be safely declared, false otherwise.
85179 */
85180 function isSafeToDeclare(names, scope) {
85181 if (names.length === 0) {
85182 return true;
85183 }
85184
85185 const functionScope = scope.variableScope;
85186 /*
85187 * If this is a function scope, scope.variables will contain parameters, implicit variables such as "arguments",
85188 * all function-scoped variables ('var'), and block-scoped variables defined in the scope.
85189 * If this is an inner scope, scope.variables will contain block-scoped variables defined in the scope.
85190 *
85191 * Redeclaring any of these would cause a syntax error, except for the implicit variables.
85192 */
85193
85194 const declaredVariables = scope.variables.filter(_ref => {
85195 let {
85196 defs
85197 } = _ref;
85198 return defs.length > 0;
85199 });
85200
85201 if (declaredVariables.some(_ref2 => {
85202 let {
85203 name
85204 } = _ref2;
85205 return names.includes(name);
85206 })) {
85207 return false;
85208 } // Redeclaring a catch variable would also cause a syntax error.
85209
85210
85211 if (scope !== functionScope && scope.upper.type === "catch") {
85212 if (scope.upper.variables.some(_ref3 => {
85213 let {
85214 name
85215 } = _ref3;
85216 return names.includes(name);
85217 })) {
85218 return false;
85219 }
85220 }
85221 /*
85222 * Redeclaring an implicit variable, such as "arguments", would not cause a syntax error.
85223 * However, if the variable was used, declaring a new one with the same name would change references
85224 * and modify behavior.
85225 */
85226
85227
85228 const usedImplicitVariables = scope.variables.filter(_ref4 => {
85229 let {
85230 defs,
85231 references
85232 } = _ref4;
85233 return defs.length === 0 && references.length > 0;
85234 });
85235
85236 if (usedImplicitVariables.some(_ref5 => {
85237 let {
85238 name
85239 } = _ref5;
85240 return names.includes(name);
85241 })) {
85242 return false;
85243 }
85244 /*
85245 * Declaring a variable with a name that was already used to reference a variable from an upper scope
85246 * would change references and modify behavior.
85247 */
85248
85249
85250 if (scope.through.some(t => names.includes(t.identifier.name))) {
85251 return false;
85252 }
85253 /*
85254 * If the scope is an inner scope (not the function scope), an uninitialized `var` variable declared inside
85255 * the scope node (directly or in one of its descendants) is neither declared nor 'through' in the scope.
85256 *
85257 * For example, this would be a syntax error "Identifier 'a' has already been declared":
85258 * function foo() { if (bar) { let a; if (baz) { var a; } } }
85259 */
85260
85261
85262 if (scope !== functionScope) {
85263 const scopeNodeRange = scope.block.range;
85264 const variablesToCheck = functionScope.variables.filter(_ref6 => {
85265 let {
85266 name
85267 } = _ref6;
85268 return names.includes(name);
85269 });
85270
85271 if (variablesToCheck.some(v => v.defs.some(_ref7 => {
85272 let {
85273 node: {
85274 range
85275 }
85276 } = _ref7;
85277 return scopeNodeRange[0] <= range[0] && range[1] <= scopeNodeRange[1];
85278 }))) {
85279 return false;
85280 }
85281 }
85282
85283 return true;
85284 }
85285 /**
85286 * Checks whether the removal of `else` and its braces is safe from variable name collisions.
85287 * @param {Node} node The 'else' node.
85288 * @param {eslint-scope.Scope} scope The scope in which the node and the whole 'if' statement is.
85289 * @returns {boolean} True if it is safe, false otherwise.
85290 */
85291
85292
85293 function isSafeFromNameCollisions(node, scope) {
85294 if (node.type === "FunctionDeclaration") {
85295 // Conditional function declaration. Scope and hoisting are unpredictable, different engines work differently.
85296 return false;
85297 }
85298
85299 if (node.type !== "BlockStatement") {
85300 return true;
85301 }
85302
85303 const elseBlockScope = scope.childScopes.find(_ref8 => {
85304 let {
85305 block
85306 } = _ref8;
85307 return block === node;
85308 });
85309
85310 if (!elseBlockScope) {
85311 // ecmaVersion < 6, `else` block statement cannot have its own scope, no possible collisions.
85312 return true;
85313 }
85314 /*
85315 * elseBlockScope is supposed to merge into its upper scope. elseBlockScope.variables array contains
85316 * only block-scoped variables (such as let and const variables or class and function declarations)
85317 * defined directly in the elseBlockScope. These are exactly the only names that could cause collisions.
85318 */
85319
85320
85321 const namesToCheck = elseBlockScope.variables.map(_ref9 => {
85322 let {
85323 name
85324 } = _ref9;
85325 return name;
85326 });
85327 return isSafeToDeclare(namesToCheck, scope);
85328 }
85329 /**
85330 * Display the context report if rule is violated
85331 * @param {Node} node The 'else' node
85332 * @returns {void}
85333 */
85334
85335
85336 function displayReport(node) {
85337 const currentScope = context.getScope();
85338 context.report({
85339 node,
85340 messageId: "unexpected",
85341 fix: fixer => {
85342 if (!isSafeFromNameCollisions(node, currentScope)) {
85343 return null;
85344 }
85345
85346 const sourceCode = context.getSourceCode();
85347 const startToken = sourceCode.getFirstToken(node);
85348 const elseToken = sourceCode.getTokenBefore(startToken);
85349 const source = sourceCode.getText(node);
85350 const lastIfToken = sourceCode.getTokenBefore(elseToken);
85351 let fixedSource, firstTokenOfElseBlock;
85352
85353 if (startToken.type === "Punctuator" && startToken.value === "{") {
85354 firstTokenOfElseBlock = sourceCode.getTokenAfter(startToken);
85355 } else {
85356 firstTokenOfElseBlock = startToken;
85357 }
85358 /*
85359 * If the if block does not have curly braces and does not end in a semicolon
85360 * and the else block starts with (, [, /, +, ` or -, then it is not
85361 * safe to remove the else keyword, because ASI will not add a semicolon
85362 * after the if block
85363 */
85364
85365
85366 const ifBlockMaybeUnsafe = node.parent.consequent.type !== "BlockStatement" && lastIfToken.value !== ";";
85367 const elseBlockUnsafe = /^[([/+`-]/u.test(firstTokenOfElseBlock.value);
85368
85369 if (ifBlockMaybeUnsafe && elseBlockUnsafe) {
85370 return null;
85371 }
85372
85373 const endToken = sourceCode.getLastToken(node);
85374 const lastTokenOfElseBlock = sourceCode.getTokenBefore(endToken);
85375
85376 if (lastTokenOfElseBlock.value !== ";") {
85377 const nextToken = sourceCode.getTokenAfter(endToken);
85378 const nextTokenUnsafe = nextToken && /^[([/+`-]/u.test(nextToken.value);
85379 const nextTokenOnSameLine = nextToken && nextToken.loc.start.line === lastTokenOfElseBlock.loc.start.line;
85380 /*
85381 * If the else block contents does not end in a semicolon,
85382 * and the else block starts with (, [, /, +, ` or -, then it is not
85383 * safe to remove the else block, because ASI will not add a semicolon
85384 * after the remaining else block contents
85385 */
85386
85387 if (nextTokenUnsafe || nextTokenOnSameLine && nextToken.value !== "}") {
85388 return null;
85389 }
85390 }
85391
85392 if (startToken.type === "Punctuator" && startToken.value === "{") {
85393 fixedSource = source.slice(1, -1);
85394 } else {
85395 fixedSource = source;
85396 }
85397 /*
85398 * Extend the replacement range to include the entire
85399 * function to avoid conflicting with no-useless-return.
85400 * https://github.com/eslint/eslint/issues/8026
85401 *
85402 * Also, to avoid name collisions between two else blocks.
85403 */
85404
85405
85406 return new FixTracker(fixer, sourceCode).retainEnclosingFunction(node).replaceTextRange([elseToken.range[0], node.range[1]], fixedSource);
85407 }
85408 });
85409 }
85410 /**
85411 * Check to see if the node is a ReturnStatement
85412 * @param {Node} node The node being evaluated
85413 * @returns {boolean} True if node is a return
85414 */
85415
85416
85417 function checkForReturn(node) {
85418 return node.type === "ReturnStatement";
85419 }
85420 /**
85421 * Naive return checking, does not iterate through the whole
85422 * BlockStatement because we make the assumption that the ReturnStatement
85423 * will be the last node in the body of the BlockStatement.
85424 * @param {Node} node The consequent/alternate node
85425 * @returns {boolean} True if it has a return
85426 */
85427
85428
85429 function naiveHasReturn(node) {
85430 if (node.type === "BlockStatement") {
85431 const body = node.body,
85432 lastChildNode = body[body.length - 1];
85433 return lastChildNode && checkForReturn(lastChildNode);
85434 }
85435
85436 return checkForReturn(node);
85437 }
85438 /**
85439 * Check to see if the node is valid for evaluation,
85440 * meaning it has an else.
85441 * @param {Node} node The node being evaluated
85442 * @returns {boolean} True if the node is valid
85443 */
85444
85445
85446 function hasElse(node) {
85447 return node.alternate && node.consequent;
85448 }
85449 /**
85450 * If the consequent is an IfStatement, check to see if it has an else
85451 * and both its consequent and alternate path return, meaning this is
85452 * a nested case of rule violation. If-Else not considered currently.
85453 * @param {Node} node The consequent node
85454 * @returns {boolean} True if this is a nested rule violation
85455 */
85456
85457
85458 function checkForIf(node) {
85459 return node.type === "IfStatement" && hasElse(node) && naiveHasReturn(node.alternate) && naiveHasReturn(node.consequent);
85460 }
85461 /**
85462 * Check the consequent/body node to make sure it is not
85463 * a ReturnStatement or an IfStatement that returns on both
85464 * code paths.
85465 * @param {Node} node The consequent or body node
85466 * @returns {boolean} `true` if it is a Return/If node that always returns.
85467 */
85468
85469
85470 function checkForReturnOrIf(node) {
85471 return checkForReturn(node) || checkForIf(node);
85472 }
85473 /**
85474 * Check whether a node returns in every codepath.
85475 * @param {Node} node The node to be checked
85476 * @returns {boolean} `true` if it returns on every codepath.
85477 */
85478
85479
85480 function alwaysReturns(node) {
85481 if (node.type === "BlockStatement") {
85482 // If we have a BlockStatement, check each consequent body node.
85483 return node.body.some(checkForReturnOrIf);
85484 }
85485 /*
85486 * If not a block statement, make sure the consequent isn't a
85487 * ReturnStatement or an IfStatement with returns on both paths.
85488 */
85489
85490
85491 return checkForReturnOrIf(node);
85492 }
85493 /**
85494 * Check the if statement, but don't catch else-if blocks.
85495 * @returns {void}
85496 * @param {Node} node The node for the if statement to check
85497 * @private
85498 */
85499
85500
85501 function checkIfWithoutElse(node) {
85502 const parent = node.parent;
85503 /*
85504 * Fixing this would require splitting one statement into two, so no error should
85505 * be reported if this node is in a position where only one statement is allowed.
85506 */
85507
85508 if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) {
85509 return;
85510 }
85511
85512 const consequents = [];
85513 let alternate;
85514
85515 for (let currentNode = node; currentNode.type === "IfStatement"; currentNode = currentNode.alternate) {
85516 if (!currentNode.alternate) {
85517 return;
85518 }
85519
85520 consequents.push(currentNode.consequent);
85521 alternate = currentNode.alternate;
85522 }
85523
85524 if (consequents.every(alwaysReturns)) {
85525 displayReport(alternate);
85526 }
85527 }
85528 /**
85529 * Check the if statement
85530 * @returns {void}
85531 * @param {Node} node The node for the if statement to check
85532 * @private
85533 */
85534
85535
85536 function checkIfWithElse(node) {
85537 const parent = node.parent;
85538 /*
85539 * Fixing this would require splitting one statement into two, so no error should
85540 * be reported if this node is in a position where only one statement is allowed.
85541 */
85542
85543 if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) {
85544 return;
85545 }
85546
85547 const alternate = node.alternate;
85548
85549 if (alternate && alwaysReturns(node.consequent)) {
85550 displayReport(alternate);
85551 }
85552 }
85553
85554 const allowElseIf = !(context.options[0] && context.options[0].allowElseIf === false); //--------------------------------------------------------------------------
85555 // Public API
85556 //--------------------------------------------------------------------------
85557
85558 return {
85559 "IfStatement:exit": allowElseIf ? checkIfWithoutElse : checkIfWithElse
85560 };
85561 }
85562
85563 };
85564
85565 /***/ }),
85566 /* 662 */
85567 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
85568
85569 "use strict";
85570 /**
85571 * @fileoverview Helper class to aid in constructing fix commands.
85572 * @author Alan Pierce
85573 */
85574 //------------------------------------------------------------------------------
85575 // Requirements
85576 //------------------------------------------------------------------------------
85577
85578 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
85579 // Public Interface
85580 //------------------------------------------------------------------------------
85581
85582 /**
85583 * A helper class to combine fix options into a fix command. Currently, it
85584 * exposes some "retain" methods that extend the range of the text being
85585 * replaced so that other fixes won't touch that region in the same pass.
85586 */
85587
85588
85589 class FixTracker {
85590 /**
85591 * Create a new FixTracker.
85592 * @param {ruleFixer} fixer A ruleFixer instance.
85593 * @param {SourceCode} sourceCode A SourceCode object for the current code.
85594 */
85595 constructor(fixer, sourceCode) {
85596 this.fixer = fixer;
85597 this.sourceCode = sourceCode;
85598 this.retainedRange = null;
85599 }
85600 /**
85601 * Mark the given range as "retained", meaning that other fixes may not
85602 * may not modify this region in the same pass.
85603 * @param {int[]} range The range to retain.
85604 * @returns {FixTracker} The same RuleFixer, for chained calls.
85605 */
85606
85607
85608 retainRange(range) {
85609 this.retainedRange = range;
85610 return this;
85611 }
85612 /**
85613 * Given a node, find the function containing it (or the entire program) and
85614 * mark it as retained, meaning that other fixes may not modify it in this
85615 * pass. This is useful for avoiding conflicts in fixes that modify control
85616 * flow.
85617 * @param {ASTNode} node The node to use as a starting point.
85618 * @returns {FixTracker} The same RuleFixer, for chained calls.
85619 */
85620
85621
85622 retainEnclosingFunction(node) {
85623 const functionNode = astUtils.getUpperFunction(node);
85624 return this.retainRange(functionNode ? functionNode.range : this.sourceCode.ast.range);
85625 }
85626 /**
85627 * Given a node or token, find the token before and afterward, and mark that
85628 * range as retained, meaning that other fixes may not modify it in this
85629 * pass. This is useful for avoiding conflicts in fixes that make a small
85630 * change to the code where the AST should not be changed.
85631 * @param {ASTNode|Token} nodeOrToken The node or token to use as a starting
85632 * point. The token to the left and right are use in the range.
85633 * @returns {FixTracker} The same RuleFixer, for chained calls.
85634 */
85635
85636
85637 retainSurroundingTokens(nodeOrToken) {
85638 const tokenBefore = this.sourceCode.getTokenBefore(nodeOrToken) || nodeOrToken;
85639 const tokenAfter = this.sourceCode.getTokenAfter(nodeOrToken) || nodeOrToken;
85640 return this.retainRange([tokenBefore.range[0], tokenAfter.range[1]]);
85641 }
85642 /**
85643 * Create a fix command that replaces the given range with the given text,
85644 * accounting for any retained ranges.
85645 * @param {int[]} range The range to remove in the fix.
85646 * @param {string} text The text to insert in place of the range.
85647 * @returns {Object} The fix command.
85648 */
85649
85650
85651 replaceTextRange(range, text) {
85652 let actualRange;
85653
85654 if (this.retainedRange) {
85655 actualRange = [Math.min(this.retainedRange[0], range[0]), Math.max(this.retainedRange[1], range[1])];
85656 } else {
85657 actualRange = range;
85658 }
85659
85660 return this.fixer.replaceTextRange(actualRange, this.sourceCode.text.slice(actualRange[0], range[0]) + text + this.sourceCode.text.slice(range[1], actualRange[1]));
85661 }
85662 /**
85663 * Create a fix command that removes the given node or token, accounting for
85664 * any retained ranges.
85665 * @param {ASTNode|Token} nodeOrToken The node or token to remove.
85666 * @returns {Object} The fix command.
85667 */
85668
85669
85670 remove(nodeOrToken) {
85671 return this.replaceTextRange(nodeOrToken.range, "");
85672 }
85673
85674 }
85675
85676 module.exports = FixTracker;
85677
85678 /***/ }),
85679 /* 663 */
85680 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
85681
85682 "use strict";
85683 /**
85684 * @fileoverview Rule to flag use of an empty block statement
85685 * @author Nicholas C. Zakas
85686 */
85687 //------------------------------------------------------------------------------
85688 // Requirements
85689 //------------------------------------------------------------------------------
85690
85691 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
85692 // Rule Definition
85693 //------------------------------------------------------------------------------
85694
85695
85696 module.exports = {
85697 meta: {
85698 type: "suggestion",
85699 docs: {
85700 description: "disallow empty block statements",
85701 recommended: true,
85702 url: "https://eslint.org/docs/rules/no-empty"
85703 },
85704 schema: [{
85705 type: "object",
85706 properties: {
85707 allowEmptyCatch: {
85708 type: "boolean",
85709 default: false
85710 }
85711 },
85712 additionalProperties: false
85713 }],
85714 messages: {
85715 unexpected: "Empty {{type}} statement."
85716 }
85717 },
85718
85719 create(context) {
85720 const options = context.options[0] || {},
85721 allowEmptyCatch = options.allowEmptyCatch || false;
85722 const sourceCode = context.getSourceCode();
85723 return {
85724 BlockStatement(node) {
85725 // if the body is not empty, we can just return immediately
85726 if (node.body.length !== 0) {
85727 return;
85728 } // a function is generally allowed to be empty
85729
85730
85731 if (astUtils.isFunction(node.parent)) {
85732 return;
85733 }
85734
85735 if (allowEmptyCatch && node.parent.type === "CatchClause") {
85736 return;
85737 } // any other block is only allowed to be empty, if it contains a comment
85738
85739
85740 if (sourceCode.getCommentsInside(node).length > 0) {
85741 return;
85742 }
85743
85744 context.report({
85745 node,
85746 messageId: "unexpected",
85747 data: {
85748 type: "block"
85749 }
85750 });
85751 },
85752
85753 SwitchStatement(node) {
85754 if (typeof node.cases === "undefined" || node.cases.length === 0) {
85755 context.report({
85756 node,
85757 messageId: "unexpected",
85758 data: {
85759 type: "switch"
85760 }
85761 });
85762 }
85763 }
85764
85765 };
85766 }
85767
85768 };
85769
85770 /***/ }),
85771 /* 664 */
85772 /***/ ((module) => {
85773
85774 "use strict";
85775 /**
85776 * @fileoverview Rule to flag the use of empty character classes in regular expressions
85777 * @author Ian Christian Myers
85778 */
85779 //------------------------------------------------------------------------------
85780 // Helpers
85781 //------------------------------------------------------------------------------
85782
85783 /*
85784 * plain-English description of the following regexp:
85785 * 0. `^` fix the match at the beginning of the string
85786 * 1. `([^\\[]|\\.|\[([^\\\]]|\\.)+\])*`: regexp contents; 0 or more of the following
85787 * 1.0. `[^\\[]`: any character that's not a `\` or a `[` (anything but escape sequences and character classes)
85788 * 1.1. `\\.`: an escape sequence
85789 * 1.2. `\[([^\\\]]|\\.)+\]`: a character class that isn't empty
85790 * 2. `$`: fix the match at the end of the string
85791 */
85792
85793 const regex = /^([^\\[]|\\.|\[([^\\\]]|\\.)+\])*$/u; //------------------------------------------------------------------------------
85794 // Rule Definition
85795 //------------------------------------------------------------------------------
85796
85797 module.exports = {
85798 meta: {
85799 type: "problem",
85800 docs: {
85801 description: "disallow empty character classes in regular expressions",
85802 recommended: true,
85803 url: "https://eslint.org/docs/rules/no-empty-character-class"
85804 },
85805 schema: [],
85806 messages: {
85807 unexpected: "Empty class."
85808 }
85809 },
85810
85811 create(context) {
85812 return {
85813 "Literal[regex]"(node) {
85814 if (!regex.test(node.regex.pattern)) {
85815 context.report({
85816 node,
85817 messageId: "unexpected"
85818 });
85819 }
85820 }
85821
85822 };
85823 }
85824
85825 };
85826
85827 /***/ }),
85828 /* 665 */
85829 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
85830
85831 "use strict";
85832 /**
85833 * @fileoverview Rule to disallow empty functions.
85834 * @author Toru Nagashima
85835 */
85836 //------------------------------------------------------------------------------
85837 // Requirements
85838 //------------------------------------------------------------------------------
85839
85840 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
85841 // Helpers
85842 //------------------------------------------------------------------------------
85843
85844
85845 const ALLOW_OPTIONS = Object.freeze(["functions", "arrowFunctions", "generatorFunctions", "methods", "generatorMethods", "getters", "setters", "constructors", "asyncFunctions", "asyncMethods"]);
85846 /**
85847 * Gets the kind of a given function node.
85848 * @param {ASTNode} node A function node to get. This is one of
85849 * an ArrowFunctionExpression, a FunctionDeclaration, or a
85850 * FunctionExpression.
85851 * @returns {string} The kind of the function. This is one of "functions",
85852 * "arrowFunctions", "generatorFunctions", "asyncFunctions", "methods",
85853 * "generatorMethods", "asyncMethods", "getters", "setters", and
85854 * "constructors".
85855 */
85856
85857 function getKind(node) {
85858 const parent = node.parent;
85859 let kind = "";
85860
85861 if (node.type === "ArrowFunctionExpression") {
85862 return "arrowFunctions";
85863 } // Detects main kind.
85864
85865
85866 if (parent.type === "Property") {
85867 if (parent.kind === "get") {
85868 return "getters";
85869 }
85870
85871 if (parent.kind === "set") {
85872 return "setters";
85873 }
85874
85875 kind = parent.method ? "methods" : "functions";
85876 } else if (parent.type === "MethodDefinition") {
85877 if (parent.kind === "get") {
85878 return "getters";
85879 }
85880
85881 if (parent.kind === "set") {
85882 return "setters";
85883 }
85884
85885 if (parent.kind === "constructor") {
85886 return "constructors";
85887 }
85888
85889 kind = "methods";
85890 } else {
85891 kind = "functions";
85892 } // Detects prefix.
85893
85894
85895 let prefix = "";
85896
85897 if (node.generator) {
85898 prefix = "generator";
85899 } else if (node.async) {
85900 prefix = "async";
85901 } else {
85902 return kind;
85903 }
85904
85905 return prefix + kind[0].toUpperCase() + kind.slice(1);
85906 } //------------------------------------------------------------------------------
85907 // Rule Definition
85908 //------------------------------------------------------------------------------
85909
85910
85911 module.exports = {
85912 meta: {
85913 type: "suggestion",
85914 docs: {
85915 description: "disallow empty functions",
85916 recommended: false,
85917 url: "https://eslint.org/docs/rules/no-empty-function"
85918 },
85919 schema: [{
85920 type: "object",
85921 properties: {
85922 allow: {
85923 type: "array",
85924 items: {
85925 enum: ALLOW_OPTIONS
85926 },
85927 uniqueItems: true
85928 }
85929 },
85930 additionalProperties: false
85931 }],
85932 messages: {
85933 unexpected: "Unexpected empty {{name}}."
85934 }
85935 },
85936
85937 create(context) {
85938 const options = context.options[0] || {};
85939 const allowed = options.allow || [];
85940 const sourceCode = context.getSourceCode();
85941 /**
85942 * Reports a given function node if the node matches the following patterns.
85943 *
85944 * - Not allowed by options.
85945 * - The body is empty.
85946 * - The body doesn't have any comments.
85947 * @param {ASTNode} node A function node to report. This is one of
85948 * an ArrowFunctionExpression, a FunctionDeclaration, or a
85949 * FunctionExpression.
85950 * @returns {void}
85951 */
85952
85953 function reportIfEmpty(node) {
85954 const kind = getKind(node);
85955 const name = astUtils.getFunctionNameWithKind(node);
85956 const innerComments = sourceCode.getTokens(node.body, {
85957 includeComments: true,
85958 filter: astUtils.isCommentToken
85959 });
85960
85961 if (allowed.indexOf(kind) === -1 && node.body.type === "BlockStatement" && node.body.body.length === 0 && innerComments.length === 0) {
85962 context.report({
85963 node,
85964 loc: node.body.loc,
85965 messageId: "unexpected",
85966 data: {
85967 name
85968 }
85969 });
85970 }
85971 }
85972
85973 return {
85974 ArrowFunctionExpression: reportIfEmpty,
85975 FunctionDeclaration: reportIfEmpty,
85976 FunctionExpression: reportIfEmpty
85977 };
85978 }
85979
85980 };
85981
85982 /***/ }),
85983 /* 666 */
85984 /***/ ((module) => {
85985
85986 "use strict";
85987 /**
85988 * @fileoverview Rule to disallow an empty pattern
85989 * @author Alberto Rodríguez
85990 */
85991 //------------------------------------------------------------------------------
85992 // Rule Definition
85993 //------------------------------------------------------------------------------
85994
85995 module.exports = {
85996 meta: {
85997 type: "problem",
85998 docs: {
85999 description: "disallow empty destructuring patterns",
86000 recommended: true,
86001 url: "https://eslint.org/docs/rules/no-empty-pattern"
86002 },
86003 schema: [],
86004 messages: {
86005 unexpected: "Unexpected empty {{type}} pattern."
86006 }
86007 },
86008
86009 create(context) {
86010 return {
86011 ObjectPattern(node) {
86012 if (node.properties.length === 0) {
86013 context.report({
86014 node,
86015 messageId: "unexpected",
86016 data: {
86017 type: "object"
86018 }
86019 });
86020 }
86021 },
86022
86023 ArrayPattern(node) {
86024 if (node.elements.length === 0) {
86025 context.report({
86026 node,
86027 messageId: "unexpected",
86028 data: {
86029 type: "array"
86030 }
86031 });
86032 }
86033 }
86034
86035 };
86036 }
86037
86038 };
86039
86040 /***/ }),
86041 /* 667 */
86042 /***/ ((module) => {
86043
86044 "use strict";
86045 /**
86046 * @fileoverview Rule to flag comparisons to null without a type-checking
86047 * operator.
86048 * @author Ian Christian Myers
86049 */
86050 //------------------------------------------------------------------------------
86051 // Rule Definition
86052 //------------------------------------------------------------------------------
86053
86054 module.exports = {
86055 meta: {
86056 type: "suggestion",
86057 docs: {
86058 description: "disallow `null` comparisons without type-checking operators",
86059 recommended: false,
86060 url: "https://eslint.org/docs/rules/no-eq-null"
86061 },
86062 schema: [],
86063 messages: {
86064 unexpected: "Use '===' to compare with null."
86065 }
86066 },
86067
86068 create(context) {
86069 return {
86070 BinaryExpression(node) {
86071 const badOperator = node.operator === "==" || node.operator === "!=";
86072
86073 if (node.right.type === "Literal" && node.right.raw === "null" && badOperator || node.left.type === "Literal" && node.left.raw === "null" && badOperator) {
86074 context.report({
86075 node,
86076 messageId: "unexpected"
86077 });
86078 }
86079 }
86080
86081 };
86082 }
86083
86084 };
86085
86086 /***/ }),
86087 /* 668 */
86088 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
86089
86090 "use strict";
86091 /**
86092 * @fileoverview Rule to flag use of eval() statement
86093 * @author Nicholas C. Zakas
86094 */
86095 //------------------------------------------------------------------------------
86096 // Requirements
86097 //------------------------------------------------------------------------------
86098
86099 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
86100 // Helpers
86101 //------------------------------------------------------------------------------
86102
86103
86104 const candidatesOfGlobalObject = Object.freeze(["global", "window", "globalThis"]);
86105 /**
86106 * Checks a given node is a MemberExpression node which has the specified name's
86107 * property.
86108 * @param {ASTNode} node A node to check.
86109 * @param {string} name A name to check.
86110 * @returns {boolean} `true` if the node is a MemberExpression node which has
86111 * the specified name's property
86112 */
86113
86114 function isMember(node, name) {
86115 return astUtils.isSpecificMemberAccess(node, null, name);
86116 } //------------------------------------------------------------------------------
86117 // Rule Definition
86118 //------------------------------------------------------------------------------
86119
86120
86121 module.exports = {
86122 meta: {
86123 type: "suggestion",
86124 docs: {
86125 description: "disallow the use of `eval()`",
86126 recommended: false,
86127 url: "https://eslint.org/docs/rules/no-eval"
86128 },
86129 schema: [{
86130 type: "object",
86131 properties: {
86132 allowIndirect: {
86133 type: "boolean",
86134 default: false
86135 }
86136 },
86137 additionalProperties: false
86138 }],
86139 messages: {
86140 unexpected: "eval can be harmful."
86141 }
86142 },
86143
86144 create(context) {
86145 const allowIndirect = Boolean(context.options[0] && context.options[0].allowIndirect);
86146 const sourceCode = context.getSourceCode();
86147 let funcInfo = null;
86148 /**
86149 * Pushs a variable scope (Program or Function) information to the stack.
86150 *
86151 * This is used in order to check whether or not `this` binding is a
86152 * reference to the global object.
86153 * @param {ASTNode} node A node of the scope. This is one of Program,
86154 * FunctionDeclaration, FunctionExpression, and ArrowFunctionExpression.
86155 * @returns {void}
86156 */
86157
86158 function enterVarScope(node) {
86159 const strict = context.getScope().isStrict;
86160 funcInfo = {
86161 upper: funcInfo,
86162 node,
86163 strict,
86164 defaultThis: false,
86165 initialized: strict
86166 };
86167 }
86168 /**
86169 * Pops a variable scope from the stack.
86170 * @returns {void}
86171 */
86172
86173
86174 function exitVarScope() {
86175 funcInfo = funcInfo.upper;
86176 }
86177 /**
86178 * Reports a given node.
86179 *
86180 * `node` is `Identifier` or `MemberExpression`.
86181 * The parent of `node` might be `CallExpression`.
86182 *
86183 * The location of the report is always `eval` `Identifier` (or possibly
86184 * `Literal`). The type of the report is `CallExpression` if the parent is
86185 * `CallExpression`. Otherwise, it's the given node type.
86186 * @param {ASTNode} node A node to report.
86187 * @returns {void}
86188 */
86189
86190
86191 function report(node) {
86192 const parent = node.parent;
86193 const locationNode = node.type === "MemberExpression" ? node.property : node;
86194 const reportNode = parent.type === "CallExpression" && parent.callee === node ? parent : node;
86195 context.report({
86196 node: reportNode,
86197 loc: locationNode.loc,
86198 messageId: "unexpected"
86199 });
86200 }
86201 /**
86202 * Reports accesses of `eval` via the global object.
86203 * @param {eslint-scope.Scope} globalScope The global scope.
86204 * @returns {void}
86205 */
86206
86207
86208 function reportAccessingEvalViaGlobalObject(globalScope) {
86209 for (let i = 0; i < candidatesOfGlobalObject.length; ++i) {
86210 const name = candidatesOfGlobalObject[i];
86211 const variable = astUtils.getVariableByName(globalScope, name);
86212
86213 if (!variable) {
86214 continue;
86215 }
86216
86217 const references = variable.references;
86218
86219 for (let j = 0; j < references.length; ++j) {
86220 const identifier = references[j].identifier;
86221 let node = identifier.parent; // To detect code like `window.window.eval`.
86222
86223 while (isMember(node, name)) {
86224 node = node.parent;
86225 } // Reports.
86226
86227
86228 if (isMember(node, "eval")) {
86229 report(node);
86230 }
86231 }
86232 }
86233 }
86234 /**
86235 * Reports all accesses of `eval` (excludes direct calls to eval).
86236 * @param {eslint-scope.Scope} globalScope The global scope.
86237 * @returns {void}
86238 */
86239
86240
86241 function reportAccessingEval(globalScope) {
86242 const variable = astUtils.getVariableByName(globalScope, "eval");
86243
86244 if (!variable) {
86245 return;
86246 }
86247
86248 const references = variable.references;
86249
86250 for (let i = 0; i < references.length; ++i) {
86251 const reference = references[i];
86252 const id = reference.identifier;
86253
86254 if (id.name === "eval" && !astUtils.isCallee(id)) {
86255 // Is accessing to eval (excludes direct calls to eval)
86256 report(id);
86257 }
86258 }
86259 }
86260
86261 if (allowIndirect) {
86262 // Checks only direct calls to eval. It's simple!
86263 return {
86264 "CallExpression:exit"(node) {
86265 const callee = node.callee;
86266 /*
86267 * Optional call (`eval?.("code")`) is not direct eval.
86268 * The direct eval is only step 6.a.vi of https://tc39.es/ecma262/#sec-function-calls-runtime-semantics-evaluation
86269 * But the optional call is https://tc39.es/ecma262/#sec-optional-chaining-chain-evaluation
86270 */
86271
86272 if (!node.optional && astUtils.isSpecificId(callee, "eval")) {
86273 report(callee);
86274 }
86275 }
86276
86277 };
86278 }
86279
86280 return {
86281 "CallExpression:exit"(node) {
86282 const callee = node.callee;
86283
86284 if (astUtils.isSpecificId(callee, "eval")) {
86285 report(callee);
86286 }
86287 },
86288
86289 Program(node) {
86290 const scope = context.getScope(),
86291 features = context.parserOptions.ecmaFeatures || {},
86292 strict = scope.isStrict || node.sourceType === "module" || features.globalReturn && scope.childScopes[0].isStrict;
86293 funcInfo = {
86294 upper: null,
86295 node,
86296 strict,
86297 defaultThis: true,
86298 initialized: true
86299 };
86300 },
86301
86302 "Program:exit"() {
86303 const globalScope = context.getScope();
86304 exitVarScope();
86305 reportAccessingEval(globalScope);
86306 reportAccessingEvalViaGlobalObject(globalScope);
86307 },
86308
86309 FunctionDeclaration: enterVarScope,
86310 "FunctionDeclaration:exit": exitVarScope,
86311 FunctionExpression: enterVarScope,
86312 "FunctionExpression:exit": exitVarScope,
86313 ArrowFunctionExpression: enterVarScope,
86314 "ArrowFunctionExpression:exit": exitVarScope,
86315 "PropertyDefinition > *.value": enterVarScope,
86316 "PropertyDefinition > *.value:exit": exitVarScope,
86317 StaticBlock: enterVarScope,
86318 "StaticBlock:exit": exitVarScope,
86319
86320 ThisExpression(node) {
86321 if (!isMember(node.parent, "eval")) {
86322 return;
86323 }
86324 /*
86325 * `this.eval` is found.
86326 * Checks whether or not the value of `this` is the global object.
86327 */
86328
86329
86330 if (!funcInfo.initialized) {
86331 funcInfo.initialized = true;
86332 funcInfo.defaultThis = astUtils.isDefaultThisBinding(funcInfo.node, sourceCode);
86333 }
86334
86335 if (!funcInfo.strict && funcInfo.defaultThis) {
86336 // `this.eval` is possible built-in `eval`.
86337 report(node.parent);
86338 }
86339 }
86340
86341 };
86342 }
86343
86344 };
86345
86346 /***/ }),
86347 /* 669 */
86348 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
86349
86350 "use strict";
86351 /**
86352 * @fileoverview Rule to flag assignment of the exception parameter
86353 * @author Stephen Murray <spmurrayzzz>
86354 */
86355
86356
86357 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
86358 // Rule Definition
86359 //------------------------------------------------------------------------------
86360
86361
86362 module.exports = {
86363 meta: {
86364 type: "problem",
86365 docs: {
86366 description: "disallow reassigning exceptions in `catch` clauses",
86367 recommended: true,
86368 url: "https://eslint.org/docs/rules/no-ex-assign"
86369 },
86370 schema: [],
86371 messages: {
86372 unexpected: "Do not assign to the exception parameter."
86373 }
86374 },
86375
86376 create(context) {
86377 /**
86378 * Finds and reports references that are non initializer and writable.
86379 * @param {Variable} variable A variable to check.
86380 * @returns {void}
86381 */
86382 function checkVariable(variable) {
86383 astUtils.getModifyingReferences(variable.references).forEach(reference => {
86384 context.report({
86385 node: reference.identifier,
86386 messageId: "unexpected"
86387 });
86388 });
86389 }
86390
86391 return {
86392 CatchClause(node) {
86393 context.getDeclaredVariables(node).forEach(checkVariable);
86394 }
86395
86396 };
86397 }
86398
86399 };
86400
86401 /***/ }),
86402 /* 670 */
86403 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
86404
86405 "use strict";
86406 /**
86407 * @fileoverview Rule to flag adding properties to native object's prototypes.
86408 * @author David Nelson
86409 */
86410 //------------------------------------------------------------------------------
86411 // Requirements
86412 //------------------------------------------------------------------------------
86413
86414 const astUtils = __webpack_require__(548);
86415
86416 const globals = __webpack_require__(492); //------------------------------------------------------------------------------
86417 // Rule Definition
86418 //------------------------------------------------------------------------------
86419
86420
86421 module.exports = {
86422 meta: {
86423 type: "suggestion",
86424 docs: {
86425 description: "disallow extending native types",
86426 recommended: false,
86427 url: "https://eslint.org/docs/rules/no-extend-native"
86428 },
86429 schema: [{
86430 type: "object",
86431 properties: {
86432 exceptions: {
86433 type: "array",
86434 items: {
86435 type: "string"
86436 },
86437 uniqueItems: true
86438 }
86439 },
86440 additionalProperties: false
86441 }],
86442 messages: {
86443 unexpected: "{{builtin}} prototype is read only, properties should not be added."
86444 }
86445 },
86446
86447 create(context) {
86448 const config = context.options[0] || {};
86449 const exceptions = new Set(config.exceptions || []);
86450 const modifiedBuiltins = new Set(Object.keys(globals.builtin).filter(builtin => builtin[0].toUpperCase() === builtin[0]).filter(builtin => !exceptions.has(builtin)));
86451 /**
86452 * Reports a lint error for the given node.
86453 * @param {ASTNode} node The node to report.
86454 * @param {string} builtin The name of the native builtin being extended.
86455 * @returns {void}
86456 */
86457
86458 function reportNode(node, builtin) {
86459 context.report({
86460 node,
86461 messageId: "unexpected",
86462 data: {
86463 builtin
86464 }
86465 });
86466 }
86467 /**
86468 * Check to see if the `prototype` property of the given object
86469 * identifier node is being accessed.
86470 * @param {ASTNode} identifierNode The Identifier representing the object
86471 * to check.
86472 * @returns {boolean} True if the identifier is the object of a
86473 * MemberExpression and its `prototype` property is being accessed,
86474 * false otherwise.
86475 */
86476
86477
86478 function isPrototypePropertyAccessed(identifierNode) {
86479 return Boolean(identifierNode && identifierNode.parent && identifierNode.parent.type === "MemberExpression" && identifierNode.parent.object === identifierNode && astUtils.getStaticPropertyName(identifierNode.parent) === "prototype");
86480 }
86481 /**
86482 * Check if it's an assignment to the property of the given node.
86483 * Example: `*.prop = 0` // the `*` is the given node.
86484 * @param {ASTNode} node The node to check.
86485 * @returns {boolean} True if an assignment to the property of the node.
86486 */
86487
86488
86489 function isAssigningToPropertyOf(node) {
86490 return node.parent.type === "MemberExpression" && node.parent.object === node && node.parent.parent.type === "AssignmentExpression" && node.parent.parent.left === node.parent;
86491 }
86492 /**
86493 * Checks if the given node is at the first argument of the method call of `Object.defineProperty()` or `Object.defineProperties()`.
86494 * @param {ASTNode} node The node to check.
86495 * @returns {boolean} True if the node is at the first argument of the method call of `Object.defineProperty()` or `Object.defineProperties()`.
86496 */
86497
86498
86499 function isInDefinePropertyCall(node) {
86500 return node.parent.type === "CallExpression" && node.parent.arguments[0] === node && astUtils.isSpecificMemberAccess(node.parent.callee, "Object", /^definePropert(?:y|ies)$/u);
86501 }
86502 /**
86503 * Check to see if object prototype access is part of a prototype
86504 * extension. There are three ways a prototype can be extended:
86505 * 1. Assignment to prototype property (Object.prototype.foo = 1)
86506 * 2. Object.defineProperty()/Object.defineProperties() on a prototype
86507 * If prototype extension is detected, report the AssignmentExpression
86508 * or CallExpression node.
86509 * @param {ASTNode} identifierNode The Identifier representing the object
86510 * which prototype is being accessed and possibly extended.
86511 * @returns {void}
86512 */
86513
86514
86515 function checkAndReportPrototypeExtension(identifierNode) {
86516 if (!isPrototypePropertyAccessed(identifierNode)) {
86517 return; // This is not `*.prototype` access.
86518 }
86519 /*
86520 * `identifierNode.parent` is a MemberExpression `*.prototype`.
86521 * If it's an optional member access, it may be wrapped by a `ChainExpression` node.
86522 */
86523
86524
86525 const prototypeNode = identifierNode.parent.parent.type === "ChainExpression" ? identifierNode.parent.parent : identifierNode.parent;
86526
86527 if (isAssigningToPropertyOf(prototypeNode)) {
86528 // `*.prototype` -> MemberExpression -> AssignmentExpression
86529 reportNode(prototypeNode.parent.parent, identifierNode.name);
86530 } else if (isInDefinePropertyCall(prototypeNode)) {
86531 // `*.prototype` -> CallExpression
86532 reportNode(prototypeNode.parent, identifierNode.name);
86533 }
86534 }
86535
86536 return {
86537 "Program:exit"() {
86538 const globalScope = context.getScope();
86539 modifiedBuiltins.forEach(builtin => {
86540 const builtinVar = globalScope.set.get(builtin);
86541
86542 if (builtinVar && builtinVar.references) {
86543 builtinVar.references.map(ref => ref.identifier).forEach(checkAndReportPrototypeExtension);
86544 }
86545 });
86546 }
86547
86548 };
86549 }
86550
86551 };
86552
86553 /***/ }),
86554 /* 671 */
86555 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
86556
86557 "use strict";
86558 /**
86559 * @fileoverview Rule to flag unnecessary bind calls
86560 * @author Bence Dányi <bence@danyi.me>
86561 */
86562 //------------------------------------------------------------------------------
86563 // Requirements
86564 //------------------------------------------------------------------------------
86565
86566 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
86567 // Helpers
86568 //------------------------------------------------------------------------------
86569
86570
86571 const SIDE_EFFECT_FREE_NODE_TYPES = new Set(["Literal", "Identifier", "ThisExpression", "FunctionExpression"]); //------------------------------------------------------------------------------
86572 // Rule Definition
86573 //------------------------------------------------------------------------------
86574
86575 module.exports = {
86576 meta: {
86577 type: "suggestion",
86578 docs: {
86579 description: "disallow unnecessary calls to `.bind()`",
86580 recommended: false,
86581 url: "https://eslint.org/docs/rules/no-extra-bind"
86582 },
86583 schema: [],
86584 fixable: "code",
86585 messages: {
86586 unexpected: "The function binding is unnecessary."
86587 }
86588 },
86589
86590 create(context) {
86591 const sourceCode = context.getSourceCode();
86592 let scopeInfo = null;
86593 /**
86594 * Checks if a node is free of side effects.
86595 *
86596 * This check is stricter than it needs to be, in order to keep the implementation simple.
86597 * @param {ASTNode} node A node to check.
86598 * @returns {boolean} True if the node is known to be side-effect free, false otherwise.
86599 */
86600
86601 function isSideEffectFree(node) {
86602 return SIDE_EFFECT_FREE_NODE_TYPES.has(node.type);
86603 }
86604 /**
86605 * Reports a given function node.
86606 * @param {ASTNode} node A node to report. This is a FunctionExpression or
86607 * an ArrowFunctionExpression.
86608 * @returns {void}
86609 */
86610
86611
86612 function report(node) {
86613 const memberNode = node.parent;
86614 const callNode = memberNode.parent.type === "ChainExpression" ? memberNode.parent.parent : memberNode.parent;
86615 context.report({
86616 node: callNode,
86617 messageId: "unexpected",
86618 loc: memberNode.property.loc,
86619
86620 fix(fixer) {
86621 if (!isSideEffectFree(callNode.arguments[0])) {
86622 return null;
86623 }
86624 /*
86625 * The list of the first/last token pair of a removal range.
86626 * This is two parts because closing parentheses may exist between the method name and arguments.
86627 * E.g. `(function(){}.bind ) (obj)`
86628 * ^^^^^ ^^^^^ < removal ranges
86629 * E.g. `(function(){}?.['bind'] ) ?.(obj)`
86630 * ^^^^^^^^^^ ^^^^^^^ < removal ranges
86631 */
86632
86633
86634 const tokenPairs = [[// `.`, `?.`, or `[` token.
86635 sourceCode.getTokenAfter(memberNode.object, astUtils.isNotClosingParenToken), // property name or `]` token.
86636 sourceCode.getLastToken(memberNode)], [// `?.` or `(` token of arguments.
86637 sourceCode.getTokenAfter(memberNode, astUtils.isNotClosingParenToken), // `)` token of arguments.
86638 sourceCode.getLastToken(callNode)]];
86639 const firstTokenToRemove = tokenPairs[0][0];
86640 const lastTokenToRemove = tokenPairs[1][1];
86641
86642 if (sourceCode.commentsExistBetween(firstTokenToRemove, lastTokenToRemove)) {
86643 return null;
86644 }
86645
86646 return tokenPairs.map(_ref => {
86647 let [start, end] = _ref;
86648 return fixer.removeRange([start.range[0], end.range[1]]);
86649 });
86650 }
86651
86652 });
86653 }
86654 /**
86655 * Checks whether or not a given function node is the callee of `.bind()`
86656 * method.
86657 *
86658 * e.g. `(function() {}.bind(foo))`
86659 * @param {ASTNode} node A node to report. This is a FunctionExpression or
86660 * an ArrowFunctionExpression.
86661 * @returns {boolean} `true` if the node is the callee of `.bind()` method.
86662 */
86663
86664
86665 function isCalleeOfBindMethod(node) {
86666 if (!astUtils.isSpecificMemberAccess(node.parent, null, "bind")) {
86667 return false;
86668 } // The node of `*.bind` member access.
86669
86670
86671 const bindNode = node.parent.parent.type === "ChainExpression" ? node.parent.parent : node.parent;
86672 return bindNode.parent.type === "CallExpression" && bindNode.parent.callee === bindNode && bindNode.parent.arguments.length === 1 && bindNode.parent.arguments[0].type !== "SpreadElement";
86673 }
86674 /**
86675 * Adds a scope information object to the stack.
86676 * @param {ASTNode} node A node to add. This node is a FunctionExpression
86677 * or a FunctionDeclaration node.
86678 * @returns {void}
86679 */
86680
86681
86682 function enterFunction(node) {
86683 scopeInfo = {
86684 isBound: isCalleeOfBindMethod(node),
86685 thisFound: false,
86686 upper: scopeInfo
86687 };
86688 }
86689 /**
86690 * Removes the scope information object from the top of the stack.
86691 * At the same time, this reports the function node if the function has
86692 * `.bind()` and the `this` keywords found.
86693 * @param {ASTNode} node A node to remove. This node is a
86694 * FunctionExpression or a FunctionDeclaration node.
86695 * @returns {void}
86696 */
86697
86698
86699 function exitFunction(node) {
86700 if (scopeInfo.isBound && !scopeInfo.thisFound) {
86701 report(node);
86702 }
86703
86704 scopeInfo = scopeInfo.upper;
86705 }
86706 /**
86707 * Reports a given arrow function if the function is callee of `.bind()`
86708 * method.
86709 * @param {ASTNode} node A node to report. This node is an
86710 * ArrowFunctionExpression.
86711 * @returns {void}
86712 */
86713
86714
86715 function exitArrowFunction(node) {
86716 if (isCalleeOfBindMethod(node)) {
86717 report(node);
86718 }
86719 }
86720 /**
86721 * Set the mark as the `this` keyword was found in this scope.
86722 * @returns {void}
86723 */
86724
86725
86726 function markAsThisFound() {
86727 if (scopeInfo) {
86728 scopeInfo.thisFound = true;
86729 }
86730 }
86731
86732 return {
86733 "ArrowFunctionExpression:exit": exitArrowFunction,
86734 FunctionDeclaration: enterFunction,
86735 "FunctionDeclaration:exit": exitFunction,
86736 FunctionExpression: enterFunction,
86737 "FunctionExpression:exit": exitFunction,
86738 ThisExpression: markAsThisFound
86739 };
86740 }
86741
86742 };
86743
86744 /***/ }),
86745 /* 672 */
86746 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
86747
86748 "use strict";
86749 /**
86750 * @fileoverview Rule to flag unnecessary double negation in Boolean contexts
86751 * @author Brandon Mills
86752 */
86753 //------------------------------------------------------------------------------
86754 // Requirements
86755 //------------------------------------------------------------------------------
86756
86757 const astUtils = __webpack_require__(548);
86758
86759 const eslintUtils = __webpack_require__(501);
86760
86761 const precedence = astUtils.getPrecedence; //------------------------------------------------------------------------------
86762 // Rule Definition
86763 //------------------------------------------------------------------------------
86764
86765 module.exports = {
86766 meta: {
86767 type: "suggestion",
86768 docs: {
86769 description: "disallow unnecessary boolean casts",
86770 recommended: true,
86771 url: "https://eslint.org/docs/rules/no-extra-boolean-cast"
86772 },
86773 schema: [{
86774 type: "object",
86775 properties: {
86776 enforceForLogicalOperands: {
86777 type: "boolean",
86778 default: false
86779 }
86780 },
86781 additionalProperties: false
86782 }],
86783 fixable: "code",
86784 messages: {
86785 unexpectedCall: "Redundant Boolean call.",
86786 unexpectedNegation: "Redundant double negation."
86787 }
86788 },
86789
86790 create(context) {
86791 const sourceCode = context.getSourceCode(); // Node types which have a test which will coerce values to booleans.
86792
86793 const BOOLEAN_NODE_TYPES = ["IfStatement", "DoWhileStatement", "WhileStatement", "ConditionalExpression", "ForStatement"];
86794 /**
86795 * Check if a node is a Boolean function or constructor.
86796 * @param {ASTNode} node the node
86797 * @returns {boolean} If the node is Boolean function or constructor
86798 */
86799
86800 function isBooleanFunctionOrConstructorCall(node) {
86801 // Boolean(<bool>) and new Boolean(<bool>)
86802 return (node.type === "CallExpression" || node.type === "NewExpression") && node.callee.type === "Identifier" && node.callee.name === "Boolean";
86803 }
86804 /**
86805 * Checks whether the node is a logical expression and that the option is enabled
86806 * @param {ASTNode} node the node
86807 * @returns {boolean} if the node is a logical expression and option is enabled
86808 */
86809
86810
86811 function isLogicalContext(node) {
86812 return node.type === "LogicalExpression" && (node.operator === "||" || node.operator === "&&") && context.options.length && context.options[0].enforceForLogicalOperands === true;
86813 }
86814 /**
86815 * Check if a node is in a context where its value would be coerced to a boolean at runtime.
86816 * @param {ASTNode} node The node
86817 * @returns {boolean} If it is in a boolean context
86818 */
86819
86820
86821 function isInBooleanContext(node) {
86822 return isBooleanFunctionOrConstructorCall(node.parent) && node === node.parent.arguments[0] || BOOLEAN_NODE_TYPES.indexOf(node.parent.type) !== -1 && node === node.parent.test || // !<bool>
86823 node.parent.type === "UnaryExpression" && node.parent.operator === "!";
86824 }
86825 /**
86826 * Checks whether the node is a context that should report an error
86827 * Acts recursively if it is in a logical context
86828 * @param {ASTNode} node the node
86829 * @returns {boolean} If the node is in one of the flagged contexts
86830 */
86831
86832
86833 function isInFlaggedContext(node) {
86834 if (node.parent.type === "ChainExpression") {
86835 return isInFlaggedContext(node.parent);
86836 }
86837
86838 return isInBooleanContext(node) || isLogicalContext(node.parent) && // For nested logical statements
86839 isInFlaggedContext(node.parent);
86840 }
86841 /**
86842 * Check if a node has comments inside.
86843 * @param {ASTNode} node The node to check.
86844 * @returns {boolean} `true` if it has comments inside.
86845 */
86846
86847
86848 function hasCommentsInside(node) {
86849 return Boolean(sourceCode.getCommentsInside(node).length);
86850 }
86851 /**
86852 * Checks if the given node is wrapped in grouping parentheses. Parentheses for constructs such as if() don't count.
86853 * @param {ASTNode} node The node to check.
86854 * @returns {boolean} `true` if the node is parenthesized.
86855 * @private
86856 */
86857
86858
86859 function isParenthesized(node) {
86860 return eslintUtils.isParenthesized(1, node, sourceCode);
86861 }
86862 /**
86863 * Determines whether the given node needs to be parenthesized when replacing the previous node.
86864 * It assumes that `previousNode` is the node to be reported by this rule, so it has a limited list
86865 * of possible parent node types. By the same assumption, the node's role in a particular parent is already known.
86866 * For example, if the parent is `ConditionalExpression`, `previousNode` must be its `test` child.
86867 * @param {ASTNode} previousNode Previous node.
86868 * @param {ASTNode} node The node to check.
86869 * @throws {Error} (Unreachable.)
86870 * @returns {boolean} `true` if the node needs to be parenthesized.
86871 */
86872
86873
86874 function needsParens(previousNode, node) {
86875 if (previousNode.parent.type === "ChainExpression") {
86876 return needsParens(previousNode.parent, node);
86877 }
86878
86879 if (isParenthesized(previousNode)) {
86880 // parentheses around the previous node will stay, so there is no need for an additional pair
86881 return false;
86882 } // parent of the previous node will become parent of the replacement node
86883
86884
86885 const parent = previousNode.parent;
86886
86887 switch (parent.type) {
86888 case "CallExpression":
86889 case "NewExpression":
86890 return node.type === "SequenceExpression";
86891
86892 case "IfStatement":
86893 case "DoWhileStatement":
86894 case "WhileStatement":
86895 case "ForStatement":
86896 return false;
86897
86898 case "ConditionalExpression":
86899 return precedence(node) <= precedence(parent);
86900
86901 case "UnaryExpression":
86902 return precedence(node) < precedence(parent);
86903
86904 case "LogicalExpression":
86905 if (astUtils.isMixedLogicalAndCoalesceExpressions(node, parent)) {
86906 return true;
86907 }
86908
86909 if (previousNode === parent.left) {
86910 return precedence(node) < precedence(parent);
86911 }
86912
86913 return precedence(node) <= precedence(parent);
86914
86915 /* istanbul ignore next */
86916
86917 default:
86918 throw new Error("Unexpected parent type: ".concat(parent.type));
86919 }
86920 }
86921
86922 return {
86923 UnaryExpression(node) {
86924 const parent = node.parent; // Exit early if it's guaranteed not to match
86925
86926 if (node.operator !== "!" || parent.type !== "UnaryExpression" || parent.operator !== "!") {
86927 return;
86928 }
86929
86930 if (isInFlaggedContext(parent)) {
86931 context.report({
86932 node: parent,
86933 messageId: "unexpectedNegation",
86934
86935 fix(fixer) {
86936 if (hasCommentsInside(parent)) {
86937 return null;
86938 }
86939
86940 if (needsParens(parent, node.argument)) {
86941 return fixer.replaceText(parent, "(".concat(sourceCode.getText(node.argument), ")"));
86942 }
86943
86944 let prefix = "";
86945 const tokenBefore = sourceCode.getTokenBefore(parent);
86946 const firstReplacementToken = sourceCode.getFirstToken(node.argument);
86947
86948 if (tokenBefore && tokenBefore.range[1] === parent.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, firstReplacementToken)) {
86949 prefix = " ";
86950 }
86951
86952 return fixer.replaceText(parent, prefix + sourceCode.getText(node.argument));
86953 }
86954
86955 });
86956 }
86957 },
86958
86959 CallExpression(node) {
86960 if (node.callee.type !== "Identifier" || node.callee.name !== "Boolean") {
86961 return;
86962 }
86963
86964 if (isInFlaggedContext(node)) {
86965 context.report({
86966 node,
86967 messageId: "unexpectedCall",
86968
86969 fix(fixer) {
86970 const parent = node.parent;
86971
86972 if (node.arguments.length === 0) {
86973 if (parent.type === "UnaryExpression" && parent.operator === "!") {
86974 /*
86975 * !Boolean() -> true
86976 */
86977 if (hasCommentsInside(parent)) {
86978 return null;
86979 }
86980
86981 const replacement = "true";
86982 let prefix = "";
86983 const tokenBefore = sourceCode.getTokenBefore(parent);
86984
86985 if (tokenBefore && tokenBefore.range[1] === parent.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, replacement)) {
86986 prefix = " ";
86987 }
86988
86989 return fixer.replaceText(parent, prefix + replacement);
86990 }
86991 /*
86992 * Boolean() -> false
86993 */
86994
86995
86996 if (hasCommentsInside(node)) {
86997 return null;
86998 }
86999
87000 return fixer.replaceText(node, "false");
87001 }
87002
87003 if (node.arguments.length === 1) {
87004 const argument = node.arguments[0];
87005
87006 if (argument.type === "SpreadElement" || hasCommentsInside(node)) {
87007 return null;
87008 }
87009 /*
87010 * Boolean(expression) -> expression
87011 */
87012
87013
87014 if (needsParens(node, argument)) {
87015 return fixer.replaceText(node, "(".concat(sourceCode.getText(argument), ")"));
87016 }
87017
87018 return fixer.replaceText(node, sourceCode.getText(argument));
87019 } // two or more arguments
87020
87021
87022 return null;
87023 }
87024
87025 });
87026 }
87027 }
87028
87029 };
87030 }
87031
87032 };
87033
87034 /***/ }),
87035 /* 673 */
87036 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
87037
87038 "use strict";
87039 /**
87040 * @fileoverview Rule to disallow unnecessary labels
87041 * @author Toru Nagashima
87042 */
87043 //------------------------------------------------------------------------------
87044 // Requirements
87045 //------------------------------------------------------------------------------
87046
87047 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
87048 // Rule Definition
87049 //------------------------------------------------------------------------------
87050
87051
87052 module.exports = {
87053 meta: {
87054 type: "suggestion",
87055 docs: {
87056 description: "disallow unnecessary labels",
87057 recommended: false,
87058 url: "https://eslint.org/docs/rules/no-extra-label"
87059 },
87060 schema: [],
87061 fixable: "code",
87062 messages: {
87063 unexpected: "This label '{{name}}' is unnecessary."
87064 }
87065 },
87066
87067 create(context) {
87068 const sourceCode = context.getSourceCode();
87069 let scopeInfo = null;
87070 /**
87071 * Creates a new scope with a breakable statement.
87072 * @param {ASTNode} node A node to create. This is a BreakableStatement.
87073 * @returns {void}
87074 */
87075
87076 function enterBreakableStatement(node) {
87077 scopeInfo = {
87078 label: node.parent.type === "LabeledStatement" ? node.parent.label : null,
87079 breakable: true,
87080 upper: scopeInfo
87081 };
87082 }
87083 /**
87084 * Removes the top scope of the stack.
87085 * @returns {void}
87086 */
87087
87088
87089 function exitBreakableStatement() {
87090 scopeInfo = scopeInfo.upper;
87091 }
87092 /**
87093 * Creates a new scope with a labeled statement.
87094 *
87095 * This ignores it if the body is a breakable statement.
87096 * In this case it's handled in the `enterBreakableStatement` function.
87097 * @param {ASTNode} node A node to create. This is a LabeledStatement.
87098 * @returns {void}
87099 */
87100
87101
87102 function enterLabeledStatement(node) {
87103 if (!astUtils.isBreakableStatement(node.body)) {
87104 scopeInfo = {
87105 label: node.label,
87106 breakable: false,
87107 upper: scopeInfo
87108 };
87109 }
87110 }
87111 /**
87112 * Removes the top scope of the stack.
87113 *
87114 * This ignores it if the body is a breakable statement.
87115 * In this case it's handled in the `exitBreakableStatement` function.
87116 * @param {ASTNode} node A node. This is a LabeledStatement.
87117 * @returns {void}
87118 */
87119
87120
87121 function exitLabeledStatement(node) {
87122 if (!astUtils.isBreakableStatement(node.body)) {
87123 scopeInfo = scopeInfo.upper;
87124 }
87125 }
87126 /**
87127 * Reports a given control node if it's unnecessary.
87128 * @param {ASTNode} node A node. This is a BreakStatement or a
87129 * ContinueStatement.
87130 * @returns {void}
87131 */
87132
87133
87134 function reportIfUnnecessary(node) {
87135 if (!node.label) {
87136 return;
87137 }
87138
87139 const labelNode = node.label;
87140
87141 for (let info = scopeInfo; info !== null; info = info.upper) {
87142 if (info.breakable || info.label && info.label.name === labelNode.name) {
87143 if (info.breakable && info.label && info.label.name === labelNode.name) {
87144 context.report({
87145 node: labelNode,
87146 messageId: "unexpected",
87147 data: labelNode,
87148
87149 fix(fixer) {
87150 const breakOrContinueToken = sourceCode.getFirstToken(node);
87151
87152 if (sourceCode.commentsExistBetween(breakOrContinueToken, labelNode)) {
87153 return null;
87154 }
87155
87156 return fixer.removeRange([breakOrContinueToken.range[1], labelNode.range[1]]);
87157 }
87158
87159 });
87160 }
87161
87162 return;
87163 }
87164 }
87165 }
87166
87167 return {
87168 WhileStatement: enterBreakableStatement,
87169 "WhileStatement:exit": exitBreakableStatement,
87170 DoWhileStatement: enterBreakableStatement,
87171 "DoWhileStatement:exit": exitBreakableStatement,
87172 ForStatement: enterBreakableStatement,
87173 "ForStatement:exit": exitBreakableStatement,
87174 ForInStatement: enterBreakableStatement,
87175 "ForInStatement:exit": exitBreakableStatement,
87176 ForOfStatement: enterBreakableStatement,
87177 "ForOfStatement:exit": exitBreakableStatement,
87178 SwitchStatement: enterBreakableStatement,
87179 "SwitchStatement:exit": exitBreakableStatement,
87180 LabeledStatement: enterLabeledStatement,
87181 "LabeledStatement:exit": exitLabeledStatement,
87182 BreakStatement: reportIfUnnecessary,
87183 ContinueStatement: reportIfUnnecessary
87184 };
87185 }
87186
87187 };
87188
87189 /***/ }),
87190 /* 674 */
87191 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
87192
87193 "use strict";
87194 /**
87195 * @fileoverview Disallow parenthesising higher precedence subexpressions.
87196 * @author Michael Ficarra
87197 */
87198 //------------------------------------------------------------------------------
87199 // Rule Definition
87200 //------------------------------------------------------------------------------
87201
87202 const {
87203 isParenthesized: isParenthesizedRaw
87204 } = __webpack_require__(501);
87205
87206 const astUtils = __webpack_require__(548);
87207
87208 module.exports = {
87209 meta: {
87210 type: "layout",
87211 docs: {
87212 description: "disallow unnecessary parentheses",
87213 recommended: false,
87214 url: "https://eslint.org/docs/rules/no-extra-parens"
87215 },
87216 fixable: "code",
87217 schema: {
87218 anyOf: [{
87219 type: "array",
87220 items: [{
87221 enum: ["functions"]
87222 }],
87223 minItems: 0,
87224 maxItems: 1
87225 }, {
87226 type: "array",
87227 items: [{
87228 enum: ["all"]
87229 }, {
87230 type: "object",
87231 properties: {
87232 conditionalAssign: {
87233 type: "boolean"
87234 },
87235 nestedBinaryExpressions: {
87236 type: "boolean"
87237 },
87238 returnAssign: {
87239 type: "boolean"
87240 },
87241 ignoreJSX: {
87242 enum: ["none", "all", "single-line", "multi-line"]
87243 },
87244 enforceForArrowConditionals: {
87245 type: "boolean"
87246 },
87247 enforceForSequenceExpressions: {
87248 type: "boolean"
87249 },
87250 enforceForNewInMemberExpressions: {
87251 type: "boolean"
87252 },
87253 enforceForFunctionPrototypeMethods: {
87254 type: "boolean"
87255 }
87256 },
87257 additionalProperties: false
87258 }],
87259 minItems: 0,
87260 maxItems: 2
87261 }]
87262 },
87263 messages: {
87264 unexpected: "Unnecessary parentheses around expression."
87265 }
87266 },
87267
87268 create(context) {
87269 const sourceCode = context.getSourceCode();
87270 const tokensToIgnore = new WeakSet();
87271 const precedence = astUtils.getPrecedence;
87272 const ALL_NODES = context.options[0] !== "functions";
87273 const EXCEPT_COND_ASSIGN = ALL_NODES && context.options[1] && context.options[1].conditionalAssign === false;
87274 const NESTED_BINARY = ALL_NODES && context.options[1] && context.options[1].nestedBinaryExpressions === false;
87275 const EXCEPT_RETURN_ASSIGN = ALL_NODES && context.options[1] && context.options[1].returnAssign === false;
87276 const IGNORE_JSX = ALL_NODES && context.options[1] && context.options[1].ignoreJSX;
87277 const IGNORE_ARROW_CONDITIONALS = ALL_NODES && context.options[1] && context.options[1].enforceForArrowConditionals === false;
87278 const IGNORE_SEQUENCE_EXPRESSIONS = ALL_NODES && context.options[1] && context.options[1].enforceForSequenceExpressions === false;
87279 const IGNORE_NEW_IN_MEMBER_EXPR = ALL_NODES && context.options[1] && context.options[1].enforceForNewInMemberExpressions === false;
87280 const IGNORE_FUNCTION_PROTOTYPE_METHODS = ALL_NODES && context.options[1] && context.options[1].enforceForFunctionPrototypeMethods === false;
87281 const PRECEDENCE_OF_ASSIGNMENT_EXPR = precedence({
87282 type: "AssignmentExpression"
87283 });
87284 const PRECEDENCE_OF_UPDATE_EXPR = precedence({
87285 type: "UpdateExpression"
87286 });
87287 let reportsBuffer;
87288 /**
87289 * Determines whether the given node is a `call` or `apply` method call, invoked directly on a `FunctionExpression` node.
87290 * Example: function(){}.call()
87291 * @param {ASTNode} node The node to be checked.
87292 * @returns {boolean} True if the node is an immediate `call` or `apply` method call.
87293 * @private
87294 */
87295
87296 function isImmediateFunctionPrototypeMethodCall(node) {
87297 const callNode = astUtils.skipChainExpression(node);
87298
87299 if (callNode.type !== "CallExpression") {
87300 return false;
87301 }
87302
87303 const callee = astUtils.skipChainExpression(callNode.callee);
87304 return callee.type === "MemberExpression" && callee.object.type === "FunctionExpression" && ["call", "apply"].includes(astUtils.getStaticPropertyName(callee));
87305 }
87306 /**
87307 * Determines if this rule should be enforced for a node given the current configuration.
87308 * @param {ASTNode} node The node to be checked.
87309 * @returns {boolean} True if the rule should be enforced for this node.
87310 * @private
87311 */
87312
87313
87314 function ruleApplies(node) {
87315 if (node.type === "JSXElement" || node.type === "JSXFragment") {
87316 const isSingleLine = node.loc.start.line === node.loc.end.line;
87317
87318 switch (IGNORE_JSX) {
87319 // Exclude this JSX element from linting
87320 case "all":
87321 return false;
87322 // Exclude this JSX element if it is multi-line element
87323
87324 case "multi-line":
87325 return isSingleLine;
87326 // Exclude this JSX element if it is single-line element
87327
87328 case "single-line":
87329 return !isSingleLine;
87330 // Nothing special to be done for JSX elements
87331
87332 case "none":
87333 break;
87334 // no default
87335 }
87336 }
87337
87338 if (node.type === "SequenceExpression" && IGNORE_SEQUENCE_EXPRESSIONS) {
87339 return false;
87340 }
87341
87342 if (isImmediateFunctionPrototypeMethodCall(node) && IGNORE_FUNCTION_PROTOTYPE_METHODS) {
87343 return false;
87344 }
87345
87346 return ALL_NODES || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
87347 }
87348 /**
87349 * Determines if a node is surrounded by parentheses.
87350 * @param {ASTNode} node The node to be checked.
87351 * @returns {boolean} True if the node is parenthesised.
87352 * @private
87353 */
87354
87355
87356 function isParenthesised(node) {
87357 return isParenthesizedRaw(1, node, sourceCode);
87358 }
87359 /**
87360 * Determines if a node is surrounded by parentheses twice.
87361 * @param {ASTNode} node The node to be checked.
87362 * @returns {boolean} True if the node is doubly parenthesised.
87363 * @private
87364 */
87365
87366
87367 function isParenthesisedTwice(node) {
87368 return isParenthesizedRaw(2, node, sourceCode);
87369 }
87370 /**
87371 * Determines if a node is surrounded by (potentially) invalid parentheses.
87372 * @param {ASTNode} node The node to be checked.
87373 * @returns {boolean} True if the node is incorrectly parenthesised.
87374 * @private
87375 */
87376
87377
87378 function hasExcessParens(node) {
87379 return ruleApplies(node) && isParenthesised(node);
87380 }
87381 /**
87382 * Determines if a node that is expected to be parenthesised is surrounded by
87383 * (potentially) invalid extra parentheses.
87384 * @param {ASTNode} node The node to be checked.
87385 * @returns {boolean} True if the node is has an unexpected extra pair of parentheses.
87386 * @private
87387 */
87388
87389
87390 function hasDoubleExcessParens(node) {
87391 return ruleApplies(node) && isParenthesisedTwice(node);
87392 }
87393 /**
87394 * Determines if a node that is expected to be parenthesised is surrounded by
87395 * (potentially) invalid extra parentheses with considering precedence level of the node.
87396 * If the preference level of the node is not higher or equal to precedence lower limit, it also checks
87397 * whether the node is surrounded by parentheses twice or not.
87398 * @param {ASTNode} node The node to be checked.
87399 * @param {number} precedenceLowerLimit The lower limit of precedence.
87400 * @returns {boolean} True if the node is has an unexpected extra pair of parentheses.
87401 * @private
87402 */
87403
87404
87405 function hasExcessParensWithPrecedence(node, precedenceLowerLimit) {
87406 if (ruleApplies(node) && isParenthesised(node)) {
87407 if (precedence(node) >= precedenceLowerLimit || isParenthesisedTwice(node)) {
87408 return true;
87409 }
87410 }
87411
87412 return false;
87413 }
87414 /**
87415 * Determines if a node test expression is allowed to have a parenthesised assignment
87416 * @param {ASTNode} node The node to be checked.
87417 * @returns {boolean} True if the assignment can be parenthesised.
87418 * @private
87419 */
87420
87421
87422 function isCondAssignException(node) {
87423 return EXCEPT_COND_ASSIGN && node.test.type === "AssignmentExpression";
87424 }
87425 /**
87426 * Determines if a node is in a return statement
87427 * @param {ASTNode} node The node to be checked.
87428 * @returns {boolean} True if the node is in a return statement.
87429 * @private
87430 */
87431
87432
87433 function isInReturnStatement(node) {
87434 for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
87435 if (currentNode.type === "ReturnStatement" || currentNode.type === "ArrowFunctionExpression" && currentNode.body.type !== "BlockStatement") {
87436 return true;
87437 }
87438 }
87439
87440 return false;
87441 }
87442 /**
87443 * Determines if a constructor function is newed-up with parens
87444 * @param {ASTNode} newExpression The NewExpression node to be checked.
87445 * @returns {boolean} True if the constructor is called with parens.
87446 * @private
87447 */
87448
87449
87450 function isNewExpressionWithParens(newExpression) {
87451 const lastToken = sourceCode.getLastToken(newExpression);
87452 const penultimateToken = sourceCode.getTokenBefore(lastToken);
87453 return newExpression.arguments.length > 0 || // The expression should end with its own parens, e.g., new new foo() is not a new expression with parens
87454 astUtils.isOpeningParenToken(penultimateToken) && astUtils.isClosingParenToken(lastToken) && newExpression.callee.range[1] < newExpression.range[1];
87455 }
87456 /**
87457 * Determines if a node is or contains an assignment expression
87458 * @param {ASTNode} node The node to be checked.
87459 * @returns {boolean} True if the node is or contains an assignment expression.
87460 * @private
87461 */
87462
87463
87464 function containsAssignment(node) {
87465 if (node.type === "AssignmentExpression") {
87466 return true;
87467 }
87468
87469 if (node.type === "ConditionalExpression" && (node.consequent.type === "AssignmentExpression" || node.alternate.type === "AssignmentExpression")) {
87470 return true;
87471 }
87472
87473 if (node.left && node.left.type === "AssignmentExpression" || node.right && node.right.type === "AssignmentExpression") {
87474 return true;
87475 }
87476
87477 return false;
87478 }
87479 /**
87480 * Determines if a node is contained by or is itself a return statement and is allowed to have a parenthesised assignment
87481 * @param {ASTNode} node The node to be checked.
87482 * @returns {boolean} True if the assignment can be parenthesised.
87483 * @private
87484 */
87485
87486
87487 function isReturnAssignException(node) {
87488 if (!EXCEPT_RETURN_ASSIGN || !isInReturnStatement(node)) {
87489 return false;
87490 }
87491
87492 if (node.type === "ReturnStatement") {
87493 return node.argument && containsAssignment(node.argument);
87494 }
87495
87496 if (node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement") {
87497 return containsAssignment(node.body);
87498 }
87499
87500 return containsAssignment(node);
87501 }
87502 /**
87503 * Determines if a node following a [no LineTerminator here] restriction is
87504 * surrounded by (potentially) invalid extra parentheses.
87505 * @param {Token} token The token preceding the [no LineTerminator here] restriction.
87506 * @param {ASTNode} node The node to be checked.
87507 * @returns {boolean} True if the node is incorrectly parenthesised.
87508 * @private
87509 */
87510
87511
87512 function hasExcessParensNoLineTerminator(token, node) {
87513 if (token.loc.end.line === node.loc.start.line) {
87514 return hasExcessParens(node);
87515 }
87516
87517 return hasDoubleExcessParens(node);
87518 }
87519 /**
87520 * Determines whether a node should be preceded by an additional space when removing parens
87521 * @param {ASTNode} node node to evaluate; must be surrounded by parentheses
87522 * @returns {boolean} `true` if a space should be inserted before the node
87523 * @private
87524 */
87525
87526
87527 function requiresLeadingSpace(node) {
87528 const leftParenToken = sourceCode.getTokenBefore(node);
87529 const tokenBeforeLeftParen = sourceCode.getTokenBefore(leftParenToken, {
87530 includeComments: true
87531 });
87532 const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParenToken, {
87533 includeComments: true
87534 });
87535 return tokenBeforeLeftParen && tokenBeforeLeftParen.range[1] === leftParenToken.range[0] && leftParenToken.range[1] === tokenAfterLeftParen.range[0] && !astUtils.canTokensBeAdjacent(tokenBeforeLeftParen, tokenAfterLeftParen);
87536 }
87537 /**
87538 * Determines whether a node should be followed by an additional space when removing parens
87539 * @param {ASTNode} node node to evaluate; must be surrounded by parentheses
87540 * @returns {boolean} `true` if a space should be inserted after the node
87541 * @private
87542 */
87543
87544
87545 function requiresTrailingSpace(node) {
87546 const nextTwoTokens = sourceCode.getTokensAfter(node, {
87547 count: 2
87548 });
87549 const rightParenToken = nextTwoTokens[0];
87550 const tokenAfterRightParen = nextTwoTokens[1];
87551 const tokenBeforeRightParen = sourceCode.getLastToken(node);
87552 return rightParenToken && tokenAfterRightParen && !sourceCode.isSpaceBetweenTokens(rightParenToken, tokenAfterRightParen) && !astUtils.canTokensBeAdjacent(tokenBeforeRightParen, tokenAfterRightParen);
87553 }
87554 /**
87555 * Determines if a given expression node is an IIFE
87556 * @param {ASTNode} node The node to check
87557 * @returns {boolean} `true` if the given node is an IIFE
87558 */
87559
87560
87561 function isIIFE(node) {
87562 const maybeCallNode = astUtils.skipChainExpression(node);
87563 return maybeCallNode.type === "CallExpression" && maybeCallNode.callee.type === "FunctionExpression";
87564 }
87565 /**
87566 * Determines if the given node can be the assignment target in destructuring or the LHS of an assignment.
87567 * This is to avoid an autofix that could change behavior because parsers mistakenly allow invalid syntax,
87568 * such as `(a = b) = c` and `[(a = b) = c] = []`. Ideally, this function shouldn't be necessary.
87569 * @param {ASTNode} [node] The node to check
87570 * @returns {boolean} `true` if the given node can be a valid assignment target
87571 */
87572
87573
87574 function canBeAssignmentTarget(node) {
87575 return node && (node.type === "Identifier" || node.type === "MemberExpression");
87576 }
87577 /**
87578 * Report the node
87579 * @param {ASTNode} node node to evaluate
87580 * @returns {void}
87581 * @private
87582 */
87583
87584
87585 function report(node) {
87586 const leftParenToken = sourceCode.getTokenBefore(node);
87587 const rightParenToken = sourceCode.getTokenAfter(node);
87588
87589 if (!isParenthesisedTwice(node)) {
87590 if (tokensToIgnore.has(sourceCode.getFirstToken(node))) {
87591 return;
87592 }
87593
87594 if (isIIFE(node) && !isParenthesised(node.callee)) {
87595 return;
87596 }
87597 }
87598 /**
87599 * Finishes reporting
87600 * @returns {void}
87601 * @private
87602 */
87603
87604
87605 function finishReport() {
87606 context.report({
87607 node,
87608 loc: leftParenToken.loc,
87609 messageId: "unexpected",
87610
87611 fix(fixer) {
87612 const parenthesizedSource = sourceCode.text.slice(leftParenToken.range[1], rightParenToken.range[0]);
87613 return fixer.replaceTextRange([leftParenToken.range[0], rightParenToken.range[1]], (requiresLeadingSpace(node) ? " " : "") + parenthesizedSource + (requiresTrailingSpace(node) ? " " : ""));
87614 }
87615
87616 });
87617 }
87618
87619 if (reportsBuffer) {
87620 reportsBuffer.reports.push({
87621 node,
87622 finishReport
87623 });
87624 return;
87625 }
87626
87627 finishReport();
87628 }
87629 /**
87630 * Evaluate a argument of the node.
87631 * @param {ASTNode} node node to evaluate
87632 * @returns {void}
87633 * @private
87634 */
87635
87636
87637 function checkArgumentWithPrecedence(node) {
87638 if (hasExcessParensWithPrecedence(node.argument, precedence(node))) {
87639 report(node.argument);
87640 }
87641 }
87642 /**
87643 * Check if a member expression contains a call expression
87644 * @param {ASTNode} node MemberExpression node to evaluate
87645 * @returns {boolean} true if found, false if not
87646 */
87647
87648
87649 function doesMemberExpressionContainCallExpression(node) {
87650 let currentNode = node.object;
87651 let currentNodeType = node.object.type;
87652
87653 while (currentNodeType === "MemberExpression") {
87654 currentNode = currentNode.object;
87655 currentNodeType = currentNode.type;
87656 }
87657
87658 return currentNodeType === "CallExpression";
87659 }
87660 /**
87661 * Evaluate a new call
87662 * @param {ASTNode} node node to evaluate
87663 * @returns {void}
87664 * @private
87665 */
87666
87667
87668 function checkCallNew(node) {
87669 const callee = node.callee;
87670
87671 if (hasExcessParensWithPrecedence(callee, precedence(node))) {
87672 if (hasDoubleExcessParens(callee) || !(isIIFE(node) || // (new A)(); new (new A)();
87673 callee.type === "NewExpression" && !isNewExpressionWithParens(callee) && !(node.type === "NewExpression" && !isNewExpressionWithParens(node)) || // new (a().b)(); new (a.b().c);
87674 node.type === "NewExpression" && callee.type === "MemberExpression" && doesMemberExpressionContainCallExpression(callee) || // (a?.b)(); (a?.())();
87675 !node.optional && callee.type === "ChainExpression")) {
87676 report(node.callee);
87677 }
87678 }
87679
87680 node.arguments.filter(arg => hasExcessParensWithPrecedence(arg, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach(report);
87681 }
87682 /**
87683 * Evaluate binary logicals
87684 * @param {ASTNode} node node to evaluate
87685 * @returns {void}
87686 * @private
87687 */
87688
87689
87690 function checkBinaryLogical(node) {
87691 const prec = precedence(node);
87692 const leftPrecedence = precedence(node.left);
87693 const rightPrecedence = precedence(node.right);
87694 const isExponentiation = node.operator === "**";
87695 const shouldSkipLeft = NESTED_BINARY && (node.left.type === "BinaryExpression" || node.left.type === "LogicalExpression");
87696 const shouldSkipRight = NESTED_BINARY && (node.right.type === "BinaryExpression" || node.right.type === "LogicalExpression");
87697
87698 if (!shouldSkipLeft && hasExcessParens(node.left)) {
87699 if (!(["AwaitExpression", "UnaryExpression"].includes(node.left.type) && isExponentiation) && !astUtils.isMixedLogicalAndCoalesceExpressions(node.left, node) && (leftPrecedence > prec || leftPrecedence === prec && !isExponentiation) || isParenthesisedTwice(node.left)) {
87700 report(node.left);
87701 }
87702 }
87703
87704 if (!shouldSkipRight && hasExcessParens(node.right)) {
87705 if (!astUtils.isMixedLogicalAndCoalesceExpressions(node.right, node) && (rightPrecedence > prec || rightPrecedence === prec && isExponentiation) || isParenthesisedTwice(node.right)) {
87706 report(node.right);
87707 }
87708 }
87709 }
87710 /**
87711 * Check the parentheses around the super class of the given class definition.
87712 * @param {ASTNode} node The node of class declarations to check.
87713 * @returns {void}
87714 */
87715
87716
87717 function checkClass(node) {
87718 if (!node.superClass) {
87719 return;
87720 }
87721 /*
87722 * If `node.superClass` is a LeftHandSideExpression, parentheses are extra.
87723 * Otherwise, parentheses are needed.
87724 */
87725
87726
87727 const hasExtraParens = precedence(node.superClass) > PRECEDENCE_OF_UPDATE_EXPR ? hasExcessParens(node.superClass) : hasDoubleExcessParens(node.superClass);
87728
87729 if (hasExtraParens) {
87730 report(node.superClass);
87731 }
87732 }
87733 /**
87734 * Check the parentheses around the argument of the given spread operator.
87735 * @param {ASTNode} node The node of spread elements/properties to check.
87736 * @returns {void}
87737 */
87738
87739
87740 function checkSpreadOperator(node) {
87741 if (hasExcessParensWithPrecedence(node.argument, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
87742 report(node.argument);
87743 }
87744 }
87745 /**
87746 * Checks the parentheses for an ExpressionStatement or ExportDefaultDeclaration
87747 * @param {ASTNode} node The ExpressionStatement.expression or ExportDefaultDeclaration.declaration node
87748 * @returns {void}
87749 */
87750
87751
87752 function checkExpressionOrExportStatement(node) {
87753 const firstToken = isParenthesised(node) ? sourceCode.getTokenBefore(node) : sourceCode.getFirstToken(node);
87754 const secondToken = sourceCode.getTokenAfter(firstToken, astUtils.isNotOpeningParenToken);
87755 const thirdToken = secondToken ? sourceCode.getTokenAfter(secondToken) : null;
87756 const tokenAfterClosingParens = secondToken ? sourceCode.getTokenAfter(secondToken, astUtils.isNotClosingParenToken) : null;
87757
87758 if (astUtils.isOpeningParenToken(firstToken) && (astUtils.isOpeningBraceToken(secondToken) || secondToken.type === "Keyword" && (secondToken.value === "function" || secondToken.value === "class" || secondToken.value === "let" && tokenAfterClosingParens && (astUtils.isOpeningBracketToken(tokenAfterClosingParens) || tokenAfterClosingParens.type === "Identifier")) || secondToken && secondToken.type === "Identifier" && secondToken.value === "async" && thirdToken && thirdToken.type === "Keyword" && thirdToken.value === "function")) {
87759 tokensToIgnore.add(secondToken);
87760 }
87761
87762 const hasExtraParens = node.parent.type === "ExportDefaultDeclaration" ? hasExcessParensWithPrecedence(node, PRECEDENCE_OF_ASSIGNMENT_EXPR) : hasExcessParens(node);
87763
87764 if (hasExtraParens) {
87765 report(node);
87766 }
87767 }
87768 /**
87769 * Finds the path from the given node to the specified ancestor.
87770 * @param {ASTNode} node First node in the path.
87771 * @param {ASTNode} ancestor Last node in the path.
87772 * @returns {ASTNode[]} Path, including both nodes.
87773 * @throws {Error} If the given node does not have the specified ancestor.
87774 */
87775
87776
87777 function pathToAncestor(node, ancestor) {
87778 const path = [node];
87779 let currentNode = node;
87780
87781 while (currentNode !== ancestor) {
87782 currentNode = currentNode.parent;
87783 /* istanbul ignore if */
87784
87785 if (currentNode === null) {
87786 throw new Error("Nodes are not in the ancestor-descendant relationship.");
87787 }
87788
87789 path.push(currentNode);
87790 }
87791
87792 return path;
87793 }
87794 /**
87795 * Finds the path from the given node to the specified descendant.
87796 * @param {ASTNode} node First node in the path.
87797 * @param {ASTNode} descendant Last node in the path.
87798 * @returns {ASTNode[]} Path, including both nodes.
87799 * @throws {Error} If the given node does not have the specified descendant.
87800 */
87801
87802
87803 function pathToDescendant(node, descendant) {
87804 return pathToAncestor(descendant, node).reverse();
87805 }
87806 /**
87807 * Checks whether the syntax of the given ancestor of an 'in' expression inside a for-loop initializer
87808 * is preventing the 'in' keyword from being interpreted as a part of an ill-formed for-in loop.
87809 * @param {ASTNode} node Ancestor of an 'in' expression.
87810 * @param {ASTNode} child Child of the node, ancestor of the same 'in' expression or the 'in' expression itself.
87811 * @returns {boolean} True if the keyword 'in' would be interpreted as the 'in' operator, without any parenthesis.
87812 */
87813
87814
87815 function isSafelyEnclosingInExpression(node, child) {
87816 switch (node.type) {
87817 case "ArrayExpression":
87818 case "ArrayPattern":
87819 case "BlockStatement":
87820 case "ObjectExpression":
87821 case "ObjectPattern":
87822 case "TemplateLiteral":
87823 return true;
87824
87825 case "ArrowFunctionExpression":
87826 case "FunctionExpression":
87827 return node.params.includes(child);
87828
87829 case "CallExpression":
87830 case "NewExpression":
87831 return node.arguments.includes(child);
87832
87833 case "MemberExpression":
87834 return node.computed && node.property === child;
87835
87836 case "ConditionalExpression":
87837 return node.consequent === child;
87838
87839 default:
87840 return false;
87841 }
87842 }
87843 /**
87844 * Starts a new reports buffering. Warnings will be stored in a buffer instead of being reported immediately.
87845 * An additional logic that requires multiple nodes (e.g. a whole subtree) may dismiss some of the stored warnings.
87846 * @returns {void}
87847 */
87848
87849
87850 function startNewReportsBuffering() {
87851 reportsBuffer = {
87852 upper: reportsBuffer,
87853 inExpressionNodes: [],
87854 reports: []
87855 };
87856 }
87857 /**
87858 * Ends the current reports buffering.
87859 * @returns {void}
87860 */
87861
87862
87863 function endCurrentReportsBuffering() {
87864 const {
87865 upper,
87866 inExpressionNodes,
87867 reports
87868 } = reportsBuffer;
87869
87870 if (upper) {
87871 upper.inExpressionNodes.push(...inExpressionNodes);
87872 upper.reports.push(...reports);
87873 } else {
87874 // flush remaining reports
87875 reports.forEach(_ref => {
87876 let {
87877 finishReport
87878 } = _ref;
87879 return finishReport();
87880 });
87881 }
87882
87883 reportsBuffer = upper;
87884 }
87885 /**
87886 * Checks whether the given node is in the current reports buffer.
87887 * @param {ASTNode} node Node to check.
87888 * @returns {boolean} True if the node is in the current buffer, false otherwise.
87889 */
87890
87891
87892 function isInCurrentReportsBuffer(node) {
87893 return reportsBuffer.reports.some(r => r.node === node);
87894 }
87895 /**
87896 * Removes the given node from the current reports buffer.
87897 * @param {ASTNode} node Node to remove.
87898 * @returns {void}
87899 */
87900
87901
87902 function removeFromCurrentReportsBuffer(node) {
87903 reportsBuffer.reports = reportsBuffer.reports.filter(r => r.node !== node);
87904 }
87905 /**
87906 * Checks whether a node is a MemberExpression at NewExpression's callee.
87907 * @param {ASTNode} node node to check.
87908 * @returns {boolean} True if the node is a MemberExpression at NewExpression's callee. false otherwise.
87909 */
87910
87911
87912 function isMemberExpInNewCallee(node) {
87913 if (node.type === "MemberExpression") {
87914 return node.parent.type === "NewExpression" && node.parent.callee === node ? true : node.parent.object === node && isMemberExpInNewCallee(node.parent);
87915 }
87916
87917 return false;
87918 }
87919
87920 return {
87921 ArrayExpression(node) {
87922 node.elements.filter(e => e && hasExcessParensWithPrecedence(e, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach(report);
87923 },
87924
87925 ArrayPattern(node) {
87926 node.elements.filter(e => canBeAssignmentTarget(e) && hasExcessParens(e)).forEach(report);
87927 },
87928
87929 ArrowFunctionExpression(node) {
87930 if (isReturnAssignException(node)) {
87931 return;
87932 }
87933
87934 if (node.body.type === "ConditionalExpression" && IGNORE_ARROW_CONDITIONALS) {
87935 return;
87936 }
87937
87938 if (node.body.type !== "BlockStatement") {
87939 const firstBodyToken = sourceCode.getFirstToken(node.body, astUtils.isNotOpeningParenToken);
87940 const tokenBeforeFirst = sourceCode.getTokenBefore(firstBodyToken);
87941
87942 if (astUtils.isOpeningParenToken(tokenBeforeFirst) && astUtils.isOpeningBraceToken(firstBodyToken)) {
87943 tokensToIgnore.add(firstBodyToken);
87944 }
87945
87946 if (hasExcessParensWithPrecedence(node.body, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
87947 report(node.body);
87948 }
87949 }
87950 },
87951
87952 AssignmentExpression(node) {
87953 if (canBeAssignmentTarget(node.left) && hasExcessParens(node.left)) {
87954 report(node.left);
87955 }
87956
87957 if (!isReturnAssignException(node) && hasExcessParensWithPrecedence(node.right, precedence(node))) {
87958 report(node.right);
87959 }
87960 },
87961
87962 BinaryExpression(node) {
87963 if (reportsBuffer && node.operator === "in") {
87964 reportsBuffer.inExpressionNodes.push(node);
87965 }
87966
87967 checkBinaryLogical(node);
87968 },
87969
87970 CallExpression: checkCallNew,
87971
87972 ConditionalExpression(node) {
87973 if (isReturnAssignException(node)) {
87974 return;
87975 }
87976
87977 if (!isCondAssignException(node) && hasExcessParensWithPrecedence(node.test, precedence({
87978 type: "LogicalExpression",
87979 operator: "||"
87980 }))) {
87981 report(node.test);
87982 }
87983
87984 if (hasExcessParensWithPrecedence(node.consequent, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
87985 report(node.consequent);
87986 }
87987
87988 if (hasExcessParensWithPrecedence(node.alternate, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
87989 report(node.alternate);
87990 }
87991 },
87992
87993 DoWhileStatement(node) {
87994 if (hasExcessParens(node.test) && !isCondAssignException(node)) {
87995 report(node.test);
87996 }
87997 },
87998
87999 ExportDefaultDeclaration: node => checkExpressionOrExportStatement(node.declaration),
88000 ExpressionStatement: node => checkExpressionOrExportStatement(node.expression),
88001
88002 ForInStatement(node) {
88003 if (node.left.type !== "VariableDeclaration") {
88004 const firstLeftToken = sourceCode.getFirstToken(node.left, astUtils.isNotOpeningParenToken);
88005
88006 if (firstLeftToken.value === "let" && astUtils.isOpeningBracketToken(sourceCode.getTokenAfter(firstLeftToken, astUtils.isNotClosingParenToken))) {
88007 // ForInStatement#left expression cannot start with `let[`.
88008 tokensToIgnore.add(firstLeftToken);
88009 }
88010 }
88011
88012 if (hasExcessParens(node.left)) {
88013 report(node.left);
88014 }
88015
88016 if (hasExcessParens(node.right)) {
88017 report(node.right);
88018 }
88019 },
88020
88021 ForOfStatement(node) {
88022 if (node.left.type !== "VariableDeclaration") {
88023 const firstLeftToken = sourceCode.getFirstToken(node.left, astUtils.isNotOpeningParenToken);
88024
88025 if (firstLeftToken.value === "let") {
88026 // ForOfStatement#left expression cannot start with `let`.
88027 tokensToIgnore.add(firstLeftToken);
88028 }
88029 }
88030
88031 if (hasExcessParens(node.left)) {
88032 report(node.left);
88033 }
88034
88035 if (hasExcessParensWithPrecedence(node.right, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
88036 report(node.right);
88037 }
88038 },
88039
88040 ForStatement(node) {
88041 if (node.test && hasExcessParens(node.test) && !isCondAssignException(node)) {
88042 report(node.test);
88043 }
88044
88045 if (node.update && hasExcessParens(node.update)) {
88046 report(node.update);
88047 }
88048
88049 if (node.init) {
88050 if (node.init.type !== "VariableDeclaration") {
88051 const firstToken = sourceCode.getFirstToken(node.init, astUtils.isNotOpeningParenToken);
88052
88053 if (firstToken.value === "let" && astUtils.isOpeningBracketToken(sourceCode.getTokenAfter(firstToken, astUtils.isNotClosingParenToken))) {
88054 // ForStatement#init expression cannot start with `let[`.
88055 tokensToIgnore.add(firstToken);
88056 }
88057 }
88058
88059 startNewReportsBuffering();
88060
88061 if (hasExcessParens(node.init)) {
88062 report(node.init);
88063 }
88064 }
88065 },
88066
88067 "ForStatement > *.init:exit"(node) {
88068 /*
88069 * Removing parentheses around `in` expressions might change semantics and cause errors.
88070 *
88071 * For example, this valid for loop:
88072 * for (let a = (b in c); ;);
88073 * after removing parentheses would be treated as an invalid for-in loop:
88074 * for (let a = b in c; ;);
88075 */
88076 if (reportsBuffer.reports.length) {
88077 reportsBuffer.inExpressionNodes.forEach(inExpressionNode => {
88078 const path = pathToDescendant(node, inExpressionNode);
88079 let nodeToExclude;
88080
88081 for (let i = 0; i < path.length; i++) {
88082 const pathNode = path[i];
88083
88084 if (i < path.length - 1) {
88085 const nextPathNode = path[i + 1];
88086
88087 if (isSafelyEnclosingInExpression(pathNode, nextPathNode)) {
88088 // The 'in' expression in safely enclosed by the syntax of its ancestor nodes (e.g. by '{}' or '[]').
88089 return;
88090 }
88091 }
88092
88093 if (isParenthesised(pathNode)) {
88094 if (isInCurrentReportsBuffer(pathNode)) {
88095 // This node was supposed to be reported, but parentheses might be necessary.
88096 if (isParenthesisedTwice(pathNode)) {
88097 /*
88098 * This node is parenthesised twice, it certainly has at least one pair of `extra` parentheses.
88099 * If the --fix option is on, the current fixing iteration will remove only one pair of parentheses.
88100 * The remaining pair is safely enclosing the 'in' expression.
88101 */
88102 return;
88103 } // Exclude the outermost node only.
88104
88105
88106 if (!nodeToExclude) {
88107 nodeToExclude = pathNode;
88108 } // Don't break the loop here, there might be some safe nodes or parentheses that will stay inside.
88109
88110 } else {
88111 // This node will stay parenthesised, the 'in' expression in safely enclosed by '()'.
88112 return;
88113 }
88114 }
88115 } // Exclude the node from the list (i.e. treat parentheses as necessary)
88116
88117
88118 removeFromCurrentReportsBuffer(nodeToExclude);
88119 });
88120 }
88121
88122 endCurrentReportsBuffering();
88123 },
88124
88125 IfStatement(node) {
88126 if (hasExcessParens(node.test) && !isCondAssignException(node)) {
88127 report(node.test);
88128 }
88129 },
88130
88131 ImportExpression(node) {
88132 const {
88133 source
88134 } = node;
88135
88136 if (source.type === "SequenceExpression") {
88137 if (hasDoubleExcessParens(source)) {
88138 report(source);
88139 }
88140 } else if (hasExcessParens(source)) {
88141 report(source);
88142 }
88143 },
88144
88145 LogicalExpression: checkBinaryLogical,
88146
88147 MemberExpression(node) {
88148 const shouldAllowWrapOnce = isMemberExpInNewCallee(node) && doesMemberExpressionContainCallExpression(node);
88149 const nodeObjHasExcessParens = shouldAllowWrapOnce ? hasDoubleExcessParens(node.object) : hasExcessParens(node.object) && !(isImmediateFunctionPrototypeMethodCall(node.parent) && node.parent.callee === node && IGNORE_FUNCTION_PROTOTYPE_METHODS);
88150
88151 if (nodeObjHasExcessParens && precedence(node.object) >= precedence(node) && (node.computed || !(astUtils.isDecimalInteger(node.object) || // RegExp literal is allowed to have parens (#1589)
88152 node.object.type === "Literal" && node.object.regex))) {
88153 report(node.object);
88154 }
88155
88156 if (nodeObjHasExcessParens && node.object.type === "CallExpression") {
88157 report(node.object);
88158 }
88159
88160 if (nodeObjHasExcessParens && !IGNORE_NEW_IN_MEMBER_EXPR && node.object.type === "NewExpression" && isNewExpressionWithParens(node.object)) {
88161 report(node.object);
88162 }
88163
88164 if (nodeObjHasExcessParens && node.optional && node.object.type === "ChainExpression") {
88165 report(node.object);
88166 }
88167
88168 if (node.computed && hasExcessParens(node.property)) {
88169 report(node.property);
88170 }
88171 },
88172
88173 "MethodDefinition[computed=true]"(node) {
88174 if (hasExcessParensWithPrecedence(node.key, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
88175 report(node.key);
88176 }
88177 },
88178
88179 NewExpression: checkCallNew,
88180
88181 ObjectExpression(node) {
88182 node.properties.filter(property => property.value && hasExcessParensWithPrecedence(property.value, PRECEDENCE_OF_ASSIGNMENT_EXPR)).forEach(property => report(property.value));
88183 },
88184
88185 ObjectPattern(node) {
88186 node.properties.filter(property => {
88187 const value = property.value;
88188 return canBeAssignmentTarget(value) && hasExcessParens(value);
88189 }).forEach(property => report(property.value));
88190 },
88191
88192 Property(node) {
88193 if (node.computed) {
88194 const {
88195 key
88196 } = node;
88197
88198 if (key && hasExcessParensWithPrecedence(key, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
88199 report(key);
88200 }
88201 }
88202 },
88203
88204 PropertyDefinition(node) {
88205 if (node.computed && hasExcessParensWithPrecedence(node.key, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
88206 report(node.key);
88207 }
88208
88209 if (node.value && hasExcessParensWithPrecedence(node.value, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
88210 report(node.value);
88211 }
88212 },
88213
88214 RestElement(node) {
88215 const argument = node.argument;
88216
88217 if (canBeAssignmentTarget(argument) && hasExcessParens(argument)) {
88218 report(argument);
88219 }
88220 },
88221
88222 ReturnStatement(node) {
88223 const returnToken = sourceCode.getFirstToken(node);
88224
88225 if (isReturnAssignException(node)) {
88226 return;
88227 }
88228
88229 if (node.argument && hasExcessParensNoLineTerminator(returnToken, node.argument) && // RegExp literal is allowed to have parens (#1589)
88230 !(node.argument.type === "Literal" && node.argument.regex)) {
88231 report(node.argument);
88232 }
88233 },
88234
88235 SequenceExpression(node) {
88236 const precedenceOfNode = precedence(node);
88237 node.expressions.filter(e => hasExcessParensWithPrecedence(e, precedenceOfNode)).forEach(report);
88238 },
88239
88240 SwitchCase(node) {
88241 if (node.test && hasExcessParens(node.test)) {
88242 report(node.test);
88243 }
88244 },
88245
88246 SwitchStatement(node) {
88247 if (hasExcessParens(node.discriminant)) {
88248 report(node.discriminant);
88249 }
88250 },
88251
88252 ThrowStatement(node) {
88253 const throwToken = sourceCode.getFirstToken(node);
88254
88255 if (hasExcessParensNoLineTerminator(throwToken, node.argument)) {
88256 report(node.argument);
88257 }
88258 },
88259
88260 UnaryExpression: checkArgumentWithPrecedence,
88261
88262 UpdateExpression(node) {
88263 if (node.prefix) {
88264 checkArgumentWithPrecedence(node);
88265 } else {
88266 const {
88267 argument
88268 } = node;
88269 const operatorToken = sourceCode.getLastToken(node);
88270
88271 if (argument.loc.end.line === operatorToken.loc.start.line) {
88272 checkArgumentWithPrecedence(node);
88273 } else {
88274 if (hasDoubleExcessParens(argument)) {
88275 report(argument);
88276 }
88277 }
88278 }
88279 },
88280
88281 AwaitExpression: checkArgumentWithPrecedence,
88282
88283 VariableDeclarator(node) {
88284 if (node.init && hasExcessParensWithPrecedence(node.init, PRECEDENCE_OF_ASSIGNMENT_EXPR) && // RegExp literal is allowed to have parens (#1589)
88285 !(node.init.type === "Literal" && node.init.regex)) {
88286 report(node.init);
88287 }
88288 },
88289
88290 WhileStatement(node) {
88291 if (hasExcessParens(node.test) && !isCondAssignException(node)) {
88292 report(node.test);
88293 }
88294 },
88295
88296 WithStatement(node) {
88297 if (hasExcessParens(node.object)) {
88298 report(node.object);
88299 }
88300 },
88301
88302 YieldExpression(node) {
88303 if (node.argument) {
88304 const yieldToken = sourceCode.getFirstToken(node);
88305
88306 if (precedence(node.argument) >= precedence(node) && hasExcessParensNoLineTerminator(yieldToken, node.argument) || hasDoubleExcessParens(node.argument)) {
88307 report(node.argument);
88308 }
88309 }
88310 },
88311
88312 ClassDeclaration: checkClass,
88313 ClassExpression: checkClass,
88314 SpreadElement: checkSpreadOperator,
88315 SpreadProperty: checkSpreadOperator,
88316 ExperimentalSpreadProperty: checkSpreadOperator,
88317
88318 TemplateLiteral(node) {
88319 node.expressions.filter(e => e && hasExcessParens(e)).forEach(report);
88320 },
88321
88322 AssignmentPattern(node) {
88323 const {
88324 left,
88325 right
88326 } = node;
88327
88328 if (canBeAssignmentTarget(left) && hasExcessParens(left)) {
88329 report(left);
88330 }
88331
88332 if (right && hasExcessParensWithPrecedence(right, PRECEDENCE_OF_ASSIGNMENT_EXPR)) {
88333 report(right);
88334 }
88335 }
88336
88337 };
88338 }
88339
88340 };
88341
88342 /***/ }),
88343 /* 675 */
88344 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
88345
88346 "use strict";
88347 /**
88348 * @fileoverview Rule to flag use of unnecessary semicolons
88349 * @author Nicholas C. Zakas
88350 */
88351 //------------------------------------------------------------------------------
88352 // Requirements
88353 //------------------------------------------------------------------------------
88354
88355 const FixTracker = __webpack_require__(662);
88356
88357 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
88358 // Rule Definition
88359 //------------------------------------------------------------------------------
88360
88361
88362 module.exports = {
88363 meta: {
88364 type: "suggestion",
88365 docs: {
88366 description: "disallow unnecessary semicolons",
88367 recommended: true,
88368 url: "https://eslint.org/docs/rules/no-extra-semi"
88369 },
88370 fixable: "code",
88371 schema: [],
88372 messages: {
88373 unexpected: "Unnecessary semicolon."
88374 }
88375 },
88376
88377 create(context) {
88378 const sourceCode = context.getSourceCode();
88379 /**
88380 * Reports an unnecessary semicolon error.
88381 * @param {Node|Token} nodeOrToken A node or a token to be reported.
88382 * @returns {void}
88383 */
88384
88385 function report(nodeOrToken) {
88386 context.report({
88387 node: nodeOrToken,
88388 messageId: "unexpected",
88389
88390 fix(fixer) {
88391 /*
88392 * Expand the replacement range to include the surrounding
88393 * tokens to avoid conflicting with semi.
88394 * https://github.com/eslint/eslint/issues/7928
88395 */
88396 return new FixTracker(fixer, context.getSourceCode()).retainSurroundingTokens(nodeOrToken).remove(nodeOrToken);
88397 }
88398
88399 });
88400 }
88401 /**
88402 * Checks for a part of a class body.
88403 * This checks tokens from a specified token to a next MethodDefinition or the end of class body.
88404 * @param {Token} firstToken The first token to check.
88405 * @returns {void}
88406 */
88407
88408
88409 function checkForPartOfClassBody(firstToken) {
88410 for (let token = firstToken; token.type === "Punctuator" && !astUtils.isClosingBraceToken(token); token = sourceCode.getTokenAfter(token)) {
88411 if (astUtils.isSemicolonToken(token)) {
88412 report(token);
88413 }
88414 }
88415 }
88416
88417 return {
88418 /**
88419 * Reports this empty statement, except if the parent node is a loop.
88420 * @param {Node} node A EmptyStatement node to be reported.
88421 * @returns {void}
88422 */
88423 EmptyStatement(node) {
88424 const parent = node.parent,
88425 allowedParentTypes = ["ForStatement", "ForInStatement", "ForOfStatement", "WhileStatement", "DoWhileStatement", "IfStatement", "LabeledStatement", "WithStatement"];
88426
88427 if (allowedParentTypes.indexOf(parent.type) === -1) {
88428 report(node);
88429 }
88430 },
88431
88432 /**
88433 * Checks tokens from the head of this class body to the first MethodDefinition or the end of this class body.
88434 * @param {Node} node A ClassBody node to check.
88435 * @returns {void}
88436 */
88437 ClassBody(node) {
88438 checkForPartOfClassBody(sourceCode.getFirstToken(node, 1)); // 0 is `{`.
88439 },
88440
88441 /**
88442 * Checks tokens from this MethodDefinition to the next MethodDefinition or the end of this class body.
88443 * @param {Node} node A MethodDefinition node of the start point.
88444 * @returns {void}
88445 */
88446 "MethodDefinition, PropertyDefinition, StaticBlock"(node) {
88447 checkForPartOfClassBody(sourceCode.getTokenAfter(node));
88448 }
88449
88450 };
88451 }
88452
88453 };
88454
88455 /***/ }),
88456 /* 676 */
88457 /***/ ((module) => {
88458
88459 "use strict";
88460 /**
88461 * @fileoverview Rule to flag fall-through cases in switch statements.
88462 * @author Matt DuVall <http://mattduvall.com/>
88463 */
88464 //------------------------------------------------------------------------------
88465 // Helpers
88466 //------------------------------------------------------------------------------
88467
88468 const DEFAULT_FALLTHROUGH_COMMENT = /falls?\s?through/iu;
88469 /**
88470 * Checks whether or not a given case has a fallthrough comment.
88471 * @param {ASTNode} caseWhichFallsThrough SwitchCase node which falls through.
88472 * @param {ASTNode} subsequentCase The case after caseWhichFallsThrough.
88473 * @param {RuleContext} context A rule context which stores comments.
88474 * @param {RegExp} fallthroughCommentPattern A pattern to match comment to.
88475 * @returns {boolean} `true` if the case has a valid fallthrough comment.
88476 */
88477
88478 function hasFallthroughComment(caseWhichFallsThrough, subsequentCase, context, fallthroughCommentPattern) {
88479 const sourceCode = context.getSourceCode();
88480
88481 if (caseWhichFallsThrough.consequent.length === 1 && caseWhichFallsThrough.consequent[0].type === "BlockStatement") {
88482 const trailingCloseBrace = sourceCode.getLastToken(caseWhichFallsThrough.consequent[0]);
88483 const commentInBlock = sourceCode.getCommentsBefore(trailingCloseBrace).pop();
88484
88485 if (commentInBlock && fallthroughCommentPattern.test(commentInBlock.value)) {
88486 return true;
88487 }
88488 }
88489
88490 const comment = sourceCode.getCommentsBefore(subsequentCase).pop();
88491 return Boolean(comment && fallthroughCommentPattern.test(comment.value));
88492 }
88493 /**
88494 * Checks whether or not a given code path segment is reachable.
88495 * @param {CodePathSegment} segment A CodePathSegment to check.
88496 * @returns {boolean} `true` if the segment is reachable.
88497 */
88498
88499
88500 function isReachable(segment) {
88501 return segment.reachable;
88502 }
88503 /**
88504 * Checks whether a node and a token are separated by blank lines
88505 * @param {ASTNode} node The node to check
88506 * @param {Token} token The token to compare against
88507 * @returns {boolean} `true` if there are blank lines between node and token
88508 */
88509
88510
88511 function hasBlankLinesBetween(node, token) {
88512 return token.loc.start.line > node.loc.end.line + 1;
88513 } //------------------------------------------------------------------------------
88514 // Rule Definition
88515 //------------------------------------------------------------------------------
88516
88517
88518 module.exports = {
88519 meta: {
88520 type: "problem",
88521 docs: {
88522 description: "disallow fallthrough of `case` statements",
88523 recommended: true,
88524 url: "https://eslint.org/docs/rules/no-fallthrough"
88525 },
88526 schema: [{
88527 type: "object",
88528 properties: {
88529 commentPattern: {
88530 type: "string",
88531 default: ""
88532 }
88533 },
88534 additionalProperties: false
88535 }],
88536 messages: {
88537 case: "Expected a 'break' statement before 'case'.",
88538 default: "Expected a 'break' statement before 'default'."
88539 }
88540 },
88541
88542 create(context) {
88543 const options = context.options[0] || {};
88544 let currentCodePath = null;
88545 const sourceCode = context.getSourceCode();
88546 /*
88547 * We need to use leading comments of the next SwitchCase node because
88548 * trailing comments is wrong if semicolons are omitted.
88549 */
88550
88551 let fallthroughCase = null;
88552 let fallthroughCommentPattern = null;
88553
88554 if (options.commentPattern) {
88555 fallthroughCommentPattern = new RegExp(options.commentPattern, "u");
88556 } else {
88557 fallthroughCommentPattern = DEFAULT_FALLTHROUGH_COMMENT;
88558 }
88559
88560 return {
88561 onCodePathStart(codePath) {
88562 currentCodePath = codePath;
88563 },
88564
88565 onCodePathEnd() {
88566 currentCodePath = currentCodePath.upper;
88567 },
88568
88569 SwitchCase(node) {
88570 /*
88571 * Checks whether or not there is a fallthrough comment.
88572 * And reports the previous fallthrough node if that does not exist.
88573 */
88574 if (fallthroughCase && !hasFallthroughComment(fallthroughCase, node, context, fallthroughCommentPattern)) {
88575 context.report({
88576 messageId: node.test ? "case" : "default",
88577 node
88578 });
88579 }
88580
88581 fallthroughCase = null;
88582 },
88583
88584 "SwitchCase:exit"(node) {
88585 const nextToken = sourceCode.getTokenAfter(node);
88586 /*
88587 * `reachable` meant fall through because statements preceded by
88588 * `break`, `return`, or `throw` are unreachable.
88589 * And allows empty cases and the last case.
88590 */
88591
88592 if (currentCodePath.currentSegments.some(isReachable) && (node.consequent.length > 0 || hasBlankLinesBetween(node, nextToken)) && node.parent.cases[node.parent.cases.length - 1] !== node) {
88593 fallthroughCase = node;
88594 }
88595 }
88596
88597 };
88598 }
88599
88600 };
88601
88602 /***/ }),
88603 /* 677 */
88604 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
88605
88606 "use strict";
88607 /**
88608 * @fileoverview Rule to flag use of a leading/trailing decimal point in a numeric literal
88609 * @author James Allardice
88610 */
88611 //------------------------------------------------------------------------------
88612 // Requirements
88613 //------------------------------------------------------------------------------
88614
88615 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
88616 // Rule Definition
88617 //------------------------------------------------------------------------------
88618
88619
88620 module.exports = {
88621 meta: {
88622 type: "suggestion",
88623 docs: {
88624 description: "disallow leading or trailing decimal points in numeric literals",
88625 recommended: false,
88626 url: "https://eslint.org/docs/rules/no-floating-decimal"
88627 },
88628 schema: [],
88629 fixable: "code",
88630 messages: {
88631 leading: "A leading decimal point can be confused with a dot.",
88632 trailing: "A trailing decimal point can be confused with a dot."
88633 }
88634 },
88635
88636 create(context) {
88637 const sourceCode = context.getSourceCode();
88638 return {
88639 Literal(node) {
88640 if (typeof node.value === "number") {
88641 if (node.raw.startsWith(".")) {
88642 context.report({
88643 node,
88644 messageId: "leading",
88645
88646 fix(fixer) {
88647 const tokenBefore = sourceCode.getTokenBefore(node);
88648 const needsSpaceBefore = tokenBefore && tokenBefore.range[1] === node.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, "0".concat(node.raw));
88649 return fixer.insertTextBefore(node, needsSpaceBefore ? " 0" : "0");
88650 }
88651
88652 });
88653 }
88654
88655 if (node.raw.indexOf(".") === node.raw.length - 1) {
88656 context.report({
88657 node,
88658 messageId: "trailing",
88659 fix: fixer => fixer.insertTextAfter(node, "0")
88660 });
88661 }
88662 }
88663 }
88664
88665 };
88666 }
88667
88668 };
88669
88670 /***/ }),
88671 /* 678 */
88672 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
88673
88674 "use strict";
88675 /**
88676 * @fileoverview Rule to flag use of function declaration identifiers as variables.
88677 * @author Ian Christian Myers
88678 */
88679
88680
88681 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
88682 // Rule Definition
88683 //------------------------------------------------------------------------------
88684
88685
88686 module.exports = {
88687 meta: {
88688 type: "problem",
88689 docs: {
88690 description: "disallow reassigning `function` declarations",
88691 recommended: true,
88692 url: "https://eslint.org/docs/rules/no-func-assign"
88693 },
88694 schema: [],
88695 messages: {
88696 isAFunction: "'{{name}}' is a function."
88697 }
88698 },
88699
88700 create(context) {
88701 /**
88702 * Reports a reference if is non initializer and writable.
88703 * @param {References} references Collection of reference to check.
88704 * @returns {void}
88705 */
88706 function checkReference(references) {
88707 astUtils.getModifyingReferences(references).forEach(reference => {
88708 context.report({
88709 node: reference.identifier,
88710 messageId: "isAFunction",
88711 data: {
88712 name: reference.identifier.name
88713 }
88714 });
88715 });
88716 }
88717 /**
88718 * Finds and reports references that are non initializer and writable.
88719 * @param {Variable} variable A variable to check.
88720 * @returns {void}
88721 */
88722
88723
88724 function checkVariable(variable) {
88725 if (variable.defs[0].type === "FunctionName") {
88726 checkReference(variable.references);
88727 }
88728 }
88729 /**
88730 * Checks parameters of a given function node.
88731 * @param {ASTNode} node A function node to check.
88732 * @returns {void}
88733 */
88734
88735
88736 function checkForFunction(node) {
88737 context.getDeclaredVariables(node).forEach(checkVariable);
88738 }
88739
88740 return {
88741 FunctionDeclaration: checkForFunction,
88742 FunctionExpression: checkForFunction
88743 };
88744 }
88745
88746 };
88747
88748 /***/ }),
88749 /* 679 */
88750 /***/ ((module) => {
88751
88752 "use strict";
88753 /**
88754 * @fileoverview Rule to disallow assignments to native objects or read-only global variables
88755 * @author Ilya Volodin
88756 */
88757 //------------------------------------------------------------------------------
88758 // Rule Definition
88759 //------------------------------------------------------------------------------
88760
88761 module.exports = {
88762 meta: {
88763 type: "suggestion",
88764 docs: {
88765 description: "disallow assignments to native objects or read-only global variables",
88766 recommended: true,
88767 url: "https://eslint.org/docs/rules/no-global-assign"
88768 },
88769 schema: [{
88770 type: "object",
88771 properties: {
88772 exceptions: {
88773 type: "array",
88774 items: {
88775 type: "string"
88776 },
88777 uniqueItems: true
88778 }
88779 },
88780 additionalProperties: false
88781 }],
88782 messages: {
88783 globalShouldNotBeModified: "Read-only global '{{name}}' should not be modified."
88784 }
88785 },
88786
88787 create(context) {
88788 const config = context.options[0];
88789 const exceptions = config && config.exceptions || [];
88790 /**
88791 * Reports write references.
88792 * @param {Reference} reference A reference to check.
88793 * @param {int} index The index of the reference in the references.
88794 * @param {Reference[]} references The array that the reference belongs to.
88795 * @returns {void}
88796 */
88797
88798 function checkReference(reference, index, references) {
88799 const identifier = reference.identifier;
88800
88801 if (reference.init === false && reference.isWrite() && (
88802 /*
88803 * Destructuring assignments can have multiple default value,
88804 * so possibly there are multiple writeable references for the same identifier.
88805 */
88806 index === 0 || references[index - 1].identifier !== identifier)) {
88807 context.report({
88808 node: identifier,
88809 messageId: "globalShouldNotBeModified",
88810 data: {
88811 name: identifier.name
88812 }
88813 });
88814 }
88815 }
88816 /**
88817 * Reports write references if a given variable is read-only builtin.
88818 * @param {Variable} variable A variable to check.
88819 * @returns {void}
88820 */
88821
88822
88823 function checkVariable(variable) {
88824 if (variable.writeable === false && exceptions.indexOf(variable.name) === -1) {
88825 variable.references.forEach(checkReference);
88826 }
88827 }
88828
88829 return {
88830 Program() {
88831 const globalScope = context.getScope();
88832 globalScope.variables.forEach(checkVariable);
88833 }
88834
88835 };
88836 }
88837
88838 };
88839
88840 /***/ }),
88841 /* 680 */
88842 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
88843
88844 "use strict";
88845 /**
88846 * @fileoverview A rule to disallow the type conversions with shorter notations.
88847 * @author Toru Nagashima
88848 */
88849
88850
88851 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
88852 // Helpers
88853 //------------------------------------------------------------------------------
88854
88855
88856 const INDEX_OF_PATTERN = /^(?:i|lastI)ndexOf$/u;
88857 const ALLOWABLE_OPERATORS = ["~", "!!", "+", "*"];
88858 /**
88859 * Parses and normalizes an option object.
88860 * @param {Object} options An option object to parse.
88861 * @returns {Object} The parsed and normalized option object.
88862 */
88863
88864 function parseOptions(options) {
88865 return {
88866 boolean: "boolean" in options ? options.boolean : true,
88867 number: "number" in options ? options.number : true,
88868 string: "string" in options ? options.string : true,
88869 disallowTemplateShorthand: "disallowTemplateShorthand" in options ? options.disallowTemplateShorthand : false,
88870 allow: options.allow || []
88871 };
88872 }
88873 /**
88874 * Checks whether or not a node is a double logical nigating.
88875 * @param {ASTNode} node An UnaryExpression node to check.
88876 * @returns {boolean} Whether or not the node is a double logical nigating.
88877 */
88878
88879
88880 function isDoubleLogicalNegating(node) {
88881 return node.operator === "!" && node.argument.type === "UnaryExpression" && node.argument.operator === "!";
88882 }
88883 /**
88884 * Checks whether or not a node is a binary negating of `.indexOf()` method calling.
88885 * @param {ASTNode} node An UnaryExpression node to check.
88886 * @returns {boolean} Whether or not the node is a binary negating of `.indexOf()` method calling.
88887 */
88888
88889
88890 function isBinaryNegatingOfIndexOf(node) {
88891 if (node.operator !== "~") {
88892 return false;
88893 }
88894
88895 const callNode = astUtils.skipChainExpression(node.argument);
88896 return callNode.type === "CallExpression" && astUtils.isSpecificMemberAccess(callNode.callee, null, INDEX_OF_PATTERN);
88897 }
88898 /**
88899 * Checks whether or not a node is a multiplying by one.
88900 * @param {BinaryExpression} node A BinaryExpression node to check.
88901 * @returns {boolean} Whether or not the node is a multiplying by one.
88902 */
88903
88904
88905 function isMultiplyByOne(node) {
88906 return node.operator === "*" && (node.left.type === "Literal" && node.left.value === 1 || node.right.type === "Literal" && node.right.value === 1);
88907 }
88908 /**
88909 * Checks whether the result of a node is numeric or not
88910 * @param {ASTNode} node The node to test
88911 * @returns {boolean} true if the node is a number literal or a `Number()`, `parseInt` or `parseFloat` call
88912 */
88913
88914
88915 function isNumeric(node) {
88916 return node.type === "Literal" && typeof node.value === "number" || node.type === "CallExpression" && (node.callee.name === "Number" || node.callee.name === "parseInt" || node.callee.name === "parseFloat");
88917 }
88918 /**
88919 * Returns the first non-numeric operand in a BinaryExpression. Designed to be
88920 * used from bottom to up since it walks up the BinaryExpression trees using
88921 * node.parent to find the result.
88922 * @param {BinaryExpression} node The BinaryExpression node to be walked up on
88923 * @returns {ASTNode|null} The first non-numeric item in the BinaryExpression tree or null
88924 */
88925
88926
88927 function getNonNumericOperand(node) {
88928 const left = node.left,
88929 right = node.right;
88930
88931 if (right.type !== "BinaryExpression" && !isNumeric(right)) {
88932 return right;
88933 }
88934
88935 if (left.type !== "BinaryExpression" && !isNumeric(left)) {
88936 return left;
88937 }
88938
88939 return null;
88940 }
88941 /**
88942 * Checks whether an expression evaluates to a string.
88943 * @param {ASTNode} node node that represents the expression to check.
88944 * @returns {boolean} Whether or not the expression evaluates to a string.
88945 */
88946
88947
88948 function isStringType(node) {
88949 return astUtils.isStringLiteral(node) || node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "String";
88950 }
88951 /**
88952 * Checks whether a node is an empty string literal or not.
88953 * @param {ASTNode} node The node to check.
88954 * @returns {boolean} Whether or not the passed in node is an
88955 * empty string literal or not.
88956 */
88957
88958
88959 function isEmptyString(node) {
88960 return astUtils.isStringLiteral(node) && (node.value === "" || node.type === "TemplateLiteral" && node.quasis.length === 1 && node.quasis[0].value.cooked === "");
88961 }
88962 /**
88963 * Checks whether or not a node is a concatenating with an empty string.
88964 * @param {ASTNode} node A BinaryExpression node to check.
88965 * @returns {boolean} Whether or not the node is a concatenating with an empty string.
88966 */
88967
88968
88969 function isConcatWithEmptyString(node) {
88970 return node.operator === "+" && (isEmptyString(node.left) && !isStringType(node.right) || isEmptyString(node.right) && !isStringType(node.left));
88971 }
88972 /**
88973 * Checks whether or not a node is appended with an empty string.
88974 * @param {ASTNode} node An AssignmentExpression node to check.
88975 * @returns {boolean} Whether or not the node is appended with an empty string.
88976 */
88977
88978
88979 function isAppendEmptyString(node) {
88980 return node.operator === "+=" && isEmptyString(node.right);
88981 }
88982 /**
88983 * Returns the operand that is not an empty string from a flagged BinaryExpression.
88984 * @param {ASTNode} node The flagged BinaryExpression node to check.
88985 * @returns {ASTNode} The operand that is not an empty string from a flagged BinaryExpression.
88986 */
88987
88988
88989 function getNonEmptyOperand(node) {
88990 return isEmptyString(node.left) ? node.right : node.left;
88991 } //------------------------------------------------------------------------------
88992 // Rule Definition
88993 //------------------------------------------------------------------------------
88994
88995
88996 module.exports = {
88997 meta: {
88998 type: "suggestion",
88999 docs: {
89000 description: "disallow shorthand type conversions",
89001 recommended: false,
89002 url: "https://eslint.org/docs/rules/no-implicit-coercion"
89003 },
89004 fixable: "code",
89005 schema: [{
89006 type: "object",
89007 properties: {
89008 boolean: {
89009 type: "boolean",
89010 default: true
89011 },
89012 number: {
89013 type: "boolean",
89014 default: true
89015 },
89016 string: {
89017 type: "boolean",
89018 default: true
89019 },
89020 disallowTemplateShorthand: {
89021 type: "boolean",
89022 default: false
89023 },
89024 allow: {
89025 type: "array",
89026 items: {
89027 enum: ALLOWABLE_OPERATORS
89028 },
89029 uniqueItems: true
89030 }
89031 },
89032 additionalProperties: false
89033 }],
89034 messages: {
89035 useRecommendation: "use `{{recommendation}}` instead."
89036 }
89037 },
89038
89039 create(context) {
89040 const options = parseOptions(context.options[0] || {});
89041 const sourceCode = context.getSourceCode();
89042 /**
89043 * Reports an error and autofixes the node
89044 * @param {ASTNode} node An ast node to report the error on.
89045 * @param {string} recommendation The recommended code for the issue
89046 * @param {bool} shouldFix Whether this report should fix the node
89047 * @returns {void}
89048 */
89049
89050 function report(node, recommendation, shouldFix) {
89051 context.report({
89052 node,
89053 messageId: "useRecommendation",
89054 data: {
89055 recommendation
89056 },
89057
89058 fix(fixer) {
89059 if (!shouldFix) {
89060 return null;
89061 }
89062
89063 const tokenBefore = sourceCode.getTokenBefore(node);
89064
89065 if (tokenBefore && tokenBefore.range[1] === node.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, recommendation)) {
89066 return fixer.replaceText(node, " ".concat(recommendation));
89067 }
89068
89069 return fixer.replaceText(node, recommendation);
89070 }
89071
89072 });
89073 }
89074
89075 return {
89076 UnaryExpression(node) {
89077 let operatorAllowed; // !!foo
89078
89079 operatorAllowed = options.allow.indexOf("!!") >= 0;
89080
89081 if (!operatorAllowed && options.boolean && isDoubleLogicalNegating(node)) {
89082 const recommendation = "Boolean(".concat(sourceCode.getText(node.argument.argument), ")");
89083 report(node, recommendation, true);
89084 } // ~foo.indexOf(bar)
89085
89086
89087 operatorAllowed = options.allow.indexOf("~") >= 0;
89088
89089 if (!operatorAllowed && options.boolean && isBinaryNegatingOfIndexOf(node)) {
89090 // `foo?.indexOf(bar) !== -1` will be true (== found) if the `foo` is nullish. So use `>= 0` in that case.
89091 const comparison = node.argument.type === "ChainExpression" ? ">= 0" : "!== -1";
89092 const recommendation = "".concat(sourceCode.getText(node.argument), " ").concat(comparison);
89093 report(node, recommendation, false);
89094 } // +foo
89095
89096
89097 operatorAllowed = options.allow.indexOf("+") >= 0;
89098
89099 if (!operatorAllowed && options.number && node.operator === "+" && !isNumeric(node.argument)) {
89100 const recommendation = "Number(".concat(sourceCode.getText(node.argument), ")");
89101 report(node, recommendation, true);
89102 }
89103 },
89104
89105 // Use `:exit` to prevent double reporting
89106 "BinaryExpression:exit"(node) {
89107 let operatorAllowed; // 1 * foo
89108
89109 operatorAllowed = options.allow.indexOf("*") >= 0;
89110 const nonNumericOperand = !operatorAllowed && options.number && isMultiplyByOne(node) && getNonNumericOperand(node);
89111
89112 if (nonNumericOperand) {
89113 const recommendation = "Number(".concat(sourceCode.getText(nonNumericOperand), ")");
89114 report(node, recommendation, true);
89115 } // "" + foo
89116
89117
89118 operatorAllowed = options.allow.indexOf("+") >= 0;
89119
89120 if (!operatorAllowed && options.string && isConcatWithEmptyString(node)) {
89121 const recommendation = "String(".concat(sourceCode.getText(getNonEmptyOperand(node)), ")");
89122 report(node, recommendation, true);
89123 }
89124 },
89125
89126 AssignmentExpression(node) {
89127 // foo += ""
89128 const operatorAllowed = options.allow.indexOf("+") >= 0;
89129
89130 if (!operatorAllowed && options.string && isAppendEmptyString(node)) {
89131 const code = sourceCode.getText(getNonEmptyOperand(node));
89132 const recommendation = "".concat(code, " = String(").concat(code, ")");
89133 report(node, recommendation, true);
89134 }
89135 },
89136
89137 TemplateLiteral(node) {
89138 if (!options.disallowTemplateShorthand) {
89139 return;
89140 } // tag`${foo}`
89141
89142
89143 if (node.parent.type === "TaggedTemplateExpression") {
89144 return;
89145 } // `` or `${foo}${bar}`
89146
89147
89148 if (node.expressions.length !== 1) {
89149 return;
89150 } // `prefix${foo}`
89151
89152
89153 if (node.quasis[0].value.cooked !== "") {
89154 return;
89155 } // `${foo}postfix`
89156
89157
89158 if (node.quasis[1].value.cooked !== "") {
89159 return;
89160 } // if the expression is already a string, then this isn't a coercion
89161
89162
89163 if (isStringType(node.expressions[0])) {
89164 return;
89165 }
89166
89167 const code = sourceCode.getText(node.expressions[0]);
89168 const recommendation = "String(".concat(code, ")");
89169 report(node, recommendation, true);
89170 }
89171
89172 };
89173 }
89174
89175 };
89176
89177 /***/ }),
89178 /* 681 */
89179 /***/ ((module) => {
89180
89181 "use strict";
89182 /**
89183 * @fileoverview Rule to check for implicit global variables, functions and classes.
89184 * @author Joshua Peek
89185 */
89186 //------------------------------------------------------------------------------
89187 // Rule Definition
89188 //------------------------------------------------------------------------------
89189
89190 module.exports = {
89191 meta: {
89192 type: "suggestion",
89193 docs: {
89194 description: "disallow declarations in the global scope",
89195 recommended: false,
89196 url: "https://eslint.org/docs/rules/no-implicit-globals"
89197 },
89198 schema: [{
89199 type: "object",
89200 properties: {
89201 lexicalBindings: {
89202 type: "boolean",
89203 default: false
89204 }
89205 },
89206 additionalProperties: false
89207 }],
89208 messages: {
89209 globalNonLexicalBinding: "Unexpected {{kind}} declaration in the global scope, wrap in an IIFE for a local variable, assign as global property for a global variable.",
89210 globalLexicalBinding: "Unexpected {{kind}} declaration in the global scope, wrap in a block or in an IIFE.",
89211 globalVariableLeak: "Global variable leak, declare the variable if it is intended to be local.",
89212 assignmentToReadonlyGlobal: "Unexpected assignment to read-only global variable.",
89213 redeclarationOfReadonlyGlobal: "Unexpected redeclaration of read-only global variable."
89214 }
89215 },
89216
89217 create(context) {
89218 const checkLexicalBindings = context.options[0] && context.options[0].lexicalBindings === true;
89219 /**
89220 * Reports the node.
89221 * @param {ASTNode} node Node to report.
89222 * @param {string} messageId Id of the message to report.
89223 * @param {string|undefined} kind Declaration kind, can be 'var', 'const', 'let', function or class.
89224 * @returns {void}
89225 */
89226
89227 function report(node, messageId, kind) {
89228 context.report({
89229 node,
89230 messageId,
89231 data: {
89232 kind
89233 }
89234 });
89235 }
89236
89237 return {
89238 Program() {
89239 const scope = context.getScope();
89240 scope.variables.forEach(variable => {
89241 // Only ESLint global variables have the `writable` key.
89242 const isReadonlyEslintGlobalVariable = variable.writeable === false;
89243 const isWritableEslintGlobalVariable = variable.writeable === true;
89244
89245 if (isWritableEslintGlobalVariable) {
89246 // Everything is allowed with writable ESLint global variables.
89247 return;
89248 }
89249
89250 variable.defs.forEach(def => {
89251 const defNode = def.node;
89252
89253 if (def.type === "FunctionName" || def.type === "Variable" && def.parent.kind === "var") {
89254 if (isReadonlyEslintGlobalVariable) {
89255 report(defNode, "redeclarationOfReadonlyGlobal");
89256 } else {
89257 report(defNode, "globalNonLexicalBinding", def.type === "FunctionName" ? "function" : "'".concat(def.parent.kind, "'"));
89258 }
89259 }
89260
89261 if (checkLexicalBindings) {
89262 if (def.type === "ClassName" || def.type === "Variable" && (def.parent.kind === "let" || def.parent.kind === "const")) {
89263 if (isReadonlyEslintGlobalVariable) {
89264 report(defNode, "redeclarationOfReadonlyGlobal");
89265 } else {
89266 report(defNode, "globalLexicalBinding", def.type === "ClassName" ? "class" : "'".concat(def.parent.kind, "'"));
89267 }
89268 }
89269 }
89270 });
89271 }); // Undeclared assigned variables.
89272
89273 scope.implicit.variables.forEach(variable => {
89274 const scopeVariable = scope.set.get(variable.name);
89275 let messageId;
89276
89277 if (scopeVariable) {
89278 // ESLint global variable
89279 if (scopeVariable.writeable) {
89280 return;
89281 }
89282
89283 messageId = "assignmentToReadonlyGlobal";
89284 } else {
89285 // Reference to an unknown variable, possible global leak.
89286 messageId = "globalVariableLeak";
89287 } // def.node is an AssignmentExpression, ForInStatement or ForOfStatement.
89288
89289
89290 variable.defs.forEach(def => {
89291 report(def.node, messageId);
89292 });
89293 });
89294 }
89295
89296 };
89297 }
89298
89299 };
89300
89301 /***/ }),
89302 /* 682 */
89303 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
89304
89305 "use strict";
89306 /**
89307 * @fileoverview Rule to flag use of implied eval via setTimeout and setInterval
89308 * @author James Allardice
89309 */
89310 //------------------------------------------------------------------------------
89311 // Requirements
89312 //------------------------------------------------------------------------------
89313
89314 const astUtils = __webpack_require__(548);
89315
89316 const {
89317 getStaticValue
89318 } = __webpack_require__(501); //------------------------------------------------------------------------------
89319 // Rule Definition
89320 //------------------------------------------------------------------------------
89321
89322
89323 module.exports = {
89324 meta: {
89325 type: "suggestion",
89326 docs: {
89327 description: "disallow the use of `eval()`-like methods",
89328 recommended: false,
89329 url: "https://eslint.org/docs/rules/no-implied-eval"
89330 },
89331 schema: [],
89332 messages: {
89333 impliedEval: "Implied eval. Consider passing a function instead of a string."
89334 }
89335 },
89336
89337 create(context) {
89338 const GLOBAL_CANDIDATES = Object.freeze(["global", "window", "globalThis"]);
89339 const EVAL_LIKE_FUNC_PATTERN = /^(?:set(?:Interval|Timeout)|execScript)$/u;
89340 /**
89341 * Checks whether a node is evaluated as a string or not.
89342 * @param {ASTNode} node A node to check.
89343 * @returns {boolean} True if the node is evaluated as a string.
89344 */
89345
89346 function isEvaluatedString(node) {
89347 if (node.type === "Literal" && typeof node.value === "string" || node.type === "TemplateLiteral") {
89348 return true;
89349 }
89350
89351 if (node.type === "BinaryExpression" && node.operator === "+") {
89352 return isEvaluatedString(node.left) || isEvaluatedString(node.right);
89353 }
89354
89355 return false;
89356 }
89357 /**
89358 * Reports if the `CallExpression` node has evaluated argument.
89359 * @param {ASTNode} node A CallExpression to check.
89360 * @returns {void}
89361 */
89362
89363
89364 function reportImpliedEvalCallExpression(node) {
89365 const [firstArgument] = node.arguments;
89366
89367 if (firstArgument) {
89368 const staticValue = getStaticValue(firstArgument, context.getScope());
89369 const isStaticString = staticValue && typeof staticValue.value === "string";
89370 const isString = isStaticString || isEvaluatedString(firstArgument);
89371
89372 if (isString) {
89373 context.report({
89374 node,
89375 messageId: "impliedEval"
89376 });
89377 }
89378 }
89379 }
89380 /**
89381 * Reports calls of `implied eval` via the global references.
89382 * @param {Variable} globalVar A global variable to check.
89383 * @returns {void}
89384 */
89385
89386
89387 function reportImpliedEvalViaGlobal(globalVar) {
89388 const {
89389 references,
89390 name
89391 } = globalVar;
89392 references.forEach(ref => {
89393 const identifier = ref.identifier;
89394 let node = identifier.parent;
89395
89396 while (astUtils.isSpecificMemberAccess(node, null, name)) {
89397 node = node.parent;
89398 }
89399
89400 if (astUtils.isSpecificMemberAccess(node, null, EVAL_LIKE_FUNC_PATTERN)) {
89401 const calleeNode = node.parent.type === "ChainExpression" ? node.parent : node;
89402 const parent = calleeNode.parent;
89403
89404 if (parent.type === "CallExpression" && parent.callee === calleeNode) {
89405 reportImpliedEvalCallExpression(parent);
89406 }
89407 }
89408 });
89409 } //--------------------------------------------------------------------------
89410 // Public
89411 //--------------------------------------------------------------------------
89412
89413
89414 return {
89415 CallExpression(node) {
89416 if (astUtils.isSpecificId(node.callee, EVAL_LIKE_FUNC_PATTERN)) {
89417 reportImpliedEvalCallExpression(node);
89418 }
89419 },
89420
89421 "Program:exit"() {
89422 const globalScope = context.getScope();
89423 GLOBAL_CANDIDATES.map(candidate => astUtils.getVariableByName(globalScope, candidate)).filter(globalVar => !!globalVar && globalVar.defs.length === 0).forEach(reportImpliedEvalViaGlobal);
89424 }
89425
89426 };
89427 }
89428
89429 };
89430
89431 /***/ }),
89432 /* 683 */
89433 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
89434
89435 "use strict";
89436 /**
89437 * @fileoverview Rule to flag updates of imported bindings.
89438 * @author Toru Nagashima <https://github.com/mysticatea>
89439 */
89440 //------------------------------------------------------------------------------
89441 // Helpers
89442 //------------------------------------------------------------------------------
89443
89444 const {
89445 findVariable
89446 } = __webpack_require__(501);
89447
89448 const astUtils = __webpack_require__(548);
89449
89450 const WellKnownMutationFunctions = {
89451 Object: /^(?:assign|definePropert(?:y|ies)|freeze|setPrototypeOf)$/u,
89452 Reflect: /^(?:(?:define|delete)Property|set(?:PrototypeOf)?)$/u
89453 };
89454 /**
89455 * Check if a given node is LHS of an assignment node.
89456 * @param {ASTNode} node The node to check.
89457 * @returns {boolean} `true` if the node is LHS.
89458 */
89459
89460 function isAssignmentLeft(node) {
89461 const {
89462 parent
89463 } = node;
89464 return parent.type === "AssignmentExpression" && parent.left === node || // Destructuring assignments
89465 parent.type === "ArrayPattern" || parent.type === "Property" && parent.value === node && parent.parent.type === "ObjectPattern" || parent.type === "RestElement" || parent.type === "AssignmentPattern" && parent.left === node;
89466 }
89467 /**
89468 * Check if a given node is the operand of mutation unary operator.
89469 * @param {ASTNode} node The node to check.
89470 * @returns {boolean} `true` if the node is the operand of mutation unary operator.
89471 */
89472
89473
89474 function isOperandOfMutationUnaryOperator(node) {
89475 const argumentNode = node.parent.type === "ChainExpression" ? node.parent : node;
89476 const {
89477 parent
89478 } = argumentNode;
89479 return parent.type === "UpdateExpression" && parent.argument === argumentNode || parent.type === "UnaryExpression" && parent.operator === "delete" && parent.argument === argumentNode;
89480 }
89481 /**
89482 * Check if a given node is the iteration variable of `for-in`/`for-of` syntax.
89483 * @param {ASTNode} node The node to check.
89484 * @returns {boolean} `true` if the node is the iteration variable.
89485 */
89486
89487
89488 function isIterationVariable(node) {
89489 const {
89490 parent
89491 } = node;
89492 return parent.type === "ForInStatement" && parent.left === node || parent.type === "ForOfStatement" && parent.left === node;
89493 }
89494 /**
89495 * Check if a given node is at the first argument of a well-known mutation function.
89496 * - `Object.assign`
89497 * - `Object.defineProperty`
89498 * - `Object.defineProperties`
89499 * - `Object.freeze`
89500 * - `Object.setPrototypeOf`
89501 * - `Reflect.defineProperty`
89502 * - `Reflect.deleteProperty`
89503 * - `Reflect.set`
89504 * - `Reflect.setPrototypeOf`
89505 * @param {ASTNode} node The node to check.
89506 * @param {Scope} scope A `escope.Scope` object to find variable (whichever).
89507 * @returns {boolean} `true` if the node is at the first argument of a well-known mutation function.
89508 */
89509
89510
89511 function isArgumentOfWellKnownMutationFunction(node, scope) {
89512 const {
89513 parent
89514 } = node;
89515
89516 if (parent.type !== "CallExpression" || parent.arguments[0] !== node) {
89517 return false;
89518 }
89519
89520 const callee = astUtils.skipChainExpression(parent.callee);
89521
89522 if (!astUtils.isSpecificMemberAccess(callee, "Object", WellKnownMutationFunctions.Object) && !astUtils.isSpecificMemberAccess(callee, "Reflect", WellKnownMutationFunctions.Reflect)) {
89523 return false;
89524 }
89525
89526 const variable = findVariable(scope, callee.object);
89527 return variable !== null && variable.scope.type === "global";
89528 }
89529 /**
89530 * Check if the identifier node is placed at to update members.
89531 * @param {ASTNode} id The Identifier node to check.
89532 * @param {Scope} scope A `escope.Scope` object to find variable (whichever).
89533 * @returns {boolean} `true` if the member of `id` was updated.
89534 */
89535
89536
89537 function isMemberWrite(id, scope) {
89538 const {
89539 parent
89540 } = id;
89541 return parent.type === "MemberExpression" && parent.object === id && (isAssignmentLeft(parent) || isOperandOfMutationUnaryOperator(parent) || isIterationVariable(parent)) || isArgumentOfWellKnownMutationFunction(id, scope);
89542 }
89543 /**
89544 * Get the mutation node.
89545 * @param {ASTNode} id The Identifier node to get.
89546 * @returns {ASTNode} The mutation node.
89547 */
89548
89549
89550 function getWriteNode(id) {
89551 let node = id.parent;
89552
89553 while (node && node.type !== "AssignmentExpression" && node.type !== "UpdateExpression" && node.type !== "UnaryExpression" && node.type !== "CallExpression" && node.type !== "ForInStatement" && node.type !== "ForOfStatement") {
89554 node = node.parent;
89555 }
89556
89557 return node || id;
89558 } //------------------------------------------------------------------------------
89559 // Rule Definition
89560 //------------------------------------------------------------------------------
89561
89562
89563 module.exports = {
89564 meta: {
89565 type: "problem",
89566 docs: {
89567 description: "disallow assigning to imported bindings",
89568 recommended: true,
89569 url: "https://eslint.org/docs/rules/no-import-assign"
89570 },
89571 schema: [],
89572 messages: {
89573 readonly: "'{{name}}' is read-only.",
89574 readonlyMember: "The members of '{{name}}' are read-only."
89575 }
89576 },
89577
89578 create(context) {
89579 return {
89580 ImportDeclaration(node) {
89581 const scope = context.getScope();
89582
89583 for (const variable of context.getDeclaredVariables(node)) {
89584 const shouldCheckMembers = variable.defs.some(d => d.node.type === "ImportNamespaceSpecifier");
89585 let prevIdNode = null;
89586
89587 for (const reference of variable.references) {
89588 const idNode = reference.identifier;
89589 /*
89590 * AssignmentPattern (e.g. `[a = 0] = b`) makes two write
89591 * references for the same identifier. This should skip
89592 * the one of the two in order to prevent redundant reports.
89593 */
89594
89595 if (idNode === prevIdNode) {
89596 continue;
89597 }
89598
89599 prevIdNode = idNode;
89600
89601 if (reference.isWrite()) {
89602 context.report({
89603 node: getWriteNode(idNode),
89604 messageId: "readonly",
89605 data: {
89606 name: idNode.name
89607 }
89608 });
89609 } else if (shouldCheckMembers && isMemberWrite(idNode, scope)) {
89610 context.report({
89611 node: getWriteNode(idNode),
89612 messageId: "readonlyMember",
89613 data: {
89614 name: idNode.name
89615 }
89616 });
89617 }
89618 }
89619 }
89620 }
89621
89622 };
89623 }
89624
89625 };
89626
89627 /***/ }),
89628 /* 684 */
89629 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
89630
89631 "use strict";
89632 /**
89633 * @fileoverview Enforces or disallows inline comments.
89634 * @author Greg Cochard
89635 */
89636
89637
89638 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
89639 // Rule Definition
89640 //------------------------------------------------------------------------------
89641
89642
89643 module.exports = {
89644 meta: {
89645 type: "suggestion",
89646 docs: {
89647 description: "disallow inline comments after code",
89648 recommended: false,
89649 url: "https://eslint.org/docs/rules/no-inline-comments"
89650 },
89651 schema: [{
89652 type: "object",
89653 properties: {
89654 ignorePattern: {
89655 type: "string"
89656 }
89657 },
89658 additionalProperties: false
89659 }],
89660 messages: {
89661 unexpectedInlineComment: "Unexpected comment inline with code."
89662 }
89663 },
89664
89665 create(context) {
89666 const sourceCode = context.getSourceCode();
89667 const options = context.options[0];
89668 let customIgnoreRegExp;
89669
89670 if (options && options.ignorePattern) {
89671 customIgnoreRegExp = new RegExp(options.ignorePattern, "u");
89672 }
89673 /**
89674 * Will check that comments are not on lines starting with or ending with code
89675 * @param {ASTNode} node The comment node to check
89676 * @private
89677 * @returns {void}
89678 */
89679
89680
89681 function testCodeAroundComment(node) {
89682 const startLine = String(sourceCode.lines[node.loc.start.line - 1]),
89683 endLine = String(sourceCode.lines[node.loc.end.line - 1]),
89684 preamble = startLine.slice(0, node.loc.start.column).trim(),
89685 postamble = endLine.slice(node.loc.end.column).trim(),
89686 isPreambleEmpty = !preamble,
89687 isPostambleEmpty = !postamble; // Nothing on both sides
89688
89689 if (isPreambleEmpty && isPostambleEmpty) {
89690 return;
89691 } // Matches the ignore pattern
89692
89693
89694 if (customIgnoreRegExp && customIgnoreRegExp.test(node.value)) {
89695 return;
89696 } // JSX Exception
89697
89698
89699 if ((isPreambleEmpty || preamble === "{") && (isPostambleEmpty || postamble === "}")) {
89700 const enclosingNode = sourceCode.getNodeByRangeIndex(node.range[0]);
89701
89702 if (enclosingNode && enclosingNode.type === "JSXEmptyExpression") {
89703 return;
89704 }
89705 } // Don't report ESLint directive comments
89706
89707
89708 if (astUtils.isDirectiveComment(node)) {
89709 return;
89710 }
89711
89712 context.report({
89713 node,
89714 messageId: "unexpectedInlineComment"
89715 });
89716 } //--------------------------------------------------------------------------
89717 // Public
89718 //--------------------------------------------------------------------------
89719
89720
89721 return {
89722 Program() {
89723 sourceCode.getAllComments().filter(token => token.type !== "Shebang").forEach(testCodeAroundComment);
89724 }
89725
89726 };
89727 }
89728
89729 };
89730
89731 /***/ }),
89732 /* 685 */
89733 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
89734
89735 "use strict";
89736 /**
89737 * @fileoverview Rule to enforce declarations in program or function body root.
89738 * @author Brandon Mills
89739 */
89740 //------------------------------------------------------------------------------
89741 // Requirements
89742 //------------------------------------------------------------------------------
89743
89744 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
89745 // Rule Definition
89746 //------------------------------------------------------------------------------
89747
89748
89749 const validParent = new Set(["Program", "StaticBlock", "ExportNamedDeclaration", "ExportDefaultDeclaration"]);
89750 const validBlockStatementParent = new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]);
89751 /**
89752 * Finds the nearest enclosing context where this rule allows declarations and returns its description.
89753 * @param {ASTNode} node Node to search from.
89754 * @returns {string} Description. One of "program", "function body", "class static block body".
89755 */
89756
89757 function getAllowedBodyDescription(node) {
89758 let {
89759 parent
89760 } = node;
89761
89762 while (parent) {
89763 if (parent.type === "StaticBlock") {
89764 return "class static block body";
89765 }
89766
89767 if (astUtils.isFunction(parent)) {
89768 return "function body";
89769 }
89770
89771 ({
89772 parent
89773 } = parent);
89774 }
89775
89776 return "program";
89777 }
89778
89779 module.exports = {
89780 meta: {
89781 type: "problem",
89782 docs: {
89783 description: "disallow variable or `function` declarations in nested blocks",
89784 recommended: true,
89785 url: "https://eslint.org/docs/rules/no-inner-declarations"
89786 },
89787 schema: [{
89788 enum: ["functions", "both"]
89789 }],
89790 messages: {
89791 moveDeclToRoot: "Move {{type}} declaration to {{body}} root."
89792 }
89793 },
89794
89795 create(context) {
89796 /**
89797 * Ensure that a given node is at a program or function body's root.
89798 * @param {ASTNode} node Declaration node to check.
89799 * @returns {void}
89800 */
89801 function check(node) {
89802 const parent = node.parent;
89803
89804 if (parent.type === "BlockStatement" && validBlockStatementParent.has(parent.parent.type)) {
89805 return;
89806 }
89807
89808 if (validParent.has(parent.type)) {
89809 return;
89810 }
89811
89812 context.report({
89813 node,
89814 messageId: "moveDeclToRoot",
89815 data: {
89816 type: node.type === "FunctionDeclaration" ? "function" : "variable",
89817 body: getAllowedBodyDescription(node)
89818 }
89819 });
89820 }
89821
89822 return {
89823 FunctionDeclaration: check,
89824
89825 VariableDeclaration(node) {
89826 if (context.options[0] === "both" && node.kind === "var") {
89827 check(node);
89828 }
89829 }
89830
89831 };
89832 }
89833
89834 };
89835
89836 /***/ }),
89837 /* 686 */
89838 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
89839
89840 "use strict";
89841 /**
89842 * @fileoverview Validate strings passed to the RegExp constructor
89843 * @author Michael Ficarra
89844 */
89845 //------------------------------------------------------------------------------
89846 // Requirements
89847 //------------------------------------------------------------------------------
89848
89849 const RegExpValidator = (__webpack_require__(651).RegExpValidator);
89850
89851 const validator = new RegExpValidator();
89852 const validFlags = /[dgimsuy]/gu;
89853 const undefined1 = void 0; //------------------------------------------------------------------------------
89854 // Rule Definition
89855 //------------------------------------------------------------------------------
89856
89857 module.exports = {
89858 meta: {
89859 type: "problem",
89860 docs: {
89861 description: "disallow invalid regular expression strings in `RegExp` constructors",
89862 recommended: true,
89863 url: "https://eslint.org/docs/rules/no-invalid-regexp"
89864 },
89865 schema: [{
89866 type: "object",
89867 properties: {
89868 allowConstructorFlags: {
89869 type: "array",
89870 items: {
89871 type: "string"
89872 }
89873 }
89874 },
89875 additionalProperties: false
89876 }],
89877 messages: {
89878 regexMessage: "{{message}}."
89879 }
89880 },
89881
89882 create(context) {
89883 const options = context.options[0];
89884 let allowedFlags = null;
89885
89886 if (options && options.allowConstructorFlags) {
89887 const temp = options.allowConstructorFlags.join("").replace(validFlags, "");
89888
89889 if (temp) {
89890 allowedFlags = new RegExp("[".concat(temp, "]"), "giu");
89891 }
89892 }
89893 /**
89894 * Check if node is a string
89895 * @param {ASTNode} node node to evaluate
89896 * @returns {boolean} True if its a string
89897 * @private
89898 */
89899
89900
89901 function isString(node) {
89902 return node && node.type === "Literal" && typeof node.value === "string";
89903 }
89904 /**
89905 * Gets flags of a regular expression created by the given `RegExp()` or `new RegExp()` call
89906 * Examples:
89907 * new RegExp(".") // => ""
89908 * new RegExp(".", "gu") // => "gu"
89909 * new RegExp(".", flags) // => null
89910 * @param {ASTNode} node `CallExpression` or `NewExpression` node
89911 * @returns {string|null} flags if they can be determined, `null` otherwise
89912 * @private
89913 */
89914
89915
89916 function getFlags(node) {
89917 if (node.arguments.length < 2) {
89918 return "";
89919 }
89920
89921 if (isString(node.arguments[1])) {
89922 return node.arguments[1].value;
89923 }
89924
89925 return null;
89926 }
89927 /**
89928 * Check syntax error in a given pattern.
89929 * @param {string} pattern The RegExp pattern to validate.
89930 * @param {boolean} uFlag The Unicode flag.
89931 * @returns {string|null} The syntax error.
89932 */
89933
89934
89935 function validateRegExpPattern(pattern, uFlag) {
89936 try {
89937 validator.validatePattern(pattern, undefined1, undefined1, uFlag);
89938 return null;
89939 } catch (err) {
89940 return err.message;
89941 }
89942 }
89943 /**
89944 * Check syntax error in a given flags.
89945 * @param {string} flags The RegExp flags to validate.
89946 * @returns {string|null} The syntax error.
89947 */
89948
89949
89950 function validateRegExpFlags(flags) {
89951 try {
89952 validator.validateFlags(flags);
89953 return null;
89954 } catch {
89955 return "Invalid flags supplied to RegExp constructor '".concat(flags, "'");
89956 }
89957 }
89958
89959 return {
89960 "CallExpression, NewExpression"(node) {
89961 if (node.callee.type !== "Identifier" || node.callee.name !== "RegExp" || !isString(node.arguments[0])) {
89962 return;
89963 }
89964
89965 const pattern = node.arguments[0].value;
89966 let flags = getFlags(node);
89967
89968 if (flags && allowedFlags) {
89969 flags = flags.replace(allowedFlags, "");
89970 }
89971
89972 const message = flags && validateRegExpFlags(flags) || ( // If flags are unknown, report the regex only if its pattern is invalid both with and without the "u" flag
89973 flags === null ? validateRegExpPattern(pattern, true) && validateRegExpPattern(pattern, false) : validateRegExpPattern(pattern, flags.includes("u")));
89974
89975 if (message) {
89976 context.report({
89977 node,
89978 messageId: "regexMessage",
89979 data: {
89980 message
89981 }
89982 });
89983 }
89984 }
89985
89986 };
89987 }
89988
89989 };
89990
89991 /***/ }),
89992 /* 687 */
89993 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
89994
89995 "use strict";
89996 /**
89997 * @fileoverview A rule to disallow `this` keywords outside of classes or class-like objects.
89998 * @author Toru Nagashima
89999 */
90000 //------------------------------------------------------------------------------
90001 // Requirements
90002 //------------------------------------------------------------------------------
90003
90004 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
90005 // Rule Definition
90006 //------------------------------------------------------------------------------
90007
90008
90009 module.exports = {
90010 meta: {
90011 type: "suggestion",
90012 docs: {
90013 description: "disallow `this` keywords outside of classes or class-like objects",
90014 recommended: false,
90015 url: "https://eslint.org/docs/rules/no-invalid-this"
90016 },
90017 schema: [{
90018 type: "object",
90019 properties: {
90020 capIsConstructor: {
90021 type: "boolean",
90022 default: true
90023 }
90024 },
90025 additionalProperties: false
90026 }],
90027 messages: {
90028 unexpectedThis: "Unexpected 'this'."
90029 }
90030 },
90031
90032 create(context) {
90033 const options = context.options[0] || {};
90034 const capIsConstructor = options.capIsConstructor !== false;
90035 const stack = [],
90036 sourceCode = context.getSourceCode();
90037 /**
90038 * Gets the current checking context.
90039 *
90040 * The return value has a flag that whether or not `this` keyword is valid.
90041 * The flag is initialized when got at the first time.
90042 * @returns {{valid: boolean}}
90043 * an object which has a flag that whether or not `this` keyword is valid.
90044 */
90045
90046 stack.getCurrent = function () {
90047 const current = this[this.length - 1];
90048
90049 if (!current.init) {
90050 current.init = true;
90051 current.valid = !astUtils.isDefaultThisBinding(current.node, sourceCode, {
90052 capIsConstructor
90053 });
90054 }
90055
90056 return current;
90057 };
90058 /**
90059 * Pushs new checking context into the stack.
90060 *
90061 * The checking context is not initialized yet.
90062 * Because most functions don't have `this` keyword.
90063 * When `this` keyword was found, the checking context is initialized.
90064 * @param {ASTNode} node A function node that was entered.
90065 * @returns {void}
90066 */
90067
90068
90069 function enterFunction(node) {
90070 // `this` can be invalid only under strict mode.
90071 stack.push({
90072 init: !context.getScope().isStrict,
90073 node,
90074 valid: true
90075 });
90076 }
90077 /**
90078 * Pops the current checking context from the stack.
90079 * @returns {void}
90080 */
90081
90082
90083 function exitFunction() {
90084 stack.pop();
90085 }
90086
90087 return {
90088 /*
90089 * `this` is invalid only under strict mode.
90090 * Modules is always strict mode.
90091 */
90092 Program(node) {
90093 const scope = context.getScope(),
90094 features = context.parserOptions.ecmaFeatures || {};
90095 stack.push({
90096 init: true,
90097 node,
90098 valid: !(scope.isStrict || node.sourceType === "module" || features.globalReturn && scope.childScopes[0].isStrict)
90099 });
90100 },
90101
90102 "Program:exit"() {
90103 stack.pop();
90104 },
90105
90106 FunctionDeclaration: enterFunction,
90107 "FunctionDeclaration:exit": exitFunction,
90108 FunctionExpression: enterFunction,
90109 "FunctionExpression:exit": exitFunction,
90110 // Field initializers are implicit functions.
90111 "PropertyDefinition > *.value": enterFunction,
90112 "PropertyDefinition > *.value:exit": exitFunction,
90113 // Class static blocks are implicit functions.
90114 StaticBlock: enterFunction,
90115 "StaticBlock:exit": exitFunction,
90116
90117 // Reports if `this` of the current context is invalid.
90118 ThisExpression(node) {
90119 const current = stack.getCurrent();
90120
90121 if (current && !current.valid) {
90122 context.report({
90123 node,
90124 messageId: "unexpectedThis"
90125 });
90126 }
90127 }
90128
90129 };
90130 }
90131
90132 };
90133
90134 /***/ }),
90135 /* 688 */
90136 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
90137
90138 "use strict";
90139 /**
90140 * @fileoverview Rule to disallow whitespace that is not a tab or space, whitespace inside strings and comments are allowed
90141 * @author Jonathan Kingston
90142 * @author Christophe Porteneuve
90143 */
90144 //------------------------------------------------------------------------------
90145 // Requirements
90146 //------------------------------------------------------------------------------
90147
90148 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
90149 // Constants
90150 //------------------------------------------------------------------------------
90151
90152
90153 const ALL_IRREGULARS = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000\u2028\u2029]/u;
90154 const IRREGULAR_WHITESPACE = /[\f\v\u0085\ufeff\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u202f\u205f\u3000]+/mgu;
90155 const IRREGULAR_LINE_TERMINATORS = /[\u2028\u2029]/mgu;
90156 const LINE_BREAK = astUtils.createGlobalLinebreakMatcher(); //------------------------------------------------------------------------------
90157 // Rule Definition
90158 //------------------------------------------------------------------------------
90159
90160 module.exports = {
90161 meta: {
90162 type: "problem",
90163 docs: {
90164 description: "disallow irregular whitespace",
90165 recommended: true,
90166 url: "https://eslint.org/docs/rules/no-irregular-whitespace"
90167 },
90168 schema: [{
90169 type: "object",
90170 properties: {
90171 skipComments: {
90172 type: "boolean",
90173 default: false
90174 },
90175 skipStrings: {
90176 type: "boolean",
90177 default: true
90178 },
90179 skipTemplates: {
90180 type: "boolean",
90181 default: false
90182 },
90183 skipRegExps: {
90184 type: "boolean",
90185 default: false
90186 }
90187 },
90188 additionalProperties: false
90189 }],
90190 messages: {
90191 noIrregularWhitespace: "Irregular whitespace not allowed."
90192 }
90193 },
90194
90195 create(context) {
90196 // Module store of errors that we have found
90197 let errors = []; // Lookup the `skipComments` option, which defaults to `false`.
90198
90199 const options = context.options[0] || {};
90200 const skipComments = !!options.skipComments;
90201 const skipStrings = options.skipStrings !== false;
90202 const skipRegExps = !!options.skipRegExps;
90203 const skipTemplates = !!options.skipTemplates;
90204 const sourceCode = context.getSourceCode();
90205 const commentNodes = sourceCode.getAllComments();
90206 /**
90207 * Removes errors that occur inside the given node
90208 * @param {ASTNode} node to check for matching errors.
90209 * @returns {void}
90210 * @private
90211 */
90212
90213 function removeWhitespaceError(node) {
90214 const locStart = node.loc.start;
90215 const locEnd = node.loc.end;
90216 errors = errors.filter(_ref => {
90217 let {
90218 loc: {
90219 start: errorLocStart
90220 }
90221 } = _ref;
90222 return errorLocStart.line < locStart.line || errorLocStart.line === locStart.line && errorLocStart.column < locStart.column || errorLocStart.line === locEnd.line && errorLocStart.column >= locEnd.column || errorLocStart.line > locEnd.line;
90223 });
90224 }
90225 /**
90226 * Checks identifier or literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
90227 * @param {ASTNode} node to check for matching errors.
90228 * @returns {void}
90229 * @private
90230 */
90231
90232
90233 function removeInvalidNodeErrorsInIdentifierOrLiteral(node) {
90234 const shouldCheckStrings = skipStrings && typeof node.value === "string";
90235 const shouldCheckRegExps = skipRegExps && Boolean(node.regex);
90236
90237 if (shouldCheckStrings || shouldCheckRegExps) {
90238 // If we have irregular characters remove them from the errors list
90239 if (ALL_IRREGULARS.test(node.raw)) {
90240 removeWhitespaceError(node);
90241 }
90242 }
90243 }
90244 /**
90245 * Checks template string literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
90246 * @param {ASTNode} node to check for matching errors.
90247 * @returns {void}
90248 * @private
90249 */
90250
90251
90252 function removeInvalidNodeErrorsInTemplateLiteral(node) {
90253 if (typeof node.value.raw === "string") {
90254 if (ALL_IRREGULARS.test(node.value.raw)) {
90255 removeWhitespaceError(node);
90256 }
90257 }
90258 }
90259 /**
90260 * Checks comment nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
90261 * @param {ASTNode} node to check for matching errors.
90262 * @returns {void}
90263 * @private
90264 */
90265
90266
90267 function removeInvalidNodeErrorsInComment(node) {
90268 if (ALL_IRREGULARS.test(node.value)) {
90269 removeWhitespaceError(node);
90270 }
90271 }
90272 /**
90273 * Checks the program source for irregular whitespace
90274 * @param {ASTNode} node The program node
90275 * @returns {void}
90276 * @private
90277 */
90278
90279
90280 function checkForIrregularWhitespace(node) {
90281 const sourceLines = sourceCode.lines;
90282 sourceLines.forEach((sourceLine, lineIndex) => {
90283 const lineNumber = lineIndex + 1;
90284 let match;
90285
90286 while ((match = IRREGULAR_WHITESPACE.exec(sourceLine)) !== null) {
90287 errors.push({
90288 node,
90289 messageId: "noIrregularWhitespace",
90290 loc: {
90291 start: {
90292 line: lineNumber,
90293 column: match.index
90294 },
90295 end: {
90296 line: lineNumber,
90297 column: match.index + match[0].length
90298 }
90299 }
90300 });
90301 }
90302 });
90303 }
90304 /**
90305 * Checks the program source for irregular line terminators
90306 * @param {ASTNode} node The program node
90307 * @returns {void}
90308 * @private
90309 */
90310
90311
90312 function checkForIrregularLineTerminators(node) {
90313 const source = sourceCode.getText(),
90314 sourceLines = sourceCode.lines,
90315 linebreaks = source.match(LINE_BREAK);
90316 let lastLineIndex = -1,
90317 match;
90318
90319 while ((match = IRREGULAR_LINE_TERMINATORS.exec(source)) !== null) {
90320 const lineIndex = linebreaks.indexOf(match[0], lastLineIndex + 1) || 0;
90321 errors.push({
90322 node,
90323 messageId: "noIrregularWhitespace",
90324 loc: {
90325 start: {
90326 line: lineIndex + 1,
90327 column: sourceLines[lineIndex].length
90328 },
90329 end: {
90330 line: lineIndex + 2,
90331 column: 0
90332 }
90333 }
90334 });
90335 lastLineIndex = lineIndex;
90336 }
90337 }
90338 /**
90339 * A no-op function to act as placeholder for comment accumulation when the `skipComments` option is `false`.
90340 * @returns {void}
90341 * @private
90342 */
90343
90344
90345 function noop() {}
90346
90347 const nodes = {};
90348
90349 if (ALL_IRREGULARS.test(sourceCode.getText())) {
90350 nodes.Program = function (node) {
90351 /*
90352 * As we can easily fire warnings for all white space issues with
90353 * all the source its simpler to fire them here.
90354 * This means we can check all the application code without having
90355 * to worry about issues caused in the parser tokens.
90356 * When writing this code also evaluating per node was missing out
90357 * connecting tokens in some cases.
90358 * We can later filter the errors when they are found to be not an
90359 * issue in nodes we don't care about.
90360 */
90361 checkForIrregularWhitespace(node);
90362 checkForIrregularLineTerminators(node);
90363 };
90364
90365 nodes.Identifier = removeInvalidNodeErrorsInIdentifierOrLiteral;
90366 nodes.Literal = removeInvalidNodeErrorsInIdentifierOrLiteral;
90367 nodes.TemplateElement = skipTemplates ? removeInvalidNodeErrorsInTemplateLiteral : noop;
90368
90369 nodes["Program:exit"] = function () {
90370 if (skipComments) {
90371 // First strip errors occurring in comment nodes.
90372 commentNodes.forEach(removeInvalidNodeErrorsInComment);
90373 } // If we have any errors remaining report on them
90374
90375
90376 errors.forEach(error => context.report(error));
90377 };
90378 } else {
90379 nodes.Program = noop;
90380 }
90381
90382 return nodes;
90383 }
90384
90385 };
90386
90387 /***/ }),
90388 /* 689 */
90389 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
90390
90391 "use strict";
90392 /**
90393 * @fileoverview Rule to flag usage of __iterator__ property
90394 * @author Ian Christian Myers
90395 */
90396 //------------------------------------------------------------------------------
90397 // Requirements
90398 //------------------------------------------------------------------------------
90399
90400 const {
90401 getStaticPropertyName
90402 } = __webpack_require__(548); //------------------------------------------------------------------------------
90403 // Rule Definition
90404 //------------------------------------------------------------------------------
90405
90406
90407 module.exports = {
90408 meta: {
90409 type: "suggestion",
90410 docs: {
90411 description: "disallow the use of the `__iterator__` property",
90412 recommended: false,
90413 url: "https://eslint.org/docs/rules/no-iterator"
90414 },
90415 schema: [],
90416 messages: {
90417 noIterator: "Reserved name '__iterator__'."
90418 }
90419 },
90420
90421 create(context) {
90422 return {
90423 MemberExpression(node) {
90424 if (getStaticPropertyName(node) === "__iterator__") {
90425 context.report({
90426 node,
90427 messageId: "noIterator"
90428 });
90429 }
90430 }
90431
90432 };
90433 }
90434
90435 };
90436
90437 /***/ }),
90438 /* 690 */
90439 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
90440
90441 "use strict";
90442 /**
90443 * @fileoverview Rule to flag labels that are the same as an identifier
90444 * @author Ian Christian Myers
90445 */
90446 //------------------------------------------------------------------------------
90447 // Requirements
90448 //------------------------------------------------------------------------------
90449
90450 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
90451 // Rule Definition
90452 //------------------------------------------------------------------------------
90453
90454
90455 module.exports = {
90456 meta: {
90457 type: "suggestion",
90458 docs: {
90459 description: "disallow labels that share a name with a variable",
90460 recommended: false,
90461 url: "https://eslint.org/docs/rules/no-label-var"
90462 },
90463 schema: [],
90464 messages: {
90465 identifierClashWithLabel: "Found identifier with same name as label."
90466 }
90467 },
90468
90469 create(context) {
90470 //--------------------------------------------------------------------------
90471 // Helpers
90472 //--------------------------------------------------------------------------
90473
90474 /**
90475 * Check if the identifier is present inside current scope
90476 * @param {Object} scope current scope
90477 * @param {string} name To evaluate
90478 * @returns {boolean} True if its present
90479 * @private
90480 */
90481 function findIdentifier(scope, name) {
90482 return astUtils.getVariableByName(scope, name) !== null;
90483 } //--------------------------------------------------------------------------
90484 // Public API
90485 //--------------------------------------------------------------------------
90486
90487
90488 return {
90489 LabeledStatement(node) {
90490 // Fetch the innermost scope.
90491 const scope = context.getScope();
90492 /*
90493 * Recursively find the identifier walking up the scope, starting
90494 * with the innermost scope.
90495 */
90496
90497 if (findIdentifier(scope, node.label.name)) {
90498 context.report({
90499 node,
90500 messageId: "identifierClashWithLabel"
90501 });
90502 }
90503 }
90504
90505 };
90506 }
90507
90508 };
90509
90510 /***/ }),
90511 /* 691 */
90512 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
90513
90514 "use strict";
90515 /**
90516 * @fileoverview Disallow Labeled Statements
90517 * @author Nicholas C. Zakas
90518 */
90519 //------------------------------------------------------------------------------
90520 // Requirements
90521 //------------------------------------------------------------------------------
90522
90523 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
90524 // Rule Definition
90525 //------------------------------------------------------------------------------
90526
90527
90528 module.exports = {
90529 meta: {
90530 type: "suggestion",
90531 docs: {
90532 description: "disallow labeled statements",
90533 recommended: false,
90534 url: "https://eslint.org/docs/rules/no-labels"
90535 },
90536 schema: [{
90537 type: "object",
90538 properties: {
90539 allowLoop: {
90540 type: "boolean",
90541 default: false
90542 },
90543 allowSwitch: {
90544 type: "boolean",
90545 default: false
90546 }
90547 },
90548 additionalProperties: false
90549 }],
90550 messages: {
90551 unexpectedLabel: "Unexpected labeled statement.",
90552 unexpectedLabelInBreak: "Unexpected label in break statement.",
90553 unexpectedLabelInContinue: "Unexpected label in continue statement."
90554 }
90555 },
90556
90557 create(context) {
90558 const options = context.options[0];
90559 const allowLoop = options && options.allowLoop;
90560 const allowSwitch = options && options.allowSwitch;
90561 let scopeInfo = null;
90562 /**
90563 * Gets the kind of a given node.
90564 * @param {ASTNode} node A node to get.
90565 * @returns {string} The kind of the node.
90566 */
90567
90568 function getBodyKind(node) {
90569 if (astUtils.isLoop(node)) {
90570 return "loop";
90571 }
90572
90573 if (node.type === "SwitchStatement") {
90574 return "switch";
90575 }
90576
90577 return "other";
90578 }
90579 /**
90580 * Checks whether the label of a given kind is allowed or not.
90581 * @param {string} kind A kind to check.
90582 * @returns {boolean} `true` if the kind is allowed.
90583 */
90584
90585
90586 function isAllowed(kind) {
90587 switch (kind) {
90588 case "loop":
90589 return allowLoop;
90590
90591 case "switch":
90592 return allowSwitch;
90593
90594 default:
90595 return false;
90596 }
90597 }
90598 /**
90599 * Checks whether a given name is a label of a loop or not.
90600 * @param {string} label A name of a label to check.
90601 * @returns {boolean} `true` if the name is a label of a loop.
90602 */
90603
90604
90605 function getKind(label) {
90606 let info = scopeInfo;
90607
90608 while (info) {
90609 if (info.label === label) {
90610 return info.kind;
90611 }
90612
90613 info = info.upper;
90614 }
90615 /* istanbul ignore next: syntax error */
90616
90617
90618 return "other";
90619 } //--------------------------------------------------------------------------
90620 // Public
90621 //--------------------------------------------------------------------------
90622
90623
90624 return {
90625 LabeledStatement(node) {
90626 scopeInfo = {
90627 label: node.label.name,
90628 kind: getBodyKind(node.body),
90629 upper: scopeInfo
90630 };
90631 },
90632
90633 "LabeledStatement:exit"(node) {
90634 if (!isAllowed(scopeInfo.kind)) {
90635 context.report({
90636 node,
90637 messageId: "unexpectedLabel"
90638 });
90639 }
90640
90641 scopeInfo = scopeInfo.upper;
90642 },
90643
90644 BreakStatement(node) {
90645 if (node.label && !isAllowed(getKind(node.label.name))) {
90646 context.report({
90647 node,
90648 messageId: "unexpectedLabelInBreak"
90649 });
90650 }
90651 },
90652
90653 ContinueStatement(node) {
90654 if (node.label && !isAllowed(getKind(node.label.name))) {
90655 context.report({
90656 node,
90657 messageId: "unexpectedLabelInContinue"
90658 });
90659 }
90660 }
90661
90662 };
90663 }
90664
90665 };
90666
90667 /***/ }),
90668 /* 692 */
90669 /***/ ((module) => {
90670
90671 "use strict";
90672 /**
90673 * @fileoverview Rule to flag blocks with no reason to exist
90674 * @author Brandon Mills
90675 */
90676 //------------------------------------------------------------------------------
90677 // Rule Definition
90678 //------------------------------------------------------------------------------
90679
90680 module.exports = {
90681 meta: {
90682 type: "suggestion",
90683 docs: {
90684 description: "disallow unnecessary nested blocks",
90685 recommended: false,
90686 url: "https://eslint.org/docs/rules/no-lone-blocks"
90687 },
90688 schema: [],
90689 messages: {
90690 redundantBlock: "Block is redundant.",
90691 redundantNestedBlock: "Nested block is redundant."
90692 }
90693 },
90694
90695 create(context) {
90696 // A stack of lone blocks to be checked for block-level bindings
90697 const loneBlocks = [];
90698 let ruleDef;
90699 /**
90700 * Reports a node as invalid.
90701 * @param {ASTNode} node The node to be reported.
90702 * @returns {void}
90703 */
90704
90705 function report(node) {
90706 const messageId = node.parent.type === "BlockStatement" || node.parent.type === "StaticBlock" ? "redundantNestedBlock" : "redundantBlock";
90707 context.report({
90708 node,
90709 messageId
90710 });
90711 }
90712 /**
90713 * Checks for any occurrence of a BlockStatement in a place where lists of statements can appear
90714 * @param {ASTNode} node The node to check
90715 * @returns {boolean} True if the node is a lone block.
90716 */
90717
90718
90719 function isLoneBlock(node) {
90720 return node.parent.type === "BlockStatement" || node.parent.type === "StaticBlock" || node.parent.type === "Program" || // Don't report blocks in switch cases if the block is the only statement of the case.
90721 node.parent.type === "SwitchCase" && !(node.parent.consequent[0] === node && node.parent.consequent.length === 1);
90722 }
90723 /**
90724 * Checks the enclosing block of the current node for block-level bindings,
90725 * and "marks it" as valid if any.
90726 * @returns {void}
90727 */
90728
90729
90730 function markLoneBlock() {
90731 if (loneBlocks.length === 0) {
90732 return;
90733 }
90734
90735 const block = context.getAncestors().pop();
90736
90737 if (loneBlocks[loneBlocks.length - 1] === block) {
90738 loneBlocks.pop();
90739 }
90740 } // Default rule definition: report all lone blocks
90741
90742
90743 ruleDef = {
90744 BlockStatement(node) {
90745 if (isLoneBlock(node)) {
90746 report(node);
90747 }
90748 }
90749
90750 }; // ES6: report blocks without block-level bindings, or that's only child of another block
90751
90752 if (context.parserOptions.ecmaVersion >= 6) {
90753 ruleDef = {
90754 BlockStatement(node) {
90755 if (isLoneBlock(node)) {
90756 loneBlocks.push(node);
90757 }
90758 },
90759
90760 "BlockStatement:exit"(node) {
90761 if (loneBlocks.length > 0 && loneBlocks[loneBlocks.length - 1] === node) {
90762 loneBlocks.pop();
90763 report(node);
90764 } else if ((node.parent.type === "BlockStatement" || node.parent.type === "StaticBlock") && node.parent.body.length === 1) {
90765 report(node);
90766 }
90767 }
90768
90769 };
90770
90771 ruleDef.VariableDeclaration = function (node) {
90772 if (node.kind === "let" || node.kind === "const") {
90773 markLoneBlock();
90774 }
90775 };
90776
90777 ruleDef.FunctionDeclaration = function () {
90778 if (context.getScope().isStrict) {
90779 markLoneBlock();
90780 }
90781 };
90782
90783 ruleDef.ClassDeclaration = markLoneBlock;
90784 }
90785
90786 return ruleDef;
90787 }
90788
90789 };
90790
90791 /***/ }),
90792 /* 693 */
90793 /***/ ((module) => {
90794
90795 "use strict";
90796 /**
90797 * @fileoverview Rule to disallow if as the only statement in an else block
90798 * @author Brandon Mills
90799 */
90800 //------------------------------------------------------------------------------
90801 // Rule Definition
90802 //------------------------------------------------------------------------------
90803
90804 module.exports = {
90805 meta: {
90806 type: "suggestion",
90807 docs: {
90808 description: "disallow `if` statements as the only statement in `else` blocks",
90809 recommended: false,
90810 url: "https://eslint.org/docs/rules/no-lonely-if"
90811 },
90812 schema: [],
90813 fixable: "code",
90814 messages: {
90815 unexpectedLonelyIf: "Unexpected if as the only statement in an else block."
90816 }
90817 },
90818
90819 create(context) {
90820 const sourceCode = context.getSourceCode();
90821 return {
90822 IfStatement(node) {
90823 const ancestors = context.getAncestors(),
90824 parent = ancestors.pop(),
90825 grandparent = ancestors.pop();
90826
90827 if (parent && parent.type === "BlockStatement" && parent.body.length === 1 && grandparent && grandparent.type === "IfStatement" && parent === grandparent.alternate) {
90828 context.report({
90829 node,
90830 messageId: "unexpectedLonelyIf",
90831
90832 fix(fixer) {
90833 const openingElseCurly = sourceCode.getFirstToken(parent);
90834 const closingElseCurly = sourceCode.getLastToken(parent);
90835 const elseKeyword = sourceCode.getTokenBefore(openingElseCurly);
90836 const tokenAfterElseBlock = sourceCode.getTokenAfter(closingElseCurly);
90837 const lastIfToken = sourceCode.getLastToken(node.consequent);
90838 const sourceText = sourceCode.getText();
90839
90840 if (sourceText.slice(openingElseCurly.range[1], node.range[0]).trim() || sourceText.slice(node.range[1], closingElseCurly.range[0]).trim()) {
90841 // Don't fix if there are any non-whitespace characters interfering (e.g. comments)
90842 return null;
90843 }
90844
90845 if (node.consequent.type !== "BlockStatement" && lastIfToken.value !== ";" && tokenAfterElseBlock && (node.consequent.loc.end.line === tokenAfterElseBlock.loc.start.line || /^[([/+`-]/u.test(tokenAfterElseBlock.value) || lastIfToken.value === "++" || lastIfToken.value === "--")) {
90846 /*
90847 * If the `if` statement has no block, and is not followed by a semicolon, make sure that fixing
90848 * the issue would not change semantics due to ASI. If this would happen, don't do a fix.
90849 */
90850 return null;
90851 }
90852
90853 return fixer.replaceTextRange([openingElseCurly.range[0], closingElseCurly.range[1]], (elseKeyword.range[1] === openingElseCurly.range[0] ? " " : "") + sourceCode.getText(node));
90854 }
90855
90856 });
90857 }
90858 }
90859
90860 };
90861 }
90862
90863 };
90864
90865 /***/ }),
90866 /* 694 */
90867 /***/ ((module) => {
90868
90869 "use strict";
90870 /**
90871 * @fileoverview Rule to flag creation of function inside a loop
90872 * @author Ilya Volodin
90873 */
90874 //------------------------------------------------------------------------------
90875 // Helpers
90876 //------------------------------------------------------------------------------
90877
90878 /**
90879 * Gets the containing loop node of a specified node.
90880 *
90881 * We don't need to check nested functions, so this ignores those.
90882 * `Scope.through` contains references of nested functions.
90883 * @param {ASTNode} node An AST node to get.
90884 * @returns {ASTNode|null} The containing loop node of the specified node, or
90885 * `null`.
90886 */
90887
90888 function getContainingLoopNode(node) {
90889 for (let currentNode = node; currentNode.parent; currentNode = currentNode.parent) {
90890 const parent = currentNode.parent;
90891
90892 switch (parent.type) {
90893 case "WhileStatement":
90894 case "DoWhileStatement":
90895 return parent;
90896
90897 case "ForStatement":
90898 // `init` is outside of the loop.
90899 if (parent.init !== currentNode) {
90900 return parent;
90901 }
90902
90903 break;
90904
90905 case "ForInStatement":
90906 case "ForOfStatement":
90907 // `right` is outside of the loop.
90908 if (parent.right !== currentNode) {
90909 return parent;
90910 }
90911
90912 break;
90913
90914 case "ArrowFunctionExpression":
90915 case "FunctionExpression":
90916 case "FunctionDeclaration":
90917 // We don't need to check nested functions.
90918 return null;
90919
90920 default:
90921 break;
90922 }
90923 }
90924
90925 return null;
90926 }
90927 /**
90928 * Gets the containing loop node of a given node.
90929 * If the loop was nested, this returns the most outer loop.
90930 * @param {ASTNode} node A node to get. This is a loop node.
90931 * @param {ASTNode|null} excludedNode A node that the result node should not
90932 * include.
90933 * @returns {ASTNode} The most outer loop node.
90934 */
90935
90936
90937 function getTopLoopNode(node, excludedNode) {
90938 const border = excludedNode ? excludedNode.range[1] : 0;
90939 let retv = node;
90940 let containingLoopNode = node;
90941
90942 while (containingLoopNode && containingLoopNode.range[0] >= border) {
90943 retv = containingLoopNode;
90944 containingLoopNode = getContainingLoopNode(containingLoopNode);
90945 }
90946
90947 return retv;
90948 }
90949 /**
90950 * Checks whether a given reference which refers to an upper scope's variable is
90951 * safe or not.
90952 * @param {ASTNode} loopNode A containing loop node.
90953 * @param {eslint-scope.Reference} reference A reference to check.
90954 * @returns {boolean} `true` if the reference is safe or not.
90955 */
90956
90957
90958 function isSafe(loopNode, reference) {
90959 const variable = reference.resolved;
90960 const definition = variable && variable.defs[0];
90961 const declaration = definition && definition.parent;
90962 const kind = declaration && declaration.type === "VariableDeclaration" ? declaration.kind : ""; // Variables which are declared by `const` is safe.
90963
90964 if (kind === "const") {
90965 return true;
90966 }
90967 /*
90968 * Variables which are declared by `let` in the loop is safe.
90969 * It's a different instance from the next loop step's.
90970 */
90971
90972
90973 if (kind === "let" && declaration.range[0] > loopNode.range[0] && declaration.range[1] < loopNode.range[1]) {
90974 return true;
90975 }
90976 /*
90977 * WriteReferences which exist after this border are unsafe because those
90978 * can modify the variable.
90979 */
90980
90981
90982 const border = getTopLoopNode(loopNode, kind === "let" ? declaration : null).range[0];
90983 /**
90984 * Checks whether a given reference is safe or not.
90985 * The reference is every reference of the upper scope's variable we are
90986 * looking now.
90987 *
90988 * It's safeafe if the reference matches one of the following condition.
90989 * - is readonly.
90990 * - doesn't exist inside a local function and after the border.
90991 * @param {eslint-scope.Reference} upperRef A reference to check.
90992 * @returns {boolean} `true` if the reference is safe.
90993 */
90994
90995 function isSafeReference(upperRef) {
90996 const id = upperRef.identifier;
90997 return !upperRef.isWrite() || variable.scope.variableScope === upperRef.from.variableScope && id.range[0] < border;
90998 }
90999
91000 return Boolean(variable) && variable.references.every(isSafeReference);
91001 } //------------------------------------------------------------------------------
91002 // Rule Definition
91003 //------------------------------------------------------------------------------
91004
91005
91006 module.exports = {
91007 meta: {
91008 type: "suggestion",
91009 docs: {
91010 description: "disallow function declarations that contain unsafe references inside loop statements",
91011 recommended: false,
91012 url: "https://eslint.org/docs/rules/no-loop-func"
91013 },
91014 schema: [],
91015 messages: {
91016 unsafeRefs: "Function declared in a loop contains unsafe references to variable(s) {{ varNames }}."
91017 }
91018 },
91019
91020 create(context) {
91021 /**
91022 * Reports functions which match the following condition:
91023 *
91024 * - has a loop node in ancestors.
91025 * - has any references which refers to an unsafe variable.
91026 * @param {ASTNode} node The AST node to check.
91027 * @returns {void}
91028 */
91029 function checkForLoops(node) {
91030 const loopNode = getContainingLoopNode(node);
91031
91032 if (!loopNode) {
91033 return;
91034 }
91035
91036 const references = context.getScope().through;
91037 const unsafeRefs = references.filter(r => !isSafe(loopNode, r)).map(r => r.identifier.name);
91038
91039 if (unsafeRefs.length > 0) {
91040 context.report({
91041 node,
91042 messageId: "unsafeRefs",
91043 data: {
91044 varNames: "'".concat(unsafeRefs.join("', '"), "'")
91045 }
91046 });
91047 }
91048 }
91049
91050 return {
91051 ArrowFunctionExpression: checkForLoops,
91052 FunctionExpression: checkForLoops,
91053 FunctionDeclaration: checkForLoops
91054 };
91055 }
91056
91057 };
91058
91059 /***/ }),
91060 /* 695 */
91061 /***/ ((module) => {
91062
91063 "use strict";
91064 /**
91065 * @fileoverview Rule to flag numbers that will lose significant figure precision at runtime
91066 * @author Jacob Moore
91067 */
91068 //------------------------------------------------------------------------------
91069 // Rule Definition
91070 //------------------------------------------------------------------------------
91071
91072 module.exports = {
91073 meta: {
91074 type: "problem",
91075 docs: {
91076 description: "disallow literal numbers that lose precision",
91077 recommended: true,
91078 url: "https://eslint.org/docs/rules/no-loss-of-precision"
91079 },
91080 schema: [],
91081 messages: {
91082 noLossOfPrecision: "This number literal will lose precision at runtime."
91083 }
91084 },
91085
91086 create(context) {
91087 /**
91088 * Returns whether the node is number literal
91089 * @param {Node} node the node literal being evaluated
91090 * @returns {boolean} true if the node is a number literal
91091 */
91092 function isNumber(node) {
91093 return typeof node.value === "number";
91094 }
91095 /**
91096 * Gets the source code of the given number literal. Removes `_` numeric separators from the result.
91097 * @param {Node} node the number `Literal` node
91098 * @returns {string} raw source code of the literal, without numeric separators
91099 */
91100
91101
91102 function getRaw(node) {
91103 return node.raw.replace(/_/gu, "");
91104 }
91105 /**
91106 * Checks whether the number is base ten
91107 * @param {ASTNode} node the node being evaluated
91108 * @returns {boolean} true if the node is in base ten
91109 */
91110
91111
91112 function isBaseTen(node) {
91113 const prefixes = ["0x", "0X", "0b", "0B", "0o", "0O"];
91114 return prefixes.every(prefix => !node.raw.startsWith(prefix)) && !/^0[0-7]+$/u.test(node.raw);
91115 }
91116 /**
91117 * Checks that the user-intended non-base ten number equals the actual number after is has been converted to the Number type
91118 * @param {Node} node the node being evaluated
91119 * @returns {boolean} true if they do not match
91120 */
91121
91122
91123 function notBaseTenLosesPrecision(node) {
91124 const rawString = getRaw(node).toUpperCase();
91125 let base = 0;
91126
91127 if (rawString.startsWith("0B")) {
91128 base = 2;
91129 } else if (rawString.startsWith("0X")) {
91130 base = 16;
91131 } else {
91132 base = 8;
91133 }
91134
91135 return !rawString.endsWith(node.value.toString(base).toUpperCase());
91136 }
91137 /**
91138 * Adds a decimal point to the numeric string at index 1
91139 * @param {string} stringNumber the numeric string without any decimal point
91140 * @returns {string} the numeric string with a decimal point in the proper place
91141 */
91142
91143
91144 function addDecimalPointToNumber(stringNumber) {
91145 return "".concat(stringNumber.slice(0, 1), ".").concat(stringNumber.slice(1));
91146 }
91147 /**
91148 * Returns the number stripped of leading zeros
91149 * @param {string} numberAsString the string representation of the number
91150 * @returns {string} the stripped string
91151 */
91152
91153
91154 function removeLeadingZeros(numberAsString) {
91155 return numberAsString.replace(/^0*/u, "");
91156 }
91157 /**
91158 * Returns the number stripped of trailing zeros
91159 * @param {string} numberAsString the string representation of the number
91160 * @returns {string} the stripped string
91161 */
91162
91163
91164 function removeTrailingZeros(numberAsString) {
91165 return numberAsString.replace(/0*$/u, "");
91166 }
91167 /**
91168 * Converts an integer to to an object containing the integer's coefficient and order of magnitude
91169 * @param {string} stringInteger the string representation of the integer being converted
91170 * @returns {Object} the object containing the integer's coefficient and order of magnitude
91171 */
91172
91173
91174 function normalizeInteger(stringInteger) {
91175 const significantDigits = removeTrailingZeros(removeLeadingZeros(stringInteger));
91176 return {
91177 magnitude: stringInteger.startsWith("0") ? stringInteger.length - 2 : stringInteger.length - 1,
91178 coefficient: addDecimalPointToNumber(significantDigits)
91179 };
91180 }
91181 /**
91182 *
91183 * Converts a float to to an object containing the floats's coefficient and order of magnitude
91184 * @param {string} stringFloat the string representation of the float being converted
91185 * @returns {Object} the object containing the integer's coefficient and order of magnitude
91186 */
91187
91188
91189 function normalizeFloat(stringFloat) {
91190 const trimmedFloat = removeLeadingZeros(stringFloat);
91191
91192 if (trimmedFloat.startsWith(".")) {
91193 const decimalDigits = trimmedFloat.split(".").pop();
91194 const significantDigits = removeLeadingZeros(decimalDigits);
91195 return {
91196 magnitude: significantDigits.length - decimalDigits.length - 1,
91197 coefficient: addDecimalPointToNumber(significantDigits)
91198 };
91199 }
91200
91201 return {
91202 magnitude: trimmedFloat.indexOf(".") - 1,
91203 coefficient: addDecimalPointToNumber(trimmedFloat.replace(".", ""))
91204 };
91205 }
91206 /**
91207 * Converts a base ten number to proper scientific notation
91208 * @param {string} stringNumber the string representation of the base ten number to be converted
91209 * @returns {string} the number converted to scientific notation
91210 */
91211
91212
91213 function convertNumberToScientificNotation(stringNumber) {
91214 const splitNumber = stringNumber.replace("E", "e").split("e");
91215 const originalCoefficient = splitNumber[0];
91216 const normalizedNumber = stringNumber.includes(".") ? normalizeFloat(originalCoefficient) : normalizeInteger(originalCoefficient);
91217 const normalizedCoefficient = normalizedNumber.coefficient;
91218 const magnitude = splitNumber.length > 1 ? parseInt(splitNumber[1], 10) + normalizedNumber.magnitude : normalizedNumber.magnitude;
91219 return "".concat(normalizedCoefficient, "e").concat(magnitude);
91220 }
91221 /**
91222 * Checks that the user-intended base ten number equals the actual number after is has been converted to the Number type
91223 * @param {Node} node the node being evaluated
91224 * @returns {boolean} true if they do not match
91225 */
91226
91227
91228 function baseTenLosesPrecision(node) {
91229 const normalizedRawNumber = convertNumberToScientificNotation(getRaw(node));
91230 const requestedPrecision = normalizedRawNumber.split("e")[0].replace(".", "").length;
91231
91232 if (requestedPrecision > 100) {
91233 return true;
91234 }
91235
91236 const storedNumber = node.value.toPrecision(requestedPrecision);
91237 const normalizedStoredNumber = convertNumberToScientificNotation(storedNumber);
91238 return normalizedRawNumber !== normalizedStoredNumber;
91239 }
91240 /**
91241 * Checks that the user-intended number equals the actual number after is has been converted to the Number type
91242 * @param {Node} node the node being evaluated
91243 * @returns {boolean} true if they do not match
91244 */
91245
91246
91247 function losesPrecision(node) {
91248 return isBaseTen(node) ? baseTenLosesPrecision(node) : notBaseTenLosesPrecision(node);
91249 }
91250
91251 return {
91252 Literal(node) {
91253 if (node.value && isNumber(node) && losesPrecision(node)) {
91254 context.report({
91255 messageId: "noLossOfPrecision",
91256 node
91257 });
91258 }
91259 }
91260
91261 };
91262 }
91263
91264 };
91265
91266 /***/ }),
91267 /* 696 */
91268 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
91269
91270 "use strict";
91271 /**
91272 * @fileoverview Rule to flag statements that use magic numbers (adapted from https://github.com/danielstjules/buddy.js)
91273 * @author Vincent Lemeunier
91274 */
91275
91276
91277 const astUtils = __webpack_require__(548); // Maximum array length by the ECMAScript Specification.
91278
91279
91280 const MAX_ARRAY_LENGTH = 2 ** 32 - 1; //------------------------------------------------------------------------------
91281 // Rule Definition
91282 //------------------------------------------------------------------------------
91283
91284 /**
91285 * Convert the value to bigint if it's a string. Otherwise return the value as-is.
91286 * @param {bigint|number|string} x The value to normalize.
91287 * @returns {bigint|number} The normalized value.
91288 */
91289
91290 function normalizeIgnoreValue(x) {
91291 if (typeof x === "string") {
91292 return BigInt(x.slice(0, -1));
91293 }
91294
91295 return x;
91296 }
91297
91298 module.exports = {
91299 meta: {
91300 type: "suggestion",
91301 docs: {
91302 description: "disallow magic numbers",
91303 recommended: false,
91304 url: "https://eslint.org/docs/rules/no-magic-numbers"
91305 },
91306 schema: [{
91307 type: "object",
91308 properties: {
91309 detectObjects: {
91310 type: "boolean",
91311 default: false
91312 },
91313 enforceConst: {
91314 type: "boolean",
91315 default: false
91316 },
91317 ignore: {
91318 type: "array",
91319 items: {
91320 anyOf: [{
91321 type: "number"
91322 }, {
91323 type: "string",
91324 pattern: "^[+-]?(?:0|[1-9][0-9]*)n$"
91325 }]
91326 },
91327 uniqueItems: true
91328 },
91329 ignoreArrayIndexes: {
91330 type: "boolean",
91331 default: false
91332 },
91333 ignoreDefaultValues: {
91334 type: "boolean",
91335 default: false
91336 }
91337 },
91338 additionalProperties: false
91339 }],
91340 messages: {
91341 useConst: "Number constants declarations must use 'const'.",
91342 noMagic: "No magic number: {{raw}}."
91343 }
91344 },
91345
91346 create(context) {
91347 const config = context.options[0] || {},
91348 detectObjects = !!config.detectObjects,
91349 enforceConst = !!config.enforceConst,
91350 ignore = (config.ignore || []).map(normalizeIgnoreValue),
91351 ignoreArrayIndexes = !!config.ignoreArrayIndexes,
91352 ignoreDefaultValues = !!config.ignoreDefaultValues;
91353 const okTypes = detectObjects ? [] : ["ObjectExpression", "Property", "AssignmentExpression"];
91354 /**
91355 * Returns whether the rule is configured to ignore the given value
91356 * @param {bigint|number} value The value to check
91357 * @returns {boolean} true if the value is ignored
91358 */
91359
91360 function isIgnoredValue(value) {
91361 return ignore.indexOf(value) !== -1;
91362 }
91363 /**
91364 * Returns whether the number is a default value assignment.
91365 * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
91366 * @returns {boolean} true if the number is a default value
91367 */
91368
91369
91370 function isDefaultValue(fullNumberNode) {
91371 const parent = fullNumberNode.parent;
91372 return parent.type === "AssignmentPattern" && parent.right === fullNumberNode;
91373 }
91374 /**
91375 * Returns whether the given node is used as a radix within parseInt() or Number.parseInt()
91376 * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
91377 * @returns {boolean} true if the node is radix
91378 */
91379
91380
91381 function isParseIntRadix(fullNumberNode) {
91382 const parent = fullNumberNode.parent;
91383 return parent.type === "CallExpression" && fullNumberNode === parent.arguments[1] && (astUtils.isSpecificId(parent.callee, "parseInt") || astUtils.isSpecificMemberAccess(parent.callee, "Number", "parseInt"));
91384 }
91385 /**
91386 * Returns whether the given node is a direct child of a JSX node.
91387 * In particular, it aims to detect numbers used as prop values in JSX tags.
91388 * Example: <input maxLength={10} />
91389 * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
91390 * @returns {boolean} true if the node is a JSX number
91391 */
91392
91393
91394 function isJSXNumber(fullNumberNode) {
91395 return fullNumberNode.parent.type.indexOf("JSX") === 0;
91396 }
91397 /**
91398 * Returns whether the given node is used as an array index.
91399 * Value must coerce to a valid array index name: "0", "1", "2" ... "4294967294".
91400 *
91401 * All other values, like "-1", "2.5", or "4294967295", are just "normal" object properties,
91402 * which can be created and accessed on an array in addition to the array index properties,
91403 * but they don't affect array's length and are not considered by methods such as .map(), .forEach() etc.
91404 *
91405 * The maximum array length by the specification is 2 ** 32 - 1 = 4294967295,
91406 * thus the maximum valid index is 2 ** 32 - 2 = 4294967294.
91407 *
91408 * All notations are allowed, as long as the value coerces to one of "0", "1", "2" ... "4294967294".
91409 *
91410 * Valid examples:
91411 * a[0], a[1], a[1.2e1], a[0xAB], a[0n], a[1n]
91412 * a[-0] (same as a[0] because -0 coerces to "0")
91413 * a[-0n] (-0n evaluates to 0n)
91414 *
91415 * Invalid examples:
91416 * a[-1], a[-0xAB], a[-1n], a[2.5], a[1.23e1], a[12e-1]
91417 * a[4294967295] (above the max index, it's an access to a regular property a["4294967295"])
91418 * a[999999999999999999999] (even if it wasn't above the max index, it would be a["1e+21"])
91419 * a[1e310] (same as a["Infinity"])
91420 * @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
91421 * @param {bigint|number} value Value expressed by the fullNumberNode
91422 * @returns {boolean} true if the node is a valid array index
91423 */
91424
91425
91426 function isArrayIndex(fullNumberNode, value) {
91427 const parent = fullNumberNode.parent;
91428 return parent.type === "MemberExpression" && parent.property === fullNumberNode && (Number.isInteger(value) || typeof value === "bigint") && value >= 0 && value < MAX_ARRAY_LENGTH;
91429 }
91430
91431 return {
91432 Literal(node) {
91433 if (!astUtils.isNumericLiteral(node)) {
91434 return;
91435 }
91436
91437 let fullNumberNode;
91438 let value;
91439 let raw; // Treat unary minus as a part of the number
91440
91441 if (node.parent.type === "UnaryExpression" && node.parent.operator === "-") {
91442 fullNumberNode = node.parent;
91443 value = -node.value;
91444 raw = "-".concat(node.raw);
91445 } else {
91446 fullNumberNode = node;
91447 value = node.value;
91448 raw = node.raw;
91449 }
91450
91451 const parent = fullNumberNode.parent; // Always allow radix arguments and JSX props
91452
91453 if (isIgnoredValue(value) || ignoreDefaultValues && isDefaultValue(fullNumberNode) || isParseIntRadix(fullNumberNode) || isJSXNumber(fullNumberNode) || ignoreArrayIndexes && isArrayIndex(fullNumberNode, value)) {
91454 return;
91455 }
91456
91457 if (parent.type === "VariableDeclarator") {
91458 if (enforceConst && parent.parent.kind !== "const") {
91459 context.report({
91460 node: fullNumberNode,
91461 messageId: "useConst"
91462 });
91463 }
91464 } else if (okTypes.indexOf(parent.type) === -1 || parent.type === "AssignmentExpression" && parent.left.type === "Identifier") {
91465 context.report({
91466 node: fullNumberNode,
91467 messageId: "noMagic",
91468 data: {
91469 raw
91470 }
91471 });
91472 }
91473 }
91474
91475 };
91476 }
91477
91478 };
91479
91480 /***/ }),
91481 /* 697 */
91482 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
91483
91484 "use strict";
91485 /**
91486 * @author Toru Nagashima <https://github.com/mysticatea>
91487 */
91488
91489
91490 const {
91491 CALL,
91492 CONSTRUCT,
91493 ReferenceTracker,
91494 getStringIfConstant
91495 } = __webpack_require__(501);
91496
91497 const {
91498 RegExpParser,
91499 visitRegExpAST
91500 } = __webpack_require__(651);
91501
91502 const {
91503 isCombiningCharacter,
91504 isEmojiModifier,
91505 isRegionalIndicatorSymbol,
91506 isSurrogatePair
91507 } = __webpack_require__(698); //------------------------------------------------------------------------------
91508 // Helpers
91509 //------------------------------------------------------------------------------
91510
91511 /**
91512 * Iterate character sequences of a given nodes.
91513 *
91514 * CharacterClassRange syntax can steal a part of character sequence,
91515 * so this function reverts CharacterClassRange syntax and restore the sequence.
91516 * @param {regexpp.AST.CharacterClassElement[]} nodes The node list to iterate character sequences.
91517 * @returns {IterableIterator<number[]>} The list of character sequences.
91518 */
91519
91520
91521 function* iterateCharacterSequence(nodes) {
91522 let seq = [];
91523
91524 for (const node of nodes) {
91525 switch (node.type) {
91526 case "Character":
91527 seq.push(node.value);
91528 break;
91529
91530 case "CharacterClassRange":
91531 seq.push(node.min.value);
91532 yield seq;
91533 seq = [node.max.value];
91534 break;
91535
91536 case "CharacterSet":
91537 if (seq.length > 0) {
91538 yield seq;
91539 seq = [];
91540 }
91541
91542 break;
91543 // no default
91544 }
91545 }
91546
91547 if (seq.length > 0) {
91548 yield seq;
91549 }
91550 }
91551
91552 const hasCharacterSequence = {
91553 surrogatePairWithoutUFlag(chars) {
91554 return chars.some((c, i) => i !== 0 && isSurrogatePair(chars[i - 1], c));
91555 },
91556
91557 combiningClass(chars) {
91558 return chars.some((c, i) => i !== 0 && isCombiningCharacter(c) && !isCombiningCharacter(chars[i - 1]));
91559 },
91560
91561 emojiModifier(chars) {
91562 return chars.some((c, i) => i !== 0 && isEmojiModifier(c) && !isEmojiModifier(chars[i - 1]));
91563 },
91564
91565 regionalIndicatorSymbol(chars) {
91566 return chars.some((c, i) => i !== 0 && isRegionalIndicatorSymbol(c) && isRegionalIndicatorSymbol(chars[i - 1]));
91567 },
91568
91569 zwj(chars) {
91570 const lastIndex = chars.length - 1;
91571 return chars.some((c, i) => i !== 0 && i !== lastIndex && c === 0x200d && chars[i - 1] !== 0x200d && chars[i + 1] !== 0x200d);
91572 }
91573
91574 };
91575 const kinds = Object.keys(hasCharacterSequence); //------------------------------------------------------------------------------
91576 // Rule Definition
91577 //------------------------------------------------------------------------------
91578
91579 module.exports = {
91580 meta: {
91581 type: "problem",
91582 docs: {
91583 description: "disallow characters which are made with multiple code points in character class syntax",
91584 recommended: true,
91585 url: "https://eslint.org/docs/rules/no-misleading-character-class"
91586 },
91587 schema: [],
91588 messages: {
91589 surrogatePairWithoutUFlag: "Unexpected surrogate pair in character class. Use 'u' flag.",
91590 combiningClass: "Unexpected combined character in character class.",
91591 emojiModifier: "Unexpected modified Emoji in character class.",
91592 regionalIndicatorSymbol: "Unexpected national flag in character class.",
91593 zwj: "Unexpected joined character sequence in character class."
91594 }
91595 },
91596
91597 create(context) {
91598 const parser = new RegExpParser();
91599 /**
91600 * Verify a given regular expression.
91601 * @param {Node} node The node to report.
91602 * @param {string} pattern The regular expression pattern to verify.
91603 * @param {string} flags The flags of the regular expression.
91604 * @returns {void}
91605 */
91606
91607 function verify(node, pattern, flags) {
91608 const has = {
91609 surrogatePairWithoutUFlag: false,
91610 combiningClass: false,
91611 variationSelector: false,
91612 emojiModifier: false,
91613 regionalIndicatorSymbol: false,
91614 zwj: false
91615 };
91616 let patternNode;
91617
91618 try {
91619 patternNode = parser.parsePattern(pattern, 0, pattern.length, flags.includes("u"));
91620 } catch {
91621 // Ignore regular expressions with syntax errors
91622 return;
91623 }
91624
91625 visitRegExpAST(patternNode, {
91626 onCharacterClassEnter(ccNode) {
91627 for (const chars of iterateCharacterSequence(ccNode.elements)) {
91628 for (const kind of kinds) {
91629 has[kind] = has[kind] || hasCharacterSequence[kind](chars);
91630 }
91631 }
91632 }
91633
91634 });
91635
91636 for (const kind of kinds) {
91637 if (has[kind]) {
91638 context.report({
91639 node,
91640 messageId: kind
91641 });
91642 }
91643 }
91644 }
91645
91646 return {
91647 "Literal[regex]"(node) {
91648 verify(node, node.regex.pattern, node.regex.flags);
91649 },
91650
91651 "Program"() {
91652 const scope = context.getScope();
91653 const tracker = new ReferenceTracker(scope);
91654 /*
91655 * Iterate calls of RegExp.
91656 * E.g., `new RegExp()`, `RegExp()`, `new window.RegExp()`,
91657 * `const {RegExp: a} = window; new a()`, etc...
91658 */
91659
91660 for (const {
91661 node
91662 } of tracker.iterateGlobalReferences({
91663 RegExp: {
91664 [CALL]: true,
91665 [CONSTRUCT]: true
91666 }
91667 })) {
91668 const [patternNode, flagsNode] = node.arguments;
91669 const pattern = getStringIfConstant(patternNode, scope);
91670 const flags = getStringIfConstant(flagsNode, scope);
91671
91672 if (typeof pattern === "string") {
91673 verify(node, pattern, flags || "");
91674 }
91675 }
91676 }
91677
91678 };
91679 }
91680
91681 };
91682
91683 /***/ }),
91684 /* 698 */
91685 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
91686
91687 "use strict";
91688 /**
91689 * @author Toru Nagashima <https://github.com/mysticatea>
91690 */
91691
91692
91693 module.exports = {
91694 isCombiningCharacter: __webpack_require__(699),
91695 isEmojiModifier: __webpack_require__(700),
91696 isRegionalIndicatorSymbol: __webpack_require__(701),
91697 isSurrogatePair: __webpack_require__(702)
91698 };
91699
91700 /***/ }),
91701 /* 699 */
91702 /***/ ((module) => {
91703
91704 "use strict";
91705 /**
91706 * @author Toru Nagashima <https://github.com/mysticatea>
91707 */
91708
91709 /**
91710 * Check whether a given character is a combining mark or not.
91711 * @param {number} codePoint The character code to check.
91712 * @returns {boolean} `true` if the character belongs to the category, any of `Mc`, `Me`, and `Mn`.
91713 */
91714
91715 module.exports = function isCombiningCharacter(codePoint) {
91716 return /^[\p{Mc}\p{Me}\p{Mn}]$/u.test(String.fromCodePoint(codePoint));
91717 };
91718
91719 /***/ }),
91720 /* 700 */
91721 /***/ ((module) => {
91722
91723 "use strict";
91724 /**
91725 * @author Toru Nagashima <https://github.com/mysticatea>
91726 */
91727
91728 /**
91729 * Check whether a given character is an emoji modifier.
91730 * @param {number} code The character code to check.
91731 * @returns {boolean} `true` if the character is an emoji modifier.
91732 */
91733
91734 module.exports = function isEmojiModifier(code) {
91735 return code >= 0x1F3FB && code <= 0x1F3FF;
91736 };
91737
91738 /***/ }),
91739 /* 701 */
91740 /***/ ((module) => {
91741
91742 "use strict";
91743 /**
91744 * @author Toru Nagashima <https://github.com/mysticatea>
91745 */
91746
91747 /**
91748 * Check whether a given character is a regional indicator symbol.
91749 * @param {number} code The character code to check.
91750 * @returns {boolean} `true` if the character is a regional indicator symbol.
91751 */
91752
91753 module.exports = function isRegionalIndicatorSymbol(code) {
91754 return code >= 0x1F1E6 && code <= 0x1F1FF;
91755 };
91756
91757 /***/ }),
91758 /* 702 */
91759 /***/ ((module) => {
91760
91761 "use strict";
91762 /**
91763 * @author Toru Nagashima <https://github.com/mysticatea>
91764 */
91765
91766 /**
91767 * Check whether given two characters are a surrogate pair.
91768 * @param {number} lead The code of the lead character.
91769 * @param {number} tail The code of the tail character.
91770 * @returns {boolean} `true` if the character pair is a surrogate pair.
91771 */
91772
91773 module.exports = function isSurrogatePair(lead, tail) {
91774 return lead >= 0xD800 && lead < 0xDC00 && tail >= 0xDC00 && tail < 0xE000;
91775 };
91776
91777 /***/ }),
91778 /* 703 */
91779 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
91780
91781 "use strict";
91782 /**
91783 * @fileoverview Rule to disallow mixed binary operators.
91784 * @author Toru Nagashima
91785 */
91786 //------------------------------------------------------------------------------
91787 // Requirements
91788 //------------------------------------------------------------------------------
91789
91790 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
91791 // Helpers
91792 //------------------------------------------------------------------------------
91793
91794
91795 const ARITHMETIC_OPERATORS = ["+", "-", "*", "/", "%", "**"];
91796 const BITWISE_OPERATORS = ["&", "|", "^", "~", "<<", ">>", ">>>"];
91797 const COMPARISON_OPERATORS = ["==", "!=", "===", "!==", ">", ">=", "<", "<="];
91798 const LOGICAL_OPERATORS = ["&&", "||"];
91799 const RELATIONAL_OPERATORS = ["in", "instanceof"];
91800 const TERNARY_OPERATOR = ["?:"];
91801 const COALESCE_OPERATOR = ["??"];
91802 const ALL_OPERATORS = [].concat(ARITHMETIC_OPERATORS, BITWISE_OPERATORS, COMPARISON_OPERATORS, LOGICAL_OPERATORS, RELATIONAL_OPERATORS, TERNARY_OPERATOR, COALESCE_OPERATOR);
91803 const DEFAULT_GROUPS = [ARITHMETIC_OPERATORS, BITWISE_OPERATORS, COMPARISON_OPERATORS, LOGICAL_OPERATORS, RELATIONAL_OPERATORS];
91804 const TARGET_NODE_TYPE = /^(?:Binary|Logical|Conditional)Expression$/u;
91805 /**
91806 * Normalizes options.
91807 * @param {Object|undefined} options A options object to normalize.
91808 * @returns {Object} Normalized option object.
91809 */
91810
91811 function normalizeOptions() {
91812 let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
91813 const hasGroups = options.groups && options.groups.length > 0;
91814 const groups = hasGroups ? options.groups : DEFAULT_GROUPS;
91815 const allowSamePrecedence = options.allowSamePrecedence !== false;
91816 return {
91817 groups,
91818 allowSamePrecedence
91819 };
91820 }
91821 /**
91822 * Checks whether any group which includes both given operator exists or not.
91823 * @param {Array<string[]>} groups A list of groups to check.
91824 * @param {string} left An operator.
91825 * @param {string} right Another operator.
91826 * @returns {boolean} `true` if such group existed.
91827 */
91828
91829
91830 function includesBothInAGroup(groups, left, right) {
91831 return groups.some(group => group.indexOf(left) !== -1 && group.indexOf(right) !== -1);
91832 }
91833 /**
91834 * Checks whether the given node is a conditional expression and returns the test node else the left node.
91835 * @param {ASTNode} node A node which can be a BinaryExpression or a LogicalExpression node.
91836 * This parent node can be BinaryExpression, LogicalExpression
91837 * , or a ConditionalExpression node
91838 * @returns {ASTNode} node the appropriate node(left or test).
91839 */
91840
91841
91842 function getChildNode(node) {
91843 return node.type === "ConditionalExpression" ? node.test : node.left;
91844 } //------------------------------------------------------------------------------
91845 // Rule Definition
91846 //------------------------------------------------------------------------------
91847
91848
91849 module.exports = {
91850 meta: {
91851 type: "suggestion",
91852 docs: {
91853 description: "disallow mixed binary operators",
91854 recommended: false,
91855 url: "https://eslint.org/docs/rules/no-mixed-operators"
91856 },
91857 schema: [{
91858 type: "object",
91859 properties: {
91860 groups: {
91861 type: "array",
91862 items: {
91863 type: "array",
91864 items: {
91865 enum: ALL_OPERATORS
91866 },
91867 minItems: 2,
91868 uniqueItems: true
91869 },
91870 uniqueItems: true
91871 },
91872 allowSamePrecedence: {
91873 type: "boolean",
91874 default: true
91875 }
91876 },
91877 additionalProperties: false
91878 }],
91879 messages: {
91880 unexpectedMixedOperator: "Unexpected mix of '{{leftOperator}}' and '{{rightOperator}}'. Use parentheses to clarify the intended order of operations."
91881 }
91882 },
91883
91884 create(context) {
91885 const sourceCode = context.getSourceCode();
91886 const options = normalizeOptions(context.options[0]);
91887 /**
91888 * Checks whether a given node should be ignored by options or not.
91889 * @param {ASTNode} node A node to check. This is a BinaryExpression
91890 * node or a LogicalExpression node. This parent node is one of
91891 * them, too.
91892 * @returns {boolean} `true` if the node should be ignored.
91893 */
91894
91895 function shouldIgnore(node) {
91896 const a = node;
91897 const b = node.parent;
91898 return !includesBothInAGroup(options.groups, a.operator, b.type === "ConditionalExpression" ? "?:" : b.operator) || options.allowSamePrecedence && astUtils.getPrecedence(a) === astUtils.getPrecedence(b);
91899 }
91900 /**
91901 * Checks whether the operator of a given node is mixed with parent
91902 * node's operator or not.
91903 * @param {ASTNode} node A node to check. This is a BinaryExpression
91904 * node or a LogicalExpression node. This parent node is one of
91905 * them, too.
91906 * @returns {boolean} `true` if the node was mixed.
91907 */
91908
91909
91910 function isMixedWithParent(node) {
91911 return node.operator !== node.parent.operator && !astUtils.isParenthesised(sourceCode, node);
91912 }
91913 /**
91914 * Gets the operator token of a given node.
91915 * @param {ASTNode} node A node to check. This is a BinaryExpression
91916 * node or a LogicalExpression node.
91917 * @returns {Token} The operator token of the node.
91918 */
91919
91920
91921 function getOperatorToken(node) {
91922 return sourceCode.getTokenAfter(getChildNode(node), astUtils.isNotClosingParenToken);
91923 }
91924 /**
91925 * Reports both the operator of a given node and the operator of the
91926 * parent node.
91927 * @param {ASTNode} node A node to check. This is a BinaryExpression
91928 * node or a LogicalExpression node. This parent node is one of
91929 * them, too.
91930 * @returns {void}
91931 */
91932
91933
91934 function reportBothOperators(node) {
91935 const parent = node.parent;
91936 const left = getChildNode(parent) === node ? node : parent;
91937 const right = getChildNode(parent) !== node ? node : parent;
91938 const data = {
91939 leftOperator: left.operator || "?:",
91940 rightOperator: right.operator || "?:"
91941 };
91942 context.report({
91943 node: left,
91944 loc: getOperatorToken(left).loc,
91945 messageId: "unexpectedMixedOperator",
91946 data
91947 });
91948 context.report({
91949 node: right,
91950 loc: getOperatorToken(right).loc,
91951 messageId: "unexpectedMixedOperator",
91952 data
91953 });
91954 }
91955 /**
91956 * Checks between the operator of this node and the operator of the
91957 * parent node.
91958 * @param {ASTNode} node A node to check.
91959 * @returns {void}
91960 */
91961
91962
91963 function check(node) {
91964 if (TARGET_NODE_TYPE.test(node.parent.type) && isMixedWithParent(node) && !shouldIgnore(node)) {
91965 reportBothOperators(node);
91966 }
91967 }
91968
91969 return {
91970 BinaryExpression: check,
91971 LogicalExpression: check
91972 };
91973 }
91974
91975 };
91976
91977 /***/ }),
91978 /* 704 */
91979 /***/ ((module) => {
91980
91981 "use strict";
91982 /**
91983 * @fileoverview Rule to enforce grouped require statements for Node.JS
91984 * @author Raphael Pigulla
91985 * @deprecated in ESLint v7.0.0
91986 */
91987 //------------------------------------------------------------------------------
91988 // Rule Definition
91989 //------------------------------------------------------------------------------
91990
91991 module.exports = {
91992 meta: {
91993 deprecated: true,
91994 replacedBy: [],
91995 type: "suggestion",
91996 docs: {
91997 description: "disallow `require` calls to be mixed with regular variable declarations",
91998 recommended: false,
91999 url: "https://eslint.org/docs/rules/no-mixed-requires"
92000 },
92001 schema: [{
92002 oneOf: [{
92003 type: "boolean"
92004 }, {
92005 type: "object",
92006 properties: {
92007 grouping: {
92008 type: "boolean"
92009 },
92010 allowCall: {
92011 type: "boolean"
92012 }
92013 },
92014 additionalProperties: false
92015 }]
92016 }],
92017 messages: {
92018 noMixRequire: "Do not mix 'require' and other declarations.",
92019 noMixCoreModuleFileComputed: "Do not mix core, module, file and computed requires."
92020 }
92021 },
92022
92023 create(context) {
92024 const options = context.options[0];
92025 let grouping = false,
92026 allowCall = false;
92027
92028 if (typeof options === "object") {
92029 grouping = options.grouping;
92030 allowCall = options.allowCall;
92031 } else {
92032 grouping = !!options;
92033 }
92034 /**
92035 * Returns the list of built-in modules.
92036 * @returns {string[]} An array of built-in Node.js modules.
92037 */
92038
92039
92040 function getBuiltinModules() {
92041 /*
92042 * This list is generated using:
92043 * `require("repl")._builtinLibs.concat('repl').sort()`
92044 * This particular list is as per nodejs v0.12.2 and iojs v0.7.1
92045 */
92046 return ["assert", "buffer", "child_process", "cluster", "crypto", "dgram", "dns", "domain", "events", "fs", "http", "https", "net", "os", "path", "punycode", "querystring", "readline", "repl", "smalloc", "stream", "string_decoder", "tls", "tty", "url", "util", "v8", "vm", "zlib"];
92047 }
92048
92049 const BUILTIN_MODULES = getBuiltinModules();
92050 const DECL_REQUIRE = "require",
92051 DECL_UNINITIALIZED = "uninitialized",
92052 DECL_OTHER = "other";
92053 const REQ_CORE = "core",
92054 REQ_FILE = "file",
92055 REQ_MODULE = "module",
92056 REQ_COMPUTED = "computed";
92057 /**
92058 * Determines the type of a declaration statement.
92059 * @param {ASTNode} initExpression The init node of the VariableDeclarator.
92060 * @returns {string} The type of declaration represented by the expression.
92061 */
92062
92063 function getDeclarationType(initExpression) {
92064 if (!initExpression) {
92065 // "var x;"
92066 return DECL_UNINITIALIZED;
92067 }
92068
92069 if (initExpression.type === "CallExpression" && initExpression.callee.type === "Identifier" && initExpression.callee.name === "require") {
92070 // "var x = require('util');"
92071 return DECL_REQUIRE;
92072 }
92073
92074 if (allowCall && initExpression.type === "CallExpression" && initExpression.callee.type === "CallExpression") {
92075 // "var x = require('diagnose')('sub-module');"
92076 return getDeclarationType(initExpression.callee);
92077 }
92078
92079 if (initExpression.type === "MemberExpression") {
92080 // "var x = require('glob').Glob;"
92081 return getDeclarationType(initExpression.object);
92082 } // "var x = 42;"
92083
92084
92085 return DECL_OTHER;
92086 }
92087 /**
92088 * Determines the type of module that is loaded via require.
92089 * @param {ASTNode} initExpression The init node of the VariableDeclarator.
92090 * @returns {string} The module type.
92091 */
92092
92093
92094 function inferModuleType(initExpression) {
92095 if (initExpression.type === "MemberExpression") {
92096 // "var x = require('glob').Glob;"
92097 return inferModuleType(initExpression.object);
92098 }
92099
92100 if (initExpression.arguments.length === 0) {
92101 // "var x = require();"
92102 return REQ_COMPUTED;
92103 }
92104
92105 const arg = initExpression.arguments[0];
92106
92107 if (arg.type !== "Literal" || typeof arg.value !== "string") {
92108 // "var x = require(42);"
92109 return REQ_COMPUTED;
92110 }
92111
92112 if (BUILTIN_MODULES.indexOf(arg.value) !== -1) {
92113 // "var fs = require('fs');"
92114 return REQ_CORE;
92115 }
92116
92117 if (/^\.{0,2}\//u.test(arg.value)) {
92118 // "var utils = require('./utils');"
92119 return REQ_FILE;
92120 } // "var async = require('async');"
92121
92122
92123 return REQ_MODULE;
92124 }
92125 /**
92126 * Check if the list of variable declarations is mixed, i.e. whether it
92127 * contains both require and other declarations.
92128 * @param {ASTNode} declarations The list of VariableDeclarators.
92129 * @returns {boolean} True if the declarations are mixed, false if not.
92130 */
92131
92132
92133 function isMixed(declarations) {
92134 const contains = {};
92135 declarations.forEach(declaration => {
92136 const type = getDeclarationType(declaration.init);
92137 contains[type] = true;
92138 });
92139 return !!(contains[DECL_REQUIRE] && (contains[DECL_UNINITIALIZED] || contains[DECL_OTHER]));
92140 }
92141 /**
92142 * Check if all require declarations in the given list are of the same
92143 * type.
92144 * @param {ASTNode} declarations The list of VariableDeclarators.
92145 * @returns {boolean} True if the declarations are grouped, false if not.
92146 */
92147
92148
92149 function isGrouped(declarations) {
92150 const found = {};
92151 declarations.forEach(declaration => {
92152 if (getDeclarationType(declaration.init) === DECL_REQUIRE) {
92153 found[inferModuleType(declaration.init)] = true;
92154 }
92155 });
92156 return Object.keys(found).length <= 1;
92157 }
92158
92159 return {
92160 VariableDeclaration(node) {
92161 if (isMixed(node.declarations)) {
92162 context.report({
92163 node,
92164 messageId: "noMixRequire"
92165 });
92166 } else if (grouping && !isGrouped(node.declarations)) {
92167 context.report({
92168 node,
92169 messageId: "noMixCoreModuleFileComputed"
92170 });
92171 }
92172 }
92173
92174 };
92175 }
92176
92177 };
92178
92179 /***/ }),
92180 /* 705 */
92181 /***/ ((module) => {
92182
92183 "use strict";
92184 /**
92185 * @fileoverview Disallow mixed spaces and tabs for indentation
92186 * @author Jary Niebur
92187 */
92188 //------------------------------------------------------------------------------
92189 // Rule Definition
92190 //------------------------------------------------------------------------------
92191
92192 module.exports = {
92193 meta: {
92194 type: "layout",
92195 docs: {
92196 description: "disallow mixed spaces and tabs for indentation",
92197 recommended: true,
92198 url: "https://eslint.org/docs/rules/no-mixed-spaces-and-tabs"
92199 },
92200 schema: [{
92201 enum: ["smart-tabs", true, false]
92202 }],
92203 messages: {
92204 mixedSpacesAndTabs: "Mixed spaces and tabs."
92205 }
92206 },
92207
92208 create(context) {
92209 const sourceCode = context.getSourceCode();
92210 let smartTabs;
92211
92212 switch (context.options[0]) {
92213 case true: // Support old syntax, maybe add deprecation warning here
92214
92215 case "smart-tabs":
92216 smartTabs = true;
92217 break;
92218
92219 default:
92220 smartTabs = false;
92221 } //--------------------------------------------------------------------------
92222 // Public
92223 //--------------------------------------------------------------------------
92224
92225
92226 return {
92227 "Program:exit"(node) {
92228 const lines = sourceCode.lines,
92229 comments = sourceCode.getAllComments(),
92230 ignoredCommentLines = new Set(); // Add all lines except the first ones.
92231
92232 comments.forEach(comment => {
92233 for (let i = comment.loc.start.line + 1; i <= comment.loc.end.line; i++) {
92234 ignoredCommentLines.add(i);
92235 }
92236 });
92237 /*
92238 * At least one space followed by a tab
92239 * or the reverse before non-tab/-space
92240 * characters begin.
92241 */
92242
92243 let regex = /^(?=( +|\t+))\1(?:\t| )/u;
92244
92245 if (smartTabs) {
92246 /*
92247 * At least one space followed by a tab
92248 * before non-tab/-space characters begin.
92249 */
92250 regex = /^(?=(\t*))\1(?=( +))\2\t/u;
92251 }
92252
92253 lines.forEach((line, i) => {
92254 const match = regex.exec(line);
92255
92256 if (match) {
92257 const lineNumber = i + 1;
92258 const loc = {
92259 start: {
92260 line: lineNumber,
92261 column: match[0].length - 2
92262 },
92263 end: {
92264 line: lineNumber,
92265 column: match[0].length
92266 }
92267 };
92268
92269 if (!ignoredCommentLines.has(lineNumber)) {
92270 const containingNode = sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(loc.start));
92271
92272 if (!(containingNode && ["Literal", "TemplateElement"].includes(containingNode.type))) {
92273 context.report({
92274 node,
92275 loc,
92276 messageId: "mixedSpacesAndTabs"
92277 });
92278 }
92279 }
92280 }
92281 });
92282 }
92283
92284 };
92285 }
92286
92287 };
92288
92289 /***/ }),
92290 /* 706 */
92291 /***/ ((module) => {
92292
92293 "use strict";
92294 /**
92295 * @fileoverview Rule to check use of chained assignment expressions
92296 * @author Stewart Rand
92297 */
92298 //------------------------------------------------------------------------------
92299 // Rule Definition
92300 //------------------------------------------------------------------------------
92301
92302 module.exports = {
92303 meta: {
92304 type: "suggestion",
92305 docs: {
92306 description: "disallow use of chained assignment expressions",
92307 recommended: false,
92308 url: "https://eslint.org/docs/rules/no-multi-assign"
92309 },
92310 schema: [{
92311 type: "object",
92312 properties: {
92313 ignoreNonDeclaration: {
92314 type: "boolean",
92315 default: false
92316 }
92317 },
92318 additionalProperties: false
92319 }],
92320 messages: {
92321 unexpectedChain: "Unexpected chained assignment."
92322 }
92323 },
92324
92325 create(context) {
92326 //--------------------------------------------------------------------------
92327 // Public
92328 //--------------------------------------------------------------------------
92329 const options = context.options[0] || {
92330 ignoreNonDeclaration: false
92331 };
92332 const selectors = ["VariableDeclarator > AssignmentExpression.init", "PropertyDefinition > AssignmentExpression.value"];
92333
92334 if (!options.ignoreNonDeclaration) {
92335 selectors.push("AssignmentExpression > AssignmentExpression.right");
92336 }
92337
92338 return {
92339 [selectors](node) {
92340 context.report({
92341 node,
92342 messageId: "unexpectedChain"
92343 });
92344 }
92345
92346 };
92347 }
92348
92349 };
92350
92351 /***/ }),
92352 /* 707 */
92353 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
92354
92355 "use strict";
92356 /**
92357 * @fileoverview Disallow use of multiple spaces.
92358 * @author Nicholas C. Zakas
92359 */
92360
92361
92362 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
92363 // Rule Definition
92364 //------------------------------------------------------------------------------
92365
92366
92367 module.exports = {
92368 meta: {
92369 type: "layout",
92370 docs: {
92371 description: "disallow multiple spaces",
92372 recommended: false,
92373 url: "https://eslint.org/docs/rules/no-multi-spaces"
92374 },
92375 fixable: "whitespace",
92376 schema: [{
92377 type: "object",
92378 properties: {
92379 exceptions: {
92380 type: "object",
92381 patternProperties: {
92382 "^([A-Z][a-z]*)+$": {
92383 type: "boolean"
92384 }
92385 },
92386 additionalProperties: false
92387 },
92388 ignoreEOLComments: {
92389 type: "boolean",
92390 default: false
92391 }
92392 },
92393 additionalProperties: false
92394 }],
92395 messages: {
92396 multipleSpaces: "Multiple spaces found before '{{displayValue}}'."
92397 }
92398 },
92399
92400 create(context) {
92401 const sourceCode = context.getSourceCode();
92402 const options = context.options[0] || {};
92403 const ignoreEOLComments = options.ignoreEOLComments;
92404 const exceptions = Object.assign({
92405 Property: true
92406 }, options.exceptions);
92407 const hasExceptions = Object.keys(exceptions).filter(key => exceptions[key]).length > 0;
92408 /**
92409 * Formats value of given comment token for error message by truncating its length.
92410 * @param {Token} token comment token
92411 * @returns {string} formatted value
92412 * @private
92413 */
92414
92415 function formatReportedCommentValue(token) {
92416 const valueLines = token.value.split("\n");
92417 const value = valueLines[0];
92418 const formattedValue = "".concat(value.slice(0, 12), "...");
92419 return valueLines.length === 1 && value.length <= 12 ? value : formattedValue;
92420 } //--------------------------------------------------------------------------
92421 // Public
92422 //--------------------------------------------------------------------------
92423
92424
92425 return {
92426 Program() {
92427 sourceCode.tokensAndComments.forEach((leftToken, leftIndex, tokensAndComments) => {
92428 if (leftIndex === tokensAndComments.length - 1) {
92429 return;
92430 }
92431
92432 const rightToken = tokensAndComments[leftIndex + 1]; // Ignore tokens that don't have 2 spaces between them or are on different lines
92433
92434 if (!sourceCode.text.slice(leftToken.range[1], rightToken.range[0]).includes(" ") || leftToken.loc.end.line < rightToken.loc.start.line) {
92435 return;
92436 } // Ignore comments that are the last token on their line if `ignoreEOLComments` is active.
92437
92438
92439 if (ignoreEOLComments && astUtils.isCommentToken(rightToken) && (leftIndex === tokensAndComments.length - 2 || rightToken.loc.end.line < tokensAndComments[leftIndex + 2].loc.start.line)) {
92440 return;
92441 } // Ignore tokens that are in a node in the "exceptions" object
92442
92443
92444 if (hasExceptions) {
92445 const parentNode = sourceCode.getNodeByRangeIndex(rightToken.range[0] - 1);
92446
92447 if (parentNode && exceptions[parentNode.type]) {
92448 return;
92449 }
92450 }
92451
92452 let displayValue;
92453
92454 if (rightToken.type === "Block") {
92455 displayValue = "/*".concat(formatReportedCommentValue(rightToken), "*/");
92456 } else if (rightToken.type === "Line") {
92457 displayValue = "//".concat(formatReportedCommentValue(rightToken));
92458 } else {
92459 displayValue = rightToken.value;
92460 }
92461
92462 context.report({
92463 node: rightToken,
92464 loc: {
92465 start: leftToken.loc.end,
92466 end: rightToken.loc.start
92467 },
92468 messageId: "multipleSpaces",
92469 data: {
92470 displayValue
92471 },
92472 fix: fixer => fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], " ")
92473 });
92474 });
92475 }
92476
92477 };
92478 }
92479
92480 };
92481
92482 /***/ }),
92483 /* 708 */
92484 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
92485
92486 "use strict";
92487 /**
92488 * @fileoverview Rule to flag when using multiline strings
92489 * @author Ilya Volodin
92490 */
92491 //------------------------------------------------------------------------------
92492 // Requirements
92493 //------------------------------------------------------------------------------
92494
92495 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
92496 // Rule Definition
92497 //------------------------------------------------------------------------------
92498
92499
92500 module.exports = {
92501 meta: {
92502 type: "suggestion",
92503 docs: {
92504 description: "disallow multiline strings",
92505 recommended: false,
92506 url: "https://eslint.org/docs/rules/no-multi-str"
92507 },
92508 schema: [],
92509 messages: {
92510 multilineString: "Multiline support is limited to browsers supporting ES5 only."
92511 }
92512 },
92513
92514 create(context) {
92515 /**
92516 * Determines if a given node is part of JSX syntax.
92517 * @param {ASTNode} node The node to check.
92518 * @returns {boolean} True if the node is a JSX node, false if not.
92519 * @private
92520 */
92521 function isJSXElement(node) {
92522 return node.type.indexOf("JSX") === 0;
92523 } //--------------------------------------------------------------------------
92524 // Public API
92525 //--------------------------------------------------------------------------
92526
92527
92528 return {
92529 Literal(node) {
92530 if (astUtils.LINEBREAK_MATCHER.test(node.raw) && !isJSXElement(node.parent)) {
92531 context.report({
92532 node,
92533 messageId: "multilineString"
92534 });
92535 }
92536 }
92537
92538 };
92539 }
92540
92541 };
92542
92543 /***/ }),
92544 /* 709 */
92545 /***/ ((module) => {
92546
92547 "use strict";
92548 /**
92549 * @fileoverview Disallows multiple blank lines.
92550 * implementation adapted from the no-trailing-spaces rule.
92551 * @author Greg Cochard
92552 */
92553 //------------------------------------------------------------------------------
92554 // Rule Definition
92555 //------------------------------------------------------------------------------
92556
92557 module.exports = {
92558 meta: {
92559 type: "layout",
92560 docs: {
92561 description: "disallow multiple empty lines",
92562 recommended: false,
92563 url: "https://eslint.org/docs/rules/no-multiple-empty-lines"
92564 },
92565 fixable: "whitespace",
92566 schema: [{
92567 type: "object",
92568 properties: {
92569 max: {
92570 type: "integer",
92571 minimum: 0
92572 },
92573 maxEOF: {
92574 type: "integer",
92575 minimum: 0
92576 },
92577 maxBOF: {
92578 type: "integer",
92579 minimum: 0
92580 }
92581 },
92582 required: ["max"],
92583 additionalProperties: false
92584 }],
92585 messages: {
92586 blankBeginningOfFile: "Too many blank lines at the beginning of file. Max of {{max}} allowed.",
92587 blankEndOfFile: "Too many blank lines at the end of file. Max of {{max}} allowed.",
92588 consecutiveBlank: "More than {{max}} blank {{pluralizedLines}} not allowed."
92589 }
92590 },
92591
92592 create(context) {
92593 // Use options.max or 2 as default
92594 let max = 2,
92595 maxEOF = max,
92596 maxBOF = max;
92597
92598 if (context.options.length) {
92599 max = context.options[0].max;
92600 maxEOF = typeof context.options[0].maxEOF !== "undefined" ? context.options[0].maxEOF : max;
92601 maxBOF = typeof context.options[0].maxBOF !== "undefined" ? context.options[0].maxBOF : max;
92602 }
92603
92604 const sourceCode = context.getSourceCode(); // Swallow the final newline, as some editors add it automatically and we don't want it to cause an issue
92605
92606 const allLines = sourceCode.lines[sourceCode.lines.length - 1] === "" ? sourceCode.lines.slice(0, -1) : sourceCode.lines;
92607 const templateLiteralLines = new Set(); //--------------------------------------------------------------------------
92608 // Public
92609 //--------------------------------------------------------------------------
92610
92611 return {
92612 TemplateLiteral(node) {
92613 node.quasis.forEach(literalPart => {
92614 // Empty lines have a semantic meaning if they're inside template literals. Don't count these as empty lines.
92615 for (let ignoredLine = literalPart.loc.start.line; ignoredLine < literalPart.loc.end.line; ignoredLine++) {
92616 templateLiteralLines.add(ignoredLine);
92617 }
92618 });
92619 },
92620
92621 "Program:exit"(node) {
92622 return allLines // Given a list of lines, first get a list of line numbers that are non-empty.
92623 .reduce((nonEmptyLineNumbers, line, index) => {
92624 if (line.trim() || templateLiteralLines.has(index + 1)) {
92625 nonEmptyLineNumbers.push(index + 1);
92626 }
92627
92628 return nonEmptyLineNumbers;
92629 }, []) // Add a value at the end to allow trailing empty lines to be checked.
92630 .concat(allLines.length + 1) // Given two line numbers of non-empty lines, report the lines between if the difference is too large.
92631 .reduce((lastLineNumber, lineNumber) => {
92632 let messageId, maxAllowed;
92633
92634 if (lastLineNumber === 0) {
92635 messageId = "blankBeginningOfFile";
92636 maxAllowed = maxBOF;
92637 } else if (lineNumber === allLines.length + 1) {
92638 messageId = "blankEndOfFile";
92639 maxAllowed = maxEOF;
92640 } else {
92641 messageId = "consecutiveBlank";
92642 maxAllowed = max;
92643 }
92644
92645 if (lineNumber - lastLineNumber - 1 > maxAllowed) {
92646 context.report({
92647 node,
92648 loc: {
92649 start: {
92650 line: lastLineNumber + maxAllowed + 1,
92651 column: 0
92652 },
92653 end: {
92654 line: lineNumber,
92655 column: 0
92656 }
92657 },
92658 messageId,
92659 data: {
92660 max: maxAllowed,
92661 pluralizedLines: maxAllowed === 1 ? "line" : "lines"
92662 },
92663
92664 fix(fixer) {
92665 const rangeStart = sourceCode.getIndexFromLoc({
92666 line: lastLineNumber + 1,
92667 column: 0
92668 });
92669 /*
92670 * The end of the removal range is usually the start index of the next line.
92671 * However, at the end of the file there is no next line, so the end of the
92672 * range is just the length of the text.
92673 */
92674
92675 const lineNumberAfterRemovedLines = lineNumber - maxAllowed;
92676 const rangeEnd = lineNumberAfterRemovedLines <= allLines.length ? sourceCode.getIndexFromLoc({
92677 line: lineNumberAfterRemovedLines,
92678 column: 0
92679 }) : sourceCode.text.length;
92680 return fixer.removeRange([rangeStart, rangeEnd]);
92681 }
92682
92683 });
92684 }
92685
92686 return lineNumber;
92687 }, 0);
92688 }
92689
92690 };
92691 }
92692
92693 };
92694
92695 /***/ }),
92696 /* 710 */
92697 /***/ ((module) => {
92698
92699 "use strict";
92700 /**
92701 * @fileoverview Rule to disallow assignments to native objects or read-only global variables
92702 * @author Ilya Volodin
92703 * @deprecated in ESLint v3.3.0
92704 */
92705 //------------------------------------------------------------------------------
92706 // Rule Definition
92707 //------------------------------------------------------------------------------
92708
92709 module.exports = {
92710 meta: {
92711 type: "suggestion",
92712 docs: {
92713 description: "disallow assignments to native objects or read-only global variables",
92714 recommended: false,
92715 url: "https://eslint.org/docs/rules/no-native-reassign"
92716 },
92717 deprecated: true,
92718 replacedBy: ["no-global-assign"],
92719 schema: [{
92720 type: "object",
92721 properties: {
92722 exceptions: {
92723 type: "array",
92724 items: {
92725 type: "string"
92726 },
92727 uniqueItems: true
92728 }
92729 },
92730 additionalProperties: false
92731 }],
92732 messages: {
92733 nativeReassign: "Read-only global '{{name}}' should not be modified."
92734 }
92735 },
92736
92737 create(context) {
92738 const config = context.options[0];
92739 const exceptions = config && config.exceptions || [];
92740 /**
92741 * Reports write references.
92742 * @param {Reference} reference A reference to check.
92743 * @param {int} index The index of the reference in the references.
92744 * @param {Reference[]} references The array that the reference belongs to.
92745 * @returns {void}
92746 */
92747
92748 function checkReference(reference, index, references) {
92749 const identifier = reference.identifier;
92750
92751 if (reference.init === false && reference.isWrite() && (
92752 /*
92753 * Destructuring assignments can have multiple default value,
92754 * so possibly there are multiple writeable references for the same identifier.
92755 */
92756 index === 0 || references[index - 1].identifier !== identifier)) {
92757 context.report({
92758 node: identifier,
92759 messageId: "nativeReassign",
92760 data: identifier
92761 });
92762 }
92763 }
92764 /**
92765 * Reports write references if a given variable is read-only builtin.
92766 * @param {Variable} variable A variable to check.
92767 * @returns {void}
92768 */
92769
92770
92771 function checkVariable(variable) {
92772 if (variable.writeable === false && exceptions.indexOf(variable.name) === -1) {
92773 variable.references.forEach(checkReference);
92774 }
92775 }
92776
92777 return {
92778 Program() {
92779 const globalScope = context.getScope();
92780 globalScope.variables.forEach(checkVariable);
92781 }
92782
92783 };
92784 }
92785
92786 };
92787
92788 /***/ }),
92789 /* 711 */
92790 /***/ ((module) => {
92791
92792 "use strict";
92793 /**
92794 * @fileoverview Rule to disallow a negated condition
92795 * @author Alberto Rodríguez
92796 */
92797 //------------------------------------------------------------------------------
92798 // Rule Definition
92799 //------------------------------------------------------------------------------
92800
92801 module.exports = {
92802 meta: {
92803 type: "suggestion",
92804 docs: {
92805 description: "disallow negated conditions",
92806 recommended: false,
92807 url: "https://eslint.org/docs/rules/no-negated-condition"
92808 },
92809 schema: [],
92810 messages: {
92811 unexpectedNegated: "Unexpected negated condition."
92812 }
92813 },
92814
92815 create(context) {
92816 /**
92817 * Determines if a given node is an if-else without a condition on the else
92818 * @param {ASTNode} node The node to check.
92819 * @returns {boolean} True if the node has an else without an if.
92820 * @private
92821 */
92822 function hasElseWithoutCondition(node) {
92823 return node.alternate && node.alternate.type !== "IfStatement";
92824 }
92825 /**
92826 * Determines if a given node is a negated unary expression
92827 * @param {Object} test The test object to check.
92828 * @returns {boolean} True if the node is a negated unary expression.
92829 * @private
92830 */
92831
92832
92833 function isNegatedUnaryExpression(test) {
92834 return test.type === "UnaryExpression" && test.operator === "!";
92835 }
92836 /**
92837 * Determines if a given node is a negated binary expression
92838 * @param {Test} test The test to check.
92839 * @returns {boolean} True if the node is a negated binary expression.
92840 * @private
92841 */
92842
92843
92844 function isNegatedBinaryExpression(test) {
92845 return test.type === "BinaryExpression" && (test.operator === "!=" || test.operator === "!==");
92846 }
92847 /**
92848 * Determines if a given node has a negated if expression
92849 * @param {ASTNode} node The node to check.
92850 * @returns {boolean} True if the node has a negated if expression.
92851 * @private
92852 */
92853
92854
92855 function isNegatedIf(node) {
92856 return isNegatedUnaryExpression(node.test) || isNegatedBinaryExpression(node.test);
92857 }
92858
92859 return {
92860 IfStatement(node) {
92861 if (!hasElseWithoutCondition(node)) {
92862 return;
92863 }
92864
92865 if (isNegatedIf(node)) {
92866 context.report({
92867 node,
92868 messageId: "unexpectedNegated"
92869 });
92870 }
92871 },
92872
92873 ConditionalExpression(node) {
92874 if (isNegatedIf(node)) {
92875 context.report({
92876 node,
92877 messageId: "unexpectedNegated"
92878 });
92879 }
92880 }
92881
92882 };
92883 }
92884
92885 };
92886
92887 /***/ }),
92888 /* 712 */
92889 /***/ ((module) => {
92890
92891 "use strict";
92892 /**
92893 * @fileoverview A rule to disallow negated left operands of the `in` operator
92894 * @author Michael Ficarra
92895 * @deprecated in ESLint v3.3.0
92896 */
92897 //------------------------------------------------------------------------------
92898 // Rule Definition
92899 //------------------------------------------------------------------------------
92900
92901 module.exports = {
92902 meta: {
92903 type: "problem",
92904 docs: {
92905 description: "disallow negating the left operand in `in` expressions",
92906 recommended: false,
92907 url: "https://eslint.org/docs/rules/no-negated-in-lhs"
92908 },
92909 replacedBy: ["no-unsafe-negation"],
92910 deprecated: true,
92911 schema: [],
92912 messages: {
92913 negatedLHS: "The 'in' expression's left operand is negated."
92914 }
92915 },
92916
92917 create(context) {
92918 return {
92919 BinaryExpression(node) {
92920 if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") {
92921 context.report({
92922 node,
92923 messageId: "negatedLHS"
92924 });
92925 }
92926 }
92927
92928 };
92929 }
92930
92931 };
92932
92933 /***/ }),
92934 /* 713 */
92935 /***/ ((module) => {
92936
92937 "use strict";
92938 /**
92939 * @fileoverview Rule to flag nested ternary expressions
92940 * @author Ian Christian Myers
92941 */
92942 //------------------------------------------------------------------------------
92943 // Rule Definition
92944 //------------------------------------------------------------------------------
92945
92946 module.exports = {
92947 meta: {
92948 type: "suggestion",
92949 docs: {
92950 description: "disallow nested ternary expressions",
92951 recommended: false,
92952 url: "https://eslint.org/docs/rules/no-nested-ternary"
92953 },
92954 schema: [],
92955 messages: {
92956 noNestedTernary: "Do not nest ternary expressions."
92957 }
92958 },
92959
92960 create(context) {
92961 return {
92962 ConditionalExpression(node) {
92963 if (node.alternate.type === "ConditionalExpression" || node.consequent.type === "ConditionalExpression") {
92964 context.report({
92965 node,
92966 messageId: "noNestedTernary"
92967 });
92968 }
92969 }
92970
92971 };
92972 }
92973
92974 };
92975
92976 /***/ }),
92977 /* 714 */
92978 /***/ ((module) => {
92979
92980 "use strict";
92981 /**
92982 * @fileoverview Rule to flag statements with function invocation preceded by
92983 * "new" and not part of assignment
92984 * @author Ilya Volodin
92985 */
92986 //------------------------------------------------------------------------------
92987 // Rule Definition
92988 //------------------------------------------------------------------------------
92989
92990 module.exports = {
92991 meta: {
92992 type: "suggestion",
92993 docs: {
92994 description: "disallow `new` operators outside of assignments or comparisons",
92995 recommended: false,
92996 url: "https://eslint.org/docs/rules/no-new"
92997 },
92998 schema: [],
92999 messages: {
93000 noNewStatement: "Do not use 'new' for side effects."
93001 }
93002 },
93003
93004 create(context) {
93005 return {
93006 "ExpressionStatement > NewExpression"(node) {
93007 context.report({
93008 node: node.parent,
93009 messageId: "noNewStatement"
93010 });
93011 }
93012
93013 };
93014 }
93015
93016 };
93017
93018 /***/ }),
93019 /* 715 */
93020 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
93021
93022 "use strict";
93023 /**
93024 * @fileoverview Rule to flag when using new Function
93025 * @author Ilya Volodin
93026 */
93027 //------------------------------------------------------------------------------
93028 // Requirements
93029 //------------------------------------------------------------------------------
93030
93031 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
93032 // Helpers
93033 //------------------------------------------------------------------------------
93034
93035
93036 const callMethods = new Set(["apply", "bind", "call"]); //------------------------------------------------------------------------------
93037 // Rule Definition
93038 //------------------------------------------------------------------------------
93039
93040 module.exports = {
93041 meta: {
93042 type: "suggestion",
93043 docs: {
93044 description: "disallow `new` operators with the `Function` object",
93045 recommended: false,
93046 url: "https://eslint.org/docs/rules/no-new-func"
93047 },
93048 schema: [],
93049 messages: {
93050 noFunctionConstructor: "The Function constructor is eval."
93051 }
93052 },
93053
93054 create(context) {
93055 return {
93056 "Program:exit"() {
93057 const globalScope = context.getScope();
93058 const variable = globalScope.set.get("Function");
93059
93060 if (variable && variable.defs.length === 0) {
93061 variable.references.forEach(ref => {
93062 const node = ref.identifier;
93063 const {
93064 parent
93065 } = node;
93066 let evalNode;
93067
93068 if (parent) {
93069 if (node === parent.callee && (parent.type === "NewExpression" || parent.type === "CallExpression")) {
93070 evalNode = parent;
93071 } else if (parent.type === "MemberExpression" && node === parent.object && callMethods.has(astUtils.getStaticPropertyName(parent))) {
93072 const maybeCallee = parent.parent.type === "ChainExpression" ? parent.parent : parent;
93073
93074 if (maybeCallee.parent.type === "CallExpression" && maybeCallee.parent.callee === maybeCallee) {
93075 evalNode = maybeCallee.parent;
93076 }
93077 }
93078 }
93079
93080 if (evalNode) {
93081 context.report({
93082 node: evalNode,
93083 messageId: "noFunctionConstructor"
93084 });
93085 }
93086 });
93087 }
93088 }
93089
93090 };
93091 }
93092
93093 };
93094
93095 /***/ }),
93096 /* 716 */
93097 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
93098
93099 "use strict";
93100 /**
93101 * @fileoverview A rule to disallow calls to the Object constructor
93102 * @author Matt DuVall <http://www.mattduvall.com/>
93103 */
93104 //------------------------------------------------------------------------------
93105 // Requirements
93106 //------------------------------------------------------------------------------
93107
93108 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
93109 // Rule Definition
93110 //------------------------------------------------------------------------------
93111
93112
93113 module.exports = {
93114 meta: {
93115 type: "suggestion",
93116 docs: {
93117 description: "disallow `Object` constructors",
93118 recommended: false,
93119 url: "https://eslint.org/docs/rules/no-new-object"
93120 },
93121 schema: [],
93122 messages: {
93123 preferLiteral: "The object literal notation {} is preferrable."
93124 }
93125 },
93126
93127 create(context) {
93128 return {
93129 NewExpression(node) {
93130 const variable = astUtils.getVariableByName(context.getScope(), node.callee.name);
93131
93132 if (variable && variable.identifiers.length > 0) {
93133 return;
93134 }
93135
93136 if (node.callee.name === "Object") {
93137 context.report({
93138 node,
93139 messageId: "preferLiteral"
93140 });
93141 }
93142 }
93143
93144 };
93145 }
93146
93147 };
93148
93149 /***/ }),
93150 /* 717 */
93151 /***/ ((module) => {
93152
93153 "use strict";
93154 /**
93155 * @fileoverview Rule to disallow use of new operator with the `require` function
93156 * @author Wil Moore III
93157 * @deprecated in ESLint v7.0.0
93158 */
93159 //------------------------------------------------------------------------------
93160 // Rule Definition
93161 //------------------------------------------------------------------------------
93162
93163 module.exports = {
93164 meta: {
93165 deprecated: true,
93166 replacedBy: [],
93167 type: "suggestion",
93168 docs: {
93169 description: "disallow `new` operators with calls to `require`",
93170 recommended: false,
93171 url: "https://eslint.org/docs/rules/no-new-require"
93172 },
93173 schema: [],
93174 messages: {
93175 noNewRequire: "Unexpected use of new with require."
93176 }
93177 },
93178
93179 create(context) {
93180 return {
93181 NewExpression(node) {
93182 if (node.callee.type === "Identifier" && node.callee.name === "require") {
93183 context.report({
93184 node,
93185 messageId: "noNewRequire"
93186 });
93187 }
93188 }
93189
93190 };
93191 }
93192
93193 };
93194
93195 /***/ }),
93196 /* 718 */
93197 /***/ ((module) => {
93198
93199 "use strict";
93200 /**
93201 * @fileoverview Rule to disallow use of the new operator with the `Symbol` object
93202 * @author Alberto Rodríguez
93203 */
93204 //------------------------------------------------------------------------------
93205 // Rule Definition
93206 //------------------------------------------------------------------------------
93207
93208 module.exports = {
93209 meta: {
93210 type: "problem",
93211 docs: {
93212 description: "disallow `new` operators with the `Symbol` object",
93213 recommended: true,
93214 url: "https://eslint.org/docs/rules/no-new-symbol"
93215 },
93216 schema: [],
93217 messages: {
93218 noNewSymbol: "`Symbol` cannot be called as a constructor."
93219 }
93220 },
93221
93222 create(context) {
93223 return {
93224 "Program:exit"() {
93225 const globalScope = context.getScope();
93226 const variable = globalScope.set.get("Symbol");
93227
93228 if (variable && variable.defs.length === 0) {
93229 variable.references.forEach(ref => {
93230 const node = ref.identifier;
93231 const parent = node.parent;
93232
93233 if (parent && parent.type === "NewExpression" && parent.callee === node) {
93234 context.report({
93235 node,
93236 messageId: "noNewSymbol"
93237 });
93238 }
93239 });
93240 }
93241 }
93242
93243 };
93244 }
93245
93246 };
93247
93248 /***/ }),
93249 /* 719 */
93250 /***/ ((module) => {
93251
93252 "use strict";
93253 /**
93254 * @fileoverview Rule to flag when using constructor for wrapper objects
93255 * @author Ilya Volodin
93256 */
93257 //------------------------------------------------------------------------------
93258 // Rule Definition
93259 //------------------------------------------------------------------------------
93260
93261 module.exports = {
93262 meta: {
93263 type: "suggestion",
93264 docs: {
93265 description: "disallow `new` operators with the `String`, `Number`, and `Boolean` objects",
93266 recommended: false,
93267 url: "https://eslint.org/docs/rules/no-new-wrappers"
93268 },
93269 schema: [],
93270 messages: {
93271 noConstructor: "Do not use {{fn}} as a constructor."
93272 }
93273 },
93274
93275 create(context) {
93276 return {
93277 NewExpression(node) {
93278 const wrapperObjects = ["String", "Number", "Boolean"];
93279
93280 if (wrapperObjects.indexOf(node.callee.name) > -1) {
93281 context.report({
93282 node,
93283 messageId: "noConstructor",
93284 data: {
93285 fn: node.callee.name
93286 }
93287 });
93288 }
93289 }
93290
93291 };
93292 }
93293
93294 };
93295
93296 /***/ }),
93297 /* 720 */
93298 /***/ ((module) => {
93299
93300 "use strict";
93301 /**
93302 * @fileoverview Rule to disallow `\8` and `\9` escape sequences in string literals.
93303 * @author Milos Djermanovic
93304 */
93305 //------------------------------------------------------------------------------
93306 // Helpers
93307 //------------------------------------------------------------------------------
93308
93309 const QUICK_TEST_REGEX = /\\[89]/u;
93310 /**
93311 * Returns unicode escape sequence that represents the given character.
93312 * @param {string} character A single code unit.
93313 * @returns {string} "\uXXXX" sequence.
93314 */
93315
93316 function getUnicodeEscape(character) {
93317 return "\\u".concat(character.charCodeAt(0).toString(16).padStart(4, "0"));
93318 } //------------------------------------------------------------------------------
93319 // Rule Definition
93320 //------------------------------------------------------------------------------
93321
93322
93323 module.exports = {
93324 meta: {
93325 type: "suggestion",
93326 docs: {
93327 description: "disallow `\\8` and `\\9` escape sequences in string literals",
93328 recommended: true,
93329 url: "https://eslint.org/docs/rules/no-nonoctal-decimal-escape"
93330 },
93331 hasSuggestions: true,
93332 schema: [],
93333 messages: {
93334 decimalEscape: "Don't use '{{decimalEscape}}' escape sequence.",
93335 // suggestions
93336 refactor: "Replace '{{original}}' with '{{replacement}}'. This maintains the current functionality.",
93337 escapeBackslash: "Replace '{{original}}' with '{{replacement}}' to include the actual backslash character."
93338 }
93339 },
93340
93341 create(context) {
93342 const sourceCode = context.getSourceCode();
93343 /**
93344 * Creates a new Suggestion object.
93345 * @param {string} messageId "refactor" or "escapeBackslash".
93346 * @param {int[]} range The range to replace.
93347 * @param {string} replacement New text for the range.
93348 * @returns {Object} Suggestion
93349 */
93350
93351 function createSuggestion(messageId, range, replacement) {
93352 return {
93353 messageId,
93354 data: {
93355 original: sourceCode.getText().slice(...range),
93356 replacement
93357 },
93358
93359 fix(fixer) {
93360 return fixer.replaceTextRange(range, replacement);
93361 }
93362
93363 };
93364 }
93365
93366 return {
93367 Literal(node) {
93368 if (typeof node.value !== "string") {
93369 return;
93370 }
93371
93372 if (!QUICK_TEST_REGEX.test(node.raw)) {
93373 return;
93374 }
93375
93376 const regex = /(?:[^\\]|(?<previousEscape>\\.))*?(?<decimalEscape>\\[89])/suy;
93377 let match;
93378
93379 while (match = regex.exec(node.raw)) {
93380 const {
93381 previousEscape,
93382 decimalEscape
93383 } = match.groups;
93384 const decimalEscapeRangeEnd = node.range[0] + match.index + match[0].length;
93385 const decimalEscapeRangeStart = decimalEscapeRangeEnd - decimalEscape.length;
93386 const decimalEscapeRange = [decimalEscapeRangeStart, decimalEscapeRangeEnd];
93387 const suggest = []; // When `regex` is matched, `previousEscape` can only capture characters adjacent to `decimalEscape`
93388
93389 if (previousEscape === "\\0") {
93390 /*
93391 * Now we have a NULL escape "\0" immediately followed by a decimal escape, e.g.: "\0\8".
93392 * Fixing this to "\08" would turn "\0" into a legacy octal escape. To avoid producing
93393 * an octal escape while fixing a decimal escape, we provide different suggestions.
93394 */
93395 suggest.push(createSuggestion( // "\0\8" -> "\u00008"
93396 "refactor", [decimalEscapeRangeStart - previousEscape.length, decimalEscapeRangeEnd], "".concat(getUnicodeEscape("\0")).concat(decimalEscape[1])), createSuggestion( // "\8" -> "\u0038"
93397 "refactor", decimalEscapeRange, getUnicodeEscape(decimalEscape[1])));
93398 } else {
93399 suggest.push(createSuggestion( // "\8" -> "8"
93400 "refactor", decimalEscapeRange, decimalEscape[1]));
93401 }
93402
93403 suggest.push(createSuggestion( // "\8" -> "\\8"
93404 "escapeBackslash", decimalEscapeRange, "\\".concat(decimalEscape)));
93405 context.report({
93406 node,
93407 loc: {
93408 start: sourceCode.getLocFromIndex(decimalEscapeRangeStart),
93409 end: sourceCode.getLocFromIndex(decimalEscapeRangeEnd)
93410 },
93411 messageId: "decimalEscape",
93412 data: {
93413 decimalEscape
93414 },
93415 suggest
93416 });
93417 }
93418 }
93419
93420 };
93421 }
93422
93423 };
93424
93425 /***/ }),
93426 /* 721 */
93427 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
93428
93429 "use strict";
93430 /**
93431 * @fileoverview Rule to flag use of an object property of the global object (Math and JSON) as a function
93432 * @author James Allardice
93433 */
93434 //------------------------------------------------------------------------------
93435 // Requirements
93436 //------------------------------------------------------------------------------
93437
93438 const {
93439 CALL,
93440 CONSTRUCT,
93441 ReferenceTracker
93442 } = __webpack_require__(501);
93443
93444 const getPropertyName = (__webpack_require__(548).getStaticPropertyName); //------------------------------------------------------------------------------
93445 // Helpers
93446 //------------------------------------------------------------------------------
93447
93448
93449 const nonCallableGlobals = ["Atomics", "JSON", "Math", "Reflect"];
93450 /**
93451 * Returns the name of the node to report
93452 * @param {ASTNode} node A node to report
93453 * @returns {string} name to report
93454 */
93455
93456 function getReportNodeName(node) {
93457 if (node.type === "ChainExpression") {
93458 return getReportNodeName(node.expression);
93459 }
93460
93461 if (node.type === "MemberExpression") {
93462 return getPropertyName(node);
93463 }
93464
93465 return node.name;
93466 } //------------------------------------------------------------------------------
93467 // Rule Definition
93468 //------------------------------------------------------------------------------
93469
93470
93471 module.exports = {
93472 meta: {
93473 type: "problem",
93474 docs: {
93475 description: "disallow calling global object properties as functions",
93476 recommended: true,
93477 url: "https://eslint.org/docs/rules/no-obj-calls"
93478 },
93479 schema: [],
93480 messages: {
93481 unexpectedCall: "'{{name}}' is not a function.",
93482 unexpectedRefCall: "'{{name}}' is reference to '{{ref}}', which is not a function."
93483 }
93484 },
93485
93486 create(context) {
93487 return {
93488 Program() {
93489 const scope = context.getScope();
93490 const tracker = new ReferenceTracker(scope);
93491 const traceMap = {};
93492
93493 for (const g of nonCallableGlobals) {
93494 traceMap[g] = {
93495 [CALL]: true,
93496 [CONSTRUCT]: true
93497 };
93498 }
93499
93500 for (const {
93501 node,
93502 path
93503 } of tracker.iterateGlobalReferences(traceMap)) {
93504 const name = getReportNodeName(node.callee);
93505 const ref = path[0];
93506 const messageId = name === ref ? "unexpectedCall" : "unexpectedRefCall";
93507 context.report({
93508 node,
93509 messageId,
93510 data: {
93511 name,
93512 ref
93513 }
93514 });
93515 }
93516 }
93517
93518 };
93519 }
93520
93521 };
93522
93523 /***/ }),
93524 /* 722 */
93525 /***/ ((module) => {
93526
93527 "use strict";
93528 /**
93529 * @fileoverview Rule to flag when initializing octal literal
93530 * @author Ilya Volodin
93531 */
93532 //------------------------------------------------------------------------------
93533 // Rule Definition
93534 //------------------------------------------------------------------------------
93535
93536 module.exports = {
93537 meta: {
93538 type: "suggestion",
93539 docs: {
93540 description: "disallow octal literals",
93541 recommended: true,
93542 url: "https://eslint.org/docs/rules/no-octal"
93543 },
93544 schema: [],
93545 messages: {
93546 noOcatal: "Octal literals should not be used."
93547 }
93548 },
93549
93550 create(context) {
93551 return {
93552 Literal(node) {
93553 if (typeof node.value === "number" && /^0[0-9]/u.test(node.raw)) {
93554 context.report({
93555 node,
93556 messageId: "noOcatal"
93557 });
93558 }
93559 }
93560
93561 };
93562 }
93563
93564 };
93565
93566 /***/ }),
93567 /* 723 */
93568 /***/ ((module) => {
93569
93570 "use strict";
93571 /**
93572 * @fileoverview Rule to flag octal escape sequences in string literals.
93573 * @author Ian Christian Myers
93574 */
93575 //------------------------------------------------------------------------------
93576 // Rule Definition
93577 //------------------------------------------------------------------------------
93578
93579 module.exports = {
93580 meta: {
93581 type: "suggestion",
93582 docs: {
93583 description: "disallow octal escape sequences in string literals",
93584 recommended: false,
93585 url: "https://eslint.org/docs/rules/no-octal-escape"
93586 },
93587 schema: [],
93588 messages: {
93589 octalEscapeSequence: "Don't use octal: '\\{{sequence}}'. Use '\\u....' instead."
93590 }
93591 },
93592
93593 create(context) {
93594 return {
93595 Literal(node) {
93596 if (typeof node.value !== "string") {
93597 return;
93598 } // \0 represents a valid NULL character if it isn't followed by a digit.
93599
93600
93601 const match = node.raw.match(/^(?:[^\\]|\\.)*?\\([0-3][0-7]{1,2}|[4-7][0-7]|0(?=[89])|[1-7])/su);
93602
93603 if (match) {
93604 context.report({
93605 node,
93606 messageId: "octalEscapeSequence",
93607 data: {
93608 sequence: match[1]
93609 }
93610 });
93611 }
93612 }
93613
93614 };
93615 }
93616
93617 };
93618
93619 /***/ }),
93620 /* 724 */
93621 /***/ ((module) => {
93622
93623 "use strict";
93624 /**
93625 * @fileoverview Disallow reassignment of function parameters.
93626 * @author Nat Burns
93627 */
93628 //------------------------------------------------------------------------------
93629 // Rule Definition
93630 //------------------------------------------------------------------------------
93631
93632 const stopNodePattern = /(?:Statement|Declaration|Function(?:Expression)?|Program)$/u;
93633 module.exports = {
93634 meta: {
93635 type: "suggestion",
93636 docs: {
93637 description: "disallow reassigning `function` parameters",
93638 recommended: false,
93639 url: "https://eslint.org/docs/rules/no-param-reassign"
93640 },
93641 schema: [{
93642 oneOf: [{
93643 type: "object",
93644 properties: {
93645 props: {
93646 enum: [false]
93647 }
93648 },
93649 additionalProperties: false
93650 }, {
93651 type: "object",
93652 properties: {
93653 props: {
93654 enum: [true]
93655 },
93656 ignorePropertyModificationsFor: {
93657 type: "array",
93658 items: {
93659 type: "string"
93660 },
93661 uniqueItems: true
93662 },
93663 ignorePropertyModificationsForRegex: {
93664 type: "array",
93665 items: {
93666 type: "string"
93667 },
93668 uniqueItems: true
93669 }
93670 },
93671 additionalProperties: false
93672 }]
93673 }],
93674 messages: {
93675 assignmentToFunctionParam: "Assignment to function parameter '{{name}}'.",
93676 assignmentToFunctionParamProp: "Assignment to property of function parameter '{{name}}'."
93677 }
93678 },
93679
93680 create(context) {
93681 const props = context.options[0] && context.options[0].props;
93682 const ignoredPropertyAssignmentsFor = context.options[0] && context.options[0].ignorePropertyModificationsFor || [];
93683 const ignoredPropertyAssignmentsForRegex = context.options[0] && context.options[0].ignorePropertyModificationsForRegex || [];
93684 /**
93685 * Checks whether or not the reference modifies properties of its variable.
93686 * @param {Reference} reference A reference to check.
93687 * @returns {boolean} Whether or not the reference modifies properties of its variable.
93688 */
93689
93690 function isModifyingProp(reference) {
93691 let node = reference.identifier;
93692 let parent = node.parent;
93693
93694 while (parent && (!stopNodePattern.test(parent.type) || parent.type === "ForInStatement" || parent.type === "ForOfStatement")) {
93695 switch (parent.type) {
93696 // e.g. foo.a = 0;
93697 case "AssignmentExpression":
93698 return parent.left === node;
93699 // e.g. ++foo.a;
93700
93701 case "UpdateExpression":
93702 return true;
93703 // e.g. delete foo.a;
93704
93705 case "UnaryExpression":
93706 if (parent.operator === "delete") {
93707 return true;
93708 }
93709
93710 break;
93711 // e.g. for (foo.a in b) {}
93712
93713 case "ForInStatement":
93714 case "ForOfStatement":
93715 if (parent.left === node) {
93716 return true;
93717 } // this is a stop node for parent.right and parent.body
93718
93719
93720 return false;
93721 // EXCLUDES: e.g. cache.get(foo.a).b = 0;
93722
93723 case "CallExpression":
93724 if (parent.callee !== node) {
93725 return false;
93726 }
93727
93728 break;
93729 // EXCLUDES: e.g. cache[foo.a] = 0;
93730
93731 case "MemberExpression":
93732 if (parent.property === node) {
93733 return false;
93734 }
93735
93736 break;
93737 // EXCLUDES: e.g. ({ [foo]: a }) = bar;
93738
93739 case "Property":
93740 if (parent.key === node) {
93741 return false;
93742 }
93743
93744 break;
93745 // EXCLUDES: e.g. (foo ? a : b).c = bar;
93746
93747 case "ConditionalExpression":
93748 if (parent.test === node) {
93749 return false;
93750 }
93751
93752 break;
93753 // no default
93754 }
93755
93756 node = parent;
93757 parent = node.parent;
93758 }
93759
93760 return false;
93761 }
93762 /**
93763 * Tests that an identifier name matches any of the ignored property assignments.
93764 * First we test strings in ignoredPropertyAssignmentsFor.
93765 * Then we instantiate and test RegExp objects from ignoredPropertyAssignmentsForRegex strings.
93766 * @param {string} identifierName A string that describes the name of an identifier to
93767 * ignore property assignments for.
93768 * @returns {boolean} Whether the string matches an ignored property assignment regular expression or not.
93769 */
93770
93771
93772 function isIgnoredPropertyAssignment(identifierName) {
93773 return ignoredPropertyAssignmentsFor.includes(identifierName) || ignoredPropertyAssignmentsForRegex.some(ignored => new RegExp(ignored, "u").test(identifierName));
93774 }
93775 /**
93776 * Reports a reference if is non initializer and writable.
93777 * @param {Reference} reference A reference to check.
93778 * @param {int} index The index of the reference in the references.
93779 * @param {Reference[]} references The array that the reference belongs to.
93780 * @returns {void}
93781 */
93782
93783
93784 function checkReference(reference, index, references) {
93785 const identifier = reference.identifier;
93786
93787 if (identifier && !reference.init && (
93788 /*
93789 * Destructuring assignments can have multiple default value,
93790 * so possibly there are multiple writeable references for the same identifier.
93791 */
93792 index === 0 || references[index - 1].identifier !== identifier)) {
93793 if (reference.isWrite()) {
93794 context.report({
93795 node: identifier,
93796 messageId: "assignmentToFunctionParam",
93797 data: {
93798 name: identifier.name
93799 }
93800 });
93801 } else if (props && isModifyingProp(reference) && !isIgnoredPropertyAssignment(identifier.name)) {
93802 context.report({
93803 node: identifier,
93804 messageId: "assignmentToFunctionParamProp",
93805 data: {
93806 name: identifier.name
93807 }
93808 });
93809 }
93810 }
93811 }
93812 /**
93813 * Finds and reports references that are non initializer and writable.
93814 * @param {Variable} variable A variable to check.
93815 * @returns {void}
93816 */
93817
93818
93819 function checkVariable(variable) {
93820 if (variable.defs[0].type === "Parameter") {
93821 variable.references.forEach(checkReference);
93822 }
93823 }
93824 /**
93825 * Checks parameters of a given function node.
93826 * @param {ASTNode} node A function node to check.
93827 * @returns {void}
93828 */
93829
93830
93831 function checkForFunction(node) {
93832 context.getDeclaredVariables(node).forEach(checkVariable);
93833 }
93834
93835 return {
93836 // `:exit` is needed for the `node.parent` property of identifier nodes.
93837 "FunctionDeclaration:exit": checkForFunction,
93838 "FunctionExpression:exit": checkForFunction,
93839 "ArrowFunctionExpression:exit": checkForFunction
93840 };
93841 }
93842
93843 };
93844
93845 /***/ }),
93846 /* 725 */
93847 /***/ ((module) => {
93848
93849 "use strict";
93850 /**
93851 * @fileoverview Disallow string concatenation when using __dirname and __filename
93852 * @author Nicholas C. Zakas
93853 * @deprecated in ESLint v7.0.0
93854 */
93855 //------------------------------------------------------------------------------
93856 // Rule Definition
93857 //------------------------------------------------------------------------------
93858
93859 module.exports = {
93860 meta: {
93861 deprecated: true,
93862 replacedBy: [],
93863 type: "suggestion",
93864 docs: {
93865 description: "disallow string concatenation with `__dirname` and `__filename`",
93866 recommended: false,
93867 url: "https://eslint.org/docs/rules/no-path-concat"
93868 },
93869 schema: [],
93870 messages: {
93871 usePathFunctions: "Use path.join() or path.resolve() instead of + to create paths."
93872 }
93873 },
93874
93875 create(context) {
93876 const MATCHER = /^__(?:dir|file)name$/u; //--------------------------------------------------------------------------
93877 // Public
93878 //--------------------------------------------------------------------------
93879
93880 return {
93881 BinaryExpression(node) {
93882 const left = node.left,
93883 right = node.right;
93884
93885 if (node.operator === "+" && (left.type === "Identifier" && MATCHER.test(left.name) || right.type === "Identifier" && MATCHER.test(right.name))) {
93886 context.report({
93887 node,
93888 messageId: "usePathFunctions"
93889 });
93890 }
93891 }
93892
93893 };
93894 }
93895
93896 };
93897
93898 /***/ }),
93899 /* 726 */
93900 /***/ ((module) => {
93901
93902 "use strict";
93903 /**
93904 * @fileoverview Rule to flag use of unary increment and decrement operators.
93905 * @author Ian Christian Myers
93906 * @author Brody McKee (github.com/mrmckeb)
93907 */
93908 //------------------------------------------------------------------------------
93909 // Helpers
93910 //------------------------------------------------------------------------------
93911
93912 /**
93913 * Determines whether the given node is the update node of a `ForStatement`.
93914 * @param {ASTNode} node The node to check.
93915 * @returns {boolean} `true` if the node is `ForStatement` update.
93916 */
93917
93918 function isForStatementUpdate(node) {
93919 const parent = node.parent;
93920 return parent.type === "ForStatement" && parent.update === node;
93921 }
93922 /**
93923 * Determines whether the given node is considered to be a for loop "afterthought" by the logic of this rule.
93924 * In particular, it returns `true` if the given node is either:
93925 * - The update node of a `ForStatement`: for (;; i++) {}
93926 * - An operand of a sequence expression that is the update node: for (;; foo(), i++) {}
93927 * - An operand of a sequence expression that is child of another sequence expression, etc.,
93928 * up to the sequence expression that is the update node: for (;; foo(), (bar(), (baz(), i++))) {}
93929 * @param {ASTNode} node The node to check.
93930 * @returns {boolean} `true` if the node is a for loop afterthought.
93931 */
93932
93933
93934 function isForLoopAfterthought(node) {
93935 const parent = node.parent;
93936
93937 if (parent.type === "SequenceExpression") {
93938 return isForLoopAfterthought(parent);
93939 }
93940
93941 return isForStatementUpdate(node);
93942 } //------------------------------------------------------------------------------
93943 // Rule Definition
93944 //------------------------------------------------------------------------------
93945
93946
93947 module.exports = {
93948 meta: {
93949 type: "suggestion",
93950 docs: {
93951 description: "disallow the unary operators `++` and `--`",
93952 recommended: false,
93953 url: "https://eslint.org/docs/rules/no-plusplus"
93954 },
93955 schema: [{
93956 type: "object",
93957 properties: {
93958 allowForLoopAfterthoughts: {
93959 type: "boolean",
93960 default: false
93961 }
93962 },
93963 additionalProperties: false
93964 }],
93965 messages: {
93966 unexpectedUnaryOp: "Unary operator '{{operator}}' used."
93967 }
93968 },
93969
93970 create(context) {
93971 const config = context.options[0];
93972 let allowForLoopAfterthoughts = false;
93973
93974 if (typeof config === "object") {
93975 allowForLoopAfterthoughts = config.allowForLoopAfterthoughts === true;
93976 }
93977
93978 return {
93979 UpdateExpression(node) {
93980 if (allowForLoopAfterthoughts && isForLoopAfterthought(node)) {
93981 return;
93982 }
93983
93984 context.report({
93985 node,
93986 messageId: "unexpectedUnaryOp",
93987 data: {
93988 operator: node.operator
93989 }
93990 });
93991 }
93992
93993 };
93994 }
93995
93996 };
93997
93998 /***/ }),
93999 /* 727 */
94000 /***/ ((module) => {
94001
94002 "use strict";
94003 /**
94004 * @fileoverview Disallow the use of process.env()
94005 * @author Vignesh Anand
94006 * @deprecated in ESLint v7.0.0
94007 */
94008 //------------------------------------------------------------------------------
94009 // Rule Definition
94010 //------------------------------------------------------------------------------
94011
94012 module.exports = {
94013 meta: {
94014 deprecated: true,
94015 replacedBy: [],
94016 type: "suggestion",
94017 docs: {
94018 description: "disallow the use of `process.env`",
94019 recommended: false,
94020 url: "https://eslint.org/docs/rules/no-process-env"
94021 },
94022 schema: [],
94023 messages: {
94024 unexpectedProcessEnv: "Unexpected use of process.env."
94025 }
94026 },
94027
94028 create(context) {
94029 return {
94030 MemberExpression(node) {
94031 const objectName = node.object.name,
94032 propertyName = node.property.name;
94033
94034 if (objectName === "process" && !node.computed && propertyName && propertyName === "env") {
94035 context.report({
94036 node,
94037 messageId: "unexpectedProcessEnv"
94038 });
94039 }
94040 }
94041
94042 };
94043 }
94044
94045 };
94046
94047 /***/ }),
94048 /* 728 */
94049 /***/ ((module) => {
94050
94051 "use strict";
94052 /**
94053 * @fileoverview Disallow the use of process.exit()
94054 * @author Nicholas C. Zakas
94055 * @deprecated in ESLint v7.0.0
94056 */
94057 //------------------------------------------------------------------------------
94058 // Rule Definition
94059 //------------------------------------------------------------------------------
94060
94061 module.exports = {
94062 meta: {
94063 deprecated: true,
94064 replacedBy: [],
94065 type: "suggestion",
94066 docs: {
94067 description: "disallow the use of `process.exit()`",
94068 recommended: false,
94069 url: "https://eslint.org/docs/rules/no-process-exit"
94070 },
94071 schema: [],
94072 messages: {
94073 noProcessExit: "Don't use process.exit(); throw an error instead."
94074 }
94075 },
94076
94077 create(context) {
94078 //--------------------------------------------------------------------------
94079 // Public
94080 //--------------------------------------------------------------------------
94081 return {
94082 "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(node) {
94083 context.report({
94084 node: node.parent,
94085 messageId: "noProcessExit"
94086 });
94087 }
94088
94089 };
94090 }
94091
94092 };
94093
94094 /***/ }),
94095 /* 729 */
94096 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
94097
94098 "use strict";
94099 /**
94100 * @fileoverview Rule to disallow returning values from Promise executor functions
94101 * @author Milos Djermanovic
94102 */
94103 //------------------------------------------------------------------------------
94104 // Requirements
94105 //------------------------------------------------------------------------------
94106
94107 const {
94108 findVariable
94109 } = __webpack_require__(501); //------------------------------------------------------------------------------
94110 // Helpers
94111 //------------------------------------------------------------------------------
94112
94113
94114 const functionTypesToCheck = new Set(["ArrowFunctionExpression", "FunctionExpression"]);
94115 /**
94116 * Determines whether the given identifier node is a reference to a global variable.
94117 * @param {ASTNode} node `Identifier` node to check.
94118 * @param {Scope} scope Scope to which the node belongs.
94119 * @returns {boolean} True if the identifier is a reference to a global variable.
94120 */
94121
94122 function isGlobalReference(node, scope) {
94123 const variable = findVariable(scope, node);
94124 return variable !== null && variable.scope.type === "global" && variable.defs.length === 0;
94125 }
94126 /**
94127 * Finds function's outer scope.
94128 * @param {Scope} scope Function's own scope.
94129 * @returns {Scope} Function's outer scope.
94130 */
94131
94132
94133 function getOuterScope(scope) {
94134 const upper = scope.upper;
94135
94136 if (upper.type === "function-expression-name") {
94137 return upper.upper;
94138 }
94139
94140 return upper;
94141 }
94142 /**
94143 * Determines whether the given function node is used as a Promise executor.
94144 * @param {ASTNode} node The node to check.
94145 * @param {Scope} scope Function's own scope.
94146 * @returns {boolean} `true` if the node is a Promise executor.
94147 */
94148
94149
94150 function isPromiseExecutor(node, scope) {
94151 const parent = node.parent;
94152 return parent.type === "NewExpression" && parent.arguments[0] === node && parent.callee.type === "Identifier" && parent.callee.name === "Promise" && isGlobalReference(parent.callee, getOuterScope(scope));
94153 } //------------------------------------------------------------------------------
94154 // Rule Definition
94155 //------------------------------------------------------------------------------
94156
94157
94158 module.exports = {
94159 meta: {
94160 type: "problem",
94161 docs: {
94162 description: "disallow returning values from Promise executor functions",
94163 recommended: false,
94164 url: "https://eslint.org/docs/rules/no-promise-executor-return"
94165 },
94166 schema: [],
94167 messages: {
94168 returnsValue: "Return values from promise executor functions cannot be read."
94169 }
94170 },
94171
94172 create(context) {
94173 let funcInfo = null;
94174 /**
94175 * Reports the given node.
94176 * @param {ASTNode} node Node to report.
94177 * @returns {void}
94178 */
94179
94180 function report(node) {
94181 context.report({
94182 node,
94183 messageId: "returnsValue"
94184 });
94185 }
94186
94187 return {
94188 onCodePathStart(_, node) {
94189 funcInfo = {
94190 upper: funcInfo,
94191 shouldCheck: functionTypesToCheck.has(node.type) && isPromiseExecutor(node, context.getScope())
94192 };
94193
94194 if (funcInfo.shouldCheck && node.type === "ArrowFunctionExpression" && node.expression) {
94195 report(node.body);
94196 }
94197 },
94198
94199 onCodePathEnd() {
94200 funcInfo = funcInfo.upper;
94201 },
94202
94203 ReturnStatement(node) {
94204 if (funcInfo.shouldCheck && node.argument) {
94205 report(node);
94206 }
94207 }
94208
94209 };
94210 }
94211
94212 };
94213
94214 /***/ }),
94215 /* 730 */
94216 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
94217
94218 "use strict";
94219 /**
94220 * @fileoverview Rule to flag usage of __proto__ property
94221 * @author Ilya Volodin
94222 */
94223 //------------------------------------------------------------------------------
94224 // Requirements
94225 //------------------------------------------------------------------------------
94226
94227 const {
94228 getStaticPropertyName
94229 } = __webpack_require__(548); //------------------------------------------------------------------------------
94230 // Rule Definition
94231 //------------------------------------------------------------------------------
94232
94233
94234 module.exports = {
94235 meta: {
94236 type: "suggestion",
94237 docs: {
94238 description: "disallow the use of the `__proto__` property",
94239 recommended: false,
94240 url: "https://eslint.org/docs/rules/no-proto"
94241 },
94242 schema: [],
94243 messages: {
94244 unexpectedProto: "The '__proto__' property is deprecated."
94245 }
94246 },
94247
94248 create(context) {
94249 return {
94250 MemberExpression(node) {
94251 if (getStaticPropertyName(node) === "__proto__") {
94252 context.report({
94253 node,
94254 messageId: "unexpectedProto"
94255 });
94256 }
94257 }
94258
94259 };
94260 }
94261
94262 };
94263
94264 /***/ }),
94265 /* 731 */
94266 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
94267
94268 "use strict";
94269 /**
94270 * @fileoverview Rule to disallow use of Object.prototype builtins on objects
94271 * @author Andrew Levine
94272 */
94273 //------------------------------------------------------------------------------
94274 // Requirements
94275 //------------------------------------------------------------------------------
94276
94277 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
94278 // Rule Definition
94279 //------------------------------------------------------------------------------
94280
94281
94282 module.exports = {
94283 meta: {
94284 type: "problem",
94285 docs: {
94286 description: "disallow calling some `Object.prototype` methods directly on objects",
94287 recommended: true,
94288 url: "https://eslint.org/docs/rules/no-prototype-builtins"
94289 },
94290 schema: [],
94291 messages: {
94292 prototypeBuildIn: "Do not access Object.prototype method '{{prop}}' from target object."
94293 }
94294 },
94295
94296 create(context) {
94297 const DISALLOWED_PROPS = ["hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable"];
94298 /**
94299 * Reports if a disallowed property is used in a CallExpression
94300 * @param {ASTNode} node The CallExpression node.
94301 * @returns {void}
94302 */
94303
94304 function disallowBuiltIns(node) {
94305 const callee = astUtils.skipChainExpression(node.callee);
94306
94307 if (callee.type !== "MemberExpression") {
94308 return;
94309 }
94310
94311 const propName = astUtils.getStaticPropertyName(callee);
94312
94313 if (propName !== null && DISALLOWED_PROPS.indexOf(propName) > -1) {
94314 context.report({
94315 messageId: "prototypeBuildIn",
94316 loc: callee.property.loc,
94317 data: {
94318 prop: propName
94319 },
94320 node
94321 });
94322 }
94323 }
94324
94325 return {
94326 CallExpression: disallowBuiltIns
94327 };
94328 }
94329
94330 };
94331
94332 /***/ }),
94333 /* 732 */
94334 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
94335
94336 "use strict";
94337 /**
94338 * @fileoverview Rule to flag when the same variable is declared more then once.
94339 * @author Ilya Volodin
94340 */
94341 //------------------------------------------------------------------------------
94342 // Requirements
94343 //------------------------------------------------------------------------------
94344
94345 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
94346 // Rule Definition
94347 //------------------------------------------------------------------------------
94348
94349
94350 module.exports = {
94351 meta: {
94352 type: "suggestion",
94353 docs: {
94354 description: "disallow variable redeclaration",
94355 recommended: true,
94356 url: "https://eslint.org/docs/rules/no-redeclare"
94357 },
94358 messages: {
94359 redeclared: "'{{id}}' is already defined.",
94360 redeclaredAsBuiltin: "'{{id}}' is already defined as a built-in global variable.",
94361 redeclaredBySyntax: "'{{id}}' is already defined by a variable declaration."
94362 },
94363 schema: [{
94364 type: "object",
94365 properties: {
94366 builtinGlobals: {
94367 type: "boolean",
94368 default: true
94369 }
94370 },
94371 additionalProperties: false
94372 }]
94373 },
94374
94375 create(context) {
94376 const options = {
94377 builtinGlobals: Boolean(context.options.length === 0 || context.options[0].builtinGlobals)
94378 };
94379 const sourceCode = context.getSourceCode();
94380 /**
94381 * Iterate declarations of a given variable.
94382 * @param {escope.variable} variable The variable object to iterate declarations.
94383 * @returns {IterableIterator<{type:string,node:ASTNode,loc:SourceLocation}>} The declarations.
94384 */
94385
94386 function* iterateDeclarations(variable) {
94387 if (options.builtinGlobals && (variable.eslintImplicitGlobalSetting === "readonly" || variable.eslintImplicitGlobalSetting === "writable")) {
94388 yield {
94389 type: "builtin"
94390 };
94391 }
94392
94393 for (const id of variable.identifiers) {
94394 yield {
94395 type: "syntax",
94396 node: id,
94397 loc: id.loc
94398 };
94399 }
94400
94401 if (variable.eslintExplicitGlobalComments) {
94402 for (const comment of variable.eslintExplicitGlobalComments) {
94403 yield {
94404 type: "comment",
94405 node: comment,
94406 loc: astUtils.getNameLocationInGlobalDirectiveComment(sourceCode, comment, variable.name)
94407 };
94408 }
94409 }
94410 }
94411 /**
94412 * Find variables in a given scope and flag redeclared ones.
94413 * @param {Scope} scope An eslint-scope scope object.
94414 * @returns {void}
94415 * @private
94416 */
94417
94418
94419 function findVariablesInScope(scope) {
94420 for (const variable of scope.variables) {
94421 const [declaration, ...extraDeclarations] = iterateDeclarations(variable);
94422
94423 if (extraDeclarations.length === 0) {
94424 continue;
94425 }
94426 /*
94427 * If the type of a declaration is different from the type of
94428 * the first declaration, it shows the location of the first
94429 * declaration.
94430 */
94431
94432
94433 const detailMessageId = declaration.type === "builtin" ? "redeclaredAsBuiltin" : "redeclaredBySyntax";
94434 const data = {
94435 id: variable.name
94436 }; // Report extra declarations.
94437
94438 for (const {
94439 type,
94440 node,
94441 loc
94442 } of extraDeclarations) {
94443 const messageId = type === declaration.type ? "redeclared" : detailMessageId;
94444 context.report({
94445 node,
94446 loc,
94447 messageId,
94448 data
94449 });
94450 }
94451 }
94452 }
94453 /**
94454 * Find variables in the current scope.
94455 * @param {ASTNode} node The node of the current scope.
94456 * @returns {void}
94457 * @private
94458 */
94459
94460
94461 function checkForBlock(node) {
94462 const scope = context.getScope();
94463 /*
94464 * In ES5, some node type such as `BlockStatement` doesn't have that scope.
94465 * `scope.block` is a different node in such a case.
94466 */
94467
94468 if (scope.block === node) {
94469 findVariablesInScope(scope);
94470 }
94471 }
94472
94473 return {
94474 Program() {
94475 const scope = context.getScope();
94476 findVariablesInScope(scope); // Node.js or ES modules has a special scope.
94477
94478 if (scope.type === "global" && scope.childScopes[0] && // The special scope's block is the Program node.
94479 scope.block === scope.childScopes[0].block) {
94480 findVariablesInScope(scope.childScopes[0]);
94481 }
94482 },
94483
94484 FunctionDeclaration: checkForBlock,
94485 FunctionExpression: checkForBlock,
94486 ArrowFunctionExpression: checkForBlock,
94487 StaticBlock: checkForBlock,
94488 BlockStatement: checkForBlock,
94489 ForStatement: checkForBlock,
94490 ForInStatement: checkForBlock,
94491 ForOfStatement: checkForBlock,
94492 SwitchStatement: checkForBlock
94493 };
94494 }
94495
94496 };
94497
94498 /***/ }),
94499 /* 733 */
94500 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
94501
94502 "use strict";
94503 /**
94504 * @fileoverview Rule to count multiple spaces in regular expressions
94505 * @author Matt DuVall <http://www.mattduvall.com/>
94506 */
94507 //------------------------------------------------------------------------------
94508 // Requirements
94509 //------------------------------------------------------------------------------
94510
94511 const astUtils = __webpack_require__(548);
94512
94513 const regexpp = __webpack_require__(651); //------------------------------------------------------------------------------
94514 // Helpers
94515 //------------------------------------------------------------------------------
94516
94517
94518 const regExpParser = new regexpp.RegExpParser();
94519 const DOUBLE_SPACE = / {2}/u;
94520 /**
94521 * Check if node is a string
94522 * @param {ASTNode} node node to evaluate
94523 * @returns {boolean} True if its a string
94524 * @private
94525 */
94526
94527 function isString(node) {
94528 return node && node.type === "Literal" && typeof node.value === "string";
94529 } //------------------------------------------------------------------------------
94530 // Rule Definition
94531 //------------------------------------------------------------------------------
94532
94533
94534 module.exports = {
94535 meta: {
94536 type: "suggestion",
94537 docs: {
94538 description: "disallow multiple spaces in regular expressions",
94539 recommended: true,
94540 url: "https://eslint.org/docs/rules/no-regex-spaces"
94541 },
94542 schema: [],
94543 fixable: "code",
94544 messages: {
94545 multipleSpaces: "Spaces are hard to count. Use {{{length}}}."
94546 }
94547 },
94548
94549 create(context) {
94550 /**
94551 * Validate regular expression
94552 * @param {ASTNode} nodeToReport Node to report.
94553 * @param {string} pattern Regular expression pattern to validate.
94554 * @param {string} rawPattern Raw representation of the pattern in the source code.
94555 * @param {number} rawPatternStartRange Start range of the pattern in the source code.
94556 * @param {string} flags Regular expression flags.
94557 * @returns {void}
94558 * @private
94559 */
94560 function checkRegex(nodeToReport, pattern, rawPattern, rawPatternStartRange, flags) {
94561 // Skip if there are no consecutive spaces in the source code, to avoid reporting e.g., RegExp(' \ ').
94562 if (!DOUBLE_SPACE.test(rawPattern)) {
94563 return;
94564 }
94565
94566 const characterClassNodes = [];
94567 let regExpAST;
94568
94569 try {
94570 regExpAST = regExpParser.parsePattern(pattern, 0, pattern.length, flags.includes("u"));
94571 } catch {
94572 // Ignore regular expressions with syntax errors
94573 return;
94574 }
94575
94576 regexpp.visitRegExpAST(regExpAST, {
94577 onCharacterClassEnter(ccNode) {
94578 characterClassNodes.push(ccNode);
94579 }
94580
94581 });
94582 const spacesPattern = /( {2,})(?: [+*{?]|[^+*{?]|$)/gu;
94583 let match;
94584
94585 while (match = spacesPattern.exec(pattern)) {
94586 const {
94587 1: {
94588 length
94589 },
94590 index
94591 } = match; // Report only consecutive spaces that are not in character classes.
94592
94593 if (characterClassNodes.every(_ref => {
94594 let {
94595 start,
94596 end
94597 } = _ref;
94598 return index < start || end <= index;
94599 })) {
94600 context.report({
94601 node: nodeToReport,
94602 messageId: "multipleSpaces",
94603 data: {
94604 length
94605 },
94606
94607 fix(fixer) {
94608 if (pattern !== rawPattern) {
94609 return null;
94610 }
94611
94612 return fixer.replaceTextRange([rawPatternStartRange + index, rawPatternStartRange + index + length], " {".concat(length, "}"));
94613 }
94614
94615 }); // Report only the first occurrence of consecutive spaces
94616
94617 return;
94618 }
94619 }
94620 }
94621 /**
94622 * Validate regular expression literals
94623 * @param {ASTNode} node node to validate
94624 * @returns {void}
94625 * @private
94626 */
94627
94628
94629 function checkLiteral(node) {
94630 if (node.regex) {
94631 const pattern = node.regex.pattern;
94632 const rawPattern = node.raw.slice(1, node.raw.lastIndexOf("/"));
94633 const rawPatternStartRange = node.range[0] + 1;
94634 const flags = node.regex.flags;
94635 checkRegex(node, pattern, rawPattern, rawPatternStartRange, flags);
94636 }
94637 }
94638 /**
94639 * Validate strings passed to the RegExp constructor
94640 * @param {ASTNode} node node to validate
94641 * @returns {void}
94642 * @private
94643 */
94644
94645
94646 function checkFunction(node) {
94647 const scope = context.getScope();
94648 const regExpVar = astUtils.getVariableByName(scope, "RegExp");
94649 const shadowed = regExpVar && regExpVar.defs.length > 0;
94650 const patternNode = node.arguments[0];
94651 const flagsNode = node.arguments[1];
94652
94653 if (node.callee.type === "Identifier" && node.callee.name === "RegExp" && isString(patternNode) && !shadowed) {
94654 const pattern = patternNode.value;
94655 const rawPattern = patternNode.raw.slice(1, -1);
94656 const rawPatternStartRange = patternNode.range[0] + 1;
94657 const flags = isString(flagsNode) ? flagsNode.value : "";
94658 checkRegex(node, pattern, rawPattern, rawPatternStartRange, flags);
94659 }
94660 }
94661
94662 return {
94663 Literal: checkLiteral,
94664 CallExpression: checkFunction,
94665 NewExpression: checkFunction
94666 };
94667 }
94668
94669 };
94670
94671 /***/ }),
94672 /* 734 */
94673 /***/ ((module) => {
94674
94675 "use strict";
94676 /**
94677 * @fileoverview Rule to disallow specified names in exports
94678 * @author Milos Djermanovic
94679 */
94680 //------------------------------------------------------------------------------
94681 // Rule Definition
94682 //------------------------------------------------------------------------------
94683
94684 module.exports = {
94685 meta: {
94686 type: "suggestion",
94687 docs: {
94688 description: "disallow specified names in exports",
94689 recommended: false,
94690 url: "https://eslint.org/docs/rules/no-restricted-exports"
94691 },
94692 schema: [{
94693 type: "object",
94694 properties: {
94695 restrictedNamedExports: {
94696 type: "array",
94697 items: {
94698 type: "string"
94699 },
94700 uniqueItems: true
94701 }
94702 },
94703 additionalProperties: false
94704 }],
94705 messages: {
94706 restrictedNamed: "'{{name}}' is restricted from being used as an exported name."
94707 }
94708 },
94709
94710 create(context) {
94711 const restrictedNames = new Set(context.options[0] && context.options[0].restrictedNamedExports);
94712 /**
94713 * Checks and reports given exported identifier.
94714 * @param {ASTNode} node exported `Identifier` node to check.
94715 * @returns {void}
94716 */
94717
94718 function checkExportedName(node) {
94719 const name = node.name;
94720
94721 if (restrictedNames.has(name)) {
94722 context.report({
94723 node,
94724 messageId: "restrictedNamed",
94725 data: {
94726 name
94727 }
94728 });
94729 }
94730 }
94731
94732 return {
94733 ExportAllDeclaration(node) {
94734 if (node.exported) {
94735 checkExportedName(node.exported);
94736 }
94737 },
94738
94739 ExportNamedDeclaration(node) {
94740 const declaration = node.declaration;
94741
94742 if (declaration) {
94743 if (declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") {
94744 checkExportedName(declaration.id);
94745 } else if (declaration.type === "VariableDeclaration") {
94746 context.getDeclaredVariables(declaration).map(v => v.defs.find(d => d.parent === declaration)).map(d => d.name) // Identifier nodes
94747 .forEach(checkExportedName);
94748 }
94749 } else {
94750 node.specifiers.map(s => s.exported).forEach(checkExportedName);
94751 }
94752 }
94753
94754 };
94755 }
94756
94757 };
94758
94759 /***/ }),
94760 /* 735 */
94761 /***/ ((module) => {
94762
94763 "use strict";
94764 /**
94765 * @fileoverview Restrict usage of specified globals.
94766 * @author Benoît Zugmeyer
94767 */
94768 //------------------------------------------------------------------------------
94769 // Rule Definition
94770 //------------------------------------------------------------------------------
94771
94772 module.exports = {
94773 meta: {
94774 type: "suggestion",
94775 docs: {
94776 description: "disallow specified global variables",
94777 recommended: false,
94778 url: "https://eslint.org/docs/rules/no-restricted-globals"
94779 },
94780 schema: {
94781 type: "array",
94782 items: {
94783 oneOf: [{
94784 type: "string"
94785 }, {
94786 type: "object",
94787 properties: {
94788 name: {
94789 type: "string"
94790 },
94791 message: {
94792 type: "string"
94793 }
94794 },
94795 required: ["name"],
94796 additionalProperties: false
94797 }]
94798 },
94799 uniqueItems: true,
94800 minItems: 0
94801 },
94802 messages: {
94803 defaultMessage: "Unexpected use of '{{name}}'.",
94804 // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
94805 customMessage: "Unexpected use of '{{name}}'. {{customMessage}}"
94806 }
94807 },
94808
94809 create(context) {
94810 // If no globals are restricted, we don't need to do anything
94811 if (context.options.length === 0) {
94812 return {};
94813 }
94814
94815 const restrictedGlobalMessages = context.options.reduce((memo, option) => {
94816 if (typeof option === "string") {
94817 memo[option] = null;
94818 } else {
94819 memo[option.name] = option.message;
94820 }
94821
94822 return memo;
94823 }, {});
94824 /**
94825 * Report a variable to be used as a restricted global.
94826 * @param {Reference} reference the variable reference
94827 * @returns {void}
94828 * @private
94829 */
94830
94831 function reportReference(reference) {
94832 const name = reference.identifier.name,
94833 customMessage = restrictedGlobalMessages[name],
94834 messageId = customMessage ? "customMessage" : "defaultMessage";
94835 context.report({
94836 node: reference.identifier,
94837 messageId,
94838 data: {
94839 name,
94840 customMessage
94841 }
94842 });
94843 }
94844 /**
94845 * Check if the given name is a restricted global name.
94846 * @param {string} name name of a variable
94847 * @returns {boolean} whether the variable is a restricted global or not
94848 * @private
94849 */
94850
94851
94852 function isRestricted(name) {
94853 return Object.prototype.hasOwnProperty.call(restrictedGlobalMessages, name);
94854 }
94855
94856 return {
94857 Program() {
94858 const scope = context.getScope(); // Report variables declared elsewhere (ex: variables defined as "global" by eslint)
94859
94860 scope.variables.forEach(variable => {
94861 if (!variable.defs.length && isRestricted(variable.name)) {
94862 variable.references.forEach(reportReference);
94863 }
94864 }); // Report variables not declared at all
94865
94866 scope.through.forEach(reference => {
94867 if (isRestricted(reference.identifier.name)) {
94868 reportReference(reference);
94869 }
94870 });
94871 }
94872
94873 };
94874 }
94875
94876 };
94877
94878 /***/ }),
94879 /* 736 */
94880 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
94881
94882 "use strict";
94883 /**
94884 * @fileoverview Restrict usage of specified node imports.
94885 * @author Guy Ellis
94886 */
94887 //------------------------------------------------------------------------------
94888 // Rule Definition
94889 //------------------------------------------------------------------------------
94890
94891 const ignore = __webpack_require__(737);
94892
94893 const arrayOfStringsOrObjects = {
94894 type: "array",
94895 items: {
94896 anyOf: [{
94897 type: "string"
94898 }, {
94899 type: "object",
94900 properties: {
94901 name: {
94902 type: "string"
94903 },
94904 message: {
94905 type: "string",
94906 minLength: 1
94907 },
94908 importNames: {
94909 type: "array",
94910 items: {
94911 type: "string"
94912 }
94913 }
94914 },
94915 additionalProperties: false,
94916 required: ["name"]
94917 }]
94918 },
94919 uniqueItems: true
94920 };
94921 const arrayOfStringsOrObjectPatterns = {
94922 anyOf: [{
94923 type: "array",
94924 items: {
94925 type: "string"
94926 },
94927 uniqueItems: true
94928 }, {
94929 type: "array",
94930 items: {
94931 type: "object",
94932 properties: {
94933 group: {
94934 type: "array",
94935 items: {
94936 type: "string"
94937 },
94938 minItems: 1,
94939 uniqueItems: true
94940 },
94941 message: {
94942 type: "string",
94943 minLength: 1
94944 }
94945 },
94946 additionalProperties: false,
94947 required: ["group"]
94948 },
94949 uniqueItems: true
94950 }]
94951 };
94952 module.exports = {
94953 meta: {
94954 type: "suggestion",
94955 docs: {
94956 description: "disallow specified modules when loaded by `import`",
94957 recommended: false,
94958 url: "https://eslint.org/docs/rules/no-restricted-imports"
94959 },
94960 messages: {
94961 path: "'{{importSource}}' import is restricted from being used.",
94962 // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
94963 pathWithCustomMessage: "'{{importSource}}' import is restricted from being used. {{customMessage}}",
94964 patterns: "'{{importSource}}' import is restricted from being used by a pattern.",
94965 // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
94966 patternWithCustomMessage: "'{{importSource}}' import is restricted from being used by a pattern. {{customMessage}}",
94967 everything: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted.",
94968 // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
94969 everythingWithCustomMessage: "* import is invalid because '{{importNames}}' from '{{importSource}}' is restricted. {{customMessage}}",
94970 importName: "'{{importName}}' import from '{{importSource}}' is restricted.",
94971 // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
94972 importNameWithCustomMessage: "'{{importName}}' import from '{{importSource}}' is restricted. {{customMessage}}"
94973 },
94974 schema: {
94975 anyOf: [arrayOfStringsOrObjects, {
94976 type: "array",
94977 items: [{
94978 type: "object",
94979 properties: {
94980 paths: arrayOfStringsOrObjects,
94981 patterns: arrayOfStringsOrObjectPatterns
94982 },
94983 additionalProperties: false
94984 }],
94985 additionalItems: false
94986 }]
94987 }
94988 },
94989
94990 create(context) {
94991 const sourceCode = context.getSourceCode();
94992 const options = Array.isArray(context.options) ? context.options : [];
94993 const isPathAndPatternsObject = typeof options[0] === "object" && (Object.prototype.hasOwnProperty.call(options[0], "paths") || Object.prototype.hasOwnProperty.call(options[0], "patterns"));
94994 const restrictedPaths = (isPathAndPatternsObject ? options[0].paths : context.options) || [];
94995 const restrictedPathMessages = restrictedPaths.reduce((memo, importSource) => {
94996 if (typeof importSource === "string") {
94997 memo[importSource] = {
94998 message: null
94999 };
95000 } else {
95001 memo[importSource.name] = {
95002 message: importSource.message,
95003 importNames: importSource.importNames
95004 };
95005 }
95006
95007 return memo;
95008 }, {}); // Handle patterns too, either as strings or groups
95009
95010 const restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || [];
95011 const restrictedPatternGroups = restrictedPatterns.length > 0 && typeof restrictedPatterns[0] === "string" ? [{
95012 matcher: ignore().add(restrictedPatterns)
95013 }] : restrictedPatterns.map(_ref => {
95014 let {
95015 group,
95016 message
95017 } = _ref;
95018 return {
95019 matcher: ignore().add(group),
95020 customMessage: message
95021 };
95022 }); // if no imports are restricted we don't need to check
95023
95024 if (Object.keys(restrictedPaths).length === 0 && restrictedPatternGroups.length === 0) {
95025 return {};
95026 }
95027 /**
95028 * Report a restricted path.
95029 * @param {string} importSource path of the import
95030 * @param {Map<string,Object[]>} importNames Map of import names that are being imported
95031 * @param {node} node representing the restricted path reference
95032 * @returns {void}
95033 * @private
95034 */
95035
95036
95037 function checkRestrictedPathAndReport(importSource, importNames, node) {
95038 if (!Object.prototype.hasOwnProperty.call(restrictedPathMessages, importSource)) {
95039 return;
95040 }
95041
95042 const customMessage = restrictedPathMessages[importSource].message;
95043 const restrictedImportNames = restrictedPathMessages[importSource].importNames;
95044
95045 if (restrictedImportNames) {
95046 if (importNames.has("*")) {
95047 const specifierData = importNames.get("*")[0];
95048 context.report({
95049 node,
95050 messageId: customMessage ? "everythingWithCustomMessage" : "everything",
95051 loc: specifierData.loc,
95052 data: {
95053 importSource,
95054 importNames: restrictedImportNames,
95055 customMessage
95056 }
95057 });
95058 }
95059
95060 restrictedImportNames.forEach(importName => {
95061 if (importNames.has(importName)) {
95062 const specifiers = importNames.get(importName);
95063 specifiers.forEach(specifier => {
95064 context.report({
95065 node,
95066 messageId: customMessage ? "importNameWithCustomMessage" : "importName",
95067 loc: specifier.loc,
95068 data: {
95069 importSource,
95070 customMessage,
95071 importName
95072 }
95073 });
95074 });
95075 }
95076 });
95077 } else {
95078 context.report({
95079 node,
95080 messageId: customMessage ? "pathWithCustomMessage" : "path",
95081 data: {
95082 importSource,
95083 customMessage
95084 }
95085 });
95086 }
95087 }
95088 /**
95089 * Report a restricted path specifically for patterns.
95090 * @param {node} node representing the restricted path reference
95091 * @param {Object} group contains a Ignore instance for paths, and the customMessage to show if it fails
95092 * @returns {void}
95093 * @private
95094 */
95095
95096
95097 function reportPathForPatterns(node, group) {
95098 const importSource = node.source.value.trim();
95099 context.report({
95100 node,
95101 messageId: group.customMessage ? "patternWithCustomMessage" : "patterns",
95102 data: {
95103 importSource,
95104 customMessage: group.customMessage
95105 }
95106 });
95107 }
95108 /**
95109 * Check if the given importSource is restricted by a pattern.
95110 * @param {string} importSource path of the import
95111 * @param {Object} group contains a Ignore instance for paths, and the customMessage to show if it fails
95112 * @returns {boolean} whether the variable is a restricted pattern or not
95113 * @private
95114 */
95115
95116
95117 function isRestrictedPattern(importSource, group) {
95118 return group.matcher.ignores(importSource);
95119 }
95120 /**
95121 * Checks a node to see if any problems should be reported.
95122 * @param {ASTNode} node The node to check.
95123 * @returns {void}
95124 * @private
95125 */
95126
95127
95128 function checkNode(node) {
95129 const importSource = node.source.value.trim();
95130 const importNames = new Map();
95131
95132 if (node.type === "ExportAllDeclaration") {
95133 const starToken = sourceCode.getFirstToken(node, 1);
95134 importNames.set("*", [{
95135 loc: starToken.loc
95136 }]);
95137 } else if (node.specifiers) {
95138 for (const specifier of node.specifiers) {
95139 let name;
95140 const specifierData = {
95141 loc: specifier.loc
95142 };
95143
95144 if (specifier.type === "ImportDefaultSpecifier") {
95145 name = "default";
95146 } else if (specifier.type === "ImportNamespaceSpecifier") {
95147 name = "*";
95148 } else if (specifier.imported) {
95149 name = specifier.imported.name;
95150 } else if (specifier.local) {
95151 name = specifier.local.name;
95152 }
95153
95154 if (name) {
95155 if (importNames.has(name)) {
95156 importNames.get(name).push(specifierData);
95157 } else {
95158 importNames.set(name, [specifierData]);
95159 }
95160 }
95161 }
95162 }
95163
95164 checkRestrictedPathAndReport(importSource, importNames, node);
95165 restrictedPatternGroups.forEach(group => {
95166 if (isRestrictedPattern(importSource, group)) {
95167 reportPathForPatterns(node, group);
95168 }
95169 });
95170 }
95171
95172 return {
95173 ImportDeclaration: checkNode,
95174
95175 ExportNamedDeclaration(node) {
95176 if (node.source) {
95177 checkNode(node);
95178 }
95179 },
95180
95181 ExportAllDeclaration: checkNode
95182 };
95183 }
95184
95185 };
95186
95187 /***/ }),
95188 /* 737 */
95189 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
95190
95191 /* provided dependency */ var process = __webpack_require__(494);
95192 // A simple implementation of make-array
95193 function make_array(subject) {
95194 return Array.isArray(subject) ? subject : [subject];
95195 }
95196
95197 const REGEX_BLANK_LINE = /^\s+$/;
95198 const REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
95199 const REGEX_LEADING_EXCAPED_HASH = /^\\#/;
95200 const SLASH = '/';
95201 const KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore')
95202 /* istanbul ignore next */
95203 : 'node-ignore';
95204
95205 const define = (object, key, value) => Object.defineProperty(object, key, {
95206 value
95207 });
95208
95209 const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g; // Sanitize the range of a regular expression
95210 // The cases are complicated, see test cases for details
95211
95212 const sanitizeRange = range => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
95213 // fatal for JavaScript regular expression, so eliminate it.
95214 : ''); // > If the pattern ends with a slash,
95215 // > it is removed for the purpose of the following description,
95216 // > but it would only find a match with a directory.
95217 // > In other words, foo/ will match a directory foo and paths underneath it,
95218 // > but will not match a regular file or a symbolic link foo
95219 // > (this is consistent with the way how pathspec works in general in Git).
95220 // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
95221 // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
95222 // you could use option `mark: true` with `glob`
95223 // '`foo/`' should not continue with the '`..`'
95224
95225
95226 const DEFAULT_REPLACER_PREFIX = [// > Trailing spaces are ignored unless they are quoted with backslash ("\")
95227 [// (a\ ) -> (a )
95228 // (a ) -> (a)
95229 // (a \ ) -> (a )
95230 /\\?\s+$/, match => match.indexOf('\\') === 0 ? ' ' : ''], // replace (\ ) with ' '
95231 [/\\\s/g, () => ' '], // Escape metacharacters
95232 // which is written down by users but means special for regular expressions.
95233 // > There are 12 characters with special meanings:
95234 // > - the backslash \,
95235 // > - the caret ^,
95236 // > - the dollar sign $,
95237 // > - the period or dot .,
95238 // > - the vertical bar or pipe symbol |,
95239 // > - the question mark ?,
95240 // > - the asterisk or star *,
95241 // > - the plus sign +,
95242 // > - the opening parenthesis (,
95243 // > - the closing parenthesis ),
95244 // > - and the opening square bracket [,
95245 // > - the opening curly brace {,
95246 // > These special characters are often called "metacharacters".
95247 [/[\\^$.|*+(){]/g, match => "\\".concat(match)], [// > [abc] matches any character inside the brackets
95248 // > (in this case a, b, or c);
95249 /\[([^\]/]*)($|\])/g, (match, p1, p2) => p2 === ']' ? "[".concat(sanitizeRange(p1), "]") : "\\".concat(match)], [// > a question mark (?) matches a single character
95250 /(?!\\)\?/g, () => '[^/]'], // leading slash
95251 [// > A leading slash matches the beginning of the pathname.
95252 // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
95253 // A leading slash matches the beginning of the pathname
95254 /^\//, () => '^'], // replace special metacharacter slash after the leading slash
95255 [/\//g, () => '\\/'], [// > A leading "**" followed by a slash means match in all directories.
95256 // > For example, "**/foo" matches file or directory "foo" anywhere,
95257 // > the same as pattern "foo".
95258 // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
95259 // > under directory "foo".
95260 // Notice that the '*'s have been replaced as '\\*'
95261 /^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo'
95262 () => '^(?:.*\\/)?']];
95263 const DEFAULT_REPLACER_SUFFIX = [// starting
95264 [// there will be no leading '/'
95265 // (which has been replaced by section "leading slash")
95266 // If starts with '**', adding a '^' to the regular expression also works
95267 /^(?=[^^])/, function startingReplacer() {
95268 return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /,
95269 // > Git treats it as a shell glob pattern
95270 // Actually, if there is only a trailing slash,
95271 // git also treats it as a shell glob pattern
95272 ? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for
95273 // > consumption by fnmatch(3)
95274 : '^';
95275 }], // two globstars
95276 [// Use lookahead assertions so that we could match more than one `'/**'`
95277 /\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories
95278 // should not use '*', or it will be replaced by the next replacer
95279 // Check if it is not the last `'/**'`
95280 (match, index, str) => index + 6 < str.length // case: /**/
95281 // > A slash followed by two consecutive asterisks then a slash matches
95282 // > zero or more directories.
95283 // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
95284 // '/**/'
95285 ? '(?:\\/[^\\/]+)*' // case: /**
95286 // > A trailing `"/**"` matches everything inside.
95287 // #21: everything inside but it should not include the current folder
95288 : '\\/.+'], // intermediate wildcards
95289 [// Never replace escaped '*'
95290 // ignore rule '\*' will match the path '*'
95291 // 'abc.*/' -> go
95292 // 'abc.*' -> skip this rule
95293 /(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js'
95294 // '*.js' doesn't match 'abc'
95295 (match, p1) => "".concat(p1, "[^\\/]*")], // trailing wildcard
95296 [/(\^|\\\/)?\\\*$/, (match, p1) => {
95297 const prefix = p1 // '\^':
95298 // '/*' does not match ''
95299 // '/*' does not match everything
95300 // '\\\/':
95301 // 'abc/*' does not match 'abc/'
95302 ? "".concat(p1, "[^/]+") // 'a*' matches 'a'
95303 // 'a*' matches 'aa'
95304 : '[^/]*';
95305 return "".concat(prefix, "(?=$|\\/$)");
95306 }], [// unescape
95307 /\\\\\\/g, () => '\\']];
95308 const POSITIVE_REPLACERS = [...DEFAULT_REPLACER_PREFIX, // 'f'
95309 // matches
95310 // - /f(end)
95311 // - /f/
95312 // - (start)f(end)
95313 // - (start)f/
95314 // doesn't match
95315 // - oof
95316 // - foo
95317 // pseudo:
95318 // -> (^|/)f(/|$)
95319 // ending
95320 [// 'js' will not match 'js.'
95321 // 'ab' will not match 'abc'
95322 /(?:[^*/])$/, // 'js*' will not match 'a.js'
95323 // 'js/' will not match 'a.js'
95324 // 'js' will match 'a.js' and 'a.js/'
95325 match => "".concat(match, "(?=$|\\/)")], ...DEFAULT_REPLACER_SUFFIX];
95326 const NEGATIVE_REPLACERS = [...DEFAULT_REPLACER_PREFIX, // #24, #38
95327 // The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore)
95328 // A negative pattern without a trailing wildcard should not
95329 // re-include the things inside that directory.
95330 // eg:
95331 // ['node_modules/*', '!node_modules']
95332 // should ignore `node_modules/a.js`
95333 [/(?:[^*])$/, match => "".concat(match, "(?=$|\\/$)")], ...DEFAULT_REPLACER_SUFFIX]; // A simple cache, because an ignore rule only has only one certain meaning
95334
95335 const cache = Object.create(null); // @param {pattern}
95336
95337 const make_regex = (pattern, negative, ignorecase) => {
95338 const r = cache[pattern];
95339
95340 if (r) {
95341 return r;
95342 }
95343
95344 const replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
95345 const source = replacers.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
95346 return cache[pattern] = ignorecase ? new RegExp(source, 'i') : new RegExp(source);
95347 }; // > A blank line matches no files, so it can serve as a separator for readability.
95348
95349
95350 const checkPattern = pattern => pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
95351 && pattern.indexOf('#') !== 0;
95352
95353 const createRule = (pattern, ignorecase) => {
95354 const origin = pattern;
95355 let negative = false; // > An optional prefix "!" which negates the pattern;
95356
95357 if (pattern.indexOf('!') === 0) {
95358 negative = true;
95359 pattern = pattern.substr(1);
95360 }
95361
95362 pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that
95363 // > begin with a literal "!", for example, `"\!important!.txt"`.
95364 .replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that
95365 // > begin with a hash.
95366 .replace(REGEX_LEADING_EXCAPED_HASH, '#');
95367 const regex = make_regex(pattern, negative, ignorecase);
95368 return {
95369 origin,
95370 pattern,
95371 negative,
95372 regex
95373 };
95374 };
95375
95376 class IgnoreBase {
95377 constructor() {
95378 let {
95379 ignorecase = true
95380 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
95381 this._rules = [];
95382 this._ignorecase = ignorecase;
95383 define(this, KEY_IGNORE, true);
95384
95385 this._initCache();
95386 }
95387
95388 _initCache() {
95389 this._cache = Object.create(null);
95390 } // @param {Array.<string>|string|Ignore} pattern
95391
95392
95393 add(pattern) {
95394 this._added = false;
95395
95396 if (typeof pattern === 'string') {
95397 pattern = pattern.split(/\r?\n/g);
95398 }
95399
95400 make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
95401 // making the behavior changed.
95402
95403 if (this._added) {
95404 this._initCache();
95405 }
95406
95407 return this;
95408 } // legacy
95409
95410
95411 addPattern(pattern) {
95412 return this.add(pattern);
95413 }
95414
95415 _addPattern(pattern) {
95416 // #32
95417 if (pattern && pattern[KEY_IGNORE]) {
95418 this._rules = this._rules.concat(pattern._rules);
95419 this._added = true;
95420 return;
95421 }
95422
95423 if (checkPattern(pattern)) {
95424 const rule = createRule(pattern, this._ignorecase);
95425 this._added = true;
95426
95427 this._rules.push(rule);
95428 }
95429 }
95430
95431 filter(paths) {
95432 return make_array(paths).filter(path => this._filter(path));
95433 }
95434
95435 createFilter() {
95436 return path => this._filter(path);
95437 }
95438
95439 ignores(path) {
95440 return !this._filter(path);
95441 } // @returns `Boolean` true if the `path` is NOT ignored
95442
95443
95444 _filter(path, slices) {
95445 if (!path) {
95446 return false;
95447 }
95448
95449 if (path in this._cache) {
95450 return this._cache[path];
95451 }
95452
95453 if (!slices) {
95454 // path/to/a.js
95455 // ['path', 'to', 'a.js']
95456 slices = path.split(SLASH);
95457 }
95458
95459 slices.pop();
95460 return this._cache[path] = slices.length // > It is not possible to re-include a file if a parent directory of
95461 // > that file is excluded.
95462 // If the path contains a parent directory, check the parent first
95463 ? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path) // Or only test the path
95464 : this._test(path);
95465 } // @returns {Boolean} true if a file is NOT ignored
95466
95467
95468 _test(path) {
95469 // Explicitly define variable type by setting matched to `0`
95470 let matched = 0;
95471
95472 this._rules.forEach(rule => {
95473 // if matched = true, then we only test negative rules
95474 // if matched = false, then we test non-negative rules
95475 if (!(matched ^ rule.negative)) {
95476 matched = rule.negative ^ rule.regex.test(path);
95477 }
95478 });
95479
95480 return !matched;
95481 }
95482
95483 } // Windows
95484 // --------------------------------------------------------------
95485
95486 /* istanbul ignore if */
95487
95488
95489 if ( // Detect `process` so that it can run in browsers.
95490 typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
95491 const filter = IgnoreBase.prototype._filter;
95492 /* eslint no-control-regex: "off" */
95493
95494 const make_posix = str => /^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/');
95495
95496 IgnoreBase.prototype._filter = function filterWin32(path, slices) {
95497 path = make_posix(path);
95498 return filter.call(this, path, slices);
95499 };
95500 }
95501
95502 module.exports = options => new IgnoreBase(options);
95503
95504 /***/ }),
95505 /* 738 */
95506 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
95507
95508 "use strict";
95509 /**
95510 * @fileoverview Restrict usage of specified node modules.
95511 * @author Christian Schulz
95512 * @deprecated in ESLint v7.0.0
95513 */
95514 //------------------------------------------------------------------------------
95515 // Rule Definition
95516 //------------------------------------------------------------------------------
95517
95518 const ignore = __webpack_require__(737);
95519
95520 const arrayOfStrings = {
95521 type: "array",
95522 items: {
95523 type: "string"
95524 },
95525 uniqueItems: true
95526 };
95527 const arrayOfStringsOrObjects = {
95528 type: "array",
95529 items: {
95530 anyOf: [{
95531 type: "string"
95532 }, {
95533 type: "object",
95534 properties: {
95535 name: {
95536 type: "string"
95537 },
95538 message: {
95539 type: "string",
95540 minLength: 1
95541 }
95542 },
95543 additionalProperties: false,
95544 required: ["name"]
95545 }]
95546 },
95547 uniqueItems: true
95548 };
95549 module.exports = {
95550 meta: {
95551 deprecated: true,
95552 replacedBy: [],
95553 type: "suggestion",
95554 docs: {
95555 description: "disallow specified modules when loaded by `require`",
95556 recommended: false,
95557 url: "https://eslint.org/docs/rules/no-restricted-modules"
95558 },
95559 schema: {
95560 anyOf: [arrayOfStringsOrObjects, {
95561 type: "array",
95562 items: {
95563 type: "object",
95564 properties: {
95565 paths: arrayOfStringsOrObjects,
95566 patterns: arrayOfStrings
95567 },
95568 additionalProperties: false
95569 },
95570 additionalItems: false
95571 }]
95572 },
95573 messages: {
95574 defaultMessage: "'{{name}}' module is restricted from being used.",
95575 // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
95576 customMessage: "'{{name}}' module is restricted from being used. {{customMessage}}",
95577 patternMessage: "'{{name}}' module is restricted from being used by a pattern."
95578 }
95579 },
95580
95581 create(context) {
95582 const options = Array.isArray(context.options) ? context.options : [];
95583 const isPathAndPatternsObject = typeof options[0] === "object" && (Object.prototype.hasOwnProperty.call(options[0], "paths") || Object.prototype.hasOwnProperty.call(options[0], "patterns"));
95584 const restrictedPaths = (isPathAndPatternsObject ? options[0].paths : context.options) || [];
95585 const restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || [];
95586 const restrictedPathMessages = restrictedPaths.reduce((memo, importName) => {
95587 if (typeof importName === "string") {
95588 memo[importName] = null;
95589 } else {
95590 memo[importName.name] = importName.message;
95591 }
95592
95593 return memo;
95594 }, {}); // if no imports are restricted we don't need to check
95595
95596 if (Object.keys(restrictedPaths).length === 0 && restrictedPatterns.length === 0) {
95597 return {};
95598 }
95599
95600 const ig = ignore().add(restrictedPatterns);
95601 /**
95602 * Function to check if a node is a string literal.
95603 * @param {ASTNode} node The node to check.
95604 * @returns {boolean} If the node is a string literal.
95605 */
95606
95607 function isStringLiteral(node) {
95608 return node && node.type === "Literal" && typeof node.value === "string";
95609 }
95610 /**
95611 * Function to check if a node is a static string template literal.
95612 * @param {ASTNode} node The node to check.
95613 * @returns {boolean} If the node is a string template literal.
95614 */
95615
95616
95617 function isStaticTemplateLiteral(node) {
95618 return node && node.type === "TemplateLiteral" && node.expressions.length === 0;
95619 }
95620 /**
95621 * Function to check if a node is a require call.
95622 * @param {ASTNode} node The node to check.
95623 * @returns {boolean} If the node is a require call.
95624 */
95625
95626
95627 function isRequireCall(node) {
95628 return node.callee.type === "Identifier" && node.callee.name === "require";
95629 }
95630 /**
95631 * Extract string from Literal or TemplateLiteral node
95632 * @param {ASTNode} node The node to extract from
95633 * @returns {string|null} Extracted string or null if node doesn't represent a string
95634 */
95635
95636
95637 function getFirstArgumentString(node) {
95638 if (isStringLiteral(node)) {
95639 return node.value.trim();
95640 }
95641
95642 if (isStaticTemplateLiteral(node)) {
95643 return node.quasis[0].value.cooked.trim();
95644 }
95645
95646 return null;
95647 }
95648 /**
95649 * Report a restricted path.
95650 * @param {node} node representing the restricted path reference
95651 * @param {string} name restricted path
95652 * @returns {void}
95653 * @private
95654 */
95655
95656
95657 function reportPath(node, name) {
95658 const customMessage = restrictedPathMessages[name];
95659 const messageId = customMessage ? "customMessage" : "defaultMessage";
95660 context.report({
95661 node,
95662 messageId,
95663 data: {
95664 name,
95665 customMessage
95666 }
95667 });
95668 }
95669 /**
95670 * Check if the given name is a restricted path name
95671 * @param {string} name name of a variable
95672 * @returns {boolean} whether the variable is a restricted path or not
95673 * @private
95674 */
95675
95676
95677 function isRestrictedPath(name) {
95678 return Object.prototype.hasOwnProperty.call(restrictedPathMessages, name);
95679 }
95680
95681 return {
95682 CallExpression(node) {
95683 if (isRequireCall(node)) {
95684 // node has arguments
95685 if (node.arguments.length) {
95686 const name = getFirstArgumentString(node.arguments[0]); // if first argument is a string literal or a static string template literal
95687
95688 if (name) {
95689 // check if argument value is in restricted modules array
95690 if (isRestrictedPath(name)) {
95691 reportPath(node, name);
95692 }
95693
95694 if (restrictedPatterns.length > 0 && ig.ignores(name)) {
95695 context.report({
95696 node,
95697 messageId: "patternMessage",
95698 data: {
95699 name
95700 }
95701 });
95702 }
95703 }
95704 }
95705 }
95706 }
95707
95708 };
95709 }
95710
95711 };
95712
95713 /***/ }),
95714 /* 739 */
95715 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
95716
95717 "use strict";
95718 /**
95719 * @fileoverview Rule to disallow certain object properties
95720 * @author Will Klein & Eli White
95721 */
95722
95723
95724 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
95725 // Rule Definition
95726 //------------------------------------------------------------------------------
95727
95728
95729 module.exports = {
95730 meta: {
95731 type: "suggestion",
95732 docs: {
95733 description: "disallow certain properties on certain objects",
95734 recommended: false,
95735 url: "https://eslint.org/docs/rules/no-restricted-properties"
95736 },
95737 schema: {
95738 type: "array",
95739 items: {
95740 anyOf: [// `object` and `property` are both optional, but at least one of them must be provided.
95741 {
95742 type: "object",
95743 properties: {
95744 object: {
95745 type: "string"
95746 },
95747 property: {
95748 type: "string"
95749 },
95750 message: {
95751 type: "string"
95752 }
95753 },
95754 additionalProperties: false,
95755 required: ["object"]
95756 }, {
95757 type: "object",
95758 properties: {
95759 object: {
95760 type: "string"
95761 },
95762 property: {
95763 type: "string"
95764 },
95765 message: {
95766 type: "string"
95767 }
95768 },
95769 additionalProperties: false,
95770 required: ["property"]
95771 }]
95772 },
95773 uniqueItems: true
95774 },
95775 messages: {
95776 // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
95777 restrictedObjectProperty: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}",
95778 // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
95779 restrictedProperty: "'{{propertyName}}' is restricted from being used.{{message}}"
95780 }
95781 },
95782
95783 create(context) {
95784 const restrictedCalls = context.options;
95785
95786 if (restrictedCalls.length === 0) {
95787 return {};
95788 }
95789
95790 const restrictedProperties = new Map();
95791 const globallyRestrictedObjects = new Map();
95792 const globallyRestrictedProperties = new Map();
95793 restrictedCalls.forEach(option => {
95794 const objectName = option.object;
95795 const propertyName = option.property;
95796
95797 if (typeof objectName === "undefined") {
95798 globallyRestrictedProperties.set(propertyName, {
95799 message: option.message
95800 });
95801 } else if (typeof propertyName === "undefined") {
95802 globallyRestrictedObjects.set(objectName, {
95803 message: option.message
95804 });
95805 } else {
95806 if (!restrictedProperties.has(objectName)) {
95807 restrictedProperties.set(objectName, new Map());
95808 }
95809
95810 restrictedProperties.get(objectName).set(propertyName, {
95811 message: option.message
95812 });
95813 }
95814 });
95815 /**
95816 * Checks to see whether a property access is restricted, and reports it if so.
95817 * @param {ASTNode} node The node to report
95818 * @param {string} objectName The name of the object
95819 * @param {string} propertyName The name of the property
95820 * @returns {undefined}
95821 */
95822
95823 function checkPropertyAccess(node, objectName, propertyName) {
95824 if (propertyName === null) {
95825 return;
95826 }
95827
95828 const matchedObject = restrictedProperties.get(objectName);
95829 const matchedObjectProperty = matchedObject ? matchedObject.get(propertyName) : globallyRestrictedObjects.get(objectName);
95830 const globalMatchedProperty = globallyRestrictedProperties.get(propertyName);
95831
95832 if (matchedObjectProperty) {
95833 const message = matchedObjectProperty.message ? " ".concat(matchedObjectProperty.message) : "";
95834 context.report({
95835 node,
95836 messageId: "restrictedObjectProperty",
95837 data: {
95838 objectName,
95839 propertyName,
95840 message
95841 }
95842 });
95843 } else if (globalMatchedProperty) {
95844 const message = globalMatchedProperty.message ? " ".concat(globalMatchedProperty.message) : "";
95845 context.report({
95846 node,
95847 messageId: "restrictedProperty",
95848 data: {
95849 propertyName,
95850 message
95851 }
95852 });
95853 }
95854 }
95855 /**
95856 * Checks property accesses in a destructuring assignment expression, e.g. `var foo; ({foo} = bar);`
95857 * @param {ASTNode} node An AssignmentExpression or AssignmentPattern node
95858 * @returns {undefined}
95859 */
95860
95861
95862 function checkDestructuringAssignment(node) {
95863 if (node.right.type === "Identifier") {
95864 const objectName = node.right.name;
95865
95866 if (node.left.type === "ObjectPattern") {
95867 node.left.properties.forEach(property => {
95868 checkPropertyAccess(node.left, objectName, astUtils.getStaticPropertyName(property));
95869 });
95870 }
95871 }
95872 }
95873
95874 return {
95875 MemberExpression(node) {
95876 checkPropertyAccess(node, node.object && node.object.name, astUtils.getStaticPropertyName(node));
95877 },
95878
95879 VariableDeclarator(node) {
95880 if (node.init && node.init.type === "Identifier") {
95881 const objectName = node.init.name;
95882
95883 if (node.id.type === "ObjectPattern") {
95884 node.id.properties.forEach(property => {
95885 checkPropertyAccess(node.id, objectName, astUtils.getStaticPropertyName(property));
95886 });
95887 }
95888 }
95889 },
95890
95891 AssignmentExpression: checkDestructuringAssignment,
95892 AssignmentPattern: checkDestructuringAssignment
95893 };
95894 }
95895
95896 };
95897
95898 /***/ }),
95899 /* 740 */
95900 /***/ ((module) => {
95901
95902 "use strict";
95903 /**
95904 * @fileoverview Rule to flag use of certain node types
95905 * @author Burak Yigit Kaya
95906 */
95907 //------------------------------------------------------------------------------
95908 // Rule Definition
95909 //------------------------------------------------------------------------------
95910
95911 module.exports = {
95912 meta: {
95913 type: "suggestion",
95914 docs: {
95915 description: "disallow specified syntax",
95916 recommended: false,
95917 url: "https://eslint.org/docs/rules/no-restricted-syntax"
95918 },
95919 schema: {
95920 type: "array",
95921 items: {
95922 oneOf: [{
95923 type: "string"
95924 }, {
95925 type: "object",
95926 properties: {
95927 selector: {
95928 type: "string"
95929 },
95930 message: {
95931 type: "string"
95932 }
95933 },
95934 required: ["selector"],
95935 additionalProperties: false
95936 }]
95937 },
95938 uniqueItems: true,
95939 minItems: 0
95940 },
95941 messages: {
95942 // eslint-disable-next-line eslint-plugin/report-message-format -- Custom message might not end in a period
95943 restrictedSyntax: "{{message}}"
95944 }
95945 },
95946
95947 create(context) {
95948 return context.options.reduce((result, selectorOrObject) => {
95949 const isStringFormat = typeof selectorOrObject === "string";
95950 const hasCustomMessage = !isStringFormat && Boolean(selectorOrObject.message);
95951 const selector = isStringFormat ? selectorOrObject : selectorOrObject.selector;
95952 const message = hasCustomMessage ? selectorOrObject.message : "Using '".concat(selector, "' is not allowed.");
95953 return Object.assign(result, {
95954 [selector](node) {
95955 context.report({
95956 node,
95957 messageId: "restrictedSyntax",
95958 data: {
95959 message
95960 }
95961 });
95962 }
95963
95964 });
95965 }, {});
95966 }
95967
95968 };
95969
95970 /***/ }),
95971 /* 741 */
95972 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
95973
95974 "use strict";
95975 /**
95976 * @fileoverview Rule to flag when return statement contains assignment
95977 * @author Ilya Volodin
95978 */
95979 //------------------------------------------------------------------------------
95980 // Requirements
95981 //------------------------------------------------------------------------------
95982
95983 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
95984 // Helpers
95985 //------------------------------------------------------------------------------
95986
95987
95988 const SENTINEL_TYPE = /^(?:[a-zA-Z]+?Statement|ArrowFunctionExpression|FunctionExpression|ClassExpression)$/u; //------------------------------------------------------------------------------
95989 // Rule Definition
95990 //------------------------------------------------------------------------------
95991
95992 module.exports = {
95993 meta: {
95994 type: "suggestion",
95995 docs: {
95996 description: "disallow assignment operators in `return` statements",
95997 recommended: false,
95998 url: "https://eslint.org/docs/rules/no-return-assign"
95999 },
96000 schema: [{
96001 enum: ["except-parens", "always"]
96002 }],
96003 messages: {
96004 returnAssignment: "Return statement should not contain assignment.",
96005 arrowAssignment: "Arrow function should not return assignment."
96006 }
96007 },
96008
96009 create(context) {
96010 const always = (context.options[0] || "except-parens") !== "except-parens";
96011 const sourceCode = context.getSourceCode();
96012 return {
96013 AssignmentExpression(node) {
96014 if (!always && astUtils.isParenthesised(sourceCode, node)) {
96015 return;
96016 }
96017
96018 let currentChild = node;
96019 let parent = currentChild.parent; // Find ReturnStatement or ArrowFunctionExpression in ancestors.
96020
96021 while (parent && !SENTINEL_TYPE.test(parent.type)) {
96022 currentChild = parent;
96023 parent = parent.parent;
96024 } // Reports.
96025
96026
96027 if (parent && parent.type === "ReturnStatement") {
96028 context.report({
96029 node: parent,
96030 messageId: "returnAssignment"
96031 });
96032 } else if (parent && parent.type === "ArrowFunctionExpression" && parent.body === currentChild) {
96033 context.report({
96034 node: parent,
96035 messageId: "arrowAssignment"
96036 });
96037 }
96038 }
96039
96040 };
96041 }
96042
96043 };
96044
96045 /***/ }),
96046 /* 742 */
96047 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
96048
96049 "use strict";
96050 /**
96051 * @fileoverview Disallows unnecessary `return await`
96052 * @author Jordan Harband
96053 */
96054
96055
96056 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
96057 // Rule Definition
96058 //------------------------------------------------------------------------------
96059
96060
96061 module.exports = {
96062 meta: {
96063 type: "suggestion",
96064 docs: {
96065 description: "disallow unnecessary `return await`",
96066 recommended: false,
96067 url: "https://eslint.org/docs/rules/no-return-await"
96068 },
96069 fixable: null,
96070 schema: [],
96071 messages: {
96072 redundantUseOfAwait: "Redundant use of `await` on a return value."
96073 }
96074 },
96075
96076 create(context) {
96077 /**
96078 * Reports a found unnecessary `await` expression.
96079 * @param {ASTNode} node The node representing the `await` expression to report
96080 * @returns {void}
96081 */
96082 function reportUnnecessaryAwait(node) {
96083 context.report({
96084 node: context.getSourceCode().getFirstToken(node),
96085 loc: node.loc,
96086 messageId: "redundantUseOfAwait"
96087 });
96088 }
96089 /**
96090 * Determines whether a thrown error from this node will be caught/handled within this function rather than immediately halting
96091 * this function. For example, a statement in a `try` block will always have an error handler. A statement in
96092 * a `catch` block will only have an error handler if there is also a `finally` block.
96093 * @param {ASTNode} node A node representing a location where an could be thrown
96094 * @returns {boolean} `true` if a thrown error will be caught/handled in this function
96095 */
96096
96097
96098 function hasErrorHandler(node) {
96099 let ancestor = node;
96100
96101 while (!astUtils.isFunction(ancestor) && ancestor.type !== "Program") {
96102 if (ancestor.parent.type === "TryStatement" && (ancestor === ancestor.parent.block || ancestor === ancestor.parent.handler && ancestor.parent.finalizer)) {
96103 return true;
96104 }
96105
96106 ancestor = ancestor.parent;
96107 }
96108
96109 return false;
96110 }
96111 /**
96112 * Checks if a node is placed in tail call position. Once `return` arguments (or arrow function expressions) can be a complex expression,
96113 * an `await` expression could or could not be unnecessary by the definition of this rule. So we're looking for `await` expressions that are in tail position.
96114 * @param {ASTNode} node A node representing the `await` expression to check
96115 * @returns {boolean} The checking result
96116 */
96117
96118
96119 function isInTailCallPosition(node) {
96120 if (node.parent.type === "ArrowFunctionExpression") {
96121 return true;
96122 }
96123
96124 if (node.parent.type === "ReturnStatement") {
96125 return !hasErrorHandler(node.parent);
96126 }
96127
96128 if (node.parent.type === "ConditionalExpression" && (node === node.parent.consequent || node === node.parent.alternate)) {
96129 return isInTailCallPosition(node.parent);
96130 }
96131
96132 if (node.parent.type === "LogicalExpression" && node === node.parent.right) {
96133 return isInTailCallPosition(node.parent);
96134 }
96135
96136 if (node.parent.type === "SequenceExpression" && node === node.parent.expressions[node.parent.expressions.length - 1]) {
96137 return isInTailCallPosition(node.parent);
96138 }
96139
96140 return false;
96141 }
96142
96143 return {
96144 AwaitExpression(node) {
96145 if (isInTailCallPosition(node) && !hasErrorHandler(node)) {
96146 reportUnnecessaryAwait(node);
96147 }
96148 }
96149
96150 };
96151 }
96152
96153 };
96154
96155 /***/ }),
96156 /* 743 */
96157 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
96158
96159 "use strict";
96160 /**
96161 * @fileoverview Rule to flag when using javascript: urls
96162 * @author Ilya Volodin
96163 */
96164
96165 /* eslint no-script-url: 0 -- Code is checking to report such URLs */
96166
96167
96168 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
96169 // Rule Definition
96170 //------------------------------------------------------------------------------
96171
96172
96173 module.exports = {
96174 meta: {
96175 type: "suggestion",
96176 docs: {
96177 description: "disallow `javascript:` urls",
96178 recommended: false,
96179 url: "https://eslint.org/docs/rules/no-script-url"
96180 },
96181 schema: [],
96182 messages: {
96183 unexpectedScriptURL: "Script URL is a form of eval."
96184 }
96185 },
96186
96187 create(context) {
96188 /**
96189 * Check whether a node's static value starts with "javascript:" or not.
96190 * And report an error for unexpected script URL.
96191 * @param {ASTNode} node node to check
96192 * @returns {void}
96193 */
96194 function check(node) {
96195 const value = astUtils.getStaticStringValue(node);
96196
96197 if (typeof value === "string" && value.toLowerCase().indexOf("javascript:") === 0) {
96198 context.report({
96199 node,
96200 messageId: "unexpectedScriptURL"
96201 });
96202 }
96203 }
96204
96205 return {
96206 Literal(node) {
96207 if (node.value && typeof node.value === "string") {
96208 check(node);
96209 }
96210 },
96211
96212 TemplateLiteral(node) {
96213 if (!(node.parent && node.parent.type === "TaggedTemplateExpression")) {
96214 check(node);
96215 }
96216 }
96217
96218 };
96219 }
96220
96221 };
96222
96223 /***/ }),
96224 /* 744 */
96225 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
96226
96227 "use strict";
96228 /**
96229 * @fileoverview Rule to disallow assignments where both sides are exactly the same
96230 * @author Toru Nagashima
96231 */
96232 //------------------------------------------------------------------------------
96233 // Requirements
96234 //------------------------------------------------------------------------------
96235
96236 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
96237 // Helpers
96238 //------------------------------------------------------------------------------
96239
96240
96241 const SPACES = /\s+/gu;
96242 /**
96243 * Traverses 2 Pattern nodes in parallel, then reports self-assignments.
96244 * @param {ASTNode|null} left A left node to traverse. This is a Pattern or
96245 * a Property.
96246 * @param {ASTNode|null} right A right node to traverse. This is a Pattern or
96247 * a Property.
96248 * @param {boolean} props The flag to check member expressions as well.
96249 * @param {Function} report A callback function to report.
96250 * @returns {void}
96251 */
96252
96253 function eachSelfAssignment(left, right, props, report) {
96254 if (!left || !right) {// do nothing
96255 } else if (left.type === "Identifier" && right.type === "Identifier" && left.name === right.name) {
96256 report(right);
96257 } else if (left.type === "ArrayPattern" && right.type === "ArrayExpression") {
96258 const end = Math.min(left.elements.length, right.elements.length);
96259
96260 for (let i = 0; i < end; ++i) {
96261 const leftElement = left.elements[i];
96262 const rightElement = right.elements[i]; // Avoid cases such as [...a] = [...a, 1]
96263
96264 if (leftElement && leftElement.type === "RestElement" && i < right.elements.length - 1) {
96265 break;
96266 }
96267
96268 eachSelfAssignment(leftElement, rightElement, props, report); // After a spread element, those indices are unknown.
96269
96270 if (rightElement && rightElement.type === "SpreadElement") {
96271 break;
96272 }
96273 }
96274 } else if (left.type === "RestElement" && right.type === "SpreadElement") {
96275 eachSelfAssignment(left.argument, right.argument, props, report);
96276 } else if (left.type === "ObjectPattern" && right.type === "ObjectExpression" && right.properties.length >= 1) {
96277 /*
96278 * Gets the index of the last spread property.
96279 * It's possible to overwrite properties followed by it.
96280 */
96281 let startJ = 0;
96282
96283 for (let i = right.properties.length - 1; i >= 0; --i) {
96284 const propType = right.properties[i].type;
96285
96286 if (propType === "SpreadElement" || propType === "ExperimentalSpreadProperty") {
96287 startJ = i + 1;
96288 break;
96289 }
96290 }
96291
96292 for (let i = 0; i < left.properties.length; ++i) {
96293 for (let j = startJ; j < right.properties.length; ++j) {
96294 eachSelfAssignment(left.properties[i], right.properties[j], props, report);
96295 }
96296 }
96297 } else if (left.type === "Property" && right.type === "Property" && right.kind === "init" && !right.method) {
96298 const leftName = astUtils.getStaticPropertyName(left);
96299
96300 if (leftName !== null && leftName === astUtils.getStaticPropertyName(right)) {
96301 eachSelfAssignment(left.value, right.value, props, report);
96302 }
96303 } else if (props && astUtils.skipChainExpression(left).type === "MemberExpression" && astUtils.skipChainExpression(right).type === "MemberExpression" && astUtils.isSameReference(left, right)) {
96304 report(right);
96305 }
96306 } //------------------------------------------------------------------------------
96307 // Rule Definition
96308 //------------------------------------------------------------------------------
96309
96310
96311 module.exports = {
96312 meta: {
96313 type: "problem",
96314 docs: {
96315 description: "disallow assignments where both sides are exactly the same",
96316 recommended: true,
96317 url: "https://eslint.org/docs/rules/no-self-assign"
96318 },
96319 schema: [{
96320 type: "object",
96321 properties: {
96322 props: {
96323 type: "boolean",
96324 default: true
96325 }
96326 },
96327 additionalProperties: false
96328 }],
96329 messages: {
96330 selfAssignment: "'{{name}}' is assigned to itself."
96331 }
96332 },
96333
96334 create(context) {
96335 const sourceCode = context.getSourceCode();
96336 const [{
96337 props = true
96338 } = {}] = context.options;
96339 /**
96340 * Reports a given node as self assignments.
96341 * @param {ASTNode} node A node to report. This is an Identifier node.
96342 * @returns {void}
96343 */
96344
96345 function report(node) {
96346 context.report({
96347 node,
96348 messageId: "selfAssignment",
96349 data: {
96350 name: sourceCode.getText(node).replace(SPACES, "")
96351 }
96352 });
96353 }
96354
96355 return {
96356 AssignmentExpression(node) {
96357 if (node.operator === "=") {
96358 eachSelfAssignment(node.left, node.right, props, report);
96359 }
96360 }
96361
96362 };
96363 }
96364
96365 };
96366
96367 /***/ }),
96368 /* 745 */
96369 /***/ ((module) => {
96370
96371 "use strict";
96372 /**
96373 * @fileoverview Rule to flag comparison where left part is the same as the right
96374 * part.
96375 * @author Ilya Volodin
96376 */
96377 //------------------------------------------------------------------------------
96378 // Rule Definition
96379 //------------------------------------------------------------------------------
96380
96381 module.exports = {
96382 meta: {
96383 type: "problem",
96384 docs: {
96385 description: "disallow comparisons where both sides are exactly the same",
96386 recommended: false,
96387 url: "https://eslint.org/docs/rules/no-self-compare"
96388 },
96389 schema: [],
96390 messages: {
96391 comparingToSelf: "Comparing to itself is potentially pointless."
96392 }
96393 },
96394
96395 create(context) {
96396 const sourceCode = context.getSourceCode();
96397 /**
96398 * Determines whether two nodes are composed of the same tokens.
96399 * @param {ASTNode} nodeA The first node
96400 * @param {ASTNode} nodeB The second node
96401 * @returns {boolean} true if the nodes have identical token representations
96402 */
96403
96404 function hasSameTokens(nodeA, nodeB) {
96405 const tokensA = sourceCode.getTokens(nodeA);
96406 const tokensB = sourceCode.getTokens(nodeB);
96407 return tokensA.length === tokensB.length && tokensA.every((token, index) => token.type === tokensB[index].type && token.value === tokensB[index].value);
96408 }
96409
96410 return {
96411 BinaryExpression(node) {
96412 const operators = new Set(["===", "==", "!==", "!=", ">", "<", ">=", "<="]);
96413
96414 if (operators.has(node.operator) && hasSameTokens(node.left, node.right)) {
96415 context.report({
96416 node,
96417 messageId: "comparingToSelf"
96418 });
96419 }
96420 }
96421
96422 };
96423 }
96424
96425 };
96426
96427 /***/ }),
96428 /* 746 */
96429 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
96430
96431 "use strict";
96432 /**
96433 * @fileoverview Rule to flag use of comma operator
96434 * @author Brandon Mills
96435 */
96436 //------------------------------------------------------------------------------
96437 // Requirements
96438 //------------------------------------------------------------------------------
96439
96440 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
96441 // Helpers
96442 //------------------------------------------------------------------------------
96443
96444
96445 const DEFAULT_OPTIONS = {
96446 allowInParentheses: true
96447 }; //------------------------------------------------------------------------------
96448 // Rule Definition
96449 //------------------------------------------------------------------------------
96450
96451 module.exports = {
96452 meta: {
96453 type: "suggestion",
96454 docs: {
96455 description: "disallow comma operators",
96456 recommended: false,
96457 url: "https://eslint.org/docs/rules/no-sequences"
96458 },
96459 schema: [{
96460 properties: {
96461 allowInParentheses: {
96462 type: "boolean",
96463 default: true
96464 }
96465 },
96466 additionalProperties: false
96467 }],
96468 messages: {
96469 unexpectedCommaExpression: "Unexpected use of comma operator."
96470 }
96471 },
96472
96473 create(context) {
96474 const options = Object.assign({}, DEFAULT_OPTIONS, context.options[0]);
96475 const sourceCode = context.getSourceCode();
96476 /**
96477 * Parts of the grammar that are required to have parens.
96478 */
96479
96480 const parenthesized = {
96481 DoWhileStatement: "test",
96482 IfStatement: "test",
96483 SwitchStatement: "discriminant",
96484 WhileStatement: "test",
96485 WithStatement: "object",
96486 ArrowFunctionExpression: "body"
96487 /*
96488 * Omitting CallExpression - commas are parsed as argument separators
96489 * Omitting NewExpression - commas are parsed as argument separators
96490 * Omitting ForInStatement - parts aren't individually parenthesised
96491 * Omitting ForStatement - parts aren't individually parenthesised
96492 */
96493
96494 };
96495 /**
96496 * Determines whether a node is required by the grammar to be wrapped in
96497 * parens, e.g. the test of an if statement.
96498 * @param {ASTNode} node The AST node
96499 * @returns {boolean} True if parens around node belong to parent node.
96500 */
96501
96502 function requiresExtraParens(node) {
96503 return node.parent && parenthesized[node.parent.type] && node === node.parent[parenthesized[node.parent.type]];
96504 }
96505 /**
96506 * Check if a node is wrapped in parens.
96507 * @param {ASTNode} node The AST node
96508 * @returns {boolean} True if the node has a paren on each side.
96509 */
96510
96511
96512 function isParenthesised(node) {
96513 return astUtils.isParenthesised(sourceCode, node);
96514 }
96515 /**
96516 * Check if a node is wrapped in two levels of parens.
96517 * @param {ASTNode} node The AST node
96518 * @returns {boolean} True if two parens surround the node on each side.
96519 */
96520
96521
96522 function isParenthesisedTwice(node) {
96523 const previousToken = sourceCode.getTokenBefore(node, 1),
96524 nextToken = sourceCode.getTokenAfter(node, 1);
96525 return isParenthesised(node) && previousToken && nextToken && astUtils.isOpeningParenToken(previousToken) && previousToken.range[1] <= node.range[0] && astUtils.isClosingParenToken(nextToken) && nextToken.range[0] >= node.range[1];
96526 }
96527
96528 return {
96529 SequenceExpression(node) {
96530 // Always allow sequences in for statement update
96531 if (node.parent.type === "ForStatement" && (node === node.parent.init || node === node.parent.update)) {
96532 return;
96533 } // Wrapping a sequence in extra parens indicates intent
96534
96535
96536 if (options.allowInParentheses) {
96537 if (requiresExtraParens(node)) {
96538 if (isParenthesisedTwice(node)) {
96539 return;
96540 }
96541 } else {
96542 if (isParenthesised(node)) {
96543 return;
96544 }
96545 }
96546 }
96547
96548 const firstCommaToken = sourceCode.getTokenAfter(node.expressions[0], astUtils.isCommaToken);
96549 context.report({
96550 node,
96551 loc: firstCommaToken.loc,
96552 messageId: "unexpectedCommaExpression"
96553 });
96554 }
96555
96556 };
96557 }
96558
96559 };
96560
96561 /***/ }),
96562 /* 747 */
96563 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
96564
96565 "use strict";
96566 /**
96567 * @fileoverview Rule to disallow returning values from setters
96568 * @author Milos Djermanovic
96569 */
96570 //------------------------------------------------------------------------------
96571 // Requirements
96572 //------------------------------------------------------------------------------
96573
96574 const astUtils = __webpack_require__(548);
96575
96576 const {
96577 findVariable
96578 } = __webpack_require__(501); //------------------------------------------------------------------------------
96579 // Helpers
96580 //------------------------------------------------------------------------------
96581
96582 /**
96583 * Determines whether the given identifier node is a reference to a global variable.
96584 * @param {ASTNode} node `Identifier` node to check.
96585 * @param {Scope} scope Scope to which the node belongs.
96586 * @returns {boolean} True if the identifier is a reference to a global variable.
96587 */
96588
96589
96590 function isGlobalReference(node, scope) {
96591 const variable = findVariable(scope, node);
96592 return variable !== null && variable.scope.type === "global" && variable.defs.length === 0;
96593 }
96594 /**
96595 * Determines whether the given node is an argument of the specified global method call, at the given `index` position.
96596 * E.g., for given `index === 1`, this function checks for `objectName.methodName(foo, node)`, where objectName is a global variable.
96597 * @param {ASTNode} node The node to check.
96598 * @param {Scope} scope Scope to which the node belongs.
96599 * @param {string} objectName Name of the global object.
96600 * @param {string} methodName Name of the method.
96601 * @param {number} index The given position.
96602 * @returns {boolean} `true` if the node is argument at the given position.
96603 */
96604
96605
96606 function isArgumentOfGlobalMethodCall(node, scope, objectName, methodName, index) {
96607 const callNode = node.parent;
96608 return callNode.type === "CallExpression" && callNode.arguments[index] === node && astUtils.isSpecificMemberAccess(callNode.callee, objectName, methodName) && isGlobalReference(astUtils.skipChainExpression(callNode.callee).object, scope);
96609 }
96610 /**
96611 * Determines whether the given node is used as a property descriptor.
96612 * @param {ASTNode} node The node to check.
96613 * @param {Scope} scope Scope to which the node belongs.
96614 * @returns {boolean} `true` if the node is a property descriptor.
96615 */
96616
96617
96618 function isPropertyDescriptor(node, scope) {
96619 if (isArgumentOfGlobalMethodCall(node, scope, "Object", "defineProperty", 2) || isArgumentOfGlobalMethodCall(node, scope, "Reflect", "defineProperty", 2)) {
96620 return true;
96621 }
96622
96623 const parent = node.parent;
96624
96625 if (parent.type === "Property" && parent.value === node) {
96626 const grandparent = parent.parent;
96627
96628 if (grandparent.type === "ObjectExpression" && (isArgumentOfGlobalMethodCall(grandparent, scope, "Object", "create", 1) || isArgumentOfGlobalMethodCall(grandparent, scope, "Object", "defineProperties", 1))) {
96629 return true;
96630 }
96631 }
96632
96633 return false;
96634 }
96635 /**
96636 * Determines whether the given function node is used as a setter function.
96637 * @param {ASTNode} node The node to check.
96638 * @param {Scope} scope Scope to which the node belongs.
96639 * @returns {boolean} `true` if the node is a setter.
96640 */
96641
96642
96643 function isSetter(node, scope) {
96644 const parent = node.parent;
96645
96646 if ((parent.type === "Property" || parent.type === "MethodDefinition") && parent.kind === "set" && parent.value === node) {
96647 // Setter in an object literal or in a class
96648 return true;
96649 }
96650
96651 if (parent.type === "Property" && parent.value === node && astUtils.getStaticPropertyName(parent) === "set" && parent.parent.type === "ObjectExpression" && isPropertyDescriptor(parent.parent, scope)) {
96652 // Setter in a property descriptor
96653 return true;
96654 }
96655
96656 return false;
96657 }
96658 /**
96659 * Finds function's outer scope.
96660 * @param {Scope} scope Function's own scope.
96661 * @returns {Scope} Function's outer scope.
96662 */
96663
96664
96665 function getOuterScope(scope) {
96666 const upper = scope.upper;
96667
96668 if (upper.type === "function-expression-name") {
96669 return upper.upper;
96670 }
96671
96672 return upper;
96673 } //------------------------------------------------------------------------------
96674 // Rule Definition
96675 //------------------------------------------------------------------------------
96676
96677
96678 module.exports = {
96679 meta: {
96680 type: "problem",
96681 docs: {
96682 description: "disallow returning values from setters",
96683 recommended: true,
96684 url: "https://eslint.org/docs/rules/no-setter-return"
96685 },
96686 schema: [],
96687 messages: {
96688 returnsValue: "Setter cannot return a value."
96689 }
96690 },
96691
96692 create(context) {
96693 let funcInfo = null;
96694 /**
96695 * Creates and pushes to the stack a function info object for the given function node.
96696 * @param {ASTNode} node The function node.
96697 * @returns {void}
96698 */
96699
96700 function enterFunction(node) {
96701 const outerScope = getOuterScope(context.getScope());
96702 funcInfo = {
96703 upper: funcInfo,
96704 isSetter: isSetter(node, outerScope)
96705 };
96706 }
96707 /**
96708 * Pops the current function info object from the stack.
96709 * @returns {void}
96710 */
96711
96712
96713 function exitFunction() {
96714 funcInfo = funcInfo.upper;
96715 }
96716 /**
96717 * Reports the given node.
96718 * @param {ASTNode} node Node to report.
96719 * @returns {void}
96720 */
96721
96722
96723 function report(node) {
96724 context.report({
96725 node,
96726 messageId: "returnsValue"
96727 });
96728 }
96729
96730 return {
96731 /*
96732 * Function declarations cannot be setters, but we still have to track them in the `funcInfo` stack to avoid
96733 * false positives, because a ReturnStatement node can belong to a function declaration inside a setter.
96734 *
96735 * Note: A previously declared function can be referenced and actually used as a setter in a property descriptor,
96736 * but that's out of scope for this rule.
96737 */
96738 FunctionDeclaration: enterFunction,
96739 FunctionExpression: enterFunction,
96740
96741 ArrowFunctionExpression(node) {
96742 enterFunction(node);
96743
96744 if (funcInfo.isSetter && node.expression) {
96745 // { set: foo => bar } property descriptor. Report implicit return 'bar' as the equivalent for a return statement.
96746 report(node.body);
96747 }
96748 },
96749
96750 "FunctionDeclaration:exit": exitFunction,
96751 "FunctionExpression:exit": exitFunction,
96752 "ArrowFunctionExpression:exit": exitFunction,
96753
96754 ReturnStatement(node) {
96755 // Global returns (e.g., at the top level of a Node module) don't have `funcInfo`.
96756 if (funcInfo && funcInfo.isSetter && node.argument) {
96757 report(node);
96758 }
96759 }
96760
96761 };
96762 }
96763
96764 };
96765
96766 /***/ }),
96767 /* 748 */
96768 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
96769
96770 "use strict";
96771 /**
96772 * @fileoverview Rule to flag on declaring variables already declared in the outer scope
96773 * @author Ilya Volodin
96774 */
96775 //------------------------------------------------------------------------------
96776 // Requirements
96777 //------------------------------------------------------------------------------
96778
96779 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
96780 // Rule Definition
96781 //------------------------------------------------------------------------------
96782
96783
96784 module.exports = {
96785 meta: {
96786 type: "suggestion",
96787 docs: {
96788 description: "disallow variable declarations from shadowing variables declared in the outer scope",
96789 recommended: false,
96790 url: "https://eslint.org/docs/rules/no-shadow"
96791 },
96792 schema: [{
96793 type: "object",
96794 properties: {
96795 builtinGlobals: {
96796 type: "boolean",
96797 default: false
96798 },
96799 hoist: {
96800 enum: ["all", "functions", "never"],
96801 default: "functions"
96802 },
96803 allow: {
96804 type: "array",
96805 items: {
96806 type: "string"
96807 }
96808 }
96809 },
96810 additionalProperties: false
96811 }],
96812 messages: {
96813 noShadow: "'{{name}}' is already declared in the upper scope on line {{shadowedLine}} column {{shadowedColumn}}.",
96814 noShadowGlobal: "'{{name}}' is already a global variable."
96815 }
96816 },
96817
96818 create(context) {
96819 const options = {
96820 builtinGlobals: context.options[0] && context.options[0].builtinGlobals,
96821 hoist: context.options[0] && context.options[0].hoist || "functions",
96822 allow: context.options[0] && context.options[0].allow || []
96823 };
96824 /**
96825 * Check if variable name is allowed.
96826 * @param {ASTNode} variable The variable to check.
96827 * @returns {boolean} Whether or not the variable name is allowed.
96828 */
96829
96830 function isAllowed(variable) {
96831 return options.allow.indexOf(variable.name) !== -1;
96832 }
96833 /**
96834 * Checks if a variable of the class name in the class scope of ClassDeclaration.
96835 *
96836 * ClassDeclaration creates two variables of its name into its outer scope and its class scope.
96837 * So we should ignore the variable in the class scope.
96838 * @param {Object} variable The variable to check.
96839 * @returns {boolean} Whether or not the variable of the class name in the class scope of ClassDeclaration.
96840 */
96841
96842
96843 function isDuplicatedClassNameVariable(variable) {
96844 const block = variable.scope.block;
96845 return block.type === "ClassDeclaration" && block.id === variable.identifiers[0];
96846 }
96847 /**
96848 * Checks if a variable is inside the initializer of scopeVar.
96849 *
96850 * To avoid reporting at declarations such as `var a = function a() {};`.
96851 * But it should report `var a = function(a) {};` or `var a = function() { function a() {} };`.
96852 * @param {Object} variable The variable to check.
96853 * @param {Object} scopeVar The scope variable to look for.
96854 * @returns {boolean} Whether or not the variable is inside initializer of scopeVar.
96855 */
96856
96857
96858 function isOnInitializer(variable, scopeVar) {
96859 const outerScope = scopeVar.scope;
96860 const outerDef = scopeVar.defs[0];
96861 const outer = outerDef && outerDef.parent && outerDef.parent.range;
96862 const innerScope = variable.scope;
96863 const innerDef = variable.defs[0];
96864 const inner = innerDef && innerDef.name.range;
96865 return outer && inner && outer[0] < inner[0] && inner[1] < outer[1] && (innerDef.type === "FunctionName" && innerDef.node.type === "FunctionExpression" || innerDef.node.type === "ClassExpression") && outerScope === innerScope.upper;
96866 }
96867 /**
96868 * Get a range of a variable's identifier node.
96869 * @param {Object} variable The variable to get.
96870 * @returns {Array|undefined} The range of the variable's identifier node.
96871 */
96872
96873
96874 function getNameRange(variable) {
96875 const def = variable.defs[0];
96876 return def && def.name.range;
96877 }
96878 /**
96879 * Get declared line and column of a variable.
96880 * @param {eslint-scope.Variable} variable The variable to get.
96881 * @returns {Object} The declared line and column of the variable.
96882 */
96883
96884
96885 function getDeclaredLocation(variable) {
96886 const identifier = variable.identifiers[0];
96887 let obj;
96888
96889 if (identifier) {
96890 obj = {
96891 global: false,
96892 line: identifier.loc.start.line,
96893 column: identifier.loc.start.column + 1
96894 };
96895 } else {
96896 obj = {
96897 global: true
96898 };
96899 }
96900
96901 return obj;
96902 }
96903 /**
96904 * Checks if a variable is in TDZ of scopeVar.
96905 * @param {Object} variable The variable to check.
96906 * @param {Object} scopeVar The variable of TDZ.
96907 * @returns {boolean} Whether or not the variable is in TDZ of scopeVar.
96908 */
96909
96910
96911 function isInTdz(variable, scopeVar) {
96912 const outerDef = scopeVar.defs[0];
96913 const inner = getNameRange(variable);
96914 const outer = getNameRange(scopeVar);
96915 return inner && outer && inner[1] < outer[0] && ( // Excepts FunctionDeclaration if is {"hoist":"function"}.
96916 options.hoist !== "functions" || !outerDef || outerDef.node.type !== "FunctionDeclaration");
96917 }
96918 /**
96919 * Checks the current context for shadowed variables.
96920 * @param {Scope} scope Fixme
96921 * @returns {void}
96922 */
96923
96924
96925 function checkForShadows(scope) {
96926 const variables = scope.variables;
96927
96928 for (let i = 0; i < variables.length; ++i) {
96929 const variable = variables[i]; // Skips "arguments" or variables of a class name in the class scope of ClassDeclaration.
96930
96931 if (variable.identifiers.length === 0 || isDuplicatedClassNameVariable(variable) || isAllowed(variable)) {
96932 continue;
96933 } // Gets shadowed variable.
96934
96935
96936 const shadowed = astUtils.getVariableByName(scope.upper, variable.name);
96937
96938 if (shadowed && (shadowed.identifiers.length > 0 || options.builtinGlobals && "writeable" in shadowed) && !isOnInitializer(variable, shadowed) && !(options.hoist !== "all" && isInTdz(variable, shadowed))) {
96939 const location = getDeclaredLocation(shadowed);
96940 const messageId = location.global ? "noShadowGlobal" : "noShadow";
96941 const data = {
96942 name: variable.name
96943 };
96944
96945 if (!location.global) {
96946 data.shadowedLine = location.line;
96947 data.shadowedColumn = location.column;
96948 }
96949
96950 context.report({
96951 node: variable.identifiers[0],
96952 messageId,
96953 data
96954 });
96955 }
96956 }
96957 }
96958
96959 return {
96960 "Program:exit"() {
96961 const globalScope = context.getScope();
96962 const stack = globalScope.childScopes.slice();
96963
96964 while (stack.length) {
96965 const scope = stack.pop();
96966 stack.push(...scope.childScopes);
96967 checkForShadows(scope);
96968 }
96969 }
96970
96971 };
96972 }
96973
96974 };
96975
96976 /***/ }),
96977 /* 749 */
96978 /***/ ((module) => {
96979
96980 "use strict";
96981 /**
96982 * @fileoverview Disallow shadowing of NaN, undefined, and Infinity (ES5 section 15.1.1)
96983 * @author Michael Ficarra
96984 */
96985
96986 /**
96987 * Determines if a variable safely shadows undefined.
96988 * This is the case when a variable named `undefined` is never assigned to a value (i.e. it always shares the same value
96989 * as the global).
96990 * @param {eslintScope.Variable} variable The variable to check
96991 * @returns {boolean} true if this variable safely shadows `undefined`
96992 */
96993
96994 function safelyShadowsUndefined(variable) {
96995 return variable.name === "undefined" && variable.references.every(ref => !ref.isWrite()) && variable.defs.every(def => def.node.type === "VariableDeclarator" && def.node.init === null);
96996 } //------------------------------------------------------------------------------
96997 // Rule Definition
96998 //------------------------------------------------------------------------------
96999
97000
97001 module.exports = {
97002 meta: {
97003 type: "suggestion",
97004 docs: {
97005 description: "disallow identifiers from shadowing restricted names",
97006 recommended: true,
97007 url: "https://eslint.org/docs/rules/no-shadow-restricted-names"
97008 },
97009 schema: [],
97010 messages: {
97011 shadowingRestrictedName: "Shadowing of global property '{{name}}'."
97012 }
97013 },
97014
97015 create(context) {
97016 const RESTRICTED = new Set(["undefined", "NaN", "Infinity", "arguments", "eval"]);
97017 return {
97018 "VariableDeclaration, :function, CatchClause"(node) {
97019 for (const variable of context.getDeclaredVariables(node)) {
97020 if (variable.defs.length > 0 && RESTRICTED.has(variable.name) && !safelyShadowsUndefined(variable)) {
97021 context.report({
97022 node: variable.defs[0].name,
97023 messageId: "shadowingRestrictedName",
97024 data: {
97025 name: variable.name
97026 }
97027 });
97028 }
97029 }
97030 }
97031
97032 };
97033 }
97034
97035 };
97036
97037 /***/ }),
97038 /* 750 */
97039 /***/ ((module) => {
97040
97041 "use strict";
97042 /**
97043 * @fileoverview Rule to check that spaced function application
97044 * @author Matt DuVall <http://www.mattduvall.com>
97045 * @deprecated in ESLint v3.3.0
97046 */
97047 //------------------------------------------------------------------------------
97048 // Rule Definition
97049 //------------------------------------------------------------------------------
97050
97051 module.exports = {
97052 meta: {
97053 type: "layout",
97054 docs: {
97055 description: "disallow spacing between function identifiers and their applications (deprecated)",
97056 recommended: false,
97057 url: "https://eslint.org/docs/rules/no-spaced-func"
97058 },
97059 deprecated: true,
97060 replacedBy: ["func-call-spacing"],
97061 fixable: "whitespace",
97062 schema: [],
97063 messages: {
97064 noSpacedFunction: "Unexpected space between function name and paren."
97065 }
97066 },
97067
97068 create(context) {
97069 const sourceCode = context.getSourceCode();
97070 /**
97071 * Check if open space is present in a function name
97072 * @param {ASTNode} node node to evaluate
97073 * @returns {void}
97074 * @private
97075 */
97076
97077 function detectOpenSpaces(node) {
97078 const lastCalleeToken = sourceCode.getLastToken(node.callee);
97079 let prevToken = lastCalleeToken,
97080 parenToken = sourceCode.getTokenAfter(lastCalleeToken); // advances to an open parenthesis.
97081
97082 while (parenToken && parenToken.range[1] < node.range[1] && parenToken.value !== "(") {
97083 prevToken = parenToken;
97084 parenToken = sourceCode.getTokenAfter(parenToken);
97085 } // look for a space between the callee and the open paren
97086
97087
97088 if (parenToken && parenToken.range[1] < node.range[1] && sourceCode.isSpaceBetweenTokens(prevToken, parenToken)) {
97089 context.report({
97090 node,
97091 loc: lastCalleeToken.loc.start,
97092 messageId: "noSpacedFunction",
97093
97094 fix(fixer) {
97095 return fixer.removeRange([prevToken.range[1], parenToken.range[0]]);
97096 }
97097
97098 });
97099 }
97100 }
97101
97102 return {
97103 CallExpression: detectOpenSpaces,
97104 NewExpression: detectOpenSpaces
97105 };
97106 }
97107
97108 };
97109
97110 /***/ }),
97111 /* 751 */
97112 /***/ ((module) => {
97113
97114 "use strict";
97115 /**
97116 * @fileoverview Disallow sparse arrays
97117 * @author Nicholas C. Zakas
97118 */
97119 //------------------------------------------------------------------------------
97120 // Rule Definition
97121 //------------------------------------------------------------------------------
97122
97123 module.exports = {
97124 meta: {
97125 type: "problem",
97126 docs: {
97127 description: "disallow sparse arrays",
97128 recommended: true,
97129 url: "https://eslint.org/docs/rules/no-sparse-arrays"
97130 },
97131 schema: [],
97132 messages: {
97133 unexpectedSparseArray: "Unexpected comma in middle of array."
97134 }
97135 },
97136
97137 create(context) {
97138 //--------------------------------------------------------------------------
97139 // Public
97140 //--------------------------------------------------------------------------
97141 return {
97142 ArrayExpression(node) {
97143 const emptySpot = node.elements.indexOf(null) > -1;
97144
97145 if (emptySpot) {
97146 context.report({
97147 node,
97148 messageId: "unexpectedSparseArray"
97149 });
97150 }
97151 }
97152
97153 };
97154 }
97155
97156 };
97157
97158 /***/ }),
97159 /* 752 */
97160 /***/ ((module) => {
97161
97162 "use strict";
97163 /**
97164 * @fileoverview Rule to check for properties whose identifier ends with the string Sync
97165 * @author Matt DuVall<http://mattduvall.com/>
97166 * @deprecated in ESLint v7.0.0
97167 */
97168 //------------------------------------------------------------------------------
97169 // Rule Definition
97170 //------------------------------------------------------------------------------
97171
97172 module.exports = {
97173 meta: {
97174 deprecated: true,
97175 replacedBy: [],
97176 type: "suggestion",
97177 docs: {
97178 description: "disallow synchronous methods",
97179 recommended: false,
97180 url: "https://eslint.org/docs/rules/no-sync"
97181 },
97182 schema: [{
97183 type: "object",
97184 properties: {
97185 allowAtRootLevel: {
97186 type: "boolean",
97187 default: false
97188 }
97189 },
97190 additionalProperties: false
97191 }],
97192 messages: {
97193 noSync: "Unexpected sync method: '{{propertyName}}'."
97194 }
97195 },
97196
97197 create(context) {
97198 const selector = context.options[0] && context.options[0].allowAtRootLevel ? ":function MemberExpression[property.name=/.*Sync$/]" : "MemberExpression[property.name=/.*Sync$/]";
97199 return {
97200 [selector](node) {
97201 context.report({
97202 node,
97203 messageId: "noSync",
97204 data: {
97205 propertyName: node.property.name
97206 }
97207 });
97208 }
97209
97210 };
97211 }
97212
97213 };
97214
97215 /***/ }),
97216 /* 753 */
97217 /***/ ((module) => {
97218
97219 "use strict";
97220 /**
97221 * @fileoverview Rule to check for tabs inside a file
97222 * @author Gyandeep Singh
97223 */
97224 //------------------------------------------------------------------------------
97225 // Helpers
97226 //------------------------------------------------------------------------------
97227
97228 const tabRegex = /\t+/gu;
97229 const anyNonWhitespaceRegex = /\S/u; //------------------------------------------------------------------------------
97230 // Public Interface
97231 //------------------------------------------------------------------------------
97232
97233 module.exports = {
97234 meta: {
97235 type: "layout",
97236 docs: {
97237 description: "disallow all tabs",
97238 recommended: false,
97239 url: "https://eslint.org/docs/rules/no-tabs"
97240 },
97241 schema: [{
97242 type: "object",
97243 properties: {
97244 allowIndentationTabs: {
97245 type: "boolean",
97246 default: false
97247 }
97248 },
97249 additionalProperties: false
97250 }],
97251 messages: {
97252 unexpectedTab: "Unexpected tab character."
97253 }
97254 },
97255
97256 create(context) {
97257 const sourceCode = context.getSourceCode();
97258 const allowIndentationTabs = context.options && context.options[0] && context.options[0].allowIndentationTabs;
97259 return {
97260 Program(node) {
97261 sourceCode.getLines().forEach((line, index) => {
97262 let match;
97263
97264 while ((match = tabRegex.exec(line)) !== null) {
97265 if (allowIndentationTabs && !anyNonWhitespaceRegex.test(line.slice(0, match.index))) {
97266 continue;
97267 }
97268
97269 context.report({
97270 node,
97271 loc: {
97272 start: {
97273 line: index + 1,
97274 column: match.index
97275 },
97276 end: {
97277 line: index + 1,
97278 column: match.index + match[0].length
97279 }
97280 },
97281 messageId: "unexpectedTab"
97282 });
97283 }
97284 });
97285 }
97286
97287 };
97288 }
97289
97290 };
97291
97292 /***/ }),
97293 /* 754 */
97294 /***/ ((module) => {
97295
97296 "use strict";
97297 /**
97298 * @fileoverview Warn when using template string syntax in regular strings
97299 * @author Jeroen Engels
97300 */
97301 //------------------------------------------------------------------------------
97302 // Rule Definition
97303 //------------------------------------------------------------------------------
97304
97305 module.exports = {
97306 meta: {
97307 type: "problem",
97308 docs: {
97309 description: "disallow template literal placeholder syntax in regular strings",
97310 recommended: false,
97311 url: "https://eslint.org/docs/rules/no-template-curly-in-string"
97312 },
97313 schema: [],
97314 messages: {
97315 unexpectedTemplateExpression: "Unexpected template string expression."
97316 }
97317 },
97318
97319 create(context) {
97320 const regex = /\$\{[^}]+\}/u;
97321 return {
97322 Literal(node) {
97323 if (typeof node.value === "string" && regex.test(node.value)) {
97324 context.report({
97325 node,
97326 messageId: "unexpectedTemplateExpression"
97327 });
97328 }
97329 }
97330
97331 };
97332 }
97333
97334 };
97335
97336 /***/ }),
97337 /* 755 */
97338 /***/ ((module) => {
97339
97340 "use strict";
97341 /**
97342 * @fileoverview Rule to flag use of ternary operators.
97343 * @author Ian Christian Myers
97344 */
97345 //------------------------------------------------------------------------------
97346 // Rule Definition
97347 //------------------------------------------------------------------------------
97348
97349 module.exports = {
97350 meta: {
97351 type: "suggestion",
97352 docs: {
97353 description: "disallow ternary operators",
97354 recommended: false,
97355 url: "https://eslint.org/docs/rules/no-ternary"
97356 },
97357 schema: [],
97358 messages: {
97359 noTernaryOperator: "Ternary operator used."
97360 }
97361 },
97362
97363 create(context) {
97364 return {
97365 ConditionalExpression(node) {
97366 context.report({
97367 node,
97368 messageId: "noTernaryOperator"
97369 });
97370 }
97371
97372 };
97373 }
97374
97375 };
97376
97377 /***/ }),
97378 /* 756 */
97379 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
97380
97381 "use strict";
97382 /**
97383 * @fileoverview A rule to disallow using `this`/`super` before `super()`.
97384 * @author Toru Nagashima
97385 */
97386 //------------------------------------------------------------------------------
97387 // Requirements
97388 //------------------------------------------------------------------------------
97389
97390 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
97391 // Helpers
97392 //------------------------------------------------------------------------------
97393
97394 /**
97395 * Checks whether or not a given node is a constructor.
97396 * @param {ASTNode} node A node to check. This node type is one of
97397 * `Program`, `FunctionDeclaration`, `FunctionExpression`, and
97398 * `ArrowFunctionExpression`.
97399 * @returns {boolean} `true` if the node is a constructor.
97400 */
97401
97402
97403 function isConstructorFunction(node) {
97404 return node.type === "FunctionExpression" && node.parent.type === "MethodDefinition" && node.parent.kind === "constructor";
97405 } //------------------------------------------------------------------------------
97406 // Rule Definition
97407 //------------------------------------------------------------------------------
97408
97409
97410 module.exports = {
97411 meta: {
97412 type: "problem",
97413 docs: {
97414 description: "disallow `this`/`super` before calling `super()` in constructors",
97415 recommended: true,
97416 url: "https://eslint.org/docs/rules/no-this-before-super"
97417 },
97418 schema: [],
97419 messages: {
97420 noBeforeSuper: "'{{kind}}' is not allowed before 'super()'."
97421 }
97422 },
97423
97424 create(context) {
97425 /*
97426 * Information for each constructor.
97427 * - upper: Information of the upper constructor.
97428 * - hasExtends: A flag which shows whether the owner class has a valid
97429 * `extends` part.
97430 * - scope: The scope of the owner class.
97431 * - codePath: The code path of this constructor.
97432 */
97433 let funcInfo = null;
97434 /*
97435 * Information for each code path segment.
97436 * Each key is the id of a code path segment.
97437 * Each value is an object:
97438 * - superCalled: The flag which shows `super()` called in all code paths.
97439 * - invalidNodes: The array of invalid ThisExpression and Super nodes.
97440 */
97441
97442 let segInfoMap = Object.create(null);
97443 /**
97444 * Gets whether or not `super()` is called in a given code path segment.
97445 * @param {CodePathSegment} segment A code path segment to get.
97446 * @returns {boolean} `true` if `super()` is called.
97447 */
97448
97449 function isCalled(segment) {
97450 return !segment.reachable || segInfoMap[segment.id].superCalled;
97451 }
97452 /**
97453 * Checks whether or not this is in a constructor.
97454 * @returns {boolean} `true` if this is in a constructor.
97455 */
97456
97457
97458 function isInConstructorOfDerivedClass() {
97459 return Boolean(funcInfo && funcInfo.isConstructor && funcInfo.hasExtends);
97460 }
97461 /**
97462 * Checks whether or not this is before `super()` is called.
97463 * @returns {boolean} `true` if this is before `super()` is called.
97464 */
97465
97466
97467 function isBeforeCallOfSuper() {
97468 return isInConstructorOfDerivedClass() && !funcInfo.codePath.currentSegments.every(isCalled);
97469 }
97470 /**
97471 * Sets a given node as invalid.
97472 * @param {ASTNode} node A node to set as invalid. This is one of
97473 * a ThisExpression and a Super.
97474 * @returns {void}
97475 */
97476
97477
97478 function setInvalid(node) {
97479 const segments = funcInfo.codePath.currentSegments;
97480
97481 for (let i = 0; i < segments.length; ++i) {
97482 const segment = segments[i];
97483
97484 if (segment.reachable) {
97485 segInfoMap[segment.id].invalidNodes.push(node);
97486 }
97487 }
97488 }
97489 /**
97490 * Sets the current segment as `super` was called.
97491 * @returns {void}
97492 */
97493
97494
97495 function setSuperCalled() {
97496 const segments = funcInfo.codePath.currentSegments;
97497
97498 for (let i = 0; i < segments.length; ++i) {
97499 const segment = segments[i];
97500
97501 if (segment.reachable) {
97502 segInfoMap[segment.id].superCalled = true;
97503 }
97504 }
97505 }
97506
97507 return {
97508 /**
97509 * Adds information of a constructor into the stack.
97510 * @param {CodePath} codePath A code path which was started.
97511 * @param {ASTNode} node The current node.
97512 * @returns {void}
97513 */
97514 onCodePathStart(codePath, node) {
97515 if (isConstructorFunction(node)) {
97516 // Class > ClassBody > MethodDefinition > FunctionExpression
97517 const classNode = node.parent.parent.parent;
97518 funcInfo = {
97519 upper: funcInfo,
97520 isConstructor: true,
97521 hasExtends: Boolean(classNode.superClass && !astUtils.isNullOrUndefined(classNode.superClass)),
97522 codePath
97523 };
97524 } else {
97525 funcInfo = {
97526 upper: funcInfo,
97527 isConstructor: false,
97528 hasExtends: false,
97529 codePath
97530 };
97531 }
97532 },
97533
97534 /**
97535 * Removes the top of stack item.
97536 *
97537 * And this traverses all segments of this code path then reports every
97538 * invalid node.
97539 * @param {CodePath} codePath A code path which was ended.
97540 * @returns {void}
97541 */
97542 onCodePathEnd(codePath) {
97543 const isDerivedClass = funcInfo.hasExtends;
97544 funcInfo = funcInfo.upper;
97545
97546 if (!isDerivedClass) {
97547 return;
97548 }
97549
97550 codePath.traverseSegments((segment, controller) => {
97551 const info = segInfoMap[segment.id];
97552
97553 for (let i = 0; i < info.invalidNodes.length; ++i) {
97554 const invalidNode = info.invalidNodes[i];
97555 context.report({
97556 messageId: "noBeforeSuper",
97557 node: invalidNode,
97558 data: {
97559 kind: invalidNode.type === "Super" ? "super" : "this"
97560 }
97561 });
97562 }
97563
97564 if (info.superCalled) {
97565 controller.skip();
97566 }
97567 });
97568 },
97569
97570 /**
97571 * Initialize information of a given code path segment.
97572 * @param {CodePathSegment} segment A code path segment to initialize.
97573 * @returns {void}
97574 */
97575 onCodePathSegmentStart(segment) {
97576 if (!isInConstructorOfDerivedClass()) {
97577 return;
97578 } // Initialize info.
97579
97580
97581 segInfoMap[segment.id] = {
97582 superCalled: segment.prevSegments.length > 0 && segment.prevSegments.every(isCalled),
97583 invalidNodes: []
97584 };
97585 },
97586
97587 /**
97588 * Update information of the code path segment when a code path was
97589 * looped.
97590 * @param {CodePathSegment} fromSegment The code path segment of the
97591 * end of a loop.
97592 * @param {CodePathSegment} toSegment A code path segment of the head
97593 * of a loop.
97594 * @returns {void}
97595 */
97596 onCodePathSegmentLoop(fromSegment, toSegment) {
97597 if (!isInConstructorOfDerivedClass()) {
97598 return;
97599 } // Update information inside of the loop.
97600
97601
97602 funcInfo.codePath.traverseSegments({
97603 first: toSegment,
97604 last: fromSegment
97605 }, (segment, controller) => {
97606 const info = segInfoMap[segment.id];
97607
97608 if (info.superCalled) {
97609 info.invalidNodes = [];
97610 controller.skip();
97611 } else if (segment.prevSegments.length > 0 && segment.prevSegments.every(isCalled)) {
97612 info.superCalled = true;
97613 info.invalidNodes = [];
97614 }
97615 });
97616 },
97617
97618 /**
97619 * Reports if this is before `super()`.
97620 * @param {ASTNode} node A target node.
97621 * @returns {void}
97622 */
97623 ThisExpression(node) {
97624 if (isBeforeCallOfSuper()) {
97625 setInvalid(node);
97626 }
97627 },
97628
97629 /**
97630 * Reports if this is before `super()`.
97631 * @param {ASTNode} node A target node.
97632 * @returns {void}
97633 */
97634 Super(node) {
97635 if (!astUtils.isCallee(node) && isBeforeCallOfSuper()) {
97636 setInvalid(node);
97637 }
97638 },
97639
97640 /**
97641 * Marks `super()` called.
97642 * @param {ASTNode} node A target node.
97643 * @returns {void}
97644 */
97645 "CallExpression:exit"(node) {
97646 if (node.callee.type === "Super" && isBeforeCallOfSuper()) {
97647 setSuperCalled();
97648 }
97649 },
97650
97651 /**
97652 * Resets state.
97653 * @returns {void}
97654 */
97655 "Program:exit"() {
97656 segInfoMap = Object.create(null);
97657 }
97658
97659 };
97660 }
97661
97662 };
97663
97664 /***/ }),
97665 /* 757 */
97666 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
97667
97668 "use strict";
97669 /**
97670 * @fileoverview Rule to restrict what can be thrown as an exception.
97671 * @author Dieter Oberkofler
97672 */
97673
97674
97675 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
97676 // Rule Definition
97677 //------------------------------------------------------------------------------
97678
97679
97680 module.exports = {
97681 meta: {
97682 type: "suggestion",
97683 docs: {
97684 description: "disallow throwing literals as exceptions",
97685 recommended: false,
97686 url: "https://eslint.org/docs/rules/no-throw-literal"
97687 },
97688 schema: [],
97689 messages: {
97690 object: "Expected an error object to be thrown.",
97691 undef: "Do not throw undefined."
97692 }
97693 },
97694
97695 create(context) {
97696 return {
97697 ThrowStatement(node) {
97698 if (!astUtils.couldBeError(node.argument)) {
97699 context.report({
97700 node,
97701 messageId: "object"
97702 });
97703 } else if (node.argument.type === "Identifier") {
97704 if (node.argument.name === "undefined") {
97705 context.report({
97706 node,
97707 messageId: "undef"
97708 });
97709 }
97710 }
97711 }
97712
97713 };
97714 }
97715
97716 };
97717
97718 /***/ }),
97719 /* 758 */
97720 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
97721
97722 "use strict";
97723 /**
97724 * @fileoverview Disallow trailing spaces at the end of lines.
97725 * @author Nodeca Team <https://github.com/nodeca>
97726 */
97727 //------------------------------------------------------------------------------
97728 // Requirements
97729 //------------------------------------------------------------------------------
97730
97731 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
97732 // Rule Definition
97733 //------------------------------------------------------------------------------
97734
97735
97736 module.exports = {
97737 meta: {
97738 type: "layout",
97739 docs: {
97740 description: "disallow trailing whitespace at the end of lines",
97741 recommended: false,
97742 url: "https://eslint.org/docs/rules/no-trailing-spaces"
97743 },
97744 fixable: "whitespace",
97745 schema: [{
97746 type: "object",
97747 properties: {
97748 skipBlankLines: {
97749 type: "boolean",
97750 default: false
97751 },
97752 ignoreComments: {
97753 type: "boolean",
97754 default: false
97755 }
97756 },
97757 additionalProperties: false
97758 }],
97759 messages: {
97760 trailingSpace: "Trailing spaces not allowed."
97761 }
97762 },
97763
97764 create(context) {
97765 const sourceCode = context.getSourceCode();
97766 const BLANK_CLASS = "[ \t\u00a0\u2000-\u200b\u3000]",
97767 SKIP_BLANK = "^".concat(BLANK_CLASS, "*$"),
97768 NONBLANK = "".concat(BLANK_CLASS, "+$");
97769 const options = context.options[0] || {},
97770 skipBlankLines = options.skipBlankLines || false,
97771 ignoreComments = options.ignoreComments || false;
97772 /**
97773 * Report the error message
97774 * @param {ASTNode} node node to report
97775 * @param {int[]} location range information
97776 * @param {int[]} fixRange Range based on the whole program
97777 * @returns {void}
97778 */
97779
97780 function report(node, location, fixRange) {
97781 /*
97782 * Passing node is a bit dirty, because message data will contain big
97783 * text in `source`. But... who cares :) ?
97784 * One more kludge will not make worse the bloody wizardry of this
97785 * plugin.
97786 */
97787 context.report({
97788 node,
97789 loc: location,
97790 messageId: "trailingSpace",
97791
97792 fix(fixer) {
97793 return fixer.removeRange(fixRange);
97794 }
97795
97796 });
97797 }
97798 /**
97799 * Given a list of comment nodes, return the line numbers for those comments.
97800 * @param {Array} comments An array of comment nodes.
97801 * @returns {number[]} An array of line numbers containing comments.
97802 */
97803
97804
97805 function getCommentLineNumbers(comments) {
97806 const lines = new Set();
97807 comments.forEach(comment => {
97808 const endLine = comment.type === "Block" ? comment.loc.end.line - 1 : comment.loc.end.line;
97809
97810 for (let i = comment.loc.start.line; i <= endLine; i++) {
97811 lines.add(i);
97812 }
97813 });
97814 return lines;
97815 } //--------------------------------------------------------------------------
97816 // Public
97817 //--------------------------------------------------------------------------
97818
97819
97820 return {
97821 Program: function checkTrailingSpaces(node) {
97822 /*
97823 * Let's hack. Since Espree does not return whitespace nodes,
97824 * fetch the source code and do matching via regexps.
97825 */
97826 const re = new RegExp(NONBLANK, "u"),
97827 skipMatch = new RegExp(SKIP_BLANK, "u"),
97828 lines = sourceCode.lines,
97829 linebreaks = sourceCode.getText().match(astUtils.createGlobalLinebreakMatcher()),
97830 comments = sourceCode.getAllComments(),
97831 commentLineNumbers = getCommentLineNumbers(comments);
97832 let totalLength = 0,
97833 fixRange = [];
97834
97835 for (let i = 0, ii = lines.length; i < ii; i++) {
97836 const lineNumber = i + 1;
97837 /*
97838 * Always add linebreak length to line length to accommodate for line break (\n or \r\n)
97839 * Because during the fix time they also reserve one spot in the array.
97840 * Usually linebreak length is 2 for \r\n (CRLF) and 1 for \n (LF)
97841 */
97842
97843 const linebreakLength = linebreaks && linebreaks[i] ? linebreaks[i].length : 1;
97844 const lineLength = lines[i].length + linebreakLength;
97845 const matches = re.exec(lines[i]);
97846
97847 if (matches) {
97848 const location = {
97849 start: {
97850 line: lineNumber,
97851 column: matches.index
97852 },
97853 end: {
97854 line: lineNumber,
97855 column: lineLength - linebreakLength
97856 }
97857 };
97858 const rangeStart = totalLength + location.start.column;
97859 const rangeEnd = totalLength + location.end.column;
97860 const containingNode = sourceCode.getNodeByRangeIndex(rangeStart);
97861
97862 if (containingNode && containingNode.type === "TemplateElement" && rangeStart > containingNode.parent.range[0] && rangeEnd < containingNode.parent.range[1]) {
97863 totalLength += lineLength;
97864 continue;
97865 }
97866 /*
97867 * If the line has only whitespace, and skipBlankLines
97868 * is true, don't report it
97869 */
97870
97871
97872 if (skipBlankLines && skipMatch.test(lines[i])) {
97873 totalLength += lineLength;
97874 continue;
97875 }
97876
97877 fixRange = [rangeStart, rangeEnd];
97878
97879 if (!ignoreComments || !commentLineNumbers.has(lineNumber)) {
97880 report(node, location, fixRange);
97881 }
97882 }
97883
97884 totalLength += lineLength;
97885 }
97886 }
97887 };
97888 }
97889
97890 };
97891
97892 /***/ }),
97893 /* 759 */
97894 /***/ ((module) => {
97895
97896 "use strict";
97897 /**
97898 * @fileoverview Rule to flag references to undeclared variables.
97899 * @author Mark Macdonald
97900 */
97901 //------------------------------------------------------------------------------
97902 // Helpers
97903 //------------------------------------------------------------------------------
97904
97905 /**
97906 * Checks if the given node is the argument of a typeof operator.
97907 * @param {ASTNode} node The AST node being checked.
97908 * @returns {boolean} Whether or not the node is the argument of a typeof operator.
97909 */
97910
97911 function hasTypeOfOperator(node) {
97912 const parent = node.parent;
97913 return parent.type === "UnaryExpression" && parent.operator === "typeof";
97914 } //------------------------------------------------------------------------------
97915 // Rule Definition
97916 //------------------------------------------------------------------------------
97917
97918
97919 module.exports = {
97920 meta: {
97921 type: "problem",
97922 docs: {
97923 description: "disallow the use of undeclared variables unless mentioned in `/*global */` comments",
97924 recommended: true,
97925 url: "https://eslint.org/docs/rules/no-undef"
97926 },
97927 schema: [{
97928 type: "object",
97929 properties: {
97930 typeof: {
97931 type: "boolean",
97932 default: false
97933 }
97934 },
97935 additionalProperties: false
97936 }],
97937 messages: {
97938 undef: "'{{name}}' is not defined."
97939 }
97940 },
97941
97942 create(context) {
97943 const options = context.options[0];
97944 const considerTypeOf = options && options.typeof === true || false;
97945 return {
97946 "Program:exit"() {
97947 const globalScope = context.getScope();
97948 globalScope.through.forEach(ref => {
97949 const identifier = ref.identifier;
97950
97951 if (!considerTypeOf && hasTypeOfOperator(identifier)) {
97952 return;
97953 }
97954
97955 context.report({
97956 node: identifier,
97957 messageId: "undef",
97958 data: identifier
97959 });
97960 });
97961 }
97962
97963 };
97964 }
97965
97966 };
97967
97968 /***/ }),
97969 /* 760 */
97970 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
97971
97972 "use strict";
97973 /**
97974 * @fileoverview Rule to flag when initializing to undefined
97975 * @author Ilya Volodin
97976 */
97977
97978
97979 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
97980 // Rule Definition
97981 //------------------------------------------------------------------------------
97982
97983
97984 module.exports = {
97985 meta: {
97986 type: "suggestion",
97987 docs: {
97988 description: "disallow initializing variables to `undefined`",
97989 recommended: false,
97990 url: "https://eslint.org/docs/rules/no-undef-init"
97991 },
97992 schema: [],
97993 fixable: "code",
97994 messages: {
97995 unnecessaryUndefinedInit: "It's not necessary to initialize '{{name}}' to undefined."
97996 }
97997 },
97998
97999 create(context) {
98000 const sourceCode = context.getSourceCode();
98001 return {
98002 VariableDeclarator(node) {
98003 const name = sourceCode.getText(node.id),
98004 init = node.init && node.init.name,
98005 scope = context.getScope(),
98006 undefinedVar = astUtils.getVariableByName(scope, "undefined"),
98007 shadowed = undefinedVar && undefinedVar.defs.length > 0,
98008 lastToken = sourceCode.getLastToken(node);
98009
98010 if (init === "undefined" && node.parent.kind !== "const" && !shadowed) {
98011 context.report({
98012 node,
98013 messageId: "unnecessaryUndefinedInit",
98014 data: {
98015 name
98016 },
98017
98018 fix(fixer) {
98019 if (node.parent.kind === "var") {
98020 return null;
98021 }
98022
98023 if (node.id.type === "ArrayPattern" || node.id.type === "ObjectPattern") {
98024 // Don't fix destructuring assignment to `undefined`.
98025 return null;
98026 }
98027
98028 if (sourceCode.commentsExistBetween(node.id, lastToken)) {
98029 return null;
98030 }
98031
98032 return fixer.removeRange([node.id.range[1], node.range[1]]);
98033 }
98034
98035 });
98036 }
98037 }
98038
98039 };
98040 }
98041
98042 };
98043
98044 /***/ }),
98045 /* 761 */
98046 /***/ ((module) => {
98047
98048 "use strict";
98049 /**
98050 * @fileoverview Rule to flag references to the undefined variable.
98051 * @author Michael Ficarra
98052 */
98053 //------------------------------------------------------------------------------
98054 // Rule Definition
98055 //------------------------------------------------------------------------------
98056
98057 module.exports = {
98058 meta: {
98059 type: "suggestion",
98060 docs: {
98061 description: "disallow the use of `undefined` as an identifier",
98062 recommended: false,
98063 url: "https://eslint.org/docs/rules/no-undefined"
98064 },
98065 schema: [],
98066 messages: {
98067 unexpectedUndefined: "Unexpected use of undefined."
98068 }
98069 },
98070
98071 create(context) {
98072 /**
98073 * Report an invalid "undefined" identifier node.
98074 * @param {ASTNode} node The node to report.
98075 * @returns {void}
98076 */
98077 function report(node) {
98078 context.report({
98079 node,
98080 messageId: "unexpectedUndefined"
98081 });
98082 }
98083 /**
98084 * Checks the given scope for references to `undefined` and reports
98085 * all references found.
98086 * @param {eslint-scope.Scope} scope The scope to check.
98087 * @returns {void}
98088 */
98089
98090
98091 function checkScope(scope) {
98092 const undefinedVar = scope.set.get("undefined");
98093
98094 if (!undefinedVar) {
98095 return;
98096 }
98097
98098 const references = undefinedVar.references;
98099 const defs = undefinedVar.defs; // Report non-initializing references (those are covered in defs below)
98100
98101 references.filter(ref => !ref.init).forEach(ref => report(ref.identifier));
98102 defs.forEach(def => report(def.name));
98103 }
98104
98105 return {
98106 "Program:exit"() {
98107 const globalScope = context.getScope();
98108 const stack = [globalScope];
98109
98110 while (stack.length) {
98111 const scope = stack.pop();
98112 stack.push(...scope.childScopes);
98113 checkScope(scope);
98114 }
98115 }
98116
98117 };
98118 }
98119
98120 };
98121
98122 /***/ }),
98123 /* 762 */
98124 /***/ ((module) => {
98125
98126 "use strict";
98127 /**
98128 * @fileoverview Rule to flag dangling underscores in variable declarations.
98129 * @author Matt DuVall <http://www.mattduvall.com>
98130 */
98131 //------------------------------------------------------------------------------
98132 // Rule Definition
98133 //------------------------------------------------------------------------------
98134
98135 module.exports = {
98136 meta: {
98137 type: "suggestion",
98138 docs: {
98139 description: "disallow dangling underscores in identifiers",
98140 recommended: false,
98141 url: "https://eslint.org/docs/rules/no-underscore-dangle"
98142 },
98143 schema: [{
98144 type: "object",
98145 properties: {
98146 allow: {
98147 type: "array",
98148 items: {
98149 type: "string"
98150 }
98151 },
98152 allowAfterThis: {
98153 type: "boolean",
98154 default: false
98155 },
98156 allowAfterSuper: {
98157 type: "boolean",
98158 default: false
98159 },
98160 allowAfterThisConstructor: {
98161 type: "boolean",
98162 default: false
98163 },
98164 enforceInMethodNames: {
98165 type: "boolean",
98166 default: false
98167 },
98168 allowFunctionParams: {
98169 type: "boolean",
98170 default: true
98171 }
98172 },
98173 additionalProperties: false
98174 }],
98175 messages: {
98176 unexpectedUnderscore: "Unexpected dangling '_' in '{{identifier}}'."
98177 }
98178 },
98179
98180 create(context) {
98181 const options = context.options[0] || {};
98182 const ALLOWED_VARIABLES = options.allow ? options.allow : [];
98183 const allowAfterThis = typeof options.allowAfterThis !== "undefined" ? options.allowAfterThis : false;
98184 const allowAfterSuper = typeof options.allowAfterSuper !== "undefined" ? options.allowAfterSuper : false;
98185 const allowAfterThisConstructor = typeof options.allowAfterThisConstructor !== "undefined" ? options.allowAfterThisConstructor : false;
98186 const enforceInMethodNames = typeof options.enforceInMethodNames !== "undefined" ? options.enforceInMethodNames : false;
98187 const allowFunctionParams = typeof options.allowFunctionParams !== "undefined" ? options.allowFunctionParams : true; //-------------------------------------------------------------------------
98188 // Helpers
98189 //-------------------------------------------------------------------------
98190
98191 /**
98192 * Check if identifier is present inside the allowed option
98193 * @param {string} identifier name of the node
98194 * @returns {boolean} true if its is present
98195 * @private
98196 */
98197
98198 function isAllowed(identifier) {
98199 return ALLOWED_VARIABLES.some(ident => ident === identifier);
98200 }
98201 /**
98202 * Check if identifier has a dangling underscore
98203 * @param {string} identifier name of the node
98204 * @returns {boolean} true if its is present
98205 * @private
98206 */
98207
98208
98209 function hasDanglingUnderscore(identifier) {
98210 const len = identifier.length;
98211 return identifier !== "_" && (identifier[0] === "_" || identifier[len - 1] === "_");
98212 }
98213 /**
98214 * Check if identifier is a special case member expression
98215 * @param {string} identifier name of the node
98216 * @returns {boolean} true if its is a special case
98217 * @private
98218 */
98219
98220
98221 function isSpecialCaseIdentifierForMemberExpression(identifier) {
98222 return identifier === "__proto__";
98223 }
98224 /**
98225 * Check if identifier is a special case variable expression
98226 * @param {string} identifier name of the node
98227 * @returns {boolean} true if its is a special case
98228 * @private
98229 */
98230
98231
98232 function isSpecialCaseIdentifierInVariableExpression(identifier) {
98233 // Checks for the underscore library usage here
98234 return identifier === "_";
98235 }
98236 /**
98237 * Check if a node is a member reference of this.constructor
98238 * @param {ASTNode} node node to evaluate
98239 * @returns {boolean} true if it is a reference on this.constructor
98240 * @private
98241 */
98242
98243
98244 function isThisConstructorReference(node) {
98245 return node.object.type === "MemberExpression" && node.object.property.name === "constructor" && node.object.object.type === "ThisExpression";
98246 }
98247 /**
98248 * Check if function parameter has a dangling underscore.
98249 * @param {ASTNode} node function node to evaluate
98250 * @returns {void}
98251 * @private
98252 */
98253
98254
98255 function checkForDanglingUnderscoreInFunctionParameters(node) {
98256 if (!allowFunctionParams) {
98257 node.params.forEach(param => {
98258 const {
98259 type
98260 } = param;
98261 let nodeToCheck;
98262
98263 if (type === "RestElement") {
98264 nodeToCheck = param.argument;
98265 } else if (type === "AssignmentPattern") {
98266 nodeToCheck = param.left;
98267 } else {
98268 nodeToCheck = param;
98269 }
98270
98271 if (nodeToCheck.type === "Identifier") {
98272 const identifier = nodeToCheck.name;
98273
98274 if (hasDanglingUnderscore(identifier) && !isAllowed(identifier)) {
98275 context.report({
98276 node: param,
98277 messageId: "unexpectedUnderscore",
98278 data: {
98279 identifier
98280 }
98281 });
98282 }
98283 }
98284 });
98285 }
98286 }
98287 /**
98288 * Check if function has a dangling underscore
98289 * @param {ASTNode} node node to evaluate
98290 * @returns {void}
98291 * @private
98292 */
98293
98294
98295 function checkForDanglingUnderscoreInFunction(node) {
98296 if (node.type === "FunctionDeclaration" && node.id) {
98297 const identifier = node.id.name;
98298
98299 if (typeof identifier !== "undefined" && hasDanglingUnderscore(identifier) && !isAllowed(identifier)) {
98300 context.report({
98301 node,
98302 messageId: "unexpectedUnderscore",
98303 data: {
98304 identifier
98305 }
98306 });
98307 }
98308 }
98309
98310 checkForDanglingUnderscoreInFunctionParameters(node);
98311 }
98312 /**
98313 * Check if variable expression has a dangling underscore
98314 * @param {ASTNode} node node to evaluate
98315 * @returns {void}
98316 * @private
98317 */
98318
98319
98320 function checkForDanglingUnderscoreInVariableExpression(node) {
98321 const identifier = node.id.name;
98322
98323 if (typeof identifier !== "undefined" && hasDanglingUnderscore(identifier) && !isSpecialCaseIdentifierInVariableExpression(identifier) && !isAllowed(identifier)) {
98324 context.report({
98325 node,
98326 messageId: "unexpectedUnderscore",
98327 data: {
98328 identifier
98329 }
98330 });
98331 }
98332 }
98333 /**
98334 * Check if member expression has a dangling underscore
98335 * @param {ASTNode} node node to evaluate
98336 * @returns {void}
98337 * @private
98338 */
98339
98340
98341 function checkForDanglingUnderscoreInMemberExpression(node) {
98342 const identifier = node.property.name,
98343 isMemberOfThis = node.object.type === "ThisExpression",
98344 isMemberOfSuper = node.object.type === "Super",
98345 isMemberOfThisConstructor = isThisConstructorReference(node);
98346
98347 if (typeof identifier !== "undefined" && hasDanglingUnderscore(identifier) && !(isMemberOfThis && allowAfterThis) && !(isMemberOfSuper && allowAfterSuper) && !(isMemberOfThisConstructor && allowAfterThisConstructor) && !isSpecialCaseIdentifierForMemberExpression(identifier) && !isAllowed(identifier)) {
98348 context.report({
98349 node,
98350 messageId: "unexpectedUnderscore",
98351 data: {
98352 identifier
98353 }
98354 });
98355 }
98356 }
98357 /**
98358 * Check if method declaration or method property has a dangling underscore
98359 * @param {ASTNode} node node to evaluate
98360 * @returns {void}
98361 * @private
98362 */
98363
98364
98365 function checkForDanglingUnderscoreInMethod(node) {
98366 const identifier = node.key.name;
98367 const isMethod = node.type === "MethodDefinition" || node.type === "Property" && node.method;
98368
98369 if (typeof identifier !== "undefined" && enforceInMethodNames && isMethod && hasDanglingUnderscore(identifier) && !isAllowed(identifier)) {
98370 context.report({
98371 node,
98372 messageId: "unexpectedUnderscore",
98373 data: {
98374 identifier: node.key.type === "PrivateIdentifier" ? "#".concat(identifier) : identifier
98375 }
98376 });
98377 }
98378 } //--------------------------------------------------------------------------
98379 // Public API
98380 //--------------------------------------------------------------------------
98381
98382
98383 return {
98384 FunctionDeclaration: checkForDanglingUnderscoreInFunction,
98385 VariableDeclarator: checkForDanglingUnderscoreInVariableExpression,
98386 MemberExpression: checkForDanglingUnderscoreInMemberExpression,
98387 MethodDefinition: checkForDanglingUnderscoreInMethod,
98388 PropertyDefinition: checkForDanglingUnderscoreInMethod,
98389 Property: checkForDanglingUnderscoreInMethod,
98390 FunctionExpression: checkForDanglingUnderscoreInFunction,
98391 ArrowFunctionExpression: checkForDanglingUnderscoreInFunction
98392 };
98393 }
98394
98395 };
98396
98397 /***/ }),
98398 /* 763 */
98399 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
98400
98401 "use strict";
98402 /**
98403 * @fileoverview Rule to spot scenarios where a newline looks like it is ending a statement, but is not.
98404 * @author Glen Mailer
98405 */
98406 //------------------------------------------------------------------------------
98407 // Requirements
98408 //------------------------------------------------------------------------------
98409
98410 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
98411 // Rule Definition
98412 //------------------------------------------------------------------------------
98413
98414
98415 module.exports = {
98416 meta: {
98417 type: "problem",
98418 docs: {
98419 description: "disallow confusing multiline expressions",
98420 recommended: true,
98421 url: "https://eslint.org/docs/rules/no-unexpected-multiline"
98422 },
98423 schema: [],
98424 messages: {
98425 function: "Unexpected newline between function and ( of function call.",
98426 property: "Unexpected newline between object and [ of property access.",
98427 taggedTemplate: "Unexpected newline between template tag and template literal.",
98428 division: "Unexpected newline between numerator and division operator."
98429 }
98430 },
98431
98432 create(context) {
98433 const REGEX_FLAG_MATCHER = /^[gimsuy]+$/u;
98434 const sourceCode = context.getSourceCode();
98435 /**
98436 * Check to see if there is a newline between the node and the following open bracket
98437 * line's expression
98438 * @param {ASTNode} node The node to check.
98439 * @param {string} messageId The error messageId to use.
98440 * @returns {void}
98441 * @private
98442 */
98443
98444 function checkForBreakAfter(node, messageId) {
98445 const openParen = sourceCode.getTokenAfter(node, astUtils.isNotClosingParenToken);
98446 const nodeExpressionEnd = sourceCode.getTokenBefore(openParen);
98447
98448 if (openParen.loc.start.line !== nodeExpressionEnd.loc.end.line) {
98449 context.report({
98450 node,
98451 loc: openParen.loc,
98452 messageId
98453 });
98454 }
98455 } //--------------------------------------------------------------------------
98456 // Public API
98457 //--------------------------------------------------------------------------
98458
98459
98460 return {
98461 MemberExpression(node) {
98462 if (!node.computed || node.optional) {
98463 return;
98464 }
98465
98466 checkForBreakAfter(node.object, "property");
98467 },
98468
98469 TaggedTemplateExpression(node) {
98470 const {
98471 quasi
98472 } = node; // handles common tags, parenthesized tags, and typescript's generic type arguments
98473
98474 const tokenBefore = sourceCode.getTokenBefore(quasi);
98475
98476 if (tokenBefore.loc.end.line !== quasi.loc.start.line) {
98477 context.report({
98478 node,
98479 loc: {
98480 start: quasi.loc.start,
98481 end: {
98482 line: quasi.loc.start.line,
98483 column: quasi.loc.start.column + 1
98484 }
98485 },
98486 messageId: "taggedTemplate"
98487 });
98488 }
98489 },
98490
98491 CallExpression(node) {
98492 if (node.arguments.length === 0 || node.optional) {
98493 return;
98494 }
98495
98496 checkForBreakAfter(node.callee, "function");
98497 },
98498
98499 "BinaryExpression[operator='/'] > BinaryExpression[operator='/'].left"(node) {
98500 const secondSlash = sourceCode.getTokenAfter(node, token => token.value === "/");
98501 const tokenAfterOperator = sourceCode.getTokenAfter(secondSlash);
98502
98503 if (tokenAfterOperator.type === "Identifier" && REGEX_FLAG_MATCHER.test(tokenAfterOperator.value) && secondSlash.range[1] === tokenAfterOperator.range[0]) {
98504 checkForBreakAfter(node.left, "division");
98505 }
98506 }
98507
98508 };
98509 }
98510
98511 };
98512
98513 /***/ }),
98514 /* 764 */
98515 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
98516
98517 "use strict";
98518 /**
98519 * @fileoverview Rule to disallow use of unmodified expressions in loop conditions
98520 * @author Toru Nagashima
98521 */
98522 //------------------------------------------------------------------------------
98523 // Requirements
98524 //------------------------------------------------------------------------------
98525
98526 const Traverser = __webpack_require__(495),
98527 astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
98528 // Helpers
98529 //------------------------------------------------------------------------------
98530
98531
98532 const SENTINEL_PATTERN = /(?:(?:Call|Class|Function|Member|New|Yield)Expression|Statement|Declaration)$/u;
98533 const LOOP_PATTERN = /^(?:DoWhile|For|While)Statement$/u; // for-in/of statements don't have `test` property.
98534
98535 const GROUP_PATTERN = /^(?:BinaryExpression|ConditionalExpression)$/u;
98536 const SKIP_PATTERN = /^(?:ArrowFunction|Class|Function)Expression$/u;
98537 const DYNAMIC_PATTERN = /^(?:Call|Member|New|TaggedTemplate|Yield)Expression$/u;
98538 /**
98539 * @typedef {Object} LoopConditionInfo
98540 * @property {eslint-scope.Reference} reference - The reference.
98541 * @property {ASTNode} group - BinaryExpression or ConditionalExpression nodes
98542 * that the reference is belonging to.
98543 * @property {Function} isInLoop - The predicate which checks a given reference
98544 * is in this loop.
98545 * @property {boolean} modified - The flag that the reference is modified in
98546 * this loop.
98547 */
98548
98549 /**
98550 * Checks whether or not a given reference is a write reference.
98551 * @param {eslint-scope.Reference} reference A reference to check.
98552 * @returns {boolean} `true` if the reference is a write reference.
98553 */
98554
98555 function isWriteReference(reference) {
98556 if (reference.init) {
98557 const def = reference.resolved && reference.resolved.defs[0];
98558
98559 if (!def || def.type !== "Variable" || def.parent.kind !== "var") {
98560 return false;
98561 }
98562 }
98563
98564 return reference.isWrite();
98565 }
98566 /**
98567 * Checks whether or not a given loop condition info does not have the modified
98568 * flag.
98569 * @param {LoopConditionInfo} condition A loop condition info to check.
98570 * @returns {boolean} `true` if the loop condition info is "unmodified".
98571 */
98572
98573
98574 function isUnmodified(condition) {
98575 return !condition.modified;
98576 }
98577 /**
98578 * Checks whether or not a given loop condition info does not have the modified
98579 * flag and does not have the group this condition belongs to.
98580 * @param {LoopConditionInfo} condition A loop condition info to check.
98581 * @returns {boolean} `true` if the loop condition info is "unmodified".
98582 */
98583
98584
98585 function isUnmodifiedAndNotBelongToGroup(condition) {
98586 return !(condition.modified || condition.group);
98587 }
98588 /**
98589 * Checks whether or not a given reference is inside of a given node.
98590 * @param {ASTNode} node A node to check.
98591 * @param {eslint-scope.Reference} reference A reference to check.
98592 * @returns {boolean} `true` if the reference is inside of the node.
98593 */
98594
98595
98596 function isInRange(node, reference) {
98597 const or = node.range;
98598 const ir = reference.identifier.range;
98599 return or[0] <= ir[0] && ir[1] <= or[1];
98600 }
98601 /**
98602 * Checks whether or not a given reference is inside of a loop node's condition.
98603 * @param {ASTNode} node A node to check.
98604 * @param {eslint-scope.Reference} reference A reference to check.
98605 * @returns {boolean} `true` if the reference is inside of the loop node's
98606 * condition.
98607 */
98608
98609
98610 const isInLoop = {
98611 WhileStatement: isInRange,
98612 DoWhileStatement: isInRange,
98613
98614 ForStatement(node, reference) {
98615 return isInRange(node, reference) && !(node.init && isInRange(node.init, reference));
98616 }
98617
98618 };
98619 /**
98620 * Gets the function which encloses a given reference.
98621 * This supports only FunctionDeclaration.
98622 * @param {eslint-scope.Reference} reference A reference to get.
98623 * @returns {ASTNode|null} The function node or null.
98624 */
98625
98626 function getEncloseFunctionDeclaration(reference) {
98627 let node = reference.identifier;
98628
98629 while (node) {
98630 if (node.type === "FunctionDeclaration") {
98631 return node.id ? node : null;
98632 }
98633
98634 node = node.parent;
98635 }
98636
98637 return null;
98638 }
98639 /**
98640 * Updates the "modified" flags of given loop conditions with given modifiers.
98641 * @param {LoopConditionInfo[]} conditions The loop conditions to be updated.
98642 * @param {eslint-scope.Reference[]} modifiers The references to update.
98643 * @returns {void}
98644 */
98645
98646
98647 function updateModifiedFlag(conditions, modifiers) {
98648 for (let i = 0; i < conditions.length; ++i) {
98649 const condition = conditions[i];
98650
98651 for (let j = 0; !condition.modified && j < modifiers.length; ++j) {
98652 const modifier = modifiers[j];
98653 let funcNode, funcVar;
98654 /*
98655 * Besides checking for the condition being in the loop, we want to
98656 * check the function that this modifier is belonging to is called
98657 * in the loop.
98658 * FIXME: This should probably be extracted to a function.
98659 */
98660
98661 const inLoop = condition.isInLoop(modifier) || Boolean((funcNode = getEncloseFunctionDeclaration(modifier)) && (funcVar = astUtils.getVariableByName(modifier.from.upper, funcNode.id.name)) && funcVar.references.some(condition.isInLoop));
98662 condition.modified = inLoop;
98663 }
98664 }
98665 } //------------------------------------------------------------------------------
98666 // Rule Definition
98667 //------------------------------------------------------------------------------
98668
98669
98670 module.exports = {
98671 meta: {
98672 type: "problem",
98673 docs: {
98674 description: "disallow unmodified loop conditions",
98675 recommended: false,
98676 url: "https://eslint.org/docs/rules/no-unmodified-loop-condition"
98677 },
98678 schema: [],
98679 messages: {
98680 loopConditionNotModified: "'{{name}}' is not modified in this loop."
98681 }
98682 },
98683
98684 create(context) {
98685 const sourceCode = context.getSourceCode();
98686 let groupMap = null;
98687 /**
98688 * Reports a given condition info.
98689 * @param {LoopConditionInfo} condition A loop condition info to report.
98690 * @returns {void}
98691 */
98692
98693 function report(condition) {
98694 const node = condition.reference.identifier;
98695 context.report({
98696 node,
98697 messageId: "loopConditionNotModified",
98698 data: node
98699 });
98700 }
98701 /**
98702 * Registers given conditions to the group the condition belongs to.
98703 * @param {LoopConditionInfo[]} conditions A loop condition info to
98704 * register.
98705 * @returns {void}
98706 */
98707
98708
98709 function registerConditionsToGroup(conditions) {
98710 for (let i = 0; i < conditions.length; ++i) {
98711 const condition = conditions[i];
98712
98713 if (condition.group) {
98714 let group = groupMap.get(condition.group);
98715
98716 if (!group) {
98717 group = [];
98718 groupMap.set(condition.group, group);
98719 }
98720
98721 group.push(condition);
98722 }
98723 }
98724 }
98725 /**
98726 * Reports references which are inside of unmodified groups.
98727 * @param {LoopConditionInfo[]} conditions A loop condition info to report.
98728 * @returns {void}
98729 */
98730
98731
98732 function checkConditionsInGroup(conditions) {
98733 if (conditions.every(isUnmodified)) {
98734 conditions.forEach(report);
98735 }
98736 }
98737 /**
98738 * Checks whether or not a given group node has any dynamic elements.
98739 * @param {ASTNode} root A node to check.
98740 * This node is one of BinaryExpression or ConditionalExpression.
98741 * @returns {boolean} `true` if the node is dynamic.
98742 */
98743
98744
98745 function hasDynamicExpressions(root) {
98746 let retv = false;
98747 Traverser.traverse(root, {
98748 visitorKeys: sourceCode.visitorKeys,
98749
98750 enter(node) {
98751 if (DYNAMIC_PATTERN.test(node.type)) {
98752 retv = true;
98753 this.break();
98754 } else if (SKIP_PATTERN.test(node.type)) {
98755 this.skip();
98756 }
98757 }
98758
98759 });
98760 return retv;
98761 }
98762 /**
98763 * Creates the loop condition information from a given reference.
98764 * @param {eslint-scope.Reference} reference A reference to create.
98765 * @returns {LoopConditionInfo|null} Created loop condition info, or null.
98766 */
98767
98768
98769 function toLoopCondition(reference) {
98770 if (reference.init) {
98771 return null;
98772 }
98773
98774 let group = null;
98775 let child = reference.identifier;
98776 let node = child.parent;
98777
98778 while (node) {
98779 if (SENTINEL_PATTERN.test(node.type)) {
98780 if (LOOP_PATTERN.test(node.type) && node.test === child) {
98781 // This reference is inside of a loop condition.
98782 return {
98783 reference,
98784 group,
98785 isInLoop: isInLoop[node.type].bind(null, node),
98786 modified: false
98787 };
98788 } // This reference is outside of a loop condition.
98789
98790
98791 break;
98792 }
98793 /*
98794 * If it's inside of a group, OK if either operand is modified.
98795 * So stores the group this reference belongs to.
98796 */
98797
98798
98799 if (GROUP_PATTERN.test(node.type)) {
98800 // If this expression is dynamic, no need to check.
98801 if (hasDynamicExpressions(node)) {
98802 break;
98803 } else {
98804 group = node;
98805 }
98806 }
98807
98808 child = node;
98809 node = node.parent;
98810 }
98811
98812 return null;
98813 }
98814 /**
98815 * Finds unmodified references which are inside of a loop condition.
98816 * Then reports the references which are outside of groups.
98817 * @param {eslint-scope.Variable} variable A variable to report.
98818 * @returns {void}
98819 */
98820
98821
98822 function checkReferences(variable) {
98823 // Gets references that exist in loop conditions.
98824 const conditions = variable.references.map(toLoopCondition).filter(Boolean);
98825
98826 if (conditions.length === 0) {
98827 return;
98828 } // Registers the conditions to belonging groups.
98829
98830
98831 registerConditionsToGroup(conditions); // Check the conditions are modified.
98832
98833 const modifiers = variable.references.filter(isWriteReference);
98834
98835 if (modifiers.length > 0) {
98836 updateModifiedFlag(conditions, modifiers);
98837 }
98838 /*
98839 * Reports the conditions which are not belonging to groups.
98840 * Others will be reported after all variables are done.
98841 */
98842
98843
98844 conditions.filter(isUnmodifiedAndNotBelongToGroup).forEach(report);
98845 }
98846
98847 return {
98848 "Program:exit"() {
98849 const queue = [context.getScope()];
98850 groupMap = new Map();
98851 let scope;
98852
98853 while (scope = queue.pop()) {
98854 queue.push(...scope.childScopes);
98855 scope.variables.forEach(checkReferences);
98856 }
98857
98858 groupMap.forEach(checkConditionsInGroup);
98859 groupMap = null;
98860 }
98861
98862 };
98863 }
98864
98865 };
98866
98867 /***/ }),
98868 /* 765 */
98869 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
98870
98871 "use strict";
98872 /**
98873 * @fileoverview Rule to flag no-unneeded-ternary
98874 * @author Gyandeep Singh
98875 */
98876
98877
98878 const astUtils = __webpack_require__(548); // Operators that always result in a boolean value
98879
98880
98881 const BOOLEAN_OPERATORS = new Set(["==", "===", "!=", "!==", ">", ">=", "<", "<=", "in", "instanceof"]);
98882 const OPERATOR_INVERSES = {
98883 "==": "!=",
98884 "!=": "==",
98885 "===": "!==",
98886 "!==": "===" // Operators like < and >= are not true inverses, since both will return false with NaN.
98887
98888 };
98889 const OR_PRECEDENCE = astUtils.getPrecedence({
98890 type: "LogicalExpression",
98891 operator: "||"
98892 }); //------------------------------------------------------------------------------
98893 // Rule Definition
98894 //------------------------------------------------------------------------------
98895
98896 module.exports = {
98897 meta: {
98898 type: "suggestion",
98899 docs: {
98900 description: "disallow ternary operators when simpler alternatives exist",
98901 recommended: false,
98902 url: "https://eslint.org/docs/rules/no-unneeded-ternary"
98903 },
98904 schema: [{
98905 type: "object",
98906 properties: {
98907 defaultAssignment: {
98908 type: "boolean",
98909 default: true
98910 }
98911 },
98912 additionalProperties: false
98913 }],
98914 fixable: "code",
98915 messages: {
98916 unnecessaryConditionalExpression: "Unnecessary use of boolean literals in conditional expression.",
98917 unnecessaryConditionalAssignment: "Unnecessary use of conditional expression for default assignment."
98918 }
98919 },
98920
98921 create(context) {
98922 const options = context.options[0] || {};
98923 const defaultAssignment = options.defaultAssignment !== false;
98924 const sourceCode = context.getSourceCode();
98925 /**
98926 * Test if the node is a boolean literal
98927 * @param {ASTNode} node The node to report.
98928 * @returns {boolean} True if the its a boolean literal
98929 * @private
98930 */
98931
98932 function isBooleanLiteral(node) {
98933 return node.type === "Literal" && typeof node.value === "boolean";
98934 }
98935 /**
98936 * Creates an expression that represents the boolean inverse of the expression represented by the original node
98937 * @param {ASTNode} node A node representing an expression
98938 * @returns {string} A string representing an inverted expression
98939 */
98940
98941
98942 function invertExpression(node) {
98943 if (node.type === "BinaryExpression" && Object.prototype.hasOwnProperty.call(OPERATOR_INVERSES, node.operator)) {
98944 const operatorToken = sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
98945 const text = sourceCode.getText();
98946 return text.slice(node.range[0], operatorToken.range[0]) + OPERATOR_INVERSES[node.operator] + text.slice(operatorToken.range[1], node.range[1]);
98947 }
98948
98949 if (astUtils.getPrecedence(node) < astUtils.getPrecedence({
98950 type: "UnaryExpression"
98951 })) {
98952 return "!(".concat(astUtils.getParenthesisedText(sourceCode, node), ")");
98953 }
98954
98955 return "!".concat(astUtils.getParenthesisedText(sourceCode, node));
98956 }
98957 /**
98958 * Tests if a given node always evaluates to a boolean value
98959 * @param {ASTNode} node An expression node
98960 * @returns {boolean} True if it is determined that the node will always evaluate to a boolean value
98961 */
98962
98963
98964 function isBooleanExpression(node) {
98965 return node.type === "BinaryExpression" && BOOLEAN_OPERATORS.has(node.operator) || node.type === "UnaryExpression" && node.operator === "!";
98966 }
98967 /**
98968 * Test if the node matches the pattern id ? id : expression
98969 * @param {ASTNode} node The ConditionalExpression to check.
98970 * @returns {boolean} True if the pattern is matched, and false otherwise
98971 * @private
98972 */
98973
98974
98975 function matchesDefaultAssignment(node) {
98976 return node.test.type === "Identifier" && node.consequent.type === "Identifier" && node.test.name === node.consequent.name;
98977 }
98978
98979 return {
98980 ConditionalExpression(node) {
98981 if (isBooleanLiteral(node.alternate) && isBooleanLiteral(node.consequent)) {
98982 context.report({
98983 node,
98984 messageId: "unnecessaryConditionalExpression",
98985
98986 fix(fixer) {
98987 if (node.consequent.value === node.alternate.value) {
98988 // Replace `foo ? true : true` with just `true`, but don't replace `foo() ? true : true`
98989 return node.test.type === "Identifier" ? fixer.replaceText(node, node.consequent.value.toString()) : null;
98990 }
98991
98992 if (node.alternate.value) {
98993 // Replace `foo() ? false : true` with `!(foo())`
98994 return fixer.replaceText(node, invertExpression(node.test));
98995 } // Replace `foo ? true : false` with `foo` if `foo` is guaranteed to be a boolean, or `!!foo` otherwise.
98996
98997
98998 return fixer.replaceText(node, isBooleanExpression(node.test) ? astUtils.getParenthesisedText(sourceCode, node.test) : "!".concat(invertExpression(node.test)));
98999 }
99000
99001 });
99002 } else if (!defaultAssignment && matchesDefaultAssignment(node)) {
99003 context.report({
99004 node,
99005 messageId: "unnecessaryConditionalAssignment",
99006 fix: fixer => {
99007 const shouldParenthesizeAlternate = (astUtils.getPrecedence(node.alternate) < OR_PRECEDENCE || astUtils.isCoalesceExpression(node.alternate)) && !astUtils.isParenthesised(sourceCode, node.alternate);
99008 const alternateText = shouldParenthesizeAlternate ? "(".concat(sourceCode.getText(node.alternate), ")") : astUtils.getParenthesisedText(sourceCode, node.alternate);
99009 const testText = astUtils.getParenthesisedText(sourceCode, node.test);
99010 return fixer.replaceText(node, "".concat(testText, " || ").concat(alternateText));
99011 }
99012 });
99013 }
99014 }
99015
99016 };
99017 }
99018
99019 };
99020
99021 /***/ }),
99022 /* 766 */
99023 /***/ ((module) => {
99024
99025 "use strict";
99026 /**
99027 * @fileoverview Checks for unreachable code due to return, throws, break, and continue.
99028 * @author Joel Feenstra
99029 */
99030 //------------------------------------------------------------------------------
99031 // Helpers
99032 //------------------------------------------------------------------------------
99033
99034 /**
99035 * @typedef {Object} ConstructorInfo
99036 * @property {ConstructorInfo | null} upper Info about the constructor that encloses this constructor.
99037 * @property {boolean} hasSuperCall The flag about having `super()` expressions.
99038 */
99039
99040 /**
99041 * Checks whether or not a given variable declarator has the initializer.
99042 * @param {ASTNode} node A VariableDeclarator node to check.
99043 * @returns {boolean} `true` if the node has the initializer.
99044 */
99045
99046 function isInitialized(node) {
99047 return Boolean(node.init);
99048 }
99049 /**
99050 * Checks whether or not a given code path segment is unreachable.
99051 * @param {CodePathSegment} segment A CodePathSegment to check.
99052 * @returns {boolean} `true` if the segment is unreachable.
99053 */
99054
99055
99056 function isUnreachable(segment) {
99057 return !segment.reachable;
99058 }
99059 /**
99060 * The class to distinguish consecutive unreachable statements.
99061 */
99062
99063
99064 class ConsecutiveRange {
99065 constructor(sourceCode) {
99066 this.sourceCode = sourceCode;
99067 this.startNode = null;
99068 this.endNode = null;
99069 }
99070 /**
99071 * The location object of this range.
99072 * @type {Object}
99073 */
99074
99075
99076 get location() {
99077 return {
99078 start: this.startNode.loc.start,
99079 end: this.endNode.loc.end
99080 };
99081 }
99082 /**
99083 * `true` if this range is empty.
99084 * @type {boolean}
99085 */
99086
99087
99088 get isEmpty() {
99089 return !(this.startNode && this.endNode);
99090 }
99091 /**
99092 * Checks whether the given node is inside of this range.
99093 * @param {ASTNode|Token} node The node to check.
99094 * @returns {boolean} `true` if the node is inside of this range.
99095 */
99096
99097
99098 contains(node) {
99099 return node.range[0] >= this.startNode.range[0] && node.range[1] <= this.endNode.range[1];
99100 }
99101 /**
99102 * Checks whether the given node is consecutive to this range.
99103 * @param {ASTNode} node The node to check.
99104 * @returns {boolean} `true` if the node is consecutive to this range.
99105 */
99106
99107
99108 isConsecutive(node) {
99109 return this.contains(this.sourceCode.getTokenBefore(node));
99110 }
99111 /**
99112 * Merges the given node to this range.
99113 * @param {ASTNode} node The node to merge.
99114 * @returns {void}
99115 */
99116
99117
99118 merge(node) {
99119 this.endNode = node;
99120 }
99121 /**
99122 * Resets this range by the given node or null.
99123 * @param {ASTNode|null} node The node to reset, or null.
99124 * @returns {void}
99125 */
99126
99127
99128 reset(node) {
99129 this.startNode = this.endNode = node;
99130 }
99131
99132 } //------------------------------------------------------------------------------
99133 // Rule Definition
99134 //------------------------------------------------------------------------------
99135
99136
99137 module.exports = {
99138 meta: {
99139 type: "problem",
99140 docs: {
99141 description: "disallow unreachable code after `return`, `throw`, `continue`, and `break` statements",
99142 recommended: true,
99143 url: "https://eslint.org/docs/rules/no-unreachable"
99144 },
99145 schema: [],
99146 messages: {
99147 unreachableCode: "Unreachable code."
99148 }
99149 },
99150
99151 create(context) {
99152 let currentCodePath = null;
99153 /** @type {ConstructorInfo | null} */
99154
99155 let constructorInfo = null;
99156 /** @type {ConsecutiveRange} */
99157
99158 const range = new ConsecutiveRange(context.getSourceCode());
99159 /**
99160 * Reports a given node if it's unreachable.
99161 * @param {ASTNode} node A statement node to report.
99162 * @returns {void}
99163 */
99164
99165 function reportIfUnreachable(node) {
99166 let nextNode = null;
99167
99168 if (node && (node.type === "PropertyDefinition" || currentCodePath.currentSegments.every(isUnreachable))) {
99169 // Store this statement to distinguish consecutive statements.
99170 if (range.isEmpty) {
99171 range.reset(node);
99172 return;
99173 } // Skip if this statement is inside of the current range.
99174
99175
99176 if (range.contains(node)) {
99177 return;
99178 } // Merge if this statement is consecutive to the current range.
99179
99180
99181 if (range.isConsecutive(node)) {
99182 range.merge(node);
99183 return;
99184 }
99185
99186 nextNode = node;
99187 }
99188 /*
99189 * Report the current range since this statement is reachable or is
99190 * not consecutive to the current range.
99191 */
99192
99193
99194 if (!range.isEmpty) {
99195 context.report({
99196 messageId: "unreachableCode",
99197 loc: range.location,
99198 node: range.startNode
99199 });
99200 } // Update the current range.
99201
99202
99203 range.reset(nextNode);
99204 }
99205
99206 return {
99207 // Manages the current code path.
99208 onCodePathStart(codePath) {
99209 currentCodePath = codePath;
99210 },
99211
99212 onCodePathEnd() {
99213 currentCodePath = currentCodePath.upper;
99214 },
99215
99216 // Registers for all statement nodes (excludes FunctionDeclaration).
99217 BlockStatement: reportIfUnreachable,
99218 BreakStatement: reportIfUnreachable,
99219 ClassDeclaration: reportIfUnreachable,
99220 ContinueStatement: reportIfUnreachable,
99221 DebuggerStatement: reportIfUnreachable,
99222 DoWhileStatement: reportIfUnreachable,
99223 ExpressionStatement: reportIfUnreachable,
99224 ForInStatement: reportIfUnreachable,
99225 ForOfStatement: reportIfUnreachable,
99226 ForStatement: reportIfUnreachable,
99227 IfStatement: reportIfUnreachable,
99228 ImportDeclaration: reportIfUnreachable,
99229 LabeledStatement: reportIfUnreachable,
99230 ReturnStatement: reportIfUnreachable,
99231 SwitchStatement: reportIfUnreachable,
99232 ThrowStatement: reportIfUnreachable,
99233 TryStatement: reportIfUnreachable,
99234
99235 VariableDeclaration(node) {
99236 if (node.kind !== "var" || node.declarations.some(isInitialized)) {
99237 reportIfUnreachable(node);
99238 }
99239 },
99240
99241 WhileStatement: reportIfUnreachable,
99242 WithStatement: reportIfUnreachable,
99243 ExportNamedDeclaration: reportIfUnreachable,
99244 ExportDefaultDeclaration: reportIfUnreachable,
99245 ExportAllDeclaration: reportIfUnreachable,
99246
99247 "Program:exit"() {
99248 reportIfUnreachable();
99249 },
99250
99251 /*
99252 * Instance fields defined in a subclass are never created if the constructor of the subclass
99253 * doesn't call `super()`, so their definitions are unreachable code.
99254 */
99255 "MethodDefinition[kind='constructor']"() {
99256 constructorInfo = {
99257 upper: constructorInfo,
99258 hasSuperCall: false
99259 };
99260 },
99261
99262 "MethodDefinition[kind='constructor']:exit"(node) {
99263 const {
99264 hasSuperCall
99265 } = constructorInfo;
99266 constructorInfo = constructorInfo.upper; // skip typescript constructors without the body
99267
99268 if (!node.value.body) {
99269 return;
99270 }
99271
99272 const classDefinition = node.parent.parent;
99273
99274 if (classDefinition.superClass && !hasSuperCall) {
99275 for (const element of classDefinition.body.body) {
99276 if (element.type === "PropertyDefinition" && !element.static) {
99277 reportIfUnreachable(element);
99278 }
99279 }
99280 }
99281 },
99282
99283 "CallExpression > Super.callee"() {
99284 if (constructorInfo) {
99285 constructorInfo.hasSuperCall = true;
99286 }
99287 }
99288
99289 };
99290 }
99291
99292 };
99293
99294 /***/ }),
99295 /* 767 */
99296 /***/ ((module) => {
99297
99298 "use strict";
99299 /**
99300 * @fileoverview Rule to disallow loops with a body that allows only one iteration
99301 * @author Milos Djermanovic
99302 */
99303 //------------------------------------------------------------------------------
99304 // Helpers
99305 //------------------------------------------------------------------------------
99306
99307 const allLoopTypes = ["WhileStatement", "DoWhileStatement", "ForStatement", "ForInStatement", "ForOfStatement"];
99308 /**
99309 * Determines whether the given node is the first node in the code path to which a loop statement
99310 * 'loops' for the next iteration.
99311 * @param {ASTNode} node The node to check.
99312 * @returns {boolean} `true` if the node is a looping target.
99313 */
99314
99315 function isLoopingTarget(node) {
99316 const parent = node.parent;
99317
99318 if (parent) {
99319 switch (parent.type) {
99320 case "WhileStatement":
99321 return node === parent.test;
99322
99323 case "DoWhileStatement":
99324 return node === parent.body;
99325
99326 case "ForStatement":
99327 return node === (parent.update || parent.test || parent.body);
99328
99329 case "ForInStatement":
99330 case "ForOfStatement":
99331 return node === parent.left;
99332 // no default
99333 }
99334 }
99335
99336 return false;
99337 }
99338 /**
99339 * Creates an array with elements from the first given array that are not included in the second given array.
99340 * @param {Array} arrA The array to compare from.
99341 * @param {Array} arrB The array to compare against.
99342 * @returns {Array} a new array that represents `arrA \ arrB`.
99343 */
99344
99345
99346 function getDifference(arrA, arrB) {
99347 return arrA.filter(a => !arrB.includes(a));
99348 } //------------------------------------------------------------------------------
99349 // Rule Definition
99350 //------------------------------------------------------------------------------
99351
99352
99353 module.exports = {
99354 meta: {
99355 type: "problem",
99356 docs: {
99357 description: "disallow loops with a body that allows only one iteration",
99358 recommended: false,
99359 url: "https://eslint.org/docs/rules/no-unreachable-loop"
99360 },
99361 schema: [{
99362 type: "object",
99363 properties: {
99364 ignore: {
99365 type: "array",
99366 items: {
99367 enum: allLoopTypes
99368 },
99369 uniqueItems: true
99370 }
99371 },
99372 additionalProperties: false
99373 }],
99374 messages: {
99375 invalid: "Invalid loop. Its body allows only one iteration."
99376 }
99377 },
99378
99379 create(context) {
99380 const ignoredLoopTypes = context.options[0] && context.options[0].ignore || [],
99381 loopTypesToCheck = getDifference(allLoopTypes, ignoredLoopTypes),
99382 loopSelector = loopTypesToCheck.join(","),
99383 loopsByTargetSegments = new Map(),
99384 loopsToReport = new Set();
99385 let currentCodePath = null;
99386 return {
99387 onCodePathStart(codePath) {
99388 currentCodePath = codePath;
99389 },
99390
99391 onCodePathEnd() {
99392 currentCodePath = currentCodePath.upper;
99393 },
99394
99395 [loopSelector](node) {
99396 /**
99397 * Ignore unreachable loop statements to avoid unnecessary complexity in the implementation, or false positives otherwise.
99398 * For unreachable segments, the code path analysis does not raise events required for this implementation.
99399 */
99400 if (currentCodePath.currentSegments.some(segment => segment.reachable)) {
99401 loopsToReport.add(node);
99402 }
99403 },
99404
99405 onCodePathSegmentStart(segment, node) {
99406 if (isLoopingTarget(node)) {
99407 const loop = node.parent;
99408 loopsByTargetSegments.set(segment, loop);
99409 }
99410 },
99411
99412 onCodePathSegmentLoop(_, toSegment, node) {
99413 const loop = loopsByTargetSegments.get(toSegment);
99414 /**
99415 * The second iteration is reachable, meaning that the loop is valid by the logic of this rule,
99416 * only if there is at least one loop event with the appropriate target (which has been already
99417 * determined in the `loopsByTargetSegments` map), raised from either:
99418 *
99419 * - the end of the loop's body (in which case `node === loop`)
99420 * - a `continue` statement
99421 *
99422 * This condition skips loop events raised from `ForInStatement > .right` and `ForOfStatement > .right` nodes.
99423 */
99424
99425 if (node === loop || node.type === "ContinueStatement") {
99426 // Removes loop if it exists in the set. Otherwise, `Set#delete` has no effect and doesn't throw.
99427 loopsToReport.delete(loop);
99428 }
99429 },
99430
99431 "Program:exit"() {
99432 loopsToReport.forEach(node => context.report({
99433 node,
99434 messageId: "invalid"
99435 }));
99436 }
99437
99438 };
99439 }
99440
99441 };
99442
99443 /***/ }),
99444 /* 768 */
99445 /***/ ((module) => {
99446
99447 "use strict";
99448 /**
99449 * @fileoverview Rule to flag unsafe statements in finally block
99450 * @author Onur Temizkan
99451 */
99452 //------------------------------------------------------------------------------
99453 // Helpers
99454 //------------------------------------------------------------------------------
99455
99456 const SENTINEL_NODE_TYPE_RETURN_THROW = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression)$/u;
99457 const SENTINEL_NODE_TYPE_BREAK = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement|SwitchStatement)$/u;
99458 const SENTINEL_NODE_TYPE_CONTINUE = /^(?:Program|(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|DoWhileStatement|WhileStatement|ForOfStatement|ForInStatement|ForStatement)$/u; //------------------------------------------------------------------------------
99459 // Rule Definition
99460 //------------------------------------------------------------------------------
99461
99462 module.exports = {
99463 meta: {
99464 type: "problem",
99465 docs: {
99466 description: "disallow control flow statements in `finally` blocks",
99467 recommended: true,
99468 url: "https://eslint.org/docs/rules/no-unsafe-finally"
99469 },
99470 schema: [],
99471 messages: {
99472 unsafeUsage: "Unsafe usage of {{nodeType}}."
99473 }
99474 },
99475
99476 create(context) {
99477 /**
99478 * Checks if the node is the finalizer of a TryStatement
99479 * @param {ASTNode} node node to check.
99480 * @returns {boolean} - true if the node is the finalizer of a TryStatement
99481 */
99482 function isFinallyBlock(node) {
99483 return node.parent.type === "TryStatement" && node.parent.finalizer === node;
99484 }
99485 /**
99486 * Climbs up the tree if the node is not a sentinel node
99487 * @param {ASTNode} node node to check.
99488 * @param {string} label label of the break or continue statement
99489 * @returns {boolean} - return whether the node is a finally block or a sentinel node
99490 */
99491
99492
99493 function isInFinallyBlock(node, label) {
99494 let labelInside = false;
99495 let sentinelNodeType;
99496
99497 if (node.type === "BreakStatement" && !node.label) {
99498 sentinelNodeType = SENTINEL_NODE_TYPE_BREAK;
99499 } else if (node.type === "ContinueStatement") {
99500 sentinelNodeType = SENTINEL_NODE_TYPE_CONTINUE;
99501 } else {
99502 sentinelNodeType = SENTINEL_NODE_TYPE_RETURN_THROW;
99503 }
99504
99505 for (let currentNode = node; currentNode && !sentinelNodeType.test(currentNode.type); currentNode = currentNode.parent) {
99506 if (currentNode.parent.label && label && currentNode.parent.label.name === label.name) {
99507 labelInside = true;
99508 }
99509
99510 if (isFinallyBlock(currentNode)) {
99511 if (label && labelInside) {
99512 return false;
99513 }
99514
99515 return true;
99516 }
99517 }
99518
99519 return false;
99520 }
99521 /**
99522 * Checks whether the possibly-unsafe statement is inside a finally block.
99523 * @param {ASTNode} node node to check.
99524 * @returns {void}
99525 */
99526
99527
99528 function check(node) {
99529 if (isInFinallyBlock(node, node.label)) {
99530 context.report({
99531 messageId: "unsafeUsage",
99532 data: {
99533 nodeType: node.type
99534 },
99535 node,
99536 line: node.loc.line,
99537 column: node.loc.column
99538 });
99539 }
99540 }
99541
99542 return {
99543 ReturnStatement: check,
99544 ThrowStatement: check,
99545 BreakStatement: check,
99546 ContinueStatement: check
99547 };
99548 }
99549
99550 };
99551
99552 /***/ }),
99553 /* 769 */
99554 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
99555
99556 "use strict";
99557 /**
99558 * @fileoverview Rule to disallow negating the left operand of relational operators
99559 * @author Toru Nagashima
99560 */
99561 //------------------------------------------------------------------------------
99562 // Requirements
99563 //------------------------------------------------------------------------------
99564
99565 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
99566 // Helpers
99567 //------------------------------------------------------------------------------
99568
99569 /**
99570 * Checks whether the given operator is `in` or `instanceof`
99571 * @param {string} op The operator type to check.
99572 * @returns {boolean} `true` if the operator is `in` or `instanceof`
99573 */
99574
99575
99576 function isInOrInstanceOfOperator(op) {
99577 return op === "in" || op === "instanceof";
99578 }
99579 /**
99580 * Checks whether the given operator is an ordering relational operator or not.
99581 * @param {string} op The operator type to check.
99582 * @returns {boolean} `true` if the operator is an ordering relational operator.
99583 */
99584
99585
99586 function isOrderingRelationalOperator(op) {
99587 return op === "<" || op === ">" || op === ">=" || op === "<=";
99588 }
99589 /**
99590 * Checks whether the given node is a logical negation expression or not.
99591 * @param {ASTNode} node The node to check.
99592 * @returns {boolean} `true` if the node is a logical negation expression.
99593 */
99594
99595
99596 function isNegation(node) {
99597 return node.type === "UnaryExpression" && node.operator === "!";
99598 } //------------------------------------------------------------------------------
99599 // Rule Definition
99600 //------------------------------------------------------------------------------
99601
99602
99603 module.exports = {
99604 meta: {
99605 type: "problem",
99606 docs: {
99607 description: "disallow negating the left operand of relational operators",
99608 recommended: true,
99609 url: "https://eslint.org/docs/rules/no-unsafe-negation"
99610 },
99611 hasSuggestions: true,
99612 schema: [{
99613 type: "object",
99614 properties: {
99615 enforceForOrderingRelations: {
99616 type: "boolean",
99617 default: false
99618 }
99619 },
99620 additionalProperties: false
99621 }],
99622 fixable: null,
99623 messages: {
99624 unexpected: "Unexpected negating the left operand of '{{operator}}' operator.",
99625 suggestNegatedExpression: "Negate '{{operator}}' expression instead of its left operand. This changes the current behavior.",
99626 suggestParenthesisedNegation: "Wrap negation in '()' to make the intention explicit. This preserves the current behavior."
99627 }
99628 },
99629
99630 create(context) {
99631 const sourceCode = context.getSourceCode();
99632 const options = context.options[0] || {};
99633 const enforceForOrderingRelations = options.enforceForOrderingRelations === true;
99634 return {
99635 BinaryExpression(node) {
99636 const operator = node.operator;
99637 const orderingRelationRuleApplies = enforceForOrderingRelations && isOrderingRelationalOperator(operator);
99638
99639 if ((isInOrInstanceOfOperator(operator) || orderingRelationRuleApplies) && isNegation(node.left) && !astUtils.isParenthesised(sourceCode, node.left)) {
99640 context.report({
99641 node,
99642 loc: node.left.loc,
99643 messageId: "unexpected",
99644 data: {
99645 operator
99646 },
99647 suggest: [{
99648 messageId: "suggestNegatedExpression",
99649 data: {
99650 operator
99651 },
99652
99653 fix(fixer) {
99654 const negationToken = sourceCode.getFirstToken(node.left);
99655 const fixRange = [negationToken.range[1], node.range[1]];
99656 const text = sourceCode.text.slice(fixRange[0], fixRange[1]);
99657 return fixer.replaceTextRange(fixRange, "(".concat(text, ")"));
99658 }
99659
99660 }, {
99661 messageId: "suggestParenthesisedNegation",
99662
99663 fix(fixer) {
99664 return fixer.replaceText(node.left, "(".concat(sourceCode.getText(node.left), ")"));
99665 }
99666
99667 }]
99668 });
99669 }
99670 }
99671
99672 };
99673 }
99674
99675 };
99676
99677 /***/ }),
99678 /* 770 */
99679 /***/ ((module) => {
99680
99681 "use strict";
99682 /**
99683 * @fileoverview Rule to disallow unsafe optional chaining
99684 * @author Yeon JuAn
99685 */
99686
99687
99688 const UNSAFE_ARITHMETIC_OPERATORS = new Set(["+", "-", "/", "*", "%", "**"]);
99689 const UNSAFE_ASSIGNMENT_OPERATORS = new Set(["+=", "-=", "/=", "*=", "%=", "**="]);
99690 const UNSAFE_RELATIONAL_OPERATORS = new Set(["in", "instanceof"]);
99691 /**
99692 * Checks whether a node is a destructuring pattern or not
99693 * @param {ASTNode} node node to check
99694 * @returns {boolean} `true` if a node is a destructuring pattern, otherwise `false`
99695 */
99696
99697 function isDestructuringPattern(node) {
99698 return node.type === "ObjectPattern" || node.type === "ArrayPattern";
99699 }
99700
99701 module.exports = {
99702 meta: {
99703 type: "problem",
99704 docs: {
99705 description: "disallow use of optional chaining in contexts where the `undefined` value is not allowed",
99706 recommended: true,
99707 url: "https://eslint.org/docs/rules/no-unsafe-optional-chaining"
99708 },
99709 schema: [{
99710 type: "object",
99711 properties: {
99712 disallowArithmeticOperators: {
99713 type: "boolean",
99714 default: false
99715 }
99716 },
99717 additionalProperties: false
99718 }],
99719 fixable: null,
99720 messages: {
99721 unsafeOptionalChain: "Unsafe usage of optional chaining. If it short-circuits with 'undefined' the evaluation will throw TypeError.",
99722 unsafeArithmetic: "Unsafe arithmetic operation on optional chaining. It can result in NaN."
99723 }
99724 },
99725
99726 create(context) {
99727 const options = context.options[0] || {};
99728 const disallowArithmeticOperators = options.disallowArithmeticOperators || false;
99729 /**
99730 * Reports unsafe usage of optional chaining
99731 * @param {ASTNode} node node to report
99732 * @returns {void}
99733 */
99734
99735 function reportUnsafeUsage(node) {
99736 context.report({
99737 messageId: "unsafeOptionalChain",
99738 node
99739 });
99740 }
99741 /**
99742 * Reports unsafe arithmetic operation on optional chaining
99743 * @param {ASTNode} node node to report
99744 * @returns {void}
99745 */
99746
99747
99748 function reportUnsafeArithmetic(node) {
99749 context.report({
99750 messageId: "unsafeArithmetic",
99751 node
99752 });
99753 }
99754 /**
99755 * Checks and reports if a node can short-circuit with `undefined` by optional chaining.
99756 * @param {ASTNode} [node] node to check
99757 * @param {Function} reportFunc report function
99758 * @returns {void}
99759 */
99760
99761
99762 function checkUndefinedShortCircuit(node, reportFunc) {
99763 if (!node) {
99764 return;
99765 }
99766
99767 switch (node.type) {
99768 case "LogicalExpression":
99769 if (node.operator === "||" || node.operator === "??") {
99770 checkUndefinedShortCircuit(node.right, reportFunc);
99771 } else if (node.operator === "&&") {
99772 checkUndefinedShortCircuit(node.left, reportFunc);
99773 checkUndefinedShortCircuit(node.right, reportFunc);
99774 }
99775
99776 break;
99777
99778 case "SequenceExpression":
99779 checkUndefinedShortCircuit(node.expressions[node.expressions.length - 1], reportFunc);
99780 break;
99781
99782 case "ConditionalExpression":
99783 checkUndefinedShortCircuit(node.consequent, reportFunc);
99784 checkUndefinedShortCircuit(node.alternate, reportFunc);
99785 break;
99786
99787 case "AwaitExpression":
99788 checkUndefinedShortCircuit(node.argument, reportFunc);
99789 break;
99790
99791 case "ChainExpression":
99792 reportFunc(node);
99793 break;
99794
99795 default:
99796 break;
99797 }
99798 }
99799 /**
99800 * Checks unsafe usage of optional chaining
99801 * @param {ASTNode} node node to check
99802 * @returns {void}
99803 */
99804
99805
99806 function checkUnsafeUsage(node) {
99807 checkUndefinedShortCircuit(node, reportUnsafeUsage);
99808 }
99809 /**
99810 * Checks unsafe arithmetic operations on optional chaining
99811 * @param {ASTNode} node node to check
99812 * @returns {void}
99813 */
99814
99815
99816 function checkUnsafeArithmetic(node) {
99817 checkUndefinedShortCircuit(node, reportUnsafeArithmetic);
99818 }
99819
99820 return {
99821 "AssignmentExpression, AssignmentPattern"(node) {
99822 if (isDestructuringPattern(node.left)) {
99823 checkUnsafeUsage(node.right);
99824 }
99825 },
99826
99827 "ClassDeclaration, ClassExpression"(node) {
99828 checkUnsafeUsage(node.superClass);
99829 },
99830
99831 CallExpression(node) {
99832 if (!node.optional) {
99833 checkUnsafeUsage(node.callee);
99834 }
99835 },
99836
99837 NewExpression(node) {
99838 checkUnsafeUsage(node.callee);
99839 },
99840
99841 VariableDeclarator(node) {
99842 if (isDestructuringPattern(node.id)) {
99843 checkUnsafeUsage(node.init);
99844 }
99845 },
99846
99847 MemberExpression(node) {
99848 if (!node.optional) {
99849 checkUnsafeUsage(node.object);
99850 }
99851 },
99852
99853 TaggedTemplateExpression(node) {
99854 checkUnsafeUsage(node.tag);
99855 },
99856
99857 ForOfStatement(node) {
99858 checkUnsafeUsage(node.right);
99859 },
99860
99861 SpreadElement(node) {
99862 if (node.parent && node.parent.type !== "ObjectExpression") {
99863 checkUnsafeUsage(node.argument);
99864 }
99865 },
99866
99867 BinaryExpression(node) {
99868 if (UNSAFE_RELATIONAL_OPERATORS.has(node.operator)) {
99869 checkUnsafeUsage(node.right);
99870 }
99871
99872 if (disallowArithmeticOperators && UNSAFE_ARITHMETIC_OPERATORS.has(node.operator)) {
99873 checkUnsafeArithmetic(node.right);
99874 checkUnsafeArithmetic(node.left);
99875 }
99876 },
99877
99878 WithStatement(node) {
99879 checkUnsafeUsage(node.object);
99880 },
99881
99882 UnaryExpression(node) {
99883 if (disallowArithmeticOperators && UNSAFE_ARITHMETIC_OPERATORS.has(node.operator)) {
99884 checkUnsafeArithmetic(node.argument);
99885 }
99886 },
99887
99888 AssignmentExpression(node) {
99889 if (disallowArithmeticOperators && UNSAFE_ASSIGNMENT_OPERATORS.has(node.operator)) {
99890 checkUnsafeArithmetic(node.right);
99891 }
99892 }
99893
99894 };
99895 }
99896
99897 };
99898
99899 /***/ }),
99900 /* 771 */
99901 /***/ ((module) => {
99902
99903 "use strict";
99904 /**
99905 * @fileoverview Flag expressions in statement position that do not side effect
99906 * @author Michael Ficarra
99907 */
99908 //------------------------------------------------------------------------------
99909 // Rule Definition
99910 //------------------------------------------------------------------------------
99911
99912 /**
99913 * Returns `true`.
99914 * @returns {boolean} `true`.
99915 */
99916
99917 function alwaysTrue() {
99918 return true;
99919 }
99920 /**
99921 * Returns `false`.
99922 * @returns {boolean} `false`.
99923 */
99924
99925
99926 function alwaysFalse() {
99927 return false;
99928 }
99929
99930 module.exports = {
99931 meta: {
99932 type: "suggestion",
99933 docs: {
99934 description: "disallow unused expressions",
99935 recommended: false,
99936 url: "https://eslint.org/docs/rules/no-unused-expressions"
99937 },
99938 schema: [{
99939 type: "object",
99940 properties: {
99941 allowShortCircuit: {
99942 type: "boolean",
99943 default: false
99944 },
99945 allowTernary: {
99946 type: "boolean",
99947 default: false
99948 },
99949 allowTaggedTemplates: {
99950 type: "boolean",
99951 default: false
99952 },
99953 enforceForJSX: {
99954 type: "boolean",
99955 default: false
99956 }
99957 },
99958 additionalProperties: false
99959 }],
99960 messages: {
99961 unusedExpression: "Expected an assignment or function call and instead saw an expression."
99962 }
99963 },
99964
99965 create(context) {
99966 const config = context.options[0] || {},
99967 allowShortCircuit = config.allowShortCircuit || false,
99968 allowTernary = config.allowTernary || false,
99969 allowTaggedTemplates = config.allowTaggedTemplates || false,
99970 enforceForJSX = config.enforceForJSX || false;
99971 /**
99972 * Has AST suggesting a directive.
99973 * @param {ASTNode} node any node
99974 * @returns {boolean} whether the given node structurally represents a directive
99975 */
99976
99977 function looksLikeDirective(node) {
99978 return node.type === "ExpressionStatement" && node.expression.type === "Literal" && typeof node.expression.value === "string";
99979 }
99980 /**
99981 * Gets the leading sequence of members in a list that pass the predicate.
99982 * @param {Function} predicate ([a] -> Boolean) the function used to make the determination
99983 * @param {a[]} list the input list
99984 * @returns {a[]} the leading sequence of members in the given list that pass the given predicate
99985 */
99986
99987
99988 function takeWhile(predicate, list) {
99989 for (let i = 0; i < list.length; ++i) {
99990 if (!predicate(list[i])) {
99991 return list.slice(0, i);
99992 }
99993 }
99994
99995 return list.slice();
99996 }
99997 /**
99998 * Gets leading directives nodes in a Node body.
99999 * @param {ASTNode} node a Program or BlockStatement node
100000 * @returns {ASTNode[]} the leading sequence of directive nodes in the given node's body
100001 */
100002
100003
100004 function directives(node) {
100005 return takeWhile(looksLikeDirective, node.body);
100006 }
100007 /**
100008 * Detect if a Node is a directive.
100009 * @param {ASTNode} node any node
100010 * @param {ASTNode[]} ancestors the given node's ancestors
100011 * @returns {boolean} whether the given node is considered a directive in its current position
100012 */
100013
100014
100015 function isDirective(node, ancestors) {
100016 const parent = ancestors[ancestors.length - 1],
100017 grandparent = ancestors[ancestors.length - 2];
100018 /**
100019 * https://tc39.es/ecma262/#directive-prologue
100020 *
100021 * Only `FunctionBody`, `ScriptBody` and `ModuleBody` can have directive prologue.
100022 * Class static blocks do not have directive prologue.
100023 */
100024
100025 return (parent.type === "Program" || parent.type === "BlockStatement" && /Function/u.test(grandparent.type)) && directives(parent).indexOf(node) >= 0;
100026 }
100027 /**
100028 * The member functions return `true` if the type has no side-effects.
100029 * Unknown nodes are handled as `false`, then this rule ignores those.
100030 */
100031
100032
100033 const Checker = Object.assign(Object.create(null), {
100034 isDisallowed(node) {
100035 return (Checker[node.type] || alwaysFalse)(node);
100036 },
100037
100038 ArrayExpression: alwaysTrue,
100039 ArrowFunctionExpression: alwaysTrue,
100040 BinaryExpression: alwaysTrue,
100041
100042 ChainExpression(node) {
100043 return Checker.isDisallowed(node.expression);
100044 },
100045
100046 ClassExpression: alwaysTrue,
100047
100048 ConditionalExpression(node) {
100049 if (allowTernary) {
100050 return Checker.isDisallowed(node.consequent) || Checker.isDisallowed(node.alternate);
100051 }
100052
100053 return true;
100054 },
100055
100056 FunctionExpression: alwaysTrue,
100057 Identifier: alwaysTrue,
100058
100059 JSXElement() {
100060 return enforceForJSX;
100061 },
100062
100063 JSXFragment() {
100064 return enforceForJSX;
100065 },
100066
100067 Literal: alwaysTrue,
100068
100069 LogicalExpression(node) {
100070 if (allowShortCircuit) {
100071 return Checker.isDisallowed(node.right);
100072 }
100073
100074 return true;
100075 },
100076
100077 MemberExpression: alwaysTrue,
100078 MetaProperty: alwaysTrue,
100079 ObjectExpression: alwaysTrue,
100080 SequenceExpression: alwaysTrue,
100081
100082 TaggedTemplateExpression() {
100083 return !allowTaggedTemplates;
100084 },
100085
100086 TemplateLiteral: alwaysTrue,
100087 ThisExpression: alwaysTrue,
100088
100089 UnaryExpression(node) {
100090 return node.operator !== "void" && node.operator !== "delete";
100091 }
100092
100093 });
100094 return {
100095 ExpressionStatement(node) {
100096 if (Checker.isDisallowed(node.expression) && !isDirective(node, context.getAncestors())) {
100097 context.report({
100098 node,
100099 messageId: "unusedExpression"
100100 });
100101 }
100102 }
100103
100104 };
100105 }
100106
100107 };
100108
100109 /***/ }),
100110 /* 772 */
100111 /***/ ((module) => {
100112
100113 "use strict";
100114 /**
100115 * @fileoverview Rule to disallow unused labels.
100116 * @author Toru Nagashima
100117 */
100118 //------------------------------------------------------------------------------
100119 // Rule Definition
100120 //------------------------------------------------------------------------------
100121
100122 module.exports = {
100123 meta: {
100124 type: "suggestion",
100125 docs: {
100126 description: "disallow unused labels",
100127 recommended: true,
100128 url: "https://eslint.org/docs/rules/no-unused-labels"
100129 },
100130 schema: [],
100131 fixable: "code",
100132 messages: {
100133 unused: "'{{name}}:' is defined but never used."
100134 }
100135 },
100136
100137 create(context) {
100138 const sourceCode = context.getSourceCode();
100139 let scopeInfo = null;
100140 /**
100141 * Adds a scope info to the stack.
100142 * @param {ASTNode} node A node to add. This is a LabeledStatement.
100143 * @returns {void}
100144 */
100145
100146 function enterLabeledScope(node) {
100147 scopeInfo = {
100148 label: node.label.name,
100149 used: false,
100150 upper: scopeInfo
100151 };
100152 }
100153 /**
100154 * Removes the top of the stack.
100155 * At the same time, this reports the label if it's never used.
100156 * @param {ASTNode} node A node to report. This is a LabeledStatement.
100157 * @returns {void}
100158 */
100159
100160
100161 function exitLabeledScope(node) {
100162 if (!scopeInfo.used) {
100163 context.report({
100164 node: node.label,
100165 messageId: "unused",
100166 data: node.label,
100167
100168 fix(fixer) {
100169 /*
100170 * Only perform a fix if there are no comments between the label and the body. This will be the case
100171 * when there is exactly one token/comment (the ":") between the label and the body.
100172 */
100173 if (sourceCode.getTokenAfter(node.label, {
100174 includeComments: true
100175 }) === sourceCode.getTokenBefore(node.body, {
100176 includeComments: true
100177 })) {
100178 return fixer.removeRange([node.range[0], node.body.range[0]]);
100179 }
100180
100181 return null;
100182 }
100183
100184 });
100185 }
100186
100187 scopeInfo = scopeInfo.upper;
100188 }
100189 /**
100190 * Marks the label of a given node as used.
100191 * @param {ASTNode} node A node to mark. This is a BreakStatement or
100192 * ContinueStatement.
100193 * @returns {void}
100194 */
100195
100196
100197 function markAsUsed(node) {
100198 if (!node.label) {
100199 return;
100200 }
100201
100202 const label = node.label.name;
100203 let info = scopeInfo;
100204
100205 while (info) {
100206 if (info.label === label) {
100207 info.used = true;
100208 break;
100209 }
100210
100211 info = info.upper;
100212 }
100213 }
100214
100215 return {
100216 LabeledStatement: enterLabeledScope,
100217 "LabeledStatement:exit": exitLabeledScope,
100218 BreakStatement: markAsUsed,
100219 ContinueStatement: markAsUsed
100220 };
100221 }
100222
100223 };
100224
100225 /***/ }),
100226 /* 773 */
100227 /***/ ((module) => {
100228
100229 "use strict";
100230 /**
100231 * @fileoverview Rule to flag declared but unused private class members
100232 * @author Tim van der Lippe
100233 */
100234 //------------------------------------------------------------------------------
100235 // Rule Definition
100236 //------------------------------------------------------------------------------
100237
100238 module.exports = {
100239 meta: {
100240 type: "problem",
100241 docs: {
100242 description: "disallow unused private class members",
100243 recommended: false,
100244 url: "https://eslint.org/docs/rules/no-unused-private-class-members"
100245 },
100246 schema: [],
100247 messages: {
100248 unusedPrivateClassMember: "'{{classMemberName}}' is defined but never used."
100249 }
100250 },
100251
100252 create(context) {
100253 const trackedClasses = [];
100254 /**
100255 * Check whether the current node is in a write only assignment.
100256 * @param {ASTNode} privateIdentifierNode Node referring to a private identifier
100257 * @returns {boolean} Whether the node is in a write only assignment
100258 * @private
100259 */
100260
100261 function isWriteOnlyAssignment(privateIdentifierNode) {
100262 const parentStatement = privateIdentifierNode.parent.parent;
100263 const isAssignmentExpression = parentStatement.type === "AssignmentExpression";
100264
100265 if (!isAssignmentExpression && parentStatement.type !== "ForInStatement" && parentStatement.type !== "ForOfStatement" && parentStatement.type !== "AssignmentPattern") {
100266 return false;
100267 } // It is a write-only usage, since we still allow usages on the right for reads
100268
100269
100270 if (parentStatement.left !== privateIdentifierNode.parent) {
100271 return false;
100272 } // For any other operator (such as '+=') we still consider it a read operation
100273
100274
100275 if (isAssignmentExpression && parentStatement.operator !== "=") {
100276 /*
100277 * However, if the read operation is "discarded" in an empty statement, then
100278 * we consider it write only.
100279 */
100280 return parentStatement.parent.type === "ExpressionStatement";
100281 }
100282
100283 return true;
100284 } //--------------------------------------------------------------------------
100285 // Public
100286 //--------------------------------------------------------------------------
100287
100288
100289 return {
100290 // Collect all declared members up front and assume they are all unused
100291 ClassBody(classBodyNode) {
100292 const privateMembers = new Map();
100293 trackedClasses.unshift(privateMembers);
100294
100295 for (const bodyMember of classBodyNode.body) {
100296 if (bodyMember.type === "PropertyDefinition" || bodyMember.type === "MethodDefinition") {
100297 if (bodyMember.key.type === "PrivateIdentifier") {
100298 privateMembers.set(bodyMember.key.name, {
100299 declaredNode: bodyMember,
100300 isAccessor: bodyMember.type === "MethodDefinition" && (bodyMember.kind === "set" || bodyMember.kind === "get")
100301 });
100302 }
100303 }
100304 }
100305 },
100306
100307 /*
100308 * Process all usages of the private identifier and remove a member from
100309 * `declaredAndUnusedPrivateMembers` if we deem it used.
100310 */
100311 PrivateIdentifier(privateIdentifierNode) {
100312 const classBody = trackedClasses.find(classProperties => classProperties.has(privateIdentifierNode.name)); // Can't happen, as it is a parser to have a missing class body, but let's code defensively here.
100313
100314 if (!classBody) {
100315 return;
100316 } // In case any other usage was already detected, we can short circuit the logic here.
100317
100318
100319 const memberDefinition = classBody.get(privateIdentifierNode.name);
100320
100321 if (memberDefinition.isUsed) {
100322 return;
100323 } // The definition of the class member itself
100324
100325
100326 if (privateIdentifierNode.parent.type === "PropertyDefinition" || privateIdentifierNode.parent.type === "MethodDefinition") {
100327 return;
100328 }
100329 /*
100330 * Any usage of an accessor is considered a read, as the getter/setter can have
100331 * side-effects in its definition.
100332 */
100333
100334
100335 if (memberDefinition.isAccessor) {
100336 memberDefinition.isUsed = true;
100337 return;
100338 } // Any assignments to this member, except for assignments that also read
100339
100340
100341 if (isWriteOnlyAssignment(privateIdentifierNode)) {
100342 return;
100343 }
100344
100345 const wrappingExpressionType = privateIdentifierNode.parent.parent.type;
100346 const parentOfWrappingExpressionType = privateIdentifierNode.parent.parent.parent.type; // A statement which only increments (`this.#x++;`)
100347
100348 if (wrappingExpressionType === "UpdateExpression" && parentOfWrappingExpressionType === "ExpressionStatement") {
100349 return;
100350 }
100351 /*
100352 * ({ x: this.#usedInDestructuring } = bar);
100353 *
100354 * But should treat the following as a read:
100355 * ({ [this.#x]: a } = foo);
100356 */
100357
100358
100359 if (wrappingExpressionType === "Property" && parentOfWrappingExpressionType === "ObjectPattern" && privateIdentifierNode.parent.parent.value === privateIdentifierNode.parent) {
100360 return;
100361 } // [...this.#unusedInRestPattern] = bar;
100362
100363
100364 if (wrappingExpressionType === "RestElement") {
100365 return;
100366 } // [this.#unusedInAssignmentPattern] = bar;
100367
100368
100369 if (wrappingExpressionType === "ArrayPattern") {
100370 return;
100371 }
100372 /*
100373 * We can't delete the memberDefinition, as we need to keep track of which member we are marking as used.
100374 * In the case of nested classes, we only mark the first member we encounter as used. If you were to delete
100375 * the member, then any subsequent usage could incorrectly mark the member of an encapsulating parent class
100376 * as used, which is incorrect.
100377 */
100378
100379
100380 memberDefinition.isUsed = true;
100381 },
100382
100383 /*
100384 * Post-process the class members and report any remaining members.
100385 * Since private members can only be accessed in the current class context,
100386 * we can safely assume that all usages are within the current class body.
100387 */
100388 "ClassBody:exit"() {
100389 const unusedPrivateMembers = trackedClasses.shift();
100390
100391 for (const [classMemberName, {
100392 declaredNode,
100393 isUsed
100394 }] of unusedPrivateMembers.entries()) {
100395 if (isUsed) {
100396 continue;
100397 }
100398
100399 context.report({
100400 node: declaredNode,
100401 loc: declaredNode.key.loc,
100402 messageId: "unusedPrivateClassMember",
100403 data: {
100404 classMemberName: "#".concat(classMemberName)
100405 }
100406 });
100407 }
100408 }
100409
100410 };
100411 }
100412
100413 };
100414
100415 /***/ }),
100416 /* 774 */
100417 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
100418
100419 "use strict";
100420 /**
100421 * @fileoverview Rule to flag declared but unused variables
100422 * @author Ilya Volodin
100423 */
100424 //------------------------------------------------------------------------------
100425 // Requirements
100426 //------------------------------------------------------------------------------
100427
100428 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
100429 // Typedefs
100430 //------------------------------------------------------------------------------
100431
100432 /**
100433 * Bag of data used for formatting the `unusedVar` lint message.
100434 * @typedef {Object} UnusedVarMessageData
100435 * @property {string} varName The name of the unused var.
100436 * @property {'defined'|'assigned a value'} action Description of the vars state.
100437 * @property {string} additional Any additional info to be appended at the end.
100438 */
100439 //------------------------------------------------------------------------------
100440 // Rule Definition
100441 //------------------------------------------------------------------------------
100442
100443
100444 module.exports = {
100445 meta: {
100446 type: "problem",
100447 docs: {
100448 description: "disallow unused variables",
100449 recommended: true,
100450 url: "https://eslint.org/docs/rules/no-unused-vars"
100451 },
100452 schema: [{
100453 oneOf: [{
100454 enum: ["all", "local"]
100455 }, {
100456 type: "object",
100457 properties: {
100458 vars: {
100459 enum: ["all", "local"]
100460 },
100461 varsIgnorePattern: {
100462 type: "string"
100463 },
100464 args: {
100465 enum: ["all", "after-used", "none"]
100466 },
100467 ignoreRestSiblings: {
100468 type: "boolean"
100469 },
100470 argsIgnorePattern: {
100471 type: "string"
100472 },
100473 caughtErrors: {
100474 enum: ["all", "none"]
100475 },
100476 caughtErrorsIgnorePattern: {
100477 type: "string"
100478 }
100479 },
100480 additionalProperties: false
100481 }]
100482 }],
100483 messages: {
100484 unusedVar: "'{{varName}}' is {{action}} but never used{{additional}}."
100485 }
100486 },
100487
100488 create(context) {
100489 const sourceCode = context.getSourceCode();
100490 const REST_PROPERTY_TYPE = /^(?:RestElement|(?:Experimental)?RestProperty)$/u;
100491 const config = {
100492 vars: "all",
100493 args: "after-used",
100494 ignoreRestSiblings: false,
100495 caughtErrors: "none"
100496 };
100497 const firstOption = context.options[0];
100498
100499 if (firstOption) {
100500 if (typeof firstOption === "string") {
100501 config.vars = firstOption;
100502 } else {
100503 config.vars = firstOption.vars || config.vars;
100504 config.args = firstOption.args || config.args;
100505 config.ignoreRestSiblings = firstOption.ignoreRestSiblings || config.ignoreRestSiblings;
100506 config.caughtErrors = firstOption.caughtErrors || config.caughtErrors;
100507
100508 if (firstOption.varsIgnorePattern) {
100509 config.varsIgnorePattern = new RegExp(firstOption.varsIgnorePattern, "u");
100510 }
100511
100512 if (firstOption.argsIgnorePattern) {
100513 config.argsIgnorePattern = new RegExp(firstOption.argsIgnorePattern, "u");
100514 }
100515
100516 if (firstOption.caughtErrorsIgnorePattern) {
100517 config.caughtErrorsIgnorePattern = new RegExp(firstOption.caughtErrorsIgnorePattern, "u");
100518 }
100519 }
100520 }
100521 /**
100522 * Generates the message data about the variable being defined and unused,
100523 * including the ignore pattern if configured.
100524 * @param {Variable} unusedVar eslint-scope variable object.
100525 * @returns {UnusedVarMessageData} The message data to be used with this unused variable.
100526 */
100527
100528
100529 function getDefinedMessageData(unusedVar) {
100530 const defType = unusedVar.defs && unusedVar.defs[0] && unusedVar.defs[0].type;
100531 let type;
100532 let pattern;
100533
100534 if (defType === "CatchClause" && config.caughtErrorsIgnorePattern) {
100535 type = "args";
100536 pattern = config.caughtErrorsIgnorePattern.toString();
100537 } else if (defType === "Parameter" && config.argsIgnorePattern) {
100538 type = "args";
100539 pattern = config.argsIgnorePattern.toString();
100540 } else if (defType !== "Parameter" && config.varsIgnorePattern) {
100541 type = "vars";
100542 pattern = config.varsIgnorePattern.toString();
100543 }
100544
100545 const additional = type ? ". Allowed unused ".concat(type, " must match ").concat(pattern) : "";
100546 return {
100547 varName: unusedVar.name,
100548 action: "defined",
100549 additional
100550 };
100551 }
100552 /**
100553 * Generate the warning message about the variable being
100554 * assigned and unused, including the ignore pattern if configured.
100555 * @param {Variable} unusedVar eslint-scope variable object.
100556 * @returns {UnusedVarMessageData} The message data to be used with this unused variable.
100557 */
100558
100559
100560 function getAssignedMessageData(unusedVar) {
100561 const additional = config.varsIgnorePattern ? ". Allowed unused vars must match ".concat(config.varsIgnorePattern.toString()) : "";
100562 return {
100563 varName: unusedVar.name,
100564 action: "assigned a value",
100565 additional
100566 };
100567 } //--------------------------------------------------------------------------
100568 // Helpers
100569 //--------------------------------------------------------------------------
100570
100571
100572 const STATEMENT_TYPE = /(?:Statement|Declaration)$/u;
100573 /**
100574 * Determines if a given variable is being exported from a module.
100575 * @param {Variable} variable eslint-scope variable object.
100576 * @returns {boolean} True if the variable is exported, false if not.
100577 * @private
100578 */
100579
100580 function isExported(variable) {
100581 const definition = variable.defs[0];
100582
100583 if (definition) {
100584 let node = definition.node;
100585
100586 if (node.type === "VariableDeclarator") {
100587 node = node.parent;
100588 } else if (definition.type === "Parameter") {
100589 return false;
100590 }
100591
100592 return node.parent.type.indexOf("Export") === 0;
100593 }
100594
100595 return false;
100596 }
100597 /**
100598 * Checks whether a node is a sibling of the rest property or not.
100599 * @param {ASTNode} node a node to check
100600 * @returns {boolean} True if the node is a sibling of the rest property, otherwise false.
100601 */
100602
100603
100604 function hasRestSibling(node) {
100605 return node.type === "Property" && node.parent.type === "ObjectPattern" && REST_PROPERTY_TYPE.test(node.parent.properties[node.parent.properties.length - 1].type);
100606 }
100607 /**
100608 * Determines if a variable has a sibling rest property
100609 * @param {Variable} variable eslint-scope variable object.
100610 * @returns {boolean} True if the variable is exported, false if not.
100611 * @private
100612 */
100613
100614
100615 function hasRestSpreadSibling(variable) {
100616 if (config.ignoreRestSiblings) {
100617 const hasRestSiblingDefinition = variable.defs.some(def => hasRestSibling(def.name.parent));
100618 const hasRestSiblingReference = variable.references.some(ref => hasRestSibling(ref.identifier.parent));
100619 return hasRestSiblingDefinition || hasRestSiblingReference;
100620 }
100621
100622 return false;
100623 }
100624 /**
100625 * Determines if a reference is a read operation.
100626 * @param {Reference} ref An eslint-scope Reference
100627 * @returns {boolean} whether the given reference represents a read operation
100628 * @private
100629 */
100630
100631
100632 function isReadRef(ref) {
100633 return ref.isRead();
100634 }
100635 /**
100636 * Determine if an identifier is referencing an enclosing function name.
100637 * @param {Reference} ref The reference to check.
100638 * @param {ASTNode[]} nodes The candidate function nodes.
100639 * @returns {boolean} True if it's a self-reference, false if not.
100640 * @private
100641 */
100642
100643
100644 function isSelfReference(ref, nodes) {
100645 let scope = ref.from;
100646
100647 while (scope) {
100648 if (nodes.indexOf(scope.block) >= 0) {
100649 return true;
100650 }
100651
100652 scope = scope.upper;
100653 }
100654
100655 return false;
100656 }
100657 /**
100658 * Gets a list of function definitions for a specified variable.
100659 * @param {Variable} variable eslint-scope variable object.
100660 * @returns {ASTNode[]} Function nodes.
100661 * @private
100662 */
100663
100664
100665 function getFunctionDefinitions(variable) {
100666 const functionDefinitions = [];
100667 variable.defs.forEach(def => {
100668 const {
100669 type,
100670 node
100671 } = def; // FunctionDeclarations
100672
100673 if (type === "FunctionName") {
100674 functionDefinitions.push(node);
100675 } // FunctionExpressions
100676
100677
100678 if (type === "Variable" && node.init && (node.init.type === "FunctionExpression" || node.init.type === "ArrowFunctionExpression")) {
100679 functionDefinitions.push(node.init);
100680 }
100681 });
100682 return functionDefinitions;
100683 }
100684 /**
100685 * Checks the position of given nodes.
100686 * @param {ASTNode} inner A node which is expected as inside.
100687 * @param {ASTNode} outer A node which is expected as outside.
100688 * @returns {boolean} `true` if the `inner` node exists in the `outer` node.
100689 * @private
100690 */
100691
100692
100693 function isInside(inner, outer) {
100694 return inner.range[0] >= outer.range[0] && inner.range[1] <= outer.range[1];
100695 }
100696 /**
100697 * Checks whether a given node is unused expression or not.
100698 * @param {ASTNode} node The node itself
100699 * @returns {boolean} The node is an unused expression.
100700 * @private
100701 */
100702
100703
100704 function isUnusedExpression(node) {
100705 const parent = node.parent;
100706
100707 if (parent.type === "ExpressionStatement") {
100708 return true;
100709 }
100710
100711 if (parent.type === "SequenceExpression") {
100712 const isLastExpression = parent.expressions[parent.expressions.length - 1] === node;
100713
100714 if (!isLastExpression) {
100715 return true;
100716 }
100717
100718 return isUnusedExpression(parent);
100719 }
100720
100721 return false;
100722 }
100723 /**
100724 * If a given reference is left-hand side of an assignment, this gets
100725 * the right-hand side node of the assignment.
100726 *
100727 * In the following cases, this returns null.
100728 *
100729 * - The reference is not the LHS of an assignment expression.
100730 * - The reference is inside of a loop.
100731 * - The reference is inside of a function scope which is different from
100732 * the declaration.
100733 * @param {eslint-scope.Reference} ref A reference to check.
100734 * @param {ASTNode} prevRhsNode The previous RHS node.
100735 * @returns {ASTNode|null} The RHS node or null.
100736 * @private
100737 */
100738
100739
100740 function getRhsNode(ref, prevRhsNode) {
100741 const id = ref.identifier;
100742 const parent = id.parent;
100743 const refScope = ref.from.variableScope;
100744 const varScope = ref.resolved.scope.variableScope;
100745 const canBeUsedLater = refScope !== varScope || astUtils.isInLoop(id);
100746 /*
100747 * Inherits the previous node if this reference is in the node.
100748 * This is for `a = a + a`-like code.
100749 */
100750
100751 if (prevRhsNode && isInside(id, prevRhsNode)) {
100752 return prevRhsNode;
100753 }
100754
100755 if (parent.type === "AssignmentExpression" && isUnusedExpression(parent) && id === parent.left && !canBeUsedLater) {
100756 return parent.right;
100757 }
100758
100759 return null;
100760 }
100761 /**
100762 * Checks whether a given function node is stored to somewhere or not.
100763 * If the function node is stored, the function can be used later.
100764 * @param {ASTNode} funcNode A function node to check.
100765 * @param {ASTNode} rhsNode The RHS node of the previous assignment.
100766 * @returns {boolean} `true` if under the following conditions:
100767 * - the funcNode is assigned to a variable.
100768 * - the funcNode is bound as an argument of a function call.
100769 * - the function is bound to a property and the object satisfies above conditions.
100770 * @private
100771 */
100772
100773
100774 function isStorableFunction(funcNode, rhsNode) {
100775 let node = funcNode;
100776 let parent = funcNode.parent;
100777
100778 while (parent && isInside(parent, rhsNode)) {
100779 switch (parent.type) {
100780 case "SequenceExpression":
100781 if (parent.expressions[parent.expressions.length - 1] !== node) {
100782 return false;
100783 }
100784
100785 break;
100786
100787 case "CallExpression":
100788 case "NewExpression":
100789 return parent.callee !== node;
100790
100791 case "AssignmentExpression":
100792 case "TaggedTemplateExpression":
100793 case "YieldExpression":
100794 return true;
100795
100796 default:
100797 if (STATEMENT_TYPE.test(parent.type)) {
100798 /*
100799 * If it encountered statements, this is a complex pattern.
100800 * Since analyzing complex patterns is hard, this returns `true` to avoid false positive.
100801 */
100802 return true;
100803 }
100804
100805 }
100806
100807 node = parent;
100808 parent = parent.parent;
100809 }
100810
100811 return false;
100812 }
100813 /**
100814 * Checks whether a given Identifier node exists inside of a function node which can be used later.
100815 *
100816 * "can be used later" means:
100817 * - the function is assigned to a variable.
100818 * - the function is bound to a property and the object can be used later.
100819 * - the function is bound as an argument of a function call.
100820 *
100821 * If a reference exists in a function which can be used later, the reference is read when the function is called.
100822 * @param {ASTNode} id An Identifier node to check.
100823 * @param {ASTNode} rhsNode The RHS node of the previous assignment.
100824 * @returns {boolean} `true` if the `id` node exists inside of a function node which can be used later.
100825 * @private
100826 */
100827
100828
100829 function isInsideOfStorableFunction(id, rhsNode) {
100830 const funcNode = astUtils.getUpperFunction(id);
100831 return funcNode && isInside(funcNode, rhsNode) && isStorableFunction(funcNode, rhsNode);
100832 }
100833 /**
100834 * Checks whether a given reference is a read to update itself or not.
100835 * @param {eslint-scope.Reference} ref A reference to check.
100836 * @param {ASTNode} rhsNode The RHS node of the previous assignment.
100837 * @returns {boolean} The reference is a read to update itself.
100838 * @private
100839 */
100840
100841
100842 function isReadForItself(ref, rhsNode) {
100843 const id = ref.identifier;
100844 const parent = id.parent;
100845 return ref.isRead() && ( // self update. e.g. `a += 1`, `a++`
100846 parent.type === "AssignmentExpression" && parent.left === id && isUnusedExpression(parent) || parent.type === "UpdateExpression" && isUnusedExpression(parent) || // in RHS of an assignment for itself. e.g. `a = a + 1`
100847 rhsNode && isInside(id, rhsNode) && !isInsideOfStorableFunction(id, rhsNode));
100848 }
100849 /**
100850 * Determine if an identifier is used either in for-in loops.
100851 * @param {Reference} ref The reference to check.
100852 * @returns {boolean} whether reference is used in the for-in loops
100853 * @private
100854 */
100855
100856
100857 function isForInRef(ref) {
100858 let target = ref.identifier.parent; // "for (var ...) { return; }"
100859
100860 if (target.type === "VariableDeclarator") {
100861 target = target.parent.parent;
100862 }
100863
100864 if (target.type !== "ForInStatement") {
100865 return false;
100866 } // "for (...) { return; }"
100867
100868
100869 if (target.body.type === "BlockStatement") {
100870 target = target.body.body[0]; // "for (...) return;"
100871 } else {
100872 target = target.body;
100873 } // For empty loop body
100874
100875
100876 if (!target) {
100877 return false;
100878 }
100879
100880 return target.type === "ReturnStatement";
100881 }
100882 /**
100883 * Determines if the variable is used.
100884 * @param {Variable} variable The variable to check.
100885 * @returns {boolean} True if the variable is used
100886 * @private
100887 */
100888
100889
100890 function isUsedVariable(variable) {
100891 const functionNodes = getFunctionDefinitions(variable),
100892 isFunctionDefinition = functionNodes.length > 0;
100893 let rhsNode = null;
100894 return variable.references.some(ref => {
100895 if (isForInRef(ref)) {
100896 return true;
100897 }
100898
100899 const forItself = isReadForItself(ref, rhsNode);
100900 rhsNode = getRhsNode(ref, rhsNode);
100901 return isReadRef(ref) && !forItself && !(isFunctionDefinition && isSelfReference(ref, functionNodes));
100902 });
100903 }
100904 /**
100905 * Checks whether the given variable is after the last used parameter.
100906 * @param {eslint-scope.Variable} variable The variable to check.
100907 * @returns {boolean} `true` if the variable is defined after the last
100908 * used parameter.
100909 */
100910
100911
100912 function isAfterLastUsedArg(variable) {
100913 const def = variable.defs[0];
100914 const params = context.getDeclaredVariables(def.node);
100915 const posteriorParams = params.slice(params.indexOf(variable) + 1); // If any used parameters occur after this parameter, do not report.
100916
100917 return !posteriorParams.some(v => v.references.length > 0 || v.eslintUsed);
100918 }
100919 /**
100920 * Gets an array of variables without read references.
100921 * @param {Scope} scope an eslint-scope Scope object.
100922 * @param {Variable[]} unusedVars an array that saving result.
100923 * @returns {Variable[]} unused variables of the scope and descendant scopes.
100924 * @private
100925 */
100926
100927
100928 function collectUnusedVariables(scope, unusedVars) {
100929 const variables = scope.variables;
100930 const childScopes = scope.childScopes;
100931 let i, l;
100932
100933 if (scope.type !== "global" || config.vars === "all") {
100934 for (i = 0, l = variables.length; i < l; ++i) {
100935 const variable = variables[i]; // skip a variable of class itself name in the class scope
100936
100937 if (scope.type === "class" && scope.block.id === variable.identifiers[0]) {
100938 continue;
100939 } // skip function expression names and variables marked with markVariableAsUsed()
100940
100941
100942 if (scope.functionExpressionScope || variable.eslintUsed) {
100943 continue;
100944 } // skip implicit "arguments" variable
100945
100946
100947 if (scope.type === "function" && variable.name === "arguments" && variable.identifiers.length === 0) {
100948 continue;
100949 } // explicit global variables don't have definitions.
100950
100951
100952 const def = variable.defs[0];
100953
100954 if (def) {
100955 const type = def.type; // skip catch variables
100956
100957 if (type === "CatchClause") {
100958 if (config.caughtErrors === "none") {
100959 continue;
100960 } // skip ignored parameters
100961
100962
100963 if (config.caughtErrorsIgnorePattern && config.caughtErrorsIgnorePattern.test(def.name.name)) {
100964 continue;
100965 }
100966 }
100967
100968 if (type === "Parameter") {
100969 // skip any setter argument
100970 if ((def.node.parent.type === "Property" || def.node.parent.type === "MethodDefinition") && def.node.parent.kind === "set") {
100971 continue;
100972 } // if "args" option is "none", skip any parameter
100973
100974
100975 if (config.args === "none") {
100976 continue;
100977 } // skip ignored parameters
100978
100979
100980 if (config.argsIgnorePattern && config.argsIgnorePattern.test(def.name.name)) {
100981 continue;
100982 } // if "args" option is "after-used", skip used variables
100983
100984
100985 if (config.args === "after-used" && astUtils.isFunction(def.name.parent) && !isAfterLastUsedArg(variable)) {
100986 continue;
100987 }
100988 } else {
100989 // skip ignored variables
100990 if (config.varsIgnorePattern && config.varsIgnorePattern.test(def.name.name)) {
100991 continue;
100992 }
100993 }
100994 }
100995
100996 if (!isUsedVariable(variable) && !isExported(variable) && !hasRestSpreadSibling(variable)) {
100997 unusedVars.push(variable);
100998 }
100999 }
101000 }
101001
101002 for (i = 0, l = childScopes.length; i < l; ++i) {
101003 collectUnusedVariables(childScopes[i], unusedVars);
101004 }
101005
101006 return unusedVars;
101007 } //--------------------------------------------------------------------------
101008 // Public
101009 //--------------------------------------------------------------------------
101010
101011
101012 return {
101013 "Program:exit"(programNode) {
101014 const unusedVars = collectUnusedVariables(context.getScope(), []);
101015
101016 for (let i = 0, l = unusedVars.length; i < l; ++i) {
101017 const unusedVar = unusedVars[i]; // Report the first declaration.
101018
101019 if (unusedVar.defs.length > 0) {
101020 // report last write reference, https://github.com/eslint/eslint/issues/14324
101021 const writeReferences = unusedVar.references.filter(ref => ref.isWrite() && ref.from.variableScope === unusedVar.scope.variableScope);
101022 let referenceToReport;
101023
101024 if (writeReferences.length > 0) {
101025 referenceToReport = writeReferences[writeReferences.length - 1];
101026 }
101027
101028 context.report({
101029 node: referenceToReport ? referenceToReport.identifier : unusedVar.identifiers[0],
101030 messageId: "unusedVar",
101031 data: unusedVar.references.some(ref => ref.isWrite()) ? getAssignedMessageData(unusedVar) : getDefinedMessageData(unusedVar)
101032 }); // If there are no regular declaration, report the first `/*globals*/` comment directive.
101033 } else if (unusedVar.eslintExplicitGlobalComments) {
101034 const directiveComment = unusedVar.eslintExplicitGlobalComments[0];
101035 context.report({
101036 node: programNode,
101037 loc: astUtils.getNameLocationInGlobalDirectiveComment(sourceCode, directiveComment, unusedVar.name),
101038 messageId: "unusedVar",
101039 data: getDefinedMessageData(unusedVar)
101040 });
101041 }
101042 }
101043 }
101044
101045 };
101046 }
101047
101048 };
101049
101050 /***/ }),
101051 /* 775 */
101052 /***/ ((module) => {
101053
101054 "use strict";
101055 /**
101056 * @fileoverview Rule to flag use of variables before they are defined
101057 * @author Ilya Volodin
101058 */
101059 //------------------------------------------------------------------------------
101060 // Helpers
101061 //------------------------------------------------------------------------------
101062
101063 const SENTINEL_TYPE = /^(?:(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|CatchClause|ImportDeclaration|ExportNamedDeclaration)$/u;
101064 const FOR_IN_OF_TYPE = /^For(?:In|Of)Statement$/u;
101065 /**
101066 * Parses a given value as options.
101067 * @param {any} options A value to parse.
101068 * @returns {Object} The parsed options.
101069 */
101070
101071 function parseOptions(options) {
101072 let functions = true;
101073 let classes = true;
101074 let variables = true;
101075
101076 if (typeof options === "string") {
101077 functions = options !== "nofunc";
101078 } else if (typeof options === "object" && options !== null) {
101079 functions = options.functions !== false;
101080 classes = options.classes !== false;
101081 variables = options.variables !== false;
101082 }
101083
101084 return {
101085 functions,
101086 classes,
101087 variables
101088 };
101089 }
101090 /**
101091 * Checks whether or not a given location is inside of the range of a given node.
101092 * @param {ASTNode} node An node to check.
101093 * @param {number} location A location to check.
101094 * @returns {boolean} `true` if the location is inside of the range of the node.
101095 */
101096
101097
101098 function isInRange(node, location) {
101099 return node && node.range[0] <= location && location <= node.range[1];
101100 }
101101 /**
101102 * Checks whether or not a given location is inside of the range of a class static initializer.
101103 * Static initializers are static blocks and initializers of static fields.
101104 * @param {ASTNode} node `ClassBody` node to check static initializers.
101105 * @param {number} location A location to check.
101106 * @returns {boolean} `true` if the location is inside of a class static initializer.
101107 */
101108
101109
101110 function isInClassStaticInitializerRange(node, location) {
101111 return node.body.some(classMember => classMember.type === "StaticBlock" && isInRange(classMember, location) || classMember.type === "PropertyDefinition" && classMember.static && classMember.value && isInRange(classMember.value, location));
101112 }
101113 /**
101114 * Checks whether a given scope is the scope of a a class static initializer.
101115 * Static initializers are static blocks and initializers of static fields.
101116 * @param {eslint-scope.Scope} scope A scope to check.
101117 * @returns {boolean} `true` if the scope is a class static initializer scope.
101118 */
101119
101120
101121 function isClassStaticInitializerScope(scope) {
101122 if (scope.type === "class-static-block") {
101123 return true;
101124 }
101125
101126 if (scope.type === "class-field-initializer") {
101127 // `scope.block` is PropertyDefinition#value node
101128 const propertyDefinition = scope.block.parent;
101129 return propertyDefinition.static;
101130 }
101131
101132 return false;
101133 }
101134 /**
101135 * Checks whether a given reference is evaluated in an execution context
101136 * that isn't the one where the variable it refers to is defined.
101137 * Execution contexts are:
101138 * - top-level
101139 * - functions
101140 * - class field initializers (implicit functions)
101141 * - class static blocks (implicit functions)
101142 * Static class field initializers and class static blocks are automatically run during the class definition evaluation,
101143 * and therefore we'll consider them as a part of the parent execution context.
101144 * Example:
101145 *
101146 * const x = 1;
101147 *
101148 * x; // returns `false`
101149 * () => x; // returns `true`
101150 *
101151 * class C {
101152 * field = x; // returns `true`
101153 * static field = x; // returns `false`
101154 *
101155 * method() {
101156 * x; // returns `true`
101157 * }
101158 *
101159 * static method() {
101160 * x; // returns `true`
101161 * }
101162 *
101163 * static {
101164 * x; // returns `false`
101165 * }
101166 * }
101167 * @param {eslint-scope.Reference} reference A reference to check.
101168 * @returns {boolean} `true` if the reference is from a separate execution context.
101169 */
101170
101171
101172 function isFromSeparateExecutionContext(reference) {
101173 const variable = reference.resolved;
101174 let scope = reference.from; // Scope#variableScope represents execution context
101175
101176 while (variable.scope.variableScope !== scope.variableScope) {
101177 if (isClassStaticInitializerScope(scope.variableScope)) {
101178 scope = scope.variableScope.upper;
101179 } else {
101180 return true;
101181 }
101182 }
101183
101184 return false;
101185 }
101186 /**
101187 * Checks whether or not a given reference is evaluated during the initialization of its variable.
101188 *
101189 * This returns `true` in the following cases:
101190 *
101191 * var a = a
101192 * var [a = a] = list
101193 * var {a = a} = obj
101194 * for (var a in a) {}
101195 * for (var a of a) {}
101196 * var C = class { [C]; };
101197 * var C = class { static foo = C; };
101198 * var C = class { static { foo = C; } };
101199 * class C extends C {}
101200 * class C extends (class { static foo = C; }) {}
101201 * class C { [C]; }
101202 * @param {Reference} reference A reference to check.
101203 * @returns {boolean} `true` if the reference is evaluated during the initialization.
101204 */
101205
101206
101207 function isEvaluatedDuringInitialization(reference) {
101208 if (isFromSeparateExecutionContext(reference)) {
101209 /*
101210 * Even if the reference appears in the initializer, it isn't evaluated during the initialization.
101211 * For example, `const x = () => x;` is valid.
101212 */
101213 return false;
101214 }
101215
101216 const location = reference.identifier.range[1];
101217 const definition = reference.resolved.defs[0];
101218
101219 if (definition.type === "ClassName") {
101220 // `ClassDeclaration` or `ClassExpression`
101221 const classDefinition = definition.node;
101222 return isInRange(classDefinition, location) &&
101223 /*
101224 * Class binding is initialized before running static initializers.
101225 * For example, `class C { static foo = C; static { bar = C; } }` is valid.
101226 */
101227 !isInClassStaticInitializerRange(classDefinition.body, location);
101228 }
101229
101230 let node = definition.name.parent;
101231
101232 while (node) {
101233 if (node.type === "VariableDeclarator") {
101234 if (isInRange(node.init, location)) {
101235 return true;
101236 }
101237
101238 if (FOR_IN_OF_TYPE.test(node.parent.parent.type) && isInRange(node.parent.parent.right, location)) {
101239 return true;
101240 }
101241
101242 break;
101243 } else if (node.type === "AssignmentPattern") {
101244 if (isInRange(node.right, location)) {
101245 return true;
101246 }
101247 } else if (SENTINEL_TYPE.test(node.type)) {
101248 break;
101249 }
101250
101251 node = node.parent;
101252 }
101253
101254 return false;
101255 } //------------------------------------------------------------------------------
101256 // Rule Definition
101257 //------------------------------------------------------------------------------
101258
101259
101260 module.exports = {
101261 meta: {
101262 type: "problem",
101263 docs: {
101264 description: "disallow the use of variables before they are defined",
101265 recommended: false,
101266 url: "https://eslint.org/docs/rules/no-use-before-define"
101267 },
101268 schema: [{
101269 oneOf: [{
101270 enum: ["nofunc"]
101271 }, {
101272 type: "object",
101273 properties: {
101274 functions: {
101275 type: "boolean"
101276 },
101277 classes: {
101278 type: "boolean"
101279 },
101280 variables: {
101281 type: "boolean"
101282 }
101283 },
101284 additionalProperties: false
101285 }]
101286 }],
101287 messages: {
101288 usedBeforeDefined: "'{{name}}' was used before it was defined."
101289 }
101290 },
101291
101292 create(context) {
101293 const options = parseOptions(context.options[0]);
101294 /**
101295 * Determines whether a given reference should be checked.
101296 *
101297 * Returns `false` if the reference is:
101298 * - initialization's (e.g., `let a = 1`).
101299 * - referring to an undefined variable (i.e., if it's an unresolved reference).
101300 * - referring to a variable that is defined, but not in the given source code
101301 * (e.g., global environment variable or `arguments` in functions).
101302 * - allowed by options.
101303 * @param {eslint-scope.Reference} reference The reference
101304 * @returns {boolean} `true` if the reference should be checked
101305 */
101306
101307 function shouldCheck(reference) {
101308 if (reference.init) {
101309 return false;
101310 }
101311
101312 const variable = reference.resolved;
101313
101314 if (!variable || variable.defs.length === 0) {
101315 return false;
101316 }
101317
101318 const definitionType = variable.defs[0].type;
101319
101320 if (!options.functions && definitionType === "FunctionName") {
101321 return false;
101322 }
101323
101324 if ((!options.variables && definitionType === "Variable" || !options.classes && definitionType === "ClassName") && // don't skip checking the reference if it's in the same execution context, because of TDZ
101325 isFromSeparateExecutionContext(reference)) {
101326 return false;
101327 }
101328
101329 return true;
101330 }
101331 /**
101332 * Finds and validates all references in a given scope and its child scopes.
101333 * @param {eslint-scope.Scope} scope The scope object.
101334 * @returns {void}
101335 */
101336
101337
101338 function checkReferencesInScope(scope) {
101339 scope.references.filter(shouldCheck).forEach(reference => {
101340 const variable = reference.resolved;
101341 const definitionIdentifier = variable.defs[0].name;
101342
101343 if (reference.identifier.range[1] < definitionIdentifier.range[1] || isEvaluatedDuringInitialization(reference)) {
101344 context.report({
101345 node: reference.identifier,
101346 messageId: "usedBeforeDefined",
101347 data: reference.identifier
101348 });
101349 }
101350 });
101351 scope.childScopes.forEach(checkReferencesInScope);
101352 }
101353
101354 return {
101355 Program() {
101356 checkReferencesInScope(context.getScope());
101357 }
101358
101359 };
101360 }
101361
101362 };
101363
101364 /***/ }),
101365 /* 776 */
101366 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
101367
101368 "use strict";
101369 /**
101370 * @fileoverview Rule to disallow useless backreferences in regular expressions
101371 * @author Milos Djermanovic
101372 */
101373 //------------------------------------------------------------------------------
101374 // Requirements
101375 //------------------------------------------------------------------------------
101376
101377 const {
101378 CALL,
101379 CONSTRUCT,
101380 ReferenceTracker,
101381 getStringIfConstant
101382 } = __webpack_require__(501);
101383
101384 const {
101385 RegExpParser,
101386 visitRegExpAST
101387 } = __webpack_require__(651); //------------------------------------------------------------------------------
101388 // Helpers
101389 //------------------------------------------------------------------------------
101390
101391
101392 const parser = new RegExpParser();
101393 /**
101394 * Finds the path from the given `regexpp` AST node to the root node.
101395 * @param {regexpp.Node} node Node.
101396 * @returns {regexpp.Node[]} Array that starts with the given node and ends with the root node.
101397 */
101398
101399 function getPathToRoot(node) {
101400 const path = [];
101401 let current = node;
101402
101403 do {
101404 path.push(current);
101405 current = current.parent;
101406 } while (current);
101407
101408 return path;
101409 }
101410 /**
101411 * Determines whether the given `regexpp` AST node is a lookaround node.
101412 * @param {regexpp.Node} node Node.
101413 * @returns {boolean} `true` if it is a lookaround node.
101414 */
101415
101416
101417 function isLookaround(node) {
101418 return node.type === "Assertion" && (node.kind === "lookahead" || node.kind === "lookbehind");
101419 }
101420 /**
101421 * Determines whether the given `regexpp` AST node is a negative lookaround node.
101422 * @param {regexpp.Node} node Node.
101423 * @returns {boolean} `true` if it is a negative lookaround node.
101424 */
101425
101426
101427 function isNegativeLookaround(node) {
101428 return isLookaround(node) && node.negate;
101429 } //------------------------------------------------------------------------------
101430 // Rule Definition
101431 //------------------------------------------------------------------------------
101432
101433
101434 module.exports = {
101435 meta: {
101436 type: "problem",
101437 docs: {
101438 description: "disallow useless backreferences in regular expressions",
101439 recommended: true,
101440 url: "https://eslint.org/docs/rules/no-useless-backreference"
101441 },
101442 schema: [],
101443 messages: {
101444 nested: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' from within that group.",
101445 forward: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which appears later in the pattern.",
101446 backward: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which appears before in the same lookbehind.",
101447 disjunctive: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which is in another alternative.",
101448 intoNegativeLookaround: "Backreference '{{ bref }}' will be ignored. It references group '{{ group }}' which is in a negative lookaround."
101449 }
101450 },
101451
101452 create(context) {
101453 /**
101454 * Checks and reports useless backreferences in the given regular expression.
101455 * @param {ASTNode} node Node that represents regular expression. A regex literal or RegExp constructor call.
101456 * @param {string} pattern Regular expression pattern.
101457 * @param {string} flags Regular expression flags.
101458 * @returns {void}
101459 */
101460 function checkRegex(node, pattern, flags) {
101461 let regExpAST;
101462
101463 try {
101464 regExpAST = parser.parsePattern(pattern, 0, pattern.length, flags.includes("u"));
101465 } catch {
101466 // Ignore regular expressions with syntax errors
101467 return;
101468 }
101469
101470 visitRegExpAST(regExpAST, {
101471 onBackreferenceEnter(bref) {
101472 const group = bref.resolved,
101473 brefPath = getPathToRoot(bref),
101474 groupPath = getPathToRoot(group);
101475 let messageId = null;
101476
101477 if (brefPath.includes(group)) {
101478 // group is bref's ancestor => bref is nested ('nested reference') => group hasn't matched yet when bref starts to match.
101479 messageId = "nested";
101480 } else {
101481 // Start from the root to find the lowest common ancestor.
101482 let i = brefPath.length - 1,
101483 j = groupPath.length - 1;
101484
101485 do {
101486 i--;
101487 j--;
101488 } while (brefPath[i] === groupPath[j]);
101489
101490 const indexOfLowestCommonAncestor = j + 1,
101491 groupCut = groupPath.slice(0, indexOfLowestCommonAncestor),
101492 commonPath = groupPath.slice(indexOfLowestCommonAncestor),
101493 lowestCommonLookaround = commonPath.find(isLookaround),
101494 isMatchingBackward = lowestCommonLookaround && lowestCommonLookaround.kind === "lookbehind";
101495
101496 if (!isMatchingBackward && bref.end <= group.start) {
101497 // bref is left, group is right ('forward reference') => group hasn't matched yet when bref starts to match.
101498 messageId = "forward";
101499 } else if (isMatchingBackward && group.end <= bref.start) {
101500 // the opposite of the previous when the regex is matching backward in a lookbehind context.
101501 messageId = "backward";
101502 } else if (groupCut[groupCut.length - 1].type === "Alternative") {
101503 // group's and bref's ancestor nodes below the lowest common ancestor are sibling alternatives => they're disjunctive.
101504 messageId = "disjunctive";
101505 } else if (groupCut.some(isNegativeLookaround)) {
101506 // group is in a negative lookaround which isn't bref's ancestor => group has already failed when bref starts to match.
101507 messageId = "intoNegativeLookaround";
101508 }
101509 }
101510
101511 if (messageId) {
101512 context.report({
101513 node,
101514 messageId,
101515 data: {
101516 bref: bref.raw,
101517 group: group.raw
101518 }
101519 });
101520 }
101521 }
101522
101523 });
101524 }
101525
101526 return {
101527 "Literal[regex]"(node) {
101528 const {
101529 pattern,
101530 flags
101531 } = node.regex;
101532 checkRegex(node, pattern, flags);
101533 },
101534
101535 Program() {
101536 const scope = context.getScope(),
101537 tracker = new ReferenceTracker(scope),
101538 traceMap = {
101539 RegExp: {
101540 [CALL]: true,
101541 [CONSTRUCT]: true
101542 }
101543 };
101544
101545 for (const {
101546 node
101547 } of tracker.iterateGlobalReferences(traceMap)) {
101548 const [patternNode, flagsNode] = node.arguments,
101549 pattern = getStringIfConstant(patternNode, scope),
101550 flags = getStringIfConstant(flagsNode, scope);
101551
101552 if (typeof pattern === "string") {
101553 checkRegex(node, pattern, flags || "");
101554 }
101555 }
101556 }
101557
101558 };
101559 }
101560
101561 };
101562
101563 /***/ }),
101564 /* 777 */
101565 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
101566
101567 "use strict";
101568 /**
101569 * @fileoverview A rule to disallow unnecessary `.call()` and `.apply()`.
101570 * @author Toru Nagashima
101571 */
101572
101573
101574 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
101575 // Helpers
101576 //------------------------------------------------------------------------------
101577
101578 /**
101579 * Checks whether or not a node is a `.call()`/`.apply()`.
101580 * @param {ASTNode} node A CallExpression node to check.
101581 * @returns {boolean} Whether or not the node is a `.call()`/`.apply()`.
101582 */
101583
101584
101585 function isCallOrNonVariadicApply(node) {
101586 const callee = astUtils.skipChainExpression(node.callee);
101587 return callee.type === "MemberExpression" && callee.property.type === "Identifier" && callee.computed === false && (callee.property.name === "call" && node.arguments.length >= 1 || callee.property.name === "apply" && node.arguments.length === 2 && node.arguments[1].type === "ArrayExpression");
101588 }
101589 /**
101590 * Checks whether or not `thisArg` is not changed by `.call()`/`.apply()`.
101591 * @param {ASTNode|null} expectedThis The node that is the owner of the applied function.
101592 * @param {ASTNode} thisArg The node that is given to the first argument of the `.call()`/`.apply()`.
101593 * @param {SourceCode} sourceCode The ESLint source code object.
101594 * @returns {boolean} Whether or not `thisArg` is not changed by `.call()`/`.apply()`.
101595 */
101596
101597
101598 function isValidThisArg(expectedThis, thisArg, sourceCode) {
101599 if (!expectedThis) {
101600 return astUtils.isNullOrUndefined(thisArg);
101601 }
101602
101603 return astUtils.equalTokens(expectedThis, thisArg, sourceCode);
101604 } //------------------------------------------------------------------------------
101605 // Rule Definition
101606 //------------------------------------------------------------------------------
101607
101608
101609 module.exports = {
101610 meta: {
101611 type: "suggestion",
101612 docs: {
101613 description: "disallow unnecessary calls to `.call()` and `.apply()`",
101614 recommended: false,
101615 url: "https://eslint.org/docs/rules/no-useless-call"
101616 },
101617 schema: [],
101618 messages: {
101619 unnecessaryCall: "Unnecessary '.{{name}}()'."
101620 }
101621 },
101622
101623 create(context) {
101624 const sourceCode = context.getSourceCode();
101625 return {
101626 CallExpression(node) {
101627 if (!isCallOrNonVariadicApply(node)) {
101628 return;
101629 }
101630
101631 const callee = astUtils.skipChainExpression(node.callee);
101632 const applied = astUtils.skipChainExpression(callee.object);
101633 const expectedThis = applied.type === "MemberExpression" ? applied.object : null;
101634 const thisArg = node.arguments[0];
101635
101636 if (isValidThisArg(expectedThis, thisArg, sourceCode)) {
101637 context.report({
101638 node,
101639 messageId: "unnecessaryCall",
101640 data: {
101641 name: callee.property.name
101642 }
101643 });
101644 }
101645 }
101646
101647 };
101648 }
101649
101650 };
101651
101652 /***/ }),
101653 /* 778 */
101654 /***/ ((module) => {
101655
101656 "use strict";
101657 /**
101658 * @fileoverview Reports useless `catch` clauses that just rethrow their error.
101659 * @author Teddy Katz
101660 */
101661 //------------------------------------------------------------------------------
101662 // Rule Definition
101663 //------------------------------------------------------------------------------
101664
101665 module.exports = {
101666 meta: {
101667 type: "suggestion",
101668 docs: {
101669 description: "disallow unnecessary `catch` clauses",
101670 recommended: true,
101671 url: "https://eslint.org/docs/rules/no-useless-catch"
101672 },
101673 schema: [],
101674 messages: {
101675 unnecessaryCatchClause: "Unnecessary catch clause.",
101676 unnecessaryCatch: "Unnecessary try/catch wrapper."
101677 }
101678 },
101679
101680 create(context) {
101681 return {
101682 CatchClause(node) {
101683 if (node.param && node.param.type === "Identifier" && node.body.body.length && node.body.body[0].type === "ThrowStatement" && node.body.body[0].argument.type === "Identifier" && node.body.body[0].argument.name === node.param.name) {
101684 if (node.parent.finalizer) {
101685 context.report({
101686 node,
101687 messageId: "unnecessaryCatchClause"
101688 });
101689 } else {
101690 context.report({
101691 node: node.parent,
101692 messageId: "unnecessaryCatch"
101693 });
101694 }
101695 }
101696 }
101697
101698 };
101699 }
101700
101701 };
101702
101703 /***/ }),
101704 /* 779 */
101705 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
101706
101707 "use strict";
101708 /**
101709 * @fileoverview Rule to disallow unnecessary computed property keys in object literals
101710 * @author Burak Yigit Kaya
101711 */
101712 //------------------------------------------------------------------------------
101713 // Requirements
101714 //------------------------------------------------------------------------------
101715
101716 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
101717 // Helpers
101718 //------------------------------------------------------------------------------
101719
101720 /**
101721 * Determines whether the computed key syntax is unnecessarily used for the given node.
101722 * In particular, it determines whether removing the square brackets and using the content between them
101723 * directly as the key (e.g. ['foo'] -> 'foo') would produce valid syntax and preserve the same behavior.
101724 * Valid non-computed keys are only: identifiers, number literals and string literals.
101725 * Only literals can preserve the same behavior, with a few exceptions for specific node types:
101726 * Property
101727 * - { ["__proto__"]: foo } defines a property named "__proto__"
101728 * { "__proto__": foo } defines object's prototype
101729 * PropertyDefinition
101730 * - class C { ["constructor"]; } defines an instance field named "constructor"
101731 * class C { "constructor"; } produces a parsing error
101732 * - class C { static ["constructor"]; } defines a static field named "constructor"
101733 * class C { static "constructor"; } produces a parsing error
101734 * - class C { static ["prototype"]; } produces a runtime error (doesn't break the whole script)
101735 * class C { static "prototype"; } produces a parsing error (breaks the whole script)
101736 * MethodDefinition
101737 * - class C { ["constructor"]() {} } defines a prototype method named "constructor"
101738 * class C { "constructor"() {} } defines the constructor
101739 * - class C { static ["prototype"]() {} } produces a runtime error (doesn't break the whole script)
101740 * class C { static "prototype"() {} } produces a parsing error (breaks the whole script)
101741 * @param {ASTNode} node The node to check. It can be `Property`, `PropertyDefinition` or `MethodDefinition`.
101742 * @throws {Error} (Unreachable.)
101743 * @returns {void} `true` if the node has useless computed key.
101744 */
101745
101746
101747 function hasUselessComputedKey(node) {
101748 if (!node.computed) {
101749 return false;
101750 }
101751
101752 const {
101753 key
101754 } = node;
101755
101756 if (key.type !== "Literal") {
101757 return false;
101758 }
101759
101760 const {
101761 value
101762 } = key;
101763
101764 if (typeof value !== "number" && typeof value !== "string") {
101765 return false;
101766 }
101767
101768 switch (node.type) {
101769 case "Property":
101770 return value !== "__proto__";
101771
101772 case "PropertyDefinition":
101773 if (node.static) {
101774 return value !== "constructor" && value !== "prototype";
101775 }
101776
101777 return value !== "constructor";
101778
101779 case "MethodDefinition":
101780 if (node.static) {
101781 return value !== "prototype";
101782 }
101783
101784 return value !== "constructor";
101785
101786 /* istanbul ignore next */
101787
101788 default:
101789 throw new Error("Unexpected node type: ".concat(node.type));
101790 }
101791 } //------------------------------------------------------------------------------
101792 // Rule Definition
101793 //------------------------------------------------------------------------------
101794
101795
101796 module.exports = {
101797 meta: {
101798 type: "suggestion",
101799 docs: {
101800 description: "disallow unnecessary computed property keys in objects and classes",
101801 recommended: false,
101802 url: "https://eslint.org/docs/rules/no-useless-computed-key"
101803 },
101804 schema: [{
101805 type: "object",
101806 properties: {
101807 enforceForClassMembers: {
101808 type: "boolean",
101809 default: false
101810 }
101811 },
101812 additionalProperties: false
101813 }],
101814 fixable: "code",
101815 messages: {
101816 unnecessarilyComputedProperty: "Unnecessarily computed property [{{property}}] found."
101817 }
101818 },
101819
101820 create(context) {
101821 const sourceCode = context.getSourceCode();
101822 const enforceForClassMembers = context.options[0] && context.options[0].enforceForClassMembers;
101823 /**
101824 * Reports a given node if it violated this rule.
101825 * @param {ASTNode} node The node to check.
101826 * @returns {void}
101827 */
101828
101829 function check(node) {
101830 if (hasUselessComputedKey(node)) {
101831 const {
101832 key
101833 } = node;
101834 context.report({
101835 node,
101836 messageId: "unnecessarilyComputedProperty",
101837 data: {
101838 property: sourceCode.getText(key)
101839 },
101840
101841 fix(fixer) {
101842 const leftSquareBracket = sourceCode.getTokenBefore(key, astUtils.isOpeningBracketToken);
101843 const rightSquareBracket = sourceCode.getTokenAfter(key, astUtils.isClosingBracketToken); // If there are comments between the brackets and the property name, don't do a fix.
101844
101845 if (sourceCode.commentsExistBetween(leftSquareBracket, rightSquareBracket)) {
101846 return null;
101847 }
101848
101849 const tokenBeforeLeftBracket = sourceCode.getTokenBefore(leftSquareBracket); // Insert a space before the key to avoid changing identifiers, e.g. ({ get[2]() {} }) to ({ get2() {} })
101850
101851 const needsSpaceBeforeKey = tokenBeforeLeftBracket.range[1] === leftSquareBracket.range[0] && !astUtils.canTokensBeAdjacent(tokenBeforeLeftBracket, sourceCode.getFirstToken(key));
101852 const replacementKey = (needsSpaceBeforeKey ? " " : "") + key.raw;
101853 return fixer.replaceTextRange([leftSquareBracket.range[0], rightSquareBracket.range[1]], replacementKey);
101854 }
101855
101856 });
101857 }
101858 }
101859 /**
101860 * A no-op function to act as placeholder for checking a node when the `enforceForClassMembers` option is `false`.
101861 * @returns {void}
101862 * @private
101863 */
101864
101865
101866 function noop() {}
101867
101868 return {
101869 Property: check,
101870 MethodDefinition: enforceForClassMembers ? check : noop,
101871 PropertyDefinition: enforceForClassMembers ? check : noop
101872 };
101873 }
101874
101875 };
101876
101877 /***/ }),
101878 /* 780 */
101879 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
101880
101881 "use strict";
101882 /**
101883 * @fileoverview disallow unnecessary concatenation of template strings
101884 * @author Henry Zhu
101885 */
101886 //------------------------------------------------------------------------------
101887 // Requirements
101888 //------------------------------------------------------------------------------
101889
101890 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
101891 // Helpers
101892 //------------------------------------------------------------------------------
101893
101894 /**
101895 * Checks whether or not a given node is a concatenation.
101896 * @param {ASTNode} node A node to check.
101897 * @returns {boolean} `true` if the node is a concatenation.
101898 */
101899
101900
101901 function isConcatenation(node) {
101902 return node.type === "BinaryExpression" && node.operator === "+";
101903 }
101904 /**
101905 * Checks if the given token is a `+` token or not.
101906 * @param {Token} token The token to check.
101907 * @returns {boolean} `true` if the token is a `+` token.
101908 */
101909
101910
101911 function isConcatOperatorToken(token) {
101912 return token.value === "+" && token.type === "Punctuator";
101913 }
101914 /**
101915 * Get's the right most node on the left side of a BinaryExpression with + operator.
101916 * @param {ASTNode} node A BinaryExpression node to check.
101917 * @returns {ASTNode} node
101918 */
101919
101920
101921 function getLeft(node) {
101922 let left = node.left;
101923
101924 while (isConcatenation(left)) {
101925 left = left.right;
101926 }
101927
101928 return left;
101929 }
101930 /**
101931 * Get's the left most node on the right side of a BinaryExpression with + operator.
101932 * @param {ASTNode} node A BinaryExpression node to check.
101933 * @returns {ASTNode} node
101934 */
101935
101936
101937 function getRight(node) {
101938 let right = node.right;
101939
101940 while (isConcatenation(right)) {
101941 right = right.left;
101942 }
101943
101944 return right;
101945 } //------------------------------------------------------------------------------
101946 // Rule Definition
101947 //------------------------------------------------------------------------------
101948
101949
101950 module.exports = {
101951 meta: {
101952 type: "suggestion",
101953 docs: {
101954 description: "disallow unnecessary concatenation of literals or template literals",
101955 recommended: false,
101956 url: "https://eslint.org/docs/rules/no-useless-concat"
101957 },
101958 schema: [],
101959 messages: {
101960 unexpectedConcat: "Unexpected string concatenation of literals."
101961 }
101962 },
101963
101964 create(context) {
101965 const sourceCode = context.getSourceCode();
101966 return {
101967 BinaryExpression(node) {
101968 // check if not concatenation
101969 if (node.operator !== "+") {
101970 return;
101971 } // account for the `foo + "a" + "b"` case
101972
101973
101974 const left = getLeft(node);
101975 const right = getRight(node);
101976
101977 if (astUtils.isStringLiteral(left) && astUtils.isStringLiteral(right) && astUtils.isTokenOnSameLine(left, right)) {
101978 const operatorToken = sourceCode.getFirstTokenBetween(left, right, isConcatOperatorToken);
101979 context.report({
101980 node,
101981 loc: operatorToken.loc,
101982 messageId: "unexpectedConcat"
101983 });
101984 }
101985 }
101986
101987 };
101988 }
101989
101990 };
101991
101992 /***/ }),
101993 /* 781 */
101994 /***/ ((module) => {
101995
101996 "use strict";
101997 /**
101998 * @fileoverview Rule to flag the use of redundant constructors in classes.
101999 * @author Alberto Rodríguez
102000 */
102001 //------------------------------------------------------------------------------
102002 // Helpers
102003 //------------------------------------------------------------------------------
102004
102005 /**
102006 * Checks whether a given array of statements is a single call of `super`.
102007 * @param {ASTNode[]} body An array of statements to check.
102008 * @returns {boolean} `true` if the body is a single call of `super`.
102009 */
102010
102011 function isSingleSuperCall(body) {
102012 return body.length === 1 && body[0].type === "ExpressionStatement" && body[0].expression.type === "CallExpression" && body[0].expression.callee.type === "Super";
102013 }
102014 /**
102015 * Checks whether a given node is a pattern which doesn't have any side effects.
102016 * Default parameters and Destructuring parameters can have side effects.
102017 * @param {ASTNode} node A pattern node.
102018 * @returns {boolean} `true` if the node doesn't have any side effects.
102019 */
102020
102021
102022 function isSimple(node) {
102023 return node.type === "Identifier" || node.type === "RestElement";
102024 }
102025 /**
102026 * Checks whether a given array of expressions is `...arguments` or not.
102027 * `super(...arguments)` passes all arguments through.
102028 * @param {ASTNode[]} superArgs An array of expressions to check.
102029 * @returns {boolean} `true` if the superArgs is `...arguments`.
102030 */
102031
102032
102033 function isSpreadArguments(superArgs) {
102034 return superArgs.length === 1 && superArgs[0].type === "SpreadElement" && superArgs[0].argument.type === "Identifier" && superArgs[0].argument.name === "arguments";
102035 }
102036 /**
102037 * Checks whether given 2 nodes are identifiers which have the same name or not.
102038 * @param {ASTNode} ctorParam A node to check.
102039 * @param {ASTNode} superArg A node to check.
102040 * @returns {boolean} `true` if the nodes are identifiers which have the same
102041 * name.
102042 */
102043
102044
102045 function isValidIdentifierPair(ctorParam, superArg) {
102046 return ctorParam.type === "Identifier" && superArg.type === "Identifier" && ctorParam.name === superArg.name;
102047 }
102048 /**
102049 * Checks whether given 2 nodes are a rest/spread pair which has the same values.
102050 * @param {ASTNode} ctorParam A node to check.
102051 * @param {ASTNode} superArg A node to check.
102052 * @returns {boolean} `true` if the nodes are a rest/spread pair which has the
102053 * same values.
102054 */
102055
102056
102057 function isValidRestSpreadPair(ctorParam, superArg) {
102058 return ctorParam.type === "RestElement" && superArg.type === "SpreadElement" && isValidIdentifierPair(ctorParam.argument, superArg.argument);
102059 }
102060 /**
102061 * Checks whether given 2 nodes have the same value or not.
102062 * @param {ASTNode} ctorParam A node to check.
102063 * @param {ASTNode} superArg A node to check.
102064 * @returns {boolean} `true` if the nodes have the same value or not.
102065 */
102066
102067
102068 function isValidPair(ctorParam, superArg) {
102069 return isValidIdentifierPair(ctorParam, superArg) || isValidRestSpreadPair(ctorParam, superArg);
102070 }
102071 /**
102072 * Checks whether the parameters of a constructor and the arguments of `super()`
102073 * have the same values or not.
102074 * @param {ASTNode} ctorParams The parameters of a constructor to check.
102075 * @param {ASTNode} superArgs The arguments of `super()` to check.
102076 * @returns {boolean} `true` if those have the same values.
102077 */
102078
102079
102080 function isPassingThrough(ctorParams, superArgs) {
102081 if (ctorParams.length !== superArgs.length) {
102082 return false;
102083 }
102084
102085 for (let i = 0; i < ctorParams.length; ++i) {
102086 if (!isValidPair(ctorParams[i], superArgs[i])) {
102087 return false;
102088 }
102089 }
102090
102091 return true;
102092 }
102093 /**
102094 * Checks whether the constructor body is a redundant super call.
102095 * @param {Array} body constructor body content.
102096 * @param {Array} ctorParams The params to check against super call.
102097 * @returns {boolean} true if the constructor body is redundant
102098 */
102099
102100
102101 function isRedundantSuperCall(body, ctorParams) {
102102 return isSingleSuperCall(body) && ctorParams.every(isSimple) && (isSpreadArguments(body[0].expression.arguments) || isPassingThrough(ctorParams, body[0].expression.arguments));
102103 } //------------------------------------------------------------------------------
102104 // Rule Definition
102105 //------------------------------------------------------------------------------
102106
102107
102108 module.exports = {
102109 meta: {
102110 type: "suggestion",
102111 docs: {
102112 description: "disallow unnecessary constructors",
102113 recommended: false,
102114 url: "https://eslint.org/docs/rules/no-useless-constructor"
102115 },
102116 schema: [],
102117 messages: {
102118 noUselessConstructor: "Useless constructor."
102119 }
102120 },
102121
102122 create(context) {
102123 /**
102124 * Checks whether a node is a redundant constructor
102125 * @param {ASTNode} node node to check
102126 * @returns {void}
102127 */
102128 function checkForConstructor(node) {
102129 if (node.kind !== "constructor") {
102130 return;
102131 }
102132 /*
102133 * Prevent crashing on parsers which do not require class constructor
102134 * to have a body, e.g. typescript and flow
102135 */
102136
102137
102138 if (!node.value.body) {
102139 return;
102140 }
102141
102142 const body = node.value.body.body;
102143 const ctorParams = node.value.params;
102144 const superClass = node.parent.parent.superClass;
102145
102146 if (superClass ? isRedundantSuperCall(body, ctorParams) : body.length === 0) {
102147 context.report({
102148 node,
102149 messageId: "noUselessConstructor"
102150 });
102151 }
102152 }
102153
102154 return {
102155 MethodDefinition: checkForConstructor
102156 };
102157 }
102158
102159 };
102160
102161 /***/ }),
102162 /* 782 */
102163 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
102164
102165 "use strict";
102166 /**
102167 * @fileoverview Look for useless escapes in strings and regexes
102168 * @author Onur Temizkan
102169 */
102170
102171
102172 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
102173 // Rule Definition
102174 //------------------------------------------------------------------------------
102175
102176 /**
102177 * Returns the union of two sets.
102178 * @param {Set} setA The first set
102179 * @param {Set} setB The second set
102180 * @returns {Set} The union of the two sets
102181 */
102182
102183
102184 function union(setA, setB) {
102185 return new Set(function* () {
102186 yield* setA;
102187 yield* setB;
102188 }());
102189 }
102190
102191 const VALID_STRING_ESCAPES = union(new Set("\\nrvtbfux"), astUtils.LINEBREAKS);
102192 const REGEX_GENERAL_ESCAPES = new Set("\\bcdDfnpPrsStvwWxu0123456789]");
102193 const REGEX_NON_CHARCLASS_ESCAPES = union(REGEX_GENERAL_ESCAPES, new Set("^/.$*+?[{}|()Bk"));
102194 /**
102195 * Parses a regular expression into a list of characters with character class info.
102196 * @param {string} regExpText The raw text used to create the regular expression
102197 * @returns {Object[]} A list of characters, each with info on escaping and whether they're in a character class.
102198 * @example
102199 *
102200 * parseRegExp("a\\b[cd-]");
102201 *
102202 * // returns:
102203 * [
102204 * { text: "a", index: 0, escaped: false, inCharClass: false, startsCharClass: false, endsCharClass: false },
102205 * { text: "b", index: 2, escaped: true, inCharClass: false, startsCharClass: false, endsCharClass: false },
102206 * { text: "c", index: 4, escaped: false, inCharClass: true, startsCharClass: true, endsCharClass: false },
102207 * { text: "d", index: 5, escaped: false, inCharClass: true, startsCharClass: false, endsCharClass: false },
102208 * { text: "-", index: 6, escaped: false, inCharClass: true, startsCharClass: false, endsCharClass: false }
102209 * ];
102210 *
102211 */
102212
102213 function parseRegExp(regExpText) {
102214 const charList = [];
102215 regExpText.split("").reduce((state, char, index) => {
102216 if (!state.escapeNextChar) {
102217 if (char === "\\") {
102218 return Object.assign(state, {
102219 escapeNextChar: true
102220 });
102221 }
102222
102223 if (char === "[" && !state.inCharClass) {
102224 return Object.assign(state, {
102225 inCharClass: true,
102226 startingCharClass: true
102227 });
102228 }
102229
102230 if (char === "]" && state.inCharClass) {
102231 if (charList.length && charList[charList.length - 1].inCharClass) {
102232 charList[charList.length - 1].endsCharClass = true;
102233 }
102234
102235 return Object.assign(state, {
102236 inCharClass: false,
102237 startingCharClass: false
102238 });
102239 }
102240 }
102241
102242 charList.push({
102243 text: char,
102244 index,
102245 escaped: state.escapeNextChar,
102246 inCharClass: state.inCharClass,
102247 startsCharClass: state.startingCharClass,
102248 endsCharClass: false
102249 });
102250 return Object.assign(state, {
102251 escapeNextChar: false,
102252 startingCharClass: false
102253 });
102254 }, {
102255 escapeNextChar: false,
102256 inCharClass: false,
102257 startingCharClass: false
102258 });
102259 return charList;
102260 }
102261
102262 module.exports = {
102263 meta: {
102264 type: "suggestion",
102265 docs: {
102266 description: "disallow unnecessary escape characters",
102267 recommended: true,
102268 url: "https://eslint.org/docs/rules/no-useless-escape"
102269 },
102270 hasSuggestions: true,
102271 messages: {
102272 unnecessaryEscape: "Unnecessary escape character: \\{{character}}.",
102273 removeEscape: "Remove the `\\`. This maintains the current functionality.",
102274 escapeBackslash: "Replace the `\\` with `\\\\` to include the actual backslash character."
102275 },
102276 schema: []
102277 },
102278
102279 create(context) {
102280 const sourceCode = context.getSourceCode();
102281 /**
102282 * Reports a node
102283 * @param {ASTNode} node The node to report
102284 * @param {number} startOffset The backslash's offset from the start of the node
102285 * @param {string} character The uselessly escaped character (not including the backslash)
102286 * @returns {void}
102287 */
102288
102289 function report(node, startOffset, character) {
102290 const rangeStart = node.range[0] + startOffset;
102291 const range = [rangeStart, rangeStart + 1];
102292 const start = sourceCode.getLocFromIndex(rangeStart);
102293 context.report({
102294 node,
102295 loc: {
102296 start,
102297 end: {
102298 line: start.line,
102299 column: start.column + 1
102300 }
102301 },
102302 messageId: "unnecessaryEscape",
102303 data: {
102304 character
102305 },
102306 suggest: [{
102307 messageId: "removeEscape",
102308
102309 fix(fixer) {
102310 return fixer.removeRange(range);
102311 }
102312
102313 }, {
102314 messageId: "escapeBackslash",
102315
102316 fix(fixer) {
102317 return fixer.insertTextBeforeRange(range, "\\");
102318 }
102319
102320 }]
102321 });
102322 }
102323 /**
102324 * Checks if the escape character in given string slice is unnecessary.
102325 * @private
102326 * @param {ASTNode} node node to validate.
102327 * @param {string} match string slice to validate.
102328 * @returns {void}
102329 */
102330
102331
102332 function validateString(node, match) {
102333 const isTemplateElement = node.type === "TemplateElement";
102334 const escapedChar = match[0][1];
102335 let isUnnecessaryEscape = !VALID_STRING_ESCAPES.has(escapedChar);
102336 let isQuoteEscape;
102337
102338 if (isTemplateElement) {
102339 isQuoteEscape = escapedChar === "`";
102340
102341 if (escapedChar === "$") {
102342 // Warn if `\$` is not followed by `{`
102343 isUnnecessaryEscape = match.input[match.index + 2] !== "{";
102344 } else if (escapedChar === "{") {
102345 /*
102346 * Warn if `\{` is not preceded by `$`. If preceded by `$`, escaping
102347 * is necessary and the rule should not warn. If preceded by `/$`, the rule
102348 * will warn for the `/$` instead, as it is the first unnecessarily escaped character.
102349 */
102350 isUnnecessaryEscape = match.input[match.index - 1] !== "$";
102351 }
102352 } else {
102353 isQuoteEscape = escapedChar === node.raw[0];
102354 }
102355
102356 if (isUnnecessaryEscape && !isQuoteEscape) {
102357 report(node, match.index, match[0].slice(1));
102358 }
102359 }
102360 /**
102361 * Checks if a node has an escape.
102362 * @param {ASTNode} node node to check.
102363 * @returns {void}
102364 */
102365
102366
102367 function check(node) {
102368 const isTemplateElement = node.type === "TemplateElement";
102369
102370 if (isTemplateElement && node.parent && node.parent.parent && node.parent.parent.type === "TaggedTemplateExpression" && node.parent === node.parent.parent.quasi) {
102371 // Don't report tagged template literals, because the backslash character is accessible to the tag function.
102372 return;
102373 }
102374
102375 if (typeof node.value === "string" || isTemplateElement) {
102376 /*
102377 * JSXAttribute doesn't have any escape sequence: https://facebook.github.io/jsx/.
102378 * In addition, backticks are not supported by JSX yet: https://github.com/facebook/jsx/issues/25.
102379 */
102380 if (node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement" || node.parent.type === "JSXFragment") {
102381 return;
102382 }
102383
102384 const value = isTemplateElement ? sourceCode.getText(node) : node.raw;
102385 const pattern = /\\[^\d]/gu;
102386 let match;
102387
102388 while (match = pattern.exec(value)) {
102389 validateString(node, match);
102390 }
102391 } else if (node.regex) {
102392 parseRegExp(node.regex.pattern)
102393 /*
102394 * The '-' character is a special case, because it's only valid to escape it if it's in a character
102395 * class, and is not at either edge of the character class. To account for this, don't consider '-'
102396 * characters to be valid in general, and filter out '-' characters that appear in the middle of a
102397 * character class.
102398 */
102399 .filter(charInfo => !(charInfo.text === "-" && charInfo.inCharClass && !charInfo.startsCharClass && !charInfo.endsCharClass))
102400 /*
102401 * The '^' character is also a special case; it must always be escaped outside of character classes, but
102402 * it only needs to be escaped in character classes if it's at the beginning of the character class. To
102403 * account for this, consider it to be a valid escape character outside of character classes, and filter
102404 * out '^' characters that appear at the start of a character class.
102405 */
102406 .filter(charInfo => !(charInfo.text === "^" && charInfo.startsCharClass)) // Filter out characters that aren't escaped.
102407 .filter(charInfo => charInfo.escaped) // Filter out characters that are valid to escape, based on their position in the regular expression.
102408 .filter(charInfo => !(charInfo.inCharClass ? REGEX_GENERAL_ESCAPES : REGEX_NON_CHARCLASS_ESCAPES).has(charInfo.text)) // Report all the remaining characters.
102409 .forEach(charInfo => report(node, charInfo.index, charInfo.text));
102410 }
102411 }
102412
102413 return {
102414 Literal: check,
102415 TemplateElement: check
102416 };
102417 }
102418
102419 };
102420
102421 /***/ }),
102422 /* 783 */
102423 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
102424
102425 "use strict";
102426 /**
102427 * @fileoverview Disallow renaming import, export, and destructured assignments to the same name.
102428 * @author Kai Cataldo
102429 */
102430 //------------------------------------------------------------------------------
102431 // Requirements
102432 //------------------------------------------------------------------------------
102433
102434 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
102435 // Rule Definition
102436 //------------------------------------------------------------------------------
102437
102438
102439 module.exports = {
102440 meta: {
102441 type: "suggestion",
102442 docs: {
102443 description: "disallow renaming import, export, and destructured assignments to the same name",
102444 recommended: false,
102445 url: "https://eslint.org/docs/rules/no-useless-rename"
102446 },
102447 fixable: "code",
102448 schema: [{
102449 type: "object",
102450 properties: {
102451 ignoreDestructuring: {
102452 type: "boolean",
102453 default: false
102454 },
102455 ignoreImport: {
102456 type: "boolean",
102457 default: false
102458 },
102459 ignoreExport: {
102460 type: "boolean",
102461 default: false
102462 }
102463 },
102464 additionalProperties: false
102465 }],
102466 messages: {
102467 unnecessarilyRenamed: "{{type}} {{name}} unnecessarily renamed."
102468 }
102469 },
102470
102471 create(context) {
102472 const sourceCode = context.getSourceCode(),
102473 options = context.options[0] || {},
102474 ignoreDestructuring = options.ignoreDestructuring === true,
102475 ignoreImport = options.ignoreImport === true,
102476 ignoreExport = options.ignoreExport === true; //--------------------------------------------------------------------------
102477 // Helpers
102478 //--------------------------------------------------------------------------
102479
102480 /**
102481 * Reports error for unnecessarily renamed assignments
102482 * @param {ASTNode} node node to report
102483 * @param {ASTNode} initial node with initial name value
102484 * @param {string} type the type of the offending node
102485 * @returns {void}
102486 */
102487
102488 function reportError(node, initial, type) {
102489 const name = initial.type === "Identifier" ? initial.name : initial.value;
102490 return context.report({
102491 node,
102492 messageId: "unnecessarilyRenamed",
102493 data: {
102494 name,
102495 type
102496 },
102497
102498 fix(fixer) {
102499 const replacementNode = node.type === "Property" ? node.value : node.local;
102500
102501 if (sourceCode.getCommentsInside(node).length > sourceCode.getCommentsInside(replacementNode).length) {
102502 return null;
102503 } // Don't autofix code such as `({foo: (foo) = a} = obj);`, parens are not allowed in shorthand properties.
102504
102505
102506 if (replacementNode.type === "AssignmentPattern" && astUtils.isParenthesised(sourceCode, replacementNode.left)) {
102507 return null;
102508 }
102509
102510 return fixer.replaceText(node, sourceCode.getText(replacementNode));
102511 }
102512
102513 });
102514 }
102515 /**
102516 * Checks whether a destructured assignment is unnecessarily renamed
102517 * @param {ASTNode} node node to check
102518 * @returns {void}
102519 */
102520
102521
102522 function checkDestructured(node) {
102523 if (ignoreDestructuring) {
102524 return;
102525 }
102526
102527 for (const property of node.properties) {
102528 /**
102529 * Properties using shorthand syntax and rest elements can not be renamed.
102530 * If the property is computed, we have no idea if a rename is useless or not.
102531 */
102532 if (property.type !== "Property" || property.shorthand || property.computed) {
102533 continue;
102534 }
102535
102536 const key = property.key.type === "Identifier" && property.key.name || property.key.type === "Literal" && property.key.value;
102537 const renamedKey = property.value.type === "AssignmentPattern" ? property.value.left.name : property.value.name;
102538
102539 if (key === renamedKey) {
102540 reportError(property, property.key, "Destructuring assignment");
102541 }
102542 }
102543 }
102544 /**
102545 * Checks whether an import is unnecessarily renamed
102546 * @param {ASTNode} node node to check
102547 * @returns {void}
102548 */
102549
102550
102551 function checkImport(node) {
102552 if (ignoreImport) {
102553 return;
102554 }
102555
102556 if (node.imported.name === node.local.name && node.imported.range[0] !== node.local.range[0]) {
102557 reportError(node, node.imported, "Import");
102558 }
102559 }
102560 /**
102561 * Checks whether an export is unnecessarily renamed
102562 * @param {ASTNode} node node to check
102563 * @returns {void}
102564 */
102565
102566
102567 function checkExport(node) {
102568 if (ignoreExport) {
102569 return;
102570 }
102571
102572 if (node.local.name === node.exported.name && node.local.range[0] !== node.exported.range[0]) {
102573 reportError(node, node.local, "Export");
102574 }
102575 } //--------------------------------------------------------------------------
102576 // Public
102577 //--------------------------------------------------------------------------
102578
102579
102580 return {
102581 ObjectPattern: checkDestructured,
102582 ImportSpecifier: checkImport,
102583 ExportSpecifier: checkExport
102584 };
102585 }
102586
102587 };
102588
102589 /***/ }),
102590 /* 784 */
102591 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
102592
102593 "use strict";
102594 /**
102595 * @fileoverview Disallow redundant return statements
102596 * @author Teddy Katz
102597 */
102598 //------------------------------------------------------------------------------
102599 // Requirements
102600 //------------------------------------------------------------------------------
102601
102602 const astUtils = __webpack_require__(548),
102603 FixTracker = __webpack_require__(662); //------------------------------------------------------------------------------
102604 // Helpers
102605 //------------------------------------------------------------------------------
102606
102607 /**
102608 * Removes the given element from the array.
102609 * @param {Array} array The source array to remove.
102610 * @param {any} element The target item to remove.
102611 * @returns {void}
102612 */
102613
102614
102615 function remove(array, element) {
102616 const index = array.indexOf(element);
102617
102618 if (index !== -1) {
102619 array.splice(index, 1);
102620 }
102621 }
102622 /**
102623 * Checks whether it can remove the given return statement or not.
102624 * @param {ASTNode} node The return statement node to check.
102625 * @returns {boolean} `true` if the node is removable.
102626 */
102627
102628
102629 function isRemovable(node) {
102630 return astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type);
102631 }
102632 /**
102633 * Checks whether the given return statement is in a `finally` block or not.
102634 * @param {ASTNode} node The return statement node to check.
102635 * @returns {boolean} `true` if the node is in a `finally` block.
102636 */
102637
102638
102639 function isInFinally(node) {
102640 for (let currentNode = node; currentNode && currentNode.parent && !astUtils.isFunction(currentNode); currentNode = currentNode.parent) {
102641 if (currentNode.parent.type === "TryStatement" && currentNode.parent.finalizer === currentNode) {
102642 return true;
102643 }
102644 }
102645
102646 return false;
102647 } //------------------------------------------------------------------------------
102648 // Rule Definition
102649 //------------------------------------------------------------------------------
102650
102651
102652 module.exports = {
102653 meta: {
102654 type: "suggestion",
102655 docs: {
102656 description: "disallow redundant return statements",
102657 recommended: false,
102658 url: "https://eslint.org/docs/rules/no-useless-return"
102659 },
102660 fixable: "code",
102661 schema: [],
102662 messages: {
102663 unnecessaryReturn: "Unnecessary return statement."
102664 }
102665 },
102666
102667 create(context) {
102668 const segmentInfoMap = new WeakMap();
102669 const usedUnreachableSegments = new WeakSet();
102670 const sourceCode = context.getSourceCode();
102671 let scopeInfo = null;
102672 /**
102673 * Checks whether the given segment is terminated by a return statement or not.
102674 * @param {CodePathSegment} segment The segment to check.
102675 * @returns {boolean} `true` if the segment is terminated by a return statement, or if it's still a part of unreachable.
102676 */
102677
102678 function isReturned(segment) {
102679 const info = segmentInfoMap.get(segment);
102680 return !info || info.returned;
102681 }
102682 /**
102683 * Collects useless return statements from the given previous segments.
102684 *
102685 * A previous segment may be an unreachable segment.
102686 * In that case, the information object of the unreachable segment is not
102687 * initialized because `onCodePathSegmentStart` event is not notified for
102688 * unreachable segments.
102689 * This goes to the previous segments of the unreachable segment recursively
102690 * if the unreachable segment was generated by a return statement. Otherwise,
102691 * this ignores the unreachable segment.
102692 *
102693 * This behavior would simulate code paths for the case that the return
102694 * statement does not exist.
102695 * @param {ASTNode[]} uselessReturns The collected return statements.
102696 * @param {CodePathSegment[]} prevSegments The previous segments to traverse.
102697 * @param {WeakSet<CodePathSegment>} [providedTraversedSegments] A set of segments that have already been traversed in this call
102698 * @returns {ASTNode[]} `uselessReturns`.
102699 */
102700
102701
102702 function getUselessReturns(uselessReturns, prevSegments, providedTraversedSegments) {
102703 const traversedSegments = providedTraversedSegments || new WeakSet();
102704
102705 for (const segment of prevSegments) {
102706 if (!segment.reachable) {
102707 if (!traversedSegments.has(segment)) {
102708 traversedSegments.add(segment);
102709 getUselessReturns(uselessReturns, segment.allPrevSegments.filter(isReturned), traversedSegments);
102710 }
102711
102712 continue;
102713 }
102714
102715 uselessReturns.push(...segmentInfoMap.get(segment).uselessReturns);
102716 }
102717
102718 return uselessReturns;
102719 }
102720 /**
102721 * Removes the return statements on the given segment from the useless return
102722 * statement list.
102723 *
102724 * This segment may be an unreachable segment.
102725 * In that case, the information object of the unreachable segment is not
102726 * initialized because `onCodePathSegmentStart` event is not notified for
102727 * unreachable segments.
102728 * This goes to the previous segments of the unreachable segment recursively
102729 * if the unreachable segment was generated by a return statement. Otherwise,
102730 * this ignores the unreachable segment.
102731 *
102732 * This behavior would simulate code paths for the case that the return
102733 * statement does not exist.
102734 * @param {CodePathSegment} segment The segment to get return statements.
102735 * @returns {void}
102736 */
102737
102738
102739 function markReturnStatementsOnSegmentAsUsed(segment) {
102740 if (!segment.reachable) {
102741 usedUnreachableSegments.add(segment);
102742 segment.allPrevSegments.filter(isReturned).filter(prevSegment => !usedUnreachableSegments.has(prevSegment)).forEach(markReturnStatementsOnSegmentAsUsed);
102743 return;
102744 }
102745
102746 const info = segmentInfoMap.get(segment);
102747
102748 for (const node of info.uselessReturns) {
102749 remove(scopeInfo.uselessReturns, node);
102750 }
102751
102752 info.uselessReturns = [];
102753 }
102754 /**
102755 * Removes the return statements on the current segments from the useless
102756 * return statement list.
102757 *
102758 * This function will be called at every statement except FunctionDeclaration,
102759 * BlockStatement, and BreakStatement.
102760 *
102761 * - FunctionDeclarations are always executed whether it's returned or not.
102762 * - BlockStatements do nothing.
102763 * - BreakStatements go the next merely.
102764 * @returns {void}
102765 */
102766
102767
102768 function markReturnStatementsOnCurrentSegmentsAsUsed() {
102769 scopeInfo.codePath.currentSegments.forEach(markReturnStatementsOnSegmentAsUsed);
102770 } //----------------------------------------------------------------------
102771 // Public
102772 //----------------------------------------------------------------------
102773
102774
102775 return {
102776 // Makes and pushs a new scope information.
102777 onCodePathStart(codePath) {
102778 scopeInfo = {
102779 upper: scopeInfo,
102780 uselessReturns: [],
102781 codePath
102782 };
102783 },
102784
102785 // Reports useless return statements if exist.
102786 onCodePathEnd() {
102787 for (const node of scopeInfo.uselessReturns) {
102788 context.report({
102789 node,
102790 loc: node.loc,
102791 messageId: "unnecessaryReturn",
102792
102793 fix(fixer) {
102794 if (isRemovable(node) && !sourceCode.getCommentsInside(node).length) {
102795 /*
102796 * Extend the replacement range to include the
102797 * entire function to avoid conflicting with
102798 * no-else-return.
102799 * https://github.com/eslint/eslint/issues/8026
102800 */
102801 return new FixTracker(fixer, sourceCode).retainEnclosingFunction(node).remove(node);
102802 }
102803
102804 return null;
102805 }
102806
102807 });
102808 }
102809
102810 scopeInfo = scopeInfo.upper;
102811 },
102812
102813 /*
102814 * Initializes segments.
102815 * NOTE: This event is notified for only reachable segments.
102816 */
102817 onCodePathSegmentStart(segment) {
102818 const info = {
102819 uselessReturns: getUselessReturns([], segment.allPrevSegments),
102820 returned: false
102821 }; // Stores the info.
102822
102823 segmentInfoMap.set(segment, info);
102824 },
102825
102826 // Adds ReturnStatement node to check whether it's useless or not.
102827 ReturnStatement(node) {
102828 if (node.argument) {
102829 markReturnStatementsOnCurrentSegmentsAsUsed();
102830 }
102831
102832 if (node.argument || astUtils.isInLoop(node) || isInFinally(node) || // Ignore `return` statements in unreachable places (https://github.com/eslint/eslint/issues/11647).
102833 !scopeInfo.codePath.currentSegments.some(s => s.reachable)) {
102834 return;
102835 }
102836
102837 for (const segment of scopeInfo.codePath.currentSegments) {
102838 const info = segmentInfoMap.get(segment);
102839
102840 if (info) {
102841 info.uselessReturns.push(node);
102842 info.returned = true;
102843 }
102844 }
102845
102846 scopeInfo.uselessReturns.push(node);
102847 },
102848
102849 /*
102850 * Registers for all statement nodes except FunctionDeclaration, BlockStatement, BreakStatement.
102851 * Removes return statements of the current segments from the useless return statement list.
102852 */
102853 ClassDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
102854 ContinueStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102855 DebuggerStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102856 DoWhileStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102857 EmptyStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102858 ExpressionStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102859 ForInStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102860 ForOfStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102861 ForStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102862 IfStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102863 ImportDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
102864 LabeledStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102865 SwitchStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102866 ThrowStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102867 TryStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102868 VariableDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
102869 WhileStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102870 WithStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
102871 ExportNamedDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
102872 ExportDefaultDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
102873 ExportAllDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed
102874 };
102875 }
102876
102877 };
102878
102879 /***/ }),
102880 /* 785 */
102881 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
102882
102883 "use strict";
102884 /**
102885 * @fileoverview Rule to check for the usage of var.
102886 * @author Jamund Ferguson
102887 */
102888 //------------------------------------------------------------------------------
102889 // Requirements
102890 //------------------------------------------------------------------------------
102891
102892 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
102893 // Helpers
102894 //------------------------------------------------------------------------------
102895
102896 /**
102897 * Check whether a given variable is a global variable or not.
102898 * @param {eslint-scope.Variable} variable The variable to check.
102899 * @returns {boolean} `true` if the variable is a global variable.
102900 */
102901
102902
102903 function isGlobal(variable) {
102904 return Boolean(variable.scope) && variable.scope.type === "global";
102905 }
102906 /**
102907 * Finds the nearest function scope or global scope walking up the scope
102908 * hierarchy.
102909 * @param {eslint-scope.Scope} scope The scope to traverse.
102910 * @returns {eslint-scope.Scope} a function scope or global scope containing the given
102911 * scope.
102912 */
102913
102914
102915 function getEnclosingFunctionScope(scope) {
102916 let currentScope = scope;
102917
102918 while (currentScope.type !== "function" && currentScope.type !== "global") {
102919 currentScope = currentScope.upper;
102920 }
102921
102922 return currentScope;
102923 }
102924 /**
102925 * Checks whether the given variable has any references from a more specific
102926 * function expression (i.e. a closure).
102927 * @param {eslint-scope.Variable} variable A variable to check.
102928 * @returns {boolean} `true` if the variable is used from a closure.
102929 */
102930
102931
102932 function isReferencedInClosure(variable) {
102933 const enclosingFunctionScope = getEnclosingFunctionScope(variable.scope);
102934 return variable.references.some(reference => getEnclosingFunctionScope(reference.from) !== enclosingFunctionScope);
102935 }
102936 /**
102937 * Checks whether the given node is the assignee of a loop.
102938 * @param {ASTNode} node A VariableDeclaration node to check.
102939 * @returns {boolean} `true` if the declaration is assigned as part of loop
102940 * iteration.
102941 */
102942
102943
102944 function isLoopAssignee(node) {
102945 return (node.parent.type === "ForOfStatement" || node.parent.type === "ForInStatement") && node === node.parent.left;
102946 }
102947 /**
102948 * Checks whether the given variable declaration is immediately initialized.
102949 * @param {ASTNode} node A VariableDeclaration node to check.
102950 * @returns {boolean} `true` if the declaration has an initializer.
102951 */
102952
102953
102954 function isDeclarationInitialized(node) {
102955 return node.declarations.every(declarator => declarator.init !== null);
102956 }
102957
102958 const SCOPE_NODE_TYPE = /^(?:Program|BlockStatement|SwitchStatement|ForStatement|ForInStatement|ForOfStatement)$/u;
102959 /**
102960 * Gets the scope node which directly contains a given node.
102961 * @param {ASTNode} node A node to get. This is a `VariableDeclaration` or
102962 * an `Identifier`.
102963 * @returns {ASTNode} A scope node. This is one of `Program`, `BlockStatement`,
102964 * `SwitchStatement`, `ForStatement`, `ForInStatement`, and
102965 * `ForOfStatement`.
102966 */
102967
102968 function getScopeNode(node) {
102969 for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
102970 if (SCOPE_NODE_TYPE.test(currentNode.type)) {
102971 return currentNode;
102972 }
102973 }
102974 /* istanbul ignore next : unreachable */
102975
102976
102977 return null;
102978 }
102979 /**
102980 * Checks whether a given variable is redeclared or not.
102981 * @param {eslint-scope.Variable} variable A variable to check.
102982 * @returns {boolean} `true` if the variable is redeclared.
102983 */
102984
102985
102986 function isRedeclared(variable) {
102987 return variable.defs.length >= 2;
102988 }
102989 /**
102990 * Checks whether a given variable is used from outside of the specified scope.
102991 * @param {ASTNode} scopeNode A scope node to check.
102992 * @returns {Function} The predicate function which checks whether a given
102993 * variable is used from outside of the specified scope.
102994 */
102995
102996
102997 function isUsedFromOutsideOf(scopeNode) {
102998 /**
102999 * Checks whether a given reference is inside of the specified scope or not.
103000 * @param {eslint-scope.Reference} reference A reference to check.
103001 * @returns {boolean} `true` if the reference is inside of the specified
103002 * scope.
103003 */
103004 function isOutsideOfScope(reference) {
103005 const scope = scopeNode.range;
103006 const id = reference.identifier.range;
103007 return id[0] < scope[0] || id[1] > scope[1];
103008 }
103009
103010 return function (variable) {
103011 return variable.references.some(isOutsideOfScope);
103012 };
103013 }
103014 /**
103015 * Creates the predicate function which checks whether a variable has their references in TDZ.
103016 *
103017 * The predicate function would return `true`:
103018 *
103019 * - if a reference is before the declarator. E.g. (var a = b, b = 1;)(var {a = b, b} = {};)
103020 * - if a reference is in the expression of their default value. E.g. (var {a = a} = {};)
103021 * - if a reference is in the expression of their initializer. E.g. (var a = a;)
103022 * @param {ASTNode} node The initializer node of VariableDeclarator.
103023 * @returns {Function} The predicate function.
103024 * @private
103025 */
103026
103027
103028 function hasReferenceInTDZ(node) {
103029 const initStart = node.range[0];
103030 const initEnd = node.range[1];
103031 return variable => {
103032 const id = variable.defs[0].name;
103033 const idStart = id.range[0];
103034 const defaultValue = id.parent.type === "AssignmentPattern" ? id.parent.right : null;
103035 const defaultStart = defaultValue && defaultValue.range[0];
103036 const defaultEnd = defaultValue && defaultValue.range[1];
103037 return variable.references.some(reference => {
103038 const start = reference.identifier.range[0];
103039 const end = reference.identifier.range[1];
103040 return !reference.init && (start < idStart || defaultValue !== null && start >= defaultStart && end <= defaultEnd || start >= initStart && end <= initEnd);
103041 });
103042 };
103043 }
103044 /**
103045 * Checks whether a given variable has name that is allowed for 'var' declarations,
103046 * but disallowed for `let` declarations.
103047 * @param {eslint-scope.Variable} variable The variable to check.
103048 * @returns {boolean} `true` if the variable has a disallowed name.
103049 */
103050
103051
103052 function hasNameDisallowedForLetDeclarations(variable) {
103053 return variable.name === "let";
103054 } //------------------------------------------------------------------------------
103055 // Rule Definition
103056 //------------------------------------------------------------------------------
103057
103058
103059 module.exports = {
103060 meta: {
103061 type: "suggestion",
103062 docs: {
103063 description: "require `let` or `const` instead of `var`",
103064 recommended: false,
103065 url: "https://eslint.org/docs/rules/no-var"
103066 },
103067 schema: [],
103068 fixable: "code",
103069 messages: {
103070 unexpectedVar: "Unexpected var, use let or const instead."
103071 }
103072 },
103073
103074 create(context) {
103075 const sourceCode = context.getSourceCode();
103076 /**
103077 * Checks whether the variables which are defined by the given declarator node have their references in TDZ.
103078 * @param {ASTNode} declarator The VariableDeclarator node to check.
103079 * @returns {boolean} `true` if one of the variables which are defined by the given declarator node have their references in TDZ.
103080 */
103081
103082 function hasSelfReferenceInTDZ(declarator) {
103083 if (!declarator.init) {
103084 return false;
103085 }
103086
103087 const variables = context.getDeclaredVariables(declarator);
103088 return variables.some(hasReferenceInTDZ(declarator.init));
103089 }
103090 /**
103091 * Checks whether it can fix a given variable declaration or not.
103092 * It cannot fix if the following cases:
103093 *
103094 * - A variable is a global variable.
103095 * - A variable is declared on a SwitchCase node.
103096 * - A variable is redeclared.
103097 * - A variable is used from outside the scope.
103098 * - A variable is used from a closure within a loop.
103099 * - A variable might be used before it is assigned within a loop.
103100 * - A variable might be used in TDZ.
103101 * - A variable is declared in statement position (e.g. a single-line `IfStatement`)
103102 * - A variable has name that is disallowed for `let` declarations.
103103 *
103104 * ## A variable is declared on a SwitchCase node.
103105 *
103106 * If this rule modifies 'var' declarations on a SwitchCase node, it
103107 * would generate the warnings of 'no-case-declarations' rule. And the
103108 * 'eslint:recommended' preset includes 'no-case-declarations' rule, so
103109 * this rule doesn't modify those declarations.
103110 *
103111 * ## A variable is redeclared.
103112 *
103113 * The language spec disallows redeclarations of `let` declarations.
103114 * Those variables would cause syntax errors.
103115 *
103116 * ## A variable is used from outside the scope.
103117 *
103118 * The language spec disallows accesses from outside of the scope for
103119 * `let` declarations. Those variables would cause reference errors.
103120 *
103121 * ## A variable is used from a closure within a loop.
103122 *
103123 * A `var` declaration within a loop shares the same variable instance
103124 * across all loop iterations, while a `let` declaration creates a new
103125 * instance for each iteration. This means if a variable in a loop is
103126 * referenced by any closure, changing it from `var` to `let` would
103127 * change the behavior in a way that is generally unsafe.
103128 *
103129 * ## A variable might be used before it is assigned within a loop.
103130 *
103131 * Within a loop, a `let` declaration without an initializer will be
103132 * initialized to null, while a `var` declaration will retain its value
103133 * from the previous iteration, so it is only safe to change `var` to
103134 * `let` if we can statically determine that the variable is always
103135 * assigned a value before its first access in the loop body. To keep
103136 * the implementation simple, we only convert `var` to `let` within
103137 * loops when the variable is a loop assignee or the declaration has an
103138 * initializer.
103139 * @param {ASTNode} node A variable declaration node to check.
103140 * @returns {boolean} `true` if it can fix the node.
103141 */
103142
103143
103144 function canFix(node) {
103145 const variables = context.getDeclaredVariables(node);
103146 const scopeNode = getScopeNode(node);
103147
103148 if (node.parent.type === "SwitchCase" || node.declarations.some(hasSelfReferenceInTDZ) || variables.some(isGlobal) || variables.some(isRedeclared) || variables.some(isUsedFromOutsideOf(scopeNode)) || variables.some(hasNameDisallowedForLetDeclarations)) {
103149 return false;
103150 }
103151
103152 if (astUtils.isInLoop(node)) {
103153 if (variables.some(isReferencedInClosure)) {
103154 return false;
103155 }
103156
103157 if (!isLoopAssignee(node) && !isDeclarationInitialized(node)) {
103158 return false;
103159 }
103160 }
103161
103162 if (!isLoopAssignee(node) && !(node.parent.type === "ForStatement" && node.parent.init === node) && !astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)) {
103163 // If the declaration is not in a block, e.g. `if (foo) var bar = 1;`, then it can't be fixed.
103164 return false;
103165 }
103166
103167 return true;
103168 }
103169 /**
103170 * Reports a given variable declaration node.
103171 * @param {ASTNode} node A variable declaration node to report.
103172 * @returns {void}
103173 */
103174
103175
103176 function report(node) {
103177 context.report({
103178 node,
103179 messageId: "unexpectedVar",
103180
103181 fix(fixer) {
103182 const varToken = sourceCode.getFirstToken(node, {
103183 filter: t => t.value === "var"
103184 });
103185 return canFix(node) ? fixer.replaceText(varToken, "let") : null;
103186 }
103187
103188 });
103189 }
103190
103191 return {
103192 "VariableDeclaration:exit"(node) {
103193 if (node.kind === "var") {
103194 report(node);
103195 }
103196 }
103197
103198 };
103199 }
103200
103201 };
103202
103203 /***/ }),
103204 /* 786 */
103205 /***/ ((module) => {
103206
103207 "use strict";
103208 /**
103209 * @fileoverview Rule to disallow use of void operator.
103210 * @author Mike Sidorov
103211 */
103212 //------------------------------------------------------------------------------
103213 // Rule Definition
103214 //------------------------------------------------------------------------------
103215
103216 module.exports = {
103217 meta: {
103218 type: "suggestion",
103219 docs: {
103220 description: "disallow `void` operators",
103221 recommended: false,
103222 url: "https://eslint.org/docs/rules/no-void"
103223 },
103224 messages: {
103225 noVoid: "Expected 'undefined' and instead saw 'void'."
103226 },
103227 schema: [{
103228 type: "object",
103229 properties: {
103230 allowAsStatement: {
103231 type: "boolean",
103232 default: false
103233 }
103234 },
103235 additionalProperties: false
103236 }]
103237 },
103238
103239 create(context) {
103240 const allowAsStatement = context.options[0] && context.options[0].allowAsStatement; //--------------------------------------------------------------------------
103241 // Public
103242 //--------------------------------------------------------------------------
103243
103244 return {
103245 'UnaryExpression[operator="void"]'(node) {
103246 if (allowAsStatement && node.parent && node.parent.type === "ExpressionStatement") {
103247 return;
103248 }
103249
103250 context.report({
103251 node,
103252 messageId: "noVoid"
103253 });
103254 }
103255
103256 };
103257 }
103258
103259 };
103260
103261 /***/ }),
103262 /* 787 */
103263 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
103264
103265 "use strict";
103266 /**
103267 * @fileoverview Rule that warns about used warning comments
103268 * @author Alexander Schmidt <https://github.com/lxanders>
103269 */
103270
103271
103272 const escapeRegExp = __webpack_require__(525);
103273
103274 const astUtils = __webpack_require__(548);
103275
103276 const CHAR_LIMIT = 40; //------------------------------------------------------------------------------
103277 // Rule Definition
103278 //------------------------------------------------------------------------------
103279
103280 module.exports = {
103281 meta: {
103282 type: "suggestion",
103283 docs: {
103284 description: "disallow specified warning terms in comments",
103285 recommended: false,
103286 url: "https://eslint.org/docs/rules/no-warning-comments"
103287 },
103288 schema: [{
103289 type: "object",
103290 properties: {
103291 terms: {
103292 type: "array",
103293 items: {
103294 type: "string"
103295 }
103296 },
103297 location: {
103298 enum: ["start", "anywhere"]
103299 }
103300 },
103301 additionalProperties: false
103302 }],
103303 messages: {
103304 unexpectedComment: "Unexpected '{{matchedTerm}}' comment: '{{comment}}'."
103305 }
103306 },
103307
103308 create(context) {
103309 const sourceCode = context.getSourceCode(),
103310 configuration = context.options[0] || {},
103311 warningTerms = configuration.terms || ["todo", "fixme", "xxx"],
103312 location = configuration.location || "start",
103313 selfConfigRegEx = /\bno-warning-comments\b/u;
103314 /**
103315 * Convert a warning term into a RegExp which will match a comment containing that whole word in the specified
103316 * location ("start" or "anywhere"). If the term starts or ends with non word characters, then the match will not
103317 * require word boundaries on that side.
103318 * @param {string} term A term to convert to a RegExp
103319 * @returns {RegExp} The term converted to a RegExp
103320 */
103321
103322 function convertToRegExp(term) {
103323 const escaped = escapeRegExp(term);
103324 const wordBoundary = "\\b";
103325 const eitherOrWordBoundary = "|".concat(wordBoundary);
103326 let prefix;
103327 /*
103328 * If the term ends in a word character (a-z0-9_), ensure a word
103329 * boundary at the end, so that substrings do not get falsely
103330 * matched. eg "todo" in a string such as "mastodon".
103331 * If the term ends in a non-word character, then \b won't match on
103332 * the boundary to the next non-word character, which would likely
103333 * be a space. For example `/\bFIX!\b/.test('FIX! blah') === false`.
103334 * In these cases, use no bounding match. Same applies for the
103335 * prefix, handled below.
103336 */
103337
103338 const suffix = /\w$/u.test(term) ? "\\b" : "";
103339
103340 if (location === "start") {
103341 /*
103342 * When matching at the start, ignore leading whitespace, and
103343 * there's no need to worry about word boundaries.
103344 */
103345 prefix = "^\\s*";
103346 } else if (/^\w/u.test(term)) {
103347 prefix = wordBoundary;
103348 } else {
103349 prefix = "";
103350 }
103351
103352 if (location === "start") {
103353 /*
103354 * For location "start" the regex should be
103355 * ^\s*TERM\b. This checks the word boundary
103356 * at the beginning of the comment.
103357 */
103358 return new RegExp(prefix + escaped + suffix, "iu");
103359 }
103360 /*
103361 * For location "anywhere" the regex should be
103362 * \bTERM\b|\bTERM\b, this checks the entire comment
103363 * for the term.
103364 */
103365
103366
103367 return new RegExp(prefix + escaped + suffix + eitherOrWordBoundary + term + wordBoundary, "iu");
103368 }
103369
103370 const warningRegExps = warningTerms.map(convertToRegExp);
103371 /**
103372 * Checks the specified comment for matches of the configured warning terms and returns the matches.
103373 * @param {string} comment The comment which is checked.
103374 * @returns {Array} All matched warning terms for this comment.
103375 */
103376
103377 function commentContainsWarningTerm(comment) {
103378 const matches = [];
103379 warningRegExps.forEach((regex, index) => {
103380 if (regex.test(comment)) {
103381 matches.push(warningTerms[index]);
103382 }
103383 });
103384 return matches;
103385 }
103386 /**
103387 * Checks the specified node for matching warning comments and reports them.
103388 * @param {ASTNode} node The AST node being checked.
103389 * @returns {void} undefined.
103390 */
103391
103392
103393 function checkComment(node) {
103394 const comment = node.value;
103395
103396 if (astUtils.isDirectiveComment(node) && selfConfigRegEx.test(comment)) {
103397 return;
103398 }
103399
103400 const matches = commentContainsWarningTerm(comment);
103401 matches.forEach(matchedTerm => {
103402 let commentToDisplay = "";
103403 let truncated = false;
103404
103405 for (const c of comment.trim().split(/\s+/u)) {
103406 const tmp = commentToDisplay ? "".concat(commentToDisplay, " ").concat(c) : c;
103407
103408 if (tmp.length <= CHAR_LIMIT) {
103409 commentToDisplay = tmp;
103410 } else {
103411 truncated = true;
103412 break;
103413 }
103414 }
103415
103416 context.report({
103417 node,
103418 messageId: "unexpectedComment",
103419 data: {
103420 matchedTerm,
103421 comment: "".concat(commentToDisplay).concat(truncated ? "..." : "")
103422 }
103423 });
103424 });
103425 }
103426
103427 return {
103428 Program() {
103429 const comments = sourceCode.getAllComments();
103430 comments.filter(token => token.type !== "Shebang").forEach(checkComment);
103431 }
103432
103433 };
103434 }
103435
103436 };
103437
103438 /***/ }),
103439 /* 788 */
103440 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
103441
103442 "use strict";
103443 /**
103444 * @fileoverview Rule to disallow whitespace before properties
103445 * @author Kai Cataldo
103446 */
103447 //------------------------------------------------------------------------------
103448 // Requirements
103449 //------------------------------------------------------------------------------
103450
103451 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
103452 // Rule Definition
103453 //------------------------------------------------------------------------------
103454
103455
103456 module.exports = {
103457 meta: {
103458 type: "layout",
103459 docs: {
103460 description: "disallow whitespace before properties",
103461 recommended: false,
103462 url: "https://eslint.org/docs/rules/no-whitespace-before-property"
103463 },
103464 fixable: "whitespace",
103465 schema: [],
103466 messages: {
103467 unexpectedWhitespace: "Unexpected whitespace before property {{propName}}."
103468 }
103469 },
103470
103471 create(context) {
103472 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
103473 // Helpers
103474 //--------------------------------------------------------------------------
103475
103476 /**
103477 * Reports whitespace before property token
103478 * @param {ASTNode} node the node to report in the event of an error
103479 * @param {Token} leftToken the left token
103480 * @param {Token} rightToken the right token
103481 * @returns {void}
103482 * @private
103483 */
103484
103485 function reportError(node, leftToken, rightToken) {
103486 context.report({
103487 node,
103488 messageId: "unexpectedWhitespace",
103489 data: {
103490 propName: sourceCode.getText(node.property)
103491 },
103492
103493 fix(fixer) {
103494 let replacementText = "";
103495
103496 if (!node.computed && !node.optional && astUtils.isDecimalInteger(node.object)) {
103497 /*
103498 * If the object is a number literal, fixing it to something like 5.toString() would cause a SyntaxError.
103499 * Don't fix this case.
103500 */
103501 return null;
103502 } // Don't fix if comments exist.
103503
103504
103505 if (sourceCode.commentsExistBetween(leftToken, rightToken)) {
103506 return null;
103507 }
103508
103509 if (node.optional) {
103510 replacementText = "?.";
103511 } else if (!node.computed) {
103512 replacementText = ".";
103513 }
103514
103515 return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], replacementText);
103516 }
103517
103518 });
103519 } //--------------------------------------------------------------------------
103520 // Public
103521 //--------------------------------------------------------------------------
103522
103523
103524 return {
103525 MemberExpression(node) {
103526 let rightToken;
103527 let leftToken;
103528
103529 if (!astUtils.isTokenOnSameLine(node.object, node.property)) {
103530 return;
103531 }
103532
103533 if (node.computed) {
103534 rightToken = sourceCode.getTokenBefore(node.property, astUtils.isOpeningBracketToken);
103535 leftToken = sourceCode.getTokenBefore(rightToken, node.optional ? 1 : 0);
103536 } else {
103537 rightToken = sourceCode.getFirstToken(node.property);
103538 leftToken = sourceCode.getTokenBefore(rightToken, 1);
103539 }
103540
103541 if (sourceCode.isSpaceBetweenTokens(leftToken, rightToken)) {
103542 reportError(node, leftToken, rightToken);
103543 }
103544 }
103545
103546 };
103547 }
103548
103549 };
103550
103551 /***/ }),
103552 /* 789 */
103553 /***/ ((module) => {
103554
103555 "use strict";
103556 /**
103557 * @fileoverview Rule to flag use of with statement
103558 * @author Nicholas C. Zakas
103559 */
103560 //------------------------------------------------------------------------------
103561 // Rule Definition
103562 //------------------------------------------------------------------------------
103563
103564 module.exports = {
103565 meta: {
103566 type: "suggestion",
103567 docs: {
103568 description: "disallow `with` statements",
103569 recommended: true,
103570 url: "https://eslint.org/docs/rules/no-with"
103571 },
103572 schema: [],
103573 messages: {
103574 unexpectedWith: "Unexpected use of 'with' statement."
103575 }
103576 },
103577
103578 create(context) {
103579 return {
103580 WithStatement(node) {
103581 context.report({
103582 node,
103583 messageId: "unexpectedWith"
103584 });
103585 }
103586
103587 };
103588 }
103589
103590 };
103591
103592 /***/ }),
103593 /* 790 */
103594 /***/ ((module) => {
103595
103596 "use strict";
103597 /**
103598 * @fileoverview enforce the location of single-line statements
103599 * @author Teddy Katz
103600 */
103601 //------------------------------------------------------------------------------
103602 // Rule Definition
103603 //------------------------------------------------------------------------------
103604
103605 const POSITION_SCHEMA = {
103606 enum: ["beside", "below", "any"]
103607 };
103608 module.exports = {
103609 meta: {
103610 type: "layout",
103611 docs: {
103612 description: "enforce the location of single-line statements",
103613 recommended: false,
103614 url: "https://eslint.org/docs/rules/nonblock-statement-body-position"
103615 },
103616 fixable: "whitespace",
103617 schema: [POSITION_SCHEMA, {
103618 properties: {
103619 overrides: {
103620 properties: {
103621 if: POSITION_SCHEMA,
103622 else: POSITION_SCHEMA,
103623 while: POSITION_SCHEMA,
103624 do: POSITION_SCHEMA,
103625 for: POSITION_SCHEMA
103626 },
103627 additionalProperties: false
103628 }
103629 },
103630 additionalProperties: false
103631 }],
103632 messages: {
103633 expectNoLinebreak: "Expected no linebreak before this statement.",
103634 expectLinebreak: "Expected a linebreak before this statement."
103635 }
103636 },
103637
103638 create(context) {
103639 const sourceCode = context.getSourceCode(); //----------------------------------------------------------------------
103640 // Helpers
103641 //----------------------------------------------------------------------
103642
103643 /**
103644 * Gets the applicable preference for a particular keyword
103645 * @param {string} keywordName The name of a keyword, e.g. 'if'
103646 * @returns {string} The applicable option for the keyword, e.g. 'beside'
103647 */
103648
103649 function getOption(keywordName) {
103650 return context.options[1] && context.options[1].overrides && context.options[1].overrides[keywordName] || context.options[0] || "beside";
103651 }
103652 /**
103653 * Validates the location of a single-line statement
103654 * @param {ASTNode} node The single-line statement
103655 * @param {string} keywordName The applicable keyword name for the single-line statement
103656 * @returns {void}
103657 */
103658
103659
103660 function validateStatement(node, keywordName) {
103661 const option = getOption(keywordName);
103662
103663 if (node.type === "BlockStatement" || option === "any") {
103664 return;
103665 }
103666
103667 const tokenBefore = sourceCode.getTokenBefore(node);
103668
103669 if (tokenBefore.loc.end.line === node.loc.start.line && option === "below") {
103670 context.report({
103671 node,
103672 messageId: "expectLinebreak",
103673 fix: fixer => fixer.insertTextBefore(node, "\n")
103674 });
103675 } else if (tokenBefore.loc.end.line !== node.loc.start.line && option === "beside") {
103676 context.report({
103677 node,
103678 messageId: "expectNoLinebreak",
103679
103680 fix(fixer) {
103681 if (sourceCode.getText().slice(tokenBefore.range[1], node.range[0]).trim()) {
103682 return null;
103683 }
103684
103685 return fixer.replaceTextRange([tokenBefore.range[1], node.range[0]], " ");
103686 }
103687
103688 });
103689 }
103690 } //----------------------------------------------------------------------
103691 // Public
103692 //----------------------------------------------------------------------
103693
103694
103695 return {
103696 IfStatement(node) {
103697 validateStatement(node.consequent, "if"); // Check the `else` node, but don't check 'else if' statements.
103698
103699 if (node.alternate && node.alternate.type !== "IfStatement") {
103700 validateStatement(node.alternate, "else");
103701 }
103702 },
103703
103704 WhileStatement: node => validateStatement(node.body, "while"),
103705 DoWhileStatement: node => validateStatement(node.body, "do"),
103706 ForStatement: node => validateStatement(node.body, "for"),
103707 ForInStatement: node => validateStatement(node.body, "for"),
103708 ForOfStatement: node => validateStatement(node.body, "for")
103709 };
103710 }
103711
103712 };
103713
103714 /***/ }),
103715 /* 791 */
103716 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
103717
103718 "use strict";
103719 /**
103720 * @fileoverview Rule to require or disallow line breaks inside braces.
103721 * @author Toru Nagashima
103722 */
103723 //------------------------------------------------------------------------------
103724 // Requirements
103725 //------------------------------------------------------------------------------
103726
103727 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
103728 // Helpers
103729 //------------------------------------------------------------------------------
103730 // Schema objects.
103731
103732
103733 const OPTION_VALUE = {
103734 oneOf: [{
103735 enum: ["always", "never"]
103736 }, {
103737 type: "object",
103738 properties: {
103739 multiline: {
103740 type: "boolean"
103741 },
103742 minProperties: {
103743 type: "integer",
103744 minimum: 0
103745 },
103746 consistent: {
103747 type: "boolean"
103748 }
103749 },
103750 additionalProperties: false,
103751 minProperties: 1
103752 }]
103753 };
103754 /**
103755 * Normalizes a given option value.
103756 * @param {string|Object|undefined} value An option value to parse.
103757 * @returns {{multiline: boolean, minProperties: number, consistent: boolean}} Normalized option object.
103758 */
103759
103760 function normalizeOptionValue(value) {
103761 let multiline = false;
103762 let minProperties = Number.POSITIVE_INFINITY;
103763 let consistent = false;
103764
103765 if (value) {
103766 if (value === "always") {
103767 minProperties = 0;
103768 } else if (value === "never") {
103769 minProperties = Number.POSITIVE_INFINITY;
103770 } else {
103771 multiline = Boolean(value.multiline);
103772 minProperties = value.minProperties || Number.POSITIVE_INFINITY;
103773 consistent = Boolean(value.consistent);
103774 }
103775 } else {
103776 consistent = true;
103777 }
103778
103779 return {
103780 multiline,
103781 minProperties,
103782 consistent
103783 };
103784 }
103785 /**
103786 * Checks if a value is an object.
103787 * @param {any} value The value to check
103788 * @returns {boolean} `true` if the value is an object, otherwise `false`
103789 */
103790
103791
103792 function isObject(value) {
103793 return typeof value === "object" && value !== null;
103794 }
103795 /**
103796 * Checks if an option is a node-specific option
103797 * @param {any} option The option to check
103798 * @returns {boolean} `true` if the option is node-specific, otherwise `false`
103799 */
103800
103801
103802 function isNodeSpecificOption(option) {
103803 return isObject(option) || typeof option === "string";
103804 }
103805 /**
103806 * Normalizes a given option value.
103807 * @param {string|Object|undefined} options An option value to parse.
103808 * @returns {{
103809 * ObjectExpression: {multiline: boolean, minProperties: number, consistent: boolean},
103810 * ObjectPattern: {multiline: boolean, minProperties: number, consistent: boolean},
103811 * ImportDeclaration: {multiline: boolean, minProperties: number, consistent: boolean},
103812 * ExportNamedDeclaration : {multiline: boolean, minProperties: number, consistent: boolean}
103813 * }} Normalized option object.
103814 */
103815
103816
103817 function normalizeOptions(options) {
103818 if (isObject(options) && Object.values(options).some(isNodeSpecificOption)) {
103819 return {
103820 ObjectExpression: normalizeOptionValue(options.ObjectExpression),
103821 ObjectPattern: normalizeOptionValue(options.ObjectPattern),
103822 ImportDeclaration: normalizeOptionValue(options.ImportDeclaration),
103823 ExportNamedDeclaration: normalizeOptionValue(options.ExportDeclaration)
103824 };
103825 }
103826
103827 const value = normalizeOptionValue(options);
103828 return {
103829 ObjectExpression: value,
103830 ObjectPattern: value,
103831 ImportDeclaration: value,
103832 ExportNamedDeclaration: value
103833 };
103834 }
103835 /**
103836 * Determines if ObjectExpression, ObjectPattern, ImportDeclaration or ExportNamedDeclaration
103837 * node needs to be checked for missing line breaks
103838 * @param {ASTNode} node Node under inspection
103839 * @param {Object} options option specific to node type
103840 * @param {Token} first First object property
103841 * @param {Token} last Last object property
103842 * @returns {boolean} `true` if node needs to be checked for missing line breaks
103843 */
103844
103845
103846 function areLineBreaksRequired(node, options, first, last) {
103847 let objectProperties;
103848
103849 if (node.type === "ObjectExpression" || node.type === "ObjectPattern") {
103850 objectProperties = node.properties;
103851 } else {
103852 // is ImportDeclaration or ExportNamedDeclaration
103853 objectProperties = node.specifiers.filter(s => s.type === "ImportSpecifier" || s.type === "ExportSpecifier");
103854 }
103855
103856 return objectProperties.length >= options.minProperties || options.multiline && objectProperties.length > 0 && first.loc.start.line !== last.loc.end.line;
103857 } //------------------------------------------------------------------------------
103858 // Rule Definition
103859 //------------------------------------------------------------------------------
103860
103861
103862 module.exports = {
103863 meta: {
103864 type: "layout",
103865 docs: {
103866 description: "enforce consistent line breaks after opening and before closing braces",
103867 recommended: false,
103868 url: "https://eslint.org/docs/rules/object-curly-newline"
103869 },
103870 fixable: "whitespace",
103871 schema: [{
103872 oneOf: [OPTION_VALUE, {
103873 type: "object",
103874 properties: {
103875 ObjectExpression: OPTION_VALUE,
103876 ObjectPattern: OPTION_VALUE,
103877 ImportDeclaration: OPTION_VALUE,
103878 ExportDeclaration: OPTION_VALUE
103879 },
103880 additionalProperties: false,
103881 minProperties: 1
103882 }]
103883 }],
103884 messages: {
103885 unexpectedLinebreakBeforeClosingBrace: "Unexpected line break before this closing brace.",
103886 unexpectedLinebreakAfterOpeningBrace: "Unexpected line break after this opening brace.",
103887 expectedLinebreakBeforeClosingBrace: "Expected a line break before this closing brace.",
103888 expectedLinebreakAfterOpeningBrace: "Expected a line break after this opening brace."
103889 }
103890 },
103891
103892 create(context) {
103893 const sourceCode = context.getSourceCode();
103894 const normalizedOptions = normalizeOptions(context.options[0]);
103895 /**
103896 * Reports a given node if it violated this rule.
103897 * @param {ASTNode} node A node to check. This is an ObjectExpression, ObjectPattern, ImportDeclaration or ExportNamedDeclaration node.
103898 * @returns {void}
103899 */
103900
103901 function check(node) {
103902 const options = normalizedOptions[node.type];
103903
103904 if (node.type === "ImportDeclaration" && !node.specifiers.some(specifier => specifier.type === "ImportSpecifier") || node.type === "ExportNamedDeclaration" && !node.specifiers.some(specifier => specifier.type === "ExportSpecifier")) {
103905 return;
103906 }
103907
103908 const openBrace = sourceCode.getFirstToken(node, token => token.value === "{");
103909 let closeBrace;
103910
103911 if (node.typeAnnotation) {
103912 closeBrace = sourceCode.getTokenBefore(node.typeAnnotation);
103913 } else {
103914 closeBrace = sourceCode.getLastToken(node, token => token.value === "}");
103915 }
103916
103917 let first = sourceCode.getTokenAfter(openBrace, {
103918 includeComments: true
103919 });
103920 let last = sourceCode.getTokenBefore(closeBrace, {
103921 includeComments: true
103922 });
103923 const needsLineBreaks = areLineBreaksRequired(node, options, first, last);
103924 const hasCommentsFirstToken = astUtils.isCommentToken(first);
103925 const hasCommentsLastToken = astUtils.isCommentToken(last);
103926 /*
103927 * Use tokens or comments to check multiline or not.
103928 * But use only tokens to check whether line breaks are needed.
103929 * This allows:
103930 * var obj = { // eslint-disable-line foo
103931 * a: 1
103932 * }
103933 */
103934
103935 first = sourceCode.getTokenAfter(openBrace);
103936 last = sourceCode.getTokenBefore(closeBrace);
103937
103938 if (needsLineBreaks) {
103939 if (astUtils.isTokenOnSameLine(openBrace, first)) {
103940 context.report({
103941 messageId: "expectedLinebreakAfterOpeningBrace",
103942 node,
103943 loc: openBrace.loc,
103944
103945 fix(fixer) {
103946 if (hasCommentsFirstToken) {
103947 return null;
103948 }
103949
103950 return fixer.insertTextAfter(openBrace, "\n");
103951 }
103952
103953 });
103954 }
103955
103956 if (astUtils.isTokenOnSameLine(last, closeBrace)) {
103957 context.report({
103958 messageId: "expectedLinebreakBeforeClosingBrace",
103959 node,
103960 loc: closeBrace.loc,
103961
103962 fix(fixer) {
103963 if (hasCommentsLastToken) {
103964 return null;
103965 }
103966
103967 return fixer.insertTextBefore(closeBrace, "\n");
103968 }
103969
103970 });
103971 }
103972 } else {
103973 const consistent = options.consistent;
103974 const hasLineBreakBetweenOpenBraceAndFirst = !astUtils.isTokenOnSameLine(openBrace, first);
103975 const hasLineBreakBetweenCloseBraceAndLast = !astUtils.isTokenOnSameLine(last, closeBrace);
103976
103977 if (!consistent && hasLineBreakBetweenOpenBraceAndFirst || consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast) {
103978 context.report({
103979 messageId: "unexpectedLinebreakAfterOpeningBrace",
103980 node,
103981 loc: openBrace.loc,
103982
103983 fix(fixer) {
103984 if (hasCommentsFirstToken) {
103985 return null;
103986 }
103987
103988 return fixer.removeRange([openBrace.range[1], first.range[0]]);
103989 }
103990
103991 });
103992 }
103993
103994 if (!consistent && hasLineBreakBetweenCloseBraceAndLast || consistent && !hasLineBreakBetweenOpenBraceAndFirst && hasLineBreakBetweenCloseBraceAndLast) {
103995 context.report({
103996 messageId: "unexpectedLinebreakBeforeClosingBrace",
103997 node,
103998 loc: closeBrace.loc,
103999
104000 fix(fixer) {
104001 if (hasCommentsLastToken) {
104002 return null;
104003 }
104004
104005 return fixer.removeRange([last.range[1], closeBrace.range[0]]);
104006 }
104007
104008 });
104009 }
104010 }
104011 }
104012
104013 return {
104014 ObjectExpression: check,
104015 ObjectPattern: check,
104016 ImportDeclaration: check,
104017 ExportNamedDeclaration: check
104018 };
104019 }
104020
104021 };
104022
104023 /***/ }),
104024 /* 792 */
104025 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
104026
104027 "use strict";
104028 /**
104029 * @fileoverview Disallows or enforces spaces inside of object literals.
104030 * @author Jamund Ferguson
104031 */
104032
104033
104034 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
104035 // Rule Definition
104036 //------------------------------------------------------------------------------
104037
104038
104039 module.exports = {
104040 meta: {
104041 type: "layout",
104042 docs: {
104043 description: "enforce consistent spacing inside braces",
104044 recommended: false,
104045 url: "https://eslint.org/docs/rules/object-curly-spacing"
104046 },
104047 fixable: "whitespace",
104048 schema: [{
104049 enum: ["always", "never"]
104050 }, {
104051 type: "object",
104052 properties: {
104053 arraysInObjects: {
104054 type: "boolean"
104055 },
104056 objectsInObjects: {
104057 type: "boolean"
104058 }
104059 },
104060 additionalProperties: false
104061 }],
104062 messages: {
104063 requireSpaceBefore: "A space is required before '{{token}}'.",
104064 requireSpaceAfter: "A space is required after '{{token}}'.",
104065 unexpectedSpaceBefore: "There should be no space before '{{token}}'.",
104066 unexpectedSpaceAfter: "There should be no space after '{{token}}'."
104067 }
104068 },
104069
104070 create(context) {
104071 const spaced = context.options[0] === "always",
104072 sourceCode = context.getSourceCode();
104073 /**
104074 * Determines whether an option is set, relative to the spacing option.
104075 * If spaced is "always", then check whether option is set to false.
104076 * If spaced is "never", then check whether option is set to true.
104077 * @param {Object} option The option to exclude.
104078 * @returns {boolean} Whether or not the property is excluded.
104079 */
104080
104081 function isOptionSet(option) {
104082 return context.options[1] ? context.options[1][option] === !spaced : false;
104083 }
104084
104085 const options = {
104086 spaced,
104087 arraysInObjectsException: isOptionSet("arraysInObjects"),
104088 objectsInObjectsException: isOptionSet("objectsInObjects")
104089 }; //--------------------------------------------------------------------------
104090 // Helpers
104091 //--------------------------------------------------------------------------
104092
104093 /**
104094 * Reports that there shouldn't be a space after the first token
104095 * @param {ASTNode} node The node to report in the event of an error.
104096 * @param {Token} token The token to use for the report.
104097 * @returns {void}
104098 */
104099
104100 function reportNoBeginningSpace(node, token) {
104101 const nextToken = context.getSourceCode().getTokenAfter(token, {
104102 includeComments: true
104103 });
104104 context.report({
104105 node,
104106 loc: {
104107 start: token.loc.end,
104108 end: nextToken.loc.start
104109 },
104110 messageId: "unexpectedSpaceAfter",
104111 data: {
104112 token: token.value
104113 },
104114
104115 fix(fixer) {
104116 return fixer.removeRange([token.range[1], nextToken.range[0]]);
104117 }
104118
104119 });
104120 }
104121 /**
104122 * Reports that there shouldn't be a space before the last token
104123 * @param {ASTNode} node The node to report in the event of an error.
104124 * @param {Token} token The token to use for the report.
104125 * @returns {void}
104126 */
104127
104128
104129 function reportNoEndingSpace(node, token) {
104130 const previousToken = context.getSourceCode().getTokenBefore(token, {
104131 includeComments: true
104132 });
104133 context.report({
104134 node,
104135 loc: {
104136 start: previousToken.loc.end,
104137 end: token.loc.start
104138 },
104139 messageId: "unexpectedSpaceBefore",
104140 data: {
104141 token: token.value
104142 },
104143
104144 fix(fixer) {
104145 return fixer.removeRange([previousToken.range[1], token.range[0]]);
104146 }
104147
104148 });
104149 }
104150 /**
104151 * Reports that there should be a space after the first token
104152 * @param {ASTNode} node The node to report in the event of an error.
104153 * @param {Token} token The token to use for the report.
104154 * @returns {void}
104155 */
104156
104157
104158 function reportRequiredBeginningSpace(node, token) {
104159 context.report({
104160 node,
104161 loc: token.loc,
104162 messageId: "requireSpaceAfter",
104163 data: {
104164 token: token.value
104165 },
104166
104167 fix(fixer) {
104168 return fixer.insertTextAfter(token, " ");
104169 }
104170
104171 });
104172 }
104173 /**
104174 * Reports that there should be a space before the last token
104175 * @param {ASTNode} node The node to report in the event of an error.
104176 * @param {Token} token The token to use for the report.
104177 * @returns {void}
104178 */
104179
104180
104181 function reportRequiredEndingSpace(node, token) {
104182 context.report({
104183 node,
104184 loc: token.loc,
104185 messageId: "requireSpaceBefore",
104186 data: {
104187 token: token.value
104188 },
104189
104190 fix(fixer) {
104191 return fixer.insertTextBefore(token, " ");
104192 }
104193
104194 });
104195 }
104196 /**
104197 * Determines if spacing in curly braces is valid.
104198 * @param {ASTNode} node The AST node to check.
104199 * @param {Token} first The first token to check (should be the opening brace)
104200 * @param {Token} second The second token to check (should be first after the opening brace)
104201 * @param {Token} penultimate The penultimate token to check (should be last before closing brace)
104202 * @param {Token} last The last token to check (should be closing brace)
104203 * @returns {void}
104204 */
104205
104206
104207 function validateBraceSpacing(node, first, second, penultimate, last) {
104208 if (astUtils.isTokenOnSameLine(first, second)) {
104209 const firstSpaced = sourceCode.isSpaceBetweenTokens(first, second);
104210
104211 if (options.spaced && !firstSpaced) {
104212 reportRequiredBeginningSpace(node, first);
104213 }
104214
104215 if (!options.spaced && firstSpaced && second.type !== "Line") {
104216 reportNoBeginningSpace(node, first);
104217 }
104218 }
104219
104220 if (astUtils.isTokenOnSameLine(penultimate, last)) {
104221 const shouldCheckPenultimate = options.arraysInObjectsException && astUtils.isClosingBracketToken(penultimate) || options.objectsInObjectsException && astUtils.isClosingBraceToken(penultimate);
104222 const penultimateType = shouldCheckPenultimate && sourceCode.getNodeByRangeIndex(penultimate.range[0]).type;
104223 const closingCurlyBraceMustBeSpaced = options.arraysInObjectsException && penultimateType === "ArrayExpression" || options.objectsInObjectsException && (penultimateType === "ObjectExpression" || penultimateType === "ObjectPattern") ? !options.spaced : options.spaced;
104224 const lastSpaced = sourceCode.isSpaceBetweenTokens(penultimate, last);
104225
104226 if (closingCurlyBraceMustBeSpaced && !lastSpaced) {
104227 reportRequiredEndingSpace(node, last);
104228 }
104229
104230 if (!closingCurlyBraceMustBeSpaced && lastSpaced) {
104231 reportNoEndingSpace(node, last);
104232 }
104233 }
104234 }
104235 /**
104236 * Gets '}' token of an object node.
104237 *
104238 * Because the last token of object patterns might be a type annotation,
104239 * this traverses tokens preceded by the last property, then returns the
104240 * first '}' token.
104241 * @param {ASTNode} node The node to get. This node is an
104242 * ObjectExpression or an ObjectPattern. And this node has one or
104243 * more properties.
104244 * @returns {Token} '}' token.
104245 */
104246
104247
104248 function getClosingBraceOfObject(node) {
104249 const lastProperty = node.properties[node.properties.length - 1];
104250 return sourceCode.getTokenAfter(lastProperty, astUtils.isClosingBraceToken);
104251 }
104252 /**
104253 * Reports a given object node if spacing in curly braces is invalid.
104254 * @param {ASTNode} node An ObjectExpression or ObjectPattern node to check.
104255 * @returns {void}
104256 */
104257
104258
104259 function checkForObject(node) {
104260 if (node.properties.length === 0) {
104261 return;
104262 }
104263
104264 const first = sourceCode.getFirstToken(node),
104265 last = getClosingBraceOfObject(node),
104266 second = sourceCode.getTokenAfter(first, {
104267 includeComments: true
104268 }),
104269 penultimate = sourceCode.getTokenBefore(last, {
104270 includeComments: true
104271 });
104272 validateBraceSpacing(node, first, second, penultimate, last);
104273 }
104274 /**
104275 * Reports a given import node if spacing in curly braces is invalid.
104276 * @param {ASTNode} node An ImportDeclaration node to check.
104277 * @returns {void}
104278 */
104279
104280
104281 function checkForImport(node) {
104282 if (node.specifiers.length === 0) {
104283 return;
104284 }
104285
104286 let firstSpecifier = node.specifiers[0];
104287 const lastSpecifier = node.specifiers[node.specifiers.length - 1];
104288
104289 if (lastSpecifier.type !== "ImportSpecifier") {
104290 return;
104291 }
104292
104293 if (firstSpecifier.type !== "ImportSpecifier") {
104294 firstSpecifier = node.specifiers[1];
104295 }
104296
104297 const first = sourceCode.getTokenBefore(firstSpecifier),
104298 last = sourceCode.getTokenAfter(lastSpecifier, astUtils.isNotCommaToken),
104299 second = sourceCode.getTokenAfter(first, {
104300 includeComments: true
104301 }),
104302 penultimate = sourceCode.getTokenBefore(last, {
104303 includeComments: true
104304 });
104305 validateBraceSpacing(node, first, second, penultimate, last);
104306 }
104307 /**
104308 * Reports a given export node if spacing in curly braces is invalid.
104309 * @param {ASTNode} node An ExportNamedDeclaration node to check.
104310 * @returns {void}
104311 */
104312
104313
104314 function checkForExport(node) {
104315 if (node.specifiers.length === 0) {
104316 return;
104317 }
104318
104319 const firstSpecifier = node.specifiers[0],
104320 lastSpecifier = node.specifiers[node.specifiers.length - 1],
104321 first = sourceCode.getTokenBefore(firstSpecifier),
104322 last = sourceCode.getTokenAfter(lastSpecifier, astUtils.isNotCommaToken),
104323 second = sourceCode.getTokenAfter(first, {
104324 includeComments: true
104325 }),
104326 penultimate = sourceCode.getTokenBefore(last, {
104327 includeComments: true
104328 });
104329 validateBraceSpacing(node, first, second, penultimate, last);
104330 } //--------------------------------------------------------------------------
104331 // Public
104332 //--------------------------------------------------------------------------
104333
104334
104335 return {
104336 // var {x} = y;
104337 ObjectPattern: checkForObject,
104338 // var y = {x: 'y'}
104339 ObjectExpression: checkForObject,
104340 // import {y} from 'x';
104341 ImportDeclaration: checkForImport,
104342 // export {name} from 'yo';
104343 ExportNamedDeclaration: checkForExport
104344 };
104345 }
104346
104347 };
104348
104349 /***/ }),
104350 /* 793 */
104351 /***/ ((module) => {
104352
104353 "use strict";
104354 /**
104355 * @fileoverview Rule to enforce placing object properties on separate lines.
104356 * @author Vitor Balocco
104357 */
104358 //------------------------------------------------------------------------------
104359 // Rule Definition
104360 //------------------------------------------------------------------------------
104361
104362 module.exports = {
104363 meta: {
104364 type: "layout",
104365 docs: {
104366 description: "enforce placing object properties on separate lines",
104367 recommended: false,
104368 url: "https://eslint.org/docs/rules/object-property-newline"
104369 },
104370 schema: [{
104371 type: "object",
104372 properties: {
104373 allowAllPropertiesOnSameLine: {
104374 type: "boolean",
104375 default: false
104376 },
104377 allowMultiplePropertiesPerLine: {
104378 // Deprecated
104379 type: "boolean",
104380 default: false
104381 }
104382 },
104383 additionalProperties: false
104384 }],
104385 fixable: "whitespace",
104386 messages: {
104387 propertiesOnNewlineAll: "Object properties must go on a new line if they aren't all on the same line.",
104388 propertiesOnNewline: "Object properties must go on a new line."
104389 }
104390 },
104391
104392 create(context) {
104393 const allowSameLine = context.options[0] && (context.options[0].allowAllPropertiesOnSameLine || context.options[0].allowMultiplePropertiesPerLine
104394 /* Deprecated */
104395 );
104396 const messageId = allowSameLine ? "propertiesOnNewlineAll" : "propertiesOnNewline";
104397 const sourceCode = context.getSourceCode();
104398 return {
104399 ObjectExpression(node) {
104400 if (allowSameLine) {
104401 if (node.properties.length > 1) {
104402 const firstTokenOfFirstProperty = sourceCode.getFirstToken(node.properties[0]);
104403 const lastTokenOfLastProperty = sourceCode.getLastToken(node.properties[node.properties.length - 1]);
104404
104405 if (firstTokenOfFirstProperty.loc.end.line === lastTokenOfLastProperty.loc.start.line) {
104406 // All keys and values are on the same line
104407 return;
104408 }
104409 }
104410 }
104411
104412 for (let i = 1; i < node.properties.length; i++) {
104413 const lastTokenOfPreviousProperty = sourceCode.getLastToken(node.properties[i - 1]);
104414 const firstTokenOfCurrentProperty = sourceCode.getFirstToken(node.properties[i]);
104415
104416 if (lastTokenOfPreviousProperty.loc.end.line === firstTokenOfCurrentProperty.loc.start.line) {
104417 context.report({
104418 node,
104419 loc: firstTokenOfCurrentProperty.loc,
104420 messageId,
104421
104422 fix(fixer) {
104423 const comma = sourceCode.getTokenBefore(firstTokenOfCurrentProperty);
104424 const rangeAfterComma = [comma.range[1], firstTokenOfCurrentProperty.range[0]]; // Don't perform a fix if there are any comments between the comma and the next property.
104425
104426 if (sourceCode.text.slice(rangeAfterComma[0], rangeAfterComma[1]).trim()) {
104427 return null;
104428 }
104429
104430 return fixer.replaceTextRange(rangeAfterComma, "\n");
104431 }
104432
104433 });
104434 }
104435 }
104436 }
104437
104438 };
104439 }
104440
104441 };
104442
104443 /***/ }),
104444 /* 794 */
104445 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
104446
104447 "use strict";
104448 /**
104449 * @fileoverview Rule to enforce concise object methods and properties.
104450 * @author Jamund Ferguson
104451 */
104452
104453
104454 const OPTIONS = {
104455 always: "always",
104456 never: "never",
104457 methods: "methods",
104458 properties: "properties",
104459 consistent: "consistent",
104460 consistentAsNeeded: "consistent-as-needed"
104461 }; //------------------------------------------------------------------------------
104462 // Requirements
104463 //------------------------------------------------------------------------------
104464
104465 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
104466 // Rule Definition
104467 //------------------------------------------------------------------------------
104468
104469
104470 module.exports = {
104471 meta: {
104472 type: "suggestion",
104473 docs: {
104474 description: "require or disallow method and property shorthand syntax for object literals",
104475 recommended: false,
104476 url: "https://eslint.org/docs/rules/object-shorthand"
104477 },
104478 fixable: "code",
104479 schema: {
104480 anyOf: [{
104481 type: "array",
104482 items: [{
104483 enum: ["always", "methods", "properties", "never", "consistent", "consistent-as-needed"]
104484 }],
104485 minItems: 0,
104486 maxItems: 1
104487 }, {
104488 type: "array",
104489 items: [{
104490 enum: ["always", "methods", "properties"]
104491 }, {
104492 type: "object",
104493 properties: {
104494 avoidQuotes: {
104495 type: "boolean"
104496 }
104497 },
104498 additionalProperties: false
104499 }],
104500 minItems: 0,
104501 maxItems: 2
104502 }, {
104503 type: "array",
104504 items: [{
104505 enum: ["always", "methods"]
104506 }, {
104507 type: "object",
104508 properties: {
104509 ignoreConstructors: {
104510 type: "boolean"
104511 },
104512 avoidQuotes: {
104513 type: "boolean"
104514 },
104515 avoidExplicitReturnArrows: {
104516 type: "boolean"
104517 }
104518 },
104519 additionalProperties: false
104520 }],
104521 minItems: 0,
104522 maxItems: 2
104523 }]
104524 },
104525 messages: {
104526 expectedAllPropertiesShorthanded: "Expected shorthand for all properties.",
104527 expectedLiteralMethodLongform: "Expected longform method syntax for string literal keys.",
104528 expectedPropertyShorthand: "Expected property shorthand.",
104529 expectedPropertyLongform: "Expected longform property syntax.",
104530 expectedMethodShorthand: "Expected method shorthand.",
104531 expectedMethodLongform: "Expected longform method syntax.",
104532 unexpectedMix: "Unexpected mix of shorthand and non-shorthand properties."
104533 }
104534 },
104535
104536 create(context) {
104537 const APPLY = context.options[0] || OPTIONS.always;
104538 const APPLY_TO_METHODS = APPLY === OPTIONS.methods || APPLY === OPTIONS.always;
104539 const APPLY_TO_PROPS = APPLY === OPTIONS.properties || APPLY === OPTIONS.always;
104540 const APPLY_NEVER = APPLY === OPTIONS.never;
104541 const APPLY_CONSISTENT = APPLY === OPTIONS.consistent;
104542 const APPLY_CONSISTENT_AS_NEEDED = APPLY === OPTIONS.consistentAsNeeded;
104543 const PARAMS = context.options[1] || {};
104544 const IGNORE_CONSTRUCTORS = PARAMS.ignoreConstructors;
104545 const AVOID_QUOTES = PARAMS.avoidQuotes;
104546 const AVOID_EXPLICIT_RETURN_ARROWS = !!PARAMS.avoidExplicitReturnArrows;
104547 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
104548 // Helpers
104549 //--------------------------------------------------------------------------
104550
104551 const CTOR_PREFIX_REGEX = /[^_$0-9]/u;
104552 /**
104553 * Determines if the first character of the name is a capital letter.
104554 * @param {string} name The name of the node to evaluate.
104555 * @returns {boolean} True if the first character of the property name is a capital letter, false if not.
104556 * @private
104557 */
104558
104559 function isConstructor(name) {
104560 const match = CTOR_PREFIX_REGEX.exec(name); // Not a constructor if name has no characters apart from '_', '$' and digits e.g. '_', '$$', '_8'
104561
104562 if (!match) {
104563 return false;
104564 }
104565
104566 const firstChar = name.charAt(match.index);
104567 return firstChar === firstChar.toUpperCase();
104568 }
104569 /**
104570 * Determines if the property can have a shorthand form.
104571 * @param {ASTNode} property Property AST node
104572 * @returns {boolean} True if the property can have a shorthand form
104573 * @private
104574 */
104575
104576
104577 function canHaveShorthand(property) {
104578 return property.kind !== "set" && property.kind !== "get" && property.type !== "SpreadElement" && property.type !== "SpreadProperty" && property.type !== "ExperimentalSpreadProperty";
104579 }
104580 /**
104581 * Checks whether a node is a string literal.
104582 * @param {ASTNode} node Any AST node.
104583 * @returns {boolean} `true` if it is a string literal.
104584 */
104585
104586
104587 function isStringLiteral(node) {
104588 return node.type === "Literal" && typeof node.value === "string";
104589 }
104590 /**
104591 * Determines if the property is a shorthand or not.
104592 * @param {ASTNode} property Property AST node
104593 * @returns {boolean} True if the property is considered shorthand, false if not.
104594 * @private
104595 */
104596
104597
104598 function isShorthand(property) {
104599 // property.method is true when `{a(){}}`.
104600 return property.shorthand || property.method;
104601 }
104602 /**
104603 * Determines if the property's key and method or value are named equally.
104604 * @param {ASTNode} property Property AST node
104605 * @returns {boolean} True if the key and value are named equally, false if not.
104606 * @private
104607 */
104608
104609
104610 function isRedundant(property) {
104611 const value = property.value;
104612
104613 if (value.type === "FunctionExpression") {
104614 return !value.id; // Only anonymous should be shorthand method.
104615 }
104616
104617 if (value.type === "Identifier") {
104618 return astUtils.getStaticPropertyName(property) === value.name;
104619 }
104620
104621 return false;
104622 }
104623 /**
104624 * Ensures that an object's properties are consistently shorthand, or not shorthand at all.
104625 * @param {ASTNode} node Property AST node
104626 * @param {boolean} checkRedundancy Whether to check longform redundancy
104627 * @returns {void}
104628 */
104629
104630
104631 function checkConsistency(node, checkRedundancy) {
104632 // We are excluding getters/setters and spread properties as they are considered neither longform nor shorthand.
104633 const properties = node.properties.filter(canHaveShorthand); // Do we still have properties left after filtering the getters and setters?
104634
104635 if (properties.length > 0) {
104636 const shorthandProperties = properties.filter(isShorthand);
104637 /*
104638 * If we do not have an equal number of longform properties as
104639 * shorthand properties, we are using the annotations inconsistently
104640 */
104641
104642 if (shorthandProperties.length !== properties.length) {
104643 // We have at least 1 shorthand property
104644 if (shorthandProperties.length > 0) {
104645 context.report({
104646 node,
104647 messageId: "unexpectedMix"
104648 });
104649 } else if (checkRedundancy) {
104650 /*
104651 * If all properties of the object contain a method or value with a name matching it's key,
104652 * all the keys are redundant.
104653 */
104654 const canAlwaysUseShorthand = properties.every(isRedundant);
104655
104656 if (canAlwaysUseShorthand) {
104657 context.report({
104658 node,
104659 messageId: "expectedAllPropertiesShorthanded"
104660 });
104661 }
104662 }
104663 }
104664 }
104665 }
104666 /**
104667 * Fixes a FunctionExpression node by making it into a shorthand property.
104668 * @param {SourceCodeFixer} fixer The fixer object
104669 * @param {ASTNode} node A `Property` node that has a `FunctionExpression` or `ArrowFunctionExpression` as its value
104670 * @returns {Object} A fix for this node
104671 */
104672
104673
104674 function makeFunctionShorthand(fixer, node) {
104675 const firstKeyToken = node.computed ? sourceCode.getFirstToken(node, astUtils.isOpeningBracketToken) : sourceCode.getFirstToken(node.key);
104676 const lastKeyToken = node.computed ? sourceCode.getFirstTokenBetween(node.key, node.value, astUtils.isClosingBracketToken) : sourceCode.getLastToken(node.key);
104677 const keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]);
104678 let keyPrefix = ""; // key: /* */ () => {}
104679
104680 if (sourceCode.commentsExistBetween(lastKeyToken, node.value)) {
104681 return null;
104682 }
104683
104684 if (node.value.async) {
104685 keyPrefix += "async ";
104686 }
104687
104688 if (node.value.generator) {
104689 keyPrefix += "*";
104690 }
104691
104692 const fixRange = [firstKeyToken.range[0], node.range[1]];
104693 const methodPrefix = keyPrefix + keyText;
104694
104695 if (node.value.type === "FunctionExpression") {
104696 const functionToken = sourceCode.getTokens(node.value).find(token => token.type === "Keyword" && token.value === "function");
104697 const tokenBeforeParams = node.value.generator ? sourceCode.getTokenAfter(functionToken) : functionToken;
104698 return fixer.replaceTextRange(fixRange, methodPrefix + sourceCode.text.slice(tokenBeforeParams.range[1], node.value.range[1]));
104699 }
104700
104701 const arrowToken = sourceCode.getTokenBefore(node.value.body, astUtils.isArrowToken);
104702 const fnBody = sourceCode.text.slice(arrowToken.range[1], node.value.range[1]);
104703 let shouldAddParensAroundParameters = false;
104704 let tokenBeforeParams;
104705
104706 if (node.value.params.length === 0) {
104707 tokenBeforeParams = sourceCode.getFirstToken(node.value, astUtils.isOpeningParenToken);
104708 } else {
104709 tokenBeforeParams = sourceCode.getTokenBefore(node.value.params[0]);
104710 }
104711
104712 if (node.value.params.length === 1) {
104713 const hasParen = astUtils.isOpeningParenToken(tokenBeforeParams);
104714 const isTokenOutsideNode = tokenBeforeParams.range[0] < node.range[0];
104715 shouldAddParensAroundParameters = !hasParen || isTokenOutsideNode;
104716 }
104717
104718 const sliceStart = shouldAddParensAroundParameters ? node.value.params[0].range[0] : tokenBeforeParams.range[0];
104719 const sliceEnd = sourceCode.getTokenBefore(arrowToken).range[1];
104720 const oldParamText = sourceCode.text.slice(sliceStart, sliceEnd);
104721 const newParamText = shouldAddParensAroundParameters ? "(".concat(oldParamText, ")") : oldParamText;
104722 return fixer.replaceTextRange(fixRange, methodPrefix + newParamText + fnBody);
104723 }
104724 /**
104725 * Fixes a FunctionExpression node by making it into a longform property.
104726 * @param {SourceCodeFixer} fixer The fixer object
104727 * @param {ASTNode} node A `Property` node that has a `FunctionExpression` as its value
104728 * @returns {Object} A fix for this node
104729 */
104730
104731
104732 function makeFunctionLongform(fixer, node) {
104733 const firstKeyToken = node.computed ? sourceCode.getTokens(node).find(token => token.value === "[") : sourceCode.getFirstToken(node.key);
104734 const lastKeyToken = node.computed ? sourceCode.getTokensBetween(node.key, node.value).find(token => token.value === "]") : sourceCode.getLastToken(node.key);
104735 const keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]);
104736 let functionHeader = "function";
104737
104738 if (node.value.async) {
104739 functionHeader = "async ".concat(functionHeader);
104740 }
104741
104742 if (node.value.generator) {
104743 functionHeader = "".concat(functionHeader, "*");
104744 }
104745
104746 return fixer.replaceTextRange([node.range[0], lastKeyToken.range[1]], "".concat(keyText, ": ").concat(functionHeader));
104747 }
104748 /*
104749 * To determine whether a given arrow function has a lexical identifier (`this`, `arguments`, `super`, or `new.target`),
104750 * create a stack of functions that define these identifiers (i.e. all functions except arrow functions) as the AST is
104751 * traversed. Whenever a new function is encountered, create a new entry on the stack (corresponding to a different lexical
104752 * scope of `this`), and whenever a function is exited, pop that entry off the stack. When an arrow function is entered,
104753 * keep a reference to it on the current stack entry, and remove that reference when the arrow function is exited.
104754 * When a lexical identifier is encountered, mark all the arrow functions on the current stack entry by adding them
104755 * to an `arrowsWithLexicalIdentifiers` set. Any arrow function in that set will not be reported by this rule,
104756 * because converting it into a method would change the value of one of the lexical identifiers.
104757 */
104758
104759
104760 const lexicalScopeStack = [];
104761 const arrowsWithLexicalIdentifiers = new WeakSet();
104762 const argumentsIdentifiers = new WeakSet();
104763 /**
104764 * Enters a function. This creates a new lexical identifier scope, so a new Set of arrow functions is pushed onto the stack.
104765 * Also, this marks all `arguments` identifiers so that they can be detected later.
104766 * @returns {void}
104767 */
104768
104769 function enterFunction() {
104770 lexicalScopeStack.unshift(new Set());
104771 context.getScope().variables.filter(variable => variable.name === "arguments").forEach(variable => {
104772 variable.references.map(ref => ref.identifier).forEach(identifier => argumentsIdentifiers.add(identifier));
104773 });
104774 }
104775 /**
104776 * Exits a function. This pops the current set of arrow functions off the lexical scope stack.
104777 * @returns {void}
104778 */
104779
104780
104781 function exitFunction() {
104782 lexicalScopeStack.shift();
104783 }
104784 /**
104785 * Marks the current function as having a lexical keyword. This implies that all arrow functions
104786 * in the current lexical scope contain a reference to this lexical keyword.
104787 * @returns {void}
104788 */
104789
104790
104791 function reportLexicalIdentifier() {
104792 lexicalScopeStack[0].forEach(arrowFunction => arrowsWithLexicalIdentifiers.add(arrowFunction));
104793 } //--------------------------------------------------------------------------
104794 // Public
104795 //--------------------------------------------------------------------------
104796
104797
104798 return {
104799 Program: enterFunction,
104800 FunctionDeclaration: enterFunction,
104801 FunctionExpression: enterFunction,
104802 "Program:exit": exitFunction,
104803 "FunctionDeclaration:exit": exitFunction,
104804 "FunctionExpression:exit": exitFunction,
104805
104806 ArrowFunctionExpression(node) {
104807 lexicalScopeStack[0].add(node);
104808 },
104809
104810 "ArrowFunctionExpression:exit"(node) {
104811 lexicalScopeStack[0].delete(node);
104812 },
104813
104814 ThisExpression: reportLexicalIdentifier,
104815 Super: reportLexicalIdentifier,
104816
104817 MetaProperty(node) {
104818 if (node.meta.name === "new" && node.property.name === "target") {
104819 reportLexicalIdentifier();
104820 }
104821 },
104822
104823 Identifier(node) {
104824 if (argumentsIdentifiers.has(node)) {
104825 reportLexicalIdentifier();
104826 }
104827 },
104828
104829 ObjectExpression(node) {
104830 if (APPLY_CONSISTENT) {
104831 checkConsistency(node, false);
104832 } else if (APPLY_CONSISTENT_AS_NEEDED) {
104833 checkConsistency(node, true);
104834 }
104835 },
104836
104837 "Property:exit"(node) {
104838 const isConciseProperty = node.method || node.shorthand; // Ignore destructuring assignment
104839
104840 if (node.parent.type === "ObjectPattern") {
104841 return;
104842 } // getters and setters are ignored
104843
104844
104845 if (node.kind === "get" || node.kind === "set") {
104846 return;
104847 } // only computed methods can fail the following checks
104848
104849
104850 if (node.computed && node.value.type !== "FunctionExpression" && node.value.type !== "ArrowFunctionExpression") {
104851 return;
104852 } //--------------------------------------------------------------
104853 // Checks for property/method shorthand.
104854
104855
104856 if (isConciseProperty) {
104857 if (node.method && (APPLY_NEVER || AVOID_QUOTES && isStringLiteral(node.key))) {
104858 const messageId = APPLY_NEVER ? "expectedMethodLongform" : "expectedLiteralMethodLongform"; // { x() {} } should be written as { x: function() {} }
104859
104860 context.report({
104861 node,
104862 messageId,
104863 fix: fixer => makeFunctionLongform(fixer, node)
104864 });
104865 } else if (APPLY_NEVER) {
104866 // { x } should be written as { x: x }
104867 context.report({
104868 node,
104869 messageId: "expectedPropertyLongform",
104870 fix: fixer => fixer.insertTextAfter(node.key, ": ".concat(node.key.name))
104871 });
104872 }
104873 } else if (APPLY_TO_METHODS && !node.value.id && (node.value.type === "FunctionExpression" || node.value.type === "ArrowFunctionExpression")) {
104874 if (IGNORE_CONSTRUCTORS && node.key.type === "Identifier" && isConstructor(node.key.name)) {
104875 return;
104876 }
104877
104878 if (AVOID_QUOTES && isStringLiteral(node.key)) {
104879 return;
104880 } // {[x]: function(){}} should be written as {[x]() {}}
104881
104882
104883 if (node.value.type === "FunctionExpression" || node.value.type === "ArrowFunctionExpression" && node.value.body.type === "BlockStatement" && AVOID_EXPLICIT_RETURN_ARROWS && !arrowsWithLexicalIdentifiers.has(node.value)) {
104884 context.report({
104885 node,
104886 messageId: "expectedMethodShorthand",
104887 fix: fixer => makeFunctionShorthand(fixer, node)
104888 });
104889 }
104890 } else if (node.value.type === "Identifier" && node.key.name === node.value.name && APPLY_TO_PROPS) {
104891 // {x: x} should be written as {x}
104892 context.report({
104893 node,
104894 messageId: "expectedPropertyShorthand",
104895
104896 fix(fixer) {
104897 return fixer.replaceText(node, node.value.name);
104898 }
104899
104900 });
104901 } else if (node.value.type === "Identifier" && node.key.type === "Literal" && node.key.value === node.value.name && APPLY_TO_PROPS) {
104902 if (AVOID_QUOTES) {
104903 return;
104904 } // {"x": x} should be written as {x}
104905
104906
104907 context.report({
104908 node,
104909 messageId: "expectedPropertyShorthand",
104910
104911 fix(fixer) {
104912 return fixer.replaceText(node, node.value.name);
104913 }
104914
104915 });
104916 }
104917 }
104918
104919 };
104920 }
104921
104922 };
104923
104924 /***/ }),
104925 /* 795 */
104926 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
104927
104928 "use strict";
104929 /**
104930 * @fileoverview A rule to control the use of single variable declarations.
104931 * @author Ian Christian Myers
104932 */
104933 //------------------------------------------------------------------------------
104934 // Requirements
104935 //------------------------------------------------------------------------------
104936
104937 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
104938 // Helpers
104939 //------------------------------------------------------------------------------
104940
104941 /**
104942 * Determines whether the given node is in a statement list.
104943 * @param {ASTNode} node node to check
104944 * @returns {boolean} `true` if the given node is in a statement list
104945 */
104946
104947
104948 function isInStatementList(node) {
104949 return astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type);
104950 } //------------------------------------------------------------------------------
104951 // Rule Definition
104952 //------------------------------------------------------------------------------
104953
104954
104955 module.exports = {
104956 meta: {
104957 type: "suggestion",
104958 docs: {
104959 description: "enforce variables to be declared either together or separately in functions",
104960 recommended: false,
104961 url: "https://eslint.org/docs/rules/one-var"
104962 },
104963 fixable: "code",
104964 schema: [{
104965 oneOf: [{
104966 enum: ["always", "never", "consecutive"]
104967 }, {
104968 type: "object",
104969 properties: {
104970 separateRequires: {
104971 type: "boolean"
104972 },
104973 var: {
104974 enum: ["always", "never", "consecutive"]
104975 },
104976 let: {
104977 enum: ["always", "never", "consecutive"]
104978 },
104979 const: {
104980 enum: ["always", "never", "consecutive"]
104981 }
104982 },
104983 additionalProperties: false
104984 }, {
104985 type: "object",
104986 properties: {
104987 initialized: {
104988 enum: ["always", "never", "consecutive"]
104989 },
104990 uninitialized: {
104991 enum: ["always", "never", "consecutive"]
104992 }
104993 },
104994 additionalProperties: false
104995 }]
104996 }],
104997 messages: {
104998 combineUninitialized: "Combine this with the previous '{{type}}' statement with uninitialized variables.",
104999 combineInitialized: "Combine this with the previous '{{type}}' statement with initialized variables.",
105000 splitUninitialized: "Split uninitialized '{{type}}' declarations into multiple statements.",
105001 splitInitialized: "Split initialized '{{type}}' declarations into multiple statements.",
105002 splitRequires: "Split requires to be separated into a single block.",
105003 combine: "Combine this with the previous '{{type}}' statement.",
105004 split: "Split '{{type}}' declarations into multiple statements."
105005 }
105006 },
105007
105008 create(context) {
105009 const MODE_ALWAYS = "always";
105010 const MODE_NEVER = "never";
105011 const MODE_CONSECUTIVE = "consecutive";
105012 const mode = context.options[0] || MODE_ALWAYS;
105013 const options = {};
105014
105015 if (typeof mode === "string") {
105016 // simple options configuration with just a string
105017 options.var = {
105018 uninitialized: mode,
105019 initialized: mode
105020 };
105021 options.let = {
105022 uninitialized: mode,
105023 initialized: mode
105024 };
105025 options.const = {
105026 uninitialized: mode,
105027 initialized: mode
105028 };
105029 } else if (typeof mode === "object") {
105030 // options configuration is an object
105031 options.separateRequires = !!mode.separateRequires;
105032 options.var = {
105033 uninitialized: mode.var,
105034 initialized: mode.var
105035 };
105036 options.let = {
105037 uninitialized: mode.let,
105038 initialized: mode.let
105039 };
105040 options.const = {
105041 uninitialized: mode.const,
105042 initialized: mode.const
105043 };
105044
105045 if (Object.prototype.hasOwnProperty.call(mode, "uninitialized")) {
105046 options.var.uninitialized = mode.uninitialized;
105047 options.let.uninitialized = mode.uninitialized;
105048 options.const.uninitialized = mode.uninitialized;
105049 }
105050
105051 if (Object.prototype.hasOwnProperty.call(mode, "initialized")) {
105052 options.var.initialized = mode.initialized;
105053 options.let.initialized = mode.initialized;
105054 options.const.initialized = mode.initialized;
105055 }
105056 }
105057
105058 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
105059 // Helpers
105060 //--------------------------------------------------------------------------
105061
105062 const functionStack = [];
105063 const blockStack = [];
105064 /**
105065 * Increments the blockStack counter.
105066 * @returns {void}
105067 * @private
105068 */
105069
105070 function startBlock() {
105071 blockStack.push({
105072 let: {
105073 initialized: false,
105074 uninitialized: false
105075 },
105076 const: {
105077 initialized: false,
105078 uninitialized: false
105079 }
105080 });
105081 }
105082 /**
105083 * Increments the functionStack counter.
105084 * @returns {void}
105085 * @private
105086 */
105087
105088
105089 function startFunction() {
105090 functionStack.push({
105091 initialized: false,
105092 uninitialized: false
105093 });
105094 startBlock();
105095 }
105096 /**
105097 * Decrements the blockStack counter.
105098 * @returns {void}
105099 * @private
105100 */
105101
105102
105103 function endBlock() {
105104 blockStack.pop();
105105 }
105106 /**
105107 * Decrements the functionStack counter.
105108 * @returns {void}
105109 * @private
105110 */
105111
105112
105113 function endFunction() {
105114 functionStack.pop();
105115 endBlock();
105116 }
105117 /**
105118 * Check if a variable declaration is a require.
105119 * @param {ASTNode} decl variable declaration Node
105120 * @returns {bool} if decl is a require, return true; else return false.
105121 * @private
105122 */
105123
105124
105125 function isRequire(decl) {
105126 return decl.init && decl.init.type === "CallExpression" && decl.init.callee.name === "require";
105127 }
105128 /**
105129 * Records whether initialized/uninitialized/required variables are defined in current scope.
105130 * @param {string} statementType node.kind, one of: "var", "let", or "const"
105131 * @param {ASTNode[]} declarations List of declarations
105132 * @param {Object} currentScope The scope being investigated
105133 * @returns {void}
105134 * @private
105135 */
105136
105137
105138 function recordTypes(statementType, declarations, currentScope) {
105139 for (let i = 0; i < declarations.length; i++) {
105140 if (declarations[i].init === null) {
105141 if (options[statementType] && options[statementType].uninitialized === MODE_ALWAYS) {
105142 currentScope.uninitialized = true;
105143 }
105144 } else {
105145 if (options[statementType] && options[statementType].initialized === MODE_ALWAYS) {
105146 if (options.separateRequires && isRequire(declarations[i])) {
105147 currentScope.required = true;
105148 } else {
105149 currentScope.initialized = true;
105150 }
105151 }
105152 }
105153 }
105154 }
105155 /**
105156 * Determines the current scope (function or block)
105157 * @param {string} statementType node.kind, one of: "var", "let", or "const"
105158 * @returns {Object} The scope associated with statementType
105159 */
105160
105161
105162 function getCurrentScope(statementType) {
105163 let currentScope;
105164
105165 if (statementType === "var") {
105166 currentScope = functionStack[functionStack.length - 1];
105167 } else if (statementType === "let") {
105168 currentScope = blockStack[blockStack.length - 1].let;
105169 } else if (statementType === "const") {
105170 currentScope = blockStack[blockStack.length - 1].const;
105171 }
105172
105173 return currentScope;
105174 }
105175 /**
105176 * Counts the number of initialized and uninitialized declarations in a list of declarations
105177 * @param {ASTNode[]} declarations List of declarations
105178 * @returns {Object} Counts of 'uninitialized' and 'initialized' declarations
105179 * @private
105180 */
105181
105182
105183 function countDeclarations(declarations) {
105184 const counts = {
105185 uninitialized: 0,
105186 initialized: 0
105187 };
105188
105189 for (let i = 0; i < declarations.length; i++) {
105190 if (declarations[i].init === null) {
105191 counts.uninitialized++;
105192 } else {
105193 counts.initialized++;
105194 }
105195 }
105196
105197 return counts;
105198 }
105199 /**
105200 * Determines if there is more than one var statement in the current scope.
105201 * @param {string} statementType node.kind, one of: "var", "let", or "const"
105202 * @param {ASTNode[]} declarations List of declarations
105203 * @returns {boolean} Returns true if it is the first var declaration, false if not.
105204 * @private
105205 */
105206
105207
105208 function hasOnlyOneStatement(statementType, declarations) {
105209 const declarationCounts = countDeclarations(declarations);
105210 const currentOptions = options[statementType] || {};
105211 const currentScope = getCurrentScope(statementType);
105212 const hasRequires = declarations.some(isRequire);
105213
105214 if (currentOptions.uninitialized === MODE_ALWAYS && currentOptions.initialized === MODE_ALWAYS) {
105215 if (currentScope.uninitialized || currentScope.initialized) {
105216 if (!hasRequires) {
105217 return false;
105218 }
105219 }
105220 }
105221
105222 if (declarationCounts.uninitialized > 0) {
105223 if (currentOptions.uninitialized === MODE_ALWAYS && currentScope.uninitialized) {
105224 return false;
105225 }
105226 }
105227
105228 if (declarationCounts.initialized > 0) {
105229 if (currentOptions.initialized === MODE_ALWAYS && currentScope.initialized) {
105230 if (!hasRequires) {
105231 return false;
105232 }
105233 }
105234 }
105235
105236 if (currentScope.required && hasRequires) {
105237 return false;
105238 }
105239
105240 recordTypes(statementType, declarations, currentScope);
105241 return true;
105242 }
105243 /**
105244 * Fixer to join VariableDeclaration's into a single declaration
105245 * @param {VariableDeclarator[]} declarations The `VariableDeclaration` to join
105246 * @returns {Function} The fixer function
105247 */
105248
105249
105250 function joinDeclarations(declarations) {
105251 const declaration = declarations[0];
105252 const body = Array.isArray(declaration.parent.parent.body) ? declaration.parent.parent.body : [];
105253 const currentIndex = body.findIndex(node => node.range[0] === declaration.parent.range[0]);
105254 const previousNode = body[currentIndex - 1];
105255 return fixer => {
105256 const type = sourceCode.getTokenBefore(declaration);
105257 const prevSemi = sourceCode.getTokenBefore(type);
105258 const res = [];
105259
105260 if (previousNode && previousNode.kind === sourceCode.getText(type)) {
105261 if (prevSemi.value === ";") {
105262 res.push(fixer.replaceText(prevSemi, ","));
105263 } else {
105264 res.push(fixer.insertTextAfter(prevSemi, ","));
105265 }
105266
105267 res.push(fixer.replaceText(type, ""));
105268 }
105269
105270 return res;
105271 };
105272 }
105273 /**
105274 * Fixer to split a VariableDeclaration into individual declarations
105275 * @param {VariableDeclaration} declaration The `VariableDeclaration` to split
105276 * @returns {Function|null} The fixer function
105277 */
105278
105279
105280 function splitDeclarations(declaration) {
105281 const {
105282 parent
105283 } = declaration; // don't autofix code such as: if (foo) var x, y;
105284
105285 if (!isInStatementList(parent.type === "ExportNamedDeclaration" ? parent : declaration)) {
105286 return null;
105287 }
105288
105289 return fixer => declaration.declarations.map(declarator => {
105290 const tokenAfterDeclarator = sourceCode.getTokenAfter(declarator);
105291
105292 if (tokenAfterDeclarator === null) {
105293 return null;
105294 }
105295
105296 const afterComma = sourceCode.getTokenAfter(tokenAfterDeclarator, {
105297 includeComments: true
105298 });
105299
105300 if (tokenAfterDeclarator.value !== ",") {
105301 return null;
105302 }
105303
105304 const exportPlacement = declaration.parent.type === "ExportNamedDeclaration" ? "export " : "";
105305 /*
105306 * `var x,y`
105307 * tokenAfterDeclarator ^^ afterComma
105308 */
105309
105310 if (afterComma.range[0] === tokenAfterDeclarator.range[1]) {
105311 return fixer.replaceText(tokenAfterDeclarator, "; ".concat(exportPlacement).concat(declaration.kind, " "));
105312 }
105313 /*
105314 * `var x,
105315 * tokenAfterDeclarator ^
105316 * y`
105317 * ^ afterComma
105318 */
105319
105320
105321 if (afterComma.loc.start.line > tokenAfterDeclarator.loc.end.line || afterComma.type === "Line" || afterComma.type === "Block") {
105322 let lastComment = afterComma;
105323
105324 while (lastComment.type === "Line" || lastComment.type === "Block") {
105325 lastComment = sourceCode.getTokenAfter(lastComment, {
105326 includeComments: true
105327 });
105328 }
105329
105330 return fixer.replaceTextRange([tokenAfterDeclarator.range[0], lastComment.range[0]], ";".concat(sourceCode.text.slice(tokenAfterDeclarator.range[1], lastComment.range[0])).concat(exportPlacement).concat(declaration.kind, " "));
105331 }
105332
105333 return fixer.replaceText(tokenAfterDeclarator, "; ".concat(exportPlacement).concat(declaration.kind));
105334 }).filter(x => x);
105335 }
105336 /**
105337 * Checks a given VariableDeclaration node for errors.
105338 * @param {ASTNode} node The VariableDeclaration node to check
105339 * @returns {void}
105340 * @private
105341 */
105342
105343
105344 function checkVariableDeclaration(node) {
105345 const parent = node.parent;
105346 const type = node.kind;
105347
105348 if (!options[type]) {
105349 return;
105350 }
105351
105352 const declarations = node.declarations;
105353 const declarationCounts = countDeclarations(declarations);
105354 const mixedRequires = declarations.some(isRequire) && !declarations.every(isRequire);
105355
105356 if (options[type].initialized === MODE_ALWAYS) {
105357 if (options.separateRequires && mixedRequires) {
105358 context.report({
105359 node,
105360 messageId: "splitRequires"
105361 });
105362 }
105363 } // consecutive
105364
105365
105366 const nodeIndex = parent.body && parent.body.length > 0 && parent.body.indexOf(node) || 0;
105367
105368 if (nodeIndex > 0) {
105369 const previousNode = parent.body[nodeIndex - 1];
105370 const isPreviousNodeDeclaration = previousNode.type === "VariableDeclaration";
105371 const declarationsWithPrevious = declarations.concat(previousNode.declarations || []);
105372
105373 if (isPreviousNodeDeclaration && previousNode.kind === type && !(declarationsWithPrevious.some(isRequire) && !declarationsWithPrevious.every(isRequire))) {
105374 const previousDeclCounts = countDeclarations(previousNode.declarations);
105375
105376 if (options[type].initialized === MODE_CONSECUTIVE && options[type].uninitialized === MODE_CONSECUTIVE) {
105377 context.report({
105378 node,
105379 messageId: "combine",
105380 data: {
105381 type
105382 },
105383 fix: joinDeclarations(declarations)
105384 });
105385 } else if (options[type].initialized === MODE_CONSECUTIVE && declarationCounts.initialized > 0 && previousDeclCounts.initialized > 0) {
105386 context.report({
105387 node,
105388 messageId: "combineInitialized",
105389 data: {
105390 type
105391 },
105392 fix: joinDeclarations(declarations)
105393 });
105394 } else if (options[type].uninitialized === MODE_CONSECUTIVE && declarationCounts.uninitialized > 0 && previousDeclCounts.uninitialized > 0) {
105395 context.report({
105396 node,
105397 messageId: "combineUninitialized",
105398 data: {
105399 type
105400 },
105401 fix: joinDeclarations(declarations)
105402 });
105403 }
105404 }
105405 } // always
105406
105407
105408 if (!hasOnlyOneStatement(type, declarations)) {
105409 if (options[type].initialized === MODE_ALWAYS && options[type].uninitialized === MODE_ALWAYS) {
105410 context.report({
105411 node,
105412 messageId: "combine",
105413 data: {
105414 type
105415 },
105416 fix: joinDeclarations(declarations)
105417 });
105418 } else {
105419 if (options[type].initialized === MODE_ALWAYS && declarationCounts.initialized > 0) {
105420 context.report({
105421 node,
105422 messageId: "combineInitialized",
105423 data: {
105424 type
105425 },
105426 fix: joinDeclarations(declarations)
105427 });
105428 }
105429
105430 if (options[type].uninitialized === MODE_ALWAYS && declarationCounts.uninitialized > 0) {
105431 if (node.parent.left === node && (node.parent.type === "ForInStatement" || node.parent.type === "ForOfStatement")) {
105432 return;
105433 }
105434
105435 context.report({
105436 node,
105437 messageId: "combineUninitialized",
105438 data: {
105439 type
105440 },
105441 fix: joinDeclarations(declarations)
105442 });
105443 }
105444 }
105445 } // never
105446
105447
105448 if (parent.type !== "ForStatement" || parent.init !== node) {
105449 const totalDeclarations = declarationCounts.uninitialized + declarationCounts.initialized;
105450
105451 if (totalDeclarations > 1) {
105452 if (options[type].initialized === MODE_NEVER && options[type].uninitialized === MODE_NEVER) {
105453 // both initialized and uninitialized
105454 context.report({
105455 node,
105456 messageId: "split",
105457 data: {
105458 type
105459 },
105460 fix: splitDeclarations(node)
105461 });
105462 } else if (options[type].initialized === MODE_NEVER && declarationCounts.initialized > 0) {
105463 // initialized
105464 context.report({
105465 node,
105466 messageId: "splitInitialized",
105467 data: {
105468 type
105469 },
105470 fix: splitDeclarations(node)
105471 });
105472 } else if (options[type].uninitialized === MODE_NEVER && declarationCounts.uninitialized > 0) {
105473 // uninitialized
105474 context.report({
105475 node,
105476 messageId: "splitUninitialized",
105477 data: {
105478 type
105479 },
105480 fix: splitDeclarations(node)
105481 });
105482 }
105483 }
105484 }
105485 } //--------------------------------------------------------------------------
105486 // Public API
105487 //--------------------------------------------------------------------------
105488
105489
105490 return {
105491 Program: startFunction,
105492 FunctionDeclaration: startFunction,
105493 FunctionExpression: startFunction,
105494 ArrowFunctionExpression: startFunction,
105495 StaticBlock: startFunction,
105496 // StaticBlock creates a new scope for `var` variables
105497 BlockStatement: startBlock,
105498 ForStatement: startBlock,
105499 ForInStatement: startBlock,
105500 ForOfStatement: startBlock,
105501 SwitchStatement: startBlock,
105502 VariableDeclaration: checkVariableDeclaration,
105503 "ForStatement:exit": endBlock,
105504 "ForOfStatement:exit": endBlock,
105505 "ForInStatement:exit": endBlock,
105506 "SwitchStatement:exit": endBlock,
105507 "BlockStatement:exit": endBlock,
105508 "Program:exit": endFunction,
105509 "FunctionDeclaration:exit": endFunction,
105510 "FunctionExpression:exit": endFunction,
105511 "ArrowFunctionExpression:exit": endFunction,
105512 "StaticBlock:exit": endFunction
105513 };
105514 }
105515
105516 };
105517
105518 /***/ }),
105519 /* 796 */
105520 /***/ ((module) => {
105521
105522 "use strict";
105523 /**
105524 * @fileoverview Rule to check multiple var declarations per line
105525 * @author Alberto Rodríguez
105526 */
105527 //------------------------------------------------------------------------------
105528 // Rule Definition
105529 //------------------------------------------------------------------------------
105530
105531 module.exports = {
105532 meta: {
105533 type: "suggestion",
105534 docs: {
105535 description: "require or disallow newlines around variable declarations",
105536 recommended: false,
105537 url: "https://eslint.org/docs/rules/one-var-declaration-per-line"
105538 },
105539 schema: [{
105540 enum: ["always", "initializations"]
105541 }],
105542 fixable: "whitespace",
105543 messages: {
105544 expectVarOnNewline: "Expected variable declaration to be on a new line."
105545 }
105546 },
105547
105548 create(context) {
105549 const always = context.options[0] === "always"; //--------------------------------------------------------------------------
105550 // Helpers
105551 //--------------------------------------------------------------------------
105552
105553 /**
105554 * Determine if provided keyword is a variant of for specifiers
105555 * @private
105556 * @param {string} keyword keyword to test
105557 * @returns {boolean} True if `keyword` is a variant of for specifier
105558 */
105559
105560 function isForTypeSpecifier(keyword) {
105561 return keyword === "ForStatement" || keyword === "ForInStatement" || keyword === "ForOfStatement";
105562 }
105563 /**
105564 * Checks newlines around variable declarations.
105565 * @private
105566 * @param {ASTNode} node `VariableDeclaration` node to test
105567 * @returns {void}
105568 */
105569
105570
105571 function checkForNewLine(node) {
105572 if (isForTypeSpecifier(node.parent.type)) {
105573 return;
105574 }
105575
105576 const declarations = node.declarations;
105577 let prev;
105578 declarations.forEach(current => {
105579 if (prev && prev.loc.end.line === current.loc.start.line) {
105580 if (always || prev.init || current.init) {
105581 context.report({
105582 node,
105583 messageId: "expectVarOnNewline",
105584 loc: current.loc,
105585 fix: fixer => fixer.insertTextBefore(current, "\n")
105586 });
105587 }
105588 }
105589
105590 prev = current;
105591 });
105592 } //--------------------------------------------------------------------------
105593 // Public
105594 //--------------------------------------------------------------------------
105595
105596
105597 return {
105598 VariableDeclaration: checkForNewLine
105599 };
105600 }
105601
105602 };
105603
105604 /***/ }),
105605 /* 797 */
105606 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
105607
105608 "use strict";
105609 /**
105610 * @fileoverview Rule to replace assignment expressions with operator assignment
105611 * @author Brandon Mills
105612 */
105613 //------------------------------------------------------------------------------
105614 // Requirements
105615 //------------------------------------------------------------------------------
105616
105617 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
105618 // Helpers
105619 //------------------------------------------------------------------------------
105620
105621 /**
105622 * Checks whether an operator is commutative and has an operator assignment
105623 * shorthand form.
105624 * @param {string} operator Operator to check.
105625 * @returns {boolean} True if the operator is commutative and has a
105626 * shorthand form.
105627 */
105628
105629
105630 function isCommutativeOperatorWithShorthand(operator) {
105631 return ["*", "&", "^", "|"].indexOf(operator) >= 0;
105632 }
105633 /**
105634 * Checks whether an operator is not commutative and has an operator assignment
105635 * shorthand form.
105636 * @param {string} operator Operator to check.
105637 * @returns {boolean} True if the operator is not commutative and has
105638 * a shorthand form.
105639 */
105640
105641
105642 function isNonCommutativeOperatorWithShorthand(operator) {
105643 return ["+", "-", "/", "%", "<<", ">>", ">>>", "**"].indexOf(operator) >= 0;
105644 } //------------------------------------------------------------------------------
105645 // Rule Definition
105646 //------------------------------------------------------------------------------
105647
105648 /**
105649 * Determines if the left side of a node can be safely fixed (i.e. if it activates the same getters/setters and)
105650 * toString calls regardless of whether assignment shorthand is used)
105651 * @param {ASTNode} node The node on the left side of the expression
105652 * @returns {boolean} `true` if the node can be fixed
105653 */
105654
105655
105656 function canBeFixed(node) {
105657 return node.type === "Identifier" || node.type === "MemberExpression" && (node.object.type === "Identifier" || node.object.type === "ThisExpression") && (!node.computed || node.property.type === "Literal");
105658 }
105659
105660 module.exports = {
105661 meta: {
105662 type: "suggestion",
105663 docs: {
105664 description: "require or disallow assignment operator shorthand where possible",
105665 recommended: false,
105666 url: "https://eslint.org/docs/rules/operator-assignment"
105667 },
105668 schema: [{
105669 enum: ["always", "never"]
105670 }],
105671 fixable: "code",
105672 messages: {
105673 replaced: "Assignment (=) can be replaced with operator assignment ({{operator}}=).",
105674 unexpected: "Unexpected operator assignment ({{operator}}=) shorthand."
105675 }
105676 },
105677
105678 create(context) {
105679 const sourceCode = context.getSourceCode();
105680 /**
105681 * Returns the operator token of an AssignmentExpression or BinaryExpression
105682 * @param {ASTNode} node An AssignmentExpression or BinaryExpression node
105683 * @returns {Token} The operator token in the node
105684 */
105685
105686 function getOperatorToken(node) {
105687 return sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
105688 }
105689 /**
105690 * Ensures that an assignment uses the shorthand form where possible.
105691 * @param {ASTNode} node An AssignmentExpression node.
105692 * @returns {void}
105693 */
105694
105695
105696 function verify(node) {
105697 if (node.operator !== "=" || node.right.type !== "BinaryExpression") {
105698 return;
105699 }
105700
105701 const left = node.left;
105702 const expr = node.right;
105703 const operator = expr.operator;
105704
105705 if (isCommutativeOperatorWithShorthand(operator) || isNonCommutativeOperatorWithShorthand(operator)) {
105706 if (astUtils.isSameReference(left, expr.left, true)) {
105707 context.report({
105708 node,
105709 messageId: "replaced",
105710 data: {
105711 operator
105712 },
105713
105714 fix(fixer) {
105715 if (canBeFixed(left) && canBeFixed(expr.left)) {
105716 const equalsToken = getOperatorToken(node);
105717 const operatorToken = getOperatorToken(expr);
105718 const leftText = sourceCode.getText().slice(node.range[0], equalsToken.range[0]);
105719 const rightText = sourceCode.getText().slice(operatorToken.range[1], node.right.range[1]); // Check for comments that would be removed.
105720
105721 if (sourceCode.commentsExistBetween(equalsToken, operatorToken)) {
105722 return null;
105723 }
105724
105725 return fixer.replaceText(node, "".concat(leftText).concat(expr.operator, "=").concat(rightText));
105726 }
105727
105728 return null;
105729 }
105730
105731 });
105732 } else if (astUtils.isSameReference(left, expr.right, true) && isCommutativeOperatorWithShorthand(operator)) {
105733 /*
105734 * This case can't be fixed safely.
105735 * If `a` and `b` both have custom valueOf() behavior, then fixing `a = b * a` to `a *= b` would
105736 * change the execution order of the valueOf() functions.
105737 */
105738 context.report({
105739 node,
105740 messageId: "replaced",
105741 data: {
105742 operator
105743 }
105744 });
105745 }
105746 }
105747 }
105748 /**
105749 * Warns if an assignment expression uses operator assignment shorthand.
105750 * @param {ASTNode} node An AssignmentExpression node.
105751 * @returns {void}
105752 */
105753
105754
105755 function prohibit(node) {
105756 if (node.operator !== "=" && !astUtils.isLogicalAssignmentOperator(node.operator)) {
105757 context.report({
105758 node,
105759 messageId: "unexpected",
105760 data: {
105761 operator: node.operator
105762 },
105763
105764 fix(fixer) {
105765 if (canBeFixed(node.left)) {
105766 const firstToken = sourceCode.getFirstToken(node);
105767 const operatorToken = getOperatorToken(node);
105768 const leftText = sourceCode.getText().slice(node.range[0], operatorToken.range[0]);
105769 const newOperator = node.operator.slice(0, -1);
105770 let rightText; // Check for comments that would be duplicated.
105771
105772 if (sourceCode.commentsExistBetween(firstToken, operatorToken)) {
105773 return null;
105774 } // If this change would modify precedence (e.g. `foo *= bar + 1` => `foo = foo * (bar + 1)`), parenthesize the right side.
105775
105776
105777 if (astUtils.getPrecedence(node.right) <= astUtils.getPrecedence({
105778 type: "BinaryExpression",
105779 operator: newOperator
105780 }) && !astUtils.isParenthesised(sourceCode, node.right)) {
105781 rightText = "".concat(sourceCode.text.slice(operatorToken.range[1], node.right.range[0]), "(").concat(sourceCode.getText(node.right), ")");
105782 } else {
105783 const tokenAfterOperator = sourceCode.getTokenAfter(operatorToken, {
105784 includeComments: true
105785 });
105786 let rightTextPrefix = "";
105787
105788 if (operatorToken.range[1] === tokenAfterOperator.range[0] && !astUtils.canTokensBeAdjacent({
105789 type: "Punctuator",
105790 value: newOperator
105791 }, tokenAfterOperator)) {
105792 rightTextPrefix = " "; // foo+=+bar -> foo= foo+ +bar
105793 }
105794
105795 rightText = "".concat(rightTextPrefix).concat(sourceCode.text.slice(operatorToken.range[1], node.range[1]));
105796 }
105797
105798 return fixer.replaceText(node, "".concat(leftText, "= ").concat(leftText).concat(newOperator).concat(rightText));
105799 }
105800
105801 return null;
105802 }
105803
105804 });
105805 }
105806 }
105807
105808 return {
105809 AssignmentExpression: context.options[0] !== "never" ? verify : prohibit
105810 };
105811 }
105812
105813 };
105814
105815 /***/ }),
105816 /* 798 */
105817 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
105818
105819 "use strict";
105820 /**
105821 * @fileoverview Operator linebreak - enforces operator linebreak style of two types: after and before
105822 * @author Benoît Zugmeyer
105823 */
105824 //------------------------------------------------------------------------------
105825 // Requirements
105826 //------------------------------------------------------------------------------
105827
105828 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
105829 // Rule Definition
105830 //------------------------------------------------------------------------------
105831
105832
105833 module.exports = {
105834 meta: {
105835 type: "layout",
105836 docs: {
105837 description: "enforce consistent linebreak style for operators",
105838 recommended: false,
105839 url: "https://eslint.org/docs/rules/operator-linebreak"
105840 },
105841 schema: [{
105842 enum: ["after", "before", "none", null]
105843 }, {
105844 type: "object",
105845 properties: {
105846 overrides: {
105847 type: "object",
105848 additionalProperties: {
105849 enum: ["after", "before", "none", "ignore"]
105850 }
105851 }
105852 },
105853 additionalProperties: false
105854 }],
105855 fixable: "code",
105856 messages: {
105857 operatorAtBeginning: "'{{operator}}' should be placed at the beginning of the line.",
105858 operatorAtEnd: "'{{operator}}' should be placed at the end of the line.",
105859 badLinebreak: "Bad line breaking before and after '{{operator}}'.",
105860 noLinebreak: "There should be no line break before or after '{{operator}}'."
105861 }
105862 },
105863
105864 create(context) {
105865 const usedDefaultGlobal = !context.options[0];
105866 const globalStyle = context.options[0] || "after";
105867 const options = context.options[1] || {};
105868 const styleOverrides = options.overrides ? Object.assign({}, options.overrides) : {};
105869
105870 if (usedDefaultGlobal && !styleOverrides["?"]) {
105871 styleOverrides["?"] = "before";
105872 }
105873
105874 if (usedDefaultGlobal && !styleOverrides[":"]) {
105875 styleOverrides[":"] = "before";
105876 }
105877
105878 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
105879 // Helpers
105880 //--------------------------------------------------------------------------
105881
105882 /**
105883 * Gets a fixer function to fix rule issues
105884 * @param {Token} operatorToken The operator token of an expression
105885 * @param {string} desiredStyle The style for the rule. One of 'before', 'after', 'none'
105886 * @returns {Function} A fixer function
105887 */
105888
105889 function getFixer(operatorToken, desiredStyle) {
105890 return fixer => {
105891 const tokenBefore = sourceCode.getTokenBefore(operatorToken);
105892 const tokenAfter = sourceCode.getTokenAfter(operatorToken);
105893 const textBefore = sourceCode.text.slice(tokenBefore.range[1], operatorToken.range[0]);
105894 const textAfter = sourceCode.text.slice(operatorToken.range[1], tokenAfter.range[0]);
105895 const hasLinebreakBefore = !astUtils.isTokenOnSameLine(tokenBefore, operatorToken);
105896 const hasLinebreakAfter = !astUtils.isTokenOnSameLine(operatorToken, tokenAfter);
105897 let newTextBefore, newTextAfter;
105898
105899 if (hasLinebreakBefore !== hasLinebreakAfter && desiredStyle !== "none") {
105900 // If there is a comment before and after the operator, don't do a fix.
105901 if (sourceCode.getTokenBefore(operatorToken, {
105902 includeComments: true
105903 }) !== tokenBefore && sourceCode.getTokenAfter(operatorToken, {
105904 includeComments: true
105905 }) !== tokenAfter) {
105906 return null;
105907 }
105908 /*
105909 * If there is only one linebreak and it's on the wrong side of the operator, swap the text before and after the operator.
105910 * foo &&
105911 * bar
105912 * would get fixed to
105913 * foo
105914 * && bar
105915 */
105916
105917
105918 newTextBefore = textAfter;
105919 newTextAfter = textBefore;
105920 } else {
105921 const LINEBREAK_REGEX = astUtils.createGlobalLinebreakMatcher(); // Otherwise, if no linebreak is desired and no comments interfere, replace the linebreaks with empty strings.
105922
105923 newTextBefore = desiredStyle === "before" || textBefore.trim() ? textBefore : textBefore.replace(LINEBREAK_REGEX, "");
105924 newTextAfter = desiredStyle === "after" || textAfter.trim() ? textAfter : textAfter.replace(LINEBREAK_REGEX, ""); // If there was no change (due to interfering comments), don't output a fix.
105925
105926 if (newTextBefore === textBefore && newTextAfter === textAfter) {
105927 return null;
105928 }
105929 }
105930
105931 if (newTextAfter === "" && tokenAfter.type === "Punctuator" && "+-".includes(operatorToken.value) && tokenAfter.value === operatorToken.value) {
105932 // To avoid accidentally creating a ++ or -- operator, insert a space if the operator is a +/- and the following token is a unary +/-.
105933 newTextAfter += " ";
105934 }
105935
105936 return fixer.replaceTextRange([tokenBefore.range[1], tokenAfter.range[0]], newTextBefore + operatorToken.value + newTextAfter);
105937 };
105938 }
105939 /**
105940 * Checks the operator placement
105941 * @param {ASTNode} node The node to check
105942 * @param {ASTNode} rightSide The node that comes after the operator in `node`
105943 * @param {string} operator The operator
105944 * @private
105945 * @returns {void}
105946 */
105947
105948
105949 function validateNode(node, rightSide, operator) {
105950 /*
105951 * Find the operator token by searching from the right side, because between the left side and the operator
105952 * there could be additional tokens from type annotations. Search specifically for the token which
105953 * value equals the operator, in order to skip possible opening parentheses before the right side node.
105954 */
105955 const operatorToken = sourceCode.getTokenBefore(rightSide, token => token.value === operator);
105956 const leftToken = sourceCode.getTokenBefore(operatorToken);
105957 const rightToken = sourceCode.getTokenAfter(operatorToken);
105958 const operatorStyleOverride = styleOverrides[operator];
105959 const style = operatorStyleOverride || globalStyle;
105960 const fix = getFixer(operatorToken, style); // if single line
105961
105962 if (astUtils.isTokenOnSameLine(leftToken, operatorToken) && astUtils.isTokenOnSameLine(operatorToken, rightToken)) {// do nothing.
105963 } else if (operatorStyleOverride !== "ignore" && !astUtils.isTokenOnSameLine(leftToken, operatorToken) && !astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
105964 // lone operator
105965 context.report({
105966 node,
105967 loc: operatorToken.loc,
105968 messageId: "badLinebreak",
105969 data: {
105970 operator
105971 },
105972 fix
105973 });
105974 } else if (style === "before" && astUtils.isTokenOnSameLine(leftToken, operatorToken)) {
105975 context.report({
105976 node,
105977 loc: operatorToken.loc,
105978 messageId: "operatorAtBeginning",
105979 data: {
105980 operator
105981 },
105982 fix
105983 });
105984 } else if (style === "after" && astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
105985 context.report({
105986 node,
105987 loc: operatorToken.loc,
105988 messageId: "operatorAtEnd",
105989 data: {
105990 operator
105991 },
105992 fix
105993 });
105994 } else if (style === "none") {
105995 context.report({
105996 node,
105997 loc: operatorToken.loc,
105998 messageId: "noLinebreak",
105999 data: {
106000 operator
106001 },
106002 fix
106003 });
106004 }
106005 }
106006 /**
106007 * Validates a binary expression using `validateNode`
106008 * @param {BinaryExpression|LogicalExpression|AssignmentExpression} node node to be validated
106009 * @returns {void}
106010 */
106011
106012
106013 function validateBinaryExpression(node) {
106014 validateNode(node, node.right, node.operator);
106015 } //--------------------------------------------------------------------------
106016 // Public
106017 //--------------------------------------------------------------------------
106018
106019
106020 return {
106021 BinaryExpression: validateBinaryExpression,
106022 LogicalExpression: validateBinaryExpression,
106023 AssignmentExpression: validateBinaryExpression,
106024
106025 VariableDeclarator(node) {
106026 if (node.init) {
106027 validateNode(node, node.init, "=");
106028 }
106029 },
106030
106031 PropertyDefinition(node) {
106032 if (node.value) {
106033 validateNode(node, node.value, "=");
106034 }
106035 },
106036
106037 ConditionalExpression(node) {
106038 validateNode(node, node.consequent, "?");
106039 validateNode(node, node.alternate, ":");
106040 }
106041
106042 };
106043 }
106044
106045 };
106046
106047 /***/ }),
106048 /* 799 */
106049 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
106050
106051 "use strict";
106052 /**
106053 * @fileoverview A rule to ensure blank lines within blocks.
106054 * @author Mathias Schreck <https://github.com/lo1tuma>
106055 */
106056 //------------------------------------------------------------------------------
106057 // Requirements
106058 //------------------------------------------------------------------------------
106059
106060 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
106061 // Rule Definition
106062 //------------------------------------------------------------------------------
106063
106064
106065 module.exports = {
106066 meta: {
106067 type: "layout",
106068 docs: {
106069 description: "require or disallow padding within blocks",
106070 recommended: false,
106071 url: "https://eslint.org/docs/rules/padded-blocks"
106072 },
106073 fixable: "whitespace",
106074 schema: [{
106075 oneOf: [{
106076 enum: ["always", "never"]
106077 }, {
106078 type: "object",
106079 properties: {
106080 blocks: {
106081 enum: ["always", "never"]
106082 },
106083 switches: {
106084 enum: ["always", "never"]
106085 },
106086 classes: {
106087 enum: ["always", "never"]
106088 }
106089 },
106090 additionalProperties: false,
106091 minProperties: 1
106092 }]
106093 }, {
106094 type: "object",
106095 properties: {
106096 allowSingleLineBlocks: {
106097 type: "boolean"
106098 }
106099 },
106100 additionalProperties: false
106101 }],
106102 messages: {
106103 alwaysPadBlock: "Block must be padded by blank lines.",
106104 neverPadBlock: "Block must not be padded by blank lines."
106105 }
106106 },
106107
106108 create(context) {
106109 const options = {};
106110 const typeOptions = context.options[0] || "always";
106111 const exceptOptions = context.options[1] || {};
106112
106113 if (typeof typeOptions === "string") {
106114 const shouldHavePadding = typeOptions === "always";
106115 options.blocks = shouldHavePadding;
106116 options.switches = shouldHavePadding;
106117 options.classes = shouldHavePadding;
106118 } else {
106119 if (Object.prototype.hasOwnProperty.call(typeOptions, "blocks")) {
106120 options.blocks = typeOptions.blocks === "always";
106121 }
106122
106123 if (Object.prototype.hasOwnProperty.call(typeOptions, "switches")) {
106124 options.switches = typeOptions.switches === "always";
106125 }
106126
106127 if (Object.prototype.hasOwnProperty.call(typeOptions, "classes")) {
106128 options.classes = typeOptions.classes === "always";
106129 }
106130 }
106131
106132 if (Object.prototype.hasOwnProperty.call(exceptOptions, "allowSingleLineBlocks")) {
106133 options.allowSingleLineBlocks = exceptOptions.allowSingleLineBlocks === true;
106134 }
106135
106136 const sourceCode = context.getSourceCode();
106137 /**
106138 * Gets the open brace token from a given node.
106139 * @param {ASTNode} node A BlockStatement or SwitchStatement node from which to get the open brace.
106140 * @returns {Token} The token of the open brace.
106141 */
106142
106143 function getOpenBrace(node) {
106144 if (node.type === "SwitchStatement") {
106145 return sourceCode.getTokenBefore(node.cases[0]);
106146 }
106147
106148 if (node.type === "StaticBlock") {
106149 return sourceCode.getFirstToken(node, {
106150 skip: 1
106151 }); // skip the `static` token
106152 } // `BlockStatement` or `ClassBody`
106153
106154
106155 return sourceCode.getFirstToken(node);
106156 }
106157 /**
106158 * Checks if the given parameter is a comment node
106159 * @param {ASTNode|Token} node An AST node or token
106160 * @returns {boolean} True if node is a comment
106161 */
106162
106163
106164 function isComment(node) {
106165 return node.type === "Line" || node.type === "Block";
106166 }
106167 /**
106168 * Checks if there is padding between two tokens
106169 * @param {Token} first The first token
106170 * @param {Token} second The second token
106171 * @returns {boolean} True if there is at least a line between the tokens
106172 */
106173
106174
106175 function isPaddingBetweenTokens(first, second) {
106176 return second.loc.start.line - first.loc.end.line >= 2;
106177 }
106178 /**
106179 * Checks if the given token has a blank line after it.
106180 * @param {Token} token The token to check.
106181 * @returns {boolean} Whether or not the token is followed by a blank line.
106182 */
106183
106184
106185 function getFirstBlockToken(token) {
106186 let prev,
106187 first = token;
106188
106189 do {
106190 prev = first;
106191 first = sourceCode.getTokenAfter(first, {
106192 includeComments: true
106193 });
106194 } while (isComment(first) && first.loc.start.line === prev.loc.end.line);
106195
106196 return first;
106197 }
106198 /**
106199 * Checks if the given token is preceded by a blank line.
106200 * @param {Token} token The token to check
106201 * @returns {boolean} Whether or not the token is preceded by a blank line
106202 */
106203
106204
106205 function getLastBlockToken(token) {
106206 let last = token,
106207 next;
106208
106209 do {
106210 next = last;
106211 last = sourceCode.getTokenBefore(last, {
106212 includeComments: true
106213 });
106214 } while (isComment(last) && last.loc.end.line === next.loc.start.line);
106215
106216 return last;
106217 }
106218 /**
106219 * Checks if a node should be padded, according to the rule config.
106220 * @param {ASTNode} node The AST node to check.
106221 * @throws {Error} (Unreachable)
106222 * @returns {boolean} True if the node should be padded, false otherwise.
106223 */
106224
106225
106226 function requirePaddingFor(node) {
106227 switch (node.type) {
106228 case "BlockStatement":
106229 case "StaticBlock":
106230 return options.blocks;
106231
106232 case "SwitchStatement":
106233 return options.switches;
106234
106235 case "ClassBody":
106236 return options.classes;
106237
106238 /* istanbul ignore next */
106239
106240 default:
106241 throw new Error("unreachable");
106242 }
106243 }
106244 /**
106245 * Checks the given BlockStatement node to be padded if the block is not empty.
106246 * @param {ASTNode} node The AST node of a BlockStatement.
106247 * @returns {void} undefined.
106248 */
106249
106250
106251 function checkPadding(node) {
106252 const openBrace = getOpenBrace(node),
106253 firstBlockToken = getFirstBlockToken(openBrace),
106254 tokenBeforeFirst = sourceCode.getTokenBefore(firstBlockToken, {
106255 includeComments: true
106256 }),
106257 closeBrace = sourceCode.getLastToken(node),
106258 lastBlockToken = getLastBlockToken(closeBrace),
106259 tokenAfterLast = sourceCode.getTokenAfter(lastBlockToken, {
106260 includeComments: true
106261 }),
106262 blockHasTopPadding = isPaddingBetweenTokens(tokenBeforeFirst, firstBlockToken),
106263 blockHasBottomPadding = isPaddingBetweenTokens(lastBlockToken, tokenAfterLast);
106264
106265 if (options.allowSingleLineBlocks && astUtils.isTokenOnSameLine(tokenBeforeFirst, tokenAfterLast)) {
106266 return;
106267 }
106268
106269 if (requirePaddingFor(node)) {
106270 if (!blockHasTopPadding) {
106271 context.report({
106272 node,
106273 loc: {
106274 start: tokenBeforeFirst.loc.start,
106275 end: firstBlockToken.loc.start
106276 },
106277
106278 fix(fixer) {
106279 return fixer.insertTextAfter(tokenBeforeFirst, "\n");
106280 },
106281
106282 messageId: "alwaysPadBlock"
106283 });
106284 }
106285
106286 if (!blockHasBottomPadding) {
106287 context.report({
106288 node,
106289 loc: {
106290 end: tokenAfterLast.loc.start,
106291 start: lastBlockToken.loc.end
106292 },
106293
106294 fix(fixer) {
106295 return fixer.insertTextBefore(tokenAfterLast, "\n");
106296 },
106297
106298 messageId: "alwaysPadBlock"
106299 });
106300 }
106301 } else {
106302 if (blockHasTopPadding) {
106303 context.report({
106304 node,
106305 loc: {
106306 start: tokenBeforeFirst.loc.start,
106307 end: firstBlockToken.loc.start
106308 },
106309
106310 fix(fixer) {
106311 return fixer.replaceTextRange([tokenBeforeFirst.range[1], firstBlockToken.range[0] - firstBlockToken.loc.start.column], "\n");
106312 },
106313
106314 messageId: "neverPadBlock"
106315 });
106316 }
106317
106318 if (blockHasBottomPadding) {
106319 context.report({
106320 node,
106321 loc: {
106322 end: tokenAfterLast.loc.start,
106323 start: lastBlockToken.loc.end
106324 },
106325 messageId: "neverPadBlock",
106326
106327 fix(fixer) {
106328 return fixer.replaceTextRange([lastBlockToken.range[1], tokenAfterLast.range[0] - tokenAfterLast.loc.start.column], "\n");
106329 }
106330
106331 });
106332 }
106333 }
106334 }
106335
106336 const rule = {};
106337
106338 if (Object.prototype.hasOwnProperty.call(options, "switches")) {
106339 rule.SwitchStatement = function (node) {
106340 if (node.cases.length === 0) {
106341 return;
106342 }
106343
106344 checkPadding(node);
106345 };
106346 }
106347
106348 if (Object.prototype.hasOwnProperty.call(options, "blocks")) {
106349 rule.BlockStatement = function (node) {
106350 if (node.body.length === 0) {
106351 return;
106352 }
106353
106354 checkPadding(node);
106355 };
106356
106357 rule.StaticBlock = rule.BlockStatement;
106358 }
106359
106360 if (Object.prototype.hasOwnProperty.call(options, "classes")) {
106361 rule.ClassBody = function (node) {
106362 if (node.body.length === 0) {
106363 return;
106364 }
106365
106366 checkPadding(node);
106367 };
106368 }
106369
106370 return rule;
106371 }
106372
106373 };
106374
106375 /***/ }),
106376 /* 800 */
106377 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
106378
106379 "use strict";
106380 /**
106381 * @fileoverview Rule to require or disallow newlines between statements
106382 * @author Toru Nagashima
106383 */
106384 //------------------------------------------------------------------------------
106385 // Requirements
106386 //------------------------------------------------------------------------------
106387
106388 var _templateObject;
106389
106390 function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
106391
106392 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
106393 // Helpers
106394 //------------------------------------------------------------------------------
106395
106396
106397 const LT = "[".concat(Array.from(astUtils.LINEBREAKS).join(""), "]");
106398 const PADDING_LINE_SEQUENCE = new RegExp(String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["^(s*?", ")s*", "(s*;?)$"], ["^(\\s*?", ")\\s*", "(\\s*;?)$"])), LT, LT), "u");
106399 const CJS_EXPORT = /^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u;
106400 const CJS_IMPORT = /^require\(/u;
106401 /**
106402 * Creates tester which check if a node starts with specific keyword.
106403 * @param {string} keyword The keyword to test.
106404 * @returns {Object} the created tester.
106405 * @private
106406 */
106407
106408 function newKeywordTester(keyword) {
106409 return {
106410 test: (node, sourceCode) => sourceCode.getFirstToken(node).value === keyword
106411 };
106412 }
106413 /**
106414 * Creates tester which check if a node starts with specific keyword and spans a single line.
106415 * @param {string} keyword The keyword to test.
106416 * @returns {Object} the created tester.
106417 * @private
106418 */
106419
106420
106421 function newSinglelineKeywordTester(keyword) {
106422 return {
106423 test: (node, sourceCode) => node.loc.start.line === node.loc.end.line && sourceCode.getFirstToken(node).value === keyword
106424 };
106425 }
106426 /**
106427 * Creates tester which check if a node starts with specific keyword and spans multiple lines.
106428 * @param {string} keyword The keyword to test.
106429 * @returns {Object} the created tester.
106430 * @private
106431 */
106432
106433
106434 function newMultilineKeywordTester(keyword) {
106435 return {
106436 test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line && sourceCode.getFirstToken(node).value === keyword
106437 };
106438 }
106439 /**
106440 * Creates tester which check if a node is specific type.
106441 * @param {string} type The node type to test.
106442 * @returns {Object} the created tester.
106443 * @private
106444 */
106445
106446
106447 function newNodeTypeTester(type) {
106448 return {
106449 test: node => node.type === type
106450 };
106451 }
106452 /**
106453 * Checks the given node is an expression statement of IIFE.
106454 * @param {ASTNode} node The node to check.
106455 * @returns {boolean} `true` if the node is an expression statement of IIFE.
106456 * @private
106457 */
106458
106459
106460 function isIIFEStatement(node) {
106461 if (node.type === "ExpressionStatement") {
106462 let call = astUtils.skipChainExpression(node.expression);
106463
106464 if (call.type === "UnaryExpression") {
106465 call = astUtils.skipChainExpression(call.argument);
106466 }
106467
106468 return call.type === "CallExpression" && astUtils.isFunction(call.callee);
106469 }
106470
106471 return false;
106472 }
106473 /**
106474 * Checks whether the given node is a block-like statement.
106475 * This checks the last token of the node is the closing brace of a block.
106476 * @param {SourceCode} sourceCode The source code to get tokens.
106477 * @param {ASTNode} node The node to check.
106478 * @returns {boolean} `true` if the node is a block-like statement.
106479 * @private
106480 */
106481
106482
106483 function isBlockLikeStatement(sourceCode, node) {
106484 // do-while with a block is a block-like statement.
106485 if (node.type === "DoWhileStatement" && node.body.type === "BlockStatement") {
106486 return true;
106487 }
106488 /*
106489 * IIFE is a block-like statement specially from
106490 * JSCS#disallowPaddingNewLinesAfterBlocks.
106491 */
106492
106493
106494 if (isIIFEStatement(node)) {
106495 return true;
106496 } // Checks the last token is a closing brace of blocks.
106497
106498
106499 const lastToken = sourceCode.getLastToken(node, astUtils.isNotSemicolonToken);
106500 const belongingNode = lastToken && astUtils.isClosingBraceToken(lastToken) ? sourceCode.getNodeByRangeIndex(lastToken.range[0]) : null;
106501 return Boolean(belongingNode) && (belongingNode.type === "BlockStatement" || belongingNode.type === "SwitchStatement");
106502 }
106503 /**
106504 * Check whether the given node is a directive or not.
106505 * @param {ASTNode} node The node to check.
106506 * @param {SourceCode} sourceCode The source code object to get tokens.
106507 * @returns {boolean} `true` if the node is a directive.
106508 */
106509
106510
106511 function isDirective(node, sourceCode) {
106512 return node.type === "ExpressionStatement" && (node.parent.type === "Program" || node.parent.type === "BlockStatement" && astUtils.isFunction(node.parent.parent)) && node.expression.type === "Literal" && typeof node.expression.value === "string" && !astUtils.isParenthesised(sourceCode, node.expression);
106513 }
106514 /**
106515 * Check whether the given node is a part of directive prologue or not.
106516 * @param {ASTNode} node The node to check.
106517 * @param {SourceCode} sourceCode The source code object to get tokens.
106518 * @returns {boolean} `true` if the node is a part of directive prologue.
106519 */
106520
106521
106522 function isDirectivePrologue(node, sourceCode) {
106523 if (isDirective(node, sourceCode)) {
106524 for (const sibling of node.parent.body) {
106525 if (sibling === node) {
106526 break;
106527 }
106528
106529 if (!isDirective(sibling, sourceCode)) {
106530 return false;
106531 }
106532 }
106533
106534 return true;
106535 }
106536
106537 return false;
106538 }
106539 /**
106540 * Gets the actual last token.
106541 *
106542 * If a semicolon is semicolon-less style's semicolon, this ignores it.
106543 * For example:
106544 *
106545 * foo()
106546 * ;[1, 2, 3].forEach(bar)
106547 * @param {SourceCode} sourceCode The source code to get tokens.
106548 * @param {ASTNode} node The node to get.
106549 * @returns {Token} The actual last token.
106550 * @private
106551 */
106552
106553
106554 function getActualLastToken(sourceCode, node) {
106555 const semiToken = sourceCode.getLastToken(node);
106556 const prevToken = sourceCode.getTokenBefore(semiToken);
106557 const nextToken = sourceCode.getTokenAfter(semiToken);
106558 const isSemicolonLessStyle = Boolean(prevToken && nextToken && prevToken.range[0] >= node.range[0] && astUtils.isSemicolonToken(semiToken) && semiToken.loc.start.line !== prevToken.loc.end.line && semiToken.loc.end.line === nextToken.loc.start.line);
106559 return isSemicolonLessStyle ? prevToken : semiToken;
106560 }
106561 /**
106562 * This returns the concatenation of the first 2 captured strings.
106563 * @param {string} _ Unused. Whole matched string.
106564 * @param {string} trailingSpaces The trailing spaces of the first line.
106565 * @param {string} indentSpaces The indentation spaces of the last line.
106566 * @returns {string} The concatenation of trailingSpaces and indentSpaces.
106567 * @private
106568 */
106569
106570
106571 function replacerToRemovePaddingLines(_, trailingSpaces, indentSpaces) {
106572 return trailingSpaces + indentSpaces;
106573 }
106574 /**
106575 * Check and report statements for `any` configuration.
106576 * It does nothing.
106577 * @returns {void}
106578 * @private
106579 */
106580
106581
106582 function verifyForAny() {}
106583 /**
106584 * Check and report statements for `never` configuration.
106585 * This autofix removes blank lines between the given 2 statements.
106586 * However, if comments exist between 2 blank lines, it does not remove those
106587 * blank lines automatically.
106588 * @param {RuleContext} context The rule context to report.
106589 * @param {ASTNode} _ Unused. The previous node to check.
106590 * @param {ASTNode} nextNode The next node to check.
106591 * @param {Array<Token[]>} paddingLines The array of token pairs that blank
106592 * lines exist between the pair.
106593 * @returns {void}
106594 * @private
106595 */
106596
106597
106598 function verifyForNever(context, _, nextNode, paddingLines) {
106599 if (paddingLines.length === 0) {
106600 return;
106601 }
106602
106603 context.report({
106604 node: nextNode,
106605 messageId: "unexpectedBlankLine",
106606
106607 fix(fixer) {
106608 if (paddingLines.length >= 2) {
106609 return null;
106610 }
106611
106612 const prevToken = paddingLines[0][0];
106613 const nextToken = paddingLines[0][1];
106614 const start = prevToken.range[1];
106615 const end = nextToken.range[0];
106616 const text = context.getSourceCode().text.slice(start, end).replace(PADDING_LINE_SEQUENCE, replacerToRemovePaddingLines);
106617 return fixer.replaceTextRange([start, end], text);
106618 }
106619
106620 });
106621 }
106622 /**
106623 * Check and report statements for `always` configuration.
106624 * This autofix inserts a blank line between the given 2 statements.
106625 * If the `prevNode` has trailing comments, it inserts a blank line after the
106626 * trailing comments.
106627 * @param {RuleContext} context The rule context to report.
106628 * @param {ASTNode} prevNode The previous node to check.
106629 * @param {ASTNode} nextNode The next node to check.
106630 * @param {Array<Token[]>} paddingLines The array of token pairs that blank
106631 * lines exist between the pair.
106632 * @returns {void}
106633 * @private
106634 */
106635
106636
106637 function verifyForAlways(context, prevNode, nextNode, paddingLines) {
106638 if (paddingLines.length > 0) {
106639 return;
106640 }
106641
106642 context.report({
106643 node: nextNode,
106644 messageId: "expectedBlankLine",
106645
106646 fix(fixer) {
106647 const sourceCode = context.getSourceCode();
106648 let prevToken = getActualLastToken(sourceCode, prevNode);
106649 const nextToken = sourceCode.getFirstTokenBetween(prevToken, nextNode, {
106650 includeComments: true,
106651
106652 /**
106653 * Skip the trailing comments of the previous node.
106654 * This inserts a blank line after the last trailing comment.
106655 *
106656 * For example:
106657 *
106658 * foo(); // trailing comment.
106659 * // comment.
106660 * bar();
106661 *
106662 * Get fixed to:
106663 *
106664 * foo(); // trailing comment.
106665 *
106666 * // comment.
106667 * bar();
106668 * @param {Token} token The token to check.
106669 * @returns {boolean} `true` if the token is not a trailing comment.
106670 * @private
106671 */
106672 filter(token) {
106673 if (astUtils.isTokenOnSameLine(prevToken, token)) {
106674 prevToken = token;
106675 return false;
106676 }
106677
106678 return true;
106679 }
106680
106681 }) || nextNode;
106682 const insertText = astUtils.isTokenOnSameLine(prevToken, nextToken) ? "\n\n" : "\n";
106683 return fixer.insertTextAfter(prevToken, insertText);
106684 }
106685
106686 });
106687 }
106688 /**
106689 * Types of blank lines.
106690 * `any`, `never`, and `always` are defined.
106691 * Those have `verify` method to check and report statements.
106692 * @private
106693 */
106694
106695
106696 const PaddingTypes = {
106697 any: {
106698 verify: verifyForAny
106699 },
106700 never: {
106701 verify: verifyForNever
106702 },
106703 always: {
106704 verify: verifyForAlways
106705 }
106706 };
106707 /**
106708 * Types of statements.
106709 * Those have `test` method to check it matches to the given statement.
106710 * @private
106711 */
106712
106713 const StatementTypes = {
106714 "*": {
106715 test: () => true
106716 },
106717 "block-like": {
106718 test: (node, sourceCode) => isBlockLikeStatement(sourceCode, node)
106719 },
106720 "cjs-export": {
106721 test: (node, sourceCode) => node.type === "ExpressionStatement" && node.expression.type === "AssignmentExpression" && CJS_EXPORT.test(sourceCode.getText(node.expression.left))
106722 },
106723 "cjs-import": {
106724 test: (node, sourceCode) => node.type === "VariableDeclaration" && node.declarations.length > 0 && Boolean(node.declarations[0].init) && CJS_IMPORT.test(sourceCode.getText(node.declarations[0].init))
106725 },
106726 directive: {
106727 test: isDirectivePrologue
106728 },
106729 expression: {
106730 test: (node, sourceCode) => node.type === "ExpressionStatement" && !isDirectivePrologue(node, sourceCode)
106731 },
106732 iife: {
106733 test: isIIFEStatement
106734 },
106735 "multiline-block-like": {
106736 test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line && isBlockLikeStatement(sourceCode, node)
106737 },
106738 "multiline-expression": {
106739 test: (node, sourceCode) => node.loc.start.line !== node.loc.end.line && node.type === "ExpressionStatement" && !isDirectivePrologue(node, sourceCode)
106740 },
106741 "multiline-const": newMultilineKeywordTester("const"),
106742 "multiline-let": newMultilineKeywordTester("let"),
106743 "multiline-var": newMultilineKeywordTester("var"),
106744 "singleline-const": newSinglelineKeywordTester("const"),
106745 "singleline-let": newSinglelineKeywordTester("let"),
106746 "singleline-var": newSinglelineKeywordTester("var"),
106747 block: newNodeTypeTester("BlockStatement"),
106748 empty: newNodeTypeTester("EmptyStatement"),
106749 function: newNodeTypeTester("FunctionDeclaration"),
106750 break: newKeywordTester("break"),
106751 case: newKeywordTester("case"),
106752 class: newKeywordTester("class"),
106753 const: newKeywordTester("const"),
106754 continue: newKeywordTester("continue"),
106755 debugger: newKeywordTester("debugger"),
106756 default: newKeywordTester("default"),
106757 do: newKeywordTester("do"),
106758 export: newKeywordTester("export"),
106759 for: newKeywordTester("for"),
106760 if: newKeywordTester("if"),
106761 import: newKeywordTester("import"),
106762 let: newKeywordTester("let"),
106763 return: newKeywordTester("return"),
106764 switch: newKeywordTester("switch"),
106765 throw: newKeywordTester("throw"),
106766 try: newKeywordTester("try"),
106767 var: newKeywordTester("var"),
106768 while: newKeywordTester("while"),
106769 with: newKeywordTester("with")
106770 }; //------------------------------------------------------------------------------
106771 // Rule Definition
106772 //------------------------------------------------------------------------------
106773
106774 module.exports = {
106775 meta: {
106776 type: "layout",
106777 docs: {
106778 description: "require or disallow padding lines between statements",
106779 recommended: false,
106780 url: "https://eslint.org/docs/rules/padding-line-between-statements"
106781 },
106782 fixable: "whitespace",
106783 schema: {
106784 definitions: {
106785 paddingType: {
106786 enum: Object.keys(PaddingTypes)
106787 },
106788 statementType: {
106789 anyOf: [{
106790 enum: Object.keys(StatementTypes)
106791 }, {
106792 type: "array",
106793 items: {
106794 enum: Object.keys(StatementTypes)
106795 },
106796 minItems: 1,
106797 uniqueItems: true,
106798 additionalItems: false
106799 }]
106800 }
106801 },
106802 type: "array",
106803 items: {
106804 type: "object",
106805 properties: {
106806 blankLine: {
106807 $ref: "#/definitions/paddingType"
106808 },
106809 prev: {
106810 $ref: "#/definitions/statementType"
106811 },
106812 next: {
106813 $ref: "#/definitions/statementType"
106814 }
106815 },
106816 additionalProperties: false,
106817 required: ["blankLine", "prev", "next"]
106818 },
106819 additionalItems: false
106820 },
106821 messages: {
106822 unexpectedBlankLine: "Unexpected blank line before this statement.",
106823 expectedBlankLine: "Expected blank line before this statement."
106824 }
106825 },
106826
106827 create(context) {
106828 const sourceCode = context.getSourceCode();
106829 const configureList = context.options || [];
106830 let scopeInfo = null;
106831 /**
106832 * Processes to enter to new scope.
106833 * This manages the current previous statement.
106834 * @returns {void}
106835 * @private
106836 */
106837
106838 function enterScope() {
106839 scopeInfo = {
106840 upper: scopeInfo,
106841 prevNode: null
106842 };
106843 }
106844 /**
106845 * Processes to exit from the current scope.
106846 * @returns {void}
106847 * @private
106848 */
106849
106850
106851 function exitScope() {
106852 scopeInfo = scopeInfo.upper;
106853 }
106854 /**
106855 * Checks whether the given node matches the given type.
106856 * @param {ASTNode} node The statement node to check.
106857 * @param {string|string[]} type The statement type to check.
106858 * @returns {boolean} `true` if the statement node matched the type.
106859 * @private
106860 */
106861
106862
106863 function match(node, type) {
106864 let innerStatementNode = node;
106865
106866 while (innerStatementNode.type === "LabeledStatement") {
106867 innerStatementNode = innerStatementNode.body;
106868 }
106869
106870 if (Array.isArray(type)) {
106871 return type.some(match.bind(null, innerStatementNode));
106872 }
106873
106874 return StatementTypes[type].test(innerStatementNode, sourceCode);
106875 }
106876 /**
106877 * Finds the last matched configure from configureList.
106878 * @param {ASTNode} prevNode The previous statement to match.
106879 * @param {ASTNode} nextNode The current statement to match.
106880 * @returns {Object} The tester of the last matched configure.
106881 * @private
106882 */
106883
106884
106885 function getPaddingType(prevNode, nextNode) {
106886 for (let i = configureList.length - 1; i >= 0; --i) {
106887 const configure = configureList[i];
106888 const matched = match(prevNode, configure.prev) && match(nextNode, configure.next);
106889
106890 if (matched) {
106891 return PaddingTypes[configure.blankLine];
106892 }
106893 }
106894
106895 return PaddingTypes.any;
106896 }
106897 /**
106898 * Gets padding line sequences between the given 2 statements.
106899 * Comments are separators of the padding line sequences.
106900 * @param {ASTNode} prevNode The previous statement to count.
106901 * @param {ASTNode} nextNode The current statement to count.
106902 * @returns {Array<Token[]>} The array of token pairs.
106903 * @private
106904 */
106905
106906
106907 function getPaddingLineSequences(prevNode, nextNode) {
106908 const pairs = [];
106909 let prevToken = getActualLastToken(sourceCode, prevNode);
106910
106911 if (nextNode.loc.start.line - prevToken.loc.end.line >= 2) {
106912 do {
106913 const token = sourceCode.getTokenAfter(prevToken, {
106914 includeComments: true
106915 });
106916
106917 if (token.loc.start.line - prevToken.loc.end.line >= 2) {
106918 pairs.push([prevToken, token]);
106919 }
106920
106921 prevToken = token;
106922 } while (prevToken.range[0] < nextNode.range[0]);
106923 }
106924
106925 return pairs;
106926 }
106927 /**
106928 * Verify padding lines between the given node and the previous node.
106929 * @param {ASTNode} node The node to verify.
106930 * @returns {void}
106931 * @private
106932 */
106933
106934
106935 function verify(node) {
106936 const parentType = node.parent.type;
106937 const validParent = astUtils.STATEMENT_LIST_PARENTS.has(parentType) || parentType === "SwitchStatement";
106938
106939 if (!validParent) {
106940 return;
106941 } // Save this node as the current previous statement.
106942
106943
106944 const prevNode = scopeInfo.prevNode; // Verify.
106945
106946 if (prevNode) {
106947 const type = getPaddingType(prevNode, node);
106948 const paddingLines = getPaddingLineSequences(prevNode, node);
106949 type.verify(context, prevNode, node, paddingLines);
106950 }
106951
106952 scopeInfo.prevNode = node;
106953 }
106954 /**
106955 * Verify padding lines between the given node and the previous node.
106956 * Then process to enter to new scope.
106957 * @param {ASTNode} node The node to verify.
106958 * @returns {void}
106959 * @private
106960 */
106961
106962
106963 function verifyThenEnterScope(node) {
106964 verify(node);
106965 enterScope();
106966 }
106967
106968 return {
106969 Program: enterScope,
106970 BlockStatement: enterScope,
106971 SwitchStatement: enterScope,
106972 StaticBlock: enterScope,
106973 "Program:exit": exitScope,
106974 "BlockStatement:exit": exitScope,
106975 "SwitchStatement:exit": exitScope,
106976 "StaticBlock:exit": exitScope,
106977 ":statement": verify,
106978 SwitchCase: verifyThenEnterScope,
106979 "SwitchCase:exit": exitScope
106980 };
106981 }
106982
106983 };
106984
106985 /***/ }),
106986 /* 801 */
106987 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
106988
106989 "use strict";
106990 /**
106991 * @fileoverview A rule to suggest using arrow functions as callbacks.
106992 * @author Toru Nagashima
106993 */
106994
106995
106996 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
106997 // Helpers
106998 //------------------------------------------------------------------------------
106999
107000 /**
107001 * Checks whether or not a given variable is a function name.
107002 * @param {eslint-scope.Variable} variable A variable to check.
107003 * @returns {boolean} `true` if the variable is a function name.
107004 */
107005
107006
107007 function isFunctionName(variable) {
107008 return variable && variable.defs[0].type === "FunctionName";
107009 }
107010 /**
107011 * Checks whether or not a given MetaProperty node equals to a given value.
107012 * @param {ASTNode} node A MetaProperty node to check.
107013 * @param {string} metaName The name of `MetaProperty.meta`.
107014 * @param {string} propertyName The name of `MetaProperty.property`.
107015 * @returns {boolean} `true` if the node is the specific value.
107016 */
107017
107018
107019 function checkMetaProperty(node, metaName, propertyName) {
107020 return node.meta.name === metaName && node.property.name === propertyName;
107021 }
107022 /**
107023 * Gets the variable object of `arguments` which is defined implicitly.
107024 * @param {eslint-scope.Scope} scope A scope to get.
107025 * @returns {eslint-scope.Variable} The found variable object.
107026 */
107027
107028
107029 function getVariableOfArguments(scope) {
107030 const variables = scope.variables;
107031
107032 for (let i = 0; i < variables.length; ++i) {
107033 const variable = variables[i];
107034
107035 if (variable.name === "arguments") {
107036 /*
107037 * If there was a parameter which is named "arguments", the
107038 * implicit "arguments" is not defined.
107039 * So does fast return with null.
107040 */
107041 return variable.identifiers.length === 0 ? variable : null;
107042 }
107043 }
107044 /* istanbul ignore next */
107045
107046
107047 return null;
107048 }
107049 /**
107050 * Checks whether or not a given node is a callback.
107051 * @param {ASTNode} node A node to check.
107052 * @throws {Error} (Unreachable.)
107053 * @returns {Object}
107054 * {boolean} retv.isCallback - `true` if the node is a callback.
107055 * {boolean} retv.isLexicalThis - `true` if the node is with `.bind(this)`.
107056 */
107057
107058
107059 function getCallbackInfo(node) {
107060 const retv = {
107061 isCallback: false,
107062 isLexicalThis: false
107063 };
107064 let currentNode = node;
107065 let parent = node.parent;
107066 let bound = false;
107067
107068 while (currentNode) {
107069 switch (parent.type) {
107070 // Checks parents recursively.
107071 case "LogicalExpression":
107072 case "ChainExpression":
107073 case "ConditionalExpression":
107074 break;
107075 // Checks whether the parent node is `.bind(this)` call.
107076
107077 case "MemberExpression":
107078 if (parent.object === currentNode && !parent.property.computed && parent.property.type === "Identifier" && parent.property.name === "bind") {
107079 const maybeCallee = parent.parent.type === "ChainExpression" ? parent.parent : parent;
107080
107081 if (astUtils.isCallee(maybeCallee)) {
107082 if (!bound) {
107083 bound = true; // Use only the first `.bind()` to make `isLexicalThis` value.
107084
107085 retv.isLexicalThis = maybeCallee.parent.arguments.length === 1 && maybeCallee.parent.arguments[0].type === "ThisExpression";
107086 }
107087
107088 parent = maybeCallee.parent;
107089 } else {
107090 return retv;
107091 }
107092 } else {
107093 return retv;
107094 }
107095
107096 break;
107097 // Checks whether the node is a callback.
107098
107099 case "CallExpression":
107100 case "NewExpression":
107101 if (parent.callee !== currentNode) {
107102 retv.isCallback = true;
107103 }
107104
107105 return retv;
107106
107107 default:
107108 return retv;
107109 }
107110
107111 currentNode = parent;
107112 parent = parent.parent;
107113 }
107114 /* istanbul ignore next */
107115
107116
107117 throw new Error("unreachable");
107118 }
107119 /**
107120 * Checks whether a simple list of parameters contains any duplicates. This does not handle complex
107121 * parameter lists (e.g. with destructuring), since complex parameter lists are a SyntaxError with duplicate
107122 * parameter names anyway. Instead, it always returns `false` for complex parameter lists.
107123 * @param {ASTNode[]} paramsList The list of parameters for a function
107124 * @returns {boolean} `true` if the list of parameters contains any duplicates
107125 */
107126
107127
107128 function hasDuplicateParams(paramsList) {
107129 return paramsList.every(param => param.type === "Identifier") && paramsList.length !== new Set(paramsList.map(param => param.name)).size;
107130 } //------------------------------------------------------------------------------
107131 // Rule Definition
107132 //------------------------------------------------------------------------------
107133
107134
107135 module.exports = {
107136 meta: {
107137 type: "suggestion",
107138 docs: {
107139 description: "require using arrow functions for callbacks",
107140 recommended: false,
107141 url: "https://eslint.org/docs/rules/prefer-arrow-callback"
107142 },
107143 schema: [{
107144 type: "object",
107145 properties: {
107146 allowNamedFunctions: {
107147 type: "boolean",
107148 default: false
107149 },
107150 allowUnboundThis: {
107151 type: "boolean",
107152 default: true
107153 }
107154 },
107155 additionalProperties: false
107156 }],
107157 fixable: "code",
107158 messages: {
107159 preferArrowCallback: "Unexpected function expression."
107160 }
107161 },
107162
107163 create(context) {
107164 const options = context.options[0] || {};
107165 const allowUnboundThis = options.allowUnboundThis !== false; // default to true
107166
107167 const allowNamedFunctions = options.allowNamedFunctions;
107168 const sourceCode = context.getSourceCode();
107169 /*
107170 * {Array<{this: boolean, super: boolean, meta: boolean}>}
107171 * - this - A flag which shows there are one or more ThisExpression.
107172 * - super - A flag which shows there are one or more Super.
107173 * - meta - A flag which shows there are one or more MethProperty.
107174 */
107175
107176 let stack = [];
107177 /**
107178 * Pushes new function scope with all `false` flags.
107179 * @returns {void}
107180 */
107181
107182 function enterScope() {
107183 stack.push({
107184 this: false,
107185 super: false,
107186 meta: false
107187 });
107188 }
107189 /**
107190 * Pops a function scope from the stack.
107191 * @returns {{this: boolean, super: boolean, meta: boolean}} The information of the last scope.
107192 */
107193
107194
107195 function exitScope() {
107196 return stack.pop();
107197 }
107198
107199 return {
107200 // Reset internal state.
107201 Program() {
107202 stack = [];
107203 },
107204
107205 // If there are below, it cannot replace with arrow functions merely.
107206 ThisExpression() {
107207 const info = stack[stack.length - 1];
107208
107209 if (info) {
107210 info.this = true;
107211 }
107212 },
107213
107214 Super() {
107215 const info = stack[stack.length - 1];
107216
107217 if (info) {
107218 info.super = true;
107219 }
107220 },
107221
107222 MetaProperty(node) {
107223 const info = stack[stack.length - 1];
107224
107225 if (info && checkMetaProperty(node, "new", "target")) {
107226 info.meta = true;
107227 }
107228 },
107229
107230 // To skip nested scopes.
107231 FunctionDeclaration: enterScope,
107232 "FunctionDeclaration:exit": exitScope,
107233 // Main.
107234 FunctionExpression: enterScope,
107235
107236 "FunctionExpression:exit"(node) {
107237 const scopeInfo = exitScope(); // Skip named function expressions
107238
107239 if (allowNamedFunctions && node.id && node.id.name) {
107240 return;
107241 } // Skip generators.
107242
107243
107244 if (node.generator) {
107245 return;
107246 } // Skip recursive functions.
107247
107248
107249 const nameVar = context.getDeclaredVariables(node)[0];
107250
107251 if (isFunctionName(nameVar) && nameVar.references.length > 0) {
107252 return;
107253 } // Skip if it's using arguments.
107254
107255
107256 const variable = getVariableOfArguments(context.getScope());
107257
107258 if (variable && variable.references.length > 0) {
107259 return;
107260 } // Reports if it's a callback which can replace with arrows.
107261
107262
107263 const callbackInfo = getCallbackInfo(node);
107264
107265 if (callbackInfo.isCallback && (!allowUnboundThis || !scopeInfo.this || callbackInfo.isLexicalThis) && !scopeInfo.super && !scopeInfo.meta) {
107266 context.report({
107267 node,
107268 messageId: "preferArrowCallback",
107269
107270 *fix(fixer) {
107271 if (!callbackInfo.isLexicalThis && scopeInfo.this || hasDuplicateParams(node.params)) {
107272 /*
107273 * If the callback function does not have .bind(this) and contains a reference to `this`, there
107274 * is no way to determine what `this` should be, so don't perform any fixes.
107275 * If the callback function has duplicates in its list of parameters (possible in sloppy mode),
107276 * don't replace it with an arrow function, because this is a SyntaxError with arrow functions.
107277 */
107278 return;
107279 } // Remove `.bind(this)` if exists.
107280
107281
107282 if (callbackInfo.isLexicalThis) {
107283 const memberNode = node.parent;
107284 /*
107285 * If `.bind(this)` exists but the parent is not `.bind(this)`, don't remove it automatically.
107286 * E.g. `(foo || function(){}).bind(this)`
107287 */
107288
107289 if (memberNode.type !== "MemberExpression") {
107290 return;
107291 }
107292
107293 const callNode = memberNode.parent;
107294 const firstTokenToRemove = sourceCode.getTokenAfter(memberNode.object, astUtils.isNotClosingParenToken);
107295 const lastTokenToRemove = sourceCode.getLastToken(callNode);
107296 /*
107297 * If the member expression is parenthesized, don't remove the right paren.
107298 * E.g. `(function(){}.bind)(this)`
107299 * ^^^^^^^^^^^^
107300 */
107301
107302 if (astUtils.isParenthesised(sourceCode, memberNode)) {
107303 return;
107304 } // If comments exist in the `.bind(this)`, don't remove those.
107305
107306
107307 if (sourceCode.commentsExistBetween(firstTokenToRemove, lastTokenToRemove)) {
107308 return;
107309 }
107310
107311 yield fixer.removeRange([firstTokenToRemove.range[0], lastTokenToRemove.range[1]]);
107312 } // Convert the function expression to an arrow function.
107313
107314
107315 const functionToken = sourceCode.getFirstToken(node, node.async ? 1 : 0);
107316 const leftParenToken = sourceCode.getTokenAfter(functionToken, astUtils.isOpeningParenToken);
107317
107318 if (sourceCode.commentsExistBetween(functionToken, leftParenToken)) {
107319 // Remove only extra tokens to keep comments.
107320 yield fixer.remove(functionToken);
107321
107322 if (node.id) {
107323 yield fixer.remove(node.id);
107324 }
107325 } else {
107326 // Remove extra tokens and spaces.
107327 yield fixer.removeRange([functionToken.range[0], leftParenToken.range[0]]);
107328 }
107329
107330 yield fixer.insertTextBefore(node.body, "=> "); // Get the node that will become the new arrow function.
107331
107332 let replacedNode = callbackInfo.isLexicalThis ? node.parent.parent : node;
107333
107334 if (replacedNode.type === "ChainExpression") {
107335 replacedNode = replacedNode.parent;
107336 }
107337 /*
107338 * If the replaced node is part of a BinaryExpression, LogicalExpression, or MemberExpression, then
107339 * the arrow function needs to be parenthesized, because `foo || () => {}` is invalid syntax even
107340 * though `foo || function() {}` is valid.
107341 */
107342
107343
107344 if (replacedNode.parent.type !== "CallExpression" && replacedNode.parent.type !== "ConditionalExpression" && !astUtils.isParenthesised(sourceCode, replacedNode) && !astUtils.isParenthesised(sourceCode, node)) {
107345 yield fixer.insertTextBefore(replacedNode, "(");
107346 yield fixer.insertTextAfter(replacedNode, ")");
107347 }
107348 }
107349
107350 });
107351 }
107352 }
107353
107354 };
107355 }
107356
107357 };
107358
107359 /***/ }),
107360 /* 802 */
107361 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
107362
107363 "use strict";
107364 /**
107365 * @fileoverview A rule to suggest using of const declaration for variables that are never reassigned after declared.
107366 * @author Toru Nagashima
107367 */
107368 //------------------------------------------------------------------------------
107369 // Requirements
107370 //------------------------------------------------------------------------------
107371
107372 const FixTracker = __webpack_require__(662);
107373
107374 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
107375 // Helpers
107376 //------------------------------------------------------------------------------
107377
107378
107379 const PATTERN_TYPE = /^(?:.+?Pattern|RestElement|SpreadProperty|ExperimentalRestProperty|Property)$/u;
107380 const DECLARATION_HOST_TYPE = /^(?:Program|BlockStatement|StaticBlock|SwitchCase)$/u;
107381 const DESTRUCTURING_HOST_TYPE = /^(?:VariableDeclarator|AssignmentExpression)$/u;
107382 /**
107383 * Checks whether a given node is located at `ForStatement.init` or not.
107384 * @param {ASTNode} node A node to check.
107385 * @returns {boolean} `true` if the node is located at `ForStatement.init`.
107386 */
107387
107388 function isInitOfForStatement(node) {
107389 return node.parent.type === "ForStatement" && node.parent.init === node;
107390 }
107391 /**
107392 * Checks whether a given Identifier node becomes a VariableDeclaration or not.
107393 * @param {ASTNode} identifier An Identifier node to check.
107394 * @returns {boolean} `true` if the node can become a VariableDeclaration.
107395 */
107396
107397
107398 function canBecomeVariableDeclaration(identifier) {
107399 let node = identifier.parent;
107400
107401 while (PATTERN_TYPE.test(node.type)) {
107402 node = node.parent;
107403 }
107404
107405 return node.type === "VariableDeclarator" || node.type === "AssignmentExpression" && node.parent.type === "ExpressionStatement" && DECLARATION_HOST_TYPE.test(node.parent.parent.type);
107406 }
107407 /**
107408 * Checks if an property or element is from outer scope or function parameters
107409 * in destructing pattern.
107410 * @param {string} name A variable name to be checked.
107411 * @param {eslint-scope.Scope} initScope A scope to start find.
107412 * @returns {boolean} Indicates if the variable is from outer scope or function parameters.
107413 */
107414
107415
107416 function isOuterVariableInDestructing(name, initScope) {
107417 if (initScope.through.find(ref => ref.resolved && ref.resolved.name === name)) {
107418 return true;
107419 }
107420
107421 const variable = astUtils.getVariableByName(initScope, name);
107422
107423 if (variable !== null) {
107424 return variable.defs.some(def => def.type === "Parameter");
107425 }
107426
107427 return false;
107428 }
107429 /**
107430 * Gets the VariableDeclarator/AssignmentExpression node that a given reference
107431 * belongs to.
107432 * This is used to detect a mix of reassigned and never reassigned in a
107433 * destructuring.
107434 * @param {eslint-scope.Reference} reference A reference to get.
107435 * @returns {ASTNode|null} A VariableDeclarator/AssignmentExpression node or
107436 * null.
107437 */
107438
107439
107440 function getDestructuringHost(reference) {
107441 if (!reference.isWrite()) {
107442 return null;
107443 }
107444
107445 let node = reference.identifier.parent;
107446
107447 while (PATTERN_TYPE.test(node.type)) {
107448 node = node.parent;
107449 }
107450
107451 if (!DESTRUCTURING_HOST_TYPE.test(node.type)) {
107452 return null;
107453 }
107454
107455 return node;
107456 }
107457 /**
107458 * Determines if a destructuring assignment node contains
107459 * any MemberExpression nodes. This is used to determine if a
107460 * variable that is only written once using destructuring can be
107461 * safely converted into a const declaration.
107462 * @param {ASTNode} node The ObjectPattern or ArrayPattern node to check.
107463 * @returns {boolean} True if the destructuring pattern contains
107464 * a MemberExpression, false if not.
107465 */
107466
107467
107468 function hasMemberExpressionAssignment(node) {
107469 switch (node.type) {
107470 case "ObjectPattern":
107471 return node.properties.some(prop => {
107472 if (prop) {
107473 /*
107474 * Spread elements have an argument property while
107475 * others have a value property. Because different
107476 * parsers use different node types for spread elements,
107477 * we just check if there is an argument property.
107478 */
107479 return hasMemberExpressionAssignment(prop.argument || prop.value);
107480 }
107481
107482 return false;
107483 });
107484
107485 case "ArrayPattern":
107486 return node.elements.some(element => {
107487 if (element) {
107488 return hasMemberExpressionAssignment(element);
107489 }
107490
107491 return false;
107492 });
107493
107494 case "AssignmentPattern":
107495 return hasMemberExpressionAssignment(node.left);
107496
107497 case "MemberExpression":
107498 return true;
107499 // no default
107500 }
107501
107502 return false;
107503 }
107504 /**
107505 * Gets an identifier node of a given variable.
107506 *
107507 * If the initialization exists or one or more reading references exist before
107508 * the first assignment, the identifier node is the node of the declaration.
107509 * Otherwise, the identifier node is the node of the first assignment.
107510 *
107511 * If the variable should not change to const, this function returns null.
107512 * - If the variable is reassigned.
107513 * - If the variable is never initialized nor assigned.
107514 * - If the variable is initialized in a different scope from the declaration.
107515 * - If the unique assignment of the variable cannot change to a declaration.
107516 * e.g. `if (a) b = 1` / `return (b = 1)`
107517 * - If the variable is declared in the global scope and `eslintUsed` is `true`.
107518 * `/*exported foo` directive comment makes such variables. This rule does not
107519 * warn such variables because this rule cannot distinguish whether the
107520 * exported variables are reassigned or not.
107521 * @param {eslint-scope.Variable} variable A variable to get.
107522 * @param {boolean} ignoreReadBeforeAssign
107523 * The value of `ignoreReadBeforeAssign` option.
107524 * @returns {ASTNode|null}
107525 * An Identifier node if the variable should change to const.
107526 * Otherwise, null.
107527 */
107528
107529
107530 function getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign) {
107531 if (variable.eslintUsed && variable.scope.type === "global") {
107532 return null;
107533 } // Finds the unique WriteReference.
107534
107535
107536 let writer = null;
107537 let isReadBeforeInit = false;
107538 const references = variable.references;
107539
107540 for (let i = 0; i < references.length; ++i) {
107541 const reference = references[i];
107542
107543 if (reference.isWrite()) {
107544 const isReassigned = writer !== null && writer.identifier !== reference.identifier;
107545
107546 if (isReassigned) {
107547 return null;
107548 }
107549
107550 const destructuringHost = getDestructuringHost(reference);
107551
107552 if (destructuringHost !== null && destructuringHost.left !== void 0) {
107553 const leftNode = destructuringHost.left;
107554 let hasOuterVariables = false,
107555 hasNonIdentifiers = false;
107556
107557 if (leftNode.type === "ObjectPattern") {
107558 const properties = leftNode.properties;
107559 hasOuterVariables = properties.filter(prop => prop.value).map(prop => prop.value.name).some(name => isOuterVariableInDestructing(name, variable.scope));
107560 hasNonIdentifiers = hasMemberExpressionAssignment(leftNode);
107561 } else if (leftNode.type === "ArrayPattern") {
107562 const elements = leftNode.elements;
107563 hasOuterVariables = elements.map(element => element && element.name).some(name => isOuterVariableInDestructing(name, variable.scope));
107564 hasNonIdentifiers = hasMemberExpressionAssignment(leftNode);
107565 }
107566
107567 if (hasOuterVariables || hasNonIdentifiers) {
107568 return null;
107569 }
107570 }
107571
107572 writer = reference;
107573 } else if (reference.isRead() && writer === null) {
107574 if (ignoreReadBeforeAssign) {
107575 return null;
107576 }
107577
107578 isReadBeforeInit = true;
107579 }
107580 }
107581 /*
107582 * If the assignment is from a different scope, ignore it.
107583 * If the assignment cannot change to a declaration, ignore it.
107584 */
107585
107586
107587 const shouldBeConst = writer !== null && writer.from === variable.scope && canBecomeVariableDeclaration(writer.identifier);
107588
107589 if (!shouldBeConst) {
107590 return null;
107591 }
107592
107593 if (isReadBeforeInit) {
107594 return variable.defs[0].name;
107595 }
107596
107597 return writer.identifier;
107598 }
107599 /**
107600 * Groups by the VariableDeclarator/AssignmentExpression node that each
107601 * reference of given variables belongs to.
107602 * This is used to detect a mix of reassigned and never reassigned in a
107603 * destructuring.
107604 * @param {eslint-scope.Variable[]} variables Variables to group by destructuring.
107605 * @param {boolean} ignoreReadBeforeAssign
107606 * The value of `ignoreReadBeforeAssign` option.
107607 * @returns {Map<ASTNode, ASTNode[]>} Grouped identifier nodes.
107608 */
107609
107610
107611 function groupByDestructuring(variables, ignoreReadBeforeAssign) {
107612 const identifierMap = new Map();
107613
107614 for (let i = 0; i < variables.length; ++i) {
107615 const variable = variables[i];
107616 const references = variable.references;
107617 const identifier = getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign);
107618 let prevId = null;
107619
107620 for (let j = 0; j < references.length; ++j) {
107621 const reference = references[j];
107622 const id = reference.identifier;
107623 /*
107624 * Avoid counting a reference twice or more for default values of
107625 * destructuring.
107626 */
107627
107628 if (id === prevId) {
107629 continue;
107630 }
107631
107632 prevId = id; // Add the identifier node into the destructuring group.
107633
107634 const group = getDestructuringHost(reference);
107635
107636 if (group) {
107637 if (identifierMap.has(group)) {
107638 identifierMap.get(group).push(identifier);
107639 } else {
107640 identifierMap.set(group, [identifier]);
107641 }
107642 }
107643 }
107644 }
107645
107646 return identifierMap;
107647 }
107648 /**
107649 * Finds the nearest parent of node with a given type.
107650 * @param {ASTNode} node The node to search from.
107651 * @param {string} type The type field of the parent node.
107652 * @param {Function} shouldStop A predicate that returns true if the traversal should stop, and false otherwise.
107653 * @returns {ASTNode} The closest ancestor with the specified type; null if no such ancestor exists.
107654 */
107655
107656
107657 function findUp(node, type, shouldStop) {
107658 if (!node || shouldStop(node)) {
107659 return null;
107660 }
107661
107662 if (node.type === type) {
107663 return node;
107664 }
107665
107666 return findUp(node.parent, type, shouldStop);
107667 } //------------------------------------------------------------------------------
107668 // Rule Definition
107669 //------------------------------------------------------------------------------
107670
107671
107672 module.exports = {
107673 meta: {
107674 type: "suggestion",
107675 docs: {
107676 description: "require `const` declarations for variables that are never reassigned after declared",
107677 recommended: false,
107678 url: "https://eslint.org/docs/rules/prefer-const"
107679 },
107680 fixable: "code",
107681 schema: [{
107682 type: "object",
107683 properties: {
107684 destructuring: {
107685 enum: ["any", "all"],
107686 default: "any"
107687 },
107688 ignoreReadBeforeAssign: {
107689 type: "boolean",
107690 default: false
107691 }
107692 },
107693 additionalProperties: false
107694 }],
107695 messages: {
107696 useConst: "'{{name}}' is never reassigned. Use 'const' instead."
107697 }
107698 },
107699
107700 create(context) {
107701 const options = context.options[0] || {};
107702 const sourceCode = context.getSourceCode();
107703 const shouldMatchAnyDestructuredVariable = options.destructuring !== "all";
107704 const ignoreReadBeforeAssign = options.ignoreReadBeforeAssign === true;
107705 const variables = [];
107706 let reportCount = 0;
107707 let checkedId = null;
107708 let checkedName = "";
107709 /**
107710 * Reports given identifier nodes if all of the nodes should be declared
107711 * as const.
107712 *
107713 * The argument 'nodes' is an array of Identifier nodes.
107714 * This node is the result of 'getIdentifierIfShouldBeConst()', so it's
107715 * nullable. In simple declaration or assignment cases, the length of
107716 * the array is 1. In destructuring cases, the length of the array can
107717 * be 2 or more.
107718 * @param {(eslint-scope.Reference|null)[]} nodes
107719 * References which are grouped by destructuring to report.
107720 * @returns {void}
107721 */
107722
107723 function checkGroup(nodes) {
107724 const nodesToReport = nodes.filter(Boolean);
107725
107726 if (nodes.length && (shouldMatchAnyDestructuredVariable || nodesToReport.length === nodes.length)) {
107727 const varDeclParent = findUp(nodes[0], "VariableDeclaration", parentNode => parentNode.type.endsWith("Statement"));
107728 const isVarDecParentNull = varDeclParent === null;
107729
107730 if (!isVarDecParentNull && varDeclParent.declarations.length > 0) {
107731 const firstDeclaration = varDeclParent.declarations[0];
107732
107733 if (firstDeclaration.init) {
107734 const firstDecParent = firstDeclaration.init.parent;
107735 /*
107736 * First we check the declaration type and then depending on
107737 * if the type is a "VariableDeclarator" or its an "ObjectPattern"
107738 * we compare the name and id from the first identifier, if the names are different
107739 * we assign the new name, id and reset the count of reportCount and nodeCount in
107740 * order to check each block for the number of reported errors and base our fix
107741 * based on comparing nodes.length and nodesToReport.length.
107742 */
107743
107744 if (firstDecParent.type === "VariableDeclarator") {
107745 if (firstDecParent.id.name !== checkedName) {
107746 checkedName = firstDecParent.id.name;
107747 reportCount = 0;
107748 }
107749
107750 if (firstDecParent.id.type === "ObjectPattern") {
107751 if (firstDecParent.init.name !== checkedName) {
107752 checkedName = firstDecParent.init.name;
107753 reportCount = 0;
107754 }
107755 }
107756
107757 if (firstDecParent.id !== checkedId) {
107758 checkedId = firstDecParent.id;
107759 reportCount = 0;
107760 }
107761 }
107762 }
107763 }
107764
107765 let shouldFix = varDeclParent && ( // Don't do a fix unless all variables in the declarations are initialized (or it's in a for-in or for-of loop)
107766 varDeclParent.parent.type === "ForInStatement" || varDeclParent.parent.type === "ForOfStatement" || varDeclParent.declarations.every(declaration => declaration.init)) &&
107767 /*
107768 * If options.destructuring is "all", then this warning will not occur unless
107769 * every assignment in the destructuring should be const. In that case, it's safe
107770 * to apply the fix.
107771 */
107772 nodesToReport.length === nodes.length;
107773
107774 if (!isVarDecParentNull && varDeclParent.declarations && varDeclParent.declarations.length !== 1) {
107775 if (varDeclParent && varDeclParent.declarations && varDeclParent.declarations.length >= 1) {
107776 /*
107777 * Add nodesToReport.length to a count, then comparing the count to the length
107778 * of the declarations in the current block.
107779 */
107780 reportCount += nodesToReport.length;
107781 shouldFix = shouldFix && reportCount === varDeclParent.declarations.length;
107782 }
107783 }
107784
107785 nodesToReport.forEach(node => {
107786 context.report({
107787 node,
107788 messageId: "useConst",
107789 data: node,
107790 fix: shouldFix ? fixer => {
107791 const letKeywordToken = sourceCode.getFirstToken(varDeclParent, t => t.value === varDeclParent.kind);
107792 /**
107793 * Extend the replacement range to the whole declaration,
107794 * in order to prevent other fixes in the same pass
107795 * https://github.com/eslint/eslint/issues/13899
107796 */
107797
107798 return new FixTracker(fixer, sourceCode).retainRange(varDeclParent.range).replaceTextRange(letKeywordToken.range, "const");
107799 } : null
107800 });
107801 });
107802 }
107803 }
107804
107805 return {
107806 "Program:exit"() {
107807 groupByDestructuring(variables, ignoreReadBeforeAssign).forEach(checkGroup);
107808 },
107809
107810 VariableDeclaration(node) {
107811 if (node.kind === "let" && !isInitOfForStatement(node)) {
107812 variables.push(...context.getDeclaredVariables(node));
107813 }
107814 }
107815
107816 };
107817 }
107818
107819 };
107820
107821 /***/ }),
107822 /* 803 */
107823 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
107824
107825 "use strict";
107826 /**
107827 * @fileoverview Prefer destructuring from arrays and objects
107828 * @author Alex LaFroscia
107829 */
107830 //------------------------------------------------------------------------------
107831 // Requirements
107832 //------------------------------------------------------------------------------
107833
107834 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
107835 // Helpers
107836 //------------------------------------------------------------------------------
107837
107838
107839 const PRECEDENCE_OF_ASSIGNMENT_EXPR = astUtils.getPrecedence({
107840 type: "AssignmentExpression"
107841 }); //------------------------------------------------------------------------------
107842 // Rule Definition
107843 //------------------------------------------------------------------------------
107844
107845 module.exports = {
107846 meta: {
107847 type: "suggestion",
107848 docs: {
107849 description: "require destructuring from arrays and/or objects",
107850 recommended: false,
107851 url: "https://eslint.org/docs/rules/prefer-destructuring"
107852 },
107853 fixable: "code",
107854 schema: [{
107855 /*
107856 * old support {array: Boolean, object: Boolean}
107857 * new support {VariableDeclarator: {}, AssignmentExpression: {}}
107858 */
107859 oneOf: [{
107860 type: "object",
107861 properties: {
107862 VariableDeclarator: {
107863 type: "object",
107864 properties: {
107865 array: {
107866 type: "boolean"
107867 },
107868 object: {
107869 type: "boolean"
107870 }
107871 },
107872 additionalProperties: false
107873 },
107874 AssignmentExpression: {
107875 type: "object",
107876 properties: {
107877 array: {
107878 type: "boolean"
107879 },
107880 object: {
107881 type: "boolean"
107882 }
107883 },
107884 additionalProperties: false
107885 }
107886 },
107887 additionalProperties: false
107888 }, {
107889 type: "object",
107890 properties: {
107891 array: {
107892 type: "boolean"
107893 },
107894 object: {
107895 type: "boolean"
107896 }
107897 },
107898 additionalProperties: false
107899 }]
107900 }, {
107901 type: "object",
107902 properties: {
107903 enforceForRenamedProperties: {
107904 type: "boolean"
107905 }
107906 },
107907 additionalProperties: false
107908 }],
107909 messages: {
107910 preferDestructuring: "Use {{type}} destructuring."
107911 }
107912 },
107913
107914 create(context) {
107915 const enabledTypes = context.options[0];
107916 const enforceForRenamedProperties = context.options[1] && context.options[1].enforceForRenamedProperties;
107917 let normalizedOptions = {
107918 VariableDeclarator: {
107919 array: true,
107920 object: true
107921 },
107922 AssignmentExpression: {
107923 array: true,
107924 object: true
107925 }
107926 };
107927
107928 if (enabledTypes) {
107929 normalizedOptions = typeof enabledTypes.array !== "undefined" || typeof enabledTypes.object !== "undefined" ? {
107930 VariableDeclarator: enabledTypes,
107931 AssignmentExpression: enabledTypes
107932 } : enabledTypes;
107933 } //--------------------------------------------------------------------------
107934 // Helpers
107935 //--------------------------------------------------------------------------
107936
107937 /**
107938 * Checks if destructuring type should be checked.
107939 * @param {string} nodeType "AssignmentExpression" or "VariableDeclarator"
107940 * @param {string} destructuringType "array" or "object"
107941 * @returns {boolean} `true` if the destructuring type should be checked for the given node
107942 */
107943
107944
107945 function shouldCheck(nodeType, destructuringType) {
107946 return normalizedOptions && normalizedOptions[nodeType] && normalizedOptions[nodeType][destructuringType];
107947 }
107948 /**
107949 * Determines if the given node is accessing an array index
107950 *
107951 * This is used to differentiate array index access from object property
107952 * access.
107953 * @param {ASTNode} node the node to evaluate
107954 * @returns {boolean} whether or not the node is an integer
107955 */
107956
107957
107958 function isArrayIndexAccess(node) {
107959 return Number.isInteger(node.property.value);
107960 }
107961 /**
107962 * Report that the given node should use destructuring
107963 * @param {ASTNode} reportNode the node to report
107964 * @param {string} type the type of destructuring that should have been done
107965 * @param {Function|null} fix the fix function or null to pass to context.report
107966 * @returns {void}
107967 */
107968
107969
107970 function report(reportNode, type, fix) {
107971 context.report({
107972 node: reportNode,
107973 messageId: "preferDestructuring",
107974 data: {
107975 type
107976 },
107977 fix
107978 });
107979 }
107980 /**
107981 * Determines if a node should be fixed into object destructuring
107982 *
107983 * The fixer only fixes the simplest case of object destructuring,
107984 * like: `let x = a.x`;
107985 *
107986 * Assignment expression is not fixed.
107987 * Array destructuring is not fixed.
107988 * Renamed property is not fixed.
107989 * @param {ASTNode} node the node to evaluate
107990 * @returns {boolean} whether or not the node should be fixed
107991 */
107992
107993
107994 function shouldFix(node) {
107995 return node.type === "VariableDeclarator" && node.id.type === "Identifier" && node.init.type === "MemberExpression" && !node.init.computed && node.init.property.type === "Identifier" && node.id.name === node.init.property.name;
107996 }
107997 /**
107998 * Fix a node into object destructuring.
107999 * This function only handles the simplest case of object destructuring,
108000 * see {@link shouldFix}.
108001 * @param {SourceCodeFixer} fixer the fixer object
108002 * @param {ASTNode} node the node to be fixed.
108003 * @returns {Object} a fix for the node
108004 */
108005
108006
108007 function fixIntoObjectDestructuring(fixer, node) {
108008 const rightNode = node.init;
108009 const sourceCode = context.getSourceCode(); // Don't fix if that would remove any comments. Only comments inside `rightNode.object` can be preserved.
108010
108011 if (sourceCode.getCommentsInside(node).length > sourceCode.getCommentsInside(rightNode.object).length) {
108012 return null;
108013 }
108014
108015 let objectText = sourceCode.getText(rightNode.object);
108016
108017 if (astUtils.getPrecedence(rightNode.object) < PRECEDENCE_OF_ASSIGNMENT_EXPR) {
108018 objectText = "(".concat(objectText, ")");
108019 }
108020
108021 return fixer.replaceText(node, "{".concat(rightNode.property.name, "} = ").concat(objectText));
108022 }
108023 /**
108024 * Check that the `prefer-destructuring` rules are followed based on the
108025 * given left- and right-hand side of the assignment.
108026 *
108027 * Pulled out into a separate method so that VariableDeclarators and
108028 * AssignmentExpressions can share the same verification logic.
108029 * @param {ASTNode} leftNode the left-hand side of the assignment
108030 * @param {ASTNode} rightNode the right-hand side of the assignment
108031 * @param {ASTNode} reportNode the node to report the error on
108032 * @returns {void}
108033 */
108034
108035
108036 function performCheck(leftNode, rightNode, reportNode) {
108037 if (rightNode.type !== "MemberExpression" || rightNode.object.type === "Super" || rightNode.property.type === "PrivateIdentifier") {
108038 return;
108039 }
108040
108041 if (isArrayIndexAccess(rightNode)) {
108042 if (shouldCheck(reportNode.type, "array")) {
108043 report(reportNode, "array", null);
108044 }
108045
108046 return;
108047 }
108048
108049 const fix = shouldFix(reportNode) ? fixer => fixIntoObjectDestructuring(fixer, reportNode) : null;
108050
108051 if (shouldCheck(reportNode.type, "object") && enforceForRenamedProperties) {
108052 report(reportNode, "object", fix);
108053 return;
108054 }
108055
108056 if (shouldCheck(reportNode.type, "object")) {
108057 const property = rightNode.property;
108058
108059 if (property.type === "Literal" && leftNode.name === property.value || property.type === "Identifier" && leftNode.name === property.name && !rightNode.computed) {
108060 report(reportNode, "object", fix);
108061 }
108062 }
108063 }
108064 /**
108065 * Check if a given variable declarator is coming from an property access
108066 * that should be using destructuring instead
108067 * @param {ASTNode} node the variable declarator to check
108068 * @returns {void}
108069 */
108070
108071
108072 function checkVariableDeclarator(node) {
108073 // Skip if variable is declared without assignment
108074 if (!node.init) {
108075 return;
108076 } // We only care about member expressions past this point
108077
108078
108079 if (node.init.type !== "MemberExpression") {
108080 return;
108081 }
108082
108083 performCheck(node.id, node.init, node);
108084 }
108085 /**
108086 * Run the `prefer-destructuring` check on an AssignmentExpression
108087 * @param {ASTNode} node the AssignmentExpression node
108088 * @returns {void}
108089 */
108090
108091
108092 function checkAssignmentExpression(node) {
108093 if (node.operator === "=") {
108094 performCheck(node.left, node.right, node);
108095 }
108096 } //--------------------------------------------------------------------------
108097 // Public
108098 //--------------------------------------------------------------------------
108099
108100
108101 return {
108102 VariableDeclarator: checkVariableDeclarator,
108103 AssignmentExpression: checkAssignmentExpression
108104 };
108105 }
108106
108107 };
108108
108109 /***/ }),
108110 /* 804 */
108111 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
108112
108113 "use strict";
108114 /**
108115 * @fileoverview Rule to disallow Math.pow in favor of the ** operator
108116 * @author Milos Djermanovic
108117 */
108118 //------------------------------------------------------------------------------
108119 // Requirements
108120 //------------------------------------------------------------------------------
108121
108122 const astUtils = __webpack_require__(548);
108123
108124 const {
108125 CALL,
108126 ReferenceTracker
108127 } = __webpack_require__(501); //------------------------------------------------------------------------------
108128 // Helpers
108129 //------------------------------------------------------------------------------
108130
108131
108132 const PRECEDENCE_OF_EXPONENTIATION_EXPR = astUtils.getPrecedence({
108133 type: "BinaryExpression",
108134 operator: "**"
108135 });
108136 /**
108137 * Determines whether the given node needs parens if used as the base in an exponentiation binary expression.
108138 * @param {ASTNode} base The node to check.
108139 * @returns {boolean} `true` if the node needs to be parenthesised.
108140 */
108141
108142 function doesBaseNeedParens(base) {
108143 return (// '**' is right-associative, parens are needed when Math.pow(a ** b, c) is converted to (a ** b) ** c
108144 astUtils.getPrecedence(base) <= PRECEDENCE_OF_EXPONENTIATION_EXPR || // An unary operator cannot be used immediately before an exponentiation expression
108145 base.type === "AwaitExpression" || base.type === "UnaryExpression"
108146 );
108147 }
108148 /**
108149 * Determines whether the given node needs parens if used as the exponent in an exponentiation binary expression.
108150 * @param {ASTNode} exponent The node to check.
108151 * @returns {boolean} `true` if the node needs to be parenthesised.
108152 */
108153
108154
108155 function doesExponentNeedParens(exponent) {
108156 // '**' is right-associative, there is no need for parens when Math.pow(a, b ** c) is converted to a ** b ** c
108157 return astUtils.getPrecedence(exponent) < PRECEDENCE_OF_EXPONENTIATION_EXPR;
108158 }
108159 /**
108160 * Determines whether an exponentiation binary expression at the place of the given node would need parens.
108161 * @param {ASTNode} node A node that would be replaced by an exponentiation binary expression.
108162 * @param {SourceCode} sourceCode A SourceCode object.
108163 * @returns {boolean} `true` if the expression needs to be parenthesised.
108164 */
108165
108166
108167 function doesExponentiationExpressionNeedParens(node, sourceCode) {
108168 const parent = node.parent.type === "ChainExpression" ? node.parent.parent : node.parent;
108169 const needsParens = parent.type === "ClassDeclaration" || parent.type.endsWith("Expression") && astUtils.getPrecedence(parent) >= PRECEDENCE_OF_EXPONENTIATION_EXPR && !(parent.type === "BinaryExpression" && parent.operator === "**" && parent.right === node) && !((parent.type === "CallExpression" || parent.type === "NewExpression") && parent.arguments.includes(node)) && !(parent.type === "MemberExpression" && parent.computed && parent.property === node) && !(parent.type === "ArrayExpression");
108170 return needsParens && !astUtils.isParenthesised(sourceCode, node);
108171 }
108172 /**
108173 * Optionally parenthesizes given text.
108174 * @param {string} text The text to parenthesize.
108175 * @param {boolean} shouldParenthesize If `true`, the text will be parenthesised.
108176 * @returns {string} parenthesised or unchanged text.
108177 */
108178
108179
108180 function parenthesizeIfShould(text, shouldParenthesize) {
108181 return shouldParenthesize ? "(".concat(text, ")") : text;
108182 } //------------------------------------------------------------------------------
108183 // Rule Definition
108184 //------------------------------------------------------------------------------
108185
108186
108187 module.exports = {
108188 meta: {
108189 type: "suggestion",
108190 docs: {
108191 description: "disallow the use of `Math.pow` in favor of the `**` operator",
108192 recommended: false,
108193 url: "https://eslint.org/docs/rules/prefer-exponentiation-operator"
108194 },
108195 schema: [],
108196 fixable: "code",
108197 messages: {
108198 useExponentiation: "Use the '**' operator instead of 'Math.pow'."
108199 }
108200 },
108201
108202 create(context) {
108203 const sourceCode = context.getSourceCode();
108204 /**
108205 * Reports the given node.
108206 * @param {ASTNode} node 'Math.pow()' node to report.
108207 * @returns {void}
108208 */
108209
108210 function report(node) {
108211 context.report({
108212 node,
108213 messageId: "useExponentiation",
108214
108215 fix(fixer) {
108216 if (node.arguments.length !== 2 || node.arguments.some(arg => arg.type === "SpreadElement") || sourceCode.getCommentsInside(node).length > 0) {
108217 return null;
108218 }
108219
108220 const base = node.arguments[0],
108221 exponent = node.arguments[1],
108222 baseText = sourceCode.getText(base),
108223 exponentText = sourceCode.getText(exponent),
108224 shouldParenthesizeBase = doesBaseNeedParens(base),
108225 shouldParenthesizeExponent = doesExponentNeedParens(exponent),
108226 shouldParenthesizeAll = doesExponentiationExpressionNeedParens(node, sourceCode);
108227 let prefix = "",
108228 suffix = "";
108229
108230 if (!shouldParenthesizeAll) {
108231 if (!shouldParenthesizeBase) {
108232 const firstReplacementToken = sourceCode.getFirstToken(base),
108233 tokenBefore = sourceCode.getTokenBefore(node);
108234
108235 if (tokenBefore && tokenBefore.range[1] === node.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, firstReplacementToken)) {
108236 prefix = " "; // a+Math.pow(++b, c) -> a+ ++b**c
108237 }
108238 }
108239
108240 if (!shouldParenthesizeExponent) {
108241 const lastReplacementToken = sourceCode.getLastToken(exponent),
108242 tokenAfter = sourceCode.getTokenAfter(node);
108243
108244 if (tokenAfter && node.range[1] === tokenAfter.range[0] && !astUtils.canTokensBeAdjacent(lastReplacementToken, tokenAfter)) {
108245 suffix = " "; // Math.pow(a, b)in c -> a**b in c
108246 }
108247 }
108248 }
108249
108250 const baseReplacement = parenthesizeIfShould(baseText, shouldParenthesizeBase),
108251 exponentReplacement = parenthesizeIfShould(exponentText, shouldParenthesizeExponent),
108252 replacement = parenthesizeIfShould("".concat(baseReplacement, "**").concat(exponentReplacement), shouldParenthesizeAll);
108253 return fixer.replaceText(node, "".concat(prefix).concat(replacement).concat(suffix));
108254 }
108255
108256 });
108257 }
108258
108259 return {
108260 Program() {
108261 const scope = context.getScope();
108262 const tracker = new ReferenceTracker(scope);
108263 const trackMap = {
108264 Math: {
108265 pow: {
108266 [CALL]: true
108267 }
108268 }
108269 };
108270
108271 for (const {
108272 node
108273 } of tracker.iterateGlobalReferences(trackMap)) {
108274 report(node);
108275 }
108276 }
108277
108278 };
108279 }
108280
108281 };
108282
108283 /***/ }),
108284 /* 805 */
108285 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
108286
108287 "use strict";
108288 /**
108289 * @fileoverview Rule to enforce requiring named capture groups in regular expression.
108290 * @author Pig Fang <https://github.com/g-plane>
108291 */
108292 //------------------------------------------------------------------------------
108293 // Requirements
108294 //------------------------------------------------------------------------------
108295
108296 const {
108297 CALL,
108298 CONSTRUCT,
108299 ReferenceTracker,
108300 getStringIfConstant
108301 } = __webpack_require__(501);
108302
108303 const regexpp = __webpack_require__(651); //------------------------------------------------------------------------------
108304 // Helpers
108305 //------------------------------------------------------------------------------
108306
108307
108308 const parser = new regexpp.RegExpParser(); //------------------------------------------------------------------------------
108309 // Rule Definition
108310 //------------------------------------------------------------------------------
108311
108312 module.exports = {
108313 meta: {
108314 type: "suggestion",
108315 docs: {
108316 description: "enforce using named capture group in regular expression",
108317 recommended: false,
108318 url: "https://eslint.org/docs/rules/prefer-named-capture-group"
108319 },
108320 schema: [],
108321 messages: {
108322 required: "Capture group '{{group}}' should be converted to a named or non-capturing group."
108323 }
108324 },
108325
108326 create(context) {
108327 /**
108328 * Function to check regular expression.
108329 * @param {string} pattern The regular expression pattern to be check.
108330 * @param {ASTNode} node AST node which contains regular expression.
108331 * @param {boolean} uFlag Flag indicates whether unicode mode is enabled or not.
108332 * @returns {void}
108333 */
108334 function checkRegex(pattern, node, uFlag) {
108335 let ast;
108336
108337 try {
108338 ast = parser.parsePattern(pattern, 0, pattern.length, uFlag);
108339 } catch {
108340 // ignore regex syntax errors
108341 return;
108342 }
108343
108344 regexpp.visitRegExpAST(ast, {
108345 onCapturingGroupEnter(group) {
108346 if (!group.name) {
108347 context.report({
108348 node,
108349 messageId: "required",
108350 data: {
108351 group: group.raw
108352 }
108353 });
108354 }
108355 }
108356
108357 });
108358 }
108359
108360 return {
108361 Literal(node) {
108362 if (node.regex) {
108363 checkRegex(node.regex.pattern, node, node.regex.flags.includes("u"));
108364 }
108365 },
108366
108367 Program() {
108368 const scope = context.getScope();
108369 const tracker = new ReferenceTracker(scope);
108370 const traceMap = {
108371 RegExp: {
108372 [CALL]: true,
108373 [CONSTRUCT]: true
108374 }
108375 };
108376
108377 for (const {
108378 node
108379 } of tracker.iterateGlobalReferences(traceMap)) {
108380 const regex = getStringIfConstant(node.arguments[0]);
108381 const flags = getStringIfConstant(node.arguments[1]);
108382
108383 if (regex) {
108384 checkRegex(regex, node, flags && flags.includes("u"));
108385 }
108386 }
108387 }
108388
108389 };
108390 }
108391
108392 };
108393
108394 /***/ }),
108395 /* 806 */
108396 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
108397
108398 "use strict";
108399 /**
108400 * @fileoverview Rule to disallow `parseInt()` in favor of binary, octal, and hexadecimal literals
108401 * @author Annie Zhang, Henry Zhu
108402 */
108403 //------------------------------------------------------------------------------
108404 // Requirements
108405 //------------------------------------------------------------------------------
108406
108407 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
108408 // Helpers
108409 //------------------------------------------------------------------------------
108410
108411
108412 const radixMap = new Map([[2, {
108413 system: "binary",
108414 literalPrefix: "0b"
108415 }], [8, {
108416 system: "octal",
108417 literalPrefix: "0o"
108418 }], [16, {
108419 system: "hexadecimal",
108420 literalPrefix: "0x"
108421 }]]);
108422 /**
108423 * Checks to see if a CallExpression's callee node is `parseInt` or
108424 * `Number.parseInt`.
108425 * @param {ASTNode} calleeNode The callee node to evaluate.
108426 * @returns {boolean} True if the callee is `parseInt` or `Number.parseInt`,
108427 * false otherwise.
108428 */
108429
108430 function isParseInt(calleeNode) {
108431 return astUtils.isSpecificId(calleeNode, "parseInt") || astUtils.isSpecificMemberAccess(calleeNode, "Number", "parseInt");
108432 } //------------------------------------------------------------------------------
108433 // Rule Definition
108434 //------------------------------------------------------------------------------
108435
108436
108437 module.exports = {
108438 meta: {
108439 type: "suggestion",
108440 docs: {
108441 description: "disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals",
108442 recommended: false,
108443 url: "https://eslint.org/docs/rules/prefer-numeric-literals"
108444 },
108445 schema: [],
108446 messages: {
108447 useLiteral: "Use {{system}} literals instead of {{functionName}}()."
108448 },
108449 fixable: "code"
108450 },
108451
108452 create(context) {
108453 const sourceCode = context.getSourceCode(); //----------------------------------------------------------------------
108454 // Public
108455 //----------------------------------------------------------------------
108456
108457 return {
108458 "CallExpression[arguments.length=2]"(node) {
108459 const [strNode, radixNode] = node.arguments,
108460 str = astUtils.getStaticStringValue(strNode),
108461 radix = radixNode.value;
108462
108463 if (str !== null && astUtils.isStringLiteral(strNode) && radixNode.type === "Literal" && typeof radix === "number" && radixMap.has(radix) && isParseInt(node.callee)) {
108464 const {
108465 system,
108466 literalPrefix
108467 } = radixMap.get(radix);
108468 context.report({
108469 node,
108470 messageId: "useLiteral",
108471 data: {
108472 system,
108473 functionName: sourceCode.getText(node.callee)
108474 },
108475
108476 fix(fixer) {
108477 if (sourceCode.getCommentsInside(node).length) {
108478 return null;
108479 }
108480
108481 const replacement = "".concat(literalPrefix).concat(str);
108482
108483 if (+replacement !== parseInt(str, radix)) {
108484 /*
108485 * If the newly-produced literal would be invalid, (e.g. 0b1234),
108486 * or it would yield an incorrect parseInt result for some other reason, don't make a fix.
108487 *
108488 * If `str` had numeric separators, `+replacement` will evaluate to `NaN` because unary `+`
108489 * per the specification doesn't support numeric separators. Thus, the above condition will be `true`
108490 * (`NaN !== anything` is always `true`) regardless of the `parseInt(str, radix)` value.
108491 * Consequently, no autofixes will be made. This is correct behavior because `parseInt` also
108492 * doesn't support numeric separators, but it does parse part of the string before the first `_`,
108493 * so the autofix would be invalid:
108494 *
108495 * parseInt("1_1", 2) // === 1
108496 * 0b1_1 // === 3
108497 */
108498 return null;
108499 }
108500
108501 const tokenBefore = sourceCode.getTokenBefore(node),
108502 tokenAfter = sourceCode.getTokenAfter(node);
108503 let prefix = "",
108504 suffix = "";
108505
108506 if (tokenBefore && tokenBefore.range[1] === node.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, replacement)) {
108507 prefix = " ";
108508 }
108509
108510 if (tokenAfter && node.range[1] === tokenAfter.range[0] && !astUtils.canTokensBeAdjacent(replacement, tokenAfter)) {
108511 suffix = " ";
108512 }
108513
108514 return fixer.replaceText(node, "".concat(prefix).concat(replacement).concat(suffix));
108515 }
108516
108517 });
108518 }
108519 }
108520
108521 };
108522 }
108523
108524 };
108525
108526 /***/ }),
108527 /* 807 */
108528 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
108529
108530 "use strict";
108531 /**
108532 * @fileoverview Prefers object spread property over Object.assign
108533 * @author Sharmila Jesupaul
108534 * See LICENSE file in root directory for full license.
108535 */
108536
108537
108538 const {
108539 CALL,
108540 ReferenceTracker
108541 } = __webpack_require__(501);
108542
108543 const {
108544 isCommaToken,
108545 isOpeningParenToken,
108546 isClosingParenToken,
108547 isParenthesised
108548 } = __webpack_require__(548);
108549
108550 const ANY_SPACE = /\s/u;
108551 /**
108552 * Helper that checks if the Object.assign call has array spread
108553 * @param {ASTNode} node The node that the rule warns on
108554 * @returns {boolean} - Returns true if the Object.assign call has array spread
108555 */
108556
108557 function hasArraySpread(node) {
108558 return node.arguments.some(arg => arg.type === "SpreadElement");
108559 }
108560 /**
108561 * Determines whether the given node is an accessor property (getter/setter).
108562 * @param {ASTNode} node Node to check.
108563 * @returns {boolean} `true` if the node is a getter or a setter.
108564 */
108565
108566
108567 function isAccessorProperty(node) {
108568 return node.type === "Property" && (node.kind === "get" || node.kind === "set");
108569 }
108570 /**
108571 * Determines whether the given object expression node has accessor properties (getters/setters).
108572 * @param {ASTNode} node `ObjectExpression` node to check.
108573 * @returns {boolean} `true` if the node has at least one getter/setter.
108574 */
108575
108576
108577 function hasAccessors(node) {
108578 return node.properties.some(isAccessorProperty);
108579 }
108580 /**
108581 * Determines whether the given call expression node has object expression arguments with accessor properties (getters/setters).
108582 * @param {ASTNode} node `CallExpression` node to check.
108583 * @returns {boolean} `true` if the node has at least one argument that is an object expression with at least one getter/setter.
108584 */
108585
108586
108587 function hasArgumentsWithAccessors(node) {
108588 return node.arguments.filter(arg => arg.type === "ObjectExpression").some(hasAccessors);
108589 }
108590 /**
108591 * Helper that checks if the node needs parentheses to be valid JS.
108592 * The default is to wrap the node in parentheses to avoid parsing errors.
108593 * @param {ASTNode} node The node that the rule warns on
108594 * @param {Object} sourceCode in context sourcecode object
108595 * @returns {boolean} - Returns true if the node needs parentheses
108596 */
108597
108598
108599 function needsParens(node, sourceCode) {
108600 const parent = node.parent;
108601
108602 switch (parent.type) {
108603 case "VariableDeclarator":
108604 case "ArrayExpression":
108605 case "ReturnStatement":
108606 case "CallExpression":
108607 case "Property":
108608 return false;
108609
108610 case "AssignmentExpression":
108611 return parent.left === node && !isParenthesised(sourceCode, node);
108612
108613 default:
108614 return !isParenthesised(sourceCode, node);
108615 }
108616 }
108617 /**
108618 * Determines if an argument needs parentheses. The default is to not add parens.
108619 * @param {ASTNode} node The node to be checked.
108620 * @param {Object} sourceCode in context sourcecode object
108621 * @returns {boolean} True if the node needs parentheses
108622 */
108623
108624
108625 function argNeedsParens(node, sourceCode) {
108626 switch (node.type) {
108627 case "AssignmentExpression":
108628 case "ArrowFunctionExpression":
108629 case "ConditionalExpression":
108630 return !isParenthesised(sourceCode, node);
108631
108632 default:
108633 return false;
108634 }
108635 }
108636 /**
108637 * Get the parenthesis tokens of a given ObjectExpression node.
108638 * This includes the braces of the object literal and enclosing parentheses.
108639 * @param {ASTNode} node The node to get.
108640 * @param {Token} leftArgumentListParen The opening paren token of the argument list.
108641 * @param {SourceCode} sourceCode The source code object to get tokens.
108642 * @returns {Token[]} The parenthesis tokens of the node. This is sorted by the location.
108643 */
108644
108645
108646 function getParenTokens(node, leftArgumentListParen, sourceCode) {
108647 const parens = [sourceCode.getFirstToken(node), sourceCode.getLastToken(node)];
108648 let leftNext = sourceCode.getTokenBefore(node);
108649 let rightNext = sourceCode.getTokenAfter(node); // Note: don't include the parens of the argument list.
108650
108651 while (leftNext && rightNext && leftNext.range[0] > leftArgumentListParen.range[0] && isOpeningParenToken(leftNext) && isClosingParenToken(rightNext)) {
108652 parens.push(leftNext, rightNext);
108653 leftNext = sourceCode.getTokenBefore(leftNext);
108654 rightNext = sourceCode.getTokenAfter(rightNext);
108655 }
108656
108657 return parens.sort((a, b) => a.range[0] - b.range[0]);
108658 }
108659 /**
108660 * Get the range of a given token and around whitespaces.
108661 * @param {Token} token The token to get range.
108662 * @param {SourceCode} sourceCode The source code object to get tokens.
108663 * @returns {number} The end of the range of the token and around whitespaces.
108664 */
108665
108666
108667 function getStartWithSpaces(token, sourceCode) {
108668 const text = sourceCode.text;
108669 let start = token.range[0]; // If the previous token is a line comment then skip this step to avoid commenting this token out.
108670
108671 {
108672 const prevToken = sourceCode.getTokenBefore(token, {
108673 includeComments: true
108674 });
108675
108676 if (prevToken && prevToken.type === "Line") {
108677 return start;
108678 }
108679 } // Detect spaces before the token.
108680
108681 while (ANY_SPACE.test(text[start - 1] || "")) {
108682 start -= 1;
108683 }
108684
108685 return start;
108686 }
108687 /**
108688 * Get the range of a given token and around whitespaces.
108689 * @param {Token} token The token to get range.
108690 * @param {SourceCode} sourceCode The source code object to get tokens.
108691 * @returns {number} The start of the range of the token and around whitespaces.
108692 */
108693
108694
108695 function getEndWithSpaces(token, sourceCode) {
108696 const text = sourceCode.text;
108697 let end = token.range[1]; // Detect spaces after the token.
108698
108699 while (ANY_SPACE.test(text[end] || "")) {
108700 end += 1;
108701 }
108702
108703 return end;
108704 }
108705 /**
108706 * Autofixes the Object.assign call to use an object spread instead.
108707 * @param {ASTNode|null} node The node that the rule warns on, i.e. the Object.assign call
108708 * @param {string} sourceCode sourceCode of the Object.assign call
108709 * @returns {Function} autofixer - replaces the Object.assign with a spread object.
108710 */
108711
108712
108713 function defineFixer(node, sourceCode) {
108714 return function* (fixer) {
108715 const leftParen = sourceCode.getTokenAfter(node.callee, isOpeningParenToken);
108716 const rightParen = sourceCode.getLastToken(node); // Remove everything before the opening paren: callee `Object.assign`, type arguments, and whitespace between the callee and the paren.
108717
108718 yield fixer.removeRange([node.range[0], leftParen.range[0]]); // Replace the parens of argument list to braces.
108719
108720 if (needsParens(node, sourceCode)) {
108721 yield fixer.replaceText(leftParen, "({");
108722 yield fixer.replaceText(rightParen, "})");
108723 } else {
108724 yield fixer.replaceText(leftParen, "{");
108725 yield fixer.replaceText(rightParen, "}");
108726 } // Process arguments.
108727
108728
108729 for (const argNode of node.arguments) {
108730 const innerParens = getParenTokens(argNode, leftParen, sourceCode);
108731 const left = innerParens.shift();
108732 const right = innerParens.pop();
108733
108734 if (argNode.type === "ObjectExpression") {
108735 const maybeTrailingComma = sourceCode.getLastToken(argNode, 1);
108736 const maybeArgumentComma = sourceCode.getTokenAfter(right);
108737 /*
108738 * Make bare this object literal.
108739 * And remove spaces inside of the braces for better formatting.
108740 */
108741
108742 for (const innerParen of innerParens) {
108743 yield fixer.remove(innerParen);
108744 }
108745
108746 const leftRange = [left.range[0], getEndWithSpaces(left, sourceCode)];
108747 const rightRange = [Math.max(getStartWithSpaces(right, sourceCode), leftRange[1]), // Ensure ranges don't overlap
108748 right.range[1]];
108749 yield fixer.removeRange(leftRange);
108750 yield fixer.removeRange(rightRange); // Remove the comma of this argument if it's duplication.
108751
108752 if ((argNode.properties.length === 0 || isCommaToken(maybeTrailingComma)) && isCommaToken(maybeArgumentComma)) {
108753 yield fixer.remove(maybeArgumentComma);
108754 }
108755 } else {
108756 // Make spread.
108757 if (argNeedsParens(argNode, sourceCode)) {
108758 yield fixer.insertTextBefore(left, "...(");
108759 yield fixer.insertTextAfter(right, ")");
108760 } else {
108761 yield fixer.insertTextBefore(left, "...");
108762 }
108763 }
108764 }
108765 };
108766 }
108767
108768 module.exports = {
108769 meta: {
108770 type: "suggestion",
108771 docs: {
108772 description: "disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.",
108773 recommended: false,
108774 url: "https://eslint.org/docs/rules/prefer-object-spread"
108775 },
108776 schema: [],
108777 fixable: "code",
108778 messages: {
108779 useSpreadMessage: "Use an object spread instead of `Object.assign` eg: `{ ...foo }`.",
108780 useLiteralMessage: "Use an object literal instead of `Object.assign`. eg: `{ foo: bar }`."
108781 }
108782 },
108783
108784 create(context) {
108785 const sourceCode = context.getSourceCode();
108786 return {
108787 Program() {
108788 const scope = context.getScope();
108789 const tracker = new ReferenceTracker(scope);
108790 const trackMap = {
108791 Object: {
108792 assign: {
108793 [CALL]: true
108794 }
108795 }
108796 }; // Iterate all calls of `Object.assign` (only of the global variable `Object`).
108797
108798 for (const {
108799 node
108800 } of tracker.iterateGlobalReferences(trackMap)) {
108801 if (node.arguments.length >= 1 && node.arguments[0].type === "ObjectExpression" && !hasArraySpread(node) && !(node.arguments.length > 1 && hasArgumentsWithAccessors(node))) {
108802 const messageId = node.arguments.length === 1 ? "useLiteralMessage" : "useSpreadMessage";
108803 const fix = defineFixer(node, sourceCode);
108804 context.report({
108805 node,
108806 messageId,
108807 fix
108808 });
108809 }
108810 }
108811 }
108812
108813 };
108814 }
108815
108816 };
108817
108818 /***/ }),
108819 /* 808 */
108820 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
108821
108822 "use strict";
108823 /**
108824 * @fileoverview restrict values that can be used as Promise rejection reasons
108825 * @author Teddy Katz
108826 */
108827
108828
108829 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
108830 // Rule Definition
108831 //------------------------------------------------------------------------------
108832
108833
108834 module.exports = {
108835 meta: {
108836 type: "suggestion",
108837 docs: {
108838 description: "require using Error objects as Promise rejection reasons",
108839 recommended: false,
108840 url: "https://eslint.org/docs/rules/prefer-promise-reject-errors"
108841 },
108842 fixable: null,
108843 schema: [{
108844 type: "object",
108845 properties: {
108846 allowEmptyReject: {
108847 type: "boolean",
108848 default: false
108849 }
108850 },
108851 additionalProperties: false
108852 }],
108853 messages: {
108854 rejectAnError: "Expected the Promise rejection reason to be an Error."
108855 }
108856 },
108857
108858 create(context) {
108859 const ALLOW_EMPTY_REJECT = context.options.length && context.options[0].allowEmptyReject; //----------------------------------------------------------------------
108860 // Helpers
108861 //----------------------------------------------------------------------
108862
108863 /**
108864 * Checks the argument of a reject() or Promise.reject() CallExpression, and reports it if it can't be an Error
108865 * @param {ASTNode} callExpression A CallExpression node which is used to reject a Promise
108866 * @returns {void}
108867 */
108868
108869 function checkRejectCall(callExpression) {
108870 if (!callExpression.arguments.length && ALLOW_EMPTY_REJECT) {
108871 return;
108872 }
108873
108874 if (!callExpression.arguments.length || !astUtils.couldBeError(callExpression.arguments[0]) || callExpression.arguments[0].type === "Identifier" && callExpression.arguments[0].name === "undefined") {
108875 context.report({
108876 node: callExpression,
108877 messageId: "rejectAnError"
108878 });
108879 }
108880 }
108881 /**
108882 * Determines whether a function call is a Promise.reject() call
108883 * @param {ASTNode} node A CallExpression node
108884 * @returns {boolean} `true` if the call is a Promise.reject() call
108885 */
108886
108887
108888 function isPromiseRejectCall(node) {
108889 return astUtils.isSpecificMemberAccess(node.callee, "Promise", "reject");
108890 } //----------------------------------------------------------------------
108891 // Public
108892 //----------------------------------------------------------------------
108893
108894
108895 return {
108896 // Check `Promise.reject(value)` calls.
108897 CallExpression(node) {
108898 if (isPromiseRejectCall(node)) {
108899 checkRejectCall(node);
108900 }
108901 },
108902
108903 /*
108904 * Check for `new Promise((resolve, reject) => {})`, and check for reject() calls.
108905 * This function is run on "NewExpression:exit" instead of "NewExpression" to ensure that
108906 * the nodes in the expression already have the `parent` property.
108907 */
108908 "NewExpression:exit"(node) {
108909 if (node.callee.type === "Identifier" && node.callee.name === "Promise" && node.arguments.length && astUtils.isFunction(node.arguments[0]) && node.arguments[0].params.length > 1 && node.arguments[0].params[1].type === "Identifier") {
108910 context.getDeclaredVariables(node.arguments[0])
108911 /*
108912 * Find the first variable that matches the second parameter's name.
108913 * If the first parameter has the same name as the second parameter, then the variable will actually
108914 * be "declared" when the first parameter is evaluated, but then it will be immediately overwritten
108915 * by the second parameter. It's not possible for an expression with the variable to be evaluated before
108916 * the variable is overwritten, because functions with duplicate parameters cannot have destructuring or
108917 * default assignments in their parameter lists. Therefore, it's not necessary to explicitly account for
108918 * this case.
108919 */
108920 .find(variable => variable.name === node.arguments[0].params[1].name) // Get the references to that variable.
108921 .references // Only check the references that read the parameter's value.
108922 .filter(ref => ref.isRead()) // Only check the references that are used as the callee in a function call, e.g. `reject(foo)`.
108923 .filter(ref => ref.identifier.parent.type === "CallExpression" && ref.identifier === ref.identifier.parent.callee) // Check the argument of the function call to determine whether it's an Error.
108924 .forEach(ref => checkRejectCall(ref.identifier.parent));
108925 }
108926 }
108927
108928 };
108929 }
108930
108931 };
108932
108933 /***/ }),
108934 /* 809 */
108935 /***/ ((module) => {
108936
108937 "use strict";
108938 /**
108939 * @fileoverview Rule to suggest using "Reflect" api over Function/Object methods
108940 * @author Keith Cirkel <http://keithcirkel.co.uk>
108941 * @deprecated in ESLint v3.9.0
108942 */
108943 //------------------------------------------------------------------------------
108944 // Rule Definition
108945 //------------------------------------------------------------------------------
108946
108947 module.exports = {
108948 meta: {
108949 type: "suggestion",
108950 docs: {
108951 description: "require `Reflect` methods where applicable",
108952 recommended: false,
108953 url: "https://eslint.org/docs/rules/prefer-reflect"
108954 },
108955 deprecated: true,
108956 replacedBy: [],
108957 schema: [{
108958 type: "object",
108959 properties: {
108960 exceptions: {
108961 type: "array",
108962 items: {
108963 enum: ["apply", "call", "delete", "defineProperty", "getOwnPropertyDescriptor", "getPrototypeOf", "setPrototypeOf", "isExtensible", "getOwnPropertyNames", "preventExtensions"]
108964 },
108965 uniqueItems: true
108966 }
108967 },
108968 additionalProperties: false
108969 }],
108970 messages: {
108971 preferReflect: "Avoid using {{existing}}, instead use {{substitute}}."
108972 }
108973 },
108974
108975 create(context) {
108976 const existingNames = {
108977 apply: "Function.prototype.apply",
108978 call: "Function.prototype.call",
108979 defineProperty: "Object.defineProperty",
108980 getOwnPropertyDescriptor: "Object.getOwnPropertyDescriptor",
108981 getPrototypeOf: "Object.getPrototypeOf",
108982 setPrototypeOf: "Object.setPrototypeOf",
108983 isExtensible: "Object.isExtensible",
108984 getOwnPropertyNames: "Object.getOwnPropertyNames",
108985 preventExtensions: "Object.preventExtensions"
108986 };
108987 const reflectSubstitutes = {
108988 apply: "Reflect.apply",
108989 call: "Reflect.apply",
108990 defineProperty: "Reflect.defineProperty",
108991 getOwnPropertyDescriptor: "Reflect.getOwnPropertyDescriptor",
108992 getPrototypeOf: "Reflect.getPrototypeOf",
108993 setPrototypeOf: "Reflect.setPrototypeOf",
108994 isExtensible: "Reflect.isExtensible",
108995 getOwnPropertyNames: "Reflect.getOwnPropertyNames",
108996 preventExtensions: "Reflect.preventExtensions"
108997 };
108998 const exceptions = (context.options[0] || {}).exceptions || [];
108999 /**
109000 * Reports the Reflect violation based on the `existing` and `substitute`
109001 * @param {Object} node The node that violates the rule.
109002 * @param {string} existing The existing method name that has been used.
109003 * @param {string} substitute The Reflect substitute that should be used.
109004 * @returns {void}
109005 */
109006
109007 function report(node, existing, substitute) {
109008 context.report({
109009 node,
109010 messageId: "preferReflect",
109011 data: {
109012 existing,
109013 substitute
109014 }
109015 });
109016 }
109017
109018 return {
109019 CallExpression(node) {
109020 const methodName = (node.callee.property || {}).name;
109021 const isReflectCall = (node.callee.object || {}).name === "Reflect";
109022 const hasReflectSubstitute = Object.prototype.hasOwnProperty.call(reflectSubstitutes, methodName);
109023 const userConfiguredException = exceptions.indexOf(methodName) !== -1;
109024
109025 if (hasReflectSubstitute && !isReflectCall && !userConfiguredException) {
109026 report(node, existingNames[methodName], reflectSubstitutes[methodName]);
109027 }
109028 },
109029
109030 UnaryExpression(node) {
109031 const isDeleteOperator = node.operator === "delete";
109032 const targetsIdentifier = node.argument.type === "Identifier";
109033 const userConfiguredException = exceptions.indexOf("delete") !== -1;
109034
109035 if (isDeleteOperator && !targetsIdentifier && !userConfiguredException) {
109036 report(node, "the delete keyword", "Reflect.deleteProperty");
109037 }
109038 }
109039
109040 };
109041 }
109042
109043 };
109044
109045 /***/ }),
109046 /* 810 */
109047 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
109048
109049 "use strict";
109050 /**
109051 * @fileoverview Rule to disallow use of the `RegExp` constructor in favor of regular expression literals
109052 * @author Milos Djermanovic
109053 */
109054 //------------------------------------------------------------------------------
109055 // Requirements
109056 //------------------------------------------------------------------------------
109057
109058 const astUtils = __webpack_require__(548);
109059
109060 const {
109061 CALL,
109062 CONSTRUCT,
109063 ReferenceTracker,
109064 findVariable
109065 } = __webpack_require__(501); //------------------------------------------------------------------------------
109066 // Helpers
109067 //------------------------------------------------------------------------------
109068
109069 /**
109070 * Determines whether the given node is a string literal.
109071 * @param {ASTNode} node Node to check.
109072 * @returns {boolean} True if the node is a string literal.
109073 */
109074
109075
109076 function isStringLiteral(node) {
109077 return node.type === "Literal" && typeof node.value === "string";
109078 }
109079 /**
109080 * Determines whether the given node is a regex literal.
109081 * @param {ASTNode} node Node to check.
109082 * @returns {boolean} True if the node is a regex literal.
109083 */
109084
109085
109086 function isRegexLiteral(node) {
109087 return node.type === "Literal" && Object.prototype.hasOwnProperty.call(node, "regex");
109088 }
109089 /**
109090 * Determines whether the given node is a template literal without expressions.
109091 * @param {ASTNode} node Node to check.
109092 * @returns {boolean} True if the node is a template literal without expressions.
109093 */
109094
109095
109096 function isStaticTemplateLiteral(node) {
109097 return node.type === "TemplateLiteral" && node.expressions.length === 0;
109098 } //------------------------------------------------------------------------------
109099 // Rule Definition
109100 //------------------------------------------------------------------------------
109101
109102
109103 module.exports = {
109104 meta: {
109105 type: "suggestion",
109106 docs: {
109107 description: "disallow use of the `RegExp` constructor in favor of regular expression literals",
109108 recommended: false,
109109 url: "https://eslint.org/docs/rules/prefer-regex-literals"
109110 },
109111 schema: [{
109112 type: "object",
109113 properties: {
109114 disallowRedundantWrapping: {
109115 type: "boolean",
109116 default: false
109117 }
109118 },
109119 additionalProperties: false
109120 }],
109121 messages: {
109122 unexpectedRegExp: "Use a regular expression literal instead of the 'RegExp' constructor.",
109123 unexpectedRedundantRegExp: "Regular expression literal is unnecessarily wrapped within a 'RegExp' constructor.",
109124 unexpectedRedundantRegExpWithFlags: "Use regular expression literal with flags instead of the 'RegExp' constructor."
109125 }
109126 },
109127
109128 create(context) {
109129 const [{
109130 disallowRedundantWrapping = false
109131 } = {}] = context.options;
109132 /**
109133 * Determines whether the given identifier node is a reference to a global variable.
109134 * @param {ASTNode} node `Identifier` node to check.
109135 * @returns {boolean} True if the identifier is a reference to a global variable.
109136 */
109137
109138 function isGlobalReference(node) {
109139 const scope = context.getScope();
109140 const variable = findVariable(scope, node);
109141 return variable !== null && variable.scope.type === "global" && variable.defs.length === 0;
109142 }
109143 /**
109144 * Determines whether the given node is a String.raw`` tagged template expression
109145 * with a static template literal.
109146 * @param {ASTNode} node Node to check.
109147 * @returns {boolean} True if the node is String.raw`` with a static template.
109148 */
109149
109150
109151 function isStringRawTaggedStaticTemplateLiteral(node) {
109152 return node.type === "TaggedTemplateExpression" && astUtils.isSpecificMemberAccess(node.tag, "String", "raw") && isGlobalReference(astUtils.skipChainExpression(node.tag).object) && isStaticTemplateLiteral(node.quasi);
109153 }
109154 /**
109155 * Determines whether the given node is considered to be a static string by the logic of this rule.
109156 * @param {ASTNode} node Node to check.
109157 * @returns {boolean} True if the node is a static string.
109158 */
109159
109160
109161 function isStaticString(node) {
109162 return isStringLiteral(node) || isStaticTemplateLiteral(node) || isStringRawTaggedStaticTemplateLiteral(node);
109163 }
109164 /**
109165 * Determines whether the relevant arguments of the given are all static string literals.
109166 * @param {ASTNode} node Node to check.
109167 * @returns {boolean} True if all arguments are static strings.
109168 */
109169
109170
109171 function hasOnlyStaticStringArguments(node) {
109172 const args = node.arguments;
109173
109174 if ((args.length === 1 || args.length === 2) && args.every(isStaticString)) {
109175 return true;
109176 }
109177
109178 return false;
109179 }
109180 /**
109181 * Determines whether the arguments of the given node indicate that a regex literal is unnecessarily wrapped.
109182 * @param {ASTNode} node Node to check.
109183 * @returns {boolean} True if the node already contains a regex literal argument.
109184 */
109185
109186
109187 function isUnnecessarilyWrappedRegexLiteral(node) {
109188 const args = node.arguments;
109189
109190 if (args.length === 1 && isRegexLiteral(args[0])) {
109191 return true;
109192 }
109193
109194 if (args.length === 2 && isRegexLiteral(args[0]) && isStaticString(args[1])) {
109195 return true;
109196 }
109197
109198 return false;
109199 }
109200
109201 return {
109202 Program() {
109203 const scope = context.getScope();
109204 const tracker = new ReferenceTracker(scope);
109205 const traceMap = {
109206 RegExp: {
109207 [CALL]: true,
109208 [CONSTRUCT]: true
109209 }
109210 };
109211
109212 for (const {
109213 node
109214 } of tracker.iterateGlobalReferences(traceMap)) {
109215 if (disallowRedundantWrapping && isUnnecessarilyWrappedRegexLiteral(node)) {
109216 if (node.arguments.length === 2) {
109217 context.report({
109218 node,
109219 messageId: "unexpectedRedundantRegExpWithFlags"
109220 });
109221 } else {
109222 context.report({
109223 node,
109224 messageId: "unexpectedRedundantRegExp"
109225 });
109226 }
109227 } else if (hasOnlyStaticStringArguments(node)) {
109228 context.report({
109229 node,
109230 messageId: "unexpectedRegExp"
109231 });
109232 }
109233 }
109234 }
109235
109236 };
109237 }
109238
109239 };
109240
109241 /***/ }),
109242 /* 811 */
109243 /***/ ((module) => {
109244
109245 "use strict";
109246 /**
109247 * @fileoverview Rule to
109248 * @author Toru Nagashima
109249 */
109250 //------------------------------------------------------------------------------
109251 // Helpers
109252 //------------------------------------------------------------------------------
109253
109254 /**
109255 * Gets the variable object of `arguments` which is defined implicitly.
109256 * @param {eslint-scope.Scope} scope A scope to get.
109257 * @returns {eslint-scope.Variable} The found variable object.
109258 */
109259
109260 function getVariableOfArguments(scope) {
109261 const variables = scope.variables;
109262
109263 for (let i = 0; i < variables.length; ++i) {
109264 const variable = variables[i];
109265
109266 if (variable.name === "arguments") {
109267 /*
109268 * If there was a parameter which is named "arguments", the implicit "arguments" is not defined.
109269 * So does fast return with null.
109270 */
109271 return variable.identifiers.length === 0 ? variable : null;
109272 }
109273 }
109274 /* istanbul ignore next : unreachable */
109275
109276
109277 return null;
109278 }
109279 /**
109280 * Checks if the given reference is not normal member access.
109281 *
109282 * - arguments .... true // not member access
109283 * - arguments[i] .... true // computed member access
109284 * - arguments[0] .... true // computed member access
109285 * - arguments.length .... false // normal member access
109286 * @param {eslint-scope.Reference} reference The reference to check.
109287 * @returns {boolean} `true` if the reference is not normal member access.
109288 */
109289
109290
109291 function isNotNormalMemberAccess(reference) {
109292 const id = reference.identifier;
109293 const parent = id.parent;
109294 return !(parent.type === "MemberExpression" && parent.object === id && !parent.computed);
109295 } //------------------------------------------------------------------------------
109296 // Rule Definition
109297 //------------------------------------------------------------------------------
109298
109299
109300 module.exports = {
109301 meta: {
109302 type: "suggestion",
109303 docs: {
109304 description: "require rest parameters instead of `arguments`",
109305 recommended: false,
109306 url: "https://eslint.org/docs/rules/prefer-rest-params"
109307 },
109308 schema: [],
109309 messages: {
109310 preferRestParams: "Use the rest parameters instead of 'arguments'."
109311 }
109312 },
109313
109314 create(context) {
109315 /**
109316 * Reports a given reference.
109317 * @param {eslint-scope.Reference} reference A reference to report.
109318 * @returns {void}
109319 */
109320 function report(reference) {
109321 context.report({
109322 node: reference.identifier,
109323 loc: reference.identifier.loc,
109324 messageId: "preferRestParams"
109325 });
109326 }
109327 /**
109328 * Reports references of the implicit `arguments` variable if exist.
109329 * @returns {void}
109330 */
109331
109332
109333 function checkForArguments() {
109334 const argumentsVar = getVariableOfArguments(context.getScope());
109335
109336 if (argumentsVar) {
109337 argumentsVar.references.filter(isNotNormalMemberAccess).forEach(report);
109338 }
109339 }
109340
109341 return {
109342 "FunctionDeclaration:exit": checkForArguments,
109343 "FunctionExpression:exit": checkForArguments
109344 };
109345 }
109346
109347 };
109348
109349 /***/ }),
109350 /* 812 */
109351 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
109352
109353 "use strict";
109354 /**
109355 * @fileoverview A rule to suggest using of the spread operator instead of `.apply()`.
109356 * @author Toru Nagashima
109357 */
109358
109359
109360 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
109361 // Helpers
109362 //------------------------------------------------------------------------------
109363
109364 /**
109365 * Checks whether or not a node is a `.apply()` for variadic.
109366 * @param {ASTNode} node A CallExpression node to check.
109367 * @returns {boolean} Whether or not the node is a `.apply()` for variadic.
109368 */
109369
109370
109371 function isVariadicApplyCalling(node) {
109372 return astUtils.isSpecificMemberAccess(node.callee, null, "apply") && node.arguments.length === 2 && node.arguments[1].type !== "ArrayExpression" && node.arguments[1].type !== "SpreadElement";
109373 }
109374 /**
109375 * Checks whether or not `thisArg` is not changed by `.apply()`.
109376 * @param {ASTNode|null} expectedThis The node that is the owner of the applied function.
109377 * @param {ASTNode} thisArg The node that is given to the first argument of the `.apply()`.
109378 * @param {RuleContext} context The ESLint rule context object.
109379 * @returns {boolean} Whether or not `thisArg` is not changed by `.apply()`.
109380 */
109381
109382
109383 function isValidThisArg(expectedThis, thisArg, context) {
109384 if (!expectedThis) {
109385 return astUtils.isNullOrUndefined(thisArg);
109386 }
109387
109388 return astUtils.equalTokens(expectedThis, thisArg, context);
109389 } //------------------------------------------------------------------------------
109390 // Rule Definition
109391 //------------------------------------------------------------------------------
109392
109393
109394 module.exports = {
109395 meta: {
109396 type: "suggestion",
109397 docs: {
109398 description: "require spread operators instead of `.apply()`",
109399 recommended: false,
109400 url: "https://eslint.org/docs/rules/prefer-spread"
109401 },
109402 schema: [],
109403 fixable: null,
109404 messages: {
109405 preferSpread: "Use the spread operator instead of '.apply()'."
109406 }
109407 },
109408
109409 create(context) {
109410 const sourceCode = context.getSourceCode();
109411 return {
109412 CallExpression(node) {
109413 if (!isVariadicApplyCalling(node)) {
109414 return;
109415 }
109416
109417 const applied = astUtils.skipChainExpression(astUtils.skipChainExpression(node.callee).object);
109418 const expectedThis = applied.type === "MemberExpression" ? applied.object : null;
109419 const thisArg = node.arguments[0];
109420
109421 if (isValidThisArg(expectedThis, thisArg, sourceCode)) {
109422 context.report({
109423 node,
109424 messageId: "preferSpread"
109425 });
109426 }
109427 }
109428
109429 };
109430 }
109431
109432 };
109433
109434 /***/ }),
109435 /* 813 */
109436 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
109437
109438 "use strict";
109439 /**
109440 * @fileoverview A rule to suggest using template literals instead of string concatenation.
109441 * @author Toru Nagashima
109442 */
109443 //------------------------------------------------------------------------------
109444 // Requirements
109445 //------------------------------------------------------------------------------
109446
109447 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
109448 // Helpers
109449 //------------------------------------------------------------------------------
109450
109451 /**
109452 * Checks whether or not a given node is a concatenation.
109453 * @param {ASTNode} node A node to check.
109454 * @returns {boolean} `true` if the node is a concatenation.
109455 */
109456
109457
109458 function isConcatenation(node) {
109459 return node.type === "BinaryExpression" && node.operator === "+";
109460 }
109461 /**
109462 * Gets the top binary expression node for concatenation in parents of a given node.
109463 * @param {ASTNode} node A node to get.
109464 * @returns {ASTNode} the top binary expression node in parents of a given node.
109465 */
109466
109467
109468 function getTopConcatBinaryExpression(node) {
109469 let currentNode = node;
109470
109471 while (isConcatenation(currentNode.parent)) {
109472 currentNode = currentNode.parent;
109473 }
109474
109475 return currentNode;
109476 }
109477 /**
109478 * Checks whether or not a node contains a string literal with an octal or non-octal decimal escape sequence
109479 * @param {ASTNode} node A node to check
109480 * @returns {boolean} `true` if at least one string literal within the node contains
109481 * an octal or non-octal decimal escape sequence
109482 */
109483
109484
109485 function hasOctalOrNonOctalDecimalEscapeSequence(node) {
109486 if (isConcatenation(node)) {
109487 return hasOctalOrNonOctalDecimalEscapeSequence(node.left) || hasOctalOrNonOctalDecimalEscapeSequence(node.right);
109488 } // No need to check TemplateLiterals – would throw parsing error
109489
109490
109491 if (node.type === "Literal" && typeof node.value === "string") {
109492 return astUtils.hasOctalOrNonOctalDecimalEscapeSequence(node.raw);
109493 }
109494
109495 return false;
109496 }
109497 /**
109498 * Checks whether or not a given binary expression has string literals.
109499 * @param {ASTNode} node A node to check.
109500 * @returns {boolean} `true` if the node has string literals.
109501 */
109502
109503
109504 function hasStringLiteral(node) {
109505 if (isConcatenation(node)) {
109506 // `left` is deeper than `right` normally.
109507 return hasStringLiteral(node.right) || hasStringLiteral(node.left);
109508 }
109509
109510 return astUtils.isStringLiteral(node);
109511 }
109512 /**
109513 * Checks whether or not a given binary expression has non string literals.
109514 * @param {ASTNode} node A node to check.
109515 * @returns {boolean} `true` if the node has non string literals.
109516 */
109517
109518
109519 function hasNonStringLiteral(node) {
109520 if (isConcatenation(node)) {
109521 // `left` is deeper than `right` normally.
109522 return hasNonStringLiteral(node.right) || hasNonStringLiteral(node.left);
109523 }
109524
109525 return !astUtils.isStringLiteral(node);
109526 }
109527 /**
109528 * Determines whether a given node will start with a template curly expression (`${}`) when being converted to a template literal.
109529 * @param {ASTNode} node The node that will be fixed to a template literal
109530 * @returns {boolean} `true` if the node will start with a template curly.
109531 */
109532
109533
109534 function startsWithTemplateCurly(node) {
109535 if (node.type === "BinaryExpression") {
109536 return startsWithTemplateCurly(node.left);
109537 }
109538
109539 if (node.type === "TemplateLiteral") {
109540 return node.expressions.length && node.quasis.length && node.quasis[0].range[0] === node.quasis[0].range[1];
109541 }
109542
109543 return node.type !== "Literal" || typeof node.value !== "string";
109544 }
109545 /**
109546 * Determines whether a given node end with a template curly expression (`${}`) when being converted to a template literal.
109547 * @param {ASTNode} node The node that will be fixed to a template literal
109548 * @returns {boolean} `true` if the node will end with a template curly.
109549 */
109550
109551
109552 function endsWithTemplateCurly(node) {
109553 if (node.type === "BinaryExpression") {
109554 return startsWithTemplateCurly(node.right);
109555 }
109556
109557 if (node.type === "TemplateLiteral") {
109558 return node.expressions.length && node.quasis.length && node.quasis[node.quasis.length - 1].range[0] === node.quasis[node.quasis.length - 1].range[1];
109559 }
109560
109561 return node.type !== "Literal" || typeof node.value !== "string";
109562 } //------------------------------------------------------------------------------
109563 // Rule Definition
109564 //------------------------------------------------------------------------------
109565
109566
109567 module.exports = {
109568 meta: {
109569 type: "suggestion",
109570 docs: {
109571 description: "require template literals instead of string concatenation",
109572 recommended: false,
109573 url: "https://eslint.org/docs/rules/prefer-template"
109574 },
109575 schema: [],
109576 fixable: "code",
109577 messages: {
109578 unexpectedStringConcatenation: "Unexpected string concatenation."
109579 }
109580 },
109581
109582 create(context) {
109583 const sourceCode = context.getSourceCode();
109584 let done = Object.create(null);
109585 /**
109586 * Gets the non-token text between two nodes, ignoring any other tokens that appear between the two tokens.
109587 * @param {ASTNode} node1 The first node
109588 * @param {ASTNode} node2 The second node
109589 * @returns {string} The text between the nodes, excluding other tokens
109590 */
109591
109592 function getTextBetween(node1, node2) {
109593 const allTokens = [node1].concat(sourceCode.getTokensBetween(node1, node2)).concat(node2);
109594 const sourceText = sourceCode.getText();
109595 return allTokens.slice(0, -1).reduce((accumulator, token, index) => accumulator + sourceText.slice(token.range[1], allTokens[index + 1].range[0]), "");
109596 }
109597 /**
109598 * Returns a template literal form of the given node.
109599 * @param {ASTNode} currentNode A node that should be converted to a template literal
109600 * @param {string} textBeforeNode Text that should appear before the node
109601 * @param {string} textAfterNode Text that should appear after the node
109602 * @returns {string} A string form of this node, represented as a template literal
109603 */
109604
109605
109606 function getTemplateLiteral(currentNode, textBeforeNode, textAfterNode) {
109607 if (currentNode.type === "Literal" && typeof currentNode.value === "string") {
109608 /*
109609 * If the current node is a string literal, escape any instances of ${ or ` to prevent them from being interpreted
109610 * as a template placeholder. However, if the code already contains a backslash before the ${ or `
109611 * for some reason, don't add another backslash, because that would change the meaning of the code (it would cause
109612 * an actual backslash character to appear before the dollar sign).
109613 */
109614 return "`".concat(currentNode.raw.slice(1, -1).replace(/\\*(\$\{|`)/gu, matched => {
109615 if (matched.lastIndexOf("\\") % 2) {
109616 return "\\".concat(matched);
109617 }
109618
109619 return matched; // Unescape any quotes that appear in the original Literal that no longer need to be escaped.
109620 }).replace(new RegExp("\\\\".concat(currentNode.raw[0]), "gu"), currentNode.raw[0]), "`");
109621 }
109622
109623 if (currentNode.type === "TemplateLiteral") {
109624 return sourceCode.getText(currentNode);
109625 }
109626
109627 if (isConcatenation(currentNode) && hasStringLiteral(currentNode) && hasNonStringLiteral(currentNode)) {
109628 const plusSign = sourceCode.getFirstTokenBetween(currentNode.left, currentNode.right, token => token.value === "+");
109629 const textBeforePlus = getTextBetween(currentNode.left, plusSign);
109630 const textAfterPlus = getTextBetween(plusSign, currentNode.right);
109631 const leftEndsWithCurly = endsWithTemplateCurly(currentNode.left);
109632 const rightStartsWithCurly = startsWithTemplateCurly(currentNode.right);
109633
109634 if (leftEndsWithCurly) {
109635 // If the left side of the expression ends with a template curly, add the extra text to the end of the curly bracket.
109636 // `foo${bar}` /* comment */ + 'baz' --> `foo${bar /* comment */ }${baz}`
109637 return getTemplateLiteral(currentNode.left, textBeforeNode, textBeforePlus + textAfterPlus).slice(0, -1) + getTemplateLiteral(currentNode.right, null, textAfterNode).slice(1);
109638 }
109639
109640 if (rightStartsWithCurly) {
109641 // Otherwise, if the right side of the expression starts with a template curly, add the text there.
109642 // 'foo' /* comment */ + `${bar}baz` --> `foo${ /* comment */ bar}baz`
109643 return getTemplateLiteral(currentNode.left, textBeforeNode, null).slice(0, -1) + getTemplateLiteral(currentNode.right, textBeforePlus + textAfterPlus, textAfterNode).slice(1);
109644 }
109645 /*
109646 * Otherwise, these nodes should not be combined into a template curly, since there is nowhere to put
109647 * the text between them.
109648 */
109649
109650
109651 return "".concat(getTemplateLiteral(currentNode.left, textBeforeNode, null)).concat(textBeforePlus, "+").concat(textAfterPlus).concat(getTemplateLiteral(currentNode.right, textAfterNode, null));
109652 }
109653
109654 return "`${".concat(textBeforeNode || "").concat(sourceCode.getText(currentNode)).concat(textAfterNode || "", "}`");
109655 }
109656 /**
109657 * Returns a fixer object that converts a non-string binary expression to a template literal
109658 * @param {SourceCodeFixer} fixer The fixer object
109659 * @param {ASTNode} node A node that should be converted to a template literal
109660 * @returns {Object} A fix for this binary expression
109661 */
109662
109663
109664 function fixNonStringBinaryExpression(fixer, node) {
109665 const topBinaryExpr = getTopConcatBinaryExpression(node.parent);
109666
109667 if (hasOctalOrNonOctalDecimalEscapeSequence(topBinaryExpr)) {
109668 return null;
109669 }
109670
109671 return fixer.replaceText(topBinaryExpr, getTemplateLiteral(topBinaryExpr, null, null));
109672 }
109673 /**
109674 * Reports if a given node is string concatenation with non string literals.
109675 * @param {ASTNode} node A node to check.
109676 * @returns {void}
109677 */
109678
109679
109680 function checkForStringConcat(node) {
109681 if (!astUtils.isStringLiteral(node) || !isConcatenation(node.parent)) {
109682 return;
109683 }
109684
109685 const topBinaryExpr = getTopConcatBinaryExpression(node.parent); // Checks whether or not this node had been checked already.
109686
109687 if (done[topBinaryExpr.range[0]]) {
109688 return;
109689 }
109690
109691 done[topBinaryExpr.range[0]] = true;
109692
109693 if (hasNonStringLiteral(topBinaryExpr)) {
109694 context.report({
109695 node: topBinaryExpr,
109696 messageId: "unexpectedStringConcatenation",
109697 fix: fixer => fixNonStringBinaryExpression(fixer, node)
109698 });
109699 }
109700 }
109701
109702 return {
109703 Program() {
109704 done = Object.create(null);
109705 },
109706
109707 Literal: checkForStringConcat,
109708 TemplateLiteral: checkForStringConcat
109709 };
109710 }
109711
109712 };
109713
109714 /***/ }),
109715 /* 814 */
109716 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
109717
109718 "use strict";
109719 /**
109720 * @fileoverview Rule to flag non-quoted property names in object literals.
109721 * @author Mathias Bynens <http://mathiasbynens.be/>
109722 */
109723 //------------------------------------------------------------------------------
109724 // Requirements
109725 //------------------------------------------------------------------------------
109726
109727 const espree = __webpack_require__(436);
109728
109729 const astUtils = __webpack_require__(548);
109730
109731 const keywords = __webpack_require__(583); //------------------------------------------------------------------------------
109732 // Rule Definition
109733 //------------------------------------------------------------------------------
109734
109735
109736 module.exports = {
109737 meta: {
109738 type: "suggestion",
109739 docs: {
109740 description: "require quotes around object literal property names",
109741 recommended: false,
109742 url: "https://eslint.org/docs/rules/quote-props"
109743 },
109744 schema: {
109745 anyOf: [{
109746 type: "array",
109747 items: [{
109748 enum: ["always", "as-needed", "consistent", "consistent-as-needed"]
109749 }],
109750 minItems: 0,
109751 maxItems: 1
109752 }, {
109753 type: "array",
109754 items: [{
109755 enum: ["always", "as-needed", "consistent", "consistent-as-needed"]
109756 }, {
109757 type: "object",
109758 properties: {
109759 keywords: {
109760 type: "boolean"
109761 },
109762 unnecessary: {
109763 type: "boolean"
109764 },
109765 numbers: {
109766 type: "boolean"
109767 }
109768 },
109769 additionalProperties: false
109770 }],
109771 minItems: 0,
109772 maxItems: 2
109773 }]
109774 },
109775 fixable: "code",
109776 messages: {
109777 requireQuotesDueToReservedWord: "Properties should be quoted as '{{property}}' is a reserved word.",
109778 inconsistentlyQuotedProperty: "Inconsistently quoted property '{{key}}' found.",
109779 unnecessarilyQuotedProperty: "Unnecessarily quoted property '{{property}}' found.",
109780 unquotedReservedProperty: "Unquoted reserved word '{{property}}' used as key.",
109781 unquotedNumericProperty: "Unquoted number literal '{{property}}' used as key.",
109782 unquotedPropertyFound: "Unquoted property '{{property}}' found.",
109783 redundantQuoting: "Properties shouldn't be quoted as all quotes are redundant."
109784 }
109785 },
109786
109787 create(context) {
109788 const MODE = context.options[0],
109789 KEYWORDS = context.options[1] && context.options[1].keywords,
109790 CHECK_UNNECESSARY = !context.options[1] || context.options[1].unnecessary !== false,
109791 NUMBERS = context.options[1] && context.options[1].numbers,
109792 sourceCode = context.getSourceCode();
109793 /**
109794 * Checks whether a certain string constitutes an ES3 token
109795 * @param {string} tokenStr The string to be checked.
109796 * @returns {boolean} `true` if it is an ES3 token.
109797 */
109798
109799 function isKeyword(tokenStr) {
109800 return keywords.indexOf(tokenStr) >= 0;
109801 }
109802 /**
109803 * Checks if an espree-tokenized key has redundant quotes (i.e. whether quotes are unnecessary)
109804 * @param {string} rawKey The raw key value from the source
109805 * @param {espreeTokens} tokens The espree-tokenized node key
109806 * @param {boolean} [skipNumberLiterals=false] Indicates whether number literals should be checked
109807 * @returns {boolean} Whether or not a key has redundant quotes.
109808 * @private
109809 */
109810
109811
109812 function areQuotesRedundant(rawKey, tokens, skipNumberLiterals) {
109813 return tokens.length === 1 && tokens[0].start === 0 && tokens[0].end === rawKey.length && (["Identifier", "Keyword", "Null", "Boolean"].indexOf(tokens[0].type) >= 0 || tokens[0].type === "Numeric" && !skipNumberLiterals && String(+tokens[0].value) === tokens[0].value);
109814 }
109815 /**
109816 * Returns a string representation of a property node with quotes removed
109817 * @param {ASTNode} key Key AST Node, which may or may not be quoted
109818 * @returns {string} A replacement string for this property
109819 */
109820
109821
109822 function getUnquotedKey(key) {
109823 return key.type === "Identifier" ? key.name : key.value;
109824 }
109825 /**
109826 * Returns a string representation of a property node with quotes added
109827 * @param {ASTNode} key Key AST Node, which may or may not be quoted
109828 * @returns {string} A replacement string for this property
109829 */
109830
109831
109832 function getQuotedKey(key) {
109833 if (key.type === "Literal" && typeof key.value === "string") {
109834 // If the key is already a string literal, don't replace the quotes with double quotes.
109835 return sourceCode.getText(key);
109836 } // Otherwise, the key is either an identifier or a number literal.
109837
109838
109839 return "\"".concat(key.type === "Identifier" ? key.name : key.value, "\"");
109840 }
109841 /**
109842 * Ensures that a property's key is quoted only when necessary
109843 * @param {ASTNode} node Property AST node
109844 * @returns {void}
109845 */
109846
109847
109848 function checkUnnecessaryQuotes(node) {
109849 const key = node.key;
109850
109851 if (node.method || node.computed || node.shorthand) {
109852 return;
109853 }
109854
109855 if (key.type === "Literal" && typeof key.value === "string") {
109856 let tokens;
109857
109858 try {
109859 tokens = espree.tokenize(key.value);
109860 } catch {
109861 return;
109862 }
109863
109864 if (tokens.length !== 1) {
109865 return;
109866 }
109867
109868 const isKeywordToken = isKeyword(tokens[0].value);
109869
109870 if (isKeywordToken && KEYWORDS) {
109871 return;
109872 }
109873
109874 if (CHECK_UNNECESSARY && areQuotesRedundant(key.value, tokens, NUMBERS)) {
109875 context.report({
109876 node,
109877 messageId: "unnecessarilyQuotedProperty",
109878 data: {
109879 property: key.value
109880 },
109881 fix: fixer => fixer.replaceText(key, getUnquotedKey(key))
109882 });
109883 }
109884 } else if (KEYWORDS && key.type === "Identifier" && isKeyword(key.name)) {
109885 context.report({
109886 node,
109887 messageId: "unquotedReservedProperty",
109888 data: {
109889 property: key.name
109890 },
109891 fix: fixer => fixer.replaceText(key, getQuotedKey(key))
109892 });
109893 } else if (NUMBERS && key.type === "Literal" && astUtils.isNumericLiteral(key)) {
109894 context.report({
109895 node,
109896 messageId: "unquotedNumericProperty",
109897 data: {
109898 property: key.value
109899 },
109900 fix: fixer => fixer.replaceText(key, getQuotedKey(key))
109901 });
109902 }
109903 }
109904 /**
109905 * Ensures that a property's key is quoted
109906 * @param {ASTNode} node Property AST node
109907 * @returns {void}
109908 */
109909
109910
109911 function checkOmittedQuotes(node) {
109912 const key = node.key;
109913
109914 if (!node.method && !node.computed && !node.shorthand && !(key.type === "Literal" && typeof key.value === "string")) {
109915 context.report({
109916 node,
109917 messageId: "unquotedPropertyFound",
109918 data: {
109919 property: key.name || key.value
109920 },
109921 fix: fixer => fixer.replaceText(key, getQuotedKey(key))
109922 });
109923 }
109924 }
109925 /**
109926 * Ensures that an object's keys are consistently quoted, optionally checks for redundancy of quotes
109927 * @param {ASTNode} node Property AST node
109928 * @param {boolean} checkQuotesRedundancy Whether to check quotes' redundancy
109929 * @returns {void}
109930 */
109931
109932
109933 function checkConsistency(node, checkQuotesRedundancy) {
109934 const quotedProps = [],
109935 unquotedProps = [];
109936 let keywordKeyName = null,
109937 necessaryQuotes = false;
109938 node.properties.forEach(property => {
109939 const key = property.key;
109940
109941 if (!key || property.method || property.computed || property.shorthand) {
109942 return;
109943 }
109944
109945 if (key.type === "Literal" && typeof key.value === "string") {
109946 quotedProps.push(property);
109947
109948 if (checkQuotesRedundancy) {
109949 let tokens;
109950
109951 try {
109952 tokens = espree.tokenize(key.value);
109953 } catch {
109954 necessaryQuotes = true;
109955 return;
109956 }
109957
109958 necessaryQuotes = necessaryQuotes || !areQuotesRedundant(key.value, tokens) || KEYWORDS && isKeyword(tokens[0].value);
109959 }
109960 } else if (KEYWORDS && checkQuotesRedundancy && key.type === "Identifier" && isKeyword(key.name)) {
109961 unquotedProps.push(property);
109962 necessaryQuotes = true;
109963 keywordKeyName = key.name;
109964 } else {
109965 unquotedProps.push(property);
109966 }
109967 });
109968
109969 if (checkQuotesRedundancy && quotedProps.length && !necessaryQuotes) {
109970 quotedProps.forEach(property => {
109971 context.report({
109972 node: property,
109973 messageId: "redundantQuoting",
109974 fix: fixer => fixer.replaceText(property.key, getUnquotedKey(property.key))
109975 });
109976 });
109977 } else if (unquotedProps.length && keywordKeyName) {
109978 unquotedProps.forEach(property => {
109979 context.report({
109980 node: property,
109981 messageId: "requireQuotesDueToReservedWord",
109982 data: {
109983 property: keywordKeyName
109984 },
109985 fix: fixer => fixer.replaceText(property.key, getQuotedKey(property.key))
109986 });
109987 });
109988 } else if (quotedProps.length && unquotedProps.length) {
109989 unquotedProps.forEach(property => {
109990 context.report({
109991 node: property,
109992 messageId: "inconsistentlyQuotedProperty",
109993 data: {
109994 key: property.key.name || property.key.value
109995 },
109996 fix: fixer => fixer.replaceText(property.key, getQuotedKey(property.key))
109997 });
109998 });
109999 }
110000 }
110001
110002 return {
110003 Property(node) {
110004 if (MODE === "always" || !MODE) {
110005 checkOmittedQuotes(node);
110006 }
110007
110008 if (MODE === "as-needed") {
110009 checkUnnecessaryQuotes(node);
110010 }
110011 },
110012
110013 ObjectExpression(node) {
110014 if (MODE === "consistent") {
110015 checkConsistency(node, false);
110016 }
110017
110018 if (MODE === "consistent-as-needed") {
110019 checkConsistency(node, true);
110020 }
110021 }
110022
110023 };
110024 }
110025
110026 };
110027
110028 /***/ }),
110029 /* 815 */
110030 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
110031
110032 "use strict";
110033 /**
110034 * @fileoverview A rule to choose between single and double quote marks
110035 * @author Matt DuVall <http://www.mattduvall.com/>, Brandon Payton
110036 */
110037 //------------------------------------------------------------------------------
110038 // Requirements
110039 //------------------------------------------------------------------------------
110040
110041 var _templateObject;
110042
110043 function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
110044
110045 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
110046 // Constants
110047 //------------------------------------------------------------------------------
110048
110049
110050 const QUOTE_SETTINGS = {
110051 double: {
110052 quote: "\"",
110053 alternateQuote: "'",
110054 description: "doublequote"
110055 },
110056 single: {
110057 quote: "'",
110058 alternateQuote: "\"",
110059 description: "singlequote"
110060 },
110061 backtick: {
110062 quote: "`",
110063 alternateQuote: "\"",
110064 description: "backtick"
110065 }
110066 }; // An unescaped newline is a newline preceded by an even number of backslashes.
110067
110068 const UNESCAPED_LINEBREAK_PATTERN = new RegExp(String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["(^|[^\\])(\\\\)*[", "]"], ["(^|[^\\\\])(\\\\\\\\)*[", "]"])), Array.from(astUtils.LINEBREAKS).join("")), "u");
110069 /**
110070 * Switches quoting of javascript string between ' " and `
110071 * escaping and unescaping as necessary.
110072 * Only escaping of the minimal set of characters is changed.
110073 * Note: escaping of newlines when switching from backtick to other quotes is not handled.
110074 * @param {string} str A string to convert.
110075 * @returns {string} The string with changed quotes.
110076 * @private
110077 */
110078
110079 QUOTE_SETTINGS.double.convert = QUOTE_SETTINGS.single.convert = QUOTE_SETTINGS.backtick.convert = function (str) {
110080 const newQuote = this.quote;
110081 const oldQuote = str[0];
110082
110083 if (newQuote === oldQuote) {
110084 return str;
110085 }
110086
110087 return newQuote + str.slice(1, -1).replace(/\\(\$\{|\r\n?|\n|.)|["'`]|\$\{|(\r\n?|\n)/gu, (match, escaped, newline) => {
110088 if (escaped === oldQuote || oldQuote === "`" && escaped === "${") {
110089 return escaped; // unescape
110090 }
110091
110092 if (match === newQuote || newQuote === "`" && match === "${") {
110093 return "\\".concat(match); // escape
110094 }
110095
110096 if (newline && oldQuote === "`") {
110097 return "\\n"; // escape newlines
110098 }
110099
110100 return match;
110101 }) + newQuote;
110102 };
110103
110104 const AVOID_ESCAPE = "avoid-escape"; //------------------------------------------------------------------------------
110105 // Rule Definition
110106 //------------------------------------------------------------------------------
110107
110108 module.exports = {
110109 meta: {
110110 type: "layout",
110111 docs: {
110112 description: "enforce the consistent use of either backticks, double, or single quotes",
110113 recommended: false,
110114 url: "https://eslint.org/docs/rules/quotes"
110115 },
110116 fixable: "code",
110117 schema: [{
110118 enum: ["single", "double", "backtick"]
110119 }, {
110120 anyOf: [{
110121 enum: ["avoid-escape"]
110122 }, {
110123 type: "object",
110124 properties: {
110125 avoidEscape: {
110126 type: "boolean"
110127 },
110128 allowTemplateLiterals: {
110129 type: "boolean"
110130 }
110131 },
110132 additionalProperties: false
110133 }]
110134 }],
110135 messages: {
110136 wrongQuotes: "Strings must use {{description}}."
110137 }
110138 },
110139
110140 create(context) {
110141 const quoteOption = context.options[0],
110142 settings = QUOTE_SETTINGS[quoteOption || "double"],
110143 options = context.options[1],
110144 allowTemplateLiterals = options && options.allowTemplateLiterals === true,
110145 sourceCode = context.getSourceCode();
110146 let avoidEscape = options && options.avoidEscape === true; // deprecated
110147
110148 if (options === AVOID_ESCAPE) {
110149 avoidEscape = true;
110150 }
110151 /**
110152 * Determines if a given node is part of JSX syntax.
110153 *
110154 * This function returns `true` in the following cases:
110155 *
110156 * - `<div className="foo"></div>` ... If the literal is an attribute value, the parent of the literal is `JSXAttribute`.
110157 * - `<div>foo</div>` ... If the literal is a text content, the parent of the literal is `JSXElement`.
110158 * - `<>foo</>` ... If the literal is a text content, the parent of the literal is `JSXFragment`.
110159 *
110160 * In particular, this function returns `false` in the following cases:
110161 *
110162 * - `<div className={"foo"}></div>`
110163 * - `<div>{"foo"}</div>`
110164 *
110165 * In both cases, inside of the braces is handled as normal JavaScript.
110166 * The braces are `JSXExpressionContainer` nodes.
110167 * @param {ASTNode} node The Literal node to check.
110168 * @returns {boolean} True if the node is a part of JSX, false if not.
110169 * @private
110170 */
110171
110172
110173 function isJSXLiteral(node) {
110174 return node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement" || node.parent.type === "JSXFragment";
110175 }
110176 /**
110177 * Checks whether or not a given node is a directive.
110178 * The directive is a `ExpressionStatement` which has only a string literal.
110179 * @param {ASTNode} node A node to check.
110180 * @returns {boolean} Whether or not the node is a directive.
110181 * @private
110182 */
110183
110184
110185 function isDirective(node) {
110186 return node.type === "ExpressionStatement" && node.expression.type === "Literal" && typeof node.expression.value === "string";
110187 }
110188 /**
110189 * Checks whether or not a given node is a part of directive prologues.
110190 * See also: http://www.ecma-international.org/ecma-262/6.0/#sec-directive-prologues-and-the-use-strict-directive
110191 * @param {ASTNode} node A node to check.
110192 * @returns {boolean} Whether or not the node is a part of directive prologues.
110193 * @private
110194 */
110195
110196
110197 function isPartOfDirectivePrologue(node) {
110198 const block = node.parent.parent;
110199
110200 if (block.type !== "Program" && (block.type !== "BlockStatement" || !astUtils.isFunction(block.parent))) {
110201 return false;
110202 } // Check the node is at a prologue.
110203
110204
110205 for (let i = 0; i < block.body.length; ++i) {
110206 const statement = block.body[i];
110207
110208 if (statement === node.parent) {
110209 return true;
110210 }
110211
110212 if (!isDirective(statement)) {
110213 break;
110214 }
110215 }
110216
110217 return false;
110218 }
110219 /**
110220 * Checks whether or not a given node is allowed as non backtick.
110221 * @param {ASTNode} node A node to check.
110222 * @returns {boolean} Whether or not the node is allowed as non backtick.
110223 * @private
110224 */
110225
110226
110227 function isAllowedAsNonBacktick(node) {
110228 const parent = node.parent;
110229
110230 switch (parent.type) {
110231 // Directive Prologues.
110232 case "ExpressionStatement":
110233 return isPartOfDirectivePrologue(node);
110234 // LiteralPropertyName.
110235
110236 case "Property":
110237 case "PropertyDefinition":
110238 case "MethodDefinition":
110239 return parent.key === node && !parent.computed;
110240 // ModuleSpecifier.
110241
110242 case "ImportDeclaration":
110243 case "ExportNamedDeclaration":
110244 case "ExportAllDeclaration":
110245 return parent.source === node;
110246 // Others don't allow.
110247
110248 default:
110249 return false;
110250 }
110251 }
110252 /**
110253 * Checks whether or not a given TemplateLiteral node is actually using any of the special features provided by template literal strings.
110254 * @param {ASTNode} node A TemplateLiteral node to check.
110255 * @returns {boolean} Whether or not the TemplateLiteral node is using any of the special features provided by template literal strings.
110256 * @private
110257 */
110258
110259
110260 function isUsingFeatureOfTemplateLiteral(node) {
110261 const hasTag = node.parent.type === "TaggedTemplateExpression" && node === node.parent.quasi;
110262
110263 if (hasTag) {
110264 return true;
110265 }
110266
110267 const hasStringInterpolation = node.expressions.length > 0;
110268
110269 if (hasStringInterpolation) {
110270 return true;
110271 }
110272
110273 const isMultilineString = node.quasis.length >= 1 && UNESCAPED_LINEBREAK_PATTERN.test(node.quasis[0].value.raw);
110274
110275 if (isMultilineString) {
110276 return true;
110277 }
110278
110279 return false;
110280 }
110281
110282 return {
110283 Literal(node) {
110284 const val = node.value,
110285 rawVal = node.raw;
110286
110287 if (settings && typeof val === "string") {
110288 let isValid = quoteOption === "backtick" && isAllowedAsNonBacktick(node) || isJSXLiteral(node) || astUtils.isSurroundedBy(rawVal, settings.quote);
110289
110290 if (!isValid && avoidEscape) {
110291 isValid = astUtils.isSurroundedBy(rawVal, settings.alternateQuote) && rawVal.indexOf(settings.quote) >= 0;
110292 }
110293
110294 if (!isValid) {
110295 context.report({
110296 node,
110297 messageId: "wrongQuotes",
110298 data: {
110299 description: settings.description
110300 },
110301
110302 fix(fixer) {
110303 if (quoteOption === "backtick" && astUtils.hasOctalOrNonOctalDecimalEscapeSequence(rawVal)) {
110304 /*
110305 * An octal or non-octal decimal escape sequence in a template literal would
110306 * produce syntax error, even in non-strict mode.
110307 */
110308 return null;
110309 }
110310
110311 return fixer.replaceText(node, settings.convert(node.raw));
110312 }
110313
110314 });
110315 }
110316 }
110317 },
110318
110319 TemplateLiteral(node) {
110320 // Don't throw an error if backticks are expected or a template literal feature is in use.
110321 if (allowTemplateLiterals || quoteOption === "backtick" || isUsingFeatureOfTemplateLiteral(node)) {
110322 return;
110323 }
110324
110325 context.report({
110326 node,
110327 messageId: "wrongQuotes",
110328 data: {
110329 description: settings.description
110330 },
110331
110332 fix(fixer) {
110333 if (isPartOfDirectivePrologue(node)) {
110334 /*
110335 * TemplateLiterals in a directive prologue aren't actually directives, but if they're
110336 * in the directive prologue, then fixing them might turn them into directives and change
110337 * the behavior of the code.
110338 */
110339 return null;
110340 }
110341
110342 return fixer.replaceText(node, settings.convert(sourceCode.getText(node)));
110343 }
110344
110345 });
110346 }
110347
110348 };
110349 }
110350
110351 };
110352
110353 /***/ }),
110354 /* 816 */
110355 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
110356
110357 "use strict";
110358 /**
110359 * @fileoverview Rule to flag use of parseInt without a radix argument
110360 * @author James Allardice
110361 */
110362 //------------------------------------------------------------------------------
110363 // Requirements
110364 //------------------------------------------------------------------------------
110365
110366 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
110367 // Helpers
110368 //------------------------------------------------------------------------------
110369
110370
110371 const MODE_ALWAYS = "always",
110372 MODE_AS_NEEDED = "as-needed";
110373 const validRadixValues = new Set(Array.from({
110374 length: 37 - 2
110375 }, (_, index) => index + 2));
110376 /**
110377 * Checks whether a given variable is shadowed or not.
110378 * @param {eslint-scope.Variable} variable A variable to check.
110379 * @returns {boolean} `true` if the variable is shadowed.
110380 */
110381
110382 function isShadowed(variable) {
110383 return variable.defs.length >= 1;
110384 }
110385 /**
110386 * Checks whether a given node is a MemberExpression of `parseInt` method or not.
110387 * @param {ASTNode} node A node to check.
110388 * @returns {boolean} `true` if the node is a MemberExpression of `parseInt`
110389 * method.
110390 */
110391
110392
110393 function isParseIntMethod(node) {
110394 return node.type === "MemberExpression" && !node.computed && node.property.type === "Identifier" && node.property.name === "parseInt";
110395 }
110396 /**
110397 * Checks whether a given node is a valid value of radix or not.
110398 *
110399 * The following values are invalid.
110400 *
110401 * - A literal except integers between 2 and 36.
110402 * - undefined.
110403 * @param {ASTNode} radix A node of radix to check.
110404 * @returns {boolean} `true` if the node is valid.
110405 */
110406
110407
110408 function isValidRadix(radix) {
110409 return !(radix.type === "Literal" && !validRadixValues.has(radix.value) || radix.type === "Identifier" && radix.name === "undefined");
110410 }
110411 /**
110412 * Checks whether a given node is a default value of radix or not.
110413 * @param {ASTNode} radix A node of radix to check.
110414 * @returns {boolean} `true` if the node is the literal node of `10`.
110415 */
110416
110417
110418 function isDefaultRadix(radix) {
110419 return radix.type === "Literal" && radix.value === 10;
110420 } //------------------------------------------------------------------------------
110421 // Rule Definition
110422 //------------------------------------------------------------------------------
110423
110424
110425 module.exports = {
110426 meta: {
110427 type: "suggestion",
110428 docs: {
110429 description: "enforce the consistent use of the radix argument when using `parseInt()`",
110430 recommended: false,
110431 url: "https://eslint.org/docs/rules/radix"
110432 },
110433 hasSuggestions: true,
110434 schema: [{
110435 enum: ["always", "as-needed"]
110436 }],
110437 messages: {
110438 missingParameters: "Missing parameters.",
110439 redundantRadix: "Redundant radix parameter.",
110440 missingRadix: "Missing radix parameter.",
110441 invalidRadix: "Invalid radix parameter, must be an integer between 2 and 36.",
110442 addRadixParameter10: "Add radix parameter `10` for parsing decimal numbers."
110443 }
110444 },
110445
110446 create(context) {
110447 const mode = context.options[0] || MODE_ALWAYS;
110448 /**
110449 * Checks the arguments of a given CallExpression node and reports it if it
110450 * offends this rule.
110451 * @param {ASTNode} node A CallExpression node to check.
110452 * @returns {void}
110453 */
110454
110455 function checkArguments(node) {
110456 const args = node.arguments;
110457
110458 switch (args.length) {
110459 case 0:
110460 context.report({
110461 node,
110462 messageId: "missingParameters"
110463 });
110464 break;
110465
110466 case 1:
110467 if (mode === MODE_ALWAYS) {
110468 context.report({
110469 node,
110470 messageId: "missingRadix",
110471 suggest: [{
110472 messageId: "addRadixParameter10",
110473
110474 fix(fixer) {
110475 const sourceCode = context.getSourceCode();
110476 const tokens = sourceCode.getTokens(node);
110477 const lastToken = tokens[tokens.length - 1]; // Parenthesis.
110478
110479 const secondToLastToken = tokens[tokens.length - 2]; // May or may not be a comma.
110480
110481 const hasTrailingComma = secondToLastToken.type === "Punctuator" && secondToLastToken.value === ",";
110482 return fixer.insertTextBefore(lastToken, hasTrailingComma ? " 10," : ", 10");
110483 }
110484
110485 }]
110486 });
110487 }
110488
110489 break;
110490
110491 default:
110492 if (mode === MODE_AS_NEEDED && isDefaultRadix(args[1])) {
110493 context.report({
110494 node,
110495 messageId: "redundantRadix"
110496 });
110497 } else if (!isValidRadix(args[1])) {
110498 context.report({
110499 node,
110500 messageId: "invalidRadix"
110501 });
110502 }
110503
110504 break;
110505 }
110506 }
110507
110508 return {
110509 "Program:exit"() {
110510 const scope = context.getScope();
110511 let variable; // Check `parseInt()`
110512
110513 variable = astUtils.getVariableByName(scope, "parseInt");
110514
110515 if (variable && !isShadowed(variable)) {
110516 variable.references.forEach(reference => {
110517 const node = reference.identifier;
110518
110519 if (astUtils.isCallee(node)) {
110520 checkArguments(node.parent);
110521 }
110522 });
110523 } // Check `Number.parseInt()`
110524
110525
110526 variable = astUtils.getVariableByName(scope, "Number");
110527
110528 if (variable && !isShadowed(variable)) {
110529 variable.references.forEach(reference => {
110530 const node = reference.identifier.parent;
110531 const maybeCallee = node.parent.type === "ChainExpression" ? node.parent : node;
110532
110533 if (isParseIntMethod(node) && astUtils.isCallee(maybeCallee)) {
110534 checkArguments(maybeCallee.parent);
110535 }
110536 });
110537 }
110538 }
110539
110540 };
110541 }
110542
110543 };
110544
110545 /***/ }),
110546 /* 817 */
110547 /***/ ((module) => {
110548
110549 "use strict";
110550 /**
110551 * @fileoverview disallow assignments that can lead to race conditions due to usage of `await` or `yield`
110552 * @author Teddy Katz
110553 * @author Toru Nagashima
110554 */
110555
110556 /**
110557 * Make the map from identifiers to each reference.
110558 * @param {escope.Scope} scope The scope to get references.
110559 * @param {Map<Identifier, escope.Reference>} [outReferenceMap] The map from identifier nodes to each reference object.
110560 * @returns {Map<Identifier, escope.Reference>} `referenceMap`.
110561 */
110562
110563 function createReferenceMap(scope) {
110564 let outReferenceMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Map();
110565
110566 for (const reference of scope.references) {
110567 if (reference.resolved === null) {
110568 continue;
110569 }
110570
110571 outReferenceMap.set(reference.identifier, reference);
110572 }
110573
110574 for (const childScope of scope.childScopes) {
110575 if (childScope.type !== "function") {
110576 createReferenceMap(childScope, outReferenceMap);
110577 }
110578 }
110579
110580 return outReferenceMap;
110581 }
110582 /**
110583 * Get `reference.writeExpr` of a given reference.
110584 * If it's the read reference of MemberExpression in LHS, returns RHS in order to address `a.b = await a`
110585 * @param {escope.Reference} reference The reference to get.
110586 * @returns {Expression|null} The `reference.writeExpr`.
110587 */
110588
110589
110590 function getWriteExpr(reference) {
110591 if (reference.writeExpr) {
110592 return reference.writeExpr;
110593 }
110594
110595 let node = reference.identifier;
110596
110597 while (node) {
110598 const t = node.parent.type;
110599
110600 if (t === "AssignmentExpression" && node.parent.left === node) {
110601 return node.parent.right;
110602 }
110603
110604 if (t === "MemberExpression" && node.parent.object === node) {
110605 node = node.parent;
110606 continue;
110607 }
110608
110609 break;
110610 }
110611
110612 return null;
110613 }
110614 /**
110615 * Checks if an expression is a variable that can only be observed within the given function.
110616 * @param {Variable|null} variable The variable to check
110617 * @param {boolean} isMemberAccess If `true` then this is a member access.
110618 * @returns {boolean} `true` if the variable is local to the given function, and is never referenced in a closure.
110619 */
110620
110621
110622 function isLocalVariableWithoutEscape(variable, isMemberAccess) {
110623 if (!variable) {
110624 return false; // A global variable which was not defined.
110625 } // If the reference is a property access and the variable is a parameter, it handles the variable is not local.
110626
110627
110628 if (isMemberAccess && variable.defs.some(d => d.type === "Parameter")) {
110629 return false;
110630 }
110631
110632 const functionScope = variable.scope.variableScope;
110633 return variable.references.every(reference => reference.from.variableScope === functionScope);
110634 }
110635 /**
110636 * Represents segment information.
110637 */
110638
110639
110640 class SegmentInfo {
110641 constructor() {
110642 this.info = new WeakMap();
110643 }
110644 /**
110645 * Initialize the segment information.
110646 * @param {PathSegment} segment The segment to initialize.
110647 * @returns {void}
110648 */
110649
110650
110651 initialize(segment) {
110652 const outdatedReadVariables = new Set();
110653 const freshReadVariables = new Set();
110654
110655 for (const prevSegment of segment.prevSegments) {
110656 const info = this.info.get(prevSegment);
110657
110658 if (info) {
110659 info.outdatedReadVariables.forEach(Set.prototype.add, outdatedReadVariables);
110660 info.freshReadVariables.forEach(Set.prototype.add, freshReadVariables);
110661 }
110662 }
110663
110664 this.info.set(segment, {
110665 outdatedReadVariables,
110666 freshReadVariables
110667 });
110668 }
110669 /**
110670 * Mark a given variable as read on given segments.
110671 * @param {PathSegment[]} segments The segments that it read the variable on.
110672 * @param {Variable} variable The variable to be read.
110673 * @returns {void}
110674 */
110675
110676
110677 markAsRead(segments, variable) {
110678 for (const segment of segments) {
110679 const info = this.info.get(segment);
110680
110681 if (info) {
110682 info.freshReadVariables.add(variable); // If a variable is freshly read again, then it's no more out-dated.
110683
110684 info.outdatedReadVariables.delete(variable);
110685 }
110686 }
110687 }
110688 /**
110689 * Move `freshReadVariables` to `outdatedReadVariables`.
110690 * @param {PathSegment[]} segments The segments to process.
110691 * @returns {void}
110692 */
110693
110694
110695 makeOutdated(segments) {
110696 for (const segment of segments) {
110697 const info = this.info.get(segment);
110698
110699 if (info) {
110700 info.freshReadVariables.forEach(Set.prototype.add, info.outdatedReadVariables);
110701 info.freshReadVariables.clear();
110702 }
110703 }
110704 }
110705 /**
110706 * Check if a given variable is outdated on the current segments.
110707 * @param {PathSegment[]} segments The current segments.
110708 * @param {Variable} variable The variable to check.
110709 * @returns {boolean} `true` if the variable is outdated on the segments.
110710 */
110711
110712
110713 isOutdated(segments, variable) {
110714 for (const segment of segments) {
110715 const info = this.info.get(segment);
110716
110717 if (info && info.outdatedReadVariables.has(variable)) {
110718 return true;
110719 }
110720 }
110721
110722 return false;
110723 }
110724
110725 } //------------------------------------------------------------------------------
110726 // Rule Definition
110727 //------------------------------------------------------------------------------
110728
110729
110730 module.exports = {
110731 meta: {
110732 type: "problem",
110733 docs: {
110734 description: "disallow assignments that can lead to race conditions due to usage of `await` or `yield`",
110735 recommended: false,
110736 url: "https://eslint.org/docs/rules/require-atomic-updates"
110737 },
110738 fixable: null,
110739 schema: [{
110740 type: "object",
110741 properties: {
110742 allowProperties: {
110743 type: "boolean",
110744 default: false
110745 }
110746 },
110747 additionalProperties: false
110748 }],
110749 messages: {
110750 nonAtomicUpdate: "Possible race condition: `{{value}}` might be reassigned based on an outdated value of `{{value}}`.",
110751 nonAtomicObjectUpdate: "Possible race condition: `{{value}}` might be assigned based on an outdated state of `{{object}}`."
110752 }
110753 },
110754
110755 create(context) {
110756 const allowProperties = !!context.options[0] && context.options[0].allowProperties;
110757 const sourceCode = context.getSourceCode();
110758 const assignmentReferences = new Map();
110759 const segmentInfo = new SegmentInfo();
110760 let stack = null;
110761 return {
110762 onCodePathStart(codePath) {
110763 const scope = context.getScope();
110764 const shouldVerify = scope.type === "function" && (scope.block.async || scope.block.generator);
110765 stack = {
110766 upper: stack,
110767 codePath,
110768 referenceMap: shouldVerify ? createReferenceMap(scope) : null
110769 };
110770 },
110771
110772 onCodePathEnd() {
110773 stack = stack.upper;
110774 },
110775
110776 // Initialize the segment information.
110777 onCodePathSegmentStart(segment) {
110778 segmentInfo.initialize(segment);
110779 },
110780
110781 // Handle references to prepare verification.
110782 Identifier(node) {
110783 const {
110784 codePath,
110785 referenceMap
110786 } = stack;
110787 const reference = referenceMap && referenceMap.get(node); // Ignore if this is not a valid variable reference.
110788
110789 if (!reference) {
110790 return;
110791 }
110792
110793 const variable = reference.resolved;
110794 const writeExpr = getWriteExpr(reference);
110795 const isMemberAccess = reference.identifier.parent.type === "MemberExpression"; // Add a fresh read variable.
110796
110797 if (reference.isRead() && !(writeExpr && writeExpr.parent.operator === "=")) {
110798 segmentInfo.markAsRead(codePath.currentSegments, variable);
110799 }
110800 /*
110801 * Register the variable to verify after ESLint traversed the `writeExpr` node
110802 * if this reference is an assignment to a variable which is referred from other closure.
110803 */
110804
110805
110806 if (writeExpr && writeExpr.parent.right === writeExpr && // ← exclude variable declarations.
110807 !isLocalVariableWithoutEscape(variable, isMemberAccess)) {
110808 let refs = assignmentReferences.get(writeExpr);
110809
110810 if (!refs) {
110811 refs = [];
110812 assignmentReferences.set(writeExpr, refs);
110813 }
110814
110815 refs.push(reference);
110816 }
110817 },
110818
110819 /*
110820 * Verify assignments.
110821 * If the reference exists in `outdatedReadVariables` list, report it.
110822 */
110823 ":expression:exit"(node) {
110824 const {
110825 codePath,
110826 referenceMap
110827 } = stack; // referenceMap exists if this is in a resumable function scope.
110828
110829 if (!referenceMap) {
110830 return;
110831 } // Mark the read variables on this code path as outdated.
110832
110833
110834 if (node.type === "AwaitExpression" || node.type === "YieldExpression") {
110835 segmentInfo.makeOutdated(codePath.currentSegments);
110836 } // Verify.
110837
110838
110839 const references = assignmentReferences.get(node);
110840
110841 if (references) {
110842 assignmentReferences.delete(node);
110843
110844 for (const reference of references) {
110845 const variable = reference.resolved;
110846
110847 if (segmentInfo.isOutdated(codePath.currentSegments, variable)) {
110848 if (node.parent.left === reference.identifier) {
110849 context.report({
110850 node: node.parent,
110851 messageId: "nonAtomicUpdate",
110852 data: {
110853 value: variable.name
110854 }
110855 });
110856 } else if (!allowProperties) {
110857 context.report({
110858 node: node.parent,
110859 messageId: "nonAtomicObjectUpdate",
110860 data: {
110861 value: sourceCode.getText(node.parent.left),
110862 object: variable.name
110863 }
110864 });
110865 }
110866 }
110867 }
110868 }
110869 }
110870
110871 };
110872 }
110873
110874 };
110875
110876 /***/ }),
110877 /* 818 */
110878 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
110879
110880 "use strict";
110881 /**
110882 * @fileoverview Rule to disallow async functions which have no `await` expression.
110883 * @author Toru Nagashima
110884 */
110885 //------------------------------------------------------------------------------
110886 // Requirements
110887 //------------------------------------------------------------------------------
110888
110889 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
110890 // Helpers
110891 //------------------------------------------------------------------------------
110892
110893 /**
110894 * Capitalize the 1st letter of the given text.
110895 * @param {string} text The text to capitalize.
110896 * @returns {string} The text that the 1st letter was capitalized.
110897 */
110898
110899
110900 function capitalizeFirstLetter(text) {
110901 return text[0].toUpperCase() + text.slice(1);
110902 } //------------------------------------------------------------------------------
110903 // Rule Definition
110904 //------------------------------------------------------------------------------
110905
110906
110907 module.exports = {
110908 meta: {
110909 type: "suggestion",
110910 docs: {
110911 description: "disallow async functions which have no `await` expression",
110912 recommended: false,
110913 url: "https://eslint.org/docs/rules/require-await"
110914 },
110915 schema: [],
110916 messages: {
110917 missingAwait: "{{name}} has no 'await' expression."
110918 }
110919 },
110920
110921 create(context) {
110922 const sourceCode = context.getSourceCode();
110923 let scopeInfo = null;
110924 /**
110925 * Push the scope info object to the stack.
110926 * @returns {void}
110927 */
110928
110929 function enterFunction() {
110930 scopeInfo = {
110931 upper: scopeInfo,
110932 hasAwait: false
110933 };
110934 }
110935 /**
110936 * Pop the top scope info object from the stack.
110937 * Also, it reports the function if needed.
110938 * @param {ASTNode} node The node to report.
110939 * @returns {void}
110940 */
110941
110942
110943 function exitFunction(node) {
110944 if (!node.generator && node.async && !scopeInfo.hasAwait && !astUtils.isEmptyFunction(node)) {
110945 context.report({
110946 node,
110947 loc: astUtils.getFunctionHeadLoc(node, sourceCode),
110948 messageId: "missingAwait",
110949 data: {
110950 name: capitalizeFirstLetter(astUtils.getFunctionNameWithKind(node))
110951 }
110952 });
110953 }
110954
110955 scopeInfo = scopeInfo.upper;
110956 }
110957
110958 return {
110959 FunctionDeclaration: enterFunction,
110960 FunctionExpression: enterFunction,
110961 ArrowFunctionExpression: enterFunction,
110962 "FunctionDeclaration:exit": exitFunction,
110963 "FunctionExpression:exit": exitFunction,
110964 "ArrowFunctionExpression:exit": exitFunction,
110965
110966 AwaitExpression() {
110967 if (!scopeInfo) {
110968 return;
110969 }
110970
110971 scopeInfo.hasAwait = true;
110972 },
110973
110974 ForOfStatement(node) {
110975 if (!scopeInfo) {
110976 return;
110977 }
110978
110979 if (node.await) {
110980 scopeInfo.hasAwait = true;
110981 }
110982 }
110983
110984 };
110985 }
110986
110987 };
110988
110989 /***/ }),
110990 /* 819 */
110991 /***/ ((module) => {
110992
110993 "use strict";
110994 /**
110995 * @fileoverview Rule to check for jsdoc presence.
110996 * @author Gyandeep Singh
110997 * @deprecated in ESLint v5.10.0
110998 */
110999
111000
111001 module.exports = {
111002 meta: {
111003 type: "suggestion",
111004 docs: {
111005 description: "require JSDoc comments",
111006 recommended: false,
111007 url: "https://eslint.org/docs/rules/require-jsdoc"
111008 },
111009 schema: [{
111010 type: "object",
111011 properties: {
111012 require: {
111013 type: "object",
111014 properties: {
111015 ClassDeclaration: {
111016 type: "boolean",
111017 default: false
111018 },
111019 MethodDefinition: {
111020 type: "boolean",
111021 default: false
111022 },
111023 FunctionDeclaration: {
111024 type: "boolean",
111025 default: true
111026 },
111027 ArrowFunctionExpression: {
111028 type: "boolean",
111029 default: false
111030 },
111031 FunctionExpression: {
111032 type: "boolean",
111033 default: false
111034 }
111035 },
111036 additionalProperties: false,
111037 default: {}
111038 }
111039 },
111040 additionalProperties: false
111041 }],
111042 deprecated: true,
111043 replacedBy: [],
111044 messages: {
111045 missingJSDocComment: "Missing JSDoc comment."
111046 }
111047 },
111048
111049 create(context) {
111050 const source = context.getSourceCode();
111051 const DEFAULT_OPTIONS = {
111052 FunctionDeclaration: true,
111053 MethodDefinition: false,
111054 ClassDeclaration: false,
111055 ArrowFunctionExpression: false,
111056 FunctionExpression: false
111057 };
111058 const options = Object.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require);
111059 /**
111060 * Report the error message
111061 * @param {ASTNode} node node to report
111062 * @returns {void}
111063 */
111064
111065 function report(node) {
111066 context.report({
111067 node,
111068 messageId: "missingJSDocComment"
111069 });
111070 }
111071 /**
111072 * Check if the jsdoc comment is present or not.
111073 * @param {ASTNode} node node to examine
111074 * @returns {void}
111075 */
111076
111077
111078 function checkJsDoc(node) {
111079 const jsdocComment = source.getJSDocComment(node);
111080
111081 if (!jsdocComment) {
111082 report(node);
111083 }
111084 }
111085
111086 return {
111087 FunctionDeclaration(node) {
111088 if (options.FunctionDeclaration) {
111089 checkJsDoc(node);
111090 }
111091 },
111092
111093 FunctionExpression(node) {
111094 if (options.MethodDefinition && node.parent.type === "MethodDefinition" || options.FunctionExpression && (node.parent.type === "VariableDeclarator" || node.parent.type === "Property" && node === node.parent.value)) {
111095 checkJsDoc(node);
111096 }
111097 },
111098
111099 ClassDeclaration(node) {
111100 if (options.ClassDeclaration) {
111101 checkJsDoc(node);
111102 }
111103 },
111104
111105 ArrowFunctionExpression(node) {
111106 if (options.ArrowFunctionExpression && node.parent.type === "VariableDeclarator") {
111107 checkJsDoc(node);
111108 }
111109 }
111110
111111 };
111112 }
111113
111114 };
111115
111116 /***/ }),
111117 /* 820 */
111118 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
111119
111120 "use strict";
111121 /**
111122 * @fileoverview Rule to enforce the use of `u` flag on RegExp.
111123 * @author Toru Nagashima
111124 */
111125 //------------------------------------------------------------------------------
111126 // Requirements
111127 //------------------------------------------------------------------------------
111128
111129 const {
111130 CALL,
111131 CONSTRUCT,
111132 ReferenceTracker,
111133 getStringIfConstant
111134 } = __webpack_require__(501); //------------------------------------------------------------------------------
111135 // Rule Definition
111136 //------------------------------------------------------------------------------
111137
111138
111139 module.exports = {
111140 meta: {
111141 type: "suggestion",
111142 docs: {
111143 description: "enforce the use of `u` flag on RegExp",
111144 recommended: false,
111145 url: "https://eslint.org/docs/rules/require-unicode-regexp"
111146 },
111147 messages: {
111148 requireUFlag: "Use the 'u' flag."
111149 },
111150 schema: []
111151 },
111152
111153 create(context) {
111154 return {
111155 "Literal[regex]"(node) {
111156 const flags = node.regex.flags || "";
111157
111158 if (!flags.includes("u")) {
111159 context.report({
111160 node,
111161 messageId: "requireUFlag"
111162 });
111163 }
111164 },
111165
111166 Program() {
111167 const scope = context.getScope();
111168 const tracker = new ReferenceTracker(scope);
111169 const trackMap = {
111170 RegExp: {
111171 [CALL]: true,
111172 [CONSTRUCT]: true
111173 }
111174 };
111175
111176 for (const {
111177 node
111178 } of tracker.iterateGlobalReferences(trackMap)) {
111179 const flagsNode = node.arguments[1];
111180 const flags = getStringIfConstant(flagsNode, scope);
111181
111182 if (!flagsNode || typeof flags === "string" && !flags.includes("u")) {
111183 context.report({
111184 node,
111185 messageId: "requireUFlag"
111186 });
111187 }
111188 }
111189 }
111190
111191 };
111192 }
111193
111194 };
111195
111196 /***/ }),
111197 /* 821 */
111198 /***/ ((module) => {
111199
111200 "use strict";
111201 /**
111202 * @fileoverview Rule to flag the generator functions that does not have yield.
111203 * @author Toru Nagashima
111204 */
111205 //------------------------------------------------------------------------------
111206 // Rule Definition
111207 //------------------------------------------------------------------------------
111208
111209 module.exports = {
111210 meta: {
111211 type: "suggestion",
111212 docs: {
111213 description: "require generator functions to contain `yield`",
111214 recommended: true,
111215 url: "https://eslint.org/docs/rules/require-yield"
111216 },
111217 schema: [],
111218 messages: {
111219 missingYield: "This generator function does not have 'yield'."
111220 }
111221 },
111222
111223 create(context) {
111224 const stack = [];
111225 /**
111226 * If the node is a generator function, start counting `yield` keywords.
111227 * @param {Node} node A function node to check.
111228 * @returns {void}
111229 */
111230
111231 function beginChecking(node) {
111232 if (node.generator) {
111233 stack.push(0);
111234 }
111235 }
111236 /**
111237 * If the node is a generator function, end counting `yield` keywords, then
111238 * reports result.
111239 * @param {Node} node A function node to check.
111240 * @returns {void}
111241 */
111242
111243
111244 function endChecking(node) {
111245 if (!node.generator) {
111246 return;
111247 }
111248
111249 const countYield = stack.pop();
111250
111251 if (countYield === 0 && node.body.body.length > 0) {
111252 context.report({
111253 node,
111254 messageId: "missingYield"
111255 });
111256 }
111257 }
111258
111259 return {
111260 FunctionDeclaration: beginChecking,
111261 "FunctionDeclaration:exit": endChecking,
111262 FunctionExpression: beginChecking,
111263 "FunctionExpression:exit": endChecking,
111264
111265 // Increases the count of `yield` keyword.
111266 YieldExpression() {
111267 /* istanbul ignore else */
111268 if (stack.length > 0) {
111269 stack[stack.length - 1] += 1;
111270 }
111271 }
111272
111273 };
111274 }
111275
111276 };
111277
111278 /***/ }),
111279 /* 822 */
111280 /***/ ((module) => {
111281
111282 "use strict";
111283 /**
111284 * @fileoverview Enforce spacing between rest and spread operators and their expressions.
111285 * @author Kai Cataldo
111286 */
111287 //------------------------------------------------------------------------------
111288 // Rule Definition
111289 //------------------------------------------------------------------------------
111290
111291 module.exports = {
111292 meta: {
111293 type: "layout",
111294 docs: {
111295 description: "enforce spacing between rest and spread operators and their expressions",
111296 recommended: false,
111297 url: "https://eslint.org/docs/rules/rest-spread-spacing"
111298 },
111299 fixable: "whitespace",
111300 schema: [{
111301 enum: ["always", "never"]
111302 }],
111303 messages: {
111304 unexpectedWhitespace: "Unexpected whitespace after {{type}} operator.",
111305 expectedWhitespace: "Expected whitespace after {{type}} operator."
111306 }
111307 },
111308
111309 create(context) {
111310 const sourceCode = context.getSourceCode(),
111311 alwaysSpace = context.options[0] === "always"; //--------------------------------------------------------------------------
111312 // Helpers
111313 //--------------------------------------------------------------------------
111314
111315 /**
111316 * Checks whitespace between rest/spread operators and their expressions
111317 * @param {ASTNode} node The node to check
111318 * @returns {void}
111319 */
111320
111321 function checkWhiteSpace(node) {
111322 const operator = sourceCode.getFirstToken(node),
111323 nextToken = sourceCode.getTokenAfter(operator),
111324 hasWhitespace = sourceCode.isSpaceBetweenTokens(operator, nextToken);
111325 let type;
111326
111327 switch (node.type) {
111328 case "SpreadElement":
111329 type = "spread";
111330
111331 if (node.parent.type === "ObjectExpression") {
111332 type += " property";
111333 }
111334
111335 break;
111336
111337 case "RestElement":
111338 type = "rest";
111339
111340 if (node.parent.type === "ObjectPattern") {
111341 type += " property";
111342 }
111343
111344 break;
111345
111346 case "ExperimentalSpreadProperty":
111347 type = "spread property";
111348 break;
111349
111350 case "ExperimentalRestProperty":
111351 type = "rest property";
111352 break;
111353
111354 default:
111355 return;
111356 }
111357
111358 if (alwaysSpace && !hasWhitespace) {
111359 context.report({
111360 node,
111361 loc: operator.loc,
111362 messageId: "expectedWhitespace",
111363 data: {
111364 type
111365 },
111366
111367 fix(fixer) {
111368 return fixer.replaceTextRange([operator.range[1], nextToken.range[0]], " ");
111369 }
111370
111371 });
111372 } else if (!alwaysSpace && hasWhitespace) {
111373 context.report({
111374 node,
111375 loc: {
111376 start: operator.loc.end,
111377 end: nextToken.loc.start
111378 },
111379 messageId: "unexpectedWhitespace",
111380 data: {
111381 type
111382 },
111383
111384 fix(fixer) {
111385 return fixer.removeRange([operator.range[1], nextToken.range[0]]);
111386 }
111387
111388 });
111389 }
111390 } //--------------------------------------------------------------------------
111391 // Public
111392 //--------------------------------------------------------------------------
111393
111394
111395 return {
111396 SpreadElement: checkWhiteSpace,
111397 RestElement: checkWhiteSpace,
111398 ExperimentalSpreadProperty: checkWhiteSpace,
111399 ExperimentalRestProperty: checkWhiteSpace
111400 };
111401 }
111402
111403 };
111404
111405 /***/ }),
111406 /* 823 */
111407 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
111408
111409 "use strict";
111410 /**
111411 * @fileoverview Rule to flag missing semicolons.
111412 * @author Nicholas C. Zakas
111413 */
111414 //------------------------------------------------------------------------------
111415 // Requirements
111416 //------------------------------------------------------------------------------
111417
111418 const FixTracker = __webpack_require__(662);
111419
111420 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
111421 // Rule Definition
111422 //------------------------------------------------------------------------------
111423
111424
111425 module.exports = {
111426 meta: {
111427 type: "layout",
111428 docs: {
111429 description: "require or disallow semicolons instead of ASI",
111430 recommended: false,
111431 url: "https://eslint.org/docs/rules/semi"
111432 },
111433 fixable: "code",
111434 schema: {
111435 anyOf: [{
111436 type: "array",
111437 items: [{
111438 enum: ["never"]
111439 }, {
111440 type: "object",
111441 properties: {
111442 beforeStatementContinuationChars: {
111443 enum: ["always", "any", "never"]
111444 }
111445 },
111446 additionalProperties: false
111447 }],
111448 minItems: 0,
111449 maxItems: 2
111450 }, {
111451 type: "array",
111452 items: [{
111453 enum: ["always"]
111454 }, {
111455 type: "object",
111456 properties: {
111457 omitLastInOneLineBlock: {
111458 type: "boolean"
111459 }
111460 },
111461 additionalProperties: false
111462 }],
111463 minItems: 0,
111464 maxItems: 2
111465 }]
111466 },
111467 messages: {
111468 missingSemi: "Missing semicolon.",
111469 extraSemi: "Extra semicolon."
111470 }
111471 },
111472
111473 create(context) {
111474 const OPT_OUT_PATTERN = /^[-[(/+`]/u; // One of [(/+-`
111475
111476 const unsafeClassFieldNames = new Set(["get", "set", "static"]);
111477 const unsafeClassFieldFollowers = new Set(["*", "in", "instanceof"]);
111478 const options = context.options[1];
111479 const never = context.options[0] === "never";
111480 const exceptOneLine = Boolean(options && options.omitLastInOneLineBlock);
111481 const beforeStatementContinuationChars = options && options.beforeStatementContinuationChars || "any";
111482 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
111483 // Helpers
111484 //--------------------------------------------------------------------------
111485
111486 /**
111487 * Reports a semicolon error with appropriate location and message.
111488 * @param {ASTNode} node The node with an extra or missing semicolon.
111489 * @param {boolean} missing True if the semicolon is missing.
111490 * @returns {void}
111491 */
111492
111493 function report(node, missing) {
111494 const lastToken = sourceCode.getLastToken(node);
111495 let messageId, fix, loc;
111496
111497 if (!missing) {
111498 messageId = "missingSemi";
111499 loc = {
111500 start: lastToken.loc.end,
111501 end: astUtils.getNextLocation(sourceCode, lastToken.loc.end)
111502 };
111503
111504 fix = function (fixer) {
111505 return fixer.insertTextAfter(lastToken, ";");
111506 };
111507 } else {
111508 messageId = "extraSemi";
111509 loc = lastToken.loc;
111510
111511 fix = function (fixer) {
111512 /*
111513 * Expand the replacement range to include the surrounding
111514 * tokens to avoid conflicting with no-extra-semi.
111515 * https://github.com/eslint/eslint/issues/7928
111516 */
111517 return new FixTracker(fixer, sourceCode).retainSurroundingTokens(lastToken).remove(lastToken);
111518 };
111519 }
111520
111521 context.report({
111522 node,
111523 loc,
111524 messageId,
111525 fix
111526 });
111527 }
111528 /**
111529 * Check whether a given semicolon token is redundant.
111530 * @param {Token} semiToken A semicolon token to check.
111531 * @returns {boolean} `true` if the next token is `;` or `}`.
111532 */
111533
111534
111535 function isRedundantSemi(semiToken) {
111536 const nextToken = sourceCode.getTokenAfter(semiToken);
111537 return !nextToken || astUtils.isClosingBraceToken(nextToken) || astUtils.isSemicolonToken(nextToken);
111538 }
111539 /**
111540 * Check whether a given token is the closing brace of an arrow function.
111541 * @param {Token} lastToken A token to check.
111542 * @returns {boolean} `true` if the token is the closing brace of an arrow function.
111543 */
111544
111545
111546 function isEndOfArrowBlock(lastToken) {
111547 if (!astUtils.isClosingBraceToken(lastToken)) {
111548 return false;
111549 }
111550
111551 const node = sourceCode.getNodeByRangeIndex(lastToken.range[0]);
111552 return node.type === "BlockStatement" && node.parent.type === "ArrowFunctionExpression";
111553 }
111554 /**
111555 * Checks if a given PropertyDefinition node followed by a semicolon
111556 * can safely remove that semicolon. It is not to safe to remove if
111557 * the class field name is "get", "set", or "static", or if
111558 * followed by a generator method.
111559 * @param {ASTNode} node The node to check.
111560 * @returns {boolean} `true` if the node cannot have the semicolon
111561 * removed.
111562 */
111563
111564
111565 function maybeClassFieldAsiHazard(node) {
111566 if (node.type !== "PropertyDefinition") {
111567 return false;
111568 }
111569 /*
111570 * Computed property names and non-identifiers are always safe
111571 * as they can be distinguished from keywords easily.
111572 */
111573
111574
111575 const needsNameCheck = !node.computed && node.key.type === "Identifier";
111576 /*
111577 * Certain names are problematic unless they also have a
111578 * a way to distinguish between keywords and property
111579 * names.
111580 */
111581
111582 if (needsNameCheck && unsafeClassFieldNames.has(node.key.name)) {
111583 /*
111584 * Special case: If the field name is `static`,
111585 * it is only valid if the field is marked as static,
111586 * so "static static" is okay but "static" is not.
111587 */
111588 const isStaticStatic = node.static && node.key.name === "static";
111589 /*
111590 * For other unsafe names, we only care if there is no
111591 * initializer. No initializer = hazard.
111592 */
111593
111594 if (!isStaticStatic && !node.value) {
111595 return true;
111596 }
111597 }
111598
111599 const followingToken = sourceCode.getTokenAfter(node);
111600 return unsafeClassFieldFollowers.has(followingToken.value);
111601 }
111602 /**
111603 * Check whether a given node is on the same line with the next token.
111604 * @param {Node} node A statement node to check.
111605 * @returns {boolean} `true` if the node is on the same line with the next token.
111606 */
111607
111608
111609 function isOnSameLineWithNextToken(node) {
111610 const prevToken = sourceCode.getLastToken(node, 1);
111611 const nextToken = sourceCode.getTokenAfter(node);
111612 return !!nextToken && astUtils.isTokenOnSameLine(prevToken, nextToken);
111613 }
111614 /**
111615 * Check whether a given node can connect the next line if the next line is unreliable.
111616 * @param {Node} node A statement node to check.
111617 * @returns {boolean} `true` if the node can connect the next line.
111618 */
111619
111620
111621 function maybeAsiHazardAfter(node) {
111622 const t = node.type;
111623
111624 if (t === "DoWhileStatement" || t === "BreakStatement" || t === "ContinueStatement" || t === "DebuggerStatement" || t === "ImportDeclaration" || t === "ExportAllDeclaration") {
111625 return false;
111626 }
111627
111628 if (t === "ReturnStatement") {
111629 return Boolean(node.argument);
111630 }
111631
111632 if (t === "ExportNamedDeclaration") {
111633 return Boolean(node.declaration);
111634 }
111635
111636 if (isEndOfArrowBlock(sourceCode.getLastToken(node, 1))) {
111637 return false;
111638 }
111639
111640 return true;
111641 }
111642 /**
111643 * Check whether a given token can connect the previous statement.
111644 * @param {Token} token A token to check.
111645 * @returns {boolean} `true` if the token is one of `[`, `(`, `/`, `+`, `-`, ```, `++`, and `--`.
111646 */
111647
111648
111649 function maybeAsiHazardBefore(token) {
111650 return Boolean(token) && OPT_OUT_PATTERN.test(token.value) && token.value !== "++" && token.value !== "--";
111651 }
111652 /**
111653 * Check if the semicolon of a given node is unnecessary, only true if:
111654 * - next token is a valid statement divider (`;` or `}`).
111655 * - next token is on a new line and the node is not connectable to the new line.
111656 * @param {Node} node A statement node to check.
111657 * @returns {boolean} whether the semicolon is unnecessary.
111658 */
111659
111660
111661 function canRemoveSemicolon(node) {
111662 if (isRedundantSemi(sourceCode.getLastToken(node))) {
111663 return true; // `;;` or `;}`
111664 }
111665
111666 if (maybeClassFieldAsiHazard(node)) {
111667 return false;
111668 }
111669
111670 if (isOnSameLineWithNextToken(node)) {
111671 return false; // One liner.
111672 } // continuation characters should not apply to class fields
111673
111674
111675 if (node.type !== "PropertyDefinition" && beforeStatementContinuationChars === "never" && !maybeAsiHazardAfter(node)) {
111676 return true; // ASI works. This statement doesn't connect to the next.
111677 }
111678
111679 if (!maybeAsiHazardBefore(sourceCode.getTokenAfter(node))) {
111680 return true; // ASI works. The next token doesn't connect to this statement.
111681 }
111682
111683 return false;
111684 }
111685 /**
111686 * Checks a node to see if it's the last item in a one-liner block.
111687 * Block is any `BlockStatement` or `StaticBlock` node. Block is a one-liner if its
111688 * braces (and consequently everything between them) are on the same line.
111689 * @param {ASTNode} node The node to check.
111690 * @returns {boolean} whether the node is the last item in a one-liner block.
111691 */
111692
111693
111694 function isLastInOneLinerBlock(node) {
111695 const parent = node.parent;
111696 const nextToken = sourceCode.getTokenAfter(node);
111697
111698 if (!nextToken || nextToken.value !== "}") {
111699 return false;
111700 }
111701
111702 if (parent.type === "BlockStatement") {
111703 return parent.loc.start.line === parent.loc.end.line;
111704 }
111705
111706 if (parent.type === "StaticBlock") {
111707 const openingBrace = sourceCode.getFirstToken(parent, {
111708 skip: 1
111709 }); // skip the `static` token
111710
111711 return openingBrace.loc.start.line === parent.loc.end.line;
111712 }
111713
111714 return false;
111715 }
111716 /**
111717 * Checks a node to see if it's followed by a semicolon.
111718 * @param {ASTNode} node The node to check.
111719 * @returns {void}
111720 */
111721
111722
111723 function checkForSemicolon(node) {
111724 const isSemi = astUtils.isSemicolonToken(sourceCode.getLastToken(node));
111725
111726 if (never) {
111727 if (isSemi && canRemoveSemicolon(node)) {
111728 report(node, true);
111729 } else if (!isSemi && beforeStatementContinuationChars === "always" && node.type !== "PropertyDefinition" && maybeAsiHazardBefore(sourceCode.getTokenAfter(node))) {
111730 report(node);
111731 }
111732 } else {
111733 const oneLinerBlock = exceptOneLine && isLastInOneLinerBlock(node);
111734
111735 if (isSemi && oneLinerBlock) {
111736 report(node, true);
111737 } else if (!isSemi && !oneLinerBlock) {
111738 report(node);
111739 }
111740 }
111741 }
111742 /**
111743 * Checks to see if there's a semicolon after a variable declaration.
111744 * @param {ASTNode} node The node to check.
111745 * @returns {void}
111746 */
111747
111748
111749 function checkForSemicolonForVariableDeclaration(node) {
111750 const parent = node.parent;
111751
111752 if ((parent.type !== "ForStatement" || parent.init !== node) && (!/^For(?:In|Of)Statement/u.test(parent.type) || parent.left !== node)) {
111753 checkForSemicolon(node);
111754 }
111755 } //--------------------------------------------------------------------------
111756 // Public API
111757 //--------------------------------------------------------------------------
111758
111759
111760 return {
111761 VariableDeclaration: checkForSemicolonForVariableDeclaration,
111762 ExpressionStatement: checkForSemicolon,
111763 ReturnStatement: checkForSemicolon,
111764 ThrowStatement: checkForSemicolon,
111765 DoWhileStatement: checkForSemicolon,
111766 DebuggerStatement: checkForSemicolon,
111767 BreakStatement: checkForSemicolon,
111768 ContinueStatement: checkForSemicolon,
111769 ImportDeclaration: checkForSemicolon,
111770 ExportAllDeclaration: checkForSemicolon,
111771
111772 ExportNamedDeclaration(node) {
111773 if (!node.declaration) {
111774 checkForSemicolon(node);
111775 }
111776 },
111777
111778 ExportDefaultDeclaration(node) {
111779 if (!/(?:Class|Function)Declaration/u.test(node.declaration.type)) {
111780 checkForSemicolon(node);
111781 }
111782 },
111783
111784 PropertyDefinition: checkForSemicolon
111785 };
111786 }
111787
111788 };
111789
111790 /***/ }),
111791 /* 824 */
111792 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
111793
111794 "use strict";
111795 /**
111796 * @fileoverview Validates spacing before and after semicolon
111797 * @author Mathias Schreck
111798 */
111799
111800
111801 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
111802 // Rule Definition
111803 //------------------------------------------------------------------------------
111804
111805
111806 module.exports = {
111807 meta: {
111808 type: "layout",
111809 docs: {
111810 description: "enforce consistent spacing before and after semicolons",
111811 recommended: false,
111812 url: "https://eslint.org/docs/rules/semi-spacing"
111813 },
111814 fixable: "whitespace",
111815 schema: [{
111816 type: "object",
111817 properties: {
111818 before: {
111819 type: "boolean",
111820 default: false
111821 },
111822 after: {
111823 type: "boolean",
111824 default: true
111825 }
111826 },
111827 additionalProperties: false
111828 }],
111829 messages: {
111830 unexpectedWhitespaceBefore: "Unexpected whitespace before semicolon.",
111831 unexpectedWhitespaceAfter: "Unexpected whitespace after semicolon.",
111832 missingWhitespaceBefore: "Missing whitespace before semicolon.",
111833 missingWhitespaceAfter: "Missing whitespace after semicolon."
111834 }
111835 },
111836
111837 create(context) {
111838 const config = context.options[0],
111839 sourceCode = context.getSourceCode();
111840 let requireSpaceBefore = false,
111841 requireSpaceAfter = true;
111842
111843 if (typeof config === "object") {
111844 requireSpaceBefore = config.before;
111845 requireSpaceAfter = config.after;
111846 }
111847 /**
111848 * Checks if a given token has leading whitespace.
111849 * @param {Object} token The token to check.
111850 * @returns {boolean} True if the given token has leading space, false if not.
111851 */
111852
111853
111854 function hasLeadingSpace(token) {
111855 const tokenBefore = sourceCode.getTokenBefore(token);
111856 return tokenBefore && astUtils.isTokenOnSameLine(tokenBefore, token) && sourceCode.isSpaceBetweenTokens(tokenBefore, token);
111857 }
111858 /**
111859 * Checks if a given token has trailing whitespace.
111860 * @param {Object} token The token to check.
111861 * @returns {boolean} True if the given token has trailing space, false if not.
111862 */
111863
111864
111865 function hasTrailingSpace(token) {
111866 const tokenAfter = sourceCode.getTokenAfter(token);
111867 return tokenAfter && astUtils.isTokenOnSameLine(token, tokenAfter) && sourceCode.isSpaceBetweenTokens(token, tokenAfter);
111868 }
111869 /**
111870 * Checks if the given token is the last token in its line.
111871 * @param {Token} token The token to check.
111872 * @returns {boolean} Whether or not the token is the last in its line.
111873 */
111874
111875
111876 function isLastTokenInCurrentLine(token) {
111877 const tokenAfter = sourceCode.getTokenAfter(token);
111878 return !(tokenAfter && astUtils.isTokenOnSameLine(token, tokenAfter));
111879 }
111880 /**
111881 * Checks if the given token is the first token in its line
111882 * @param {Token} token The token to check.
111883 * @returns {boolean} Whether or not the token is the first in its line.
111884 */
111885
111886
111887 function isFirstTokenInCurrentLine(token) {
111888 const tokenBefore = sourceCode.getTokenBefore(token);
111889 return !(tokenBefore && astUtils.isTokenOnSameLine(token, tokenBefore));
111890 }
111891 /**
111892 * Checks if the next token of a given token is a closing parenthesis.
111893 * @param {Token} token The token to check.
111894 * @returns {boolean} Whether or not the next token of a given token is a closing parenthesis.
111895 */
111896
111897
111898 function isBeforeClosingParen(token) {
111899 const nextToken = sourceCode.getTokenAfter(token);
111900 return nextToken && astUtils.isClosingBraceToken(nextToken) || astUtils.isClosingParenToken(nextToken);
111901 }
111902 /**
111903 * Report location example :
111904 *
111905 * for unexpected space `before`
111906 *
111907 * var a = 'b' ;
111908 * ^^^
111909 *
111910 * for unexpected space `after`
111911 *
111912 * var a = 'b'; c = 10;
111913 * ^^
111914 *
111915 * Reports if the given token has invalid spacing.
111916 * @param {Token} token The semicolon token to check.
111917 * @param {ASTNode} node The corresponding node of the token.
111918 * @returns {void}
111919 */
111920
111921
111922 function checkSemicolonSpacing(token, node) {
111923 if (astUtils.isSemicolonToken(token)) {
111924 if (hasLeadingSpace(token)) {
111925 if (!requireSpaceBefore) {
111926 const tokenBefore = sourceCode.getTokenBefore(token);
111927 const loc = {
111928 start: tokenBefore.loc.end,
111929 end: token.loc.start
111930 };
111931 context.report({
111932 node,
111933 loc,
111934 messageId: "unexpectedWhitespaceBefore",
111935
111936 fix(fixer) {
111937 return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
111938 }
111939
111940 });
111941 }
111942 } else {
111943 if (requireSpaceBefore) {
111944 const loc = token.loc;
111945 context.report({
111946 node,
111947 loc,
111948 messageId: "missingWhitespaceBefore",
111949
111950 fix(fixer) {
111951 return fixer.insertTextBefore(token, " ");
111952 }
111953
111954 });
111955 }
111956 }
111957
111958 if (!isFirstTokenInCurrentLine(token) && !isLastTokenInCurrentLine(token) && !isBeforeClosingParen(token)) {
111959 if (hasTrailingSpace(token)) {
111960 if (!requireSpaceAfter) {
111961 const tokenAfter = sourceCode.getTokenAfter(token);
111962 const loc = {
111963 start: token.loc.end,
111964 end: tokenAfter.loc.start
111965 };
111966 context.report({
111967 node,
111968 loc,
111969 messageId: "unexpectedWhitespaceAfter",
111970
111971 fix(fixer) {
111972 return fixer.removeRange([token.range[1], tokenAfter.range[0]]);
111973 }
111974
111975 });
111976 }
111977 } else {
111978 if (requireSpaceAfter) {
111979 const loc = token.loc;
111980 context.report({
111981 node,
111982 loc,
111983 messageId: "missingWhitespaceAfter",
111984
111985 fix(fixer) {
111986 return fixer.insertTextAfter(token, " ");
111987 }
111988
111989 });
111990 }
111991 }
111992 }
111993 }
111994 }
111995 /**
111996 * Checks the spacing of the semicolon with the assumption that the last token is the semicolon.
111997 * @param {ASTNode} node The node to check.
111998 * @returns {void}
111999 */
112000
112001
112002 function checkNode(node) {
112003 const token = sourceCode.getLastToken(node);
112004 checkSemicolonSpacing(token, node);
112005 }
112006
112007 return {
112008 VariableDeclaration: checkNode,
112009 ExpressionStatement: checkNode,
112010 BreakStatement: checkNode,
112011 ContinueStatement: checkNode,
112012 DebuggerStatement: checkNode,
112013 DoWhileStatement: checkNode,
112014 ReturnStatement: checkNode,
112015 ThrowStatement: checkNode,
112016 ImportDeclaration: checkNode,
112017 ExportNamedDeclaration: checkNode,
112018 ExportAllDeclaration: checkNode,
112019 ExportDefaultDeclaration: checkNode,
112020
112021 ForStatement(node) {
112022 if (node.init) {
112023 checkSemicolonSpacing(sourceCode.getTokenAfter(node.init), node);
112024 }
112025
112026 if (node.test) {
112027 checkSemicolonSpacing(sourceCode.getTokenAfter(node.test), node);
112028 }
112029 },
112030
112031 PropertyDefinition: checkNode
112032 };
112033 }
112034
112035 };
112036
112037 /***/ }),
112038 /* 825 */
112039 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
112040
112041 "use strict";
112042 /**
112043 * @fileoverview Rule to enforce location of semicolons.
112044 * @author Toru Nagashima
112045 */
112046 //------------------------------------------------------------------------------
112047 // Requirements
112048 //------------------------------------------------------------------------------
112049
112050 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
112051 // Rule Definition
112052 //------------------------------------------------------------------------------
112053
112054
112055 const SELECTOR = ["BreakStatement", "ContinueStatement", "DebuggerStatement", "DoWhileStatement", "ExportAllDeclaration", "ExportDefaultDeclaration", "ExportNamedDeclaration", "ExpressionStatement", "ImportDeclaration", "ReturnStatement", "ThrowStatement", "VariableDeclaration", "PropertyDefinition"].join(",");
112056 /**
112057 * Get the child node list of a given node.
112058 * This returns `BlockStatement#body`, `StaticBlock#body`, `Program#body`,
112059 * `ClassBody#body`, or `SwitchCase#consequent`.
112060 * This is used to check whether a node is the first/last child.
112061 * @param {Node} node A node to get child node list.
112062 * @returns {Node[]|null} The child node list.
112063 */
112064
112065 function getChildren(node) {
112066 const t = node.type;
112067
112068 if (t === "BlockStatement" || t === "StaticBlock" || t === "Program" || t === "ClassBody") {
112069 return node.body;
112070 }
112071
112072 if (t === "SwitchCase") {
112073 return node.consequent;
112074 }
112075
112076 return null;
112077 }
112078 /**
112079 * Check whether a given node is the last statement in the parent block.
112080 * @param {Node} node A node to check.
112081 * @returns {boolean} `true` if the node is the last statement in the parent block.
112082 */
112083
112084
112085 function isLastChild(node) {
112086 const t = node.parent.type;
112087
112088 if (t === "IfStatement" && node.parent.consequent === node && node.parent.alternate) {
112089 // before `else` keyword.
112090 return true;
112091 }
112092
112093 if (t === "DoWhileStatement") {
112094 // before `while` keyword.
112095 return true;
112096 }
112097
112098 const nodeList = getChildren(node.parent);
112099 return nodeList !== null && nodeList[nodeList.length - 1] === node; // before `}` or etc.
112100 }
112101
112102 module.exports = {
112103 meta: {
112104 type: "layout",
112105 docs: {
112106 description: "enforce location of semicolons",
112107 recommended: false,
112108 url: "https://eslint.org/docs/rules/semi-style"
112109 },
112110 schema: [{
112111 enum: ["last", "first"]
112112 }],
112113 fixable: "whitespace",
112114 messages: {
112115 expectedSemiColon: "Expected this semicolon to be at {{pos}}."
112116 }
112117 },
112118
112119 create(context) {
112120 const sourceCode = context.getSourceCode();
112121 const option = context.options[0] || "last";
112122 /**
112123 * Check the given semicolon token.
112124 * @param {Token} semiToken The semicolon token to check.
112125 * @param {"first"|"last"} expected The expected location to check.
112126 * @returns {void}
112127 */
112128
112129 function check(semiToken, expected) {
112130 const prevToken = sourceCode.getTokenBefore(semiToken);
112131 const nextToken = sourceCode.getTokenAfter(semiToken);
112132 const prevIsSameLine = !prevToken || astUtils.isTokenOnSameLine(prevToken, semiToken);
112133 const nextIsSameLine = !nextToken || astUtils.isTokenOnSameLine(semiToken, nextToken);
112134
112135 if (expected === "last" && !prevIsSameLine || expected === "first" && !nextIsSameLine) {
112136 context.report({
112137 loc: semiToken.loc,
112138 messageId: "expectedSemiColon",
112139 data: {
112140 pos: expected === "last" ? "the end of the previous line" : "the beginning of the next line"
112141 },
112142
112143 fix(fixer) {
112144 if (prevToken && nextToken && sourceCode.commentsExistBetween(prevToken, nextToken)) {
112145 return null;
112146 }
112147
112148 const start = prevToken ? prevToken.range[1] : semiToken.range[0];
112149 const end = nextToken ? nextToken.range[0] : semiToken.range[1];
112150 const text = expected === "last" ? ";\n" : "\n;";
112151 return fixer.replaceTextRange([start, end], text);
112152 }
112153
112154 });
112155 }
112156 }
112157
112158 return {
112159 [SELECTOR](node) {
112160 if (option === "first" && isLastChild(node)) {
112161 return;
112162 }
112163
112164 const lastToken = sourceCode.getLastToken(node);
112165
112166 if (astUtils.isSemicolonToken(lastToken)) {
112167 check(lastToken, option);
112168 }
112169 },
112170
112171 ForStatement(node) {
112172 const firstSemi = node.init && sourceCode.getTokenAfter(node.init, astUtils.isSemicolonToken);
112173 const secondSemi = node.test && sourceCode.getTokenAfter(node.test, astUtils.isSemicolonToken);
112174
112175 if (firstSemi) {
112176 check(firstSemi, "last");
112177 }
112178
112179 if (secondSemi) {
112180 check(secondSemi, "last");
112181 }
112182 }
112183
112184 };
112185 }
112186
112187 };
112188
112189 /***/ }),
112190 /* 826 */
112191 /***/ ((module) => {
112192
112193 "use strict";
112194 /**
112195 * @fileoverview Rule to require sorting of import declarations
112196 * @author Christian Schuller
112197 */
112198 //------------------------------------------------------------------------------
112199 // Rule Definition
112200 //------------------------------------------------------------------------------
112201
112202 module.exports = {
112203 meta: {
112204 type: "suggestion",
112205 docs: {
112206 description: "enforce sorted import declarations within modules",
112207 recommended: false,
112208 url: "https://eslint.org/docs/rules/sort-imports"
112209 },
112210 schema: [{
112211 type: "object",
112212 properties: {
112213 ignoreCase: {
112214 type: "boolean",
112215 default: false
112216 },
112217 memberSyntaxSortOrder: {
112218 type: "array",
112219 items: {
112220 enum: ["none", "all", "multiple", "single"]
112221 },
112222 uniqueItems: true,
112223 minItems: 4,
112224 maxItems: 4
112225 },
112226 ignoreDeclarationSort: {
112227 type: "boolean",
112228 default: false
112229 },
112230 ignoreMemberSort: {
112231 type: "boolean",
112232 default: false
112233 },
112234 allowSeparatedGroups: {
112235 type: "boolean",
112236 default: false
112237 }
112238 },
112239 additionalProperties: false
112240 }],
112241 fixable: "code",
112242 messages: {
112243 sortImportsAlphabetically: "Imports should be sorted alphabetically.",
112244 sortMembersAlphabetically: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.",
112245 unexpectedSyntaxOrder: "Expected '{{syntaxA}}' syntax before '{{syntaxB}}' syntax."
112246 }
112247 },
112248
112249 create(context) {
112250 const configuration = context.options[0] || {},
112251 ignoreCase = configuration.ignoreCase || false,
112252 ignoreDeclarationSort = configuration.ignoreDeclarationSort || false,
112253 ignoreMemberSort = configuration.ignoreMemberSort || false,
112254 memberSyntaxSortOrder = configuration.memberSyntaxSortOrder || ["none", "all", "multiple", "single"],
112255 allowSeparatedGroups = configuration.allowSeparatedGroups || false,
112256 sourceCode = context.getSourceCode();
112257 let previousDeclaration = null;
112258 /**
112259 * Gets the used member syntax style.
112260 *
112261 * import "my-module.js" --> none
112262 * import * as myModule from "my-module.js" --> all
112263 * import {myMember} from "my-module.js" --> single
112264 * import {foo, bar} from "my-module.js" --> multiple
112265 * @param {ASTNode} node the ImportDeclaration node.
112266 * @returns {string} used member parameter style, ["all", "multiple", "single"]
112267 */
112268
112269 function usedMemberSyntax(node) {
112270 if (node.specifiers.length === 0) {
112271 return "none";
112272 }
112273
112274 if (node.specifiers[0].type === "ImportNamespaceSpecifier") {
112275 return "all";
112276 }
112277
112278 if (node.specifiers.length === 1) {
112279 return "single";
112280 }
112281
112282 return "multiple";
112283 }
112284 /**
112285 * Gets the group by member parameter index for given declaration.
112286 * @param {ASTNode} node the ImportDeclaration node.
112287 * @returns {number} the declaration group by member index.
112288 */
112289
112290
112291 function getMemberParameterGroupIndex(node) {
112292 return memberSyntaxSortOrder.indexOf(usedMemberSyntax(node));
112293 }
112294 /**
112295 * Gets the local name of the first imported module.
112296 * @param {ASTNode} node the ImportDeclaration node.
112297 * @returns {?string} the local name of the first imported module.
112298 */
112299
112300
112301 function getFirstLocalMemberName(node) {
112302 if (node.specifiers[0]) {
112303 return node.specifiers[0].local.name;
112304 }
112305
112306 return null;
112307 }
112308 /**
112309 * Calculates number of lines between two nodes. It is assumed that the given `left` node appears before
112310 * the given `right` node in the source code. Lines are counted from the end of the `left` node till the
112311 * start of the `right` node. If the given nodes are on the same line, it returns `0`, same as if they were
112312 * on two consecutive lines.
112313 * @param {ASTNode} left node that appears before the given `right` node.
112314 * @param {ASTNode} right node that appears after the given `left` node.
112315 * @returns {number} number of lines between nodes.
112316 */
112317
112318
112319 function getNumberOfLinesBetween(left, right) {
112320 return Math.max(right.loc.start.line - left.loc.end.line - 1, 0);
112321 }
112322
112323 return {
112324 ImportDeclaration(node) {
112325 if (!ignoreDeclarationSort) {
112326 if (previousDeclaration && allowSeparatedGroups && getNumberOfLinesBetween(previousDeclaration, node) > 0) {
112327 // reset declaration sort
112328 previousDeclaration = null;
112329 }
112330
112331 if (previousDeclaration) {
112332 const currentMemberSyntaxGroupIndex = getMemberParameterGroupIndex(node),
112333 previousMemberSyntaxGroupIndex = getMemberParameterGroupIndex(previousDeclaration);
112334 let currentLocalMemberName = getFirstLocalMemberName(node),
112335 previousLocalMemberName = getFirstLocalMemberName(previousDeclaration);
112336
112337 if (ignoreCase) {
112338 previousLocalMemberName = previousLocalMemberName && previousLocalMemberName.toLowerCase();
112339 currentLocalMemberName = currentLocalMemberName && currentLocalMemberName.toLowerCase();
112340 }
112341 /*
112342 * When the current declaration uses a different member syntax,
112343 * then check if the ordering is correct.
112344 * Otherwise, make a default string compare (like rule sort-vars to be consistent) of the first used local member name.
112345 */
112346
112347
112348 if (currentMemberSyntaxGroupIndex !== previousMemberSyntaxGroupIndex) {
112349 if (currentMemberSyntaxGroupIndex < previousMemberSyntaxGroupIndex) {
112350 context.report({
112351 node,
112352 messageId: "unexpectedSyntaxOrder",
112353 data: {
112354 syntaxA: memberSyntaxSortOrder[currentMemberSyntaxGroupIndex],
112355 syntaxB: memberSyntaxSortOrder[previousMemberSyntaxGroupIndex]
112356 }
112357 });
112358 }
112359 } else {
112360 if (previousLocalMemberName && currentLocalMemberName && currentLocalMemberName < previousLocalMemberName) {
112361 context.report({
112362 node,
112363 messageId: "sortImportsAlphabetically"
112364 });
112365 }
112366 }
112367 }
112368
112369 previousDeclaration = node;
112370 }
112371
112372 if (!ignoreMemberSort) {
112373 const importSpecifiers = node.specifiers.filter(specifier => specifier.type === "ImportSpecifier");
112374 const getSortableName = ignoreCase ? specifier => specifier.local.name.toLowerCase() : specifier => specifier.local.name;
112375 const firstUnsortedIndex = importSpecifiers.map(getSortableName).findIndex((name, index, array) => array[index - 1] > name);
112376
112377 if (firstUnsortedIndex !== -1) {
112378 context.report({
112379 node: importSpecifiers[firstUnsortedIndex],
112380 messageId: "sortMembersAlphabetically",
112381 data: {
112382 memberName: importSpecifiers[firstUnsortedIndex].local.name
112383 },
112384
112385 fix(fixer) {
112386 if (importSpecifiers.some(specifier => sourceCode.getCommentsBefore(specifier).length || sourceCode.getCommentsAfter(specifier).length)) {
112387 // If there are comments in the ImportSpecifier list, don't rearrange the specifiers.
112388 return null;
112389 }
112390
112391 return fixer.replaceTextRange([importSpecifiers[0].range[0], importSpecifiers[importSpecifiers.length - 1].range[1]], importSpecifiers // Clone the importSpecifiers array to avoid mutating it
112392 .slice() // Sort the array into the desired order
112393 .sort((specifierA, specifierB) => {
112394 const aName = getSortableName(specifierA);
112395 const bName = getSortableName(specifierB);
112396 return aName > bName ? 1 : -1;
112397 }) // Build a string out of the sorted list of import specifiers and the text between the originals
112398 .reduce((sourceText, specifier, index) => {
112399 const textAfterSpecifier = index === importSpecifiers.length - 1 ? "" : sourceCode.getText().slice(importSpecifiers[index].range[1], importSpecifiers[index + 1].range[0]);
112400 return sourceText + sourceCode.getText(specifier) + textAfterSpecifier;
112401 }, ""));
112402 }
112403
112404 });
112405 }
112406 }
112407 }
112408
112409 };
112410 }
112411
112412 };
112413
112414 /***/ }),
112415 /* 827 */
112416 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
112417
112418 "use strict";
112419 /**
112420 * @fileoverview Rule to require object keys to be sorted
112421 * @author Toru Nagashima
112422 */
112423 //------------------------------------------------------------------------------
112424 // Requirements
112425 //------------------------------------------------------------------------------
112426
112427 const astUtils = __webpack_require__(548),
112428 naturalCompare = __webpack_require__(828); //------------------------------------------------------------------------------
112429 // Helpers
112430 //------------------------------------------------------------------------------
112431
112432 /**
112433 * Gets the property name of the given `Property` node.
112434 *
112435 * - If the property's key is an `Identifier` node, this returns the key's name
112436 * whether it's a computed property or not.
112437 * - If the property has a static name, this returns the static name.
112438 * - Otherwise, this returns null.
112439 * @param {ASTNode} node The `Property` node to get.
112440 * @returns {string|null} The property name or null.
112441 * @private
112442 */
112443
112444
112445 function getPropertyName(node) {
112446 const staticName = astUtils.getStaticPropertyName(node);
112447
112448 if (staticName !== null) {
112449 return staticName;
112450 }
112451
112452 return node.key.name || null;
112453 }
112454 /**
112455 * Functions which check that the given 2 names are in specific order.
112456 *
112457 * Postfix `I` is meant insensitive.
112458 * Postfix `N` is meant natural.
112459 * @private
112460 */
112461
112462
112463 const isValidOrders = {
112464 asc(a, b) {
112465 return a <= b;
112466 },
112467
112468 ascI(a, b) {
112469 return a.toLowerCase() <= b.toLowerCase();
112470 },
112471
112472 ascN(a, b) {
112473 return naturalCompare(a, b) <= 0;
112474 },
112475
112476 ascIN(a, b) {
112477 return naturalCompare(a.toLowerCase(), b.toLowerCase()) <= 0;
112478 },
112479
112480 desc(a, b) {
112481 return isValidOrders.asc(b, a);
112482 },
112483
112484 descI(a, b) {
112485 return isValidOrders.ascI(b, a);
112486 },
112487
112488 descN(a, b) {
112489 return isValidOrders.ascN(b, a);
112490 },
112491
112492 descIN(a, b) {
112493 return isValidOrders.ascIN(b, a);
112494 }
112495
112496 }; //------------------------------------------------------------------------------
112497 // Rule Definition
112498 //------------------------------------------------------------------------------
112499
112500 module.exports = {
112501 meta: {
112502 type: "suggestion",
112503 docs: {
112504 description: "require object keys to be sorted",
112505 recommended: false,
112506 url: "https://eslint.org/docs/rules/sort-keys"
112507 },
112508 schema: [{
112509 enum: ["asc", "desc"]
112510 }, {
112511 type: "object",
112512 properties: {
112513 caseSensitive: {
112514 type: "boolean",
112515 default: true
112516 },
112517 natural: {
112518 type: "boolean",
112519 default: false
112520 },
112521 minKeys: {
112522 type: "integer",
112523 minimum: 2,
112524 default: 2
112525 }
112526 },
112527 additionalProperties: false
112528 }],
112529 messages: {
112530 sortKeys: "Expected object keys to be in {{natural}}{{insensitive}}{{order}}ending order. '{{thisName}}' should be before '{{prevName}}'."
112531 }
112532 },
112533
112534 create(context) {
112535 // Parse options.
112536 const order = context.options[0] || "asc";
112537 const options = context.options[1];
112538 const insensitive = options && options.caseSensitive === false;
112539 const natural = options && options.natural;
112540 const minKeys = options && options.minKeys;
112541 const isValidOrder = isValidOrders[order + (insensitive ? "I" : "") + (natural ? "N" : "")]; // The stack to save the previous property's name for each object literals.
112542
112543 let stack = null;
112544 return {
112545 ObjectExpression(node) {
112546 stack = {
112547 upper: stack,
112548 prevName: null,
112549 numKeys: node.properties.length
112550 };
112551 },
112552
112553 "ObjectExpression:exit"() {
112554 stack = stack.upper;
112555 },
112556
112557 SpreadElement(node) {
112558 if (node.parent.type === "ObjectExpression") {
112559 stack.prevName = null;
112560 }
112561 },
112562
112563 Property(node) {
112564 if (node.parent.type === "ObjectPattern") {
112565 return;
112566 }
112567
112568 const prevName = stack.prevName;
112569 const numKeys = stack.numKeys;
112570 const thisName = getPropertyName(node);
112571
112572 if (thisName !== null) {
112573 stack.prevName = thisName;
112574 }
112575
112576 if (prevName === null || thisName === null || numKeys < minKeys) {
112577 return;
112578 }
112579
112580 if (!isValidOrder(prevName, thisName)) {
112581 context.report({
112582 node,
112583 loc: node.key.loc,
112584 messageId: "sortKeys",
112585 data: {
112586 thisName,
112587 prevName,
112588 order,
112589 insensitive: insensitive ? "insensitive " : "",
112590 natural: natural ? "natural " : ""
112591 }
112592 });
112593 }
112594 }
112595
112596 };
112597 }
112598
112599 };
112600
112601 /***/ }),
112602 /* 828 */
112603 /***/ ((module) => {
112604
112605 /*
112606 * @version 1.4.0
112607 * @date 2015-10-26
112608 * @stability 3 - Stable
112609 * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
112610 * @license MIT License
112611 */
112612 var naturalCompare = function (a, b) {
112613 var i,
112614 codeA,
112615 codeB = 1,
112616 posA = 0,
112617 posB = 0,
112618 alphabet = String.alphabet;
112619
112620 function getCode(str, pos, code) {
112621 if (code) {
112622 for (i = pos; code = getCode(str, i), code < 76 && code > 65;) ++i;
112623
112624 return +str.slice(pos - 1, i);
112625 }
112626
112627 code = alphabet && alphabet.indexOf(str.charAt(pos));
112628 return code > -1 ? code + 76 : (code = str.charCodeAt(pos) || 0, code < 45 || code > 127) ? code : code < 46 ? 65 // -
112629 : code < 48 ? code - 1 : code < 58 ? code + 18 // 0-9
112630 : code < 65 ? code - 11 : code < 91 ? code + 11 // A-Z
112631 : code < 97 ? code - 37 : code < 123 ? code + 5 // a-z
112632 : code - 63;
112633 }
112634
112635 if ((a += "") != (b += "")) for (; codeB;) {
112636 codeA = getCode(a, posA++);
112637 codeB = getCode(b, posB++);
112638
112639 if (codeA < 76 && codeB < 76 && codeA > 66 && codeB > 66) {
112640 codeA = getCode(a, posA, posA);
112641 codeB = getCode(b, posB, posA = i);
112642 posB = i;
112643 }
112644
112645 if (codeA != codeB) return codeA < codeB ? -1 : 1;
112646 }
112647 return 0;
112648 };
112649
112650 try {
112651 module.exports = naturalCompare;
112652 } catch (e) {
112653 String.naturalCompare = naturalCompare;
112654 }
112655
112656 /***/ }),
112657 /* 829 */
112658 /***/ ((module) => {
112659
112660 "use strict";
112661 /**
112662 * @fileoverview Rule to require sorting of variables within a single Variable Declaration block
112663 * @author Ilya Volodin
112664 */
112665 //------------------------------------------------------------------------------
112666 // Rule Definition
112667 //------------------------------------------------------------------------------
112668
112669 module.exports = {
112670 meta: {
112671 type: "suggestion",
112672 docs: {
112673 description: "require variables within the same declaration block to be sorted",
112674 recommended: false,
112675 url: "https://eslint.org/docs/rules/sort-vars"
112676 },
112677 schema: [{
112678 type: "object",
112679 properties: {
112680 ignoreCase: {
112681 type: "boolean",
112682 default: false
112683 }
112684 },
112685 additionalProperties: false
112686 }],
112687 fixable: "code",
112688 messages: {
112689 sortVars: "Variables within the same declaration block should be sorted alphabetically."
112690 }
112691 },
112692
112693 create(context) {
112694 const configuration = context.options[0] || {},
112695 ignoreCase = configuration.ignoreCase || false,
112696 sourceCode = context.getSourceCode();
112697 return {
112698 VariableDeclaration(node) {
112699 const idDeclarations = node.declarations.filter(decl => decl.id.type === "Identifier");
112700 const getSortableName = ignoreCase ? decl => decl.id.name.toLowerCase() : decl => decl.id.name;
112701 const unfixable = idDeclarations.some(decl => decl.init !== null && decl.init.type !== "Literal");
112702 let fixed = false;
112703 idDeclarations.slice(1).reduce((memo, decl) => {
112704 const lastVariableName = getSortableName(memo),
112705 currentVariableName = getSortableName(decl);
112706
112707 if (currentVariableName < lastVariableName) {
112708 context.report({
112709 node: decl,
112710 messageId: "sortVars",
112711
112712 fix(fixer) {
112713 if (unfixable || fixed) {
112714 return null;
112715 }
112716
112717 return fixer.replaceTextRange([idDeclarations[0].range[0], idDeclarations[idDeclarations.length - 1].range[1]], idDeclarations // Clone the idDeclarations array to avoid mutating it
112718 .slice() // Sort the array into the desired order
112719 .sort((declA, declB) => {
112720 const aName = getSortableName(declA);
112721 const bName = getSortableName(declB);
112722 return aName > bName ? 1 : -1;
112723 }) // Build a string out of the sorted list of identifier declarations and the text between the originals
112724 .reduce((sourceText, identifier, index) => {
112725 const textAfterIdentifier = index === idDeclarations.length - 1 ? "" : sourceCode.getText().slice(idDeclarations[index].range[1], idDeclarations[index + 1].range[0]);
112726 return sourceText + sourceCode.getText(identifier) + textAfterIdentifier;
112727 }, ""));
112728 }
112729
112730 });
112731 fixed = true;
112732 return memo;
112733 }
112734
112735 return decl;
112736 }, idDeclarations[0]);
112737 }
112738
112739 };
112740 }
112741
112742 };
112743
112744 /***/ }),
112745 /* 830 */
112746 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
112747
112748 "use strict";
112749 /**
112750 * @fileoverview A rule to ensure whitespace before blocks.
112751 * @author Mathias Schreck <https://github.com/lo1tuma>
112752 */
112753 //------------------------------------------------------------------------------
112754 // Requirements
112755 //------------------------------------------------------------------------------
112756
112757 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
112758 // Helpers
112759 //------------------------------------------------------------------------------
112760
112761 /**
112762 * Checks whether the given node represents the body of a function.
112763 * @param {ASTNode} node the node to check.
112764 * @returns {boolean} `true` if the node is function body.
112765 */
112766
112767
112768 function isFunctionBody(node) {
112769 const parent = node.parent;
112770 return node.type === "BlockStatement" && astUtils.isFunction(parent) && parent.body === node;
112771 } //------------------------------------------------------------------------------
112772 // Rule Definition
112773 //------------------------------------------------------------------------------
112774
112775
112776 module.exports = {
112777 meta: {
112778 type: "layout",
112779 docs: {
112780 description: "enforce consistent spacing before blocks",
112781 recommended: false,
112782 url: "https://eslint.org/docs/rules/space-before-blocks"
112783 },
112784 fixable: "whitespace",
112785 schema: [{
112786 oneOf: [{
112787 enum: ["always", "never"]
112788 }, {
112789 type: "object",
112790 properties: {
112791 keywords: {
112792 enum: ["always", "never", "off"]
112793 },
112794 functions: {
112795 enum: ["always", "never", "off"]
112796 },
112797 classes: {
112798 enum: ["always", "never", "off"]
112799 }
112800 },
112801 additionalProperties: false
112802 }]
112803 }],
112804 messages: {
112805 unexpectedSpace: "Unexpected space before opening brace.",
112806 missingSpace: "Missing space before opening brace."
112807 }
112808 },
112809
112810 create(context) {
112811 const config = context.options[0],
112812 sourceCode = context.getSourceCode();
112813 let alwaysFunctions = true,
112814 alwaysKeywords = true,
112815 alwaysClasses = true,
112816 neverFunctions = false,
112817 neverKeywords = false,
112818 neverClasses = false;
112819
112820 if (typeof config === "object") {
112821 alwaysFunctions = config.functions === "always";
112822 alwaysKeywords = config.keywords === "always";
112823 alwaysClasses = config.classes === "always";
112824 neverFunctions = config.functions === "never";
112825 neverKeywords = config.keywords === "never";
112826 neverClasses = config.classes === "never";
112827 } else if (config === "never") {
112828 alwaysFunctions = false;
112829 alwaysKeywords = false;
112830 alwaysClasses = false;
112831 neverFunctions = true;
112832 neverKeywords = true;
112833 neverClasses = true;
112834 }
112835 /**
112836 * Checks whether the spacing before the given block is already controlled by another rule:
112837 * - `arrow-spacing` checks spaces after `=>`.
112838 * - `keyword-spacing` checks spaces after keywords in certain contexts.
112839 * - `switch-colon-spacing` checks spaces after `:` of switch cases.
112840 * @param {Token} precedingToken first token before the block.
112841 * @param {ASTNode|Token} node `BlockStatement` node or `{` token of a `SwitchStatement` node.
112842 * @returns {boolean} `true` if requiring or disallowing spaces before the given block could produce conflicts with other rules.
112843 */
112844
112845
112846 function isConflicted(precedingToken, node) {
112847 return astUtils.isArrowToken(precedingToken) || astUtils.isKeywordToken(precedingToken) && !isFunctionBody(node) || astUtils.isColonToken(precedingToken) && node.parent && node.parent.type === "SwitchCase" && precedingToken === astUtils.getSwitchCaseColonToken(node.parent, sourceCode);
112848 }
112849 /**
112850 * Checks the given BlockStatement node has a preceding space if it doesn’t start on a new line.
112851 * @param {ASTNode|Token} node The AST node of a BlockStatement.
112852 * @returns {void} undefined.
112853 */
112854
112855
112856 function checkPrecedingSpace(node) {
112857 const precedingToken = sourceCode.getTokenBefore(node);
112858
112859 if (precedingToken && !isConflicted(precedingToken, node) && astUtils.isTokenOnSameLine(precedingToken, node)) {
112860 const hasSpace = sourceCode.isSpaceBetweenTokens(precedingToken, node);
112861 let requireSpace;
112862 let requireNoSpace;
112863
112864 if (isFunctionBody(node)) {
112865 requireSpace = alwaysFunctions;
112866 requireNoSpace = neverFunctions;
112867 } else if (node.type === "ClassBody") {
112868 requireSpace = alwaysClasses;
112869 requireNoSpace = neverClasses;
112870 } else {
112871 requireSpace = alwaysKeywords;
112872 requireNoSpace = neverKeywords;
112873 }
112874
112875 if (requireSpace && !hasSpace) {
112876 context.report({
112877 node,
112878 messageId: "missingSpace",
112879
112880 fix(fixer) {
112881 return fixer.insertTextBefore(node, " ");
112882 }
112883
112884 });
112885 } else if (requireNoSpace && hasSpace) {
112886 context.report({
112887 node,
112888 messageId: "unexpectedSpace",
112889
112890 fix(fixer) {
112891 return fixer.removeRange([precedingToken.range[1], node.range[0]]);
112892 }
112893
112894 });
112895 }
112896 }
112897 }
112898 /**
112899 * Checks if the CaseBlock of an given SwitchStatement node has a preceding space.
112900 * @param {ASTNode} node The node of a SwitchStatement.
112901 * @returns {void} undefined.
112902 */
112903
112904
112905 function checkSpaceBeforeCaseBlock(node) {
112906 const cases = node.cases;
112907 let openingBrace;
112908
112909 if (cases.length > 0) {
112910 openingBrace = sourceCode.getTokenBefore(cases[0]);
112911 } else {
112912 openingBrace = sourceCode.getLastToken(node, 1);
112913 }
112914
112915 checkPrecedingSpace(openingBrace);
112916 }
112917
112918 return {
112919 BlockStatement: checkPrecedingSpace,
112920 ClassBody: checkPrecedingSpace,
112921 SwitchStatement: checkSpaceBeforeCaseBlock
112922 };
112923 }
112924
112925 };
112926
112927 /***/ }),
112928 /* 831 */
112929 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
112930
112931 "use strict";
112932 /**
112933 * @fileoverview Rule to validate spacing before function paren.
112934 * @author Mathias Schreck <https://github.com/lo1tuma>
112935 */
112936 //------------------------------------------------------------------------------
112937 // Requirements
112938 //------------------------------------------------------------------------------
112939
112940 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
112941 // Rule Definition
112942 //------------------------------------------------------------------------------
112943
112944
112945 module.exports = {
112946 meta: {
112947 type: "layout",
112948 docs: {
112949 description: "enforce consistent spacing before `function` definition opening parenthesis",
112950 recommended: false,
112951 url: "https://eslint.org/docs/rules/space-before-function-paren"
112952 },
112953 fixable: "whitespace",
112954 schema: [{
112955 oneOf: [{
112956 enum: ["always", "never"]
112957 }, {
112958 type: "object",
112959 properties: {
112960 anonymous: {
112961 enum: ["always", "never", "ignore"]
112962 },
112963 named: {
112964 enum: ["always", "never", "ignore"]
112965 },
112966 asyncArrow: {
112967 enum: ["always", "never", "ignore"]
112968 }
112969 },
112970 additionalProperties: false
112971 }]
112972 }],
112973 messages: {
112974 unexpectedSpace: "Unexpected space before function parentheses.",
112975 missingSpace: "Missing space before function parentheses."
112976 }
112977 },
112978
112979 create(context) {
112980 const sourceCode = context.getSourceCode();
112981 const baseConfig = typeof context.options[0] === "string" ? context.options[0] : "always";
112982 const overrideConfig = typeof context.options[0] === "object" ? context.options[0] : {};
112983 /**
112984 * Determines whether a function has a name.
112985 * @param {ASTNode} node The function node.
112986 * @returns {boolean} Whether the function has a name.
112987 */
112988
112989 function isNamedFunction(node) {
112990 if (node.id) {
112991 return true;
112992 }
112993
112994 const parent = node.parent;
112995 return parent.type === "MethodDefinition" || parent.type === "Property" && (parent.kind === "get" || parent.kind === "set" || parent.method);
112996 }
112997 /**
112998 * Gets the config for a given function
112999 * @param {ASTNode} node The function node
113000 * @returns {string} "always", "never", or "ignore"
113001 */
113002
113003
113004 function getConfigForFunction(node) {
113005 if (node.type === "ArrowFunctionExpression") {
113006 // Always ignore non-async functions and arrow functions without parens, e.g. async foo => bar
113007 if (node.async && astUtils.isOpeningParenToken(sourceCode.getFirstToken(node, {
113008 skip: 1
113009 }))) {
113010 return overrideConfig.asyncArrow || baseConfig;
113011 }
113012 } else if (isNamedFunction(node)) {
113013 return overrideConfig.named || baseConfig; // `generator-star-spacing` should warn anonymous generators. E.g. `function* () {}`
113014 } else if (!node.generator) {
113015 return overrideConfig.anonymous || baseConfig;
113016 }
113017
113018 return "ignore";
113019 }
113020 /**
113021 * Checks the parens of a function node
113022 * @param {ASTNode} node A function node
113023 * @returns {void}
113024 */
113025
113026
113027 function checkFunction(node) {
113028 const functionConfig = getConfigForFunction(node);
113029
113030 if (functionConfig === "ignore") {
113031 return;
113032 }
113033
113034 const rightToken = sourceCode.getFirstToken(node, astUtils.isOpeningParenToken);
113035 const leftToken = sourceCode.getTokenBefore(rightToken);
113036 const hasSpacing = sourceCode.isSpaceBetweenTokens(leftToken, rightToken);
113037
113038 if (hasSpacing && functionConfig === "never") {
113039 context.report({
113040 node,
113041 loc: {
113042 start: leftToken.loc.end,
113043 end: rightToken.loc.start
113044 },
113045 messageId: "unexpectedSpace",
113046
113047 fix(fixer) {
113048 const comments = sourceCode.getCommentsBefore(rightToken); // Don't fix anything if there's a single line comment between the left and the right token
113049
113050 if (comments.some(comment => comment.type === "Line")) {
113051 return null;
113052 }
113053
113054 return fixer.replaceTextRange([leftToken.range[1], rightToken.range[0]], comments.reduce((text, comment) => text + sourceCode.getText(comment), ""));
113055 }
113056
113057 });
113058 } else if (!hasSpacing && functionConfig === "always") {
113059 context.report({
113060 node,
113061 loc: rightToken.loc,
113062 messageId: "missingSpace",
113063 fix: fixer => fixer.insertTextAfter(leftToken, " ")
113064 });
113065 }
113066 }
113067
113068 return {
113069 ArrowFunctionExpression: checkFunction,
113070 FunctionDeclaration: checkFunction,
113071 FunctionExpression: checkFunction
113072 };
113073 }
113074
113075 };
113076
113077 /***/ }),
113078 /* 832 */
113079 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
113080
113081 "use strict";
113082 /**
113083 * @fileoverview Disallows or enforces spaces inside of parentheses.
113084 * @author Jonathan Rajavuori
113085 */
113086
113087
113088 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
113089 // Rule Definition
113090 //------------------------------------------------------------------------------
113091
113092
113093 module.exports = {
113094 meta: {
113095 type: "layout",
113096 docs: {
113097 description: "enforce consistent spacing inside parentheses",
113098 recommended: false,
113099 url: "https://eslint.org/docs/rules/space-in-parens"
113100 },
113101 fixable: "whitespace",
113102 schema: [{
113103 enum: ["always", "never"]
113104 }, {
113105 type: "object",
113106 properties: {
113107 exceptions: {
113108 type: "array",
113109 items: {
113110 enum: ["{}", "[]", "()", "empty"]
113111 },
113112 uniqueItems: true
113113 }
113114 },
113115 additionalProperties: false
113116 }],
113117 messages: {
113118 missingOpeningSpace: "There must be a space after this paren.",
113119 missingClosingSpace: "There must be a space before this paren.",
113120 rejectedOpeningSpace: "There should be no space after this paren.",
113121 rejectedClosingSpace: "There should be no space before this paren."
113122 }
113123 },
113124
113125 create(context) {
113126 const ALWAYS = context.options[0] === "always",
113127 exceptionsArrayOptions = context.options[1] && context.options[1].exceptions || [],
113128 options = {};
113129 let exceptions;
113130
113131 if (exceptionsArrayOptions.length) {
113132 options.braceException = exceptionsArrayOptions.includes("{}");
113133 options.bracketException = exceptionsArrayOptions.includes("[]");
113134 options.parenException = exceptionsArrayOptions.includes("()");
113135 options.empty = exceptionsArrayOptions.includes("empty");
113136 }
113137 /**
113138 * Produces an object with the opener and closer exception values
113139 * @returns {Object} `openers` and `closers` exception values
113140 * @private
113141 */
113142
113143
113144 function getExceptions() {
113145 const openers = [],
113146 closers = [];
113147
113148 if (options.braceException) {
113149 openers.push("{");
113150 closers.push("}");
113151 }
113152
113153 if (options.bracketException) {
113154 openers.push("[");
113155 closers.push("]");
113156 }
113157
113158 if (options.parenException) {
113159 openers.push("(");
113160 closers.push(")");
113161 }
113162
113163 if (options.empty) {
113164 openers.push(")");
113165 closers.push("(");
113166 }
113167
113168 return {
113169 openers,
113170 closers
113171 };
113172 } //--------------------------------------------------------------------------
113173 // Helpers
113174 //--------------------------------------------------------------------------
113175
113176
113177 const sourceCode = context.getSourceCode();
113178 /**
113179 * Determines if a token is one of the exceptions for the opener paren
113180 * @param {Object} token The token to check
113181 * @returns {boolean} True if the token is one of the exceptions for the opener paren
113182 */
113183
113184 function isOpenerException(token) {
113185 return exceptions.openers.includes(token.value);
113186 }
113187 /**
113188 * Determines if a token is one of the exceptions for the closer paren
113189 * @param {Object} token The token to check
113190 * @returns {boolean} True if the token is one of the exceptions for the closer paren
113191 */
113192
113193
113194 function isCloserException(token) {
113195 return exceptions.closers.includes(token.value);
113196 }
113197 /**
113198 * Determines if an opening paren is immediately followed by a required space
113199 * @param {Object} openingParenToken The paren token
113200 * @param {Object} tokenAfterOpeningParen The token after it
113201 * @returns {boolean} True if the opening paren is missing a required space
113202 */
113203
113204
113205 function openerMissingSpace(openingParenToken, tokenAfterOpeningParen) {
113206 if (sourceCode.isSpaceBetweenTokens(openingParenToken, tokenAfterOpeningParen)) {
113207 return false;
113208 }
113209
113210 if (!options.empty && astUtils.isClosingParenToken(tokenAfterOpeningParen)) {
113211 return false;
113212 }
113213
113214 if (ALWAYS) {
113215 return !isOpenerException(tokenAfterOpeningParen);
113216 }
113217
113218 return isOpenerException(tokenAfterOpeningParen);
113219 }
113220 /**
113221 * Determines if an opening paren is immediately followed by a disallowed space
113222 * @param {Object} openingParenToken The paren token
113223 * @param {Object} tokenAfterOpeningParen The token after it
113224 * @returns {boolean} True if the opening paren has a disallowed space
113225 */
113226
113227
113228 function openerRejectsSpace(openingParenToken, tokenAfterOpeningParen) {
113229 if (!astUtils.isTokenOnSameLine(openingParenToken, tokenAfterOpeningParen)) {
113230 return false;
113231 }
113232
113233 if (tokenAfterOpeningParen.type === "Line") {
113234 return false;
113235 }
113236
113237 if (!sourceCode.isSpaceBetweenTokens(openingParenToken, tokenAfterOpeningParen)) {
113238 return false;
113239 }
113240
113241 if (ALWAYS) {
113242 return isOpenerException(tokenAfterOpeningParen);
113243 }
113244
113245 return !isOpenerException(tokenAfterOpeningParen);
113246 }
113247 /**
113248 * Determines if a closing paren is immediately preceded by a required space
113249 * @param {Object} tokenBeforeClosingParen The token before the paren
113250 * @param {Object} closingParenToken The paren token
113251 * @returns {boolean} True if the closing paren is missing a required space
113252 */
113253
113254
113255 function closerMissingSpace(tokenBeforeClosingParen, closingParenToken) {
113256 if (sourceCode.isSpaceBetweenTokens(tokenBeforeClosingParen, closingParenToken)) {
113257 return false;
113258 }
113259
113260 if (!options.empty && astUtils.isOpeningParenToken(tokenBeforeClosingParen)) {
113261 return false;
113262 }
113263
113264 if (ALWAYS) {
113265 return !isCloserException(tokenBeforeClosingParen);
113266 }
113267
113268 return isCloserException(tokenBeforeClosingParen);
113269 }
113270 /**
113271 * Determines if a closer paren is immediately preceded by a disallowed space
113272 * @param {Object} tokenBeforeClosingParen The token before the paren
113273 * @param {Object} closingParenToken The paren token
113274 * @returns {boolean} True if the closing paren has a disallowed space
113275 */
113276
113277
113278 function closerRejectsSpace(tokenBeforeClosingParen, closingParenToken) {
113279 if (!astUtils.isTokenOnSameLine(tokenBeforeClosingParen, closingParenToken)) {
113280 return false;
113281 }
113282
113283 if (!sourceCode.isSpaceBetweenTokens(tokenBeforeClosingParen, closingParenToken)) {
113284 return false;
113285 }
113286
113287 if (ALWAYS) {
113288 return isCloserException(tokenBeforeClosingParen);
113289 }
113290
113291 return !isCloserException(tokenBeforeClosingParen);
113292 } //--------------------------------------------------------------------------
113293 // Public
113294 //--------------------------------------------------------------------------
113295
113296
113297 return {
113298 Program: function checkParenSpaces(node) {
113299 exceptions = getExceptions();
113300 const tokens = sourceCode.tokensAndComments;
113301 tokens.forEach((token, i) => {
113302 const prevToken = tokens[i - 1];
113303 const nextToken = tokens[i + 1]; // if token is not an opening or closing paren token, do nothing
113304
113305 if (!astUtils.isOpeningParenToken(token) && !astUtils.isClosingParenToken(token)) {
113306 return;
113307 } // if token is an opening paren and is not followed by a required space
113308
113309
113310 if (token.value === "(" && openerMissingSpace(token, nextToken)) {
113311 context.report({
113312 node,
113313 loc: token.loc,
113314 messageId: "missingOpeningSpace",
113315
113316 fix(fixer) {
113317 return fixer.insertTextAfter(token, " ");
113318 }
113319
113320 });
113321 } // if token is an opening paren and is followed by a disallowed space
113322
113323
113324 if (token.value === "(" && openerRejectsSpace(token, nextToken)) {
113325 context.report({
113326 node,
113327 loc: {
113328 start: token.loc.end,
113329 end: nextToken.loc.start
113330 },
113331 messageId: "rejectedOpeningSpace",
113332
113333 fix(fixer) {
113334 return fixer.removeRange([token.range[1], nextToken.range[0]]);
113335 }
113336
113337 });
113338 } // if token is a closing paren and is not preceded by a required space
113339
113340
113341 if (token.value === ")" && closerMissingSpace(prevToken, token)) {
113342 context.report({
113343 node,
113344 loc: token.loc,
113345 messageId: "missingClosingSpace",
113346
113347 fix(fixer) {
113348 return fixer.insertTextBefore(token, " ");
113349 }
113350
113351 });
113352 } // if token is a closing paren and is preceded by a disallowed space
113353
113354
113355 if (token.value === ")" && closerRejectsSpace(prevToken, token)) {
113356 context.report({
113357 node,
113358 loc: {
113359 start: prevToken.loc.end,
113360 end: token.loc.start
113361 },
113362 messageId: "rejectedClosingSpace",
113363
113364 fix(fixer) {
113365 return fixer.removeRange([prevToken.range[1], token.range[0]]);
113366 }
113367
113368 });
113369 }
113370 });
113371 }
113372 };
113373 }
113374
113375 };
113376
113377 /***/ }),
113378 /* 833 */
113379 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
113380
113381 "use strict";
113382 /**
113383 * @fileoverview Require spaces around infix operators
113384 * @author Michael Ficarra
113385 */
113386
113387
113388 const {
113389 isEqToken
113390 } = __webpack_require__(548); //------------------------------------------------------------------------------
113391 // Rule Definition
113392 //------------------------------------------------------------------------------
113393
113394
113395 module.exports = {
113396 meta: {
113397 type: "layout",
113398 docs: {
113399 description: "require spacing around infix operators",
113400 recommended: false,
113401 url: "https://eslint.org/docs/rules/space-infix-ops"
113402 },
113403 fixable: "whitespace",
113404 schema: [{
113405 type: "object",
113406 properties: {
113407 int32Hint: {
113408 type: "boolean",
113409 default: false
113410 }
113411 },
113412 additionalProperties: false
113413 }],
113414 messages: {
113415 missingSpace: "Operator '{{operator}}' must be spaced."
113416 }
113417 },
113418
113419 create(context) {
113420 const int32Hint = context.options[0] ? context.options[0].int32Hint === true : false;
113421 const sourceCode = context.getSourceCode();
113422 /**
113423 * Returns the first token which violates the rule
113424 * @param {ASTNode} left The left node of the main node
113425 * @param {ASTNode} right The right node of the main node
113426 * @param {string} op The operator of the main node
113427 * @returns {Object} The violator token or null
113428 * @private
113429 */
113430
113431 function getFirstNonSpacedToken(left, right, op) {
113432 const operator = sourceCode.getFirstTokenBetween(left, right, token => token.value === op);
113433 const prev = sourceCode.getTokenBefore(operator);
113434 const next = sourceCode.getTokenAfter(operator);
113435
113436 if (!sourceCode.isSpaceBetweenTokens(prev, operator) || !sourceCode.isSpaceBetweenTokens(operator, next)) {
113437 return operator;
113438 }
113439
113440 return null;
113441 }
113442 /**
113443 * Reports an AST node as a rule violation
113444 * @param {ASTNode} mainNode The node to report
113445 * @param {Object} culpritToken The token which has a problem
113446 * @returns {void}
113447 * @private
113448 */
113449
113450
113451 function report(mainNode, culpritToken) {
113452 context.report({
113453 node: mainNode,
113454 loc: culpritToken.loc,
113455 messageId: "missingSpace",
113456 data: {
113457 operator: culpritToken.value
113458 },
113459
113460 fix(fixer) {
113461 const previousToken = sourceCode.getTokenBefore(culpritToken);
113462 const afterToken = sourceCode.getTokenAfter(culpritToken);
113463 let fixString = "";
113464
113465 if (culpritToken.range[0] - previousToken.range[1] === 0) {
113466 fixString = " ";
113467 }
113468
113469 fixString += culpritToken.value;
113470
113471 if (afterToken.range[0] - culpritToken.range[1] === 0) {
113472 fixString += " ";
113473 }
113474
113475 return fixer.replaceText(culpritToken, fixString);
113476 }
113477
113478 });
113479 }
113480 /**
113481 * Check if the node is binary then report
113482 * @param {ASTNode} node node to evaluate
113483 * @returns {void}
113484 * @private
113485 */
113486
113487
113488 function checkBinary(node) {
113489 const leftNode = node.left.typeAnnotation ? node.left.typeAnnotation : node.left;
113490 const rightNode = node.right; // search for = in AssignmentPattern nodes
113491
113492 const operator = node.operator || "=";
113493 const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, operator);
113494
113495 if (nonSpacedNode) {
113496 if (!(int32Hint && sourceCode.getText(node).endsWith("|0"))) {
113497 report(node, nonSpacedNode);
113498 }
113499 }
113500 }
113501 /**
113502 * Check if the node is conditional
113503 * @param {ASTNode} node node to evaluate
113504 * @returns {void}
113505 * @private
113506 */
113507
113508
113509 function checkConditional(node) {
113510 const nonSpacedConsequentNode = getFirstNonSpacedToken(node.test, node.consequent, "?");
113511 const nonSpacedAlternateNode = getFirstNonSpacedToken(node.consequent, node.alternate, ":");
113512
113513 if (nonSpacedConsequentNode) {
113514 report(node, nonSpacedConsequentNode);
113515 }
113516
113517 if (nonSpacedAlternateNode) {
113518 report(node, nonSpacedAlternateNode);
113519 }
113520 }
113521 /**
113522 * Check if the node is a variable
113523 * @param {ASTNode} node node to evaluate
113524 * @returns {void}
113525 * @private
113526 */
113527
113528
113529 function checkVar(node) {
113530 const leftNode = node.id.typeAnnotation ? node.id.typeAnnotation : node.id;
113531 const rightNode = node.init;
113532
113533 if (rightNode) {
113534 const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, "=");
113535
113536 if (nonSpacedNode) {
113537 report(node, nonSpacedNode);
113538 }
113539 }
113540 }
113541
113542 return {
113543 AssignmentExpression: checkBinary,
113544 AssignmentPattern: checkBinary,
113545 BinaryExpression: checkBinary,
113546 LogicalExpression: checkBinary,
113547 ConditionalExpression: checkConditional,
113548 VariableDeclarator: checkVar,
113549
113550 PropertyDefinition(node) {
113551 if (!node.value) {
113552 return;
113553 }
113554 /*
113555 * Because of computed properties and type annotations, some
113556 * tokens may exist between `node.key` and `=`.
113557 * Therefore, find the `=` from the right.
113558 */
113559
113560
113561 const operatorToken = sourceCode.getTokenBefore(node.value, isEqToken);
113562 const leftToken = sourceCode.getTokenBefore(operatorToken);
113563 const rightToken = sourceCode.getTokenAfter(operatorToken);
113564
113565 if (!sourceCode.isSpaceBetweenTokens(leftToken, operatorToken) || !sourceCode.isSpaceBetweenTokens(operatorToken, rightToken)) {
113566 report(node, operatorToken);
113567 }
113568 }
113569
113570 };
113571 }
113572
113573 };
113574
113575 /***/ }),
113576 /* 834 */
113577 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
113578
113579 "use strict";
113580 /**
113581 * @fileoverview This rule should require or disallow spaces before or after unary operations.
113582 * @author Marcin Kumorek
113583 */
113584 //------------------------------------------------------------------------------
113585 // Requirements
113586 //------------------------------------------------------------------------------
113587
113588 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
113589 // Rule Definition
113590 //------------------------------------------------------------------------------
113591
113592
113593 module.exports = {
113594 meta: {
113595 type: "layout",
113596 docs: {
113597 description: "enforce consistent spacing before or after unary operators",
113598 recommended: false,
113599 url: "https://eslint.org/docs/rules/space-unary-ops"
113600 },
113601 fixable: "whitespace",
113602 schema: [{
113603 type: "object",
113604 properties: {
113605 words: {
113606 type: "boolean",
113607 default: true
113608 },
113609 nonwords: {
113610 type: "boolean",
113611 default: false
113612 },
113613 overrides: {
113614 type: "object",
113615 additionalProperties: {
113616 type: "boolean"
113617 }
113618 }
113619 },
113620 additionalProperties: false
113621 }],
113622 messages: {
113623 unexpectedBefore: "Unexpected space before unary operator '{{operator}}'.",
113624 unexpectedAfter: "Unexpected space after unary operator '{{operator}}'.",
113625 unexpectedAfterWord: "Unexpected space after unary word operator '{{word}}'.",
113626 wordOperator: "Unary word operator '{{word}}' must be followed by whitespace.",
113627 operator: "Unary operator '{{operator}}' must be followed by whitespace.",
113628 beforeUnaryExpressions: "Space is required before unary expressions '{{token}}'."
113629 }
113630 },
113631
113632 create(context) {
113633 const options = context.options[0] || {
113634 words: true,
113635 nonwords: false
113636 };
113637 const sourceCode = context.getSourceCode(); //--------------------------------------------------------------------------
113638 // Helpers
113639 //--------------------------------------------------------------------------
113640
113641 /**
113642 * Check if the node is the first "!" in a "!!" convert to Boolean expression
113643 * @param {ASTnode} node AST node
113644 * @returns {boolean} Whether or not the node is first "!" in "!!"
113645 */
113646
113647 function isFirstBangInBangBangExpression(node) {
113648 return node && node.type === "UnaryExpression" && node.argument.operator === "!" && node.argument && node.argument.type === "UnaryExpression" && node.argument.operator === "!";
113649 }
113650 /**
113651 * Checks if an override exists for a given operator.
113652 * @param {string} operator Operator
113653 * @returns {boolean} Whether or not an override has been provided for the operator
113654 */
113655
113656
113657 function overrideExistsForOperator(operator) {
113658 return options.overrides && Object.prototype.hasOwnProperty.call(options.overrides, operator);
113659 }
113660 /**
113661 * Gets the value that the override was set to for this operator
113662 * @param {string} operator Operator
113663 * @returns {boolean} Whether or not an override enforces a space with this operator
113664 */
113665
113666
113667 function overrideEnforcesSpaces(operator) {
113668 return options.overrides[operator];
113669 }
113670 /**
113671 * Verify Unary Word Operator has spaces after the word operator
113672 * @param {ASTnode} node AST node
113673 * @param {Object} firstToken first token from the AST node
113674 * @param {Object} secondToken second token from the AST node
113675 * @param {string} word The word to be used for reporting
113676 * @returns {void}
113677 */
113678
113679
113680 function verifyWordHasSpaces(node, firstToken, secondToken, word) {
113681 if (secondToken.range[0] === firstToken.range[1]) {
113682 context.report({
113683 node,
113684 messageId: "wordOperator",
113685 data: {
113686 word
113687 },
113688
113689 fix(fixer) {
113690 return fixer.insertTextAfter(firstToken, " ");
113691 }
113692
113693 });
113694 }
113695 }
113696 /**
113697 * Verify Unary Word Operator doesn't have spaces after the word operator
113698 * @param {ASTnode} node AST node
113699 * @param {Object} firstToken first token from the AST node
113700 * @param {Object} secondToken second token from the AST node
113701 * @param {string} word The word to be used for reporting
113702 * @returns {void}
113703 */
113704
113705
113706 function verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word) {
113707 if (astUtils.canTokensBeAdjacent(firstToken, secondToken)) {
113708 if (secondToken.range[0] > firstToken.range[1]) {
113709 context.report({
113710 node,
113711 messageId: "unexpectedAfterWord",
113712 data: {
113713 word
113714 },
113715
113716 fix(fixer) {
113717 return fixer.removeRange([firstToken.range[1], secondToken.range[0]]);
113718 }
113719
113720 });
113721 }
113722 }
113723 }
113724 /**
113725 * Check Unary Word Operators for spaces after the word operator
113726 * @param {ASTnode} node AST node
113727 * @param {Object} firstToken first token from the AST node
113728 * @param {Object} secondToken second token from the AST node
113729 * @param {string} word The word to be used for reporting
113730 * @returns {void}
113731 */
113732
113733
113734 function checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, word) {
113735 if (overrideExistsForOperator(word)) {
113736 if (overrideEnforcesSpaces(word)) {
113737 verifyWordHasSpaces(node, firstToken, secondToken, word);
113738 } else {
113739 verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word);
113740 }
113741 } else if (options.words) {
113742 verifyWordHasSpaces(node, firstToken, secondToken, word);
113743 } else {
113744 verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word);
113745 }
113746 }
113747 /**
113748 * Verifies YieldExpressions satisfy spacing requirements
113749 * @param {ASTnode} node AST node
113750 * @returns {void}
113751 */
113752
113753
113754 function checkForSpacesAfterYield(node) {
113755 const tokens = sourceCode.getFirstTokens(node, 3),
113756 word = "yield";
113757
113758 if (!node.argument || node.delegate) {
113759 return;
113760 }
113761
113762 checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], word);
113763 }
113764 /**
113765 * Verifies AwaitExpressions satisfy spacing requirements
113766 * @param {ASTNode} node AwaitExpression AST node
113767 * @returns {void}
113768 */
113769
113770
113771 function checkForSpacesAfterAwait(node) {
113772 const tokens = sourceCode.getFirstTokens(node, 3);
113773 checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], "await");
113774 }
113775 /**
113776 * Verifies UnaryExpression, UpdateExpression and NewExpression have spaces before or after the operator
113777 * @param {ASTnode} node AST node
113778 * @param {Object} firstToken First token in the expression
113779 * @param {Object} secondToken Second token in the expression
113780 * @returns {void}
113781 */
113782
113783
113784 function verifyNonWordsHaveSpaces(node, firstToken, secondToken) {
113785 if (node.prefix) {
113786 if (isFirstBangInBangBangExpression(node)) {
113787 return;
113788 }
113789
113790 if (firstToken.range[1] === secondToken.range[0]) {
113791 context.report({
113792 node,
113793 messageId: "operator",
113794 data: {
113795 operator: firstToken.value
113796 },
113797
113798 fix(fixer) {
113799 return fixer.insertTextAfter(firstToken, " ");
113800 }
113801
113802 });
113803 }
113804 } else {
113805 if (firstToken.range[1] === secondToken.range[0]) {
113806 context.report({
113807 node,
113808 messageId: "beforeUnaryExpressions",
113809 data: {
113810 token: secondToken.value
113811 },
113812
113813 fix(fixer) {
113814 return fixer.insertTextBefore(secondToken, " ");
113815 }
113816
113817 });
113818 }
113819 }
113820 }
113821 /**
113822 * Verifies UnaryExpression, UpdateExpression and NewExpression don't have spaces before or after the operator
113823 * @param {ASTnode} node AST node
113824 * @param {Object} firstToken First token in the expression
113825 * @param {Object} secondToken Second token in the expression
113826 * @returns {void}
113827 */
113828
113829
113830 function verifyNonWordsDontHaveSpaces(node, firstToken, secondToken) {
113831 if (node.prefix) {
113832 if (secondToken.range[0] > firstToken.range[1]) {
113833 context.report({
113834 node,
113835 messageId: "unexpectedAfter",
113836 data: {
113837 operator: firstToken.value
113838 },
113839
113840 fix(fixer) {
113841 if (astUtils.canTokensBeAdjacent(firstToken, secondToken)) {
113842 return fixer.removeRange([firstToken.range[1], secondToken.range[0]]);
113843 }
113844
113845 return null;
113846 }
113847
113848 });
113849 }
113850 } else {
113851 if (secondToken.range[0] > firstToken.range[1]) {
113852 context.report({
113853 node,
113854 messageId: "unexpectedBefore",
113855 data: {
113856 operator: secondToken.value
113857 },
113858
113859 fix(fixer) {
113860 return fixer.removeRange([firstToken.range[1], secondToken.range[0]]);
113861 }
113862
113863 });
113864 }
113865 }
113866 }
113867 /**
113868 * Verifies UnaryExpression, UpdateExpression and NewExpression satisfy spacing requirements
113869 * @param {ASTnode} node AST node
113870 * @returns {void}
113871 */
113872
113873
113874 function checkForSpaces(node) {
113875 const tokens = node.type === "UpdateExpression" && !node.prefix ? sourceCode.getLastTokens(node, 2) : sourceCode.getFirstTokens(node, 2);
113876 const firstToken = tokens[0];
113877 const secondToken = tokens[1];
113878
113879 if ((node.type === "NewExpression" || node.prefix) && firstToken.type === "Keyword") {
113880 checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, firstToken.value);
113881 return;
113882 }
113883
113884 const operator = node.prefix ? tokens[0].value : tokens[1].value;
113885
113886 if (overrideExistsForOperator(operator)) {
113887 if (overrideEnforcesSpaces(operator)) {
113888 verifyNonWordsHaveSpaces(node, firstToken, secondToken);
113889 } else {
113890 verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
113891 }
113892 } else if (options.nonwords) {
113893 verifyNonWordsHaveSpaces(node, firstToken, secondToken);
113894 } else {
113895 verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
113896 }
113897 } //--------------------------------------------------------------------------
113898 // Public
113899 //--------------------------------------------------------------------------
113900
113901
113902 return {
113903 UnaryExpression: checkForSpaces,
113904 UpdateExpression: checkForSpaces,
113905 NewExpression: checkForSpaces,
113906 YieldExpression: checkForSpacesAfterYield,
113907 AwaitExpression: checkForSpacesAfterAwait
113908 };
113909 }
113910
113911 };
113912
113913 /***/ }),
113914 /* 835 */
113915 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
113916
113917 "use strict";
113918 /**
113919 * @fileoverview Source code for spaced-comments rule
113920 * @author Gyandeep Singh
113921 */
113922
113923
113924 const escapeRegExp = __webpack_require__(525);
113925
113926 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
113927 // Helpers
113928 //------------------------------------------------------------------------------
113929
113930 /**
113931 * Escapes the control characters of a given string.
113932 * @param {string} s A string to escape.
113933 * @returns {string} An escaped string.
113934 */
113935
113936
113937 function escape(s) {
113938 return "(?:".concat(escapeRegExp(s), ")");
113939 }
113940 /**
113941 * Escapes the control characters of a given string.
113942 * And adds a repeat flag.
113943 * @param {string} s A string to escape.
113944 * @returns {string} An escaped string.
113945 */
113946
113947
113948 function escapeAndRepeat(s) {
113949 return "".concat(escape(s), "+");
113950 }
113951 /**
113952 * Parses `markers` option.
113953 * If markers don't include `"*"`, this adds `"*"` to allow JSDoc comments.
113954 * @param {string[]} [markers] A marker list.
113955 * @returns {string[]} A marker list.
113956 */
113957
113958
113959 function parseMarkersOption(markers) {
113960 // `*` is a marker for JSDoc comments.
113961 if (markers.indexOf("*") === -1) {
113962 return markers.concat("*");
113963 }
113964
113965 return markers;
113966 }
113967 /**
113968 * Creates string pattern for exceptions.
113969 * Generated pattern:
113970 *
113971 * 1. A space or an exception pattern sequence.
113972 * @param {string[]} exceptions An exception pattern list.
113973 * @returns {string} A regular expression string for exceptions.
113974 */
113975
113976
113977 function createExceptionsPattern(exceptions) {
113978 let pattern = "";
113979 /*
113980 * A space or an exception pattern sequence.
113981 * [] ==> "\s"
113982 * ["-"] ==> "(?:\s|\-+$)"
113983 * ["-", "="] ==> "(?:\s|(?:\-+|=+)$)"
113984 * ["-", "=", "--=="] ==> "(?:\s|(?:\-+|=+|(?:\-\-==)+)$)" ==> https://jex.im/regulex/#!embed=false&flags=&re=(%3F%3A%5Cs%7C(%3F%3A%5C-%2B%7C%3D%2B%7C(%3F%3A%5C-%5C-%3D%3D)%2B)%24)
113985 */
113986
113987 if (exceptions.length === 0) {
113988 // a space.
113989 pattern += "\\s";
113990 } else {
113991 // a space or...
113992 pattern += "(?:\\s|";
113993
113994 if (exceptions.length === 1) {
113995 // a sequence of the exception pattern.
113996 pattern += escapeAndRepeat(exceptions[0]);
113997 } else {
113998 // a sequence of one of the exception patterns.
113999 pattern += "(?:";
114000 pattern += exceptions.map(escapeAndRepeat).join("|");
114001 pattern += ")";
114002 }
114003
114004 pattern += "(?:$|[".concat(Array.from(astUtils.LINEBREAKS).join(""), "]))");
114005 }
114006
114007 return pattern;
114008 }
114009 /**
114010 * Creates RegExp object for `always` mode.
114011 * Generated pattern for beginning of comment:
114012 *
114013 * 1. First, a marker or nothing.
114014 * 2. Next, a space or an exception pattern sequence.
114015 * @param {string[]} markers A marker list.
114016 * @param {string[]} exceptions An exception pattern list.
114017 * @returns {RegExp} A RegExp object for the beginning of a comment in `always` mode.
114018 */
114019
114020
114021 function createAlwaysStylePattern(markers, exceptions) {
114022 let pattern = "^";
114023 /*
114024 * A marker or nothing.
114025 * ["*"] ==> "\*?"
114026 * ["*", "!"] ==> "(?:\*|!)?"
114027 * ["*", "/", "!<"] ==> "(?:\*|\/|(?:!<))?" ==> https://jex.im/regulex/#!embed=false&flags=&re=(%3F%3A%5C*%7C%5C%2F%7C(%3F%3A!%3C))%3F
114028 */
114029
114030 if (markers.length === 1) {
114031 // the marker.
114032 pattern += escape(markers[0]);
114033 } else {
114034 // one of markers.
114035 pattern += "(?:";
114036 pattern += markers.map(escape).join("|");
114037 pattern += ")";
114038 }
114039
114040 pattern += "?"; // or nothing.
114041
114042 pattern += createExceptionsPattern(exceptions);
114043 return new RegExp(pattern, "u");
114044 }
114045 /**
114046 * Creates RegExp object for `never` mode.
114047 * Generated pattern for beginning of comment:
114048 *
114049 * 1. First, a marker or nothing (captured).
114050 * 2. Next, a space or a tab.
114051 * @param {string[]} markers A marker list.
114052 * @returns {RegExp} A RegExp object for `never` mode.
114053 */
114054
114055
114056 function createNeverStylePattern(markers) {
114057 const pattern = "^(".concat(markers.map(escape).join("|"), ")?[ \t]+");
114058 return new RegExp(pattern, "u");
114059 } //------------------------------------------------------------------------------
114060 // Rule Definition
114061 //------------------------------------------------------------------------------
114062
114063
114064 module.exports = {
114065 meta: {
114066 type: "suggestion",
114067 docs: {
114068 description: "enforce consistent spacing after the `//` or `/*` in a comment",
114069 recommended: false,
114070 url: "https://eslint.org/docs/rules/spaced-comment"
114071 },
114072 fixable: "whitespace",
114073 schema: [{
114074 enum: ["always", "never"]
114075 }, {
114076 type: "object",
114077 properties: {
114078 exceptions: {
114079 type: "array",
114080 items: {
114081 type: "string"
114082 }
114083 },
114084 markers: {
114085 type: "array",
114086 items: {
114087 type: "string"
114088 }
114089 },
114090 line: {
114091 type: "object",
114092 properties: {
114093 exceptions: {
114094 type: "array",
114095 items: {
114096 type: "string"
114097 }
114098 },
114099 markers: {
114100 type: "array",
114101 items: {
114102 type: "string"
114103 }
114104 }
114105 },
114106 additionalProperties: false
114107 },
114108 block: {
114109 type: "object",
114110 properties: {
114111 exceptions: {
114112 type: "array",
114113 items: {
114114 type: "string"
114115 }
114116 },
114117 markers: {
114118 type: "array",
114119 items: {
114120 type: "string"
114121 }
114122 },
114123 balanced: {
114124 type: "boolean",
114125 default: false
114126 }
114127 },
114128 additionalProperties: false
114129 }
114130 },
114131 additionalProperties: false
114132 }],
114133 messages: {
114134 unexpectedSpaceAfterMarker: "Unexpected space or tab after marker ({{refChar}}) in comment.",
114135 expectedExceptionAfter: "Expected exception block, space or tab after '{{refChar}}' in comment.",
114136 unexpectedSpaceBefore: "Unexpected space or tab before '*/' in comment.",
114137 unexpectedSpaceAfter: "Unexpected space or tab after '{{refChar}}' in comment.",
114138 expectedSpaceBefore: "Expected space or tab before '*/' in comment.",
114139 expectedSpaceAfter: "Expected space or tab after '{{refChar}}' in comment."
114140 }
114141 },
114142
114143 create(context) {
114144 const sourceCode = context.getSourceCode(); // Unless the first option is never, require a space
114145
114146 const requireSpace = context.options[0] !== "never";
114147 /*
114148 * Parse the second options.
114149 * If markers don't include `"*"`, it's added automatically for JSDoc
114150 * comments.
114151 */
114152
114153 const config = context.options[1] || {};
114154 const balanced = config.block && config.block.balanced;
114155 const styleRules = ["block", "line"].reduce((rule, type) => {
114156 const markers = parseMarkersOption(config[type] && config[type].markers || config.markers || []);
114157 const exceptions = config[type] && config[type].exceptions || config.exceptions || [];
114158 const endNeverPattern = "[ \t]+$"; // Create RegExp object for valid patterns.
114159
114160 rule[type] = {
114161 beginRegex: requireSpace ? createAlwaysStylePattern(markers, exceptions) : createNeverStylePattern(markers),
114162 endRegex: balanced && requireSpace ? new RegExp("".concat(createExceptionsPattern(exceptions), "$"), "u") : new RegExp(endNeverPattern, "u"),
114163 hasExceptions: exceptions.length > 0,
114164 captureMarker: new RegExp("^(".concat(markers.map(escape).join("|"), ")"), "u"),
114165 markers: new Set(markers)
114166 };
114167 return rule;
114168 }, {});
114169 /**
114170 * Reports a beginning spacing error with an appropriate message.
114171 * @param {ASTNode} node A comment node to check.
114172 * @param {string} messageId An error message to report.
114173 * @param {Array} match An array of match results for markers.
114174 * @param {string} refChar Character used for reference in the error message.
114175 * @returns {void}
114176 */
114177
114178 function reportBegin(node, messageId, match, refChar) {
114179 const type = node.type.toLowerCase(),
114180 commentIdentifier = type === "block" ? "/*" : "//";
114181 context.report({
114182 node,
114183
114184 fix(fixer) {
114185 const start = node.range[0];
114186 let end = start + 2;
114187
114188 if (requireSpace) {
114189 if (match) {
114190 end += match[0].length;
114191 }
114192
114193 return fixer.insertTextAfterRange([start, end], " ");
114194 }
114195
114196 end += match[0].length;
114197 return fixer.replaceTextRange([start, end], commentIdentifier + (match[1] ? match[1] : ""));
114198 },
114199
114200 messageId,
114201 data: {
114202 refChar
114203 }
114204 });
114205 }
114206 /**
114207 * Reports an ending spacing error with an appropriate message.
114208 * @param {ASTNode} node A comment node to check.
114209 * @param {string} messageId An error message to report.
114210 * @param {string} match An array of the matched whitespace characters.
114211 * @returns {void}
114212 */
114213
114214
114215 function reportEnd(node, messageId, match) {
114216 context.report({
114217 node,
114218
114219 fix(fixer) {
114220 if (requireSpace) {
114221 return fixer.insertTextAfterRange([node.range[0], node.range[1] - 2], " ");
114222 }
114223
114224 const end = node.range[1] - 2,
114225 start = end - match[0].length;
114226 return fixer.replaceTextRange([start, end], "");
114227 },
114228
114229 messageId
114230 });
114231 }
114232 /**
114233 * Reports a given comment if it's invalid.
114234 * @param {ASTNode} node a comment node to check.
114235 * @returns {void}
114236 */
114237
114238
114239 function checkCommentForSpace(node) {
114240 const type = node.type.toLowerCase(),
114241 rule = styleRules[type],
114242 commentIdentifier = type === "block" ? "/*" : "//"; // Ignores empty comments and comments that consist only of a marker.
114243
114244 if (node.value.length === 0 || rule.markers.has(node.value)) {
114245 return;
114246 }
114247
114248 const beginMatch = rule.beginRegex.exec(node.value);
114249 const endMatch = rule.endRegex.exec(node.value); // Checks.
114250
114251 if (requireSpace) {
114252 if (!beginMatch) {
114253 const hasMarker = rule.captureMarker.exec(node.value);
114254 const marker = hasMarker ? commentIdentifier + hasMarker[0] : commentIdentifier;
114255
114256 if (rule.hasExceptions) {
114257 reportBegin(node, "expectedExceptionAfter", hasMarker, marker);
114258 } else {
114259 reportBegin(node, "expectedSpaceAfter", hasMarker, marker);
114260 }
114261 }
114262
114263 if (balanced && type === "block" && !endMatch) {
114264 reportEnd(node, "expectedSpaceBefore");
114265 }
114266 } else {
114267 if (beginMatch) {
114268 if (!beginMatch[1]) {
114269 reportBegin(node, "unexpectedSpaceAfter", beginMatch, commentIdentifier);
114270 } else {
114271 reportBegin(node, "unexpectedSpaceAfterMarker", beginMatch, beginMatch[1]);
114272 }
114273 }
114274
114275 if (balanced && type === "block" && endMatch) {
114276 reportEnd(node, "unexpectedSpaceBefore", endMatch);
114277 }
114278 }
114279 }
114280
114281 return {
114282 Program() {
114283 const comments = sourceCode.getAllComments();
114284 comments.filter(token => token.type !== "Shebang").forEach(checkCommentForSpace);
114285 }
114286
114287 };
114288 }
114289
114290 };
114291
114292 /***/ }),
114293 /* 836 */
114294 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
114295
114296 "use strict";
114297 /**
114298 * @fileoverview Rule to control usage of strict mode directives.
114299 * @author Brandon Mills
114300 */
114301 //------------------------------------------------------------------------------
114302 // Requirements
114303 //------------------------------------------------------------------------------
114304
114305 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
114306 // Helpers
114307 //------------------------------------------------------------------------------
114308
114309 /**
114310 * Gets all of the Use Strict Directives in the Directive Prologue of a group of
114311 * statements.
114312 * @param {ASTNode[]} statements Statements in the program or function body.
114313 * @returns {ASTNode[]} All of the Use Strict Directives.
114314 */
114315
114316
114317 function getUseStrictDirectives(statements) {
114318 const directives = [];
114319
114320 for (let i = 0; i < statements.length; i++) {
114321 const statement = statements[i];
114322
114323 if (statement.type === "ExpressionStatement" && statement.expression.type === "Literal" && statement.expression.value === "use strict") {
114324 directives[i] = statement;
114325 } else {
114326 break;
114327 }
114328 }
114329
114330 return directives;
114331 }
114332 /**
114333 * Checks whether a given parameter is a simple parameter.
114334 * @param {ASTNode} node A pattern node to check.
114335 * @returns {boolean} `true` if the node is an Identifier node.
114336 */
114337
114338
114339 function isSimpleParameter(node) {
114340 return node.type === "Identifier";
114341 }
114342 /**
114343 * Checks whether a given parameter list is a simple parameter list.
114344 * @param {ASTNode[]} params A parameter list to check.
114345 * @returns {boolean} `true` if the every parameter is an Identifier node.
114346 */
114347
114348
114349 function isSimpleParameterList(params) {
114350 return params.every(isSimpleParameter);
114351 } //------------------------------------------------------------------------------
114352 // Rule Definition
114353 //------------------------------------------------------------------------------
114354
114355
114356 module.exports = {
114357 meta: {
114358 type: "suggestion",
114359 docs: {
114360 description: "require or disallow strict mode directives",
114361 recommended: false,
114362 url: "https://eslint.org/docs/rules/strict"
114363 },
114364 schema: [{
114365 enum: ["never", "global", "function", "safe"]
114366 }],
114367 fixable: "code",
114368 messages: {
114369 function: "Use the function form of 'use strict'.",
114370 global: "Use the global form of 'use strict'.",
114371 multiple: "Multiple 'use strict' directives.",
114372 never: "Strict mode is not permitted.",
114373 unnecessary: "Unnecessary 'use strict' directive.",
114374 module: "'use strict' is unnecessary inside of modules.",
114375 implied: "'use strict' is unnecessary when implied strict mode is enabled.",
114376 unnecessaryInClasses: "'use strict' is unnecessary inside of classes.",
114377 nonSimpleParameterList: "'use strict' directive inside a function with non-simple parameter list throws a syntax error since ES2016.",
114378 wrap: "Wrap {{name}} in a function with 'use strict' directive."
114379 }
114380 },
114381
114382 create(context) {
114383 const ecmaFeatures = context.parserOptions.ecmaFeatures || {},
114384 scopes = [],
114385 classScopes = [];
114386 let mode = context.options[0] || "safe";
114387
114388 if (ecmaFeatures.impliedStrict) {
114389 mode = "implied";
114390 } else if (mode === "safe") {
114391 mode = ecmaFeatures.globalReturn ? "global" : "function";
114392 }
114393 /**
114394 * Determines whether a reported error should be fixed, depending on the error type.
114395 * @param {string} errorType The type of error
114396 * @returns {boolean} `true` if the reported error should be fixed
114397 */
114398
114399
114400 function shouldFix(errorType) {
114401 return errorType === "multiple" || errorType === "unnecessary" || errorType === "module" || errorType === "implied" || errorType === "unnecessaryInClasses";
114402 }
114403 /**
114404 * Gets a fixer function to remove a given 'use strict' directive.
114405 * @param {ASTNode} node The directive that should be removed
114406 * @returns {Function} A fixer function
114407 */
114408
114409
114410 function getFixFunction(node) {
114411 return fixer => fixer.remove(node);
114412 }
114413 /**
114414 * Report a slice of an array of nodes with a given message.
114415 * @param {ASTNode[]} nodes Nodes.
114416 * @param {string} start Index to start from.
114417 * @param {string} end Index to end before.
114418 * @param {string} messageId Message to display.
114419 * @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
114420 * @returns {void}
114421 */
114422
114423
114424 function reportSlice(nodes, start, end, messageId, fix) {
114425 nodes.slice(start, end).forEach(node => {
114426 context.report({
114427 node,
114428 messageId,
114429 fix: fix ? getFixFunction(node) : null
114430 });
114431 });
114432 }
114433 /**
114434 * Report all nodes in an array with a given message.
114435 * @param {ASTNode[]} nodes Nodes.
114436 * @param {string} messageId Message id to display.
114437 * @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
114438 * @returns {void}
114439 */
114440
114441
114442 function reportAll(nodes, messageId, fix) {
114443 reportSlice(nodes, 0, nodes.length, messageId, fix);
114444 }
114445 /**
114446 * Report all nodes in an array, except the first, with a given message.
114447 * @param {ASTNode[]} nodes Nodes.
114448 * @param {string} messageId Message id to display.
114449 * @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
114450 * @returns {void}
114451 */
114452
114453
114454 function reportAllExceptFirst(nodes, messageId, fix) {
114455 reportSlice(nodes, 1, nodes.length, messageId, fix);
114456 }
114457 /**
114458 * Entering a function in 'function' mode pushes a new nested scope onto the
114459 * stack. The new scope is true if the nested function is strict mode code.
114460 * @param {ASTNode} node The function declaration or expression.
114461 * @param {ASTNode[]} useStrictDirectives The Use Strict Directives of the node.
114462 * @returns {void}
114463 */
114464
114465
114466 function enterFunctionInFunctionMode(node, useStrictDirectives) {
114467 const isInClass = classScopes.length > 0,
114468 isParentGlobal = scopes.length === 0 && classScopes.length === 0,
114469 isParentStrict = scopes.length > 0 && scopes[scopes.length - 1],
114470 isStrict = useStrictDirectives.length > 0;
114471
114472 if (isStrict) {
114473 if (!isSimpleParameterList(node.params)) {
114474 context.report({
114475 node: useStrictDirectives[0],
114476 messageId: "nonSimpleParameterList"
114477 });
114478 } else if (isParentStrict) {
114479 context.report({
114480 node: useStrictDirectives[0],
114481 messageId: "unnecessary",
114482 fix: getFixFunction(useStrictDirectives[0])
114483 });
114484 } else if (isInClass) {
114485 context.report({
114486 node: useStrictDirectives[0],
114487 messageId: "unnecessaryInClasses",
114488 fix: getFixFunction(useStrictDirectives[0])
114489 });
114490 }
114491
114492 reportAllExceptFirst(useStrictDirectives, "multiple", true);
114493 } else if (isParentGlobal) {
114494 if (isSimpleParameterList(node.params)) {
114495 context.report({
114496 node,
114497 messageId: "function"
114498 });
114499 } else {
114500 context.report({
114501 node,
114502 messageId: "wrap",
114503 data: {
114504 name: astUtils.getFunctionNameWithKind(node)
114505 }
114506 });
114507 }
114508 }
114509
114510 scopes.push(isParentStrict || isStrict);
114511 }
114512 /**
114513 * Exiting a function in 'function' mode pops its scope off the stack.
114514 * @returns {void}
114515 */
114516
114517
114518 function exitFunctionInFunctionMode() {
114519 scopes.pop();
114520 }
114521 /**
114522 * Enter a function and either:
114523 * - Push a new nested scope onto the stack (in 'function' mode).
114524 * - Report all the Use Strict Directives (in the other modes).
114525 * @param {ASTNode} node The function declaration or expression.
114526 * @returns {void}
114527 */
114528
114529
114530 function enterFunction(node) {
114531 const isBlock = node.body.type === "BlockStatement",
114532 useStrictDirectives = isBlock ? getUseStrictDirectives(node.body.body) : [];
114533
114534 if (mode === "function") {
114535 enterFunctionInFunctionMode(node, useStrictDirectives);
114536 } else if (useStrictDirectives.length > 0) {
114537 if (isSimpleParameterList(node.params)) {
114538 reportAll(useStrictDirectives, mode, shouldFix(mode));
114539 } else {
114540 context.report({
114541 node: useStrictDirectives[0],
114542 messageId: "nonSimpleParameterList"
114543 });
114544 reportAllExceptFirst(useStrictDirectives, "multiple", true);
114545 }
114546 }
114547 }
114548
114549 const rule = {
114550 Program(node) {
114551 const useStrictDirectives = getUseStrictDirectives(node.body);
114552
114553 if (node.sourceType === "module") {
114554 mode = "module";
114555 }
114556
114557 if (mode === "global") {
114558 if (node.body.length > 0 && useStrictDirectives.length === 0) {
114559 context.report({
114560 node,
114561 messageId: "global"
114562 });
114563 }
114564
114565 reportAllExceptFirst(useStrictDirectives, "multiple", true);
114566 } else {
114567 reportAll(useStrictDirectives, mode, shouldFix(mode));
114568 }
114569 },
114570
114571 FunctionDeclaration: enterFunction,
114572 FunctionExpression: enterFunction,
114573 ArrowFunctionExpression: enterFunction
114574 };
114575
114576 if (mode === "function") {
114577 Object.assign(rule, {
114578 // Inside of class bodies are always strict mode.
114579 ClassBody() {
114580 classScopes.push(true);
114581 },
114582
114583 "ClassBody:exit"() {
114584 classScopes.pop();
114585 },
114586
114587 "FunctionDeclaration:exit": exitFunctionInFunctionMode,
114588 "FunctionExpression:exit": exitFunctionInFunctionMode,
114589 "ArrowFunctionExpression:exit": exitFunctionInFunctionMode
114590 });
114591 }
114592
114593 return rule;
114594 }
114595
114596 };
114597
114598 /***/ }),
114599 /* 837 */
114600 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
114601
114602 "use strict";
114603 /**
114604 * @fileoverview Rule to enforce spacing around colons of switch statements.
114605 * @author Toru Nagashima
114606 */
114607 //------------------------------------------------------------------------------
114608 // Requirements
114609 //------------------------------------------------------------------------------
114610
114611 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
114612 // Rule Definition
114613 //------------------------------------------------------------------------------
114614
114615
114616 module.exports = {
114617 meta: {
114618 type: "layout",
114619 docs: {
114620 description: "enforce spacing around colons of switch statements",
114621 recommended: false,
114622 url: "https://eslint.org/docs/rules/switch-colon-spacing"
114623 },
114624 schema: [{
114625 type: "object",
114626 properties: {
114627 before: {
114628 type: "boolean",
114629 default: false
114630 },
114631 after: {
114632 type: "boolean",
114633 default: true
114634 }
114635 },
114636 additionalProperties: false
114637 }],
114638 fixable: "whitespace",
114639 messages: {
114640 expectedBefore: "Expected space(s) before this colon.",
114641 expectedAfter: "Expected space(s) after this colon.",
114642 unexpectedBefore: "Unexpected space(s) before this colon.",
114643 unexpectedAfter: "Unexpected space(s) after this colon."
114644 }
114645 },
114646
114647 create(context) {
114648 const sourceCode = context.getSourceCode();
114649 const options = context.options[0] || {};
114650 const beforeSpacing = options.before === true; // false by default
114651
114652 const afterSpacing = options.after !== false; // true by default
114653
114654 /**
114655 * Check whether the spacing between the given 2 tokens is valid or not.
114656 * @param {Token} left The left token to check.
114657 * @param {Token} right The right token to check.
114658 * @param {boolean} expected The expected spacing to check. `true` if there should be a space.
114659 * @returns {boolean} `true` if the spacing between the tokens is valid.
114660 */
114661
114662 function isValidSpacing(left, right, expected) {
114663 return astUtils.isClosingBraceToken(right) || !astUtils.isTokenOnSameLine(left, right) || sourceCode.isSpaceBetweenTokens(left, right) === expected;
114664 }
114665 /**
114666 * Check whether comments exist between the given 2 tokens.
114667 * @param {Token} left The left token to check.
114668 * @param {Token} right The right token to check.
114669 * @returns {boolean} `true` if comments exist between the given 2 tokens.
114670 */
114671
114672
114673 function commentsExistBetween(left, right) {
114674 return sourceCode.getFirstTokenBetween(left, right, {
114675 includeComments: true,
114676 filter: astUtils.isCommentToken
114677 }) !== null;
114678 }
114679 /**
114680 * Fix the spacing between the given 2 tokens.
114681 * @param {RuleFixer} fixer The fixer to fix.
114682 * @param {Token} left The left token of fix range.
114683 * @param {Token} right The right token of fix range.
114684 * @param {boolean} spacing The spacing style. `true` if there should be a space.
114685 * @returns {Fix|null} The fix object.
114686 */
114687
114688
114689 function fix(fixer, left, right, spacing) {
114690 if (commentsExistBetween(left, right)) {
114691 return null;
114692 }
114693
114694 if (spacing) {
114695 return fixer.insertTextAfter(left, " ");
114696 }
114697
114698 return fixer.removeRange([left.range[1], right.range[0]]);
114699 }
114700
114701 return {
114702 SwitchCase(node) {
114703 const colonToken = astUtils.getSwitchCaseColonToken(node, sourceCode);
114704 const beforeToken = sourceCode.getTokenBefore(colonToken);
114705 const afterToken = sourceCode.getTokenAfter(colonToken);
114706
114707 if (!isValidSpacing(beforeToken, colonToken, beforeSpacing)) {
114708 context.report({
114709 node,
114710 loc: colonToken.loc,
114711 messageId: beforeSpacing ? "expectedBefore" : "unexpectedBefore",
114712 fix: fixer => fix(fixer, beforeToken, colonToken, beforeSpacing)
114713 });
114714 }
114715
114716 if (!isValidSpacing(colonToken, afterToken, afterSpacing)) {
114717 context.report({
114718 node,
114719 loc: colonToken.loc,
114720 messageId: afterSpacing ? "expectedAfter" : "unexpectedAfter",
114721 fix: fixer => fix(fixer, colonToken, afterToken, afterSpacing)
114722 });
114723 }
114724 }
114725
114726 };
114727 }
114728
114729 };
114730
114731 /***/ }),
114732 /* 838 */
114733 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
114734
114735 "use strict";
114736 /**
114737 * @fileoverview Rule to enforce description with the `Symbol` object
114738 * @author Jarek Rencz
114739 */
114740 //------------------------------------------------------------------------------
114741 // Requirements
114742 //------------------------------------------------------------------------------
114743
114744 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
114745 // Rule Definition
114746 //------------------------------------------------------------------------------
114747
114748
114749 module.exports = {
114750 meta: {
114751 type: "suggestion",
114752 docs: {
114753 description: "require symbol descriptions",
114754 recommended: false,
114755 url: "https://eslint.org/docs/rules/symbol-description"
114756 },
114757 fixable: null,
114758 schema: [],
114759 messages: {
114760 expected: "Expected Symbol to have a description."
114761 }
114762 },
114763
114764 create(context) {
114765 /**
114766 * Reports if node does not conform the rule in case rule is set to
114767 * report missing description
114768 * @param {ASTNode} node A CallExpression node to check.
114769 * @returns {void}
114770 */
114771 function checkArgument(node) {
114772 if (node.arguments.length === 0) {
114773 context.report({
114774 node,
114775 messageId: "expected"
114776 });
114777 }
114778 }
114779
114780 return {
114781 "Program:exit"() {
114782 const scope = context.getScope();
114783 const variable = astUtils.getVariableByName(scope, "Symbol");
114784
114785 if (variable && variable.defs.length === 0) {
114786 variable.references.forEach(reference => {
114787 const node = reference.identifier;
114788
114789 if (astUtils.isCallee(node)) {
114790 checkArgument(node.parent);
114791 }
114792 });
114793 }
114794 }
114795
114796 };
114797 }
114798
114799 };
114800
114801 /***/ }),
114802 /* 839 */
114803 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
114804
114805 "use strict";
114806 /**
114807 * @fileoverview Rule to enforce spacing around embedded expressions of template strings
114808 * @author Toru Nagashima
114809 */
114810 //------------------------------------------------------------------------------
114811 // Requirements
114812 //------------------------------------------------------------------------------
114813
114814 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
114815 // Rule Definition
114816 //------------------------------------------------------------------------------
114817
114818
114819 module.exports = {
114820 meta: {
114821 type: "layout",
114822 docs: {
114823 description: "require or disallow spacing around embedded expressions of template strings",
114824 recommended: false,
114825 url: "https://eslint.org/docs/rules/template-curly-spacing"
114826 },
114827 fixable: "whitespace",
114828 schema: [{
114829 enum: ["always", "never"]
114830 }],
114831 messages: {
114832 expectedBefore: "Expected space(s) before '}'.",
114833 expectedAfter: "Expected space(s) after '${'.",
114834 unexpectedBefore: "Unexpected space(s) before '}'.",
114835 unexpectedAfter: "Unexpected space(s) after '${'."
114836 }
114837 },
114838
114839 create(context) {
114840 const sourceCode = context.getSourceCode();
114841 const always = context.options[0] === "always";
114842 /**
114843 * Checks spacing before `}` of a given token.
114844 * @param {Token} token A token to check. This is a Template token.
114845 * @returns {void}
114846 */
114847
114848 function checkSpacingBefore(token) {
114849 if (!token.value.startsWith("}")) {
114850 return; // starts with a backtick, this is the first template element in the template literal
114851 }
114852
114853 const prevToken = sourceCode.getTokenBefore(token, {
114854 includeComments: true
114855 }),
114856 hasSpace = sourceCode.isSpaceBetween(prevToken, token);
114857
114858 if (!astUtils.isTokenOnSameLine(prevToken, token)) {
114859 return;
114860 }
114861
114862 if (always && !hasSpace) {
114863 context.report({
114864 loc: {
114865 start: token.loc.start,
114866 end: {
114867 line: token.loc.start.line,
114868 column: token.loc.start.column + 1
114869 }
114870 },
114871 messageId: "expectedBefore",
114872 fix: fixer => fixer.insertTextBefore(token, " ")
114873 });
114874 }
114875
114876 if (!always && hasSpace) {
114877 context.report({
114878 loc: {
114879 start: prevToken.loc.end,
114880 end: token.loc.start
114881 },
114882 messageId: "unexpectedBefore",
114883 fix: fixer => fixer.removeRange([prevToken.range[1], token.range[0]])
114884 });
114885 }
114886 }
114887 /**
114888 * Checks spacing after `${` of a given token.
114889 * @param {Token} token A token to check. This is a Template token.
114890 * @returns {void}
114891 */
114892
114893
114894 function checkSpacingAfter(token) {
114895 if (!token.value.endsWith("${")) {
114896 return; // ends with a backtick, this is the last template element in the template literal
114897 }
114898
114899 const nextToken = sourceCode.getTokenAfter(token, {
114900 includeComments: true
114901 }),
114902 hasSpace = sourceCode.isSpaceBetween(token, nextToken);
114903
114904 if (!astUtils.isTokenOnSameLine(token, nextToken)) {
114905 return;
114906 }
114907
114908 if (always && !hasSpace) {
114909 context.report({
114910 loc: {
114911 start: {
114912 line: token.loc.end.line,
114913 column: token.loc.end.column - 2
114914 },
114915 end: token.loc.end
114916 },
114917 messageId: "expectedAfter",
114918 fix: fixer => fixer.insertTextAfter(token, " ")
114919 });
114920 }
114921
114922 if (!always && hasSpace) {
114923 context.report({
114924 loc: {
114925 start: token.loc.end,
114926 end: nextToken.loc.start
114927 },
114928 messageId: "unexpectedAfter",
114929 fix: fixer => fixer.removeRange([token.range[1], nextToken.range[0]])
114930 });
114931 }
114932 }
114933
114934 return {
114935 TemplateElement(node) {
114936 const token = sourceCode.getFirstToken(node);
114937 checkSpacingBefore(token);
114938 checkSpacingAfter(token);
114939 }
114940
114941 };
114942 }
114943
114944 };
114945
114946 /***/ }),
114947 /* 840 */
114948 /***/ ((module) => {
114949
114950 "use strict";
114951 /**
114952 * @fileoverview Rule to check spacing between template tags and their literals
114953 * @author Jonathan Wilsson
114954 */
114955 //------------------------------------------------------------------------------
114956 // Rule Definition
114957 //------------------------------------------------------------------------------
114958
114959 module.exports = {
114960 meta: {
114961 type: "layout",
114962 docs: {
114963 description: "require or disallow spacing between template tags and their literals",
114964 recommended: false,
114965 url: "https://eslint.org/docs/rules/template-tag-spacing"
114966 },
114967 fixable: "whitespace",
114968 schema: [{
114969 enum: ["always", "never"]
114970 }],
114971 messages: {
114972 unexpected: "Unexpected space between template tag and template literal.",
114973 missing: "Missing space between template tag and template literal."
114974 }
114975 },
114976
114977 create(context) {
114978 const never = context.options[0] !== "always";
114979 const sourceCode = context.getSourceCode();
114980 /**
114981 * Check if a space is present between a template tag and its literal
114982 * @param {ASTNode} node node to evaluate
114983 * @returns {void}
114984 * @private
114985 */
114986
114987 function checkSpacing(node) {
114988 const tagToken = sourceCode.getTokenBefore(node.quasi);
114989 const literalToken = sourceCode.getFirstToken(node.quasi);
114990 const hasWhitespace = sourceCode.isSpaceBetweenTokens(tagToken, literalToken);
114991
114992 if (never && hasWhitespace) {
114993 context.report({
114994 node,
114995 loc: {
114996 start: tagToken.loc.end,
114997 end: literalToken.loc.start
114998 },
114999 messageId: "unexpected",
115000
115001 fix(fixer) {
115002 const comments = sourceCode.getCommentsBefore(node.quasi); // Don't fix anything if there's a single line comment after the template tag
115003
115004 if (comments.some(comment => comment.type === "Line")) {
115005 return null;
115006 }
115007
115008 return fixer.replaceTextRange([tagToken.range[1], literalToken.range[0]], comments.reduce((text, comment) => text + sourceCode.getText(comment), ""));
115009 }
115010
115011 });
115012 } else if (!never && !hasWhitespace) {
115013 context.report({
115014 node,
115015 loc: {
115016 start: node.loc.start,
115017 end: literalToken.loc.start
115018 },
115019 messageId: "missing",
115020
115021 fix(fixer) {
115022 return fixer.insertTextAfter(tagToken, " ");
115023 }
115024
115025 });
115026 }
115027 }
115028
115029 return {
115030 TaggedTemplateExpression: checkSpacing
115031 };
115032 }
115033
115034 };
115035
115036 /***/ }),
115037 /* 841 */
115038 /***/ ((module) => {
115039
115040 "use strict";
115041 /**
115042 * @fileoverview Require or disallow Unicode BOM
115043 * @author Andrew Johnston <https://github.com/ehjay>
115044 */
115045 //------------------------------------------------------------------------------
115046 // Rule Definition
115047 //------------------------------------------------------------------------------
115048
115049 module.exports = {
115050 meta: {
115051 type: "layout",
115052 docs: {
115053 description: "require or disallow Unicode byte order mark (BOM)",
115054 recommended: false,
115055 url: "https://eslint.org/docs/rules/unicode-bom"
115056 },
115057 fixable: "whitespace",
115058 schema: [{
115059 enum: ["always", "never"]
115060 }],
115061 messages: {
115062 expected: "Expected Unicode BOM (Byte Order Mark).",
115063 unexpected: "Unexpected Unicode BOM (Byte Order Mark)."
115064 }
115065 },
115066
115067 create(context) {
115068 //--------------------------------------------------------------------------
115069 // Public
115070 //--------------------------------------------------------------------------
115071 return {
115072 Program: function checkUnicodeBOM(node) {
115073 const sourceCode = context.getSourceCode(),
115074 location = {
115075 column: 0,
115076 line: 1
115077 },
115078 requireBOM = context.options[0] || "never";
115079
115080 if (!sourceCode.hasBOM && requireBOM === "always") {
115081 context.report({
115082 node,
115083 loc: location,
115084 messageId: "expected",
115085
115086 fix(fixer) {
115087 return fixer.insertTextBeforeRange([0, 1], "\uFEFF");
115088 }
115089
115090 });
115091 } else if (sourceCode.hasBOM && requireBOM === "never") {
115092 context.report({
115093 node,
115094 loc: location,
115095 messageId: "unexpected",
115096
115097 fix(fixer) {
115098 return fixer.removeRange([-1, 0]);
115099 }
115100
115101 });
115102 }
115103 }
115104 };
115105 }
115106
115107 };
115108
115109 /***/ }),
115110 /* 842 */
115111 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
115112
115113 "use strict";
115114 /**
115115 * @fileoverview Rule to flag comparisons to the value NaN
115116 * @author James Allardice
115117 */
115118 //------------------------------------------------------------------------------
115119 // Requirements
115120 //------------------------------------------------------------------------------
115121
115122 const astUtils = __webpack_require__(548); //------------------------------------------------------------------------------
115123 // Helpers
115124 //------------------------------------------------------------------------------
115125
115126 /**
115127 * Determines if the given node is a NaN `Identifier` node.
115128 * @param {ASTNode|null} node The node to check.
115129 * @returns {boolean} `true` if the node is 'NaN' identifier.
115130 */
115131
115132
115133 function isNaNIdentifier(node) {
115134 return Boolean(node) && (astUtils.isSpecificId(node, "NaN") || astUtils.isSpecificMemberAccess(node, "Number", "NaN"));
115135 } //------------------------------------------------------------------------------
115136 // Rule Definition
115137 //------------------------------------------------------------------------------
115138
115139
115140 module.exports = {
115141 meta: {
115142 type: "problem",
115143 docs: {
115144 description: "require calls to `isNaN()` when checking for `NaN`",
115145 recommended: true,
115146 url: "https://eslint.org/docs/rules/use-isnan"
115147 },
115148 schema: [{
115149 type: "object",
115150 properties: {
115151 enforceForSwitchCase: {
115152 type: "boolean",
115153 default: true
115154 },
115155 enforceForIndexOf: {
115156 type: "boolean",
115157 default: false
115158 }
115159 },
115160 additionalProperties: false
115161 }],
115162 messages: {
115163 comparisonWithNaN: "Use the isNaN function to compare with NaN.",
115164 switchNaN: "'switch(NaN)' can never match a case clause. Use Number.isNaN instead of the switch.",
115165 caseNaN: "'case NaN' can never match. Use Number.isNaN before the switch.",
115166 indexOfNaN: "Array prototype method '{{ methodName }}' cannot find NaN."
115167 }
115168 },
115169
115170 create(context) {
115171 const enforceForSwitchCase = !context.options[0] || context.options[0].enforceForSwitchCase;
115172 const enforceForIndexOf = context.options[0] && context.options[0].enforceForIndexOf;
115173 /**
115174 * Checks the given `BinaryExpression` node for `foo === NaN` and other comparisons.
115175 * @param {ASTNode} node The node to check.
115176 * @returns {void}
115177 */
115178
115179 function checkBinaryExpression(node) {
115180 if (/^(?:[<>]|[!=]=)=?$/u.test(node.operator) && (isNaNIdentifier(node.left) || isNaNIdentifier(node.right))) {
115181 context.report({
115182 node,
115183 messageId: "comparisonWithNaN"
115184 });
115185 }
115186 }
115187 /**
115188 * Checks the discriminant and all case clauses of the given `SwitchStatement` node for `switch(NaN)` and `case NaN:`
115189 * @param {ASTNode} node The node to check.
115190 * @returns {void}
115191 */
115192
115193
115194 function checkSwitchStatement(node) {
115195 if (isNaNIdentifier(node.discriminant)) {
115196 context.report({
115197 node,
115198 messageId: "switchNaN"
115199 });
115200 }
115201
115202 for (const switchCase of node.cases) {
115203 if (isNaNIdentifier(switchCase.test)) {
115204 context.report({
115205 node: switchCase,
115206 messageId: "caseNaN"
115207 });
115208 }
115209 }
115210 }
115211 /**
115212 * Checks the given `CallExpression` node for `.indexOf(NaN)` and `.lastIndexOf(NaN)`.
115213 * @param {ASTNode} node The node to check.
115214 * @returns {void}
115215 */
115216
115217
115218 function checkCallExpression(node) {
115219 const callee = astUtils.skipChainExpression(node.callee);
115220
115221 if (callee.type === "MemberExpression") {
115222 const methodName = astUtils.getStaticPropertyName(callee);
115223
115224 if ((methodName === "indexOf" || methodName === "lastIndexOf") && node.arguments.length === 1 && isNaNIdentifier(node.arguments[0])) {
115225 context.report({
115226 node,
115227 messageId: "indexOfNaN",
115228 data: {
115229 methodName
115230 }
115231 });
115232 }
115233 }
115234 }
115235
115236 const listeners = {
115237 BinaryExpression: checkBinaryExpression
115238 };
115239
115240 if (enforceForSwitchCase) {
115241 listeners.SwitchStatement = checkSwitchStatement;
115242 }
115243
115244 if (enforceForIndexOf) {
115245 listeners.CallExpression = checkCallExpression;
115246 }
115247
115248 return listeners;
115249 }
115250
115251 };
115252
115253 /***/ }),
115254 /* 843 */
115255 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
115256
115257 "use strict";
115258 /**
115259 * @fileoverview Validates JSDoc comments are syntactically correct
115260 * @author Nicholas C. Zakas
115261 * @deprecated in ESLint v5.10.0
115262 */
115263 //------------------------------------------------------------------------------
115264 // Requirements
115265 //------------------------------------------------------------------------------
115266
115267 const doctrine = __webpack_require__(844); //------------------------------------------------------------------------------
115268 // Rule Definition
115269 //------------------------------------------------------------------------------
115270
115271
115272 module.exports = {
115273 meta: {
115274 type: "suggestion",
115275 docs: {
115276 description: "enforce valid JSDoc comments",
115277 recommended: false,
115278 url: "https://eslint.org/docs/rules/valid-jsdoc"
115279 },
115280 schema: [{
115281 type: "object",
115282 properties: {
115283 prefer: {
115284 type: "object",
115285 additionalProperties: {
115286 type: "string"
115287 }
115288 },
115289 preferType: {
115290 type: "object",
115291 additionalProperties: {
115292 type: "string"
115293 }
115294 },
115295 requireReturn: {
115296 type: "boolean",
115297 default: true
115298 },
115299 requireParamDescription: {
115300 type: "boolean",
115301 default: true
115302 },
115303 requireReturnDescription: {
115304 type: "boolean",
115305 default: true
115306 },
115307 matchDescription: {
115308 type: "string"
115309 },
115310 requireReturnType: {
115311 type: "boolean",
115312 default: true
115313 },
115314 requireParamType: {
115315 type: "boolean",
115316 default: true
115317 }
115318 },
115319 additionalProperties: false
115320 }],
115321 fixable: "code",
115322 messages: {
115323 unexpectedTag: "Unexpected @{{title}} tag; function has no return statement.",
115324 expected: "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.",
115325 use: "Use @{{name}} instead.",
115326 useType: "Use '{{expectedTypeName}}' instead of '{{currentTypeName}}'.",
115327 syntaxError: "JSDoc syntax error.",
115328 missingBrace: "JSDoc type missing brace.",
115329 missingParamDesc: "Missing JSDoc parameter description for '{{name}}'.",
115330 missingParamType: "Missing JSDoc parameter type for '{{name}}'.",
115331 missingReturnType: "Missing JSDoc return type.",
115332 missingReturnDesc: "Missing JSDoc return description.",
115333 missingReturn: "Missing JSDoc @{{returns}} for function.",
115334 missingParam: "Missing JSDoc for parameter '{{name}}'.",
115335 duplicateParam: "Duplicate JSDoc parameter '{{name}}'.",
115336 unsatisfiedDesc: "JSDoc description does not satisfy the regex pattern."
115337 },
115338 deprecated: true,
115339 replacedBy: []
115340 },
115341
115342 create(context) {
115343 const options = context.options[0] || {},
115344 prefer = options.prefer || {},
115345 sourceCode = context.getSourceCode(),
115346 // these both default to true, so you have to explicitly make them false
115347 requireReturn = options.requireReturn !== false,
115348 requireParamDescription = options.requireParamDescription !== false,
115349 requireReturnDescription = options.requireReturnDescription !== false,
115350 requireReturnType = options.requireReturnType !== false,
115351 requireParamType = options.requireParamType !== false,
115352 preferType = options.preferType || {},
115353 checkPreferType = Object.keys(preferType).length !== 0; //--------------------------------------------------------------------------
115354 // Helpers
115355 //--------------------------------------------------------------------------
115356 // Using a stack to store if a function returns or not (handling nested functions)
115357
115358 const fns = [];
115359 /**
115360 * Check if node type is a Class
115361 * @param {ASTNode} node node to check.
115362 * @returns {boolean} True is its a class
115363 * @private
115364 */
115365
115366 function isTypeClass(node) {
115367 return node.type === "ClassExpression" || node.type === "ClassDeclaration";
115368 }
115369 /**
115370 * When parsing a new function, store it in our function stack.
115371 * @param {ASTNode} node A function node to check.
115372 * @returns {void}
115373 * @private
115374 */
115375
115376
115377 function startFunction(node) {
115378 fns.push({
115379 returnPresent: node.type === "ArrowFunctionExpression" && node.body.type !== "BlockStatement" || isTypeClass(node) || node.async
115380 });
115381 }
115382 /**
115383 * Indicate that return has been found in the current function.
115384 * @param {ASTNode} node The return node.
115385 * @returns {void}
115386 * @private
115387 */
115388
115389
115390 function addReturn(node) {
115391 const functionState = fns[fns.length - 1];
115392
115393 if (functionState && node.argument !== null) {
115394 functionState.returnPresent = true;
115395 }
115396 }
115397 /**
115398 * Check if return tag type is void or undefined
115399 * @param {Object} tag JSDoc tag
115400 * @returns {boolean} True if its of type void or undefined
115401 * @private
115402 */
115403
115404
115405 function isValidReturnType(tag) {
115406 return tag.type === null || tag.type.name === "void" || tag.type.type === "UndefinedLiteral";
115407 }
115408 /**
115409 * Check if type should be validated based on some exceptions
115410 * @param {Object} type JSDoc tag
115411 * @returns {boolean} True if it can be validated
115412 * @private
115413 */
115414
115415
115416 function canTypeBeValidated(type) {
115417 return type !== "UndefinedLiteral" && // {undefined} as there is no name property available.
115418 type !== "NullLiteral" && // {null}
115419 type !== "NullableLiteral" && // {?}
115420 type !== "FunctionType" && // {function(a)}
115421 type !== "AllLiteral"; // {*}
115422 }
115423 /**
115424 * Extract the current and expected type based on the input type object
115425 * @param {Object} type JSDoc tag
115426 * @returns {{currentType: Doctrine.Type, expectedTypeName: string}} The current type annotation and
115427 * the expected name of the annotation
115428 * @private
115429 */
115430
115431
115432 function getCurrentExpectedTypes(type) {
115433 let currentType;
115434
115435 if (type.name) {
115436 currentType = type;
115437 } else if (type.expression) {
115438 currentType = type.expression;
115439 }
115440
115441 return {
115442 currentType,
115443 expectedTypeName: currentType && preferType[currentType.name]
115444 };
115445 }
115446 /**
115447 * Gets the location of a JSDoc node in a file
115448 * @param {Token} jsdocComment The comment that this node is parsed from
115449 * @param {{range: number[]}} parsedJsdocNode A tag or other node which was parsed from this comment
115450 * @returns {{start: SourceLocation, end: SourceLocation}} The 0-based source location for the tag
115451 */
115452
115453
115454 function getAbsoluteRange(jsdocComment, parsedJsdocNode) {
115455 return {
115456 start: sourceCode.getLocFromIndex(jsdocComment.range[0] + 2 + parsedJsdocNode.range[0]),
115457 end: sourceCode.getLocFromIndex(jsdocComment.range[0] + 2 + parsedJsdocNode.range[1])
115458 };
115459 }
115460 /**
115461 * Validate type for a given JSDoc node
115462 * @param {Object} jsdocNode JSDoc node
115463 * @param {Object} type JSDoc tag
115464 * @returns {void}
115465 * @private
115466 */
115467
115468
115469 function validateType(jsdocNode, type) {
115470 if (!type || !canTypeBeValidated(type.type)) {
115471 return;
115472 }
115473
115474 const typesToCheck = [];
115475 let elements = [];
115476
115477 switch (type.type) {
115478 case "TypeApplication":
115479 // {Array.<String>}
115480 elements = type.applications[0].type === "UnionType" ? type.applications[0].elements : type.applications;
115481 typesToCheck.push(getCurrentExpectedTypes(type));
115482 break;
115483
115484 case "RecordType":
115485 // {{20:String}}
115486 elements = type.fields;
115487 break;
115488
115489 case "UnionType": // {String|number|Test}
115490
115491 case "ArrayType":
115492 // {[String, number, Test]}
115493 elements = type.elements;
115494 break;
115495
115496 case "FieldType":
115497 // Array.<{count: number, votes: number}>
115498 if (type.value) {
115499 typesToCheck.push(getCurrentExpectedTypes(type.value));
115500 }
115501
115502 break;
115503
115504 default:
115505 typesToCheck.push(getCurrentExpectedTypes(type));
115506 }
115507
115508 elements.forEach(validateType.bind(null, jsdocNode));
115509 typesToCheck.forEach(typeToCheck => {
115510 if (typeToCheck.expectedTypeName && typeToCheck.expectedTypeName !== typeToCheck.currentType.name) {
115511 context.report({
115512 node: jsdocNode,
115513 messageId: "useType",
115514 loc: getAbsoluteRange(jsdocNode, typeToCheck.currentType),
115515 data: {
115516 currentTypeName: typeToCheck.currentType.name,
115517 expectedTypeName: typeToCheck.expectedTypeName
115518 },
115519
115520 fix(fixer) {
115521 return fixer.replaceTextRange(typeToCheck.currentType.range.map(indexInComment => jsdocNode.range[0] + 2 + indexInComment), typeToCheck.expectedTypeName);
115522 }
115523
115524 });
115525 }
115526 });
115527 }
115528 /**
115529 * Validate the JSDoc node and output warnings if anything is wrong.
115530 * @param {ASTNode} node The AST node to check.
115531 * @returns {void}
115532 * @private
115533 */
115534
115535
115536 function checkJSDoc(node) {
115537 const jsdocNode = sourceCode.getJSDocComment(node),
115538 functionData = fns.pop(),
115539 paramTagsByName = Object.create(null),
115540 paramTags = [];
115541 let hasReturns = false,
115542 returnsTag,
115543 hasConstructor = false,
115544 isInterface = false,
115545 isOverride = false,
115546 isAbstract = false; // make sure only to validate JSDoc comments
115547
115548 if (jsdocNode) {
115549 let jsdoc;
115550
115551 try {
115552 jsdoc = doctrine.parse(jsdocNode.value, {
115553 strict: true,
115554 unwrap: true,
115555 sloppy: true,
115556 range: true
115557 });
115558 } catch (ex) {
115559 if (/braces/iu.test(ex.message)) {
115560 context.report({
115561 node: jsdocNode,
115562 messageId: "missingBrace"
115563 });
115564 } else {
115565 context.report({
115566 node: jsdocNode,
115567 messageId: "syntaxError"
115568 });
115569 }
115570
115571 return;
115572 }
115573
115574 jsdoc.tags.forEach(tag => {
115575 switch (tag.title.toLowerCase()) {
115576 case "param":
115577 case "arg":
115578 case "argument":
115579 paramTags.push(tag);
115580 break;
115581
115582 case "return":
115583 case "returns":
115584 hasReturns = true;
115585 returnsTag = tag;
115586 break;
115587
115588 case "constructor":
115589 case "class":
115590 hasConstructor = true;
115591 break;
115592
115593 case "override":
115594 case "inheritdoc":
115595 isOverride = true;
115596 break;
115597
115598 case "abstract":
115599 case "virtual":
115600 isAbstract = true;
115601 break;
115602
115603 case "interface":
115604 isInterface = true;
115605 break;
115606 // no default
115607 } // check tag preferences
115608
115609
115610 if (Object.prototype.hasOwnProperty.call(prefer, tag.title) && tag.title !== prefer[tag.title]) {
115611 const entireTagRange = getAbsoluteRange(jsdocNode, tag);
115612 context.report({
115613 node: jsdocNode,
115614 messageId: "use",
115615 loc: {
115616 start: entireTagRange.start,
115617 end: {
115618 line: entireTagRange.start.line,
115619 column: entireTagRange.start.column + "@".concat(tag.title).length
115620 }
115621 },
115622 data: {
115623 name: prefer[tag.title]
115624 },
115625
115626 fix(fixer) {
115627 return fixer.replaceTextRange([jsdocNode.range[0] + tag.range[0] + 3, jsdocNode.range[0] + tag.range[0] + tag.title.length + 3], prefer[tag.title]);
115628 }
115629
115630 });
115631 } // validate the types
115632
115633
115634 if (checkPreferType && tag.type) {
115635 validateType(jsdocNode, tag.type);
115636 }
115637 });
115638 paramTags.forEach(param => {
115639 if (requireParamType && !param.type) {
115640 context.report({
115641 node: jsdocNode,
115642 messageId: "missingParamType",
115643 loc: getAbsoluteRange(jsdocNode, param),
115644 data: {
115645 name: param.name
115646 }
115647 });
115648 }
115649
115650 if (!param.description && requireParamDescription) {
115651 context.report({
115652 node: jsdocNode,
115653 messageId: "missingParamDesc",
115654 loc: getAbsoluteRange(jsdocNode, param),
115655 data: {
115656 name: param.name
115657 }
115658 });
115659 }
115660
115661 if (paramTagsByName[param.name]) {
115662 context.report({
115663 node: jsdocNode,
115664 messageId: "duplicateParam",
115665 loc: getAbsoluteRange(jsdocNode, param),
115666 data: {
115667 name: param.name
115668 }
115669 });
115670 } else if (param.name.indexOf(".") === -1) {
115671 paramTagsByName[param.name] = param;
115672 }
115673 });
115674
115675 if (hasReturns) {
115676 if (!requireReturn && !functionData.returnPresent && (returnsTag.type === null || !isValidReturnType(returnsTag)) && !isAbstract) {
115677 context.report({
115678 node: jsdocNode,
115679 messageId: "unexpectedTag",
115680 loc: getAbsoluteRange(jsdocNode, returnsTag),
115681 data: {
115682 title: returnsTag.title
115683 }
115684 });
115685 } else {
115686 if (requireReturnType && !returnsTag.type) {
115687 context.report({
115688 node: jsdocNode,
115689 messageId: "missingReturnType"
115690 });
115691 }
115692
115693 if (!isValidReturnType(returnsTag) && !returnsTag.description && requireReturnDescription) {
115694 context.report({
115695 node: jsdocNode,
115696 messageId: "missingReturnDesc"
115697 });
115698 }
115699 }
115700 } // check for functions missing @returns
115701
115702
115703 if (!isOverride && !hasReturns && !hasConstructor && !isInterface && node.parent.kind !== "get" && node.parent.kind !== "constructor" && node.parent.kind !== "set" && !isTypeClass(node)) {
115704 if (requireReturn || functionData.returnPresent && !node.async) {
115705 context.report({
115706 node: jsdocNode,
115707 messageId: "missingReturn",
115708 data: {
115709 returns: prefer.returns || "returns"
115710 }
115711 });
115712 }
115713 } // check the parameters
115714
115715
115716 const jsdocParamNames = Object.keys(paramTagsByName);
115717
115718 if (node.params) {
115719 node.params.forEach((param, paramsIndex) => {
115720 const bindingParam = param.type === "AssignmentPattern" ? param.left : param; // TODO(nzakas): Figure out logical things to do with destructured, default, rest params
115721
115722 if (bindingParam.type === "Identifier") {
115723 const name = bindingParam.name;
115724
115725 if (jsdocParamNames[paramsIndex] && name !== jsdocParamNames[paramsIndex]) {
115726 context.report({
115727 node: jsdocNode,
115728 messageId: "expected",
115729 loc: getAbsoluteRange(jsdocNode, paramTagsByName[jsdocParamNames[paramsIndex]]),
115730 data: {
115731 name,
115732 jsdocName: jsdocParamNames[paramsIndex]
115733 }
115734 });
115735 } else if (!paramTagsByName[name] && !isOverride) {
115736 context.report({
115737 node: jsdocNode,
115738 messageId: "missingParam",
115739 data: {
115740 name
115741 }
115742 });
115743 }
115744 }
115745 });
115746 }
115747
115748 if (options.matchDescription) {
115749 const regex = new RegExp(options.matchDescription, "u");
115750
115751 if (!regex.test(jsdoc.description)) {
115752 context.report({
115753 node: jsdocNode,
115754 messageId: "unsatisfiedDesc"
115755 });
115756 }
115757 }
115758 }
115759 } //--------------------------------------------------------------------------
115760 // Public
115761 //--------------------------------------------------------------------------
115762
115763
115764 return {
115765 ArrowFunctionExpression: startFunction,
115766 FunctionExpression: startFunction,
115767 FunctionDeclaration: startFunction,
115768 ClassExpression: startFunction,
115769 ClassDeclaration: startFunction,
115770 "ArrowFunctionExpression:exit": checkJSDoc,
115771 "FunctionExpression:exit": checkJSDoc,
115772 "FunctionDeclaration:exit": checkJSDoc,
115773 "ClassExpression:exit": checkJSDoc,
115774 "ClassDeclaration:exit": checkJSDoc,
115775 ReturnStatement: addReturn
115776 };
115777 }
115778
115779 };
115780
115781 /***/ }),
115782 /* 844 */
115783 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
115784
115785 /*
115786 * @fileoverview Main Doctrine object
115787 * @author Yusuke Suzuki <utatane.tea@gmail.com>
115788 * @author Dan Tao <daniel.tao@gmail.com>
115789 * @author Andrew Eisenberg <andrew@eisenberg.as>
115790 */
115791 (function () {
115792 'use strict';
115793
115794 var typed, utility, jsdoc, esutils, hasOwnProperty;
115795 esutils = __webpack_require__(549);
115796 typed = __webpack_require__(845);
115797 utility = __webpack_require__(846);
115798
115799 function sliceSource(source, index, last) {
115800 return source.slice(index, last);
115801 }
115802
115803 hasOwnProperty = function () {
115804 var func = Object.prototype.hasOwnProperty;
115805 return function hasOwnProperty(obj, name) {
115806 return func.call(obj, name);
115807 };
115808 }();
115809
115810 function shallowCopy(obj) {
115811 var ret = {},
115812 key;
115813
115814 for (key in obj) {
115815 if (obj.hasOwnProperty(key)) {
115816 ret[key] = obj[key];
115817 }
115818 }
115819
115820 return ret;
115821 }
115822
115823 function isASCIIAlphanumeric(ch) {
115824 return ch >= 0x61
115825 /* 'a' */
115826 && ch <= 0x7A
115827 /* 'z' */
115828 || ch >= 0x41
115829 /* 'A' */
115830 && ch <= 0x5A
115831 /* 'Z' */
115832 || ch >= 0x30
115833 /* '0' */
115834 && ch <= 0x39
115835 /* '9' */
115836 ;
115837 }
115838
115839 function isParamTitle(title) {
115840 return title === 'param' || title === 'argument' || title === 'arg';
115841 }
115842
115843 function isReturnTitle(title) {
115844 return title === 'return' || title === 'returns';
115845 }
115846
115847 function isProperty(title) {
115848 return title === 'property' || title === 'prop';
115849 }
115850
115851 function isNameParameterRequired(title) {
115852 return isParamTitle(title) || isProperty(title) || title === 'alias' || title === 'this' || title === 'mixes' || title === 'requires';
115853 }
115854
115855 function isAllowedName(title) {
115856 return isNameParameterRequired(title) || title === 'const' || title === 'constant';
115857 }
115858
115859 function isAllowedNested(title) {
115860 return isProperty(title) || isParamTitle(title);
115861 }
115862
115863 function isAllowedOptional(title) {
115864 return isProperty(title) || isParamTitle(title);
115865 }
115866
115867 function isTypeParameterRequired(title) {
115868 return isParamTitle(title) || isReturnTitle(title) || title === 'define' || title === 'enum' || title === 'implements' || title === 'this' || title === 'type' || title === 'typedef' || isProperty(title);
115869 } // Consider deprecation instead using 'isTypeParameterRequired' and 'Rules' declaration to pick when a type is optional/required
115870 // This would require changes to 'parseType'
115871
115872
115873 function isAllowedType(title) {
115874 return isTypeParameterRequired(title) || title === 'throws' || title === 'const' || title === 'constant' || title === 'namespace' || title === 'member' || title === 'var' || title === 'module' || title === 'constructor' || title === 'class' || title === 'extends' || title === 'augments' || title === 'public' || title === 'private' || title === 'protected';
115875 } // A regex character class that contains all whitespace except linebreak characters (\r, \n, \u2028, \u2029)
115876
115877
115878 var WHITESPACE = '[ \\f\\t\\v\\u00a0\\u1680\\u180e\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]';
115879 var STAR_MATCHER = '(' + WHITESPACE + '*(?:\\*' + WHITESPACE + '?)?)(.+|[\r\n\u2028\u2029])';
115880
115881 function unwrapComment(doc) {
115882 // JSDoc comment is following form
115883 // /**
115884 // * .......
115885 // */
115886 return doc. // remove /**
115887 replace(/^\/\*\*?/, ''). // remove */
115888 replace(/\*\/$/, ''). // remove ' * ' at the beginning of a line
115889 replace(new RegExp(STAR_MATCHER, 'g'), '$2'). // remove trailing whitespace
115890 replace(/\s*$/, '');
115891 }
115892 /**
115893 * Converts an index in an "unwrapped" JSDoc comment to the corresponding index in the original "wrapped" version
115894 * @param {string} originalSource The original wrapped comment
115895 * @param {number} unwrappedIndex The index of a character in the unwrapped string
115896 * @returns {number} The index of the corresponding character in the original wrapped string
115897 */
115898
115899
115900 function convertUnwrappedCommentIndex(originalSource, unwrappedIndex) {
115901 var replacedSource = originalSource.replace(/^\/\*\*?/, '');
115902 var numSkippedChars = 0;
115903 var matcher = new RegExp(STAR_MATCHER, 'g');
115904 var match;
115905
115906 while (match = matcher.exec(replacedSource)) {
115907 numSkippedChars += match[1].length;
115908
115909 if (match.index + match[0].length > unwrappedIndex + numSkippedChars) {
115910 return unwrappedIndex + numSkippedChars + originalSource.length - replacedSource.length;
115911 }
115912 }
115913
115914 return originalSource.replace(/\*\/$/, '').replace(/\s*$/, '').length;
115915 } // JSDoc Tag Parser
115916
115917
115918 (function (exports) {
115919 var Rules, index, lineNumber, length, source, originalSource, recoverable, sloppy, strict;
115920
115921 function advance() {
115922 var ch = source.charCodeAt(index);
115923 index += 1;
115924
115925 if (esutils.code.isLineTerminator(ch) && !(ch === 0x0D
115926 /* '\r' */
115927 && source.charCodeAt(index) === 0x0A
115928 /* '\n' */
115929 )) {
115930 lineNumber += 1;
115931 }
115932
115933 return String.fromCharCode(ch);
115934 }
115935
115936 function scanTitle() {
115937 var title = ''; // waste '@'
115938
115939 advance();
115940
115941 while (index < length && isASCIIAlphanumeric(source.charCodeAt(index))) {
115942 title += advance();
115943 }
115944
115945 return title;
115946 }
115947
115948 function seekContent() {
115949 var ch,
115950 waiting,
115951 last = index;
115952 waiting = false;
115953
115954 while (last < length) {
115955 ch = source.charCodeAt(last);
115956
115957 if (esutils.code.isLineTerminator(ch) && !(ch === 0x0D
115958 /* '\r' */
115959 && source.charCodeAt(last + 1) === 0x0A
115960 /* '\n' */
115961 )) {
115962 waiting = true;
115963 } else if (waiting) {
115964 if (ch === 0x40
115965 /* '@' */
115966 ) {
115967 break;
115968 }
115969
115970 if (!esutils.code.isWhiteSpace(ch)) {
115971 waiting = false;
115972 }
115973 }
115974
115975 last += 1;
115976 }
115977
115978 return last;
115979 } // type expression may have nest brace, such as,
115980 // { { ok: string } }
115981 //
115982 // therefore, scanning type expression with balancing braces.
115983
115984
115985 function parseType(title, last, addRange) {
115986 var ch,
115987 brace,
115988 type,
115989 startIndex,
115990 direct = false; // search '{'
115991
115992 while (index < last) {
115993 ch = source.charCodeAt(index);
115994
115995 if (esutils.code.isWhiteSpace(ch)) {
115996 advance();
115997 } else if (ch === 0x7B
115998 /* '{' */
115999 ) {
116000 advance();
116001 break;
116002 } else {
116003 // this is direct pattern
116004 direct = true;
116005 break;
116006 }
116007 }
116008
116009 if (direct) {
116010 return null;
116011 } // type expression { is found
116012
116013
116014 brace = 1;
116015 type = '';
116016
116017 while (index < last) {
116018 ch = source.charCodeAt(index);
116019
116020 if (esutils.code.isLineTerminator(ch)) {
116021 advance();
116022 } else {
116023 if (ch === 0x7D
116024 /* '}' */
116025 ) {
116026 brace -= 1;
116027
116028 if (brace === 0) {
116029 advance();
116030 break;
116031 }
116032 } else if (ch === 0x7B
116033 /* '{' */
116034 ) {
116035 brace += 1;
116036 }
116037
116038 if (type === '') {
116039 startIndex = index;
116040 }
116041
116042 type += advance();
116043 }
116044 }
116045
116046 if (brace !== 0) {
116047 // braces is not balanced
116048 return utility.throwError('Braces are not balanced');
116049 }
116050
116051 if (isAllowedOptional(title)) {
116052 return typed.parseParamType(type, {
116053 startIndex: convertIndex(startIndex),
116054 range: addRange
116055 });
116056 }
116057
116058 return typed.parseType(type, {
116059 startIndex: convertIndex(startIndex),
116060 range: addRange
116061 });
116062 }
116063
116064 function scanIdentifier(last) {
116065 var identifier;
116066
116067 if (!esutils.code.isIdentifierStartES5(source.charCodeAt(index)) && !source[index].match(/[0-9]/)) {
116068 return null;
116069 }
116070
116071 identifier = advance();
116072
116073 while (index < last && esutils.code.isIdentifierPartES5(source.charCodeAt(index))) {
116074 identifier += advance();
116075 }
116076
116077 return identifier;
116078 }
116079
116080 function skipWhiteSpace(last) {
116081 while (index < last && (esutils.code.isWhiteSpace(source.charCodeAt(index)) || esutils.code.isLineTerminator(source.charCodeAt(index)))) {
116082 advance();
116083 }
116084 }
116085
116086 function parseName(last, allowBrackets, allowNestedParams) {
116087 var name = '',
116088 useBrackets,
116089 insideString;
116090 skipWhiteSpace(last);
116091
116092 if (index >= last) {
116093 return null;
116094 }
116095
116096 if (source.charCodeAt(index) === 0x5B
116097 /* '[' */
116098 ) {
116099 if (allowBrackets) {
116100 useBrackets = true;
116101 name = advance();
116102 } else {
116103 return null;
116104 }
116105 }
116106
116107 name += scanIdentifier(last);
116108
116109 if (allowNestedParams) {
116110 if (source.charCodeAt(index) === 0x3A
116111 /* ':' */
116112 && (name === 'module' || name === 'external' || name === 'event')) {
116113 name += advance();
116114 name += scanIdentifier(last);
116115 }
116116
116117 if (source.charCodeAt(index) === 0x5B
116118 /* '[' */
116119 && source.charCodeAt(index + 1) === 0x5D
116120 /* ']' */
116121 ) {
116122 name += advance();
116123 name += advance();
116124 }
116125
116126 while (source.charCodeAt(index) === 0x2E
116127 /* '.' */
116128 || source.charCodeAt(index) === 0x2F
116129 /* '/' */
116130 || source.charCodeAt(index) === 0x23
116131 /* '#' */
116132 || source.charCodeAt(index) === 0x2D
116133 /* '-' */
116134 || source.charCodeAt(index) === 0x7E
116135 /* '~' */
116136 ) {
116137 name += advance();
116138 name += scanIdentifier(last);
116139 }
116140 }
116141
116142 if (useBrackets) {
116143 skipWhiteSpace(last); // do we have a default value for this?
116144
116145 if (source.charCodeAt(index) === 0x3D
116146 /* '=' */
116147 ) {
116148 // consume the '='' symbol
116149 name += advance();
116150 skipWhiteSpace(last);
116151 var ch;
116152 var bracketDepth = 1; // scan in the default value
116153
116154 while (index < last) {
116155 ch = source.charCodeAt(index);
116156
116157 if (esutils.code.isWhiteSpace(ch)) {
116158 if (!insideString) {
116159 skipWhiteSpace(last);
116160 ch = source.charCodeAt(index);
116161 }
116162 }
116163
116164 if (ch === 0x27
116165 /* ''' */
116166 ) {
116167 if (!insideString) {
116168 insideString = '\'';
116169 } else {
116170 if (insideString === '\'') {
116171 insideString = '';
116172 }
116173 }
116174 }
116175
116176 if (ch === 0x22
116177 /* '"' */
116178 ) {
116179 if (!insideString) {
116180 insideString = '"';
116181 } else {
116182 if (insideString === '"') {
116183 insideString = '';
116184 }
116185 }
116186 }
116187
116188 if (ch === 0x5B
116189 /* '[' */
116190 ) {
116191 bracketDepth++;
116192 } else if (ch === 0x5D
116193 /* ']' */
116194 && --bracketDepth === 0) {
116195 break;
116196 }
116197
116198 name += advance();
116199 }
116200 }
116201
116202 skipWhiteSpace(last);
116203
116204 if (index >= last || source.charCodeAt(index) !== 0x5D
116205 /* ']' */
116206 ) {
116207 // we never found a closing ']'
116208 return null;
116209 } // collect the last ']'
116210
116211
116212 name += advance();
116213 }
116214
116215 return name;
116216 }
116217
116218 function skipToTag() {
116219 while (index < length && source.charCodeAt(index) !== 0x40
116220 /* '@' */
116221 ) {
116222 advance();
116223 }
116224
116225 if (index >= length) {
116226 return false;
116227 }
116228
116229 utility.assert(source.charCodeAt(index) === 0x40
116230 /* '@' */
116231 );
116232 return true;
116233 }
116234
116235 function convertIndex(rangeIndex) {
116236 if (source === originalSource) {
116237 return rangeIndex;
116238 }
116239
116240 return convertUnwrappedCommentIndex(originalSource, rangeIndex);
116241 }
116242
116243 function TagParser(options, title) {
116244 this._options = options;
116245 this._title = title.toLowerCase();
116246 this._tag = {
116247 title: title,
116248 description: null
116249 };
116250
116251 if (this._options.lineNumbers) {
116252 this._tag.lineNumber = lineNumber;
116253 }
116254
116255 this._first = index - title.length - 1;
116256 this._last = 0; // space to save special information for title parsers.
116257
116258 this._extra = {};
116259 } // addError(err, ...)
116260
116261
116262 TagParser.prototype.addError = function addError(errorText) {
116263 var args = Array.prototype.slice.call(arguments, 1),
116264 msg = errorText.replace(/%(\d)/g, function (whole, index) {
116265 utility.assert(index < args.length, 'Message reference must be in range');
116266 return args[index];
116267 });
116268
116269 if (!this._tag.errors) {
116270 this._tag.errors = [];
116271 }
116272
116273 if (strict) {
116274 utility.throwError(msg);
116275 }
116276
116277 this._tag.errors.push(msg);
116278
116279 return recoverable;
116280 };
116281
116282 TagParser.prototype.parseType = function () {
116283 // type required titles
116284 if (isTypeParameterRequired(this._title)) {
116285 try {
116286 this._tag.type = parseType(this._title, this._last, this._options.range);
116287
116288 if (!this._tag.type) {
116289 if (!isParamTitle(this._title) && !isReturnTitle(this._title)) {
116290 if (!this.addError('Missing or invalid tag type')) {
116291 return false;
116292 }
116293 }
116294 }
116295 } catch (error) {
116296 this._tag.type = null;
116297
116298 if (!this.addError(error.message)) {
116299 return false;
116300 }
116301 }
116302 } else if (isAllowedType(this._title)) {
116303 // optional types
116304 try {
116305 this._tag.type = parseType(this._title, this._last, this._options.range);
116306 } catch (e) {//For optional types, lets drop the thrown error when we hit the end of the file
116307 }
116308 }
116309
116310 return true;
116311 };
116312
116313 TagParser.prototype._parseNamePath = function (optional) {
116314 var name;
116315 name = parseName(this._last, sloppy && isAllowedOptional(this._title), true);
116316
116317 if (!name) {
116318 if (!optional) {
116319 if (!this.addError('Missing or invalid tag name')) {
116320 return false;
116321 }
116322 }
116323 }
116324
116325 this._tag.name = name;
116326 return true;
116327 };
116328
116329 TagParser.prototype.parseNamePath = function () {
116330 return this._parseNamePath(false);
116331 };
116332
116333 TagParser.prototype.parseNamePathOptional = function () {
116334 return this._parseNamePath(true);
116335 };
116336
116337 TagParser.prototype.parseName = function () {
116338 var assign, name; // param, property requires name
116339
116340 if (isAllowedName(this._title)) {
116341 this._tag.name = parseName(this._last, sloppy && isAllowedOptional(this._title), isAllowedNested(this._title));
116342
116343 if (!this._tag.name) {
116344 if (!isNameParameterRequired(this._title)) {
116345 return true;
116346 } // it's possible the name has already been parsed but interpreted as a type
116347 // it's also possible this is a sloppy declaration, in which case it will be
116348 // fixed at the end
116349
116350
116351 if (isParamTitle(this._title) && this._tag.type && this._tag.type.name) {
116352 this._extra.name = this._tag.type;
116353 this._tag.name = this._tag.type.name;
116354 this._tag.type = null;
116355 } else {
116356 if (!this.addError('Missing or invalid tag name')) {
116357 return false;
116358 }
116359 }
116360 } else {
116361 name = this._tag.name;
116362
116363 if (name.charAt(0) === '[' && name.charAt(name.length - 1) === ']') {
116364 // extract the default value if there is one
116365 // example: @param {string} [somebody=John Doe] description
116366 assign = name.substring(1, name.length - 1).split('=');
116367
116368 if (assign.length > 1) {
116369 this._tag['default'] = assign.slice(1).join('=');
116370 }
116371
116372 this._tag.name = assign[0]; // convert to an optional type
116373
116374 if (this._tag.type && this._tag.type.type !== 'OptionalType') {
116375 this._tag.type = {
116376 type: 'OptionalType',
116377 expression: this._tag.type
116378 };
116379 }
116380 }
116381 }
116382 }
116383
116384 return true;
116385 };
116386
116387 TagParser.prototype.parseDescription = function parseDescription() {
116388 var description = sliceSource(source, index, this._last).trim();
116389
116390 if (description) {
116391 if (/^-\s+/.test(description)) {
116392 description = description.substring(2);
116393 }
116394
116395 this._tag.description = description;
116396 }
116397
116398 return true;
116399 };
116400
116401 TagParser.prototype.parseCaption = function parseDescription() {
116402 var description = sliceSource(source, index, this._last).trim();
116403 var captionStartTag = '<caption>';
116404 var captionEndTag = '</caption>';
116405 var captionStart = description.indexOf(captionStartTag);
116406 var captionEnd = description.indexOf(captionEndTag);
116407
116408 if (captionStart >= 0 && captionEnd >= 0) {
116409 this._tag.caption = description.substring(captionStart + captionStartTag.length, captionEnd).trim();
116410 this._tag.description = description.substring(captionEnd + captionEndTag.length).trim();
116411 } else {
116412 this._tag.description = description;
116413 }
116414
116415 return true;
116416 };
116417
116418 TagParser.prototype.parseKind = function parseKind() {
116419 var kind, kinds;
116420 kinds = {
116421 'class': true,
116422 'constant': true,
116423 'event': true,
116424 'external': true,
116425 'file': true,
116426 'function': true,
116427 'member': true,
116428 'mixin': true,
116429 'module': true,
116430 'namespace': true,
116431 'typedef': true
116432 };
116433 kind = sliceSource(source, index, this._last).trim();
116434 this._tag.kind = kind;
116435
116436 if (!hasOwnProperty(kinds, kind)) {
116437 if (!this.addError('Invalid kind name \'%0\'', kind)) {
116438 return false;
116439 }
116440 }
116441
116442 return true;
116443 };
116444
116445 TagParser.prototype.parseAccess = function parseAccess() {
116446 var access;
116447 access = sliceSource(source, index, this._last).trim();
116448 this._tag.access = access;
116449
116450 if (access !== 'private' && access !== 'protected' && access !== 'public') {
116451 if (!this.addError('Invalid access name \'%0\'', access)) {
116452 return false;
116453 }
116454 }
116455
116456 return true;
116457 };
116458
116459 TagParser.prototype.parseThis = function parseThis() {
116460 // this name may be a name expression (e.g. {foo.bar}),
116461 // an union (e.g. {foo.bar|foo.baz}) or a name path (e.g. foo.bar)
116462 var value = sliceSource(source, index, this._last).trim();
116463
116464 if (value && value.charAt(0) === '{') {
116465 var gotType = this.parseType();
116466
116467 if (gotType && this._tag.type.type === 'NameExpression' || this._tag.type.type === 'UnionType') {
116468 this._tag.name = this._tag.type.name;
116469 return true;
116470 } else {
116471 return this.addError('Invalid name for this');
116472 }
116473 } else {
116474 return this.parseNamePath();
116475 }
116476 };
116477
116478 TagParser.prototype.parseVariation = function parseVariation() {
116479 var variation, text;
116480 text = sliceSource(source, index, this._last).trim();
116481 variation = parseFloat(text, 10);
116482 this._tag.variation = variation;
116483
116484 if (isNaN(variation)) {
116485 if (!this.addError('Invalid variation \'%0\'', text)) {
116486 return false;
116487 }
116488 }
116489
116490 return true;
116491 };
116492
116493 TagParser.prototype.ensureEnd = function () {
116494 var shouldBeEmpty = sliceSource(source, index, this._last).trim();
116495
116496 if (shouldBeEmpty) {
116497 if (!this.addError('Unknown content \'%0\'', shouldBeEmpty)) {
116498 return false;
116499 }
116500 }
116501
116502 return true;
116503 };
116504
116505 TagParser.prototype.epilogue = function epilogue() {
116506 var description;
116507 description = this._tag.description; // un-fix potentially sloppy declaration
116508
116509 if (isAllowedOptional(this._title) && !this._tag.type && description && description.charAt(0) === '[') {
116510 this._tag.type = this._extra.name;
116511
116512 if (!this._tag.name) {
116513 this._tag.name = undefined;
116514 }
116515
116516 if (!sloppy) {
116517 if (!this.addError('Missing or invalid tag name')) {
116518 return false;
116519 }
116520 }
116521 }
116522
116523 return true;
116524 };
116525
116526 Rules = {
116527 // http://usejsdoc.org/tags-access.html
116528 'access': ['parseAccess'],
116529 // http://usejsdoc.org/tags-alias.html
116530 'alias': ['parseNamePath', 'ensureEnd'],
116531 // http://usejsdoc.org/tags-augments.html
116532 'augments': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
116533 // http://usejsdoc.org/tags-constructor.html
116534 'constructor': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
116535 // Synonym: http://usejsdoc.org/tags-constructor.html
116536 'class': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
116537 // Synonym: http://usejsdoc.org/tags-extends.html
116538 'extends': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
116539 // http://usejsdoc.org/tags-example.html
116540 'example': ['parseCaption'],
116541 // http://usejsdoc.org/tags-deprecated.html
116542 'deprecated': ['parseDescription'],
116543 // http://usejsdoc.org/tags-global.html
116544 'global': ['ensureEnd'],
116545 // http://usejsdoc.org/tags-inner.html
116546 'inner': ['ensureEnd'],
116547 // http://usejsdoc.org/tags-instance.html
116548 'instance': ['ensureEnd'],
116549 // http://usejsdoc.org/tags-kind.html
116550 'kind': ['parseKind'],
116551 // http://usejsdoc.org/tags-mixes.html
116552 'mixes': ['parseNamePath', 'ensureEnd'],
116553 // http://usejsdoc.org/tags-mixin.html
116554 'mixin': ['parseNamePathOptional', 'ensureEnd'],
116555 // http://usejsdoc.org/tags-member.html
116556 'member': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
116557 // http://usejsdoc.org/tags-method.html
116558 'method': ['parseNamePathOptional', 'ensureEnd'],
116559 // http://usejsdoc.org/tags-module.html
116560 'module': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
116561 // Synonym: http://usejsdoc.org/tags-method.html
116562 'func': ['parseNamePathOptional', 'ensureEnd'],
116563 // Synonym: http://usejsdoc.org/tags-method.html
116564 'function': ['parseNamePathOptional', 'ensureEnd'],
116565 // Synonym: http://usejsdoc.org/tags-member.html
116566 'var': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
116567 // http://usejsdoc.org/tags-name.html
116568 'name': ['parseNamePath', 'ensureEnd'],
116569 // http://usejsdoc.org/tags-namespace.html
116570 'namespace': ['parseType', 'parseNamePathOptional', 'ensureEnd'],
116571 // http://usejsdoc.org/tags-private.html
116572 'private': ['parseType', 'parseDescription'],
116573 // http://usejsdoc.org/tags-protected.html
116574 'protected': ['parseType', 'parseDescription'],
116575 // http://usejsdoc.org/tags-public.html
116576 'public': ['parseType', 'parseDescription'],
116577 // http://usejsdoc.org/tags-readonly.html
116578 'readonly': ['ensureEnd'],
116579 // http://usejsdoc.org/tags-requires.html
116580 'requires': ['parseNamePath', 'ensureEnd'],
116581 // http://usejsdoc.org/tags-since.html
116582 'since': ['parseDescription'],
116583 // http://usejsdoc.org/tags-static.html
116584 'static': ['ensureEnd'],
116585 // http://usejsdoc.org/tags-summary.html
116586 'summary': ['parseDescription'],
116587 // http://usejsdoc.org/tags-this.html
116588 'this': ['parseThis', 'ensureEnd'],
116589 // http://usejsdoc.org/tags-todo.html
116590 'todo': ['parseDescription'],
116591 // http://usejsdoc.org/tags-typedef.html
116592 'typedef': ['parseType', 'parseNamePathOptional'],
116593 // http://usejsdoc.org/tags-variation.html
116594 'variation': ['parseVariation'],
116595 // http://usejsdoc.org/tags-version.html
116596 'version': ['parseDescription']
116597 };
116598
116599 TagParser.prototype.parse = function parse() {
116600 var i, iz, sequences, method; // empty title
116601
116602 if (!this._title) {
116603 if (!this.addError('Missing or invalid title')) {
116604 return null;
116605 }
116606 } // Seek to content last index.
116607
116608
116609 this._last = seekContent(this._title);
116610
116611 if (this._options.range) {
116612 this._tag.range = [this._first, source.slice(0, this._last).replace(/\s*$/, '').length].map(convertIndex);
116613 }
116614
116615 if (hasOwnProperty(Rules, this._title)) {
116616 sequences = Rules[this._title];
116617 } else {
116618 // default sequences
116619 sequences = ['parseType', 'parseName', 'parseDescription', 'epilogue'];
116620 }
116621
116622 for (i = 0, iz = sequences.length; i < iz; ++i) {
116623 method = sequences[i];
116624
116625 if (!this[method]()) {
116626 return null;
116627 }
116628 }
116629
116630 return this._tag;
116631 };
116632
116633 function parseTag(options) {
116634 var title, parser, tag; // skip to tag
116635
116636 if (!skipToTag()) {
116637 return null;
116638 } // scan title
116639
116640
116641 title = scanTitle(); // construct tag parser
116642
116643 parser = new TagParser(options, title);
116644 tag = parser.parse(); // Seek global index to end of this tag.
116645
116646 while (index < parser._last) {
116647 advance();
116648 }
116649
116650 return tag;
116651 } //
116652 // Parse JSDoc
116653 //
116654
116655
116656 function scanJSDocDescription(preserveWhitespace) {
116657 var description = '',
116658 ch,
116659 atAllowed;
116660 atAllowed = true;
116661
116662 while (index < length) {
116663 ch = source.charCodeAt(index);
116664
116665 if (atAllowed && ch === 0x40
116666 /* '@' */
116667 ) {
116668 break;
116669 }
116670
116671 if (esutils.code.isLineTerminator(ch)) {
116672 atAllowed = true;
116673 } else if (atAllowed && !esutils.code.isWhiteSpace(ch)) {
116674 atAllowed = false;
116675 }
116676
116677 description += advance();
116678 }
116679
116680 return preserveWhitespace ? description : description.trim();
116681 }
116682
116683 function parse(comment, options) {
116684 var tags = [],
116685 tag,
116686 description,
116687 interestingTags,
116688 i,
116689 iz;
116690
116691 if (options === undefined) {
116692 options = {};
116693 }
116694
116695 if (typeof options.unwrap === 'boolean' && options.unwrap) {
116696 source = unwrapComment(comment);
116697 } else {
116698 source = comment;
116699 }
116700
116701 originalSource = comment; // array of relevant tags
116702
116703 if (options.tags) {
116704 if (Array.isArray(options.tags)) {
116705 interestingTags = {};
116706
116707 for (i = 0, iz = options.tags.length; i < iz; i++) {
116708 if (typeof options.tags[i] === 'string') {
116709 interestingTags[options.tags[i]] = true;
116710 } else {
116711 utility.throwError('Invalid "tags" parameter: ' + options.tags);
116712 }
116713 }
116714 } else {
116715 utility.throwError('Invalid "tags" parameter: ' + options.tags);
116716 }
116717 }
116718
116719 length = source.length;
116720 index = 0;
116721 lineNumber = 0;
116722 recoverable = options.recoverable;
116723 sloppy = options.sloppy;
116724 strict = options.strict;
116725 description = scanJSDocDescription(options.preserveWhitespace);
116726
116727 while (true) {
116728 tag = parseTag(options);
116729
116730 if (!tag) {
116731 break;
116732 }
116733
116734 if (!interestingTags || interestingTags.hasOwnProperty(tag.title)) {
116735 tags.push(tag);
116736 }
116737 }
116738
116739 return {
116740 description: description,
116741 tags: tags
116742 };
116743 }
116744
116745 exports.parse = parse;
116746 })(jsdoc = {});
116747
116748 exports.version = utility.VERSION;
116749 exports.parse = jsdoc.parse;
116750 exports.parseType = typed.parseType;
116751 exports.parseParamType = typed.parseParamType;
116752 exports.unwrapComment = unwrapComment;
116753 exports.Syntax = shallowCopy(typed.Syntax);
116754 exports.Error = utility.DoctrineError;
116755 exports.type = {
116756 Syntax: exports.Syntax,
116757 parseType: typed.parseType,
116758 parseParamType: typed.parseParamType,
116759 stringify: typed.stringify
116760 };
116761 })();
116762 /* vim: set sw=4 ts=4 et tw=80 : */
116763
116764 /***/ }),
116765 /* 845 */
116766 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
116767
116768 /*
116769 * @fileoverview Type expression parser.
116770 * @author Yusuke Suzuki <utatane.tea@gmail.com>
116771 * @author Dan Tao <daniel.tao@gmail.com>
116772 * @author Andrew Eisenberg <andrew@eisenberg.as>
116773 */
116774 // "typed", the Type Expression Parser for doctrine.
116775 (function () {
116776 'use strict';
116777
116778 var Syntax, Token, source, length, index, previous, token, value, esutils, utility, rangeOffset, addRange;
116779 esutils = __webpack_require__(549);
116780 utility = __webpack_require__(846);
116781 Syntax = {
116782 NullableLiteral: 'NullableLiteral',
116783 AllLiteral: 'AllLiteral',
116784 NullLiteral: 'NullLiteral',
116785 UndefinedLiteral: 'UndefinedLiteral',
116786 VoidLiteral: 'VoidLiteral',
116787 UnionType: 'UnionType',
116788 ArrayType: 'ArrayType',
116789 RecordType: 'RecordType',
116790 FieldType: 'FieldType',
116791 FunctionType: 'FunctionType',
116792 ParameterType: 'ParameterType',
116793 RestType: 'RestType',
116794 NonNullableType: 'NonNullableType',
116795 OptionalType: 'OptionalType',
116796 NullableType: 'NullableType',
116797 NameExpression: 'NameExpression',
116798 TypeApplication: 'TypeApplication',
116799 StringLiteralType: 'StringLiteralType',
116800 NumericLiteralType: 'NumericLiteralType',
116801 BooleanLiteralType: 'BooleanLiteralType'
116802 };
116803 Token = {
116804 ILLEGAL: 0,
116805 // ILLEGAL
116806 DOT_LT: 1,
116807 // .<
116808 REST: 2,
116809 // ...
116810 LT: 3,
116811 // <
116812 GT: 4,
116813 // >
116814 LPAREN: 5,
116815 // (
116816 RPAREN: 6,
116817 // )
116818 LBRACE: 7,
116819 // {
116820 RBRACE: 8,
116821 // }
116822 LBRACK: 9,
116823 // [
116824 RBRACK: 10,
116825 // ]
116826 COMMA: 11,
116827 // ,
116828 COLON: 12,
116829 // :
116830 STAR: 13,
116831 // *
116832 PIPE: 14,
116833 // |
116834 QUESTION: 15,
116835 // ?
116836 BANG: 16,
116837 // !
116838 EQUAL: 17,
116839 // =
116840 NAME: 18,
116841 // name token
116842 STRING: 19,
116843 // string
116844 NUMBER: 20,
116845 // number
116846 EOF: 21
116847 };
116848
116849 function isTypeName(ch) {
116850 return '><(){}[],:*|?!='.indexOf(String.fromCharCode(ch)) === -1 && !esutils.code.isWhiteSpace(ch) && !esutils.code.isLineTerminator(ch);
116851 }
116852
116853 function Context(previous, index, token, value) {
116854 this._previous = previous;
116855 this._index = index;
116856 this._token = token;
116857 this._value = value;
116858 }
116859
116860 Context.prototype.restore = function () {
116861 previous = this._previous;
116862 index = this._index;
116863 token = this._token;
116864 value = this._value;
116865 };
116866
116867 Context.save = function () {
116868 return new Context(previous, index, token, value);
116869 };
116870
116871 function maybeAddRange(node, range) {
116872 if (addRange) {
116873 node.range = [range[0] + rangeOffset, range[1] + rangeOffset];
116874 }
116875
116876 return node;
116877 }
116878
116879 function advance() {
116880 var ch = source.charAt(index);
116881 index += 1;
116882 return ch;
116883 }
116884
116885 function scanHexEscape(prefix) {
116886 var i,
116887 len,
116888 ch,
116889 code = 0;
116890 len = prefix === 'u' ? 4 : 2;
116891
116892 for (i = 0; i < len; ++i) {
116893 if (index < length && esutils.code.isHexDigit(source.charCodeAt(index))) {
116894 ch = advance();
116895 code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
116896 } else {
116897 return '';
116898 }
116899 }
116900
116901 return String.fromCharCode(code);
116902 }
116903
116904 function scanString() {
116905 var str = '',
116906 quote,
116907 ch,
116908 code,
116909 unescaped,
116910 restore; //TODO review removal octal = false
116911
116912 quote = source.charAt(index);
116913 ++index;
116914
116915 while (index < length) {
116916 ch = advance();
116917
116918 if (ch === quote) {
116919 quote = '';
116920 break;
116921 } else if (ch === '\\') {
116922 ch = advance();
116923
116924 if (!esutils.code.isLineTerminator(ch.charCodeAt(0))) {
116925 switch (ch) {
116926 case 'n':
116927 str += '\n';
116928 break;
116929
116930 case 'r':
116931 str += '\r';
116932 break;
116933
116934 case 't':
116935 str += '\t';
116936 break;
116937
116938 case 'u':
116939 case 'x':
116940 restore = index;
116941 unescaped = scanHexEscape(ch);
116942
116943 if (unescaped) {
116944 str += unescaped;
116945 } else {
116946 index = restore;
116947 str += ch;
116948 }
116949
116950 break;
116951
116952 case 'b':
116953 str += '\b';
116954 break;
116955
116956 case 'f':
116957 str += '\f';
116958 break;
116959
116960 case 'v':
116961 str += '\v';
116962 break;
116963
116964 default:
116965 if (esutils.code.isOctalDigit(ch.charCodeAt(0))) {
116966 code = '01234567'.indexOf(ch); // \0 is not octal escape sequence
116967 // Deprecating unused code. TODO review removal
116968 //if (code !== 0) {
116969 // octal = true;
116970 //}
116971
116972 if (index < length && esutils.code.isOctalDigit(source.charCodeAt(index))) {
116973 //TODO Review Removal octal = true;
116974 code = code * 8 + '01234567'.indexOf(advance()); // 3 digits are only allowed when string starts
116975 // with 0, 1, 2, 3
116976
116977 if ('0123'.indexOf(ch) >= 0 && index < length && esutils.code.isOctalDigit(source.charCodeAt(index))) {
116978 code = code * 8 + '01234567'.indexOf(advance());
116979 }
116980 }
116981
116982 str += String.fromCharCode(code);
116983 } else {
116984 str += ch;
116985 }
116986
116987 break;
116988 }
116989 } else {
116990 if (ch === '\r' && source.charCodeAt(index) === 0x0A
116991 /* '\n' */
116992 ) {
116993 ++index;
116994 }
116995 }
116996 } else if (esutils.code.isLineTerminator(ch.charCodeAt(0))) {
116997 break;
116998 } else {
116999 str += ch;
117000 }
117001 }
117002
117003 if (quote !== '') {
117004 utility.throwError('unexpected quote');
117005 }
117006
117007 value = str;
117008 return Token.STRING;
117009 }
117010
117011 function scanNumber() {
117012 var number, ch;
117013 number = '';
117014 ch = source.charCodeAt(index);
117015
117016 if (ch !== 0x2E
117017 /* '.' */
117018 ) {
117019 number = advance();
117020 ch = source.charCodeAt(index);
117021
117022 if (number === '0') {
117023 if (ch === 0x78
117024 /* 'x' */
117025 || ch === 0x58
117026 /* 'X' */
117027 ) {
117028 number += advance();
117029
117030 while (index < length) {
117031 ch = source.charCodeAt(index);
117032
117033 if (!esutils.code.isHexDigit(ch)) {
117034 break;
117035 }
117036
117037 number += advance();
117038 }
117039
117040 if (number.length <= 2) {
117041 // only 0x
117042 utility.throwError('unexpected token');
117043 }
117044
117045 if (index < length) {
117046 ch = source.charCodeAt(index);
117047
117048 if (esutils.code.isIdentifierStartES5(ch)) {
117049 utility.throwError('unexpected token');
117050 }
117051 }
117052
117053 value = parseInt(number, 16);
117054 return Token.NUMBER;
117055 }
117056
117057 if (esutils.code.isOctalDigit(ch)) {
117058 number += advance();
117059
117060 while (index < length) {
117061 ch = source.charCodeAt(index);
117062
117063 if (!esutils.code.isOctalDigit(ch)) {
117064 break;
117065 }
117066
117067 number += advance();
117068 }
117069
117070 if (index < length) {
117071 ch = source.charCodeAt(index);
117072
117073 if (esutils.code.isIdentifierStartES5(ch) || esutils.code.isDecimalDigit(ch)) {
117074 utility.throwError('unexpected token');
117075 }
117076 }
117077
117078 value = parseInt(number, 8);
117079 return Token.NUMBER;
117080 }
117081
117082 if (esutils.code.isDecimalDigit(ch)) {
117083 utility.throwError('unexpected token');
117084 }
117085 }
117086
117087 while (index < length) {
117088 ch = source.charCodeAt(index);
117089
117090 if (!esutils.code.isDecimalDigit(ch)) {
117091 break;
117092 }
117093
117094 number += advance();
117095 }
117096 }
117097
117098 if (ch === 0x2E
117099 /* '.' */
117100 ) {
117101 number += advance();
117102
117103 while (index < length) {
117104 ch = source.charCodeAt(index);
117105
117106 if (!esutils.code.isDecimalDigit(ch)) {
117107 break;
117108 }
117109
117110 number += advance();
117111 }
117112 }
117113
117114 if (ch === 0x65
117115 /* 'e' */
117116 || ch === 0x45
117117 /* 'E' */
117118 ) {
117119 number += advance();
117120 ch = source.charCodeAt(index);
117121
117122 if (ch === 0x2B
117123 /* '+' */
117124 || ch === 0x2D
117125 /* '-' */
117126 ) {
117127 number += advance();
117128 }
117129
117130 ch = source.charCodeAt(index);
117131
117132 if (esutils.code.isDecimalDigit(ch)) {
117133 number += advance();
117134
117135 while (index < length) {
117136 ch = source.charCodeAt(index);
117137
117138 if (!esutils.code.isDecimalDigit(ch)) {
117139 break;
117140 }
117141
117142 number += advance();
117143 }
117144 } else {
117145 utility.throwError('unexpected token');
117146 }
117147 }
117148
117149 if (index < length) {
117150 ch = source.charCodeAt(index);
117151
117152 if (esutils.code.isIdentifierStartES5(ch)) {
117153 utility.throwError('unexpected token');
117154 }
117155 }
117156
117157 value = parseFloat(number);
117158 return Token.NUMBER;
117159 }
117160
117161 function scanTypeName() {
117162 var ch, ch2;
117163 value = advance();
117164
117165 while (index < length && isTypeName(source.charCodeAt(index))) {
117166 ch = source.charCodeAt(index);
117167
117168 if (ch === 0x2E
117169 /* '.' */
117170 ) {
117171 if (index + 1 >= length) {
117172 return Token.ILLEGAL;
117173 }
117174
117175 ch2 = source.charCodeAt(index + 1);
117176
117177 if (ch2 === 0x3C
117178 /* '<' */
117179 ) {
117180 break;
117181 }
117182 }
117183
117184 value += advance();
117185 }
117186
117187 return Token.NAME;
117188 }
117189
117190 function next() {
117191 var ch;
117192 previous = index;
117193
117194 while (index < length && esutils.code.isWhiteSpace(source.charCodeAt(index))) {
117195 advance();
117196 }
117197
117198 if (index >= length) {
117199 token = Token.EOF;
117200 return token;
117201 }
117202
117203 ch = source.charCodeAt(index);
117204
117205 switch (ch) {
117206 case 0x27:
117207 /* ''' */
117208
117209 case 0x22:
117210 /* '"' */
117211 token = scanString();
117212 return token;
117213
117214 case 0x3A:
117215 /* ':' */
117216 advance();
117217 token = Token.COLON;
117218 return token;
117219
117220 case 0x2C:
117221 /* ',' */
117222 advance();
117223 token = Token.COMMA;
117224 return token;
117225
117226 case 0x28:
117227 /* '(' */
117228 advance();
117229 token = Token.LPAREN;
117230 return token;
117231
117232 case 0x29:
117233 /* ')' */
117234 advance();
117235 token = Token.RPAREN;
117236 return token;
117237
117238 case 0x5B:
117239 /* '[' */
117240 advance();
117241 token = Token.LBRACK;
117242 return token;
117243
117244 case 0x5D:
117245 /* ']' */
117246 advance();
117247 token = Token.RBRACK;
117248 return token;
117249
117250 case 0x7B:
117251 /* '{' */
117252 advance();
117253 token = Token.LBRACE;
117254 return token;
117255
117256 case 0x7D:
117257 /* '}' */
117258 advance();
117259 token = Token.RBRACE;
117260 return token;
117261
117262 case 0x2E:
117263 /* '.' */
117264 if (index + 1 < length) {
117265 ch = source.charCodeAt(index + 1);
117266
117267 if (ch === 0x3C
117268 /* '<' */
117269 ) {
117270 advance(); // '.'
117271
117272 advance(); // '<'
117273
117274 token = Token.DOT_LT;
117275 return token;
117276 }
117277
117278 if (ch === 0x2E
117279 /* '.' */
117280 && index + 2 < length && source.charCodeAt(index + 2) === 0x2E
117281 /* '.' */
117282 ) {
117283 advance(); // '.'
117284
117285 advance(); // '.'
117286
117287 advance(); // '.'
117288
117289 token = Token.REST;
117290 return token;
117291 }
117292
117293 if (esutils.code.isDecimalDigit(ch)) {
117294 token = scanNumber();
117295 return token;
117296 }
117297 }
117298
117299 token = Token.ILLEGAL;
117300 return token;
117301
117302 case 0x3C:
117303 /* '<' */
117304 advance();
117305 token = Token.LT;
117306 return token;
117307
117308 case 0x3E:
117309 /* '>' */
117310 advance();
117311 token = Token.GT;
117312 return token;
117313
117314 case 0x2A:
117315 /* '*' */
117316 advance();
117317 token = Token.STAR;
117318 return token;
117319
117320 case 0x7C:
117321 /* '|' */
117322 advance();
117323 token = Token.PIPE;
117324 return token;
117325
117326 case 0x3F:
117327 /* '?' */
117328 advance();
117329 token = Token.QUESTION;
117330 return token;
117331
117332 case 0x21:
117333 /* '!' */
117334 advance();
117335 token = Token.BANG;
117336 return token;
117337
117338 case 0x3D:
117339 /* '=' */
117340 advance();
117341 token = Token.EQUAL;
117342 return token;
117343
117344 case 0x2D:
117345 /* '-' */
117346 token = scanNumber();
117347 return token;
117348
117349 default:
117350 if (esutils.code.isDecimalDigit(ch)) {
117351 token = scanNumber();
117352 return token;
117353 } // type string permits following case,
117354 //
117355 // namespace.module.MyClass
117356 //
117357 // this reduced 1 token TK_NAME
117358
117359
117360 utility.assert(isTypeName(ch));
117361 token = scanTypeName();
117362 return token;
117363 }
117364 }
117365
117366 function consume(target, text) {
117367 utility.assert(token === target, text || 'consumed token not matched');
117368 next();
117369 }
117370
117371 function expect(target, message) {
117372 if (token !== target) {
117373 utility.throwError(message || 'unexpected token');
117374 }
117375
117376 next();
117377 } // UnionType := '(' TypeUnionList ')'
117378 //
117379 // TypeUnionList :=
117380 // <<empty>>
117381 // | NonemptyTypeUnionList
117382 //
117383 // NonemptyTypeUnionList :=
117384 // TypeExpression
117385 // | TypeExpression '|' NonemptyTypeUnionList
117386
117387
117388 function parseUnionType() {
117389 var elements,
117390 startIndex = index - 1;
117391 consume(Token.LPAREN, 'UnionType should start with (');
117392 elements = [];
117393
117394 if (token !== Token.RPAREN) {
117395 while (true) {
117396 elements.push(parseTypeExpression());
117397
117398 if (token === Token.RPAREN) {
117399 break;
117400 }
117401
117402 expect(Token.PIPE);
117403 }
117404 }
117405
117406 consume(Token.RPAREN, 'UnionType should end with )');
117407 return maybeAddRange({
117408 type: Syntax.UnionType,
117409 elements: elements
117410 }, [startIndex, previous]);
117411 } // ArrayType := '[' ElementTypeList ']'
117412 //
117413 // ElementTypeList :=
117414 // <<empty>>
117415 // | TypeExpression
117416 // | '...' TypeExpression
117417 // | TypeExpression ',' ElementTypeList
117418
117419
117420 function parseArrayType() {
117421 var elements,
117422 startIndex = index - 1,
117423 restStartIndex;
117424 consume(Token.LBRACK, 'ArrayType should start with [');
117425 elements = [];
117426
117427 while (token !== Token.RBRACK) {
117428 if (token === Token.REST) {
117429 restStartIndex = index - 3;
117430 consume(Token.REST);
117431 elements.push(maybeAddRange({
117432 type: Syntax.RestType,
117433 expression: parseTypeExpression()
117434 }, [restStartIndex, previous]));
117435 break;
117436 } else {
117437 elements.push(parseTypeExpression());
117438 }
117439
117440 if (token !== Token.RBRACK) {
117441 expect(Token.COMMA);
117442 }
117443 }
117444
117445 expect(Token.RBRACK);
117446 return maybeAddRange({
117447 type: Syntax.ArrayType,
117448 elements: elements
117449 }, [startIndex, previous]);
117450 }
117451
117452 function parseFieldName() {
117453 var v = value;
117454
117455 if (token === Token.NAME || token === Token.STRING) {
117456 next();
117457 return v;
117458 }
117459
117460 if (token === Token.NUMBER) {
117461 consume(Token.NUMBER);
117462 return String(v);
117463 }
117464
117465 utility.throwError('unexpected token');
117466 } // FieldType :=
117467 // FieldName
117468 // | FieldName ':' TypeExpression
117469 //
117470 // FieldName :=
117471 // NameExpression
117472 // | StringLiteral
117473 // | NumberLiteral
117474 // | ReservedIdentifier
117475
117476
117477 function parseFieldType() {
117478 var key,
117479 rangeStart = previous;
117480 key = parseFieldName();
117481
117482 if (token === Token.COLON) {
117483 consume(Token.COLON);
117484 return maybeAddRange({
117485 type: Syntax.FieldType,
117486 key: key,
117487 value: parseTypeExpression()
117488 }, [rangeStart, previous]);
117489 }
117490
117491 return maybeAddRange({
117492 type: Syntax.FieldType,
117493 key: key,
117494 value: null
117495 }, [rangeStart, previous]);
117496 } // RecordType := '{' FieldTypeList '}'
117497 //
117498 // FieldTypeList :=
117499 // <<empty>>
117500 // | FieldType
117501 // | FieldType ',' FieldTypeList
117502
117503
117504 function parseRecordType() {
117505 var fields,
117506 rangeStart = index - 1,
117507 rangeEnd;
117508 consume(Token.LBRACE, 'RecordType should start with {');
117509 fields = [];
117510
117511 if (token === Token.COMMA) {
117512 consume(Token.COMMA);
117513 } else {
117514 while (token !== Token.RBRACE) {
117515 fields.push(parseFieldType());
117516
117517 if (token !== Token.RBRACE) {
117518 expect(Token.COMMA);
117519 }
117520 }
117521 }
117522
117523 rangeEnd = index;
117524 expect(Token.RBRACE);
117525 return maybeAddRange({
117526 type: Syntax.RecordType,
117527 fields: fields
117528 }, [rangeStart, rangeEnd]);
117529 } // NameExpression :=
117530 // Identifier
117531 // | TagIdentifier ':' Identifier
117532 //
117533 // Tag identifier is one of "module", "external" or "event"
117534 // Identifier is the same as Token.NAME, including any dots, something like
117535 // namespace.module.MyClass
117536
117537
117538 function parseNameExpression() {
117539 var name = value,
117540 rangeStart = index - name.length;
117541 expect(Token.NAME);
117542
117543 if (token === Token.COLON && (name === 'module' || name === 'external' || name === 'event')) {
117544 consume(Token.COLON);
117545 name += ':' + value;
117546 expect(Token.NAME);
117547 }
117548
117549 return maybeAddRange({
117550 type: Syntax.NameExpression,
117551 name: name
117552 }, [rangeStart, previous]);
117553 } // TypeExpressionList :=
117554 // TopLevelTypeExpression
117555 // | TopLevelTypeExpression ',' TypeExpressionList
117556
117557
117558 function parseTypeExpressionList() {
117559 var elements = [];
117560 elements.push(parseTop());
117561
117562 while (token === Token.COMMA) {
117563 consume(Token.COMMA);
117564 elements.push(parseTop());
117565 }
117566
117567 return elements;
117568 } // TypeName :=
117569 // NameExpression
117570 // | NameExpression TypeApplication
117571 //
117572 // TypeApplication :=
117573 // '.<' TypeExpressionList '>'
117574 // | '<' TypeExpressionList '>' // this is extension of doctrine
117575
117576
117577 function parseTypeName() {
117578 var expr,
117579 applications,
117580 startIndex = index - value.length;
117581 expr = parseNameExpression();
117582
117583 if (token === Token.DOT_LT || token === Token.LT) {
117584 next();
117585 applications = parseTypeExpressionList();
117586 expect(Token.GT);
117587 return maybeAddRange({
117588 type: Syntax.TypeApplication,
117589 expression: expr,
117590 applications: applications
117591 }, [startIndex, previous]);
117592 }
117593
117594 return expr;
117595 } // ResultType :=
117596 // <<empty>>
117597 // | ':' void
117598 // | ':' TypeExpression
117599 //
117600 // BNF is above
117601 // but, we remove <<empty>> pattern, so token is always TypeToken::COLON
117602
117603
117604 function parseResultType() {
117605 consume(Token.COLON, 'ResultType should start with :');
117606
117607 if (token === Token.NAME && value === 'void') {
117608 consume(Token.NAME);
117609 return {
117610 type: Syntax.VoidLiteral
117611 };
117612 }
117613
117614 return parseTypeExpression();
117615 } // ParametersType :=
117616 // RestParameterType
117617 // | NonRestParametersType
117618 // | NonRestParametersType ',' RestParameterType
117619 //
117620 // RestParameterType :=
117621 // '...'
117622 // '...' Identifier
117623 //
117624 // NonRestParametersType :=
117625 // ParameterType ',' NonRestParametersType
117626 // | ParameterType
117627 // | OptionalParametersType
117628 //
117629 // OptionalParametersType :=
117630 // OptionalParameterType
117631 // | OptionalParameterType, OptionalParametersType
117632 //
117633 // OptionalParameterType := ParameterType=
117634 //
117635 // ParameterType := TypeExpression | Identifier ':' TypeExpression
117636 //
117637 // Identifier is "new" or "this"
117638
117639
117640 function parseParametersType() {
117641 var params = [],
117642 optionalSequence = false,
117643 expr,
117644 rest = false,
117645 startIndex,
117646 restStartIndex = index - 3,
117647 nameStartIndex;
117648
117649 while (token !== Token.RPAREN) {
117650 if (token === Token.REST) {
117651 // RestParameterType
117652 consume(Token.REST);
117653 rest = true;
117654 }
117655
117656 startIndex = previous;
117657 expr = parseTypeExpression();
117658
117659 if (expr.type === Syntax.NameExpression && token === Token.COLON) {
117660 nameStartIndex = previous - expr.name.length; // Identifier ':' TypeExpression
117661
117662 consume(Token.COLON);
117663 expr = maybeAddRange({
117664 type: Syntax.ParameterType,
117665 name: expr.name,
117666 expression: parseTypeExpression()
117667 }, [nameStartIndex, previous]);
117668 }
117669
117670 if (token === Token.EQUAL) {
117671 consume(Token.EQUAL);
117672 expr = maybeAddRange({
117673 type: Syntax.OptionalType,
117674 expression: expr
117675 }, [startIndex, previous]);
117676 optionalSequence = true;
117677 } else {
117678 if (optionalSequence) {
117679 utility.throwError('unexpected token');
117680 }
117681 }
117682
117683 if (rest) {
117684 expr = maybeAddRange({
117685 type: Syntax.RestType,
117686 expression: expr
117687 }, [restStartIndex, previous]);
117688 }
117689
117690 params.push(expr);
117691
117692 if (token !== Token.RPAREN) {
117693 expect(Token.COMMA);
117694 }
117695 }
117696
117697 return params;
117698 } // FunctionType := 'function' FunctionSignatureType
117699 //
117700 // FunctionSignatureType :=
117701 // | TypeParameters '(' ')' ResultType
117702 // | TypeParameters '(' ParametersType ')' ResultType
117703 // | TypeParameters '(' 'this' ':' TypeName ')' ResultType
117704 // | TypeParameters '(' 'this' ':' TypeName ',' ParametersType ')' ResultType
117705
117706
117707 function parseFunctionType() {
117708 var isNew,
117709 thisBinding,
117710 params,
117711 result,
117712 fnType,
117713 startIndex = index - value.length;
117714 utility.assert(token === Token.NAME && value === 'function', 'FunctionType should start with \'function\'');
117715 consume(Token.NAME); // Google Closure Compiler is not implementing TypeParameters.
117716 // So we do not. if we don't get '(', we see it as error.
117717
117718 expect(Token.LPAREN);
117719 isNew = false;
117720 params = [];
117721 thisBinding = null;
117722
117723 if (token !== Token.RPAREN) {
117724 // ParametersType or 'this'
117725 if (token === Token.NAME && (value === 'this' || value === 'new')) {
117726 // 'this' or 'new'
117727 // 'new' is Closure Compiler extension
117728 isNew = value === 'new';
117729 consume(Token.NAME);
117730 expect(Token.COLON);
117731 thisBinding = parseTypeName();
117732
117733 if (token === Token.COMMA) {
117734 consume(Token.COMMA);
117735 params = parseParametersType();
117736 }
117737 } else {
117738 params = parseParametersType();
117739 }
117740 }
117741
117742 expect(Token.RPAREN);
117743 result = null;
117744
117745 if (token === Token.COLON) {
117746 result = parseResultType();
117747 }
117748
117749 fnType = maybeAddRange({
117750 type: Syntax.FunctionType,
117751 params: params,
117752 result: result
117753 }, [startIndex, previous]);
117754
117755 if (thisBinding) {
117756 // avoid adding null 'new' and 'this' properties
117757 fnType['this'] = thisBinding;
117758
117759 if (isNew) {
117760 fnType['new'] = true;
117761 }
117762 }
117763
117764 return fnType;
117765 } // BasicTypeExpression :=
117766 // '*'
117767 // | 'null'
117768 // | 'undefined'
117769 // | TypeName
117770 // | FunctionType
117771 // | UnionType
117772 // | RecordType
117773 // | ArrayType
117774
117775
117776 function parseBasicTypeExpression() {
117777 var context, startIndex;
117778
117779 switch (token) {
117780 case Token.STAR:
117781 consume(Token.STAR);
117782 return maybeAddRange({
117783 type: Syntax.AllLiteral
117784 }, [previous - 1, previous]);
117785
117786 case Token.LPAREN:
117787 return parseUnionType();
117788
117789 case Token.LBRACK:
117790 return parseArrayType();
117791
117792 case Token.LBRACE:
117793 return parseRecordType();
117794
117795 case Token.NAME:
117796 startIndex = index - value.length;
117797
117798 if (value === 'null') {
117799 consume(Token.NAME);
117800 return maybeAddRange({
117801 type: Syntax.NullLiteral
117802 }, [startIndex, previous]);
117803 }
117804
117805 if (value === 'undefined') {
117806 consume(Token.NAME);
117807 return maybeAddRange({
117808 type: Syntax.UndefinedLiteral
117809 }, [startIndex, previous]);
117810 }
117811
117812 if (value === 'true' || value === 'false') {
117813 consume(Token.NAME);
117814 return maybeAddRange({
117815 type: Syntax.BooleanLiteralType,
117816 value: value === 'true'
117817 }, [startIndex, previous]);
117818 }
117819
117820 context = Context.save();
117821
117822 if (value === 'function') {
117823 try {
117824 return parseFunctionType();
117825 } catch (e) {
117826 context.restore();
117827 }
117828 }
117829
117830 return parseTypeName();
117831
117832 case Token.STRING:
117833 next();
117834 return maybeAddRange({
117835 type: Syntax.StringLiteralType,
117836 value: value
117837 }, [previous - value.length - 2, previous]);
117838
117839 case Token.NUMBER:
117840 next();
117841 return maybeAddRange({
117842 type: Syntax.NumericLiteralType,
117843 value: value
117844 }, [previous - String(value).length, previous]);
117845
117846 default:
117847 utility.throwError('unexpected token');
117848 }
117849 } // TypeExpression :=
117850 // BasicTypeExpression
117851 // | '?' BasicTypeExpression
117852 // | '!' BasicTypeExpression
117853 // | BasicTypeExpression '?'
117854 // | BasicTypeExpression '!'
117855 // | '?'
117856 // | BasicTypeExpression '[]'
117857
117858
117859 function parseTypeExpression() {
117860 var expr, rangeStart;
117861
117862 if (token === Token.QUESTION) {
117863 rangeStart = index - 1;
117864 consume(Token.QUESTION);
117865
117866 if (token === Token.COMMA || token === Token.EQUAL || token === Token.RBRACE || token === Token.RPAREN || token === Token.PIPE || token === Token.EOF || token === Token.RBRACK || token === Token.GT) {
117867 return maybeAddRange({
117868 type: Syntax.NullableLiteral
117869 }, [rangeStart, previous]);
117870 }
117871
117872 return maybeAddRange({
117873 type: Syntax.NullableType,
117874 expression: parseBasicTypeExpression(),
117875 prefix: true
117876 }, [rangeStart, previous]);
117877 } else if (token === Token.BANG) {
117878 rangeStart = index - 1;
117879 consume(Token.BANG);
117880 return maybeAddRange({
117881 type: Syntax.NonNullableType,
117882 expression: parseBasicTypeExpression(),
117883 prefix: true
117884 }, [rangeStart, previous]);
117885 } else {
117886 rangeStart = previous;
117887 }
117888
117889 expr = parseBasicTypeExpression();
117890
117891 if (token === Token.BANG) {
117892 consume(Token.BANG);
117893 return maybeAddRange({
117894 type: Syntax.NonNullableType,
117895 expression: expr,
117896 prefix: false
117897 }, [rangeStart, previous]);
117898 }
117899
117900 if (token === Token.QUESTION) {
117901 consume(Token.QUESTION);
117902 return maybeAddRange({
117903 type: Syntax.NullableType,
117904 expression: expr,
117905 prefix: false
117906 }, [rangeStart, previous]);
117907 }
117908
117909 if (token === Token.LBRACK) {
117910 consume(Token.LBRACK);
117911 expect(Token.RBRACK, 'expected an array-style type declaration (' + value + '[])');
117912 return maybeAddRange({
117913 type: Syntax.TypeApplication,
117914 expression: maybeAddRange({
117915 type: Syntax.NameExpression,
117916 name: 'Array'
117917 }, [rangeStart, previous]),
117918 applications: [expr]
117919 }, [rangeStart, previous]);
117920 }
117921
117922 return expr;
117923 } // TopLevelTypeExpression :=
117924 // TypeExpression
117925 // | TypeUnionList
117926 //
117927 // This rule is Google Closure Compiler extension, not ES4
117928 // like,
117929 // { number | string }
117930 // If strict to ES4, we should write it as
117931 // { (number|string) }
117932
117933
117934 function parseTop() {
117935 var expr, elements;
117936 expr = parseTypeExpression();
117937
117938 if (token !== Token.PIPE) {
117939 return expr;
117940 }
117941
117942 elements = [expr];
117943 consume(Token.PIPE);
117944
117945 while (true) {
117946 elements.push(parseTypeExpression());
117947
117948 if (token !== Token.PIPE) {
117949 break;
117950 }
117951
117952 consume(Token.PIPE);
117953 }
117954
117955 return maybeAddRange({
117956 type: Syntax.UnionType,
117957 elements: elements
117958 }, [0, index]);
117959 }
117960
117961 function parseTopParamType() {
117962 var expr;
117963
117964 if (token === Token.REST) {
117965 consume(Token.REST);
117966 return maybeAddRange({
117967 type: Syntax.RestType,
117968 expression: parseTop()
117969 }, [0, index]);
117970 }
117971
117972 expr = parseTop();
117973
117974 if (token === Token.EQUAL) {
117975 consume(Token.EQUAL);
117976 return maybeAddRange({
117977 type: Syntax.OptionalType,
117978 expression: expr
117979 }, [0, index]);
117980 }
117981
117982 return expr;
117983 }
117984
117985 function parseType(src, opt) {
117986 var expr;
117987 source = src;
117988 length = source.length;
117989 index = 0;
117990 previous = 0;
117991 addRange = opt && opt.range;
117992 rangeOffset = opt && opt.startIndex || 0;
117993 next();
117994 expr = parseTop();
117995
117996 if (opt && opt.midstream) {
117997 return {
117998 expression: expr,
117999 index: previous
118000 };
118001 }
118002
118003 if (token !== Token.EOF) {
118004 utility.throwError('not reach to EOF');
118005 }
118006
118007 return expr;
118008 }
118009
118010 function parseParamType(src, opt) {
118011 var expr;
118012 source = src;
118013 length = source.length;
118014 index = 0;
118015 previous = 0;
118016 addRange = opt && opt.range;
118017 rangeOffset = opt && opt.startIndex || 0;
118018 next();
118019 expr = parseTopParamType();
118020
118021 if (opt && opt.midstream) {
118022 return {
118023 expression: expr,
118024 index: previous
118025 };
118026 }
118027
118028 if (token !== Token.EOF) {
118029 utility.throwError('not reach to EOF');
118030 }
118031
118032 return expr;
118033 }
118034
118035 function stringifyImpl(node, compact, topLevel) {
118036 var result, i, iz;
118037
118038 switch (node.type) {
118039 case Syntax.NullableLiteral:
118040 result = '?';
118041 break;
118042
118043 case Syntax.AllLiteral:
118044 result = '*';
118045 break;
118046
118047 case Syntax.NullLiteral:
118048 result = 'null';
118049 break;
118050
118051 case Syntax.UndefinedLiteral:
118052 result = 'undefined';
118053 break;
118054
118055 case Syntax.VoidLiteral:
118056 result = 'void';
118057 break;
118058
118059 case Syntax.UnionType:
118060 if (!topLevel) {
118061 result = '(';
118062 } else {
118063 result = '';
118064 }
118065
118066 for (i = 0, iz = node.elements.length; i < iz; ++i) {
118067 result += stringifyImpl(node.elements[i], compact);
118068
118069 if (i + 1 !== iz) {
118070 result += compact ? '|' : ' | ';
118071 }
118072 }
118073
118074 if (!topLevel) {
118075 result += ')';
118076 }
118077
118078 break;
118079
118080 case Syntax.ArrayType:
118081 result = '[';
118082
118083 for (i = 0, iz = node.elements.length; i < iz; ++i) {
118084 result += stringifyImpl(node.elements[i], compact);
118085
118086 if (i + 1 !== iz) {
118087 result += compact ? ',' : ', ';
118088 }
118089 }
118090
118091 result += ']';
118092 break;
118093
118094 case Syntax.RecordType:
118095 result = '{';
118096
118097 for (i = 0, iz = node.fields.length; i < iz; ++i) {
118098 result += stringifyImpl(node.fields[i], compact);
118099
118100 if (i + 1 !== iz) {
118101 result += compact ? ',' : ', ';
118102 }
118103 }
118104
118105 result += '}';
118106 break;
118107
118108 case Syntax.FieldType:
118109 if (node.value) {
118110 result = node.key + (compact ? ':' : ': ') + stringifyImpl(node.value, compact);
118111 } else {
118112 result = node.key;
118113 }
118114
118115 break;
118116
118117 case Syntax.FunctionType:
118118 result = compact ? 'function(' : 'function (';
118119
118120 if (node['this']) {
118121 if (node['new']) {
118122 result += compact ? 'new:' : 'new: ';
118123 } else {
118124 result += compact ? 'this:' : 'this: ';
118125 }
118126
118127 result += stringifyImpl(node['this'], compact);
118128
118129 if (node.params.length !== 0) {
118130 result += compact ? ',' : ', ';
118131 }
118132 }
118133
118134 for (i = 0, iz = node.params.length; i < iz; ++i) {
118135 result += stringifyImpl(node.params[i], compact);
118136
118137 if (i + 1 !== iz) {
118138 result += compact ? ',' : ', ';
118139 }
118140 }
118141
118142 result += ')';
118143
118144 if (node.result) {
118145 result += (compact ? ':' : ': ') + stringifyImpl(node.result, compact);
118146 }
118147
118148 break;
118149
118150 case Syntax.ParameterType:
118151 result = node.name + (compact ? ':' : ': ') + stringifyImpl(node.expression, compact);
118152 break;
118153
118154 case Syntax.RestType:
118155 result = '...';
118156
118157 if (node.expression) {
118158 result += stringifyImpl(node.expression, compact);
118159 }
118160
118161 break;
118162
118163 case Syntax.NonNullableType:
118164 if (node.prefix) {
118165 result = '!' + stringifyImpl(node.expression, compact);
118166 } else {
118167 result = stringifyImpl(node.expression, compact) + '!';
118168 }
118169
118170 break;
118171
118172 case Syntax.OptionalType:
118173 result = stringifyImpl(node.expression, compact) + '=';
118174 break;
118175
118176 case Syntax.NullableType:
118177 if (node.prefix) {
118178 result = '?' + stringifyImpl(node.expression, compact);
118179 } else {
118180 result = stringifyImpl(node.expression, compact) + '?';
118181 }
118182
118183 break;
118184
118185 case Syntax.NameExpression:
118186 result = node.name;
118187 break;
118188
118189 case Syntax.TypeApplication:
118190 result = stringifyImpl(node.expression, compact) + '.<';
118191
118192 for (i = 0, iz = node.applications.length; i < iz; ++i) {
118193 result += stringifyImpl(node.applications[i], compact);
118194
118195 if (i + 1 !== iz) {
118196 result += compact ? ',' : ', ';
118197 }
118198 }
118199
118200 result += '>';
118201 break;
118202
118203 case Syntax.StringLiteralType:
118204 result = '"' + node.value + '"';
118205 break;
118206
118207 case Syntax.NumericLiteralType:
118208 result = String(node.value);
118209 break;
118210
118211 case Syntax.BooleanLiteralType:
118212 result = String(node.value);
118213 break;
118214
118215 default:
118216 utility.throwError('Unknown type ' + node.type);
118217 }
118218
118219 return result;
118220 }
118221
118222 function stringify(node, options) {
118223 if (options == null) {
118224 options = {};
118225 }
118226
118227 return stringifyImpl(node, options.compact, options.topLevel);
118228 }
118229
118230 exports.parseType = parseType;
118231 exports.parseParamType = parseParamType;
118232 exports.stringify = stringify;
118233 exports.Syntax = Syntax;
118234 })();
118235 /* vim: set sw=4 ts=4 et tw=80 : */
118236
118237 /***/ }),
118238 /* 846 */
118239 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
118240
118241 /*
118242 * @fileoverview Utilities for Doctrine
118243 * @author Yusuke Suzuki <utatane.tea@gmail.com>
118244 */
118245 (function () {
118246 'use strict';
118247
118248 var VERSION;
118249 VERSION = (__webpack_require__(847).version);
118250 exports.VERSION = VERSION;
118251
118252 function DoctrineError(message) {
118253 this.name = 'DoctrineError';
118254 this.message = message;
118255 }
118256
118257 DoctrineError.prototype = function () {
118258 var Middle = function () {};
118259
118260 Middle.prototype = Error.prototype;
118261 return new Middle();
118262 }();
118263
118264 DoctrineError.prototype.constructor = DoctrineError;
118265 exports.DoctrineError = DoctrineError;
118266
118267 function throwError(message) {
118268 throw new DoctrineError(message);
118269 }
118270
118271 exports.throwError = throwError;
118272 exports.assert = __webpack_require__(431);
118273 })();
118274 /* vim: set sw=4 ts=4 et tw=80 : */
118275
118276 /***/ }),
118277 /* 847 */
118278 /***/ ((module) => {
118279
118280 "use strict";
118281 module.exports = JSON.parse('{"name":"doctrine","description":"JSDoc parser","homepage":"https://github.com/eslint/doctrine","main":"lib/doctrine.js","version":"3.0.0","engines":{"node":">=6.0.0"},"directories":{"lib":"./lib"},"files":["lib"],"maintainers":[{"name":"Nicholas C. Zakas","email":"nicholas+npm@nczconsulting.com","web":"https://www.nczonline.net"},{"name":"Yusuke Suzuki","email":"utatane.tea@gmail.com","web":"https://github.com/Constellation"}],"repository":"eslint/doctrine","devDependencies":{"coveralls":"^3.0.1","dateformat":"^1.0.11","eslint":"^1.10.3","eslint-release":"^1.0.0","linefix":"^0.1.1","mocha":"^3.4.2","npm-license":"^0.3.1","nyc":"^10.3.2","semver":"^5.0.3","shelljs":"^0.5.3","shelljs-nodecli":"^0.1.1","should":"^5.0.1"},"license":"Apache-2.0","scripts":{"pretest":"npm run lint","test":"nyc mocha","coveralls":"nyc report --reporter=text-lcov | coveralls","lint":"eslint lib/","generate-release":"eslint-generate-release","generate-alpharelease":"eslint-generate-prerelease alpha","generate-betarelease":"eslint-generate-prerelease beta","generate-rcrelease":"eslint-generate-prerelease rc","publish-release":"eslint-publish-release"},"dependencies":{"esutils":"^2.0.2"}}');
118282
118283 /***/ }),
118284 /* 848 */
118285 /***/ ((module) => {
118286
118287 "use strict";
118288 /**
118289 * @fileoverview Ensures that the results of typeof are compared against a valid string
118290 * @author Ian Christian Myers
118291 */
118292 //------------------------------------------------------------------------------
118293 // Rule Definition
118294 //------------------------------------------------------------------------------
118295
118296 module.exports = {
118297 meta: {
118298 type: "problem",
118299 docs: {
118300 description: "enforce comparing `typeof` expressions against valid strings",
118301 recommended: true,
118302 url: "https://eslint.org/docs/rules/valid-typeof"
118303 },
118304 schema: [{
118305 type: "object",
118306 properties: {
118307 requireStringLiterals: {
118308 type: "boolean",
118309 default: false
118310 }
118311 },
118312 additionalProperties: false
118313 }],
118314 messages: {
118315 invalidValue: "Invalid typeof comparison value.",
118316 notString: "Typeof comparisons should be to string literals."
118317 }
118318 },
118319
118320 create(context) {
118321 const VALID_TYPES = ["symbol", "undefined", "object", "boolean", "number", "string", "function", "bigint"],
118322 OPERATORS = ["==", "===", "!=", "!=="];
118323 const requireStringLiterals = context.options[0] && context.options[0].requireStringLiterals;
118324 /**
118325 * Determines whether a node is a typeof expression.
118326 * @param {ASTNode} node The node
118327 * @returns {boolean} `true` if the node is a typeof expression
118328 */
118329
118330 function isTypeofExpression(node) {
118331 return node.type === "UnaryExpression" && node.operator === "typeof";
118332 } //--------------------------------------------------------------------------
118333 // Public
118334 //--------------------------------------------------------------------------
118335
118336
118337 return {
118338 UnaryExpression(node) {
118339 if (isTypeofExpression(node)) {
118340 const parent = context.getAncestors().pop();
118341
118342 if (parent.type === "BinaryExpression" && OPERATORS.indexOf(parent.operator) !== -1) {
118343 const sibling = parent.left === node ? parent.right : parent.left;
118344
118345 if (sibling.type === "Literal" || sibling.type === "TemplateLiteral" && !sibling.expressions.length) {
118346 const value = sibling.type === "Literal" ? sibling.value : sibling.quasis[0].value.cooked;
118347
118348 if (VALID_TYPES.indexOf(value) === -1) {
118349 context.report({
118350 node: sibling,
118351 messageId: "invalidValue"
118352 });
118353 }
118354 } else if (requireStringLiterals && !isTypeofExpression(sibling)) {
118355 context.report({
118356 node: sibling,
118357 messageId: "notString"
118358 });
118359 }
118360 }
118361 }
118362 }
118363
118364 };
118365 }
118366
118367 };
118368
118369 /***/ }),
118370 /* 849 */
118371 /***/ ((module) => {
118372
118373 "use strict";
118374 /**
118375 * @fileoverview Rule to enforce var declarations are only at the top of a function.
118376 * @author Danny Fritz
118377 * @author Gyandeep Singh
118378 */
118379 //------------------------------------------------------------------------------
118380 // Rule Definition
118381 //------------------------------------------------------------------------------
118382
118383 module.exports = {
118384 meta: {
118385 type: "suggestion",
118386 docs: {
118387 description: "require `var` declarations be placed at the top of their containing scope",
118388 recommended: false,
118389 url: "https://eslint.org/docs/rules/vars-on-top"
118390 },
118391 schema: [],
118392 messages: {
118393 top: "All 'var' declarations must be at the top of the function scope."
118394 }
118395 },
118396
118397 create(context) {
118398 //--------------------------------------------------------------------------
118399 // Helpers
118400 //--------------------------------------------------------------------------
118401
118402 /**
118403 * Has AST suggesting a directive.
118404 * @param {ASTNode} node any node
118405 * @returns {boolean} whether the given node structurally represents a directive
118406 */
118407 function looksLikeDirective(node) {
118408 return node.type === "ExpressionStatement" && node.expression.type === "Literal" && typeof node.expression.value === "string";
118409 }
118410 /**
118411 * Check to see if its a ES6 import declaration
118412 * @param {ASTNode} node any node
118413 * @returns {boolean} whether the given node represents a import declaration
118414 */
118415
118416
118417 function looksLikeImport(node) {
118418 return node.type === "ImportDeclaration" || node.type === "ImportSpecifier" || node.type === "ImportDefaultSpecifier" || node.type === "ImportNamespaceSpecifier";
118419 }
118420 /**
118421 * Checks whether a given node is a variable declaration or not.
118422 * @param {ASTNode} node any node
118423 * @returns {boolean} `true` if the node is a variable declaration.
118424 */
118425
118426
118427 function isVariableDeclaration(node) {
118428 return node.type === "VariableDeclaration" || node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "VariableDeclaration";
118429 }
118430 /**
118431 * Checks whether this variable is on top of the block body
118432 * @param {ASTNode} node The node to check
118433 * @param {ASTNode[]} statements collection of ASTNodes for the parent node block
118434 * @returns {boolean} True if var is on top otherwise false
118435 */
118436
118437
118438 function isVarOnTop(node, statements) {
118439 const l = statements.length;
118440 let i = 0; // Skip over directives and imports. Static blocks don't have either.
118441
118442 if (node.parent.type !== "StaticBlock") {
118443 for (; i < l; ++i) {
118444 if (!looksLikeDirective(statements[i]) && !looksLikeImport(statements[i])) {
118445 break;
118446 }
118447 }
118448 }
118449
118450 for (; i < l; ++i) {
118451 if (!isVariableDeclaration(statements[i])) {
118452 return false;
118453 }
118454
118455 if (statements[i] === node) {
118456 return true;
118457 }
118458 }
118459
118460 return false;
118461 }
118462 /**
118463 * Checks whether variable is on top at the global level
118464 * @param {ASTNode} node The node to check
118465 * @param {ASTNode} parent Parent of the node
118466 * @returns {void}
118467 */
118468
118469
118470 function globalVarCheck(node, parent) {
118471 if (!isVarOnTop(node, parent.body)) {
118472 context.report({
118473 node,
118474 messageId: "top"
118475 });
118476 }
118477 }
118478 /**
118479 * Checks whether variable is on top at functional block scope level
118480 * @param {ASTNode} node The node to check
118481 * @returns {void}
118482 */
118483
118484
118485 function blockScopeVarCheck(node) {
118486 const {
118487 parent
118488 } = node;
118489
118490 if (parent.type === "BlockStatement" && /Function/u.test(parent.parent.type) && isVarOnTop(node, parent.body)) {
118491 return;
118492 }
118493
118494 if (parent.type === "StaticBlock" && isVarOnTop(node, parent.body)) {
118495 return;
118496 }
118497
118498 context.report({
118499 node,
118500 messageId: "top"
118501 });
118502 } //--------------------------------------------------------------------------
118503 // Public API
118504 //--------------------------------------------------------------------------
118505
118506
118507 return {
118508 "VariableDeclaration[kind='var']"(node) {
118509 if (node.parent.type === "ExportNamedDeclaration") {
118510 globalVarCheck(node.parent, node.parent.parent);
118511 } else if (node.parent.type === "Program") {
118512 globalVarCheck(node, node.parent);
118513 } else {
118514 blockScopeVarCheck(node);
118515 }
118516 }
118517
118518 };
118519 }
118520
118521 };
118522
118523 /***/ }),
118524 /* 850 */
118525 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
118526
118527 "use strict";
118528 /**
118529 * @fileoverview Rule to flag when IIFE is not wrapped in parens
118530 * @author Ilya Volodin
118531 */
118532 //------------------------------------------------------------------------------
118533 // Requirements
118534 //------------------------------------------------------------------------------
118535
118536 const astUtils = __webpack_require__(548);
118537
118538 const eslintUtils = __webpack_require__(501); //----------------------------------------------------------------------
118539 // Helpers
118540 //----------------------------------------------------------------------
118541
118542 /**
118543 * Check if the given node is callee of a `NewExpression` node
118544 * @param {ASTNode} node node to check
118545 * @returns {boolean} True if the node is callee of a `NewExpression` node
118546 * @private
118547 */
118548
118549
118550 function isCalleeOfNewExpression(node) {
118551 const maybeCallee = node.parent.type === "ChainExpression" ? node.parent : node;
118552 return maybeCallee.parent.type === "NewExpression" && maybeCallee.parent.callee === maybeCallee;
118553 } //------------------------------------------------------------------------------
118554 // Rule Definition
118555 //------------------------------------------------------------------------------
118556
118557
118558 module.exports = {
118559 meta: {
118560 type: "layout",
118561 docs: {
118562 description: "require parentheses around immediate `function` invocations",
118563 recommended: false,
118564 url: "https://eslint.org/docs/rules/wrap-iife"
118565 },
118566 schema: [{
118567 enum: ["outside", "inside", "any"]
118568 }, {
118569 type: "object",
118570 properties: {
118571 functionPrototypeMethods: {
118572 type: "boolean",
118573 default: false
118574 }
118575 },
118576 additionalProperties: false
118577 }],
118578 fixable: "code",
118579 messages: {
118580 wrapInvocation: "Wrap an immediate function invocation in parentheses.",
118581 wrapExpression: "Wrap only the function expression in parens.",
118582 moveInvocation: "Move the invocation into the parens that contain the function."
118583 }
118584 },
118585
118586 create(context) {
118587 const style = context.options[0] || "outside";
118588 const includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods;
118589 const sourceCode = context.getSourceCode();
118590 /**
118591 * Check if the node is wrapped in any (). All parens count: grouping parens and parens for constructs such as if()
118592 * @param {ASTNode} node node to evaluate
118593 * @returns {boolean} True if it is wrapped in any parens
118594 * @private
118595 */
118596
118597 function isWrappedInAnyParens(node) {
118598 return astUtils.isParenthesised(sourceCode, node);
118599 }
118600 /**
118601 * Check if the node is wrapped in grouping (). Parens for constructs such as if() don't count
118602 * @param {ASTNode} node node to evaluate
118603 * @returns {boolean} True if it is wrapped in grouping parens
118604 * @private
118605 */
118606
118607
118608 function isWrappedInGroupingParens(node) {
118609 return eslintUtils.isParenthesized(1, node, sourceCode);
118610 }
118611 /**
118612 * Get the function node from an IIFE
118613 * @param {ASTNode} node node to evaluate
118614 * @returns {ASTNode} node that is the function expression of the given IIFE, or null if none exist
118615 */
118616
118617
118618 function getFunctionNodeFromIIFE(node) {
118619 const callee = astUtils.skipChainExpression(node.callee);
118620
118621 if (callee.type === "FunctionExpression") {
118622 return callee;
118623 }
118624
118625 if (includeFunctionPrototypeMethods && callee.type === "MemberExpression" && callee.object.type === "FunctionExpression" && (astUtils.getStaticPropertyName(callee) === "call" || astUtils.getStaticPropertyName(callee) === "apply")) {
118626 return callee.object;
118627 }
118628
118629 return null;
118630 }
118631
118632 return {
118633 CallExpression(node) {
118634 const innerNode = getFunctionNodeFromIIFE(node);
118635
118636 if (!innerNode) {
118637 return;
118638 }
118639
118640 const isCallExpressionWrapped = isWrappedInAnyParens(node),
118641 isFunctionExpressionWrapped = isWrappedInAnyParens(innerNode);
118642
118643 if (!isCallExpressionWrapped && !isFunctionExpressionWrapped) {
118644 context.report({
118645 node,
118646 messageId: "wrapInvocation",
118647
118648 fix(fixer) {
118649 const nodeToSurround = style === "inside" ? innerNode : node;
118650 return fixer.replaceText(nodeToSurround, "(".concat(sourceCode.getText(nodeToSurround), ")"));
118651 }
118652
118653 });
118654 } else if (style === "inside" && !isFunctionExpressionWrapped) {
118655 context.report({
118656 node,
118657 messageId: "wrapExpression",
118658
118659 fix(fixer) {
118660 // The outer call expression will always be wrapped at this point.
118661 if (isWrappedInGroupingParens(node) && !isCalleeOfNewExpression(node)) {
118662 /*
118663 * Parenthesize the function expression and remove unnecessary grouping parens around the call expression.
118664 * Replace the range between the end of the function expression and the end of the call expression.
118665 * for example, in `(function(foo) {}(bar))`, the range `(bar))` should get replaced with `)(bar)`.
118666 */
118667 const parenAfter = sourceCode.getTokenAfter(node);
118668 return fixer.replaceTextRange([innerNode.range[1], parenAfter.range[1]], ")".concat(sourceCode.getText().slice(innerNode.range[1], parenAfter.range[0])));
118669 }
118670 /*
118671 * Call expression is wrapped in mandatory parens such as if(), or in necessary grouping parens.
118672 * These parens cannot be removed, so just parenthesize the function expression.
118673 */
118674
118675
118676 return fixer.replaceText(innerNode, "(".concat(sourceCode.getText(innerNode), ")"));
118677 }
118678
118679 });
118680 } else if (style === "outside" && !isCallExpressionWrapped) {
118681 context.report({
118682 node,
118683 messageId: "moveInvocation",
118684
118685 fix(fixer) {
118686 /*
118687 * The inner function expression will always be wrapped at this point.
118688 * It's only necessary to replace the range between the end of the function expression
118689 * and the call expression. For example, in `(function(foo) {})(bar)`, the range `)(bar)`
118690 * should get replaced with `(bar))`.
118691 */
118692 const parenAfter = sourceCode.getTokenAfter(innerNode);
118693 return fixer.replaceTextRange([parenAfter.range[0], node.range[1]], "".concat(sourceCode.getText().slice(parenAfter.range[1], node.range[1]), ")"));
118694 }
118695
118696 });
118697 }
118698 }
118699
118700 };
118701 }
118702
118703 };
118704
118705 /***/ }),
118706 /* 851 */
118707 /***/ ((module) => {
118708
118709 "use strict";
118710 /**
118711 * @fileoverview Rule to flag when regex literals are not wrapped in parens
118712 * @author Matt DuVall <http://www.mattduvall.com>
118713 */
118714 //------------------------------------------------------------------------------
118715 // Rule Definition
118716 //------------------------------------------------------------------------------
118717
118718 module.exports = {
118719 meta: {
118720 type: "layout",
118721 docs: {
118722 description: "require parenthesis around regex literals",
118723 recommended: false,
118724 url: "https://eslint.org/docs/rules/wrap-regex"
118725 },
118726 schema: [],
118727 fixable: "code",
118728 messages: {
118729 requireParens: "Wrap the regexp literal in parens to disambiguate the slash."
118730 }
118731 },
118732
118733 create(context) {
118734 const sourceCode = context.getSourceCode();
118735 return {
118736 Literal(node) {
118737 const token = sourceCode.getFirstToken(node),
118738 nodeType = token.type;
118739
118740 if (nodeType === "RegularExpression") {
118741 const beforeToken = sourceCode.getTokenBefore(node);
118742 const afterToken = sourceCode.getTokenAfter(node);
118743 const ancestors = context.getAncestors();
118744 const grandparent = ancestors[ancestors.length - 1];
118745
118746 if (grandparent.type === "MemberExpression" && grandparent.object === node && !(beforeToken && beforeToken.value === "(" && afterToken && afterToken.value === ")")) {
118747 context.report({
118748 node,
118749 messageId: "requireParens",
118750 fix: fixer => fixer.replaceText(node, "(".concat(sourceCode.getText(node), ")"))
118751 });
118752 }
118753 }
118754 }
118755
118756 };
118757 }
118758
118759 };
118760
118761 /***/ }),
118762 /* 852 */
118763 /***/ ((module) => {
118764
118765 "use strict";
118766 /**
118767 * @fileoverview Rule to check the spacing around the * in yield* expressions.
118768 * @author Bryan Smith
118769 */
118770 //------------------------------------------------------------------------------
118771 // Rule Definition
118772 //------------------------------------------------------------------------------
118773
118774 module.exports = {
118775 meta: {
118776 type: "layout",
118777 docs: {
118778 description: "require or disallow spacing around the `*` in `yield*` expressions",
118779 recommended: false,
118780 url: "https://eslint.org/docs/rules/yield-star-spacing"
118781 },
118782 fixable: "whitespace",
118783 schema: [{
118784 oneOf: [{
118785 enum: ["before", "after", "both", "neither"]
118786 }, {
118787 type: "object",
118788 properties: {
118789 before: {
118790 type: "boolean"
118791 },
118792 after: {
118793 type: "boolean"
118794 }
118795 },
118796 additionalProperties: false
118797 }]
118798 }],
118799 messages: {
118800 missingBefore: "Missing space before *.",
118801 missingAfter: "Missing space after *.",
118802 unexpectedBefore: "Unexpected space before *.",
118803 unexpectedAfter: "Unexpected space after *."
118804 }
118805 },
118806
118807 create(context) {
118808 const sourceCode = context.getSourceCode();
118809
118810 const mode = function (option) {
118811 if (!option || typeof option === "string") {
118812 return {
118813 before: {
118814 before: true,
118815 after: false
118816 },
118817 after: {
118818 before: false,
118819 after: true
118820 },
118821 both: {
118822 before: true,
118823 after: true
118824 },
118825 neither: {
118826 before: false,
118827 after: false
118828 }
118829 }[option || "after"];
118830 }
118831
118832 return option;
118833 }(context.options[0]);
118834 /**
118835 * Checks the spacing between two tokens before or after the star token.
118836 * @param {string} side Either "before" or "after".
118837 * @param {Token} leftToken `function` keyword token if side is "before", or
118838 * star token if side is "after".
118839 * @param {Token} rightToken Star token if side is "before", or identifier
118840 * token if side is "after".
118841 * @returns {void}
118842 */
118843
118844
118845 function checkSpacing(side, leftToken, rightToken) {
118846 if (sourceCode.isSpaceBetweenTokens(leftToken, rightToken) !== mode[side]) {
118847 const after = leftToken.value === "*";
118848 const spaceRequired = mode[side];
118849 const node = after ? leftToken : rightToken;
118850 let messageId = "";
118851
118852 if (spaceRequired) {
118853 messageId = side === "before" ? "missingBefore" : "missingAfter";
118854 } else {
118855 messageId = side === "before" ? "unexpectedBefore" : "unexpectedAfter";
118856 }
118857
118858 context.report({
118859 node,
118860 messageId,
118861
118862 fix(fixer) {
118863 if (spaceRequired) {
118864 if (after) {
118865 return fixer.insertTextAfter(node, " ");
118866 }
118867
118868 return fixer.insertTextBefore(node, " ");
118869 }
118870
118871 return fixer.removeRange([leftToken.range[1], rightToken.range[0]]);
118872 }
118873
118874 });
118875 }
118876 }
118877 /**
118878 * Enforces the spacing around the star if node is a yield* expression.
118879 * @param {ASTNode} node A yield expression node.
118880 * @returns {void}
118881 */
118882
118883
118884 function checkExpression(node) {
118885 if (!node.delegate) {
118886 return;
118887 }
118888
118889 const tokens = sourceCode.getFirstTokens(node, 3);
118890 const yieldToken = tokens[0];
118891 const starToken = tokens[1];
118892 const nextToken = tokens[2];
118893 checkSpacing("before", yieldToken, starToken);
118894 checkSpacing("after", starToken, nextToken);
118895 }
118896
118897 return {
118898 YieldExpression: checkExpression
118899 };
118900 }
118901
118902 };
118903
118904 /***/ }),
118905 /* 853 */
118906 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
118907
118908 "use strict";
118909 /**
118910 * @fileoverview Rule to require or disallow yoda comparisons
118911 * @author Nicholas C. Zakas
118912 */
118913 //--------------------------------------------------------------------------
118914 // Requirements
118915 //--------------------------------------------------------------------------
118916
118917 const astUtils = __webpack_require__(548); //--------------------------------------------------------------------------
118918 // Helpers
118919 //--------------------------------------------------------------------------
118920
118921 /**
118922 * Determines whether an operator is a comparison operator.
118923 * @param {string} operator The operator to check.
118924 * @returns {boolean} Whether or not it is a comparison operator.
118925 */
118926
118927
118928 function isComparisonOperator(operator) {
118929 return /^(==|===|!=|!==|<|>|<=|>=)$/u.test(operator);
118930 }
118931 /**
118932 * Determines whether an operator is an equality operator.
118933 * @param {string} operator The operator to check.
118934 * @returns {boolean} Whether or not it is an equality operator.
118935 */
118936
118937
118938 function isEqualityOperator(operator) {
118939 return /^(==|===)$/u.test(operator);
118940 }
118941 /**
118942 * Determines whether an operator is one used in a range test.
118943 * Allowed operators are `<` and `<=`.
118944 * @param {string} operator The operator to check.
118945 * @returns {boolean} Whether the operator is used in range tests.
118946 */
118947
118948
118949 function isRangeTestOperator(operator) {
118950 return ["<", "<="].indexOf(operator) >= 0;
118951 }
118952 /**
118953 * Determines whether a non-Literal node is a negative number that should be
118954 * treated as if it were a single Literal node.
118955 * @param {ASTNode} node Node to test.
118956 * @returns {boolean} True if the node is a negative number that looks like a
118957 * real literal and should be treated as such.
118958 */
118959
118960
118961 function isNegativeNumericLiteral(node) {
118962 return node.type === "UnaryExpression" && node.operator === "-" && node.prefix && astUtils.isNumericLiteral(node.argument);
118963 }
118964 /**
118965 * Determines whether a node is a Template Literal which can be determined statically.
118966 * @param {ASTNode} node Node to test
118967 * @returns {boolean} True if the node is a Template Literal without expression.
118968 */
118969
118970
118971 function isStaticTemplateLiteral(node) {
118972 return node.type === "TemplateLiteral" && node.expressions.length === 0;
118973 }
118974 /**
118975 * Determines whether a non-Literal node should be treated as a single Literal node.
118976 * @param {ASTNode} node Node to test
118977 * @returns {boolean} True if the node should be treated as a single Literal node.
118978 */
118979
118980
118981 function looksLikeLiteral(node) {
118982 return isNegativeNumericLiteral(node) || isStaticTemplateLiteral(node);
118983 }
118984 /**
118985 * Attempts to derive a Literal node from nodes that are treated like literals.
118986 * @param {ASTNode} node Node to normalize.
118987 * @returns {ASTNode} One of the following options.
118988 * 1. The original node if the node is already a Literal
118989 * 2. A normalized Literal node with the negative number as the value if the
118990 * node represents a negative number literal.
118991 * 3. A normalized Literal node with the string as the value if the node is
118992 * a Template Literal without expression.
118993 * 4. Otherwise `null`.
118994 */
118995
118996
118997 function getNormalizedLiteral(node) {
118998 if (node.type === "Literal") {
118999 return node;
119000 }
119001
119002 if (isNegativeNumericLiteral(node)) {
119003 return {
119004 type: "Literal",
119005 value: -node.argument.value,
119006 raw: "-".concat(node.argument.value)
119007 };
119008 }
119009
119010 if (isStaticTemplateLiteral(node)) {
119011 return {
119012 type: "Literal",
119013 value: node.quasis[0].value.cooked,
119014 raw: node.quasis[0].value.raw
119015 };
119016 }
119017
119018 return null;
119019 } //------------------------------------------------------------------------------
119020 // Rule Definition
119021 //------------------------------------------------------------------------------
119022
119023
119024 module.exports = {
119025 meta: {
119026 type: "suggestion",
119027 docs: {
119028 description: 'require or disallow "Yoda" conditions',
119029 recommended: false,
119030 url: "https://eslint.org/docs/rules/yoda"
119031 },
119032 schema: [{
119033 enum: ["always", "never"]
119034 }, {
119035 type: "object",
119036 properties: {
119037 exceptRange: {
119038 type: "boolean",
119039 default: false
119040 },
119041 onlyEquality: {
119042 type: "boolean",
119043 default: false
119044 }
119045 },
119046 additionalProperties: false
119047 }],
119048 fixable: "code",
119049 messages: {
119050 expected: "Expected literal to be on the {{expectedSide}} side of {{operator}}."
119051 }
119052 },
119053
119054 create(context) {
119055 // Default to "never" (!always) if no option
119056 const always = context.options[0] === "always";
119057 const exceptRange = context.options[1] && context.options[1].exceptRange;
119058 const onlyEquality = context.options[1] && context.options[1].onlyEquality;
119059 const sourceCode = context.getSourceCode();
119060 /**
119061 * Determines whether node represents a range test.
119062 * A range test is a "between" test like `(0 <= x && x < 1)` or an "outside"
119063 * test like `(x < 0 || 1 <= x)`. It must be wrapped in parentheses, and
119064 * both operators must be `<` or `<=`. Finally, the literal on the left side
119065 * must be less than or equal to the literal on the right side so that the
119066 * test makes any sense.
119067 * @param {ASTNode} node LogicalExpression node to test.
119068 * @returns {boolean} Whether node is a range test.
119069 */
119070
119071 function isRangeTest(node) {
119072 const left = node.left,
119073 right = node.right;
119074 /**
119075 * Determines whether node is of the form `0 <= x && x < 1`.
119076 * @returns {boolean} Whether node is a "between" range test.
119077 */
119078
119079 function isBetweenTest() {
119080 if (node.operator === "&&" && astUtils.isSameReference(left.right, right.left)) {
119081 const leftLiteral = getNormalizedLiteral(left.left);
119082 const rightLiteral = getNormalizedLiteral(right.right);
119083
119084 if (leftLiteral === null && rightLiteral === null) {
119085 return false;
119086 }
119087
119088 if (rightLiteral === null || leftLiteral === null) {
119089 return true;
119090 }
119091
119092 if (leftLiteral.value <= rightLiteral.value) {
119093 return true;
119094 }
119095 }
119096
119097 return false;
119098 }
119099 /**
119100 * Determines whether node is of the form `x < 0 || 1 <= x`.
119101 * @returns {boolean} Whether node is an "outside" range test.
119102 */
119103
119104
119105 function isOutsideTest() {
119106 if (node.operator === "||" && astUtils.isSameReference(left.left, right.right)) {
119107 const leftLiteral = getNormalizedLiteral(left.right);
119108 const rightLiteral = getNormalizedLiteral(right.left);
119109
119110 if (leftLiteral === null && rightLiteral === null) {
119111 return false;
119112 }
119113
119114 if (rightLiteral === null || leftLiteral === null) {
119115 return true;
119116 }
119117
119118 if (leftLiteral.value <= rightLiteral.value) {
119119 return true;
119120 }
119121 }
119122
119123 return false;
119124 }
119125 /**
119126 * Determines whether node is wrapped in parentheses.
119127 * @returns {boolean} Whether node is preceded immediately by an open
119128 * paren token and followed immediately by a close
119129 * paren token.
119130 */
119131
119132
119133 function isParenWrapped() {
119134 return astUtils.isParenthesised(sourceCode, node);
119135 }
119136
119137 return node.type === "LogicalExpression" && left.type === "BinaryExpression" && right.type === "BinaryExpression" && isRangeTestOperator(left.operator) && isRangeTestOperator(right.operator) && (isBetweenTest() || isOutsideTest()) && isParenWrapped();
119138 }
119139
119140 const OPERATOR_FLIP_MAP = {
119141 "===": "===",
119142 "!==": "!==",
119143 "==": "==",
119144 "!=": "!=",
119145 "<": ">",
119146 ">": "<",
119147 "<=": ">=",
119148 ">=": "<="
119149 };
119150 /**
119151 * Returns a string representation of a BinaryExpression node with its sides/operator flipped around.
119152 * @param {ASTNode} node The BinaryExpression node
119153 * @returns {string} A string representation of the node with the sides and operator flipped
119154 */
119155
119156 function getFlippedString(node) {
119157 const operatorToken = sourceCode.getFirstTokenBetween(node.left, node.right, token => token.value === node.operator);
119158 const lastLeftToken = sourceCode.getTokenBefore(operatorToken);
119159 const firstRightToken = sourceCode.getTokenAfter(operatorToken);
119160 const source = sourceCode.getText();
119161 const leftText = source.slice(node.range[0], lastLeftToken.range[1]);
119162 const textBeforeOperator = source.slice(lastLeftToken.range[1], operatorToken.range[0]);
119163 const textAfterOperator = source.slice(operatorToken.range[1], firstRightToken.range[0]);
119164 const rightText = source.slice(firstRightToken.range[0], node.range[1]);
119165 const tokenBefore = sourceCode.getTokenBefore(node);
119166 const tokenAfter = sourceCode.getTokenAfter(node);
119167 let prefix = "";
119168 let suffix = "";
119169
119170 if (tokenBefore && tokenBefore.range[1] === node.range[0] && !astUtils.canTokensBeAdjacent(tokenBefore, firstRightToken)) {
119171 prefix = " ";
119172 }
119173
119174 if (tokenAfter && node.range[1] === tokenAfter.range[0] && !astUtils.canTokensBeAdjacent(lastLeftToken, tokenAfter)) {
119175 suffix = " ";
119176 }
119177
119178 return prefix + rightText + textBeforeOperator + OPERATOR_FLIP_MAP[operatorToken.value] + textAfterOperator + leftText + suffix;
119179 } //--------------------------------------------------------------------------
119180 // Public
119181 //--------------------------------------------------------------------------
119182
119183
119184 return {
119185 BinaryExpression(node) {
119186 const expectedLiteral = always ? node.left : node.right;
119187 const expectedNonLiteral = always ? node.right : node.left; // If `expectedLiteral` is not a literal, and `expectedNonLiteral` is a literal, raise an error.
119188
119189 if ((expectedNonLiteral.type === "Literal" || looksLikeLiteral(expectedNonLiteral)) && !(expectedLiteral.type === "Literal" || looksLikeLiteral(expectedLiteral)) && !(!isEqualityOperator(node.operator) && onlyEquality) && isComparisonOperator(node.operator) && !(exceptRange && isRangeTest(context.getAncestors().pop()))) {
119190 context.report({
119191 node,
119192 messageId: "expected",
119193 data: {
119194 operator: node.operator,
119195 expectedSide: always ? "left" : "right"
119196 },
119197 fix: fixer => fixer.replaceText(node, getFlippedString(node))
119198 });
119199 }
119200 }
119201
119202 };
119203 }
119204
119205 };
119206
119207 /***/ }),
119208 /* 854 */
119209 /***/ ((module) => {
119210
119211 function webpackEmptyContext(req) {
119212 var e = new Error("Cannot find module '" + req + "'");
119213 e.code = 'MODULE_NOT_FOUND';
119214 throw e;
119215 }
119216 webpackEmptyContext.keys = () => ([]);
119217 webpackEmptyContext.resolve = webpackEmptyContext;
119218 webpackEmptyContext.id = 854;
119219 module.exports = webpackEmptyContext;
119220
119221 /***/ }),
119222 /* 855 */
119223 /***/ ((module) => {
119224
119225 "use strict";
119226 /**
119227 * @fileoverview A variant of EventEmitter which does not give listeners information about each other
119228 * @author Teddy Katz
119229 */
119230 //------------------------------------------------------------------------------
119231 // Typedefs
119232 //------------------------------------------------------------------------------
119233
119234 /**
119235 * An event emitter
119236 * @typedef {Object} SafeEmitter
119237 * @property {(eventName: string, listenerFunc: Function) => void} on Adds a listener for a given event name
119238 * @property {(eventName: string, arg1?: any, arg2?: any, arg3?: any) => void} emit Emits an event with a given name.
119239 * This calls all the listeners that were listening for that name, with `arg1`, `arg2`, and `arg3` as arguments.
119240 * @property {function(): string[]} eventNames Gets the list of event names that have registered listeners.
119241 */
119242
119243 /**
119244 * Creates an object which can listen for and emit events.
119245 * This is similar to the EventEmitter API in Node's standard library, but it has a few differences.
119246 * The goal is to allow multiple modules to attach arbitrary listeners to the same emitter, without
119247 * letting the modules know about each other at all.
119248 * 1. It has no special keys like `error` and `newListener`, which would allow modules to detect when
119249 * another module throws an error or registers a listener.
119250 * 2. It calls listener functions without any `this` value. (`EventEmitter` calls listeners with a
119251 * `this` value of the emitter instance, which would give listeners access to other listeners.)
119252 * @returns {SafeEmitter} An emitter
119253 */
119254
119255 module.exports = () => {
119256 const listeners = Object.create(null);
119257 return Object.freeze({
119258 on(eventName, listener) {
119259 if (eventName in listeners) {
119260 listeners[eventName].push(listener);
119261 } else {
119262 listeners[eventName] = [listener];
119263 }
119264 },
119265
119266 emit(eventName) {
119267 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
119268 args[_key - 1] = arguments[_key];
119269 }
119270
119271 if (eventName in listeners) {
119272 listeners[eventName].forEach(listener => listener(...args));
119273 }
119274 },
119275
119276 eventNames() {
119277 return Object.keys(listeners);
119278 }
119279
119280 });
119281 };
119282
119283 /***/ }),
119284 /* 856 */
119285 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
119286
119287 "use strict";
119288 /**
119289 * @fileoverview An object that caches and applies source code fixes.
119290 * @author Nicholas C. Zakas
119291 */
119292 //------------------------------------------------------------------------------
119293 // Requirements
119294 //------------------------------------------------------------------------------
119295
119296 const debug = __webpack_require__(496)("eslint:source-code-fixer"); //------------------------------------------------------------------------------
119297 // Helpers
119298 //------------------------------------------------------------------------------
119299
119300
119301 const BOM = "\uFEFF";
119302 /**
119303 * Compares items in a messages array by range.
119304 * @param {Message} a The first message.
119305 * @param {Message} b The second message.
119306 * @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
119307 * @private
119308 */
119309
119310 function compareMessagesByFixRange(a, b) {
119311 return a.fix.range[0] - b.fix.range[0] || a.fix.range[1] - b.fix.range[1];
119312 }
119313 /**
119314 * Compares items in a messages array by line and column.
119315 * @param {Message} a The first message.
119316 * @param {Message} b The second message.
119317 * @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
119318 * @private
119319 */
119320
119321
119322 function compareMessagesByLocation(a, b) {
119323 return a.line - b.line || a.column - b.column;
119324 } //------------------------------------------------------------------------------
119325 // Public Interface
119326 //------------------------------------------------------------------------------
119327
119328 /**
119329 * Utility for apply fixes to source code.
119330 * @constructor
119331 */
119332
119333
119334 function SourceCodeFixer() {
119335 Object.freeze(this);
119336 }
119337 /**
119338 * Applies the fixes specified by the messages to the given text. Tries to be
119339 * smart about the fixes and won't apply fixes over the same area in the text.
119340 * @param {string} sourceText The text to apply the changes to.
119341 * @param {Message[]} messages The array of messages reported by ESLint.
119342 * @param {boolean|Function} [shouldFix=true] Determines whether each message should be fixed
119343 * @returns {Object} An object containing the fixed text and any unfixed messages.
119344 */
119345
119346
119347 SourceCodeFixer.applyFixes = function (sourceText, messages, shouldFix) {
119348 debug("Applying fixes");
119349
119350 if (shouldFix === false) {
119351 debug("shouldFix parameter was false, not attempting fixes");
119352 return {
119353 fixed: false,
119354 messages,
119355 output: sourceText
119356 };
119357 } // clone the array
119358
119359
119360 const remainingMessages = [],
119361 fixes = [],
119362 bom = sourceText.startsWith(BOM) ? BOM : "",
119363 text = bom ? sourceText.slice(1) : sourceText;
119364 let lastPos = Number.NEGATIVE_INFINITY,
119365 output = bom;
119366 /**
119367 * Try to use the 'fix' from a problem.
119368 * @param {Message} problem The message object to apply fixes from
119369 * @returns {boolean} Whether fix was successfully applied
119370 */
119371
119372 function attemptFix(problem) {
119373 const fix = problem.fix;
119374 const start = fix.range[0];
119375 const end = fix.range[1]; // Remain it as a problem if it's overlapped or it's a negative range
119376
119377 if (lastPos >= start || start > end) {
119378 remainingMessages.push(problem);
119379 return false;
119380 } // Remove BOM.
119381
119382
119383 if (start < 0 && end >= 0 || start === 0 && fix.text.startsWith(BOM)) {
119384 output = "";
119385 } // Make output to this fix.
119386
119387
119388 output += text.slice(Math.max(0, lastPos), Math.max(0, start));
119389 output += fix.text;
119390 lastPos = end;
119391 return true;
119392 }
119393
119394 messages.forEach(problem => {
119395 if (Object.prototype.hasOwnProperty.call(problem, "fix")) {
119396 fixes.push(problem);
119397 } else {
119398 remainingMessages.push(problem);
119399 }
119400 });
119401
119402 if (fixes.length) {
119403 debug("Found fixes to apply");
119404 let fixesWereApplied = false;
119405
119406 for (const problem of fixes.sort(compareMessagesByFixRange)) {
119407 if (typeof shouldFix !== "function" || shouldFix(problem)) {
119408 attemptFix(problem);
119409 /*
119410 * The only time attemptFix will fail is if a previous fix was
119411 * applied which conflicts with it. So we can mark this as true.
119412 */
119413
119414 fixesWereApplied = true;
119415 } else {
119416 remainingMessages.push(problem);
119417 }
119418 }
119419
119420 output += text.slice(Math.max(0, lastPos));
119421 return {
119422 fixed: fixesWereApplied,
119423 messages: remainingMessages.sort(compareMessagesByLocation),
119424 output
119425 };
119426 }
119427
119428 debug("No fixes to apply");
119429 return {
119430 fixed: false,
119431 messages,
119432 output: bom + text
119433 };
119434 };
119435
119436 module.exports = SourceCodeFixer;
119437
119438 /***/ }),
119439 /* 857 */
119440 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
119441
119442 "use strict";
119443 /* provided dependency */ var process = __webpack_require__(494);
119444 /* provided dependency */ var console = __webpack_require__(438);
119445 /**
119446 * @fileoverview Tracks performance of individual rules.
119447 * @author Brandon Mills
119448 */
119449 //------------------------------------------------------------------------------
119450 // Helpers
119451 //------------------------------------------------------------------------------
119452
119453 /* istanbul ignore next */
119454
119455 /**
119456 * Align the string to left
119457 * @param {string} str string to evaluate
119458 * @param {int} len length of the string
119459 * @param {string} ch delimiter character
119460 * @returns {string} modified string
119461 * @private
119462 */
119463
119464 function alignLeft(str, len, ch) {
119465 return str + new Array(len - str.length + 1).join(ch || " ");
119466 }
119467 /* istanbul ignore next */
119468
119469 /**
119470 * Align the string to right
119471 * @param {string} str string to evaluate
119472 * @param {int} len length of the string
119473 * @param {string} ch delimiter character
119474 * @returns {string} modified string
119475 * @private
119476 */
119477
119478
119479 function alignRight(str, len, ch) {
119480 return new Array(len - str.length + 1).join(ch || " ") + str;
119481 } //------------------------------------------------------------------------------
119482 // Module definition
119483 //------------------------------------------------------------------------------
119484
119485
119486 const enabled = !!process.env.TIMING;
119487 const HEADERS = ["Rule", "Time (ms)", "Relative"];
119488 const ALIGN = [alignLeft, alignRight, alignRight];
119489 /**
119490 * Decide how many rules to show in the output list.
119491 * @returns {number} the number of rules to show
119492 */
119493
119494 function getListSize() {
119495 const MINIMUM_SIZE = 10;
119496
119497 if (typeof process.env.TIMING !== "string") {
119498 return MINIMUM_SIZE;
119499 }
119500
119501 if (process.env.TIMING.toLowerCase() === "all") {
119502 return Number.POSITIVE_INFINITY;
119503 }
119504
119505 const TIMING_ENV_VAR_AS_INTEGER = Number.parseInt(process.env.TIMING, 10);
119506 return TIMING_ENV_VAR_AS_INTEGER > 10 ? TIMING_ENV_VAR_AS_INTEGER : MINIMUM_SIZE;
119507 }
119508 /* istanbul ignore next */
119509
119510 /**
119511 * display the data
119512 * @param {Object} data Data object to be displayed
119513 * @returns {void} prints modified string with console.log
119514 * @private
119515 */
119516
119517
119518 function display(data) {
119519 let total = 0;
119520 const rows = Object.keys(data).map(key => {
119521 const time = data[key];
119522 total += time;
119523 return [key, time];
119524 }).sort((a, b) => b[1] - a[1]).slice(0, getListSize());
119525 rows.forEach(row => {
119526 row.push("".concat((row[1] * 100 / total).toFixed(1), "%"));
119527 row[1] = row[1].toFixed(3);
119528 });
119529 rows.unshift(HEADERS);
119530 const widths = [];
119531 rows.forEach(row => {
119532 const len = row.length;
119533
119534 for (let i = 0; i < len; i++) {
119535 const n = row[i].length;
119536
119537 if (!widths[i] || n > widths[i]) {
119538 widths[i] = n;
119539 }
119540 }
119541 });
119542 const table = rows.map(row => row.map((cell, index) => ALIGN[index](cell, widths[index])).join(" | "));
119543 table.splice(1, 0, widths.map((width, index) => {
119544 const extraAlignment = index !== 0 && index !== widths.length - 1 ? 2 : 1;
119545 return ALIGN[index](":", width + extraAlignment, "-");
119546 }).join("|"));
119547 console.log(table.join("\n")); // eslint-disable-line no-console -- Debugging function
119548 }
119549 /* istanbul ignore next */
119550
119551
119552 module.exports = function () {
119553 const data = Object.create(null);
119554 /**
119555 * Time the run
119556 * @param {any} key key from the data object
119557 * @param {Function} fn function to be called
119558 * @returns {Function} function to be executed
119559 * @private
119560 */
119561
119562 function time(key, fn) {
119563 if (typeof data[key] === "undefined") {
119564 data[key] = 0;
119565 }
119566
119567 return function () {
119568 let t = process.hrtime();
119569 fn(...arguments);
119570 t = process.hrtime(t);
119571 data[key] += t[0] * 1e3 + t[1] / 1e6;
119572 };
119573 }
119574
119575 if (enabled) {
119576 process.on("exit", () => {
119577 display(data);
119578 });
119579 }
119580
119581 return {
119582 time,
119583 enabled,
119584 getListSize
119585 };
119586 }();
119587
119588 /***/ }),
119589 /* 858 */
119590 /***/ ((module) => {
119591
119592 "use strict";
119593 module.exports = JSON.parse('{"rules":{"generator-star":["generator-star-spacing"],"global-strict":["strict"],"no-arrow-condition":["no-confusing-arrow","no-constant-condition"],"no-comma-dangle":["comma-dangle"],"no-empty-class":["no-empty-character-class"],"no-empty-label":["no-labels"],"no-extra-strict":["strict"],"no-reserved-keys":["quote-props"],"no-space-before-semi":["semi-spacing"],"no-wrap-func":["no-extra-parens"],"space-after-function-name":["space-before-function-paren"],"space-after-keywords":["keyword-spacing"],"space-before-function-parentheses":["space-before-function-paren"],"space-before-keywords":["keyword-spacing"],"space-in-brackets":["object-curly-spacing","array-bracket-spacing","computed-property-spacing"],"space-return-throw-case":["keyword-spacing"],"space-unary-word-ops":["space-unary-ops"],"spaced-line-comment":["spaced-comment"]}}');
119594
119595 /***/ }),
119596 /* 859 */
119597 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
119598
119599 "use strict";
119600
119601
119602 const {
119603 CLIEngine
119604 } = __webpack_require__(860);
119605
119606 module.exports = {
119607 CLIEngine
119608 };
119609
119610 /***/ }),
119611 /* 860 */
119612 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
119613
119614 "use strict";
119615 /* provided dependency */ var process = __webpack_require__(494);
119616 /**
119617 * @fileoverview Main CLI object.
119618 * @author Nicholas C. Zakas
119619 */
119620
119621 /*
119622 * The CLI object should *not* call process.exit() directly. It should only return
119623 * exit codes. This allows other programs to use the CLI object and still control
119624 * when the program exits.
119625 */
119626 //------------------------------------------------------------------------------
119627 // Requirements
119628 //------------------------------------------------------------------------------
119629
119630 const fs = __webpack_require__(861);
119631
119632 const path = __webpack_require__(429);
119633
119634 const defaultOptions = __webpack_require__(862);
119635
119636 const pkg = __webpack_require__(443);
119637
119638 const {
119639 Legacy: {
119640 ConfigOps,
119641 naming,
119642 CascadingConfigArrayFactory,
119643 IgnorePattern,
119644 getUsedExtractedConfigs,
119645 ModuleResolver
119646 }
119647 } = __webpack_require__(863);
119648
119649 const {
119650 FileEnumerator
119651 } = __webpack_require__(877);
119652
119653 const {
119654 Linter
119655 } = __webpack_require__(881);
119656
119657 const builtInRules = __webpack_require__(545);
119658
119659 const loadRules = __webpack_require__(882);
119660
119661 const hash = __webpack_require__(884);
119662
119663 const LintResultCache = __webpack_require__(886);
119664
119665 const debug = __webpack_require__(496)("eslint:cli-engine");
119666
119667 const validFixTypes = new Set(["directive", "problem", "suggestion", "layout"]); //------------------------------------------------------------------------------
119668 // Typedefs
119669 //------------------------------------------------------------------------------
119670 // For VSCode IntelliSense
119671
119672 /** @typedef {import("../shared/types").ConfigData} ConfigData */
119673
119674 /** @typedef {import("../shared/types").DeprecatedRuleInfo} DeprecatedRuleInfo */
119675
119676 /** @typedef {import("../shared/types").LintMessage} LintMessage */
119677
119678 /** @typedef {import("../shared/types").ParserOptions} ParserOptions */
119679
119680 /** @typedef {import("../shared/types").Plugin} Plugin */
119681
119682 /** @typedef {import("../shared/types").RuleConf} RuleConf */
119683
119684 /** @typedef {import("../shared/types").Rule} Rule */
119685
119686 /** @typedef {ReturnType<CascadingConfigArrayFactory.getConfigArrayForFile>} ConfigArray */
119687
119688 /** @typedef {ReturnType<ConfigArray.extractConfig>} ExtractedConfig */
119689
119690 /**
119691 * The options to configure a CLI engine with.
119692 * @typedef {Object} CLIEngineOptions
119693 * @property {boolean} [allowInlineConfig] Enable or disable inline configuration comments.
119694 * @property {ConfigData} [baseConfig] Base config object, extended by all configs used with this CLIEngine instance
119695 * @property {boolean} [cache] Enable result caching.
119696 * @property {string} [cacheLocation] The cache file to use instead of .eslintcache.
119697 * @property {string} [configFile] The configuration file to use.
119698 * @property {string} [cwd] The value to use for the current working directory.
119699 * @property {string[]} [envs] An array of environments to load.
119700 * @property {string[]|null} [extensions] An array of file extensions to check.
119701 * @property {boolean|Function} [fix] Execute in autofix mode. If a function, should return a boolean.
119702 * @property {string[]} [fixTypes] Array of rule types to apply fixes for.
119703 * @property {string[]} [globals] An array of global variables to declare.
119704 * @property {boolean} [ignore] False disables use of .eslintignore.
119705 * @property {string} [ignorePath] The ignore file to use instead of .eslintignore.
119706 * @property {string|string[]} [ignorePattern] One or more glob patterns to ignore.
119707 * @property {boolean} [useEslintrc] False disables looking for .eslintrc
119708 * @property {string} [parser] The name of the parser to use.
119709 * @property {ParserOptions} [parserOptions] An object of parserOption settings to use.
119710 * @property {string[]} [plugins] An array of plugins to load.
119711 * @property {Record<string,RuleConf>} [rules] An object of rules to use.
119712 * @property {string[]} [rulePaths] An array of directories to load custom rules from.
119713 * @property {boolean} [reportUnusedDisableDirectives] `true` adds reports for unused eslint-disable directives
119714 * @property {boolean} [globInputPaths] Set to false to skip glob resolution of input file paths to lint (default: true). If false, each input file paths is assumed to be a non-glob path to an existing file.
119715 * @property {string} [resolvePluginsRelativeTo] The folder where plugins should be resolved from, defaulting to the CWD
119716 */
119717
119718 /**
119719 * A linting result.
119720 * @typedef {Object} LintResult
119721 * @property {string} filePath The path to the file that was linted.
119722 * @property {LintMessage[]} messages All of the messages for the result.
119723 * @property {number} errorCount Number of errors for the result.
119724 * @property {number} warningCount Number of warnings for the result.
119725 * @property {number} fixableErrorCount Number of fixable errors for the result.
119726 * @property {number} fixableWarningCount Number of fixable warnings for the result.
119727 * @property {string} [source] The source code of the file that was linted.
119728 * @property {string} [output] The source code of the file that was linted, with as many fixes applied as possible.
119729 */
119730
119731 /**
119732 * Linting results.
119733 * @typedef {Object} LintReport
119734 * @property {LintResult[]} results All of the result.
119735 * @property {number} errorCount Number of errors for the result.
119736 * @property {number} warningCount Number of warnings for the result.
119737 * @property {number} fixableErrorCount Number of fixable errors for the result.
119738 * @property {number} fixableWarningCount Number of fixable warnings for the result.
119739 * @property {DeprecatedRuleInfo[]} usedDeprecatedRules The list of used deprecated rules.
119740 */
119741
119742 /**
119743 * Private data for CLIEngine.
119744 * @typedef {Object} CLIEngineInternalSlots
119745 * @property {Map<string, Plugin>} additionalPluginPool The map for additional plugins.
119746 * @property {string} cacheFilePath The path to the cache of lint results.
119747 * @property {CascadingConfigArrayFactory} configArrayFactory The factory of configs.
119748 * @property {(filePath: string) => boolean} defaultIgnores The default predicate function to check if a file ignored or not.
119749 * @property {FileEnumerator} fileEnumerator The file enumerator.
119750 * @property {ConfigArray[]} lastConfigArrays The list of config arrays that the last `executeOnFiles` or `executeOnText` used.
119751 * @property {LintResultCache|null} lintResultCache The cache of lint results.
119752 * @property {Linter} linter The linter instance which has loaded rules.
119753 * @property {CLIEngineOptions} options The normalized options of this instance.
119754 */
119755 //------------------------------------------------------------------------------
119756 // Helpers
119757 //------------------------------------------------------------------------------
119758
119759 /** @type {WeakMap<CLIEngine, CLIEngineInternalSlots>} */
119760
119761 const internalSlotsMap = new WeakMap();
119762 /**
119763 * Determines if each fix type in an array is supported by ESLint and throws
119764 * an error if not.
119765 * @param {string[]} fixTypes An array of fix types to check.
119766 * @returns {void}
119767 * @throws {Error} If an invalid fix type is found.
119768 */
119769
119770 function validateFixTypes(fixTypes) {
119771 for (const fixType of fixTypes) {
119772 if (!validFixTypes.has(fixType)) {
119773 throw new Error("Invalid fix type \"".concat(fixType, "\" found."));
119774 }
119775 }
119776 }
119777 /**
119778 * It will calculate the error and warning count for collection of messages per file
119779 * @param {LintMessage[]} messages Collection of messages
119780 * @returns {Object} Contains the stats
119781 * @private
119782 */
119783
119784
119785 function calculateStatsPerFile(messages) {
119786 return messages.reduce((stat, message) => {
119787 if (message.fatal || message.severity === 2) {
119788 stat.errorCount++;
119789
119790 if (message.fatal) {
119791 stat.fatalErrorCount++;
119792 }
119793
119794 if (message.fix) {
119795 stat.fixableErrorCount++;
119796 }
119797 } else {
119798 stat.warningCount++;
119799
119800 if (message.fix) {
119801 stat.fixableWarningCount++;
119802 }
119803 }
119804
119805 return stat;
119806 }, {
119807 errorCount: 0,
119808 fatalErrorCount: 0,
119809 warningCount: 0,
119810 fixableErrorCount: 0,
119811 fixableWarningCount: 0
119812 });
119813 }
119814 /**
119815 * It will calculate the error and warning count for collection of results from all files
119816 * @param {LintResult[]} results Collection of messages from all the files
119817 * @returns {Object} Contains the stats
119818 * @private
119819 */
119820
119821
119822 function calculateStatsPerRun(results) {
119823 return results.reduce((stat, result) => {
119824 stat.errorCount += result.errorCount;
119825 stat.fatalErrorCount += result.fatalErrorCount;
119826 stat.warningCount += result.warningCount;
119827 stat.fixableErrorCount += result.fixableErrorCount;
119828 stat.fixableWarningCount += result.fixableWarningCount;
119829 return stat;
119830 }, {
119831 errorCount: 0,
119832 fatalErrorCount: 0,
119833 warningCount: 0,
119834 fixableErrorCount: 0,
119835 fixableWarningCount: 0
119836 });
119837 }
119838 /**
119839 * Processes an source code using ESLint.
119840 * @param {Object} config The config object.
119841 * @param {string} config.text The source code to verify.
119842 * @param {string} config.cwd The path to the current working directory.
119843 * @param {string|undefined} config.filePath The path to the file of `text`. If this is undefined, it uses `<text>`.
119844 * @param {ConfigArray} config.config The config.
119845 * @param {boolean} config.fix If `true` then it does fix.
119846 * @param {boolean} config.allowInlineConfig If `true` then it uses directive comments.
119847 * @param {boolean} config.reportUnusedDisableDirectives If `true` then it reports unused `eslint-disable` comments.
119848 * @param {FileEnumerator} config.fileEnumerator The file enumerator to check if a path is a target or not.
119849 * @param {Linter} config.linter The linter instance to verify.
119850 * @returns {LintResult} The result of linting.
119851 * @private
119852 */
119853
119854
119855 function verifyText(_ref) {
119856 let {
119857 text,
119858 cwd,
119859 filePath: providedFilePath,
119860 config,
119861 fix,
119862 allowInlineConfig,
119863 reportUnusedDisableDirectives,
119864 fileEnumerator,
119865 linter
119866 } = _ref;
119867 const filePath = providedFilePath || "<text>";
119868 debug("Lint ".concat(filePath));
119869 /*
119870 * Verify.
119871 * `config.extractConfig(filePath)` requires an absolute path, but `linter`
119872 * doesn't know CWD, so it gives `linter` an absolute path always.
119873 */
119874
119875 const filePathToVerify = filePath === "<text>" ? path.join(cwd, filePath) : filePath;
119876 const {
119877 fixed,
119878 messages,
119879 output
119880 } = linter.verifyAndFix(text, config, {
119881 allowInlineConfig,
119882 filename: filePathToVerify,
119883 fix,
119884 reportUnusedDisableDirectives,
119885
119886 /**
119887 * Check if the linter should adopt a given code block or not.
119888 * @param {string} blockFilename The virtual filename of a code block.
119889 * @returns {boolean} `true` if the linter should adopt the code block.
119890 */
119891 filterCodeBlock(blockFilename) {
119892 return fileEnumerator.isTargetPath(blockFilename);
119893 }
119894
119895 }); // Tweak and return.
119896
119897 const result = {
119898 filePath,
119899 messages,
119900 ...calculateStatsPerFile(messages)
119901 };
119902
119903 if (fixed) {
119904 result.output = output;
119905 }
119906
119907 if (result.errorCount + result.warningCount > 0 && typeof result.output === "undefined") {
119908 result.source = text;
119909 }
119910
119911 return result;
119912 }
119913 /**
119914 * Returns result with warning by ignore settings
119915 * @param {string} filePath File path of checked code
119916 * @param {string} baseDir Absolute path of base directory
119917 * @returns {LintResult} Result with single warning
119918 * @private
119919 */
119920
119921
119922 function createIgnoreResult(filePath, baseDir) {
119923 let message;
119924 const isHidden = filePath.split(path.sep).find(segment => /^\./u.test(segment));
119925 const isInNodeModules = baseDir && path.relative(baseDir, filePath).startsWith("node_modules");
119926
119927 if (isHidden) {
119928 message = "File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!<relative/path/to/filename>'\") to override.";
119929 } else if (isInNodeModules) {
119930 message = "File ignored by default. Use \"--ignore-pattern '!node_modules/*'\" to override.";
119931 } else {
119932 message = "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override.";
119933 }
119934
119935 return {
119936 filePath: path.resolve(filePath),
119937 messages: [{
119938 fatal: false,
119939 severity: 1,
119940 message
119941 }],
119942 errorCount: 0,
119943 warningCount: 1,
119944 fixableErrorCount: 0,
119945 fixableWarningCount: 0
119946 };
119947 }
119948 /**
119949 * Get a rule.
119950 * @param {string} ruleId The rule ID to get.
119951 * @param {ConfigArray[]} configArrays The config arrays that have plugin rules.
119952 * @returns {Rule|null} The rule or null.
119953 */
119954
119955
119956 function getRule(ruleId, configArrays) {
119957 for (const configArray of configArrays) {
119958 const rule = configArray.pluginRules.get(ruleId);
119959
119960 if (rule) {
119961 return rule;
119962 }
119963 }
119964
119965 return builtInRules.get(ruleId) || null;
119966 }
119967 /**
119968 * Checks whether a message's rule type should be fixed.
119969 * @param {LintMessage} message The message to check.
119970 * @param {ConfigArray[]} lastConfigArrays The list of config arrays that the last `executeOnFiles` or `executeOnText` used.
119971 * @param {string[]} fixTypes An array of fix types to check.
119972 * @returns {boolean} Whether the message should be fixed.
119973 */
119974
119975
119976 function shouldMessageBeFixed(message, lastConfigArrays, fixTypes) {
119977 if (!message.ruleId) {
119978 return fixTypes.has("directive");
119979 }
119980
119981 const rule = message.ruleId && getRule(message.ruleId, lastConfigArrays);
119982 return Boolean(rule && rule.meta && fixTypes.has(rule.meta.type));
119983 }
119984 /**
119985 * Collect used deprecated rules.
119986 * @param {ConfigArray[]} usedConfigArrays The config arrays which were used.
119987 * @returns {IterableIterator<DeprecatedRuleInfo>} Used deprecated rules.
119988 */
119989
119990
119991 function* iterateRuleDeprecationWarnings(usedConfigArrays) {
119992 const processedRuleIds = new Set(); // Flatten used configs.
119993
119994 /** @type {ExtractedConfig[]} */
119995
119996 const configs = [].concat(...usedConfigArrays.map(getUsedExtractedConfigs)); // Traverse rule configs.
119997
119998 for (const config of configs) {
119999 for (const [ruleId, ruleConfig] of Object.entries(config.rules)) {
120000 // Skip if it was processed.
120001 if (processedRuleIds.has(ruleId)) {
120002 continue;
120003 }
120004
120005 processedRuleIds.add(ruleId); // Skip if it's not used.
120006
120007 if (!ConfigOps.getRuleSeverity(ruleConfig)) {
120008 continue;
120009 }
120010
120011 const rule = getRule(ruleId, usedConfigArrays); // Skip if it's not deprecated.
120012
120013 if (!(rule && rule.meta && rule.meta.deprecated)) {
120014 continue;
120015 } // This rule was used and deprecated.
120016
120017
120018 yield {
120019 ruleId,
120020 replacedBy: rule.meta.replacedBy || []
120021 };
120022 }
120023 }
120024 }
120025 /**
120026 * Checks if the given message is an error message.
120027 * @param {LintMessage} message The message to check.
120028 * @returns {boolean} Whether or not the message is an error message.
120029 * @private
120030 */
120031
120032
120033 function isErrorMessage(message) {
120034 return message.severity === 2;
120035 }
120036 /**
120037 * return the cacheFile to be used by eslint, based on whether the provided parameter is
120038 * a directory or looks like a directory (ends in `path.sep`), in which case the file
120039 * name will be the `cacheFile/.cache_hashOfCWD`
120040 *
120041 * if cacheFile points to a file or looks like a file then in will just use that file
120042 * @param {string} cacheFile The name of file to be used to store the cache
120043 * @param {string} cwd Current working directory
120044 * @returns {string} the resolved path to the cache file
120045 */
120046
120047
120048 function getCacheFile(cacheFile, cwd) {
120049 /*
120050 * make sure the path separators are normalized for the environment/os
120051 * keeping the trailing path separator if present
120052 */
120053 const normalizedCacheFile = path.normalize(cacheFile);
120054 const resolvedCacheFile = path.resolve(cwd, normalizedCacheFile);
120055 const looksLikeADirectory = normalizedCacheFile.slice(-1) === path.sep;
120056 /**
120057 * return the name for the cache file in case the provided parameter is a directory
120058 * @returns {string} the resolved path to the cacheFile
120059 */
120060
120061 function getCacheFileForDirectory() {
120062 return path.join(resolvedCacheFile, ".cache_".concat(hash(cwd)));
120063 }
120064
120065 let fileStats;
120066
120067 try {
120068 fileStats = fs.lstatSync(resolvedCacheFile);
120069 } catch {
120070 fileStats = null;
120071 }
120072 /*
120073 * in case the file exists we need to verify if the provided path
120074 * is a directory or a file. If it is a directory we want to create a file
120075 * inside that directory
120076 */
120077
120078
120079 if (fileStats) {
120080 /*
120081 * is a directory or is a file, but the original file the user provided
120082 * looks like a directory but `path.resolve` removed the `last path.sep`
120083 * so we need to still treat this like a directory
120084 */
120085 if (fileStats.isDirectory() || looksLikeADirectory) {
120086 return getCacheFileForDirectory();
120087 } // is file so just use that file
120088
120089
120090 return resolvedCacheFile;
120091 }
120092 /*
120093 * here we known the file or directory doesn't exist,
120094 * so we will try to infer if its a directory if it looks like a directory
120095 * for the current operating system.
120096 */
120097 // if the last character passed is a path separator we assume is a directory
120098
120099
120100 if (looksLikeADirectory) {
120101 return getCacheFileForDirectory();
120102 }
120103
120104 return resolvedCacheFile;
120105 }
120106 /**
120107 * Convert a string array to a boolean map.
120108 * @param {string[]|null} keys The keys to assign true.
120109 * @param {boolean} defaultValue The default value for each property.
120110 * @param {string} displayName The property name which is used in error message.
120111 * @throws {Error} Requires array.
120112 * @returns {Record<string,boolean>} The boolean map.
120113 */
120114
120115
120116 function toBooleanMap(keys, defaultValue, displayName) {
120117 if (keys && !Array.isArray(keys)) {
120118 throw new Error("".concat(displayName, " must be an array."));
120119 }
120120
120121 if (keys && keys.length > 0) {
120122 return keys.reduce((map, def) => {
120123 const [key, value] = def.split(":");
120124
120125 if (key !== "__proto__") {
120126 map[key] = value === void 0 ? defaultValue : value === "true";
120127 }
120128
120129 return map;
120130 }, {});
120131 }
120132
120133 return void 0;
120134 }
120135 /**
120136 * Create a config data from CLI options.
120137 * @param {CLIEngineOptions} options The options
120138 * @returns {ConfigData|null} The created config data.
120139 */
120140
120141
120142 function createConfigDataFromOptions(options) {
120143 const {
120144 ignorePattern,
120145 parser,
120146 parserOptions,
120147 plugins,
120148 rules
120149 } = options;
120150 const env = toBooleanMap(options.envs, true, "envs");
120151 const globals = toBooleanMap(options.globals, false, "globals");
120152
120153 if (env === void 0 && globals === void 0 && (ignorePattern === void 0 || ignorePattern.length === 0) && parser === void 0 && parserOptions === void 0 && plugins === void 0 && rules === void 0) {
120154 return null;
120155 }
120156
120157 return {
120158 env,
120159 globals,
120160 ignorePatterns: ignorePattern,
120161 parser,
120162 parserOptions,
120163 plugins,
120164 rules
120165 };
120166 }
120167 /**
120168 * Checks whether a directory exists at the given location
120169 * @param {string} resolvedPath A path from the CWD
120170 * @throws {Error} As thrown by `fs.statSync` or `fs.isDirectory`.
120171 * @returns {boolean} `true` if a directory exists
120172 */
120173
120174
120175 function directoryExists(resolvedPath) {
120176 try {
120177 return fs.statSync(resolvedPath).isDirectory();
120178 } catch (error) {
120179 if (error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
120180 return false;
120181 }
120182
120183 throw error;
120184 }
120185 } //------------------------------------------------------------------------------
120186 // Public Interface
120187 //------------------------------------------------------------------------------
120188
120189 /**
120190 * Core CLI.
120191 */
120192
120193
120194 class CLIEngine {
120195 /**
120196 * Creates a new instance of the core CLI engine.
120197 * @param {CLIEngineOptions} providedOptions The options for this instance.
120198 * @param {Object} [additionalData] Additional settings that are not CLIEngineOptions.
120199 * @param {Record<string,Plugin>|null} [additionalData.preloadedPlugins] Preloaded plugins.
120200 */
120201 constructor(providedOptions) {
120202 let {
120203 preloadedPlugins
120204 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
120205 const options = Object.assign(Object.create(null), defaultOptions, {
120206 cwd: process.cwd()
120207 }, providedOptions);
120208
120209 if (options.fix === void 0) {
120210 options.fix = false;
120211 }
120212
120213 const additionalPluginPool = new Map();
120214
120215 if (preloadedPlugins) {
120216 for (const [id, plugin] of Object.entries(preloadedPlugins)) {
120217 additionalPluginPool.set(id, plugin);
120218 }
120219 }
120220
120221 const cacheFilePath = getCacheFile(options.cacheLocation || options.cacheFile, options.cwd);
120222 const configArrayFactory = new CascadingConfigArrayFactory({
120223 additionalPluginPool,
120224 baseConfig: options.baseConfig || null,
120225 cliConfig: createConfigDataFromOptions(options),
120226 cwd: options.cwd,
120227 ignorePath: options.ignorePath,
120228 resolvePluginsRelativeTo: options.resolvePluginsRelativeTo,
120229 rulePaths: options.rulePaths,
120230 specificConfigPath: options.configFile,
120231 useEslintrc: options.useEslintrc,
120232 builtInRules,
120233 loadRules,
120234 eslintRecommendedPath: path.resolve(__dirname, "../../conf/eslint-recommended.js"),
120235 eslintAllPath: path.resolve(__dirname, "../../conf/eslint-all.js")
120236 });
120237 const fileEnumerator = new FileEnumerator({
120238 configArrayFactory,
120239 cwd: options.cwd,
120240 extensions: options.extensions,
120241 globInputPaths: options.globInputPaths,
120242 errorOnUnmatchedPattern: options.errorOnUnmatchedPattern,
120243 ignore: options.ignore
120244 });
120245 const lintResultCache = options.cache ? new LintResultCache(cacheFilePath, options.cacheStrategy) : null;
120246 const linter = new Linter({
120247 cwd: options.cwd
120248 });
120249 /** @type {ConfigArray[]} */
120250
120251 const lastConfigArrays = [configArrayFactory.getConfigArrayForFile()]; // Store private data.
120252
120253 internalSlotsMap.set(this, {
120254 additionalPluginPool,
120255 cacheFilePath,
120256 configArrayFactory,
120257 defaultIgnores: IgnorePattern.createDefaultIgnore(options.cwd),
120258 fileEnumerator,
120259 lastConfigArrays,
120260 lintResultCache,
120261 linter,
120262 options
120263 }); // setup special filter for fixes
120264
120265 if (options.fix && options.fixTypes && options.fixTypes.length > 0) {
120266 debug("Using fix types ".concat(options.fixTypes)); // throw an error if any invalid fix types are found
120267
120268 validateFixTypes(options.fixTypes); // convert to Set for faster lookup
120269
120270 const fixTypes = new Set(options.fixTypes); // save original value of options.fix in case it's a function
120271
120272 const originalFix = typeof options.fix === "function" ? options.fix : () => true;
120273
120274 options.fix = message => shouldMessageBeFixed(message, lastConfigArrays, fixTypes) && originalFix(message);
120275 }
120276 }
120277
120278 getRules() {
120279 const {
120280 lastConfigArrays
120281 } = internalSlotsMap.get(this);
120282 return new Map(function* () {
120283 yield* builtInRules;
120284
120285 for (const configArray of lastConfigArrays) {
120286 yield* configArray.pluginRules;
120287 }
120288 }());
120289 }
120290 /**
120291 * Returns results that only contains errors.
120292 * @param {LintResult[]} results The results to filter.
120293 * @returns {LintResult[]} The filtered results.
120294 */
120295
120296
120297 static getErrorResults(results) {
120298 const filtered = [];
120299 results.forEach(result => {
120300 const filteredMessages = result.messages.filter(isErrorMessage);
120301
120302 if (filteredMessages.length > 0) {
120303 filtered.push({ ...result,
120304 messages: filteredMessages,
120305 errorCount: filteredMessages.length,
120306 warningCount: 0,
120307 fixableErrorCount: result.fixableErrorCount,
120308 fixableWarningCount: 0
120309 });
120310 }
120311 });
120312 return filtered;
120313 }
120314 /**
120315 * Outputs fixes from the given results to files.
120316 * @param {LintReport} report The report object created by CLIEngine.
120317 * @returns {void}
120318 */
120319
120320
120321 static outputFixes(report) {
120322 report.results.filter(result => Object.prototype.hasOwnProperty.call(result, "output")).forEach(result => {
120323 fs.writeFileSync(result.filePath, result.output);
120324 });
120325 }
120326 /**
120327 * Resolves the patterns passed into executeOnFiles() into glob-based patterns
120328 * for easier handling.
120329 * @param {string[]} patterns The file patterns passed on the command line.
120330 * @returns {string[]} The equivalent glob patterns.
120331 */
120332
120333
120334 resolveFileGlobPatterns(patterns) {
120335 const {
120336 options
120337 } = internalSlotsMap.get(this);
120338
120339 if (options.globInputPaths === false) {
120340 return patterns.filter(Boolean);
120341 }
120342
120343 const extensions = (options.extensions || [".js"]).map(ext => ext.replace(/^\./u, ""));
120344 const dirSuffix = "/**/*.{".concat(extensions.join(","), "}");
120345 return patterns.filter(Boolean).map(pathname => {
120346 const resolvedPath = path.resolve(options.cwd, pathname);
120347 const newPath = directoryExists(resolvedPath) ? pathname.replace(/[/\\]$/u, "") + dirSuffix : pathname;
120348 return path.normalize(newPath).replace(/\\/gu, "/");
120349 });
120350 }
120351 /**
120352 * Executes the current configuration on an array of file and directory names.
120353 * @param {string[]} patterns An array of file and directory names.
120354 * @throws {Error} As may be thrown by `fs.unlinkSync`.
120355 * @returns {LintReport} The results for all files that were linted.
120356 */
120357
120358
120359 executeOnFiles(patterns) {
120360 const {
120361 cacheFilePath,
120362 fileEnumerator,
120363 lastConfigArrays,
120364 lintResultCache,
120365 linter,
120366 options: {
120367 allowInlineConfig,
120368 cache,
120369 cwd,
120370 fix,
120371 reportUnusedDisableDirectives
120372 }
120373 } = internalSlotsMap.get(this);
120374 const results = [];
120375 const startTime = Date.now(); // Clear the last used config arrays.
120376
120377 lastConfigArrays.length = 0; // Delete cache file; should this do here?
120378
120379 if (!cache) {
120380 try {
120381 fs.unlinkSync(cacheFilePath);
120382 } catch (error) {
120383 const errorCode = error && error.code; // Ignore errors when no such file exists or file system is read only (and cache file does not exist)
120384
120385 if (errorCode !== "ENOENT" && !(errorCode === "EROFS" && !fs.existsSync(cacheFilePath))) {
120386 throw error;
120387 }
120388 }
120389 } // Iterate source code files.
120390
120391
120392 for (const {
120393 config,
120394 filePath,
120395 ignored
120396 } of fileEnumerator.iterateFiles(patterns)) {
120397 if (ignored) {
120398 results.push(createIgnoreResult(filePath, cwd));
120399 continue;
120400 }
120401 /*
120402 * Store used configs for:
120403 * - this method uses to collect used deprecated rules.
120404 * - `getRules()` method uses to collect all loaded rules.
120405 * - `--fix-type` option uses to get the loaded rule's meta data.
120406 */
120407
120408
120409 if (!lastConfigArrays.includes(config)) {
120410 lastConfigArrays.push(config);
120411 } // Skip if there is cached result.
120412
120413
120414 if (lintResultCache) {
120415 const cachedResult = lintResultCache.getCachedLintResults(filePath, config);
120416
120417 if (cachedResult) {
120418 const hadMessages = cachedResult.messages && cachedResult.messages.length > 0;
120419
120420 if (hadMessages && fix) {
120421 debug("Reprocessing cached file to allow autofix: ".concat(filePath));
120422 } else {
120423 debug("Skipping file since it hasn't changed: ".concat(filePath));
120424 results.push(cachedResult);
120425 continue;
120426 }
120427 }
120428 } // Do lint.
120429
120430
120431 const result = verifyText({
120432 text: fs.readFileSync(filePath, "utf8"),
120433 filePath,
120434 config,
120435 cwd,
120436 fix,
120437 allowInlineConfig,
120438 reportUnusedDisableDirectives,
120439 fileEnumerator,
120440 linter
120441 });
120442 results.push(result);
120443 /*
120444 * Store the lint result in the LintResultCache.
120445 * NOTE: The LintResultCache will remove the file source and any
120446 * other properties that are difficult to serialize, and will
120447 * hydrate those properties back in on future lint runs.
120448 */
120449
120450 if (lintResultCache) {
120451 lintResultCache.setCachedLintResults(filePath, config, result);
120452 }
120453 } // Persist the cache to disk.
120454
120455
120456 if (lintResultCache) {
120457 lintResultCache.reconcile();
120458 }
120459
120460 debug("Linting complete in: ".concat(Date.now() - startTime, "ms"));
120461 let usedDeprecatedRules;
120462 return {
120463 results,
120464 ...calculateStatsPerRun(results),
120465
120466 // Initialize it lazily because CLI and `ESLint` API don't use it.
120467 get usedDeprecatedRules() {
120468 if (!usedDeprecatedRules) {
120469 usedDeprecatedRules = Array.from(iterateRuleDeprecationWarnings(lastConfigArrays));
120470 }
120471
120472 return usedDeprecatedRules;
120473 }
120474
120475 };
120476 }
120477 /**
120478 * Executes the current configuration on text.
120479 * @param {string} text A string of JavaScript code to lint.
120480 * @param {string} [filename] An optional string representing the texts filename.
120481 * @param {boolean} [warnIgnored] Always warn when a file is ignored
120482 * @returns {LintReport} The results for the linting.
120483 */
120484
120485
120486 executeOnText(text, filename, warnIgnored) {
120487 const {
120488 configArrayFactory,
120489 fileEnumerator,
120490 lastConfigArrays,
120491 linter,
120492 options: {
120493 allowInlineConfig,
120494 cwd,
120495 fix,
120496 reportUnusedDisableDirectives
120497 }
120498 } = internalSlotsMap.get(this);
120499 const results = [];
120500 const startTime = Date.now();
120501 const resolvedFilename = filename && path.resolve(cwd, filename); // Clear the last used config arrays.
120502
120503 lastConfigArrays.length = 0;
120504
120505 if (resolvedFilename && this.isPathIgnored(resolvedFilename)) {
120506 if (warnIgnored) {
120507 results.push(createIgnoreResult(resolvedFilename, cwd));
120508 }
120509 } else {
120510 const config = configArrayFactory.getConfigArrayForFile(resolvedFilename || "__placeholder__.js");
120511 /*
120512 * Store used configs for:
120513 * - this method uses to collect used deprecated rules.
120514 * - `getRules()` method uses to collect all loaded rules.
120515 * - `--fix-type` option uses to get the loaded rule's meta data.
120516 */
120517
120518 lastConfigArrays.push(config); // Do lint.
120519
120520 results.push(verifyText({
120521 text,
120522 filePath: resolvedFilename,
120523 config,
120524 cwd,
120525 fix,
120526 allowInlineConfig,
120527 reportUnusedDisableDirectives,
120528 fileEnumerator,
120529 linter
120530 }));
120531 }
120532
120533 debug("Linting complete in: ".concat(Date.now() - startTime, "ms"));
120534 let usedDeprecatedRules;
120535 return {
120536 results,
120537 ...calculateStatsPerRun(results),
120538
120539 // Initialize it lazily because CLI and `ESLint` API don't use it.
120540 get usedDeprecatedRules() {
120541 if (!usedDeprecatedRules) {
120542 usedDeprecatedRules = Array.from(iterateRuleDeprecationWarnings(lastConfigArrays));
120543 }
120544
120545 return usedDeprecatedRules;
120546 }
120547
120548 };
120549 }
120550 /**
120551 * Returns a configuration object for the given file based on the CLI options.
120552 * This is the same logic used by the ESLint CLI executable to determine
120553 * configuration for each file it processes.
120554 * @param {string} filePath The path of the file to retrieve a config object for.
120555 * @throws {Error} If filepath a directory path.
120556 * @returns {ConfigData} A configuration object for the file.
120557 */
120558
120559
120560 getConfigForFile(filePath) {
120561 const {
120562 configArrayFactory,
120563 options
120564 } = internalSlotsMap.get(this);
120565 const absolutePath = path.resolve(options.cwd, filePath);
120566
120567 if (directoryExists(absolutePath)) {
120568 throw Object.assign(new Error("'filePath' should not be a directory path."), {
120569 messageTemplate: "print-config-with-directory-path"
120570 });
120571 }
120572
120573 return configArrayFactory.getConfigArrayForFile(absolutePath).extractConfig(absolutePath).toCompatibleObjectAsConfigFileContent();
120574 }
120575 /**
120576 * Checks if a given path is ignored by ESLint.
120577 * @param {string} filePath The path of the file to check.
120578 * @returns {boolean} Whether or not the given path is ignored.
120579 */
120580
120581
120582 isPathIgnored(filePath) {
120583 const {
120584 configArrayFactory,
120585 defaultIgnores,
120586 options: {
120587 cwd,
120588 ignore
120589 }
120590 } = internalSlotsMap.get(this);
120591 const absolutePath = path.resolve(cwd, filePath);
120592
120593 if (ignore) {
120594 const config = configArrayFactory.getConfigArrayForFile(absolutePath).extractConfig(absolutePath);
120595 const ignores = config.ignores || defaultIgnores;
120596 return ignores(absolutePath);
120597 }
120598
120599 return defaultIgnores(absolutePath);
120600 }
120601 /**
120602 * Returns the formatter representing the given format or null if the `format` is not a string.
120603 * @param {string} [format] The name of the format to load or the path to a
120604 * custom formatter.
120605 * @throws {any} As may be thrown by requiring of formatter
120606 * @returns {(Function|null)} The formatter function or null if the `format` is not a string.
120607 */
120608
120609
120610 getFormatter(format) {
120611 // default is stylish
120612 const resolvedFormatName = format || "stylish"; // only strings are valid formatters
120613
120614 if (typeof resolvedFormatName === "string") {
120615 // replace \ with / for Windows compatibility
120616 const normalizedFormatName = resolvedFormatName.replace(/\\/gu, "/");
120617 const slots = internalSlotsMap.get(this);
120618 const cwd = slots ? slots.options.cwd : process.cwd();
120619 const namespace = naming.getNamespaceFromTerm(normalizedFormatName);
120620 let formatterPath; // if there's a slash, then it's a file (TODO: this check seems dubious for scoped npm packages)
120621
120622 if (!namespace && normalizedFormatName.indexOf("/") > -1) {
120623 formatterPath = path.resolve(cwd, normalizedFormatName);
120624 } else {
120625 try {
120626 const npmFormat = naming.normalizePackageName(normalizedFormatName, "eslint-formatter");
120627 formatterPath = ModuleResolver.resolve(npmFormat, path.join(cwd, "__placeholder__.js"));
120628 } catch {
120629 formatterPath = path.resolve(__dirname, "formatters", normalizedFormatName);
120630 }
120631 }
120632
120633 try {
120634 return __webpack_require__(883)(formatterPath);
120635 } catch (ex) {
120636 if (format === "table" || format === "codeframe") {
120637 ex.message = "The ".concat(format, " formatter is no longer part of core ESLint. Install it manually with `npm install -D eslint-formatter-").concat(format, "`");
120638 } else {
120639 ex.message = "There was a problem loading formatter: ".concat(formatterPath, "\nError: ").concat(ex.message);
120640 }
120641
120642 throw ex;
120643 }
120644 } else {
120645 return null;
120646 }
120647 }
120648
120649 }
120650
120651 CLIEngine.version = pkg.version;
120652 CLIEngine.getFormatter = CLIEngine.prototype.getFormatter;
120653 module.exports = {
120654 CLIEngine,
120655
120656 /**
120657 * Get the internal slots of a given CLIEngine instance for tests.
120658 * @param {CLIEngine} instance The CLIEngine instance to get.
120659 * @returns {CLIEngineInternalSlots} The internal slots.
120660 */
120661 getCLIEngineInternalSlots(instance) {
120662 return internalSlotsMap.get(instance);
120663 }
120664
120665 };
120666
120667 /***/ }),
120668 /* 861 */
120669 /***/ ((module) => {
120670
120671 "use strict";
120672 module.exports = require("fs");
120673
120674 /***/ }),
120675 /* 862 */
120676 /***/ ((module) => {
120677
120678 "use strict";
120679 /**
120680 * @fileoverview Default CLIEngineOptions.
120681 * @author Ian VanSchooten
120682 */
120683
120684
120685 module.exports = {
120686 configFile: null,
120687 baseConfig: false,
120688 rulePaths: [],
120689 useEslintrc: true,
120690 envs: [],
120691 globals: [],
120692 extensions: null,
120693 ignore: true,
120694 ignorePath: void 0,
120695 cache: false,
120696
120697 /*
120698 * in order to honor the cacheFile option if specified
120699 * this option should not have a default value otherwise
120700 * it will always be used
120701 */
120702 cacheLocation: "",
120703 cacheFile: ".eslintcache",
120704 cacheStrategy: "metadata",
120705 fix: false,
120706 allowInlineConfig: true,
120707 reportUnusedDisableDirectives: void 0,
120708 globInputPaths: true
120709 };
120710
120711 /***/ }),
120712 /* 863 */
120713 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
120714
120715 "use strict";
120716 /* provided dependency */ var process = __webpack_require__(494);
120717
120718
120719 Object.defineProperty(exports, "__esModule", ({ value: true }));
120720
120721 var fs = __webpack_require__(861);
120722 var path = __webpack_require__(429);
120723 var importFresh = __webpack_require__(864);
120724 var stripComments = __webpack_require__(870);
120725 var util = __webpack_require__(439);
120726 var Ajv = __webpack_require__(446);
120727 var globals = __webpack_require__(492);
120728 var Module = __webpack_require__(866);
120729 var assert = __webpack_require__(431);
120730 var ignore = __webpack_require__(737);
120731 var debugOrig = __webpack_require__(496);
120732 var minimatch = __webpack_require__(871);
120733 var os = __webpack_require__(875);
120734 var url = __webpack_require__(876);
120735
120736 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
120737
120738 var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
120739 var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
120740 var importFresh__default = /*#__PURE__*/_interopDefaultLegacy(importFresh);
120741 var stripComments__default = /*#__PURE__*/_interopDefaultLegacy(stripComments);
120742 var util__default = /*#__PURE__*/_interopDefaultLegacy(util);
120743 var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);
120744 var globals__default = /*#__PURE__*/_interopDefaultLegacy(globals);
120745 var Module__default = /*#__PURE__*/_interopDefaultLegacy(Module);
120746 var assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
120747 var ignore__default = /*#__PURE__*/_interopDefaultLegacy(ignore);
120748 var debugOrig__default = /*#__PURE__*/_interopDefaultLegacy(debugOrig);
120749 var minimatch__default = /*#__PURE__*/_interopDefaultLegacy(minimatch);
120750 var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
120751
120752 /**
120753 * @fileoverview Config file operations. This file must be usable in the browser,
120754 * so no Node-specific code can be here.
120755 * @author Nicholas C. Zakas
120756 */
120757
120758 //------------------------------------------------------------------------------
120759 // Private
120760 //------------------------------------------------------------------------------
120761
120762 const RULE_SEVERITY_STRINGS = ["off", "warn", "error"],
120763 RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce((map, value, index) => {
120764 map[value] = index;
120765 return map;
120766 }, {}),
120767 VALID_SEVERITIES = [0, 1, 2, "off", "warn", "error"];
120768
120769 //------------------------------------------------------------------------------
120770 // Public Interface
120771 //------------------------------------------------------------------------------
120772
120773 /**
120774 * Normalizes the severity value of a rule's configuration to a number
120775 * @param {(number|string|[number, ...*]|[string, ...*])} ruleConfig A rule's configuration value, generally
120776 * received from the user. A valid config value is either 0, 1, 2, the string "off" (treated the same as 0),
120777 * the string "warn" (treated the same as 1), the string "error" (treated the same as 2), or an array
120778 * whose first element is one of the above values. Strings are matched case-insensitively.
120779 * @returns {(0|1|2)} The numeric severity value if the config value was valid, otherwise 0.
120780 */
120781 function getRuleSeverity(ruleConfig) {
120782 const severityValue = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
120783
120784 if (severityValue === 0 || severityValue === 1 || severityValue === 2) {
120785 return severityValue;
120786 }
120787
120788 if (typeof severityValue === "string") {
120789 return RULE_SEVERITY[severityValue.toLowerCase()] || 0;
120790 }
120791
120792 return 0;
120793 }
120794
120795 /**
120796 * Converts old-style severity settings (0, 1, 2) into new-style
120797 * severity settings (off, warn, error) for all rules. Assumption is that severity
120798 * values have already been validated as correct.
120799 * @param {Object} config The config object to normalize.
120800 * @returns {void}
120801 */
120802 function normalizeToStrings(config) {
120803
120804 if (config.rules) {
120805 Object.keys(config.rules).forEach(ruleId => {
120806 const ruleConfig = config.rules[ruleId];
120807
120808 if (typeof ruleConfig === "number") {
120809 config.rules[ruleId] = RULE_SEVERITY_STRINGS[ruleConfig] || RULE_SEVERITY_STRINGS[0];
120810 } else if (Array.isArray(ruleConfig) && typeof ruleConfig[0] === "number") {
120811 ruleConfig[0] = RULE_SEVERITY_STRINGS[ruleConfig[0]] || RULE_SEVERITY_STRINGS[0];
120812 }
120813 });
120814 }
120815 }
120816
120817 /**
120818 * Determines if the severity for the given rule configuration represents an error.
120819 * @param {int|string|Array} ruleConfig The configuration for an individual rule.
120820 * @returns {boolean} True if the rule represents an error, false if not.
120821 */
120822 function isErrorSeverity(ruleConfig) {
120823 return getRuleSeverity(ruleConfig) === 2;
120824 }
120825
120826 /**
120827 * Checks whether a given config has valid severity or not.
120828 * @param {number|string|Array} ruleConfig The configuration for an individual rule.
120829 * @returns {boolean} `true` if the configuration has valid severity.
120830 */
120831 function isValidSeverity(ruleConfig) {
120832 let severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
120833
120834 if (typeof severity === "string") {
120835 severity = severity.toLowerCase();
120836 }
120837 return VALID_SEVERITIES.indexOf(severity) !== -1;
120838 }
120839
120840 /**
120841 * Checks whether every rule of a given config has valid severity or not.
120842 * @param {Object} config The configuration for rules.
120843 * @returns {boolean} `true` if the configuration has valid severity.
120844 */
120845 function isEverySeverityValid(config) {
120846 return Object.keys(config).every(ruleId => isValidSeverity(config[ruleId]));
120847 }
120848
120849 /**
120850 * Normalizes a value for a global in a config
120851 * @param {(boolean|string|null)} configuredValue The value given for a global in configuration or in
120852 * a global directive comment
120853 * @returns {("readable"|"writeable"|"off")} The value normalized as a string
120854 * @throws Error if global value is invalid
120855 */
120856 function normalizeConfigGlobal(configuredValue) {
120857 switch (configuredValue) {
120858 case "off":
120859 return "off";
120860
120861 case true:
120862 case "true":
120863 case "writeable":
120864 case "writable":
120865 return "writable";
120866
120867 case null:
120868 case false:
120869 case "false":
120870 case "readable":
120871 case "readonly":
120872 return "readonly";
120873
120874 default:
120875 throw new Error(`'${configuredValue}' is not a valid configuration for a global (use 'readonly', 'writable', or 'off')`);
120876 }
120877 }
120878
120879 var ConfigOps = {
120880 __proto__: null,
120881 getRuleSeverity: getRuleSeverity,
120882 normalizeToStrings: normalizeToStrings,
120883 isErrorSeverity: isErrorSeverity,
120884 isValidSeverity: isValidSeverity,
120885 isEverySeverityValid: isEverySeverityValid,
120886 normalizeConfigGlobal: normalizeConfigGlobal
120887 };
120888
120889 /**
120890 * @fileoverview Provide the function that emits deprecation warnings.
120891 * @author Toru Nagashima <http://github.com/mysticatea>
120892 */
120893
120894 //------------------------------------------------------------------------------
120895 // Private
120896 //------------------------------------------------------------------------------
120897
120898 // Defitions for deprecation warnings.
120899 const deprecationWarningMessages = {
120900 ESLINT_LEGACY_ECMAFEATURES:
120901 "The 'ecmaFeatures' config file property is deprecated and has no effect.",
120902 ESLINT_PERSONAL_CONFIG_LOAD:
120903 "'~/.eslintrc.*' config files have been deprecated. " +
120904 "Please use a config file per project or the '--config' option.",
120905 ESLINT_PERSONAL_CONFIG_SUPPRESS:
120906 "'~/.eslintrc.*' config files have been deprecated. " +
120907 "Please remove it or add 'root:true' to the config files in your " +
120908 "projects in order to avoid loading '~/.eslintrc.*' accidentally."
120909 };
120910
120911 const sourceFileErrorCache = new Set();
120912
120913 /**
120914 * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted
120915 * for each unique file path, but repeated invocations with the same file path have no effect.
120916 * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active.
120917 * @param {string} source The name of the configuration source to report the warning for.
120918 * @param {string} errorCode The warning message to show.
120919 * @returns {void}
120920 */
120921 function emitDeprecationWarning(source, errorCode) {
120922 const cacheKey = JSON.stringify({ source, errorCode });
120923
120924 if (sourceFileErrorCache.has(cacheKey)) {
120925 return;
120926 }
120927 sourceFileErrorCache.add(cacheKey);
120928
120929 const rel = path__default["default"].relative(process.cwd(), source);
120930 const message = deprecationWarningMessages[errorCode];
120931
120932 process.emitWarning(
120933 `${message} (found in "${rel}")`,
120934 "DeprecationWarning",
120935 errorCode
120936 );
120937 }
120938
120939 /**
120940 * @fileoverview The instance of Ajv validator.
120941 * @author Evgeny Poberezkin
120942 */
120943
120944 //-----------------------------------------------------------------------------
120945 // Helpers
120946 //-----------------------------------------------------------------------------
120947
120948 /*
120949 * Copied from ajv/lib/refs/json-schema-draft-04.json
120950 * The MIT License (MIT)
120951 * Copyright (c) 2015-2017 Evgeny Poberezkin
120952 */
120953 const metaSchema = {
120954 id: "http://json-schema.org/draft-04/schema#",
120955 $schema: "http://json-schema.org/draft-04/schema#",
120956 description: "Core schema meta-schema",
120957 definitions: {
120958 schemaArray: {
120959 type: "array",
120960 minItems: 1,
120961 items: { $ref: "#" }
120962 },
120963 positiveInteger: {
120964 type: "integer",
120965 minimum: 0
120966 },
120967 positiveIntegerDefault0: {
120968 allOf: [{ $ref: "#/definitions/positiveInteger" }, { default: 0 }]
120969 },
120970 simpleTypes: {
120971 enum: ["array", "boolean", "integer", "null", "number", "object", "string"]
120972 },
120973 stringArray: {
120974 type: "array",
120975 items: { type: "string" },
120976 minItems: 1,
120977 uniqueItems: true
120978 }
120979 },
120980 type: "object",
120981 properties: {
120982 id: {
120983 type: "string"
120984 },
120985 $schema: {
120986 type: "string"
120987 },
120988 title: {
120989 type: "string"
120990 },
120991 description: {
120992 type: "string"
120993 },
120994 default: { },
120995 multipleOf: {
120996 type: "number",
120997 minimum: 0,
120998 exclusiveMinimum: true
120999 },
121000 maximum: {
121001 type: "number"
121002 },
121003 exclusiveMaximum: {
121004 type: "boolean",
121005 default: false
121006 },
121007 minimum: {
121008 type: "number"
121009 },
121010 exclusiveMinimum: {
121011 type: "boolean",
121012 default: false
121013 },
121014 maxLength: { $ref: "#/definitions/positiveInteger" },
121015 minLength: { $ref: "#/definitions/positiveIntegerDefault0" },
121016 pattern: {
121017 type: "string",
121018 format: "regex"
121019 },
121020 additionalItems: {
121021 anyOf: [
121022 { type: "boolean" },
121023 { $ref: "#" }
121024 ],
121025 default: { }
121026 },
121027 items: {
121028 anyOf: [
121029 { $ref: "#" },
121030 { $ref: "#/definitions/schemaArray" }
121031 ],
121032 default: { }
121033 },
121034 maxItems: { $ref: "#/definitions/positiveInteger" },
121035 minItems: { $ref: "#/definitions/positiveIntegerDefault0" },
121036 uniqueItems: {
121037 type: "boolean",
121038 default: false
121039 },
121040 maxProperties: { $ref: "#/definitions/positiveInteger" },
121041 minProperties: { $ref: "#/definitions/positiveIntegerDefault0" },
121042 required: { $ref: "#/definitions/stringArray" },
121043 additionalProperties: {
121044 anyOf: [
121045 { type: "boolean" },
121046 { $ref: "#" }
121047 ],
121048 default: { }
121049 },
121050 definitions: {
121051 type: "object",
121052 additionalProperties: { $ref: "#" },
121053 default: { }
121054 },
121055 properties: {
121056 type: "object",
121057 additionalProperties: { $ref: "#" },
121058 default: { }
121059 },
121060 patternProperties: {
121061 type: "object",
121062 additionalProperties: { $ref: "#" },
121063 default: { }
121064 },
121065 dependencies: {
121066 type: "object",
121067 additionalProperties: {
121068 anyOf: [
121069 { $ref: "#" },
121070 { $ref: "#/definitions/stringArray" }
121071 ]
121072 }
121073 },
121074 enum: {
121075 type: "array",
121076 minItems: 1,
121077 uniqueItems: true
121078 },
121079 type: {
121080 anyOf: [
121081 { $ref: "#/definitions/simpleTypes" },
121082 {
121083 type: "array",
121084 items: { $ref: "#/definitions/simpleTypes" },
121085 minItems: 1,
121086 uniqueItems: true
121087 }
121088 ]
121089 },
121090 format: { type: "string" },
121091 allOf: { $ref: "#/definitions/schemaArray" },
121092 anyOf: { $ref: "#/definitions/schemaArray" },
121093 oneOf: { $ref: "#/definitions/schemaArray" },
121094 not: { $ref: "#" }
121095 },
121096 dependencies: {
121097 exclusiveMaximum: ["maximum"],
121098 exclusiveMinimum: ["minimum"]
121099 },
121100 default: { }
121101 };
121102
121103 //------------------------------------------------------------------------------
121104 // Public Interface
121105 //------------------------------------------------------------------------------
121106
121107 var ajvOrig = (additionalOptions = {}) => {
121108 const ajv = new Ajv__default["default"]({
121109 meta: false,
121110 useDefaults: true,
121111 validateSchema: false,
121112 missingRefs: "ignore",
121113 verbose: true,
121114 schemaId: "auto",
121115 ...additionalOptions
121116 });
121117
121118 ajv.addMetaSchema(metaSchema);
121119 // eslint-disable-next-line no-underscore-dangle
121120 ajv._opts.defaultMeta = metaSchema.id;
121121
121122 return ajv;
121123 };
121124
121125 /**
121126 * @fileoverview Defines a schema for configs.
121127 * @author Sylvan Mably
121128 */
121129
121130 const baseConfigProperties = {
121131 $schema: { type: "string" },
121132 env: { type: "object" },
121133 extends: { $ref: "#/definitions/stringOrStrings" },
121134 globals: { type: "object" },
121135 overrides: {
121136 type: "array",
121137 items: { $ref: "#/definitions/overrideConfig" },
121138 additionalItems: false
121139 },
121140 parser: { type: ["string", "null"] },
121141 parserOptions: { type: "object" },
121142 plugins: { type: "array" },
121143 processor: { type: "string" },
121144 rules: { type: "object" },
121145 settings: { type: "object" },
121146 noInlineConfig: { type: "boolean" },
121147 reportUnusedDisableDirectives: { type: "boolean" },
121148
121149 ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
121150 };
121151
121152 const configSchema = {
121153 definitions: {
121154 stringOrStrings: {
121155 oneOf: [
121156 { type: "string" },
121157 {
121158 type: "array",
121159 items: { type: "string" },
121160 additionalItems: false
121161 }
121162 ]
121163 },
121164 stringOrStringsRequired: {
121165 oneOf: [
121166 { type: "string" },
121167 {
121168 type: "array",
121169 items: { type: "string" },
121170 additionalItems: false,
121171 minItems: 1
121172 }
121173 ]
121174 },
121175
121176 // Config at top-level.
121177 objectConfig: {
121178 type: "object",
121179 properties: {
121180 root: { type: "boolean" },
121181 ignorePatterns: { $ref: "#/definitions/stringOrStrings" },
121182 ...baseConfigProperties
121183 },
121184 additionalProperties: false
121185 },
121186
121187 // Config in `overrides`.
121188 overrideConfig: {
121189 type: "object",
121190 properties: {
121191 excludedFiles: { $ref: "#/definitions/stringOrStrings" },
121192 files: { $ref: "#/definitions/stringOrStringsRequired" },
121193 ...baseConfigProperties
121194 },
121195 required: ["files"],
121196 additionalProperties: false
121197 }
121198 },
121199
121200 $ref: "#/definitions/objectConfig"
121201 };
121202
121203 /**
121204 * @fileoverview Defines environment settings and globals.
121205 * @author Elan Shanker
121206 */
121207
121208 //------------------------------------------------------------------------------
121209 // Helpers
121210 //------------------------------------------------------------------------------
121211
121212 /**
121213 * Get the object that has difference.
121214 * @param {Record<string,boolean>} current The newer object.
121215 * @param {Record<string,boolean>} prev The older object.
121216 * @returns {Record<string,boolean>} The difference object.
121217 */
121218 function getDiff(current, prev) {
121219 const retv = {};
121220
121221 for (const [key, value] of Object.entries(current)) {
121222 if (!Object.hasOwnProperty.call(prev, key)) {
121223 retv[key] = value;
121224 }
121225 }
121226
121227 return retv;
121228 }
121229
121230 const newGlobals2015 = getDiff(globals__default["default"].es2015, globals__default["default"].es5); // 19 variables such as Promise, Map, ...
121231 const newGlobals2017 = {
121232 Atomics: false,
121233 SharedArrayBuffer: false
121234 };
121235 const newGlobals2020 = {
121236 BigInt: false,
121237 BigInt64Array: false,
121238 BigUint64Array: false,
121239 globalThis: false
121240 };
121241
121242 const newGlobals2021 = {
121243 AggregateError: false,
121244 FinalizationRegistry: false,
121245 WeakRef: false
121246 };
121247
121248 //------------------------------------------------------------------------------
121249 // Public Interface
121250 //------------------------------------------------------------------------------
121251
121252 /** @type {Map<string, import("../lib/shared/types").Environment>} */
121253 var environments = new Map(Object.entries({
121254
121255 // Language
121256 builtin: {
121257 globals: globals__default["default"].es5
121258 },
121259 es6: {
121260 globals: newGlobals2015,
121261 parserOptions: {
121262 ecmaVersion: 6
121263 }
121264 },
121265 es2015: {
121266 globals: newGlobals2015,
121267 parserOptions: {
121268 ecmaVersion: 6
121269 }
121270 },
121271 es2017: {
121272 globals: { ...newGlobals2015, ...newGlobals2017 },
121273 parserOptions: {
121274 ecmaVersion: 8
121275 }
121276 },
121277 es2020: {
121278 globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020 },
121279 parserOptions: {
121280 ecmaVersion: 11
121281 }
121282 },
121283 es2021: {
121284 globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020, ...newGlobals2021 },
121285 parserOptions: {
121286 ecmaVersion: 12
121287 }
121288 },
121289
121290 // Platforms
121291 browser: {
121292 globals: globals__default["default"].browser
121293 },
121294 node: {
121295 globals: globals__default["default"].node,
121296 parserOptions: {
121297 ecmaFeatures: {
121298 globalReturn: true
121299 }
121300 }
121301 },
121302 "shared-node-browser": {
121303 globals: globals__default["default"]["shared-node-browser"]
121304 },
121305 worker: {
121306 globals: globals__default["default"].worker
121307 },
121308 serviceworker: {
121309 globals: globals__default["default"].serviceworker
121310 },
121311
121312 // Frameworks
121313 commonjs: {
121314 globals: globals__default["default"].commonjs,
121315 parserOptions: {
121316 ecmaFeatures: {
121317 globalReturn: true
121318 }
121319 }
121320 },
121321 amd: {
121322 globals: globals__default["default"].amd
121323 },
121324 mocha: {
121325 globals: globals__default["default"].mocha
121326 },
121327 jasmine: {
121328 globals: globals__default["default"].jasmine
121329 },
121330 jest: {
121331 globals: globals__default["default"].jest
121332 },
121333 phantomjs: {
121334 globals: globals__default["default"].phantomjs
121335 },
121336 jquery: {
121337 globals: globals__default["default"].jquery
121338 },
121339 qunit: {
121340 globals: globals__default["default"].qunit
121341 },
121342 prototypejs: {
121343 globals: globals__default["default"].prototypejs
121344 },
121345 shelljs: {
121346 globals: globals__default["default"].shelljs
121347 },
121348 meteor: {
121349 globals: globals__default["default"].meteor
121350 },
121351 mongo: {
121352 globals: globals__default["default"].mongo
121353 },
121354 protractor: {
121355 globals: globals__default["default"].protractor
121356 },
121357 applescript: {
121358 globals: globals__default["default"].applescript
121359 },
121360 nashorn: {
121361 globals: globals__default["default"].nashorn
121362 },
121363 atomtest: {
121364 globals: globals__default["default"].atomtest
121365 },
121366 embertest: {
121367 globals: globals__default["default"].embertest
121368 },
121369 webextensions: {
121370 globals: globals__default["default"].webextensions
121371 },
121372 greasemonkey: {
121373 globals: globals__default["default"].greasemonkey
121374 }
121375 }));
121376
121377 /**
121378 * @fileoverview Validates configs.
121379 * @author Brandon Mills
121380 */
121381
121382 const ajv = ajvOrig();
121383
121384 const ruleValidators = new WeakMap();
121385 const noop = Function.prototype;
121386
121387 //------------------------------------------------------------------------------
121388 // Private
121389 //------------------------------------------------------------------------------
121390 let validateSchema;
121391 const severityMap = {
121392 error: 2,
121393 warn: 1,
121394 off: 0
121395 };
121396
121397 const validated = new WeakSet();
121398
121399 //-----------------------------------------------------------------------------
121400 // Exports
121401 //-----------------------------------------------------------------------------
121402
121403 class ConfigValidator {
121404 constructor({ builtInRules = new Map() } = {}) {
121405 this.builtInRules = builtInRules;
121406 }
121407
121408 /**
121409 * Gets a complete options schema for a rule.
121410 * @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
121411 * @returns {Object} JSON Schema for the rule's options.
121412 */
121413 getRuleOptionsSchema(rule) {
121414 if (!rule) {
121415 return null;
121416 }
121417
121418 const schema = rule.schema || rule.meta && rule.meta.schema;
121419
121420 // Given a tuple of schemas, insert warning level at the beginning
121421 if (Array.isArray(schema)) {
121422 if (schema.length) {
121423 return {
121424 type: "array",
121425 items: schema,
121426 minItems: 0,
121427 maxItems: schema.length
121428 };
121429 }
121430 return {
121431 type: "array",
121432 minItems: 0,
121433 maxItems: 0
121434 };
121435
121436 }
121437
121438 // Given a full schema, leave it alone
121439 return schema || null;
121440 }
121441
121442 /**
121443 * Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
121444 * @param {options} options The given options for the rule.
121445 * @returns {number|string} The rule's severity value
121446 */
121447 validateRuleSeverity(options) {
121448 const severity = Array.isArray(options) ? options[0] : options;
121449 const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity;
121450
121451 if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) {
121452 return normSeverity;
121453 }
121454
121455 throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util__default["default"].inspect(severity).replace(/'/gu, "\"").replace(/\n/gu, "")}').\n`);
121456
121457 }
121458
121459 /**
121460 * Validates the non-severity options passed to a rule, based on its schema.
121461 * @param {{create: Function}} rule The rule to validate
121462 * @param {Array} localOptions The options for the rule, excluding severity
121463 * @returns {void}
121464 */
121465 validateRuleSchema(rule, localOptions) {
121466 if (!ruleValidators.has(rule)) {
121467 const schema = this.getRuleOptionsSchema(rule);
121468
121469 if (schema) {
121470 ruleValidators.set(rule, ajv.compile(schema));
121471 }
121472 }
121473
121474 const validateRule = ruleValidators.get(rule);
121475
121476 if (validateRule) {
121477 validateRule(localOptions);
121478 if (validateRule.errors) {
121479 throw new Error(validateRule.errors.map(
121480 error => `\tValue ${JSON.stringify(error.data)} ${error.message}.\n`
121481 ).join(""));
121482 }
121483 }
121484 }
121485
121486 /**
121487 * Validates a rule's options against its schema.
121488 * @param {{create: Function}|null} rule The rule that the config is being validated for
121489 * @param {string} ruleId The rule's unique name.
121490 * @param {Array|number} options The given options for the rule.
121491 * @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
121492 * no source is prepended to the message.
121493 * @returns {void}
121494 */
121495 validateRuleOptions(rule, ruleId, options, source = null) {
121496 try {
121497 const severity = this.validateRuleSeverity(options);
121498
121499 if (severity !== 0) {
121500 this.validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
121501 }
121502 } catch (err) {
121503 const enhancedMessage = `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
121504
121505 if (typeof source === "string") {
121506 throw new Error(`${source}:\n\t${enhancedMessage}`);
121507 } else {
121508 throw new Error(enhancedMessage);
121509 }
121510 }
121511 }
121512
121513 /**
121514 * Validates an environment object
121515 * @param {Object} environment The environment config object to validate.
121516 * @param {string} source The name of the configuration source to report in any errors.
121517 * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments.
121518 * @returns {void}
121519 */
121520 validateEnvironment(
121521 environment,
121522 source,
121523 getAdditionalEnv = noop
121524 ) {
121525
121526 // not having an environment is ok
121527 if (!environment) {
121528 return;
121529 }
121530
121531 Object.keys(environment).forEach(id => {
121532 const env = getAdditionalEnv(id) || environments.get(id) || null;
121533
121534 if (!env) {
121535 const message = `${source}:\n\tEnvironment key "${id}" is unknown\n`;
121536
121537 throw new Error(message);
121538 }
121539 });
121540 }
121541
121542 /**
121543 * Validates a rules config object
121544 * @param {Object} rulesConfig The rules config object to validate.
121545 * @param {string} source The name of the configuration source to report in any errors.
121546 * @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules
121547 * @returns {void}
121548 */
121549 validateRules(
121550 rulesConfig,
121551 source,
121552 getAdditionalRule = noop
121553 ) {
121554 if (!rulesConfig) {
121555 return;
121556 }
121557
121558 Object.keys(rulesConfig).forEach(id => {
121559 const rule = getAdditionalRule(id) || this.builtInRules.get(id) || null;
121560
121561 this.validateRuleOptions(rule, id, rulesConfig[id], source);
121562 });
121563 }
121564
121565 /**
121566 * Validates a `globals` section of a config file
121567 * @param {Object} globalsConfig The `globals` section
121568 * @param {string|null} source The name of the configuration source to report in the event of an error.
121569 * @returns {void}
121570 */
121571 validateGlobals(globalsConfig, source = null) {
121572 if (!globalsConfig) {
121573 return;
121574 }
121575
121576 Object.entries(globalsConfig)
121577 .forEach(([configuredGlobal, configuredValue]) => {
121578 try {
121579 normalizeConfigGlobal(configuredValue);
121580 } catch (err) {
121581 throw new Error(`ESLint configuration of global '${configuredGlobal}' in ${source} is invalid:\n${err.message}`);
121582 }
121583 });
121584 }
121585
121586 /**
121587 * Validate `processor` configuration.
121588 * @param {string|undefined} processorName The processor name.
121589 * @param {string} source The name of config file.
121590 * @param {function(id:string): Processor} getProcessor The getter of defined processors.
121591 * @returns {void}
121592 */
121593 validateProcessor(processorName, source, getProcessor) {
121594 if (processorName && !getProcessor(processorName)) {
121595 throw new Error(`ESLint configuration of processor in '${source}' is invalid: '${processorName}' was not found.`);
121596 }
121597 }
121598
121599 /**
121600 * Formats an array of schema validation errors.
121601 * @param {Array} errors An array of error messages to format.
121602 * @returns {string} Formatted error message
121603 */
121604 formatErrors(errors) {
121605 return errors.map(error => {
121606 if (error.keyword === "additionalProperties") {
121607 const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty;
121608
121609 return `Unexpected top-level property "${formattedPropertyPath}"`;
121610 }
121611 if (error.keyword === "type") {
121612 const formattedField = error.dataPath.slice(1);
121613 const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema;
121614 const formattedValue = JSON.stringify(error.data);
121615
121616 return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`;
121617 }
121618
121619 const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath;
121620
121621 return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`;
121622 }).map(message => `\t- ${message}.\n`).join("");
121623 }
121624
121625 /**
121626 * Validates the top level properties of the config object.
121627 * @param {Object} config The config object to validate.
121628 * @param {string} source The name of the configuration source to report in any errors.
121629 * @returns {void}
121630 */
121631 validateConfigSchema(config, source = null) {
121632 validateSchema = validateSchema || ajv.compile(configSchema);
121633
121634 if (!validateSchema(config)) {
121635 throw new Error(`ESLint configuration in ${source} is invalid:\n${this.formatErrors(validateSchema.errors)}`);
121636 }
121637
121638 if (Object.hasOwnProperty.call(config, "ecmaFeatures")) {
121639 emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES");
121640 }
121641 }
121642
121643 /**
121644 * Validates an entire config object.
121645 * @param {Object} config The config object to validate.
121646 * @param {string} source The name of the configuration source to report in any errors.
121647 * @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules.
121648 * @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs.
121649 * @returns {void}
121650 */
121651 validate(config, source, getAdditionalRule, getAdditionalEnv) {
121652 this.validateConfigSchema(config, source);
121653 this.validateRules(config.rules, source, getAdditionalRule);
121654 this.validateEnvironment(config.env, source, getAdditionalEnv);
121655 this.validateGlobals(config.globals, source);
121656
121657 for (const override of config.overrides || []) {
121658 this.validateRules(override.rules, source, getAdditionalRule);
121659 this.validateEnvironment(override.env, source, getAdditionalEnv);
121660 this.validateGlobals(config.globals, source);
121661 }
121662 }
121663
121664 /**
121665 * Validate config array object.
121666 * @param {ConfigArray} configArray The config array to validate.
121667 * @returns {void}
121668 */
121669 validateConfigArray(configArray) {
121670 const getPluginEnv = Map.prototype.get.bind(configArray.pluginEnvironments);
121671 const getPluginProcessor = Map.prototype.get.bind(configArray.pluginProcessors);
121672 const getPluginRule = Map.prototype.get.bind(configArray.pluginRules);
121673
121674 // Validate.
121675 for (const element of configArray) {
121676 if (validated.has(element)) {
121677 continue;
121678 }
121679 validated.add(element);
121680
121681 this.validateEnvironment(element.env, element.name, getPluginEnv);
121682 this.validateGlobals(element.globals, element.name);
121683 this.validateProcessor(element.processor, element.name, getPluginProcessor);
121684 this.validateRules(element.rules, element.name, getPluginRule);
121685 }
121686 }
121687
121688 }
121689
121690 /**
121691 * @fileoverview Common helpers for naming of plugins, formatters and configs
121692 */
121693
121694 const NAMESPACE_REGEX = /^@.*\//iu;
121695
121696 /**
121697 * Brings package name to correct format based on prefix
121698 * @param {string} name The name of the package.
121699 * @param {string} prefix Can be either "eslint-plugin", "eslint-config" or "eslint-formatter"
121700 * @returns {string} Normalized name of the package
121701 * @private
121702 */
121703 function normalizePackageName(name, prefix) {
121704 let normalizedName = name;
121705
121706 /**
121707 * On Windows, name can come in with Windows slashes instead of Unix slashes.
121708 * Normalize to Unix first to avoid errors later on.
121709 * https://github.com/eslint/eslint/issues/5644
121710 */
121711 if (normalizedName.includes("\\")) {
121712 normalizedName = normalizedName.replace(/\\/gu, "/");
121713 }
121714
121715 if (normalizedName.charAt(0) === "@") {
121716
121717 /**
121718 * it's a scoped package
121719 * package name is the prefix, or just a username
121720 */
121721 const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, "u"),
121722 scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`, "u");
121723
121724 if (scopedPackageShortcutRegex.test(normalizedName)) {
121725 normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`);
121726 } else if (!scopedPackageNameRegex.test(normalizedName.split("/")[1])) {
121727
121728 /**
121729 * for scoped packages, insert the prefix after the first / unless
121730 * the path is already @scope/eslint or @scope/eslint-xxx-yyy
121731 */
121732 normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, `@$1/${prefix}-$2`);
121733 }
121734 } else if (!normalizedName.startsWith(`${prefix}-`)) {
121735 normalizedName = `${prefix}-${normalizedName}`;
121736 }
121737
121738 return normalizedName;
121739 }
121740
121741 /**
121742 * Removes the prefix from a fullname.
121743 * @param {string} fullname The term which may have the prefix.
121744 * @param {string} prefix The prefix to remove.
121745 * @returns {string} The term without prefix.
121746 */
121747 function getShorthandName(fullname, prefix) {
121748 if (fullname[0] === "@") {
121749 let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, "u").exec(fullname);
121750
121751 if (matchResult) {
121752 return matchResult[1];
121753 }
121754
121755 matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`, "u").exec(fullname);
121756 if (matchResult) {
121757 return `${matchResult[1]}/${matchResult[2]}`;
121758 }
121759 } else if (fullname.startsWith(`${prefix}-`)) {
121760 return fullname.slice(prefix.length + 1);
121761 }
121762
121763 return fullname;
121764 }
121765
121766 /**
121767 * Gets the scope (namespace) of a term.
121768 * @param {string} term The term which may have the namespace.
121769 * @returns {string} The namespace of the term if it has one.
121770 */
121771 function getNamespaceFromTerm(term) {
121772 const match = term.match(NAMESPACE_REGEX);
121773
121774 return match ? match[0] : "";
121775 }
121776
121777 var naming = {
121778 __proto__: null,
121779 normalizePackageName: normalizePackageName,
121780 getShorthandName: getShorthandName,
121781 getNamespaceFromTerm: getNamespaceFromTerm
121782 };
121783
121784 /**
121785 * Utility for resolving a module relative to another module
121786 * @author Teddy Katz
121787 */
121788
121789 /*
121790 * `Module.createRequire` is added in v12.2.0. It supports URL as well.
121791 * We only support the case where the argument is a filepath, not a URL.
121792 */
121793 const createRequire = Module__default["default"].createRequire;
121794
121795 /**
121796 * Resolves a Node module relative to another module
121797 * @param {string} moduleName The name of a Node module, or a path to a Node module.
121798 * @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be
121799 * a file rather than a directory, but the file need not actually exist.
121800 * @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath`
121801 */
121802 function resolve(moduleName, relativeToPath) {
121803 try {
121804 return createRequire(relativeToPath).resolve(moduleName);
121805 } catch (error) {
121806
121807 // This `if` block is for older Node.js than 12.0.0. We can remove this block in the future.
121808 if (
121809 typeof error === "object" &&
121810 error !== null &&
121811 error.code === "MODULE_NOT_FOUND" &&
121812 !error.requireStack &&
121813 error.message.includes(moduleName)
121814 ) {
121815 error.message += `\nRequire stack:\n- ${relativeToPath}`;
121816 }
121817 throw error;
121818 }
121819 }
121820
121821 var ModuleResolver = {
121822 __proto__: null,
121823 resolve: resolve
121824 };
121825
121826 /**
121827 * @fileoverview `IgnorePattern` class.
121828 *
121829 * `IgnorePattern` class has the set of glob patterns and the base path.
121830 *
121831 * It provides two static methods.
121832 *
121833 * - `IgnorePattern.createDefaultIgnore(cwd)`
121834 * Create the default predicate function.
121835 * - `IgnorePattern.createIgnore(ignorePatterns)`
121836 * Create the predicate function from multiple `IgnorePattern` objects.
121837 *
121838 * It provides two properties and a method.
121839 *
121840 * - `patterns`
121841 * The glob patterns that ignore to lint.
121842 * - `basePath`
121843 * The base path of the glob patterns. If absolute paths existed in the
121844 * glob patterns, those are handled as relative paths to the base path.
121845 * - `getPatternsRelativeTo(basePath)`
121846 * Get `patterns` as modified for a given base path. It modifies the
121847 * absolute paths in the patterns as prepending the difference of two base
121848 * paths.
121849 *
121850 * `ConfigArrayFactory` creates `IgnorePattern` objects when it processes
121851 * `ignorePatterns` properties.
121852 *
121853 * @author Toru Nagashima <https://github.com/mysticatea>
121854 */
121855
121856 const debug$3 = debugOrig__default["default"]("eslintrc:ignore-pattern");
121857
121858 /** @typedef {ReturnType<import("ignore").default>} Ignore */
121859
121860 //------------------------------------------------------------------------------
121861 // Helpers
121862 //------------------------------------------------------------------------------
121863
121864 /**
121865 * Get the path to the common ancestor directory of given paths.
121866 * @param {string[]} sourcePaths The paths to calculate the common ancestor.
121867 * @returns {string} The path to the common ancestor directory.
121868 */
121869 function getCommonAncestorPath(sourcePaths) {
121870 let result = sourcePaths[0];
121871
121872 for (let i = 1; i < sourcePaths.length; ++i) {
121873 const a = result;
121874 const b = sourcePaths[i];
121875
121876 // Set the shorter one (it's the common ancestor if one includes the other).
121877 result = a.length < b.length ? a : b;
121878
121879 // Set the common ancestor.
121880 for (let j = 0, lastSepPos = 0; j < a.length && j < b.length; ++j) {
121881 if (a[j] !== b[j]) {
121882 result = a.slice(0, lastSepPos);
121883 break;
121884 }
121885 if (a[j] === path__default["default"].sep) {
121886 lastSepPos = j;
121887 }
121888 }
121889 }
121890
121891 let resolvedResult = result || path__default["default"].sep;
121892
121893 // if Windows common ancestor is root of drive must have trailing slash to be absolute.
121894 if (resolvedResult && resolvedResult.endsWith(":") && process.platform === "win32") {
121895 resolvedResult += path__default["default"].sep;
121896 }
121897 return resolvedResult;
121898 }
121899
121900 /**
121901 * Make relative path.
121902 * @param {string} from The source path to get relative path.
121903 * @param {string} to The destination path to get relative path.
121904 * @returns {string} The relative path.
121905 */
121906 function relative(from, to) {
121907 const relPath = path__default["default"].relative(from, to);
121908
121909 if (path__default["default"].sep === "/") {
121910 return relPath;
121911 }
121912 return relPath.split(path__default["default"].sep).join("/");
121913 }
121914
121915 /**
121916 * Get the trailing slash if existed.
121917 * @param {string} filePath The path to check.
121918 * @returns {string} The trailing slash if existed.
121919 */
121920 function dirSuffix(filePath) {
121921 const isDir = (
121922 filePath.endsWith(path__default["default"].sep) ||
121923 (process.platform === "win32" && filePath.endsWith("/"))
121924 );
121925
121926 return isDir ? "/" : "";
121927 }
121928
121929 const DefaultPatterns = Object.freeze(["/**/node_modules/*"]);
121930 const DotPatterns = Object.freeze([".*", "!.eslintrc.*", "!../"]);
121931
121932 //------------------------------------------------------------------------------
121933 // Public
121934 //------------------------------------------------------------------------------
121935
121936 class IgnorePattern {
121937
121938 /**
121939 * The default patterns.
121940 * @type {string[]}
121941 */
121942 static get DefaultPatterns() {
121943 return DefaultPatterns;
121944 }
121945
121946 /**
121947 * Create the default predicate function.
121948 * @param {string} cwd The current working directory.
121949 * @returns {((filePath:string, dot:boolean) => boolean) & {basePath:string; patterns:string[]}}
121950 * The preficate function.
121951 * The first argument is an absolute path that is checked.
121952 * The second argument is the flag to not ignore dotfiles.
121953 * If the predicate function returned `true`, it means the path should be ignored.
121954 */
121955 static createDefaultIgnore(cwd) {
121956 return this.createIgnore([new IgnorePattern(DefaultPatterns, cwd)]);
121957 }
121958
121959 /**
121960 * Create the predicate function from multiple `IgnorePattern` objects.
121961 * @param {IgnorePattern[]} ignorePatterns The list of ignore patterns.
121962 * @returns {((filePath:string, dot?:boolean) => boolean) & {basePath:string; patterns:string[]}}
121963 * The preficate function.
121964 * The first argument is an absolute path that is checked.
121965 * The second argument is the flag to not ignore dotfiles.
121966 * If the predicate function returned `true`, it means the path should be ignored.
121967 */
121968 static createIgnore(ignorePatterns) {
121969 debug$3("Create with: %o", ignorePatterns);
121970
121971 const basePath = getCommonAncestorPath(ignorePatterns.map(p => p.basePath));
121972 const patterns = [].concat(
121973 ...ignorePatterns.map(p => p.getPatternsRelativeTo(basePath))
121974 );
121975 const ig = ignore__default["default"]().add([...DotPatterns, ...patterns]);
121976 const dotIg = ignore__default["default"]().add(patterns);
121977
121978 debug$3(" processed: %o", { basePath, patterns });
121979
121980 return Object.assign(
121981 (filePath, dot = false) => {
121982 assert__default["default"](path__default["default"].isAbsolute(filePath), "'filePath' should be an absolute path.");
121983 const relPathRaw = relative(basePath, filePath);
121984 const relPath = relPathRaw && (relPathRaw + dirSuffix(filePath));
121985 const adoptedIg = dot ? dotIg : ig;
121986 const result = relPath !== "" && adoptedIg.ignores(relPath);
121987
121988 debug$3("Check", { filePath, dot, relativePath: relPath, result });
121989 return result;
121990 },
121991 { basePath, patterns }
121992 );
121993 }
121994
121995 /**
121996 * Initialize a new `IgnorePattern` instance.
121997 * @param {string[]} patterns The glob patterns that ignore to lint.
121998 * @param {string} basePath The base path of `patterns`.
121999 */
122000 constructor(patterns, basePath) {
122001 assert__default["default"](path__default["default"].isAbsolute(basePath), "'basePath' should be an absolute path.");
122002
122003 /**
122004 * The glob patterns that ignore to lint.
122005 * @type {string[]}
122006 */
122007 this.patterns = patterns;
122008
122009 /**
122010 * The base path of `patterns`.
122011 * @type {string}
122012 */
122013 this.basePath = basePath;
122014
122015 /**
122016 * If `true` then patterns which don't start with `/` will match the paths to the outside of `basePath`. Defaults to `false`.
122017 *
122018 * It's set `true` for `.eslintignore`, `package.json`, and `--ignore-path` for backward compatibility.
122019 * It's `false` as-is for `ignorePatterns` property in config files.
122020 * @type {boolean}
122021 */
122022 this.loose = false;
122023 }
122024
122025 /**
122026 * Get `patterns` as modified for a given base path. It modifies the
122027 * absolute paths in the patterns as prepending the difference of two base
122028 * paths.
122029 * @param {string} newBasePath The base path.
122030 * @returns {string[]} Modifired patterns.
122031 */
122032 getPatternsRelativeTo(newBasePath) {
122033 assert__default["default"](path__default["default"].isAbsolute(newBasePath), "'newBasePath' should be an absolute path.");
122034 const { basePath, loose, patterns } = this;
122035
122036 if (newBasePath === basePath) {
122037 return patterns;
122038 }
122039 const prefix = `/${relative(newBasePath, basePath)}`;
122040
122041 return patterns.map(pattern => {
122042 const negative = pattern.startsWith("!");
122043 const head = negative ? "!" : "";
122044 const body = negative ? pattern.slice(1) : pattern;
122045
122046 if (body.startsWith("/") || body.startsWith("../")) {
122047 return `${head}${prefix}${body}`;
122048 }
122049 return loose ? pattern : `${head}${prefix}/**/${body}`;
122050 });
122051 }
122052 }
122053
122054 /**
122055 * @fileoverview `ExtractedConfig` class.
122056 *
122057 * `ExtractedConfig` class expresses a final configuration for a specific file.
122058 *
122059 * It provides one method.
122060 *
122061 * - `toCompatibleObjectAsConfigFileContent()`
122062 * Convert this configuration to the compatible object as the content of
122063 * config files. It converts the loaded parser and plugins to strings.
122064 * `CLIEngine#getConfigForFile(filePath)` method uses this method.
122065 *
122066 * `ConfigArray#extractConfig(filePath)` creates a `ExtractedConfig` instance.
122067 *
122068 * @author Toru Nagashima <https://github.com/mysticatea>
122069 */
122070
122071 // For VSCode intellisense
122072 /** @typedef {import("../../shared/types").ConfigData} ConfigData */
122073 /** @typedef {import("../../shared/types").GlobalConf} GlobalConf */
122074 /** @typedef {import("../../shared/types").SeverityConf} SeverityConf */
122075 /** @typedef {import("./config-dependency").DependentParser} DependentParser */
122076 /** @typedef {import("./config-dependency").DependentPlugin} DependentPlugin */
122077
122078 /**
122079 * Check if `xs` starts with `ys`.
122080 * @template T
122081 * @param {T[]} xs The array to check.
122082 * @param {T[]} ys The array that may be the first part of `xs`.
122083 * @returns {boolean} `true` if `xs` starts with `ys`.
122084 */
122085 function startsWith(xs, ys) {
122086 return xs.length >= ys.length && ys.every((y, i) => y === xs[i]);
122087 }
122088
122089 /**
122090 * The class for extracted config data.
122091 */
122092 class ExtractedConfig {
122093 constructor() {
122094
122095 /**
122096 * The config name what `noInlineConfig` setting came from.
122097 * @type {string}
122098 */
122099 this.configNameOfNoInlineConfig = "";
122100
122101 /**
122102 * Environments.
122103 * @type {Record<string, boolean>}
122104 */
122105 this.env = {};
122106
122107 /**
122108 * Global variables.
122109 * @type {Record<string, GlobalConf>}
122110 */
122111 this.globals = {};
122112
122113 /**
122114 * The glob patterns that ignore to lint.
122115 * @type {(((filePath:string, dot?:boolean) => boolean) & { basePath:string; patterns:string[] }) | undefined}
122116 */
122117 this.ignores = void 0;
122118
122119 /**
122120 * The flag that disables directive comments.
122121 * @type {boolean|undefined}
122122 */
122123 this.noInlineConfig = void 0;
122124
122125 /**
122126 * Parser definition.
122127 * @type {DependentParser|null}
122128 */
122129 this.parser = null;
122130
122131 /**
122132 * Options for the parser.
122133 * @type {Object}
122134 */
122135 this.parserOptions = {};
122136
122137 /**
122138 * Plugin definitions.
122139 * @type {Record<string, DependentPlugin>}
122140 */
122141 this.plugins = {};
122142
122143 /**
122144 * Processor ID.
122145 * @type {string|null}
122146 */
122147 this.processor = null;
122148
122149 /**
122150 * The flag that reports unused `eslint-disable` directive comments.
122151 * @type {boolean|undefined}
122152 */
122153 this.reportUnusedDisableDirectives = void 0;
122154
122155 /**
122156 * Rule settings.
122157 * @type {Record<string, [SeverityConf, ...any[]]>}
122158 */
122159 this.rules = {};
122160
122161 /**
122162 * Shared settings.
122163 * @type {Object}
122164 */
122165 this.settings = {};
122166 }
122167
122168 /**
122169 * Convert this config to the compatible object as a config file content.
122170 * @returns {ConfigData} The converted object.
122171 */
122172 toCompatibleObjectAsConfigFileContent() {
122173 const {
122174 /* eslint-disable no-unused-vars */
122175 configNameOfNoInlineConfig: _ignore1,
122176 processor: _ignore2,
122177 /* eslint-enable no-unused-vars */
122178 ignores,
122179 ...config
122180 } = this;
122181
122182 config.parser = config.parser && config.parser.filePath;
122183 config.plugins = Object.keys(config.plugins).filter(Boolean).reverse();
122184 config.ignorePatterns = ignores ? ignores.patterns : [];
122185
122186 // Strip the default patterns from `ignorePatterns`.
122187 if (startsWith(config.ignorePatterns, IgnorePattern.DefaultPatterns)) {
122188 config.ignorePatterns =
122189 config.ignorePatterns.slice(IgnorePattern.DefaultPatterns.length);
122190 }
122191
122192 return config;
122193 }
122194 }
122195
122196 /**
122197 * @fileoverview `ConfigArray` class.
122198 *
122199 * `ConfigArray` class expresses the full of a configuration. It has the entry
122200 * config file, base config files that were extended, loaded parsers, and loaded
122201 * plugins.
122202 *
122203 * `ConfigArray` class provides three properties and two methods.
122204 *
122205 * - `pluginEnvironments`
122206 * - `pluginProcessors`
122207 * - `pluginRules`
122208 * The `Map` objects that contain the members of all plugins that this
122209 * config array contains. Those map objects don't have mutation methods.
122210 * Those keys are the member ID such as `pluginId/memberName`.
122211 * - `isRoot()`
122212 * If `true` then this configuration has `root:true` property.
122213 * - `extractConfig(filePath)`
122214 * Extract the final configuration for a given file. This means merging
122215 * every config array element which that `criteria` property matched. The
122216 * `filePath` argument must be an absolute path.
122217 *
122218 * `ConfigArrayFactory` provides the loading logic of config files.
122219 *
122220 * @author Toru Nagashima <https://github.com/mysticatea>
122221 */
122222
122223 //------------------------------------------------------------------------------
122224 // Helpers
122225 //------------------------------------------------------------------------------
122226
122227 // Define types for VSCode IntelliSense.
122228 /** @typedef {import("../../shared/types").Environment} Environment */
122229 /** @typedef {import("../../shared/types").GlobalConf} GlobalConf */
122230 /** @typedef {import("../../shared/types").RuleConf} RuleConf */
122231 /** @typedef {import("../../shared/types").Rule} Rule */
122232 /** @typedef {import("../../shared/types").Plugin} Plugin */
122233 /** @typedef {import("../../shared/types").Processor} Processor */
122234 /** @typedef {import("./config-dependency").DependentParser} DependentParser */
122235 /** @typedef {import("./config-dependency").DependentPlugin} DependentPlugin */
122236 /** @typedef {import("./override-tester")["OverrideTester"]} OverrideTester */
122237
122238 /**
122239 * @typedef {Object} ConfigArrayElement
122240 * @property {string} name The name of this config element.
122241 * @property {string} filePath The path to the source file of this config element.
122242 * @property {InstanceType<OverrideTester>|null} criteria The tester for the `files` and `excludedFiles` of this config element.
122243 * @property {Record<string, boolean>|undefined} env The environment settings.
122244 * @property {Record<string, GlobalConf>|undefined} globals The global variable settings.
122245 * @property {IgnorePattern|undefined} ignorePattern The ignore patterns.
122246 * @property {boolean|undefined} noInlineConfig The flag that disables directive comments.
122247 * @property {DependentParser|undefined} parser The parser loader.
122248 * @property {Object|undefined} parserOptions The parser options.
122249 * @property {Record<string, DependentPlugin>|undefined} plugins The plugin loaders.
122250 * @property {string|undefined} processor The processor name to refer plugin's processor.
122251 * @property {boolean|undefined} reportUnusedDisableDirectives The flag to report unused `eslint-disable` comments.
122252 * @property {boolean|undefined} root The flag to express root.
122253 * @property {Record<string, RuleConf>|undefined} rules The rule settings
122254 * @property {Object|undefined} settings The shared settings.
122255 * @property {"config" | "ignore" | "implicit-processor"} type The element type.
122256 */
122257
122258 /**
122259 * @typedef {Object} ConfigArrayInternalSlots
122260 * @property {Map<string, ExtractedConfig>} cache The cache to extract configs.
122261 * @property {ReadonlyMap<string, Environment>|null} envMap The map from environment ID to environment definition.
122262 * @property {ReadonlyMap<string, Processor>|null} processorMap The map from processor ID to environment definition.
122263 * @property {ReadonlyMap<string, Rule>|null} ruleMap The map from rule ID to rule definition.
122264 */
122265
122266 /** @type {WeakMap<ConfigArray, ConfigArrayInternalSlots>} */
122267 const internalSlotsMap$2 = new class extends WeakMap {
122268 get(key) {
122269 let value = super.get(key);
122270
122271 if (!value) {
122272 value = {
122273 cache: new Map(),
122274 envMap: null,
122275 processorMap: null,
122276 ruleMap: null
122277 };
122278 super.set(key, value);
122279 }
122280
122281 return value;
122282 }
122283 }();
122284
122285 /**
122286 * Get the indices which are matched to a given file.
122287 * @param {ConfigArrayElement[]} elements The elements.
122288 * @param {string} filePath The path to a target file.
122289 * @returns {number[]} The indices.
122290 */
122291 function getMatchedIndices(elements, filePath) {
122292 const indices = [];
122293
122294 for (let i = elements.length - 1; i >= 0; --i) {
122295 const element = elements[i];
122296
122297 if (!element.criteria || (filePath && element.criteria.test(filePath))) {
122298 indices.push(i);
122299 }
122300 }
122301
122302 return indices;
122303 }
122304
122305 /**
122306 * Check if a value is a non-null object.
122307 * @param {any} x The value to check.
122308 * @returns {boolean} `true` if the value is a non-null object.
122309 */
122310 function isNonNullObject(x) {
122311 return typeof x === "object" && x !== null;
122312 }
122313
122314 /**
122315 * Merge two objects.
122316 *
122317 * Assign every property values of `y` to `x` if `x` doesn't have the property.
122318 * If `x`'s property value is an object, it does recursive.
122319 * @param {Object} target The destination to merge
122320 * @param {Object|undefined} source The source to merge.
122321 * @returns {void}
122322 */
122323 function mergeWithoutOverwrite(target, source) {
122324 if (!isNonNullObject(source)) {
122325 return;
122326 }
122327
122328 for (const key of Object.keys(source)) {
122329 if (key === "__proto__") {
122330 continue;
122331 }
122332
122333 if (isNonNullObject(target[key])) {
122334 mergeWithoutOverwrite(target[key], source[key]);
122335 } else if (target[key] === void 0) {
122336 if (isNonNullObject(source[key])) {
122337 target[key] = Array.isArray(source[key]) ? [] : {};
122338 mergeWithoutOverwrite(target[key], source[key]);
122339 } else if (source[key] !== void 0) {
122340 target[key] = source[key];
122341 }
122342 }
122343 }
122344 }
122345
122346 /**
122347 * The error for plugin conflicts.
122348 */
122349 class PluginConflictError extends Error {
122350
122351 /**
122352 * Initialize this error object.
122353 * @param {string} pluginId The plugin ID.
122354 * @param {{filePath:string, importerName:string}[]} plugins The resolved plugins.
122355 */
122356 constructor(pluginId, plugins) {
122357 super(`Plugin "${pluginId}" was conflicted between ${plugins.map(p => `"${p.importerName}"`).join(" and ")}.`);
122358 this.messageTemplate = "plugin-conflict";
122359 this.messageData = { pluginId, plugins };
122360 }
122361 }
122362
122363 /**
122364 * Merge plugins.
122365 * `target`'s definition is prior to `source`'s.
122366 * @param {Record<string, DependentPlugin>} target The destination to merge
122367 * @param {Record<string, DependentPlugin>|undefined} source The source to merge.
122368 * @returns {void}
122369 */
122370 function mergePlugins(target, source) {
122371 if (!isNonNullObject(source)) {
122372 return;
122373 }
122374
122375 for (const key of Object.keys(source)) {
122376 if (key === "__proto__") {
122377 continue;
122378 }
122379 const targetValue = target[key];
122380 const sourceValue = source[key];
122381
122382 // Adopt the plugin which was found at first.
122383 if (targetValue === void 0) {
122384 if (sourceValue.error) {
122385 throw sourceValue.error;
122386 }
122387 target[key] = sourceValue;
122388 } else if (sourceValue.filePath !== targetValue.filePath) {
122389 throw new PluginConflictError(key, [
122390 {
122391 filePath: targetValue.filePath,
122392 importerName: targetValue.importerName
122393 },
122394 {
122395 filePath: sourceValue.filePath,
122396 importerName: sourceValue.importerName
122397 }
122398 ]);
122399 }
122400 }
122401 }
122402
122403 /**
122404 * Merge rule configs.
122405 * `target`'s definition is prior to `source`'s.
122406 * @param {Record<string, Array>} target The destination to merge
122407 * @param {Record<string, RuleConf>|undefined} source The source to merge.
122408 * @returns {void}
122409 */
122410 function mergeRuleConfigs(target, source) {
122411 if (!isNonNullObject(source)) {
122412 return;
122413 }
122414
122415 for (const key of Object.keys(source)) {
122416 if (key === "__proto__") {
122417 continue;
122418 }
122419 const targetDef = target[key];
122420 const sourceDef = source[key];
122421
122422 // Adopt the rule config which was found at first.
122423 if (targetDef === void 0) {
122424 if (Array.isArray(sourceDef)) {
122425 target[key] = [...sourceDef];
122426 } else {
122427 target[key] = [sourceDef];
122428 }
122429
122430 /*
122431 * If the first found rule config is severity only and the current rule
122432 * config has options, merge the severity and the options.
122433 */
122434 } else if (
122435 targetDef.length === 1 &&
122436 Array.isArray(sourceDef) &&
122437 sourceDef.length >= 2
122438 ) {
122439 targetDef.push(...sourceDef.slice(1));
122440 }
122441 }
122442 }
122443
122444 /**
122445 * Create the extracted config.
122446 * @param {ConfigArray} instance The config elements.
122447 * @param {number[]} indices The indices to use.
122448 * @returns {ExtractedConfig} The extracted config.
122449 */
122450 function createConfig(instance, indices) {
122451 const config = new ExtractedConfig();
122452 const ignorePatterns = [];
122453
122454 // Merge elements.
122455 for (const index of indices) {
122456 const element = instance[index];
122457
122458 // Adopt the parser which was found at first.
122459 if (!config.parser && element.parser) {
122460 if (element.parser.error) {
122461 throw element.parser.error;
122462 }
122463 config.parser = element.parser;
122464 }
122465
122466 // Adopt the processor which was found at first.
122467 if (!config.processor && element.processor) {
122468 config.processor = element.processor;
122469 }
122470
122471 // Adopt the noInlineConfig which was found at first.
122472 if (config.noInlineConfig === void 0 && element.noInlineConfig !== void 0) {
122473 config.noInlineConfig = element.noInlineConfig;
122474 config.configNameOfNoInlineConfig = element.name;
122475 }
122476
122477 // Adopt the reportUnusedDisableDirectives which was found at first.
122478 if (config.reportUnusedDisableDirectives === void 0 && element.reportUnusedDisableDirectives !== void 0) {
122479 config.reportUnusedDisableDirectives = element.reportUnusedDisableDirectives;
122480 }
122481
122482 // Collect ignorePatterns
122483 if (element.ignorePattern) {
122484 ignorePatterns.push(element.ignorePattern);
122485 }
122486
122487 // Merge others.
122488 mergeWithoutOverwrite(config.env, element.env);
122489 mergeWithoutOverwrite(config.globals, element.globals);
122490 mergeWithoutOverwrite(config.parserOptions, element.parserOptions);
122491 mergeWithoutOverwrite(config.settings, element.settings);
122492 mergePlugins(config.plugins, element.plugins);
122493 mergeRuleConfigs(config.rules, element.rules);
122494 }
122495
122496 // Create the predicate function for ignore patterns.
122497 if (ignorePatterns.length > 0) {
122498 config.ignores = IgnorePattern.createIgnore(ignorePatterns.reverse());
122499 }
122500
122501 return config;
122502 }
122503
122504 /**
122505 * Collect definitions.
122506 * @template T, U
122507 * @param {string} pluginId The plugin ID for prefix.
122508 * @param {Record<string,T>} defs The definitions to collect.
122509 * @param {Map<string, U>} map The map to output.
122510 * @param {function(T): U} [normalize] The normalize function for each value.
122511 * @returns {void}
122512 */
122513 function collect(pluginId, defs, map, normalize) {
122514 if (defs) {
122515 const prefix = pluginId && `${pluginId}/`;
122516
122517 for (const [key, value] of Object.entries(defs)) {
122518 map.set(
122519 `${prefix}${key}`,
122520 normalize ? normalize(value) : value
122521 );
122522 }
122523 }
122524 }
122525
122526 /**
122527 * Normalize a rule definition.
122528 * @param {Function|Rule} rule The rule definition to normalize.
122529 * @returns {Rule} The normalized rule definition.
122530 */
122531 function normalizePluginRule(rule) {
122532 return typeof rule === "function" ? { create: rule } : rule;
122533 }
122534
122535 /**
122536 * Delete the mutation methods from a given map.
122537 * @param {Map<any, any>} map The map object to delete.
122538 * @returns {void}
122539 */
122540 function deleteMutationMethods(map) {
122541 Object.defineProperties(map, {
122542 clear: { configurable: true, value: void 0 },
122543 delete: { configurable: true, value: void 0 },
122544 set: { configurable: true, value: void 0 }
122545 });
122546 }
122547
122548 /**
122549 * Create `envMap`, `processorMap`, `ruleMap` with the plugins in the config array.
122550 * @param {ConfigArrayElement[]} elements The config elements.
122551 * @param {ConfigArrayInternalSlots} slots The internal slots.
122552 * @returns {void}
122553 */
122554 function initPluginMemberMaps(elements, slots) {
122555 const processed = new Set();
122556
122557 slots.envMap = new Map();
122558 slots.processorMap = new Map();
122559 slots.ruleMap = new Map();
122560
122561 for (const element of elements) {
122562 if (!element.plugins) {
122563 continue;
122564 }
122565
122566 for (const [pluginId, value] of Object.entries(element.plugins)) {
122567 const plugin = value.definition;
122568
122569 if (!plugin || processed.has(pluginId)) {
122570 continue;
122571 }
122572 processed.add(pluginId);
122573
122574 collect(pluginId, plugin.environments, slots.envMap);
122575 collect(pluginId, plugin.processors, slots.processorMap);
122576 collect(pluginId, plugin.rules, slots.ruleMap, normalizePluginRule);
122577 }
122578 }
122579
122580 deleteMutationMethods(slots.envMap);
122581 deleteMutationMethods(slots.processorMap);
122582 deleteMutationMethods(slots.ruleMap);
122583 }
122584
122585 /**
122586 * Create `envMap`, `processorMap`, `ruleMap` with the plugins in the config array.
122587 * @param {ConfigArray} instance The config elements.
122588 * @returns {ConfigArrayInternalSlots} The extracted config.
122589 */
122590 function ensurePluginMemberMaps(instance) {
122591 const slots = internalSlotsMap$2.get(instance);
122592
122593 if (!slots.ruleMap) {
122594 initPluginMemberMaps(instance, slots);
122595 }
122596
122597 return slots;
122598 }
122599
122600 //------------------------------------------------------------------------------
122601 // Public Interface
122602 //------------------------------------------------------------------------------
122603
122604 /**
122605 * The Config Array.
122606 *
122607 * `ConfigArray` instance contains all settings, parsers, and plugins.
122608 * You need to call `ConfigArray#extractConfig(filePath)` method in order to
122609 * extract, merge and get only the config data which is related to an arbitrary
122610 * file.
122611 * @extends {Array<ConfigArrayElement>}
122612 */
122613 class ConfigArray extends Array {
122614
122615 /**
122616 * Get the plugin environments.
122617 * The returned map cannot be mutated.
122618 * @type {ReadonlyMap<string, Environment>} The plugin environments.
122619 */
122620 get pluginEnvironments() {
122621 return ensurePluginMemberMaps(this).envMap;
122622 }
122623
122624 /**
122625 * Get the plugin processors.
122626 * The returned map cannot be mutated.
122627 * @type {ReadonlyMap<string, Processor>} The plugin processors.
122628 */
122629 get pluginProcessors() {
122630 return ensurePluginMemberMaps(this).processorMap;
122631 }
122632
122633 /**
122634 * Get the plugin rules.
122635 * The returned map cannot be mutated.
122636 * @returns {ReadonlyMap<string, Rule>} The plugin rules.
122637 */
122638 get pluginRules() {
122639 return ensurePluginMemberMaps(this).ruleMap;
122640 }
122641
122642 /**
122643 * Check if this config has `root` flag.
122644 * @returns {boolean} `true` if this config array is root.
122645 */
122646 isRoot() {
122647 for (let i = this.length - 1; i >= 0; --i) {
122648 const root = this[i].root;
122649
122650 if (typeof root === "boolean") {
122651 return root;
122652 }
122653 }
122654 return false;
122655 }
122656
122657 /**
122658 * Extract the config data which is related to a given file.
122659 * @param {string} filePath The absolute path to the target file.
122660 * @returns {ExtractedConfig} The extracted config data.
122661 */
122662 extractConfig(filePath) {
122663 const { cache } = internalSlotsMap$2.get(this);
122664 const indices = getMatchedIndices(this, filePath);
122665 const cacheKey = indices.join(",");
122666
122667 if (!cache.has(cacheKey)) {
122668 cache.set(cacheKey, createConfig(this, indices));
122669 }
122670
122671 return cache.get(cacheKey);
122672 }
122673
122674 /**
122675 * Check if a given path is an additional lint target.
122676 * @param {string} filePath The absolute path to the target file.
122677 * @returns {boolean} `true` if the file is an additional lint target.
122678 */
122679 isAdditionalTargetPath(filePath) {
122680 for (const { criteria, type } of this) {
122681 if (
122682 type === "config" &&
122683 criteria &&
122684 !criteria.endsWithWildcard &&
122685 criteria.test(filePath)
122686 ) {
122687 return true;
122688 }
122689 }
122690 return false;
122691 }
122692 }
122693
122694 /**
122695 * Get the used extracted configs.
122696 * CLIEngine will use this method to collect used deprecated rules.
122697 * @param {ConfigArray} instance The config array object to get.
122698 * @returns {ExtractedConfig[]} The used extracted configs.
122699 * @private
122700 */
122701 function getUsedExtractedConfigs(instance) {
122702 const { cache } = internalSlotsMap$2.get(instance);
122703
122704 return Array.from(cache.values());
122705 }
122706
122707 /**
122708 * @fileoverview `ConfigDependency` class.
122709 *
122710 * `ConfigDependency` class expresses a loaded parser or plugin.
122711 *
122712 * If the parser or plugin was loaded successfully, it has `definition` property
122713 * and `filePath` property. Otherwise, it has `error` property.
122714 *
122715 * When `JSON.stringify()` converted a `ConfigDependency` object to a JSON, it
122716 * omits `definition` property.
122717 *
122718 * `ConfigArrayFactory` creates `ConfigDependency` objects when it loads parsers
122719 * or plugins.
122720 *
122721 * @author Toru Nagashima <https://github.com/mysticatea>
122722 */
122723
122724 /**
122725 * The class is to store parsers or plugins.
122726 * This class hides the loaded object from `JSON.stringify()` and `console.log`.
122727 * @template T
122728 */
122729 class ConfigDependency {
122730
122731 /**
122732 * Initialize this instance.
122733 * @param {Object} data The dependency data.
122734 * @param {T} [data.definition] The dependency if the loading succeeded.
122735 * @param {Error} [data.error] The error object if the loading failed.
122736 * @param {string} [data.filePath] The actual path to the dependency if the loading succeeded.
122737 * @param {string} data.id The ID of this dependency.
122738 * @param {string} data.importerName The name of the config file which loads this dependency.
122739 * @param {string} data.importerPath The path to the config file which loads this dependency.
122740 */
122741 constructor({
122742 definition = null,
122743 error = null,
122744 filePath = null,
122745 id,
122746 importerName,
122747 importerPath
122748 }) {
122749
122750 /**
122751 * The loaded dependency if the loading succeeded.
122752 * @type {T|null}
122753 */
122754 this.definition = definition;
122755
122756 /**
122757 * The error object if the loading failed.
122758 * @type {Error|null}
122759 */
122760 this.error = error;
122761
122762 /**
122763 * The loaded dependency if the loading succeeded.
122764 * @type {string|null}
122765 */
122766 this.filePath = filePath;
122767
122768 /**
122769 * The ID of this dependency.
122770 * @type {string}
122771 */
122772 this.id = id;
122773
122774 /**
122775 * The name of the config file which loads this dependency.
122776 * @type {string}
122777 */
122778 this.importerName = importerName;
122779
122780 /**
122781 * The path to the config file which loads this dependency.
122782 * @type {string}
122783 */
122784 this.importerPath = importerPath;
122785 }
122786
122787 // eslint-disable-next-line jsdoc/require-description
122788 /**
122789 * @returns {Object} a JSON compatible object.
122790 */
122791 toJSON() {
122792 const obj = this[util__default["default"].inspect.custom]();
122793
122794 // Display `error.message` (`Error#message` is unenumerable).
122795 if (obj.error instanceof Error) {
122796 obj.error = { ...obj.error, message: obj.error.message };
122797 }
122798
122799 return obj;
122800 }
122801
122802 // eslint-disable-next-line jsdoc/require-description
122803 /**
122804 * @returns {Object} an object to display by `console.log()`.
122805 */
122806 [util__default["default"].inspect.custom]() {
122807 const {
122808 definition: _ignore, // eslint-disable-line no-unused-vars
122809 ...obj
122810 } = this;
122811
122812 return obj;
122813 }
122814 }
122815
122816 /**
122817 * @fileoverview `OverrideTester` class.
122818 *
122819 * `OverrideTester` class handles `files` property and `excludedFiles` property
122820 * of `overrides` config.
122821 *
122822 * It provides one method.
122823 *
122824 * - `test(filePath)`
122825 * Test if a file path matches the pair of `files` property and
122826 * `excludedFiles` property. The `filePath` argument must be an absolute
122827 * path.
122828 *
122829 * `ConfigArrayFactory` creates `OverrideTester` objects when it processes
122830 * `overrides` properties.
122831 *
122832 * @author Toru Nagashima <https://github.com/mysticatea>
122833 */
122834
122835 const { Minimatch } = minimatch__default["default"];
122836
122837 const minimatchOpts = { dot: true, matchBase: true };
122838
122839 /**
122840 * @typedef {Object} Pattern
122841 * @property {InstanceType<Minimatch>[] | null} includes The positive matchers.
122842 * @property {InstanceType<Minimatch>[] | null} excludes The negative matchers.
122843 */
122844
122845 /**
122846 * Normalize a given pattern to an array.
122847 * @param {string|string[]|undefined} patterns A glob pattern or an array of glob patterns.
122848 * @returns {string[]|null} Normalized patterns.
122849 * @private
122850 */
122851 function normalizePatterns(patterns) {
122852 if (Array.isArray(patterns)) {
122853 return patterns.filter(Boolean);
122854 }
122855 if (typeof patterns === "string" && patterns) {
122856 return [patterns];
122857 }
122858 return [];
122859 }
122860
122861 /**
122862 * Create the matchers of given patterns.
122863 * @param {string[]} patterns The patterns.
122864 * @returns {InstanceType<Minimatch>[] | null} The matchers.
122865 */
122866 function toMatcher(patterns) {
122867 if (patterns.length === 0) {
122868 return null;
122869 }
122870 return patterns.map(pattern => {
122871 if (/^\.[/\\]/u.test(pattern)) {
122872 return new Minimatch(
122873 pattern.slice(2),
122874
122875 // `./*.js` should not match with `subdir/foo.js`
122876 { ...minimatchOpts, matchBase: false }
122877 );
122878 }
122879 return new Minimatch(pattern, minimatchOpts);
122880 });
122881 }
122882
122883 /**
122884 * Convert a given matcher to string.
122885 * @param {Pattern} matchers The matchers.
122886 * @returns {string} The string expression of the matcher.
122887 */
122888 function patternToJson({ includes, excludes }) {
122889 return {
122890 includes: includes && includes.map(m => m.pattern),
122891 excludes: excludes && excludes.map(m => m.pattern)
122892 };
122893 }
122894
122895 /**
122896 * The class to test given paths are matched by the patterns.
122897 */
122898 class OverrideTester {
122899
122900 /**
122901 * Create a tester with given criteria.
122902 * If there are no criteria, returns `null`.
122903 * @param {string|string[]} files The glob patterns for included files.
122904 * @param {string|string[]} excludedFiles The glob patterns for excluded files.
122905 * @param {string} basePath The path to the base directory to test paths.
122906 * @returns {OverrideTester|null} The created instance or `null`.
122907 */
122908 static create(files, excludedFiles, basePath) {
122909 const includePatterns = normalizePatterns(files);
122910 const excludePatterns = normalizePatterns(excludedFiles);
122911 let endsWithWildcard = false;
122912
122913 if (includePatterns.length === 0) {
122914 return null;
122915 }
122916
122917 // Rejects absolute paths or relative paths to parents.
122918 for (const pattern of includePatterns) {
122919 if (path__default["default"].isAbsolute(pattern) || pattern.includes("..")) {
122920 throw new Error(`Invalid override pattern (expected relative path not containing '..'): ${pattern}`);
122921 }
122922 if (pattern.endsWith("*")) {
122923 endsWithWildcard = true;
122924 }
122925 }
122926 for (const pattern of excludePatterns) {
122927 if (path__default["default"].isAbsolute(pattern) || pattern.includes("..")) {
122928 throw new Error(`Invalid override pattern (expected relative path not containing '..'): ${pattern}`);
122929 }
122930 }
122931
122932 const includes = toMatcher(includePatterns);
122933 const excludes = toMatcher(excludePatterns);
122934
122935 return new OverrideTester(
122936 [{ includes, excludes }],
122937 basePath,
122938 endsWithWildcard
122939 );
122940 }
122941
122942 /**
122943 * Combine two testers by logical and.
122944 * If either of the testers was `null`, returns the other tester.
122945 * The `basePath` property of the two must be the same value.
122946 * @param {OverrideTester|null} a A tester.
122947 * @param {OverrideTester|null} b Another tester.
122948 * @returns {OverrideTester|null} Combined tester.
122949 */
122950 static and(a, b) {
122951 if (!b) {
122952 return a && new OverrideTester(
122953 a.patterns,
122954 a.basePath,
122955 a.endsWithWildcard
122956 );
122957 }
122958 if (!a) {
122959 return new OverrideTester(
122960 b.patterns,
122961 b.basePath,
122962 b.endsWithWildcard
122963 );
122964 }
122965
122966 assert__default["default"].strictEqual(a.basePath, b.basePath);
122967 return new OverrideTester(
122968 a.patterns.concat(b.patterns),
122969 a.basePath,
122970 a.endsWithWildcard || b.endsWithWildcard
122971 );
122972 }
122973
122974 /**
122975 * Initialize this instance.
122976 * @param {Pattern[]} patterns The matchers.
122977 * @param {string} basePath The base path.
122978 * @param {boolean} endsWithWildcard If `true` then a pattern ends with `*`.
122979 */
122980 constructor(patterns, basePath, endsWithWildcard = false) {
122981
122982 /** @type {Pattern[]} */
122983 this.patterns = patterns;
122984
122985 /** @type {string} */
122986 this.basePath = basePath;
122987
122988 /** @type {boolean} */
122989 this.endsWithWildcard = endsWithWildcard;
122990 }
122991
122992 /**
122993 * Test if a given path is matched or not.
122994 * @param {string} filePath The absolute path to the target file.
122995 * @returns {boolean} `true` if the path was matched.
122996 */
122997 test(filePath) {
122998 if (typeof filePath !== "string" || !path__default["default"].isAbsolute(filePath)) {
122999 throw new Error(`'filePath' should be an absolute path, but got ${filePath}.`);
123000 }
123001 const relativePath = path__default["default"].relative(this.basePath, filePath);
123002
123003 return this.patterns.every(({ includes, excludes }) => (
123004 (!includes || includes.some(m => m.match(relativePath))) &&
123005 (!excludes || !excludes.some(m => m.match(relativePath)))
123006 ));
123007 }
123008
123009 // eslint-disable-next-line jsdoc/require-description
123010 /**
123011 * @returns {Object} a JSON compatible object.
123012 */
123013 toJSON() {
123014 if (this.patterns.length === 1) {
123015 return {
123016 ...patternToJson(this.patterns[0]),
123017 basePath: this.basePath
123018 };
123019 }
123020 return {
123021 AND: this.patterns.map(patternToJson),
123022 basePath: this.basePath
123023 };
123024 }
123025
123026 // eslint-disable-next-line jsdoc/require-description
123027 /**
123028 * @returns {Object} an object to display by `console.log()`.
123029 */
123030 [util__default["default"].inspect.custom]() {
123031 return this.toJSON();
123032 }
123033 }
123034
123035 /**
123036 * @fileoverview `ConfigArray` class.
123037 * @author Toru Nagashima <https://github.com/mysticatea>
123038 */
123039
123040 /**
123041 * @fileoverview The factory of `ConfigArray` objects.
123042 *
123043 * This class provides methods to create `ConfigArray` instance.
123044 *
123045 * - `create(configData, options)`
123046 * Create a `ConfigArray` instance from a config data. This is to handle CLI
123047 * options except `--config`.
123048 * - `loadFile(filePath, options)`
123049 * Create a `ConfigArray` instance from a config file. This is to handle
123050 * `--config` option. If the file was not found, throws the following error:
123051 * - If the filename was `*.js`, a `MODULE_NOT_FOUND` error.
123052 * - If the filename was `package.json`, an IO error or an
123053 * `ESLINT_CONFIG_FIELD_NOT_FOUND` error.
123054 * - Otherwise, an IO error such as `ENOENT`.
123055 * - `loadInDirectory(directoryPath, options)`
123056 * Create a `ConfigArray` instance from a config file which is on a given
123057 * directory. This tries to load `.eslintrc.*` or `package.json`. If not
123058 * found, returns an empty `ConfigArray`.
123059 * - `loadESLintIgnore(filePath)`
123060 * Create a `ConfigArray` instance from a config file that is `.eslintignore`
123061 * format. This is to handle `--ignore-path` option.
123062 * - `loadDefaultESLintIgnore()`
123063 * Create a `ConfigArray` instance from `.eslintignore` or `package.json` in
123064 * the current working directory.
123065 *
123066 * `ConfigArrayFactory` class has the responsibility that loads configuration
123067 * files, including loading `extends`, `parser`, and `plugins`. The created
123068 * `ConfigArray` instance has the loaded `extends`, `parser`, and `plugins`.
123069 *
123070 * But this class doesn't handle cascading. `CascadingConfigArrayFactory` class
123071 * handles cascading and hierarchy.
123072 *
123073 * @author Toru Nagashima <https://github.com/mysticatea>
123074 */
123075 const require$1 = Module.createRequire((typeof document === 'undefined' ? new ((__webpack_require__(876).URL))('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('eslintrc.cjs', document.baseURI).href)));
123076
123077 const debug$2 = debugOrig__default["default"]("eslintrc:config-array-factory");
123078
123079 //------------------------------------------------------------------------------
123080 // Helpers
123081 //------------------------------------------------------------------------------
123082
123083 const configFilenames = [
123084 ".eslintrc.js",
123085 ".eslintrc.cjs",
123086 ".eslintrc.yaml",
123087 ".eslintrc.yml",
123088 ".eslintrc.json",
123089 ".eslintrc",
123090 "package.json"
123091 ];
123092
123093 // Define types for VSCode IntelliSense.
123094 /** @typedef {import("./shared/types").ConfigData} ConfigData */
123095 /** @typedef {import("./shared/types").OverrideConfigData} OverrideConfigData */
123096 /** @typedef {import("./shared/types").Parser} Parser */
123097 /** @typedef {import("./shared/types").Plugin} Plugin */
123098 /** @typedef {import("./shared/types").Rule} Rule */
123099 /** @typedef {import("./config-array/config-dependency").DependentParser} DependentParser */
123100 /** @typedef {import("./config-array/config-dependency").DependentPlugin} DependentPlugin */
123101 /** @typedef {ConfigArray[0]} ConfigArrayElement */
123102
123103 /**
123104 * @typedef {Object} ConfigArrayFactoryOptions
123105 * @property {Map<string,Plugin>} [additionalPluginPool] The map for additional plugins.
123106 * @property {string} [cwd] The path to the current working directory.
123107 * @property {string} [resolvePluginsRelativeTo] A path to the directory that plugins should be resolved from. Defaults to `cwd`.
123108 * @property {Map<string,Rule>} builtInRules The rules that are built in to ESLint.
123109 * @property {Object} [resolver=ModuleResolver] The module resolver object.
123110 * @property {string} eslintAllPath The path to the definitions for eslint:all.
123111 * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended.
123112 */
123113
123114 /**
123115 * @typedef {Object} ConfigArrayFactoryInternalSlots
123116 * @property {Map<string,Plugin>} additionalPluginPool The map for additional plugins.
123117 * @property {string} cwd The path to the current working directory.
123118 * @property {string | undefined} resolvePluginsRelativeTo An absolute path the the directory that plugins should be resolved from.
123119 * @property {Map<string,Rule>} builtInRules The rules that are built in to ESLint.
123120 * @property {Object} [resolver=ModuleResolver] The module resolver object.
123121 * @property {string} eslintAllPath The path to the definitions for eslint:all.
123122 * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended.
123123 */
123124
123125 /**
123126 * @typedef {Object} ConfigArrayFactoryLoadingContext
123127 * @property {string} filePath The path to the current configuration.
123128 * @property {string} matchBasePath The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`.
123129 * @property {string} name The name of the current configuration.
123130 * @property {string} pluginBasePath The base path to resolve plugins.
123131 * @property {"config" | "ignore" | "implicit-processor"} type The type of the current configuration. This is `"config"` in normal. This is `"ignore"` if it came from `.eslintignore`. This is `"implicit-processor"` if it came from legacy file-extension processors.
123132 */
123133
123134 /**
123135 * @typedef {Object} ConfigArrayFactoryLoadingContext
123136 * @property {string} filePath The path to the current configuration.
123137 * @property {string} matchBasePath The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`.
123138 * @property {string} name The name of the current configuration.
123139 * @property {"config" | "ignore" | "implicit-processor"} type The type of the current configuration. This is `"config"` in normal. This is `"ignore"` if it came from `.eslintignore`. This is `"implicit-processor"` if it came from legacy file-extension processors.
123140 */
123141
123142 /** @type {WeakMap<ConfigArrayFactory, ConfigArrayFactoryInternalSlots>} */
123143 const internalSlotsMap$1 = new WeakMap();
123144
123145 /**
123146 * Check if a given string is a file path.
123147 * @param {string} nameOrPath A module name or file path.
123148 * @returns {boolean} `true` if the `nameOrPath` is a file path.
123149 */
123150 function isFilePath(nameOrPath) {
123151 return (
123152 /^\.{1,2}[/\\]/u.test(nameOrPath) ||
123153 path__default["default"].isAbsolute(nameOrPath)
123154 );
123155 }
123156
123157 /**
123158 * Convenience wrapper for synchronously reading file contents.
123159 * @param {string} filePath The filename to read.
123160 * @returns {string} The file contents, with the BOM removed.
123161 * @private
123162 */
123163 function readFile(filePath) {
123164 return fs__default["default"].readFileSync(filePath, "utf8").replace(/^\ufeff/u, "");
123165 }
123166
123167 /**
123168 * Loads a YAML configuration from a file.
123169 * @param {string} filePath The filename to load.
123170 * @returns {ConfigData} The configuration object from the file.
123171 * @throws {Error} If the file cannot be read.
123172 * @private
123173 */
123174 function loadYAMLConfigFile(filePath) {
123175 debug$2(`Loading YAML config file: ${filePath}`);
123176
123177 // lazy load YAML to improve performance when not used
123178 const yaml = require$1("js-yaml");
123179
123180 try {
123181
123182 // empty YAML file can be null, so always use
123183 return yaml.load(readFile(filePath)) || {};
123184 } catch (e) {
123185 debug$2(`Error reading YAML file: ${filePath}`);
123186 e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
123187 throw e;
123188 }
123189 }
123190
123191 /**
123192 * Loads a JSON configuration from a file.
123193 * @param {string} filePath The filename to load.
123194 * @returns {ConfigData} The configuration object from the file.
123195 * @throws {Error} If the file cannot be read.
123196 * @private
123197 */
123198 function loadJSONConfigFile(filePath) {
123199 debug$2(`Loading JSON config file: ${filePath}`);
123200
123201 try {
123202 return JSON.parse(stripComments__default["default"](readFile(filePath)));
123203 } catch (e) {
123204 debug$2(`Error reading JSON file: ${filePath}`);
123205 e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
123206 e.messageTemplate = "failed-to-read-json";
123207 e.messageData = {
123208 path: filePath,
123209 message: e.message
123210 };
123211 throw e;
123212 }
123213 }
123214
123215 /**
123216 * Loads a legacy (.eslintrc) configuration from a file.
123217 * @param {string} filePath The filename to load.
123218 * @returns {ConfigData} The configuration object from the file.
123219 * @throws {Error} If the file cannot be read.
123220 * @private
123221 */
123222 function loadLegacyConfigFile(filePath) {
123223 debug$2(`Loading legacy config file: ${filePath}`);
123224
123225 // lazy load YAML to improve performance when not used
123226 const yaml = require$1("js-yaml");
123227
123228 try {
123229 return yaml.load(stripComments__default["default"](readFile(filePath))) || /* istanbul ignore next */ {};
123230 } catch (e) {
123231 debug$2("Error reading YAML file: %s\n%o", filePath, e);
123232 e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
123233 throw e;
123234 }
123235 }
123236
123237 /**
123238 * Loads a JavaScript configuration from a file.
123239 * @param {string} filePath The filename to load.
123240 * @returns {ConfigData} The configuration object from the file.
123241 * @throws {Error} If the file cannot be read.
123242 * @private
123243 */
123244 function loadJSConfigFile(filePath) {
123245 debug$2(`Loading JS config file: ${filePath}`);
123246 try {
123247 return importFresh__default["default"](filePath);
123248 } catch (e) {
123249 debug$2(`Error reading JavaScript file: ${filePath}`);
123250 e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
123251 throw e;
123252 }
123253 }
123254
123255 /**
123256 * Loads a configuration from a package.json file.
123257 * @param {string} filePath The filename to load.
123258 * @returns {ConfigData} The configuration object from the file.
123259 * @throws {Error} If the file cannot be read.
123260 * @private
123261 */
123262 function loadPackageJSONConfigFile(filePath) {
123263 debug$2(`Loading package.json config file: ${filePath}`);
123264 try {
123265 const packageData = loadJSONConfigFile(filePath);
123266
123267 if (!Object.hasOwnProperty.call(packageData, "eslintConfig")) {
123268 throw Object.assign(
123269 new Error("package.json file doesn't have 'eslintConfig' field."),
123270 { code: "ESLINT_CONFIG_FIELD_NOT_FOUND" }
123271 );
123272 }
123273
123274 return packageData.eslintConfig;
123275 } catch (e) {
123276 debug$2(`Error reading package.json file: ${filePath}`);
123277 e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
123278 throw e;
123279 }
123280 }
123281
123282 /**
123283 * Loads a `.eslintignore` from a file.
123284 * @param {string} filePath The filename to load.
123285 * @returns {string[]} The ignore patterns from the file.
123286 * @private
123287 */
123288 function loadESLintIgnoreFile(filePath) {
123289 debug$2(`Loading .eslintignore file: ${filePath}`);
123290
123291 try {
123292 return readFile(filePath)
123293 .split(/\r?\n/gu)
123294 .filter(line => line.trim() !== "" && !line.startsWith("#"));
123295 } catch (e) {
123296 debug$2(`Error reading .eslintignore file: ${filePath}`);
123297 e.message = `Cannot read .eslintignore file: ${filePath}\nError: ${e.message}`;
123298 throw e;
123299 }
123300 }
123301
123302 /**
123303 * Creates an error to notify about a missing config to extend from.
123304 * @param {string} configName The name of the missing config.
123305 * @param {string} importerName The name of the config that imported the missing config
123306 * @param {string} messageTemplate The text template to source error strings from.
123307 * @returns {Error} The error object to throw
123308 * @private
123309 */
123310 function configInvalidError(configName, importerName, messageTemplate) {
123311 return Object.assign(
123312 new Error(`Failed to load config "${configName}" to extend from.`),
123313 {
123314 messageTemplate,
123315 messageData: { configName, importerName }
123316 }
123317 );
123318 }
123319
123320 /**
123321 * Loads a configuration file regardless of the source. Inspects the file path
123322 * to determine the correctly way to load the config file.
123323 * @param {string} filePath The path to the configuration.
123324 * @returns {ConfigData|null} The configuration information.
123325 * @private
123326 */
123327 function loadConfigFile(filePath) {
123328 switch (path__default["default"].extname(filePath)) {
123329 case ".js":
123330 case ".cjs":
123331 return loadJSConfigFile(filePath);
123332
123333 case ".json":
123334 if (path__default["default"].basename(filePath) === "package.json") {
123335 return loadPackageJSONConfigFile(filePath);
123336 }
123337 return loadJSONConfigFile(filePath);
123338
123339 case ".yaml":
123340 case ".yml":
123341 return loadYAMLConfigFile(filePath);
123342
123343 default:
123344 return loadLegacyConfigFile(filePath);
123345 }
123346 }
123347
123348 /**
123349 * Write debug log.
123350 * @param {string} request The requested module name.
123351 * @param {string} relativeTo The file path to resolve the request relative to.
123352 * @param {string} filePath The resolved file path.
123353 * @returns {void}
123354 */
123355 function writeDebugLogForLoading(request, relativeTo, filePath) {
123356 /* istanbul ignore next */
123357 if (debug$2.enabled) {
123358 let nameAndVersion = null;
123359
123360 try {
123361 const packageJsonPath = resolve(
123362 `${request}/package.json`,
123363 relativeTo
123364 );
123365 const { version = "unknown" } = require$1(packageJsonPath);
123366
123367 nameAndVersion = `${request}@${version}`;
123368 } catch (error) {
123369 debug$2("package.json was not found:", error.message);
123370 nameAndVersion = request;
123371 }
123372
123373 debug$2("Loaded: %s (%s)", nameAndVersion, filePath);
123374 }
123375 }
123376
123377 /**
123378 * Create a new context with default values.
123379 * @param {ConfigArrayFactoryInternalSlots} slots The internal slots.
123380 * @param {"config" | "ignore" | "implicit-processor" | undefined} providedType The type of the current configuration. Default is `"config"`.
123381 * @param {string | undefined} providedName The name of the current configuration. Default is the relative path from `cwd` to `filePath`.
123382 * @param {string | undefined} providedFilePath The path to the current configuration. Default is empty string.
123383 * @param {string | undefined} providedMatchBasePath The type of the current configuration. Default is the directory of `filePath` or `cwd`.
123384 * @returns {ConfigArrayFactoryLoadingContext} The created context.
123385 */
123386 function createContext(
123387 { cwd, resolvePluginsRelativeTo },
123388 providedType,
123389 providedName,
123390 providedFilePath,
123391 providedMatchBasePath
123392 ) {
123393 const filePath = providedFilePath
123394 ? path__default["default"].resolve(cwd, providedFilePath)
123395 : "";
123396 const matchBasePath =
123397 (providedMatchBasePath && path__default["default"].resolve(cwd, providedMatchBasePath)) ||
123398 (filePath && path__default["default"].dirname(filePath)) ||
123399 cwd;
123400 const name =
123401 providedName ||
123402 (filePath && path__default["default"].relative(cwd, filePath)) ||
123403 "";
123404 const pluginBasePath =
123405 resolvePluginsRelativeTo ||
123406 (filePath && path__default["default"].dirname(filePath)) ||
123407 cwd;
123408 const type = providedType || "config";
123409
123410 return { filePath, matchBasePath, name, pluginBasePath, type };
123411 }
123412
123413 /**
123414 * Normalize a given plugin.
123415 * - Ensure the object to have four properties: configs, environments, processors, and rules.
123416 * - Ensure the object to not have other properties.
123417 * @param {Plugin} plugin The plugin to normalize.
123418 * @returns {Plugin} The normalized plugin.
123419 */
123420 function normalizePlugin(plugin) {
123421 return {
123422 configs: plugin.configs || {},
123423 environments: plugin.environments || {},
123424 processors: plugin.processors || {},
123425 rules: plugin.rules || {}
123426 };
123427 }
123428
123429 //------------------------------------------------------------------------------
123430 // Public Interface
123431 //------------------------------------------------------------------------------
123432
123433 /**
123434 * The factory of `ConfigArray` objects.
123435 */
123436 class ConfigArrayFactory {
123437
123438 /**
123439 * Initialize this instance.
123440 * @param {ConfigArrayFactoryOptions} [options] The map for additional plugins.
123441 */
123442 constructor({
123443 additionalPluginPool = new Map(),
123444 cwd = process.cwd(),
123445 resolvePluginsRelativeTo,
123446 builtInRules,
123447 resolver = ModuleResolver,
123448 eslintAllPath,
123449 eslintRecommendedPath
123450 } = {}) {
123451 internalSlotsMap$1.set(this, {
123452 additionalPluginPool,
123453 cwd,
123454 resolvePluginsRelativeTo:
123455 resolvePluginsRelativeTo &&
123456 path__default["default"].resolve(cwd, resolvePluginsRelativeTo),
123457 builtInRules,
123458 resolver,
123459 eslintAllPath,
123460 eslintRecommendedPath
123461 });
123462 }
123463
123464 /**
123465 * Create `ConfigArray` instance from a config data.
123466 * @param {ConfigData|null} configData The config data to create.
123467 * @param {Object} [options] The options.
123468 * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`.
123469 * @param {string} [options.filePath] The path to this config data.
123470 * @param {string} [options.name] The config name.
123471 * @returns {ConfigArray} Loaded config.
123472 */
123473 create(configData, { basePath, filePath, name } = {}) {
123474 if (!configData) {
123475 return new ConfigArray();
123476 }
123477
123478 const slots = internalSlotsMap$1.get(this);
123479 const ctx = createContext(slots, "config", name, filePath, basePath);
123480 const elements = this._normalizeConfigData(configData, ctx);
123481
123482 return new ConfigArray(...elements);
123483 }
123484
123485 /**
123486 * Load a config file.
123487 * @param {string} filePath The path to a config file.
123488 * @param {Object} [options] The options.
123489 * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`.
123490 * @param {string} [options.name] The config name.
123491 * @returns {ConfigArray} Loaded config.
123492 */
123493 loadFile(filePath, { basePath, name } = {}) {
123494 const slots = internalSlotsMap$1.get(this);
123495 const ctx = createContext(slots, "config", name, filePath, basePath);
123496
123497 return new ConfigArray(...this._loadConfigData(ctx));
123498 }
123499
123500 /**
123501 * Load the config file on a given directory if exists.
123502 * @param {string} directoryPath The path to a directory.
123503 * @param {Object} [options] The options.
123504 * @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`.
123505 * @param {string} [options.name] The config name.
123506 * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist.
123507 */
123508 loadInDirectory(directoryPath, { basePath, name } = {}) {
123509 const slots = internalSlotsMap$1.get(this);
123510
123511 for (const filename of configFilenames) {
123512 const ctx = createContext(
123513 slots,
123514 "config",
123515 name,
123516 path__default["default"].join(directoryPath, filename),
123517 basePath
123518 );
123519
123520 if (fs__default["default"].existsSync(ctx.filePath) && fs__default["default"].statSync(ctx.filePath).isFile()) {
123521 let configData;
123522
123523 try {
123524 configData = loadConfigFile(ctx.filePath);
123525 } catch (error) {
123526 if (!error || error.code !== "ESLINT_CONFIG_FIELD_NOT_FOUND") {
123527 throw error;
123528 }
123529 }
123530
123531 if (configData) {
123532 debug$2(`Config file found: ${ctx.filePath}`);
123533 return new ConfigArray(
123534 ...this._normalizeConfigData(configData, ctx)
123535 );
123536 }
123537 }
123538 }
123539
123540 debug$2(`Config file not found on ${directoryPath}`);
123541 return new ConfigArray();
123542 }
123543
123544 /**
123545 * Check if a config file on a given directory exists or not.
123546 * @param {string} directoryPath The path to a directory.
123547 * @returns {string | null} The path to the found config file. If not found then null.
123548 */
123549 static getPathToConfigFileInDirectory(directoryPath) {
123550 for (const filename of configFilenames) {
123551 const filePath = path__default["default"].join(directoryPath, filename);
123552
123553 if (fs__default["default"].existsSync(filePath)) {
123554 if (filename === "package.json") {
123555 try {
123556 loadPackageJSONConfigFile(filePath);
123557 return filePath;
123558 } catch { /* ignore */ }
123559 } else {
123560 return filePath;
123561 }
123562 }
123563 }
123564 return null;
123565 }
123566
123567 /**
123568 * Load `.eslintignore` file.
123569 * @param {string} filePath The path to a `.eslintignore` file to load.
123570 * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist.
123571 */
123572 loadESLintIgnore(filePath) {
123573 const slots = internalSlotsMap$1.get(this);
123574 const ctx = createContext(
123575 slots,
123576 "ignore",
123577 void 0,
123578 filePath,
123579 slots.cwd
123580 );
123581 const ignorePatterns = loadESLintIgnoreFile(ctx.filePath);
123582
123583 return new ConfigArray(
123584 ...this._normalizeESLintIgnoreData(ignorePatterns, ctx)
123585 );
123586 }
123587
123588 /**
123589 * Load `.eslintignore` file in the current working directory.
123590 * @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist.
123591 */
123592 loadDefaultESLintIgnore() {
123593 const slots = internalSlotsMap$1.get(this);
123594 const eslintIgnorePath = path__default["default"].resolve(slots.cwd, ".eslintignore");
123595 const packageJsonPath = path__default["default"].resolve(slots.cwd, "package.json");
123596
123597 if (fs__default["default"].existsSync(eslintIgnorePath)) {
123598 return this.loadESLintIgnore(eslintIgnorePath);
123599 }
123600 if (fs__default["default"].existsSync(packageJsonPath)) {
123601 const data = loadJSONConfigFile(packageJsonPath);
123602
123603 if (Object.hasOwnProperty.call(data, "eslintIgnore")) {
123604 if (!Array.isArray(data.eslintIgnore)) {
123605 throw new Error("Package.json eslintIgnore property requires an array of paths");
123606 }
123607 const ctx = createContext(
123608 slots,
123609 "ignore",
123610 "eslintIgnore in package.json",
123611 packageJsonPath,
123612 slots.cwd
123613 );
123614
123615 return new ConfigArray(
123616 ...this._normalizeESLintIgnoreData(data.eslintIgnore, ctx)
123617 );
123618 }
123619 }
123620
123621 return new ConfigArray();
123622 }
123623
123624 /**
123625 * Load a given config file.
123626 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
123627 * @returns {IterableIterator<ConfigArrayElement>} Loaded config.
123628 * @private
123629 */
123630 _loadConfigData(ctx) {
123631 return this._normalizeConfigData(loadConfigFile(ctx.filePath), ctx);
123632 }
123633
123634 /**
123635 * Normalize a given `.eslintignore` data to config array elements.
123636 * @param {string[]} ignorePatterns The patterns to ignore files.
123637 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
123638 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
123639 * @private
123640 */
123641 *_normalizeESLintIgnoreData(ignorePatterns, ctx) {
123642 const elements = this._normalizeObjectConfigData(
123643 { ignorePatterns },
123644 ctx
123645 );
123646
123647 // Set `ignorePattern.loose` flag for backward compatibility.
123648 for (const element of elements) {
123649 if (element.ignorePattern) {
123650 element.ignorePattern.loose = true;
123651 }
123652 yield element;
123653 }
123654 }
123655
123656 /**
123657 * Normalize a given config to an array.
123658 * @param {ConfigData} configData The config data to normalize.
123659 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
123660 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
123661 * @private
123662 */
123663 _normalizeConfigData(configData, ctx) {
123664 const validator = new ConfigValidator();
123665
123666 validator.validateConfigSchema(configData, ctx.name || ctx.filePath);
123667 return this._normalizeObjectConfigData(configData, ctx);
123668 }
123669
123670 /**
123671 * Normalize a given config to an array.
123672 * @param {ConfigData|OverrideConfigData} configData The config data to normalize.
123673 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
123674 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
123675 * @private
123676 */
123677 *_normalizeObjectConfigData(configData, ctx) {
123678 const { files, excludedFiles, ...configBody } = configData;
123679 const criteria = OverrideTester.create(
123680 files,
123681 excludedFiles,
123682 ctx.matchBasePath
123683 );
123684 const elements = this._normalizeObjectConfigDataBody(configBody, ctx);
123685
123686 // Apply the criteria to every element.
123687 for (const element of elements) {
123688
123689 /*
123690 * Merge the criteria.
123691 * This is for the `overrides` entries that came from the
123692 * configurations of `overrides[].extends`.
123693 */
123694 element.criteria = OverrideTester.and(criteria, element.criteria);
123695
123696 /*
123697 * Remove `root` property to ignore `root` settings which came from
123698 * `extends` in `overrides`.
123699 */
123700 if (element.criteria) {
123701 element.root = void 0;
123702 }
123703
123704 yield element;
123705 }
123706 }
123707
123708 /**
123709 * Normalize a given config to an array.
123710 * @param {ConfigData} configData The config data to normalize.
123711 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
123712 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
123713 * @private
123714 */
123715 *_normalizeObjectConfigDataBody(
123716 {
123717 env,
123718 extends: extend,
123719 globals,
123720 ignorePatterns,
123721 noInlineConfig,
123722 parser: parserName,
123723 parserOptions,
123724 plugins: pluginList,
123725 processor,
123726 reportUnusedDisableDirectives,
123727 root,
123728 rules,
123729 settings,
123730 overrides: overrideList = []
123731 },
123732 ctx
123733 ) {
123734 const extendList = Array.isArray(extend) ? extend : [extend];
123735 const ignorePattern = ignorePatterns && new IgnorePattern(
123736 Array.isArray(ignorePatterns) ? ignorePatterns : [ignorePatterns],
123737 ctx.matchBasePath
123738 );
123739
123740 // Flatten `extends`.
123741 for (const extendName of extendList.filter(Boolean)) {
123742 yield* this._loadExtends(extendName, ctx);
123743 }
123744
123745 // Load parser & plugins.
123746 const parser = parserName && this._loadParser(parserName, ctx);
123747 const plugins = pluginList && this._loadPlugins(pluginList, ctx);
123748
123749 // Yield pseudo config data for file extension processors.
123750 if (plugins) {
123751 yield* this._takeFileExtensionProcessors(plugins, ctx);
123752 }
123753
123754 // Yield the config data except `extends` and `overrides`.
123755 yield {
123756
123757 // Debug information.
123758 type: ctx.type,
123759 name: ctx.name,
123760 filePath: ctx.filePath,
123761
123762 // Config data.
123763 criteria: null,
123764 env,
123765 globals,
123766 ignorePattern,
123767 noInlineConfig,
123768 parser,
123769 parserOptions,
123770 plugins,
123771 processor,
123772 reportUnusedDisableDirectives,
123773 root,
123774 rules,
123775 settings
123776 };
123777
123778 // Flatten `overries`.
123779 for (let i = 0; i < overrideList.length; ++i) {
123780 yield* this._normalizeObjectConfigData(
123781 overrideList[i],
123782 { ...ctx, name: `${ctx.name}#overrides[${i}]` }
123783 );
123784 }
123785 }
123786
123787 /**
123788 * Load configs of an element in `extends`.
123789 * @param {string} extendName The name of a base config.
123790 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
123791 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
123792 * @private
123793 */
123794 _loadExtends(extendName, ctx) {
123795 debug$2("Loading {extends:%j} relative to %s", extendName, ctx.filePath);
123796 try {
123797 if (extendName.startsWith("eslint:")) {
123798 return this._loadExtendedBuiltInConfig(extendName, ctx);
123799 }
123800 if (extendName.startsWith("plugin:")) {
123801 return this._loadExtendedPluginConfig(extendName, ctx);
123802 }
123803 return this._loadExtendedShareableConfig(extendName, ctx);
123804 } catch (error) {
123805 error.message += `\nReferenced from: ${ctx.filePath || ctx.name}`;
123806 throw error;
123807 }
123808 }
123809
123810 /**
123811 * Load configs of an element in `extends`.
123812 * @param {string} extendName The name of a base config.
123813 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
123814 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
123815 * @private
123816 */
123817 _loadExtendedBuiltInConfig(extendName, ctx) {
123818 const { eslintAllPath, eslintRecommendedPath } = internalSlotsMap$1.get(this);
123819
123820 if (extendName === "eslint:recommended") {
123821 return this._loadConfigData({
123822 ...ctx,
123823 filePath: eslintRecommendedPath,
123824 name: `${ctx.name} » ${extendName}`
123825 });
123826 }
123827 if (extendName === "eslint:all") {
123828 return this._loadConfigData({
123829 ...ctx,
123830 filePath: eslintAllPath,
123831 name: `${ctx.name} » ${extendName}`
123832 });
123833 }
123834
123835 throw configInvalidError(extendName, ctx.name, "extend-config-missing");
123836 }
123837
123838 /**
123839 * Load configs of an element in `extends`.
123840 * @param {string} extendName The name of a base config.
123841 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
123842 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
123843 * @private
123844 */
123845 _loadExtendedPluginConfig(extendName, ctx) {
123846 const slashIndex = extendName.lastIndexOf("/");
123847
123848 if (slashIndex === -1) {
123849 throw configInvalidError(extendName, ctx.filePath, "plugin-invalid");
123850 }
123851
123852 const pluginName = extendName.slice("plugin:".length, slashIndex);
123853 const configName = extendName.slice(slashIndex + 1);
123854
123855 if (isFilePath(pluginName)) {
123856 throw new Error("'extends' cannot use a file path for plugins.");
123857 }
123858
123859 const plugin = this._loadPlugin(pluginName, ctx);
123860 const configData =
123861 plugin.definition &&
123862 plugin.definition.configs[configName];
123863
123864 if (configData) {
123865 return this._normalizeConfigData(configData, {
123866 ...ctx,
123867 filePath: plugin.filePath || ctx.filePath,
123868 name: `${ctx.name} » plugin:${plugin.id}/${configName}`
123869 });
123870 }
123871
123872 throw plugin.error || configInvalidError(extendName, ctx.filePath, "extend-config-missing");
123873 }
123874
123875 /**
123876 * Load configs of an element in `extends`.
123877 * @param {string} extendName The name of a base config.
123878 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
123879 * @returns {IterableIterator<ConfigArrayElement>} The normalized config.
123880 * @private
123881 */
123882 _loadExtendedShareableConfig(extendName, ctx) {
123883 const { cwd, resolver } = internalSlotsMap$1.get(this);
123884 const relativeTo = ctx.filePath || path__default["default"].join(cwd, "__placeholder__.js");
123885 let request;
123886
123887 if (isFilePath(extendName)) {
123888 request = extendName;
123889 } else if (extendName.startsWith(".")) {
123890 request = `./${extendName}`; // For backward compatibility. A ton of tests depended on this behavior.
123891 } else {
123892 request = normalizePackageName(
123893 extendName,
123894 "eslint-config"
123895 );
123896 }
123897
123898 let filePath;
123899
123900 try {
123901 filePath = resolver.resolve(request, relativeTo);
123902 } catch (error) {
123903 /* istanbul ignore else */
123904 if (error && error.code === "MODULE_NOT_FOUND") {
123905 throw configInvalidError(extendName, ctx.filePath, "extend-config-missing");
123906 }
123907 throw error;
123908 }
123909
123910 writeDebugLogForLoading(request, relativeTo, filePath);
123911 return this._loadConfigData({
123912 ...ctx,
123913 filePath,
123914 name: `${ctx.name} » ${request}`
123915 });
123916 }
123917
123918 /**
123919 * Load given plugins.
123920 * @param {string[]} names The plugin names to load.
123921 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
123922 * @returns {Record<string,DependentPlugin>} The loaded parser.
123923 * @private
123924 */
123925 _loadPlugins(names, ctx) {
123926 return names.reduce((map, name) => {
123927 if (isFilePath(name)) {
123928 throw new Error("Plugins array cannot includes file paths.");
123929 }
123930 const plugin = this._loadPlugin(name, ctx);
123931
123932 map[plugin.id] = plugin;
123933
123934 return map;
123935 }, {});
123936 }
123937
123938 /**
123939 * Load a given parser.
123940 * @param {string} nameOrPath The package name or the path to a parser file.
123941 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
123942 * @returns {DependentParser} The loaded parser.
123943 */
123944 _loadParser(nameOrPath, ctx) {
123945 debug$2("Loading parser %j from %s", nameOrPath, ctx.filePath);
123946
123947 const { cwd, resolver } = internalSlotsMap$1.get(this);
123948 const relativeTo = ctx.filePath || path__default["default"].join(cwd, "__placeholder__.js");
123949
123950 try {
123951 const filePath = resolver.resolve(nameOrPath, relativeTo);
123952
123953 writeDebugLogForLoading(nameOrPath, relativeTo, filePath);
123954
123955 return new ConfigDependency({
123956 definition: require$1(filePath),
123957 filePath,
123958 id: nameOrPath,
123959 importerName: ctx.name,
123960 importerPath: ctx.filePath
123961 });
123962 } catch (error) {
123963
123964 // If the parser name is "espree", load the espree of ESLint.
123965 if (nameOrPath === "espree") {
123966 debug$2("Fallback espree.");
123967 return new ConfigDependency({
123968 definition: require$1("espree"),
123969 filePath: require$1.resolve("espree"),
123970 id: nameOrPath,
123971 importerName: ctx.name,
123972 importerPath: ctx.filePath
123973 });
123974 }
123975
123976 debug$2("Failed to load parser '%s' declared in '%s'.", nameOrPath, ctx.name);
123977 error.message = `Failed to load parser '${nameOrPath}' declared in '${ctx.name}': ${error.message}`;
123978
123979 return new ConfigDependency({
123980 error,
123981 id: nameOrPath,
123982 importerName: ctx.name,
123983 importerPath: ctx.filePath
123984 });
123985 }
123986 }
123987
123988 /**
123989 * Load a given plugin.
123990 * @param {string} name The plugin name to load.
123991 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
123992 * @returns {DependentPlugin} The loaded plugin.
123993 * @private
123994 */
123995 _loadPlugin(name, ctx) {
123996 debug$2("Loading plugin %j from %s", name, ctx.filePath);
123997
123998 const { additionalPluginPool, resolver } = internalSlotsMap$1.get(this);
123999 const request = normalizePackageName(name, "eslint-plugin");
124000 const id = getShorthandName(request, "eslint-plugin");
124001 const relativeTo = path__default["default"].join(ctx.pluginBasePath, "__placeholder__.js");
124002
124003 if (name.match(/\s+/u)) {
124004 const error = Object.assign(
124005 new Error(`Whitespace found in plugin name '${name}'`),
124006 {
124007 messageTemplate: "whitespace-found",
124008 messageData: { pluginName: request }
124009 }
124010 );
124011
124012 return new ConfigDependency({
124013 error,
124014 id,
124015 importerName: ctx.name,
124016 importerPath: ctx.filePath
124017 });
124018 }
124019
124020 // Check for additional pool.
124021 const plugin =
124022 additionalPluginPool.get(request) ||
124023 additionalPluginPool.get(id);
124024
124025 if (plugin) {
124026 return new ConfigDependency({
124027 definition: normalizePlugin(plugin),
124028 filePath: "", // It's unknown where the plugin came from.
124029 id,
124030 importerName: ctx.name,
124031 importerPath: ctx.filePath
124032 });
124033 }
124034
124035 let filePath;
124036 let error;
124037
124038 try {
124039 filePath = resolver.resolve(request, relativeTo);
124040 } catch (resolveError) {
124041 error = resolveError;
124042 /* istanbul ignore else */
124043 if (error && error.code === "MODULE_NOT_FOUND") {
124044 error.messageTemplate = "plugin-missing";
124045 error.messageData = {
124046 pluginName: request,
124047 resolvePluginsRelativeTo: ctx.pluginBasePath,
124048 importerName: ctx.name
124049 };
124050 }
124051 }
124052
124053 if (filePath) {
124054 try {
124055 writeDebugLogForLoading(request, relativeTo, filePath);
124056
124057 const startTime = Date.now();
124058 const pluginDefinition = require$1(filePath);
124059
124060 debug$2(`Plugin ${filePath} loaded in: ${Date.now() - startTime}ms`);
124061
124062 return new ConfigDependency({
124063 definition: normalizePlugin(pluginDefinition),
124064 filePath,
124065 id,
124066 importerName: ctx.name,
124067 importerPath: ctx.filePath
124068 });
124069 } catch (loadError) {
124070 error = loadError;
124071 }
124072 }
124073
124074 debug$2("Failed to load plugin '%s' declared in '%s'.", name, ctx.name);
124075 error.message = `Failed to load plugin '${name}' declared in '${ctx.name}': ${error.message}`;
124076 return new ConfigDependency({
124077 error,
124078 id,
124079 importerName: ctx.name,
124080 importerPath: ctx.filePath
124081 });
124082 }
124083
124084 /**
124085 * Take file expression processors as config array elements.
124086 * @param {Record<string,DependentPlugin>} plugins The plugin definitions.
124087 * @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
124088 * @returns {IterableIterator<ConfigArrayElement>} The config array elements of file expression processors.
124089 * @private
124090 */
124091 *_takeFileExtensionProcessors(plugins, ctx) {
124092 for (const pluginId of Object.keys(plugins)) {
124093 const processors =
124094 plugins[pluginId] &&
124095 plugins[pluginId].definition &&
124096 plugins[pluginId].definition.processors;
124097
124098 if (!processors) {
124099 continue;
124100 }
124101
124102 for (const processorId of Object.keys(processors)) {
124103 if (processorId.startsWith(".")) {
124104 yield* this._normalizeObjectConfigData(
124105 {
124106 files: [`*${processorId}`],
124107 processor: `${pluginId}/${processorId}`
124108 },
124109 {
124110 ...ctx,
124111 type: "implicit-processor",
124112 name: `${ctx.name}#processors["${pluginId}/${processorId}"]`
124113 }
124114 );
124115 }
124116 }
124117 }
124118 }
124119 }
124120
124121 /**
124122 * @fileoverview `CascadingConfigArrayFactory` class.
124123 *
124124 * `CascadingConfigArrayFactory` class has a responsibility:
124125 *
124126 * 1. Handles cascading of config files.
124127 *
124128 * It provides two methods:
124129 *
124130 * - `getConfigArrayForFile(filePath)`
124131 * Get the corresponded configuration of a given file. This method doesn't
124132 * throw even if the given file didn't exist.
124133 * - `clearCache()`
124134 * Clear the internal cache. You have to call this method when
124135 * `additionalPluginPool` was updated if `baseConfig` or `cliConfig` depends
124136 * on the additional plugins. (`CLIEngine#addPlugin()` method calls this.)
124137 *
124138 * @author Toru Nagashima <https://github.com/mysticatea>
124139 */
124140
124141 const debug$1 = debugOrig__default["default"]("eslintrc:cascading-config-array-factory");
124142
124143 //------------------------------------------------------------------------------
124144 // Helpers
124145 //------------------------------------------------------------------------------
124146
124147 // Define types for VSCode IntelliSense.
124148 /** @typedef {import("./shared/types").ConfigData} ConfigData */
124149 /** @typedef {import("./shared/types").Parser} Parser */
124150 /** @typedef {import("./shared/types").Plugin} Plugin */
124151 /** @typedef {import("./shared/types").Rule} Rule */
124152 /** @typedef {ReturnType<ConfigArrayFactory["create"]>} ConfigArray */
124153
124154 /**
124155 * @typedef {Object} CascadingConfigArrayFactoryOptions
124156 * @property {Map<string,Plugin>} [additionalPluginPool] The map for additional plugins.
124157 * @property {ConfigData} [baseConfig] The config by `baseConfig` option.
124158 * @property {ConfigData} [cliConfig] The config by CLI options (`--env`, `--global`, `--ignore-pattern`, `--parser`, `--parser-options`, `--plugin`, and `--rule`). CLI options overwrite the setting in config files.
124159 * @property {string} [cwd] The base directory to start lookup.
124160 * @property {string} [ignorePath] The path to the alternative file of `.eslintignore`.
124161 * @property {string[]} [rulePaths] The value of `--rulesdir` option.
124162 * @property {string} [specificConfigPath] The value of `--config` option.
124163 * @property {boolean} [useEslintrc] if `false` then it doesn't load config files.
124164 * @property {Function} loadRules The function to use to load rules.
124165 * @property {Map<string,Rule>} builtInRules The rules that are built in to ESLint.
124166 * @property {Object} [resolver=ModuleResolver] The module resolver object.
124167 * @property {string} eslintAllPath The path to the definitions for eslint:all.
124168 * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended.
124169 */
124170
124171 /**
124172 * @typedef {Object} CascadingConfigArrayFactoryInternalSlots
124173 * @property {ConfigArray} baseConfigArray The config array of `baseConfig` option.
124174 * @property {ConfigData} baseConfigData The config data of `baseConfig` option. This is used to reset `baseConfigArray`.
124175 * @property {ConfigArray} cliConfigArray The config array of CLI options.
124176 * @property {ConfigData} cliConfigData The config data of CLI options. This is used to reset `cliConfigArray`.
124177 * @property {ConfigArrayFactory} configArrayFactory The factory for config arrays.
124178 * @property {Map<string, ConfigArray>} configCache The cache from directory paths to config arrays.
124179 * @property {string} cwd The base directory to start lookup.
124180 * @property {WeakMap<ConfigArray, ConfigArray>} finalizeCache The cache from config arrays to finalized config arrays.
124181 * @property {string} [ignorePath] The path to the alternative file of `.eslintignore`.
124182 * @property {string[]|null} rulePaths The value of `--rulesdir` option. This is used to reset `baseConfigArray`.
124183 * @property {string|null} specificConfigPath The value of `--config` option. This is used to reset `cliConfigArray`.
124184 * @property {boolean} useEslintrc if `false` then it doesn't load config files.
124185 * @property {Function} loadRules The function to use to load rules.
124186 * @property {Map<string,Rule>} builtInRules The rules that are built in to ESLint.
124187 * @property {Object} [resolver=ModuleResolver] The module resolver object.
124188 * @property {string} eslintAllPath The path to the definitions for eslint:all.
124189 * @property {string} eslintRecommendedPath The path to the definitions for eslint:recommended.
124190 */
124191
124192 /** @type {WeakMap<CascadingConfigArrayFactory, CascadingConfigArrayFactoryInternalSlots>} */
124193 const internalSlotsMap = new WeakMap();
124194
124195 /**
124196 * Create the config array from `baseConfig` and `rulePaths`.
124197 * @param {CascadingConfigArrayFactoryInternalSlots} slots The slots.
124198 * @returns {ConfigArray} The config array of the base configs.
124199 */
124200 function createBaseConfigArray({
124201 configArrayFactory,
124202 baseConfigData,
124203 rulePaths,
124204 cwd,
124205 loadRules
124206 }) {
124207 const baseConfigArray = configArrayFactory.create(
124208 baseConfigData,
124209 { name: "BaseConfig" }
124210 );
124211
124212 /*
124213 * Create the config array element for the default ignore patterns.
124214 * This element has `ignorePattern` property that ignores the default
124215 * patterns in the current working directory.
124216 */
124217 baseConfigArray.unshift(configArrayFactory.create(
124218 { ignorePatterns: IgnorePattern.DefaultPatterns },
124219 { name: "DefaultIgnorePattern" }
124220 )[0]);
124221
124222 /*
124223 * Load rules `--rulesdir` option as a pseudo plugin.
124224 * Use a pseudo plugin to define rules of `--rulesdir`, so we can validate
124225 * the rule's options with only information in the config array.
124226 */
124227 if (rulePaths && rulePaths.length > 0) {
124228 baseConfigArray.push({
124229 type: "config",
124230 name: "--rulesdir",
124231 filePath: "",
124232 plugins: {
124233 "": new ConfigDependency({
124234 definition: {
124235 rules: rulePaths.reduce(
124236 (map, rulesPath) => Object.assign(
124237 map,
124238 loadRules(rulesPath, cwd)
124239 ),
124240 {}
124241 )
124242 },
124243 filePath: "",
124244 id: "",
124245 importerName: "--rulesdir",
124246 importerPath: ""
124247 })
124248 }
124249 });
124250 }
124251
124252 return baseConfigArray;
124253 }
124254
124255 /**
124256 * Create the config array from CLI options.
124257 * @param {CascadingConfigArrayFactoryInternalSlots} slots The slots.
124258 * @returns {ConfigArray} The config array of the base configs.
124259 */
124260 function createCLIConfigArray({
124261 cliConfigData,
124262 configArrayFactory,
124263 cwd,
124264 ignorePath,
124265 specificConfigPath
124266 }) {
124267 const cliConfigArray = configArrayFactory.create(
124268 cliConfigData,
124269 { name: "CLIOptions" }
124270 );
124271
124272 cliConfigArray.unshift(
124273 ...(ignorePath
124274 ? configArrayFactory.loadESLintIgnore(ignorePath)
124275 : configArrayFactory.loadDefaultESLintIgnore())
124276 );
124277
124278 if (specificConfigPath) {
124279 cliConfigArray.unshift(
124280 ...configArrayFactory.loadFile(
124281 specificConfigPath,
124282 { name: "--config", basePath: cwd }
124283 )
124284 );
124285 }
124286
124287 return cliConfigArray;
124288 }
124289
124290 /**
124291 * The error type when there are files matched by a glob, but all of them have been ignored.
124292 */
124293 class ConfigurationNotFoundError extends Error {
124294
124295 // eslint-disable-next-line jsdoc/require-description
124296 /**
124297 * @param {string} directoryPath The directory path.
124298 */
124299 constructor(directoryPath) {
124300 super(`No ESLint configuration found in ${directoryPath}.`);
124301 this.messageTemplate = "no-config-found";
124302 this.messageData = { directoryPath };
124303 }
124304 }
124305
124306 /**
124307 * This class provides the functionality that enumerates every file which is
124308 * matched by given glob patterns and that configuration.
124309 */
124310 class CascadingConfigArrayFactory {
124311
124312 /**
124313 * Initialize this enumerator.
124314 * @param {CascadingConfigArrayFactoryOptions} options The options.
124315 */
124316 constructor({
124317 additionalPluginPool = new Map(),
124318 baseConfig: baseConfigData = null,
124319 cliConfig: cliConfigData = null,
124320 cwd = process.cwd(),
124321 ignorePath,
124322 resolvePluginsRelativeTo,
124323 rulePaths = [],
124324 specificConfigPath = null,
124325 useEslintrc = true,
124326 builtInRules = new Map(),
124327 loadRules,
124328 resolver,
124329 eslintRecommendedPath,
124330 eslintAllPath
124331 } = {}) {
124332 const configArrayFactory = new ConfigArrayFactory({
124333 additionalPluginPool,
124334 cwd,
124335 resolvePluginsRelativeTo,
124336 builtInRules,
124337 resolver,
124338 eslintRecommendedPath,
124339 eslintAllPath
124340 });
124341
124342 internalSlotsMap.set(this, {
124343 baseConfigArray: createBaseConfigArray({
124344 baseConfigData,
124345 configArrayFactory,
124346 cwd,
124347 rulePaths,
124348 loadRules,
124349 resolver
124350 }),
124351 baseConfigData,
124352 cliConfigArray: createCLIConfigArray({
124353 cliConfigData,
124354 configArrayFactory,
124355 cwd,
124356 ignorePath,
124357 specificConfigPath
124358 }),
124359 cliConfigData,
124360 configArrayFactory,
124361 configCache: new Map(),
124362 cwd,
124363 finalizeCache: new WeakMap(),
124364 ignorePath,
124365 rulePaths,
124366 specificConfigPath,
124367 useEslintrc,
124368 builtInRules,
124369 loadRules
124370 });
124371 }
124372
124373 /**
124374 * The path to the current working directory.
124375 * This is used by tests.
124376 * @type {string}
124377 */
124378 get cwd() {
124379 const { cwd } = internalSlotsMap.get(this);
124380
124381 return cwd;
124382 }
124383
124384 /**
124385 * Get the config array of a given file.
124386 * If `filePath` was not given, it returns the config which contains only
124387 * `baseConfigData` and `cliConfigData`.
124388 * @param {string} [filePath] The file path to a file.
124389 * @param {Object} [options] The options.
124390 * @param {boolean} [options.ignoreNotFoundError] If `true` then it doesn't throw `ConfigurationNotFoundError`.
124391 * @returns {ConfigArray} The config array of the file.
124392 */
124393 getConfigArrayForFile(filePath, { ignoreNotFoundError = false } = {}) {
124394 const {
124395 baseConfigArray,
124396 cliConfigArray,
124397 cwd
124398 } = internalSlotsMap.get(this);
124399
124400 if (!filePath) {
124401 return new ConfigArray(...baseConfigArray, ...cliConfigArray);
124402 }
124403
124404 const directoryPath = path__default["default"].dirname(path__default["default"].resolve(cwd, filePath));
124405
124406 debug$1(`Load config files for ${directoryPath}.`);
124407
124408 return this._finalizeConfigArray(
124409 this._loadConfigInAncestors(directoryPath),
124410 directoryPath,
124411 ignoreNotFoundError
124412 );
124413 }
124414
124415 /**
124416 * Set the config data to override all configs.
124417 * Require to call `clearCache()` method after this method is called.
124418 * @param {ConfigData} configData The config data to override all configs.
124419 * @returns {void}
124420 */
124421 setOverrideConfig(configData) {
124422 const slots = internalSlotsMap.get(this);
124423
124424 slots.cliConfigData = configData;
124425 }
124426
124427 /**
124428 * Clear config cache.
124429 * @returns {void}
124430 */
124431 clearCache() {
124432 const slots = internalSlotsMap.get(this);
124433
124434 slots.baseConfigArray = createBaseConfigArray(slots);
124435 slots.cliConfigArray = createCLIConfigArray(slots);
124436 slots.configCache.clear();
124437 }
124438
124439 /**
124440 * Load and normalize config files from the ancestor directories.
124441 * @param {string} directoryPath The path to a leaf directory.
124442 * @param {boolean} configsExistInSubdirs `true` if configurations exist in subdirectories.
124443 * @returns {ConfigArray} The loaded config.
124444 * @private
124445 */
124446 _loadConfigInAncestors(directoryPath, configsExistInSubdirs = false) {
124447 const {
124448 baseConfigArray,
124449 configArrayFactory,
124450 configCache,
124451 cwd,
124452 useEslintrc
124453 } = internalSlotsMap.get(this);
124454
124455 if (!useEslintrc) {
124456 return baseConfigArray;
124457 }
124458
124459 let configArray = configCache.get(directoryPath);
124460
124461 // Hit cache.
124462 if (configArray) {
124463 debug$1(`Cache hit: ${directoryPath}.`);
124464 return configArray;
124465 }
124466 debug$1(`No cache found: ${directoryPath}.`);
124467
124468 const homePath = os__default["default"].homedir();
124469
124470 // Consider this is root.
124471 if (directoryPath === homePath && cwd !== homePath) {
124472 debug$1("Stop traversing because of considered root.");
124473 if (configsExistInSubdirs) {
124474 const filePath = ConfigArrayFactory.getPathToConfigFileInDirectory(directoryPath);
124475
124476 if (filePath) {
124477 emitDeprecationWarning(
124478 filePath,
124479 "ESLINT_PERSONAL_CONFIG_SUPPRESS"
124480 );
124481 }
124482 }
124483 return this._cacheConfig(directoryPath, baseConfigArray);
124484 }
124485
124486 // Load the config on this directory.
124487 try {
124488 configArray = configArrayFactory.loadInDirectory(directoryPath);
124489 } catch (error) {
124490 /* istanbul ignore next */
124491 if (error.code === "EACCES") {
124492 debug$1("Stop traversing because of 'EACCES' error.");
124493 return this._cacheConfig(directoryPath, baseConfigArray);
124494 }
124495 throw error;
124496 }
124497
124498 if (configArray.length > 0 && configArray.isRoot()) {
124499 debug$1("Stop traversing because of 'root:true'.");
124500 configArray.unshift(...baseConfigArray);
124501 return this._cacheConfig(directoryPath, configArray);
124502 }
124503
124504 // Load from the ancestors and merge it.
124505 const parentPath = path__default["default"].dirname(directoryPath);
124506 const parentConfigArray = parentPath && parentPath !== directoryPath
124507 ? this._loadConfigInAncestors(
124508 parentPath,
124509 configsExistInSubdirs || configArray.length > 0
124510 )
124511 : baseConfigArray;
124512
124513 if (configArray.length > 0) {
124514 configArray.unshift(...parentConfigArray);
124515 } else {
124516 configArray = parentConfigArray;
124517 }
124518
124519 // Cache and return.
124520 return this._cacheConfig(directoryPath, configArray);
124521 }
124522
124523 /**
124524 * Freeze and cache a given config.
124525 * @param {string} directoryPath The path to a directory as a cache key.
124526 * @param {ConfigArray} configArray The config array as a cache value.
124527 * @returns {ConfigArray} The `configArray` (frozen).
124528 */
124529 _cacheConfig(directoryPath, configArray) {
124530 const { configCache } = internalSlotsMap.get(this);
124531
124532 Object.freeze(configArray);
124533 configCache.set(directoryPath, configArray);
124534
124535 return configArray;
124536 }
124537
124538 /**
124539 * Finalize a given config array.
124540 * Concatenate `--config` and other CLI options.
124541 * @param {ConfigArray} configArray The parent config array.
124542 * @param {string} directoryPath The path to the leaf directory to find config files.
124543 * @param {boolean} ignoreNotFoundError If `true` then it doesn't throw `ConfigurationNotFoundError`.
124544 * @returns {ConfigArray} The loaded config.
124545 * @private
124546 */
124547 _finalizeConfigArray(configArray, directoryPath, ignoreNotFoundError) {
124548 const {
124549 cliConfigArray,
124550 configArrayFactory,
124551 finalizeCache,
124552 useEslintrc,
124553 builtInRules
124554 } = internalSlotsMap.get(this);
124555
124556 let finalConfigArray = finalizeCache.get(configArray);
124557
124558 if (!finalConfigArray) {
124559 finalConfigArray = configArray;
124560
124561 // Load the personal config if there are no regular config files.
124562 if (
124563 useEslintrc &&
124564 configArray.every(c => !c.filePath) &&
124565 cliConfigArray.every(c => !c.filePath) // `--config` option can be a file.
124566 ) {
124567 const homePath = os__default["default"].homedir();
124568
124569 debug$1("Loading the config file of the home directory:", homePath);
124570
124571 const personalConfigArray = configArrayFactory.loadInDirectory(
124572 homePath,
124573 { name: "PersonalConfig" }
124574 );
124575
124576 if (
124577 personalConfigArray.length > 0 &&
124578 !directoryPath.startsWith(homePath)
124579 ) {
124580 const lastElement =
124581 personalConfigArray[personalConfigArray.length - 1];
124582
124583 emitDeprecationWarning(
124584 lastElement.filePath,
124585 "ESLINT_PERSONAL_CONFIG_LOAD"
124586 );
124587 }
124588
124589 finalConfigArray = finalConfigArray.concat(personalConfigArray);
124590 }
124591
124592 // Apply CLI options.
124593 if (cliConfigArray.length > 0) {
124594 finalConfigArray = finalConfigArray.concat(cliConfigArray);
124595 }
124596
124597 // Validate rule settings and environments.
124598 const validator = new ConfigValidator({
124599 builtInRules
124600 });
124601
124602 validator.validateConfigArray(finalConfigArray);
124603
124604 // Cache it.
124605 Object.freeze(finalConfigArray);
124606 finalizeCache.set(configArray, finalConfigArray);
124607
124608 debug$1(
124609 "Configuration was determined: %o on %s",
124610 finalConfigArray,
124611 directoryPath
124612 );
124613 }
124614
124615 // At least one element (the default ignore patterns) exists.
124616 if (!ignoreNotFoundError && useEslintrc && finalConfigArray.length <= 1) {
124617 throw new ConfigurationNotFoundError(directoryPath);
124618 }
124619
124620 return finalConfigArray;
124621 }
124622 }
124623
124624 /**
124625 * @fileoverview Compatibility class for flat config.
124626 * @author Nicholas C. Zakas
124627 */
124628
124629 const dirname = path__default["default"].dirname(url.fileURLToPath((typeof document === 'undefined' ? new ((__webpack_require__(876).URL))('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('eslintrc.cjs', document.baseURI).href))));
124630
124631 //-----------------------------------------------------------------------------
124632 // Helpers
124633 //-----------------------------------------------------------------------------
124634
124635 /** @typedef {import("../../shared/types").Environment} Environment */
124636 /** @typedef {import("../../shared/types").Processor} Processor */
124637
124638 const debug = debugOrig__default["default"]("eslintrc:flat-compat");
124639 const cafactory = Symbol("cafactory");
124640
124641 /**
124642 * Translates an ESLintRC-style config object into a flag-config-style config
124643 * object.
124644 * @param {Object} eslintrcConfig An ESLintRC-style config object.
124645 * @param {Object} options Options to help translate the config.
124646 * @param {string} options.resolveConfigRelativeTo To the directory to resolve
124647 * configs from.
124648 * @param {string} options.resolvePluginsRelativeTo The directory to resolve
124649 * plugins from.
124650 * @param {ReadOnlyMap<string,Environment>} options.pluginEnvironments A map of plugin environment
124651 * names to objects.
124652 * @param {ReadOnlyMap<string,Processor>} options.pluginProcessors A map of plugin processor
124653 * names to objects.
124654 * @returns {Object} A flag-config-style config object.
124655 */
124656 function translateESLintRC(eslintrcConfig, {
124657 resolveConfigRelativeTo,
124658 resolvePluginsRelativeTo,
124659 pluginEnvironments,
124660 pluginProcessors
124661 }) {
124662
124663 const flatConfig = {};
124664 const configs = [];
124665 const languageOptions = {};
124666 const linterOptions = {};
124667 const keysToCopy = ["settings", "rules", "processor"];
124668 const languageOptionsKeysToCopy = ["globals", "parser", "parserOptions"];
124669 const linterOptionsKeysToCopy = ["noInlineConfig", "reportUnusedDisableDirectives"];
124670
124671 // check for special settings for eslint:all and eslint:recommended:
124672 if (eslintrcConfig.settings) {
124673 if (eslintrcConfig.settings["eslint:all"] === true) {
124674 return ["eslint:all"];
124675 }
124676
124677 if (eslintrcConfig.settings["eslint:recommended"] === true) {
124678 return ["eslint:recommended"];
124679 }
124680 }
124681
124682 // copy over simple translations
124683 for (const key of keysToCopy) {
124684 if (key in eslintrcConfig && typeof eslintrcConfig[key] !== "undefined") {
124685 flatConfig[key] = eslintrcConfig[key];
124686 }
124687 }
124688
124689 // copy over languageOptions
124690 for (const key of languageOptionsKeysToCopy) {
124691 if (key in eslintrcConfig && typeof eslintrcConfig[key] !== "undefined") {
124692
124693 // create the languageOptions key in the flat config
124694 flatConfig.languageOptions = languageOptions;
124695
124696 if (key === "parser") {
124697 debug(`Resolving parser '${languageOptions[key]}' relative to ${resolveConfigRelativeTo}`);
124698
124699 if (eslintrcConfig[key].error) {
124700 throw eslintrcConfig[key].error;
124701 }
124702
124703 languageOptions[key] = eslintrcConfig[key].definition;
124704 continue;
124705 }
124706
124707 // clone any object values that are in the eslintrc config
124708 if (eslintrcConfig[key] && typeof eslintrcConfig[key] === "object") {
124709 languageOptions[key] = {
124710 ...eslintrcConfig[key]
124711 };
124712 } else {
124713 languageOptions[key] = eslintrcConfig[key];
124714 }
124715 }
124716 }
124717
124718 // copy over linterOptions
124719 for (const key of linterOptionsKeysToCopy) {
124720 if (key in eslintrcConfig && typeof eslintrcConfig[key] !== "undefined") {
124721 flatConfig.linterOptions = linterOptions;
124722 linterOptions[key] = eslintrcConfig[key];
124723 }
124724 }
124725
124726 // move ecmaVersion a level up
124727 if (languageOptions.parserOptions) {
124728
124729 if ("ecmaVersion" in languageOptions.parserOptions) {
124730 languageOptions.ecmaVersion = languageOptions.parserOptions.ecmaVersion;
124731 delete languageOptions.parserOptions.ecmaVersion;
124732 }
124733
124734 if ("sourceType" in languageOptions.parserOptions) {
124735 languageOptions.sourceType = languageOptions.parserOptions.sourceType;
124736 delete languageOptions.parserOptions.sourceType;
124737 }
124738
124739 // check to see if we even need parserOptions anymore and remove it if not
124740 if (Object.keys(languageOptions.parserOptions).length === 0) {
124741 delete languageOptions.parserOptions;
124742 }
124743 }
124744
124745 // overrides
124746 if (eslintrcConfig.criteria) {
124747 flatConfig.files = [absoluteFilePath => eslintrcConfig.criteria.test(absoluteFilePath)];
124748 }
124749
124750 // translate plugins
124751 if (eslintrcConfig.plugins && typeof eslintrcConfig.plugins === "object") {
124752 debug(`Translating plugins: ${eslintrcConfig.plugins}`);
124753
124754 flatConfig.plugins = {};
124755
124756 for (const pluginName of Object.keys(eslintrcConfig.plugins)) {
124757
124758 debug(`Translating plugin: ${pluginName}`);
124759 debug(`Resolving plugin '${pluginName} relative to ${resolvePluginsRelativeTo}`);
124760
124761 const { definition: plugin, error } = eslintrcConfig.plugins[pluginName];
124762
124763 if (error) {
124764 throw error;
124765 }
124766
124767 flatConfig.plugins[pluginName] = plugin;
124768
124769 // create a config for any processors
124770 if (plugin.processors) {
124771 for (const processorName of Object.keys(plugin.processors)) {
124772 if (processorName.startsWith(".")) {
124773 debug(`Assigning processor: ${pluginName}/${processorName}`);
124774
124775 configs.unshift({
124776 files: [`**/*${processorName}`],
124777 processor: pluginProcessors.get(`${pluginName}/${processorName}`)
124778 });
124779 }
124780
124781 }
124782 }
124783 }
124784 }
124785
124786 // translate env - must come after plugins
124787 if (eslintrcConfig.env && typeof eslintrcConfig.env === "object") {
124788 for (const envName of Object.keys(eslintrcConfig.env)) {
124789
124790 // only add environments that are true
124791 if (eslintrcConfig.env[envName]) {
124792 debug(`Translating environment: ${envName}`);
124793
124794 if (environments.has(envName)) {
124795
124796 // built-in environments should be defined first
124797 configs.unshift(...translateESLintRC(environments.get(envName), {
124798 resolveConfigRelativeTo,
124799 resolvePluginsRelativeTo
124800 }));
124801 } else if (pluginEnvironments.has(envName)) {
124802
124803 // if the environment comes from a plugin, it should come after the plugin config
124804 configs.push(...translateESLintRC(pluginEnvironments.get(envName), {
124805 resolveConfigRelativeTo,
124806 resolvePluginsRelativeTo
124807 }));
124808 }
124809 }
124810 }
124811 }
124812
124813 // only add if there are actually keys in the config
124814 if (Object.keys(flatConfig).length > 0) {
124815 configs.push(flatConfig);
124816 }
124817
124818 return configs;
124819 }
124820
124821
124822 //-----------------------------------------------------------------------------
124823 // Exports
124824 //-----------------------------------------------------------------------------
124825
124826 /**
124827 * A compatibility class for working with configs.
124828 */
124829 class FlatCompat {
124830
124831 constructor({
124832 baseDirectory = process.cwd(),
124833 resolvePluginsRelativeTo = baseDirectory
124834 } = {}) {
124835 this.baseDirectory = baseDirectory;
124836 this.resolvePluginsRelativeTo = resolvePluginsRelativeTo;
124837 this[cafactory] = new ConfigArrayFactory({
124838 cwd: baseDirectory,
124839 resolvePluginsRelativeTo,
124840 eslintAllPath: path__default["default"].resolve(dirname, "../conf/eslint-all.cjs"),
124841 eslintRecommendedPath: path__default["default"].resolve(dirname, "../conf/eslint-recommended.cjs")
124842 });
124843 }
124844
124845 /**
124846 * Translates an ESLintRC-style config into a flag-config-style config.
124847 * @param {Object} eslintrcConfig The ESLintRC-style config object.
124848 * @returns {Object} A flag-config-style config object.
124849 */
124850 config(eslintrcConfig) {
124851 const eslintrcArray = this[cafactory].create(eslintrcConfig, {
124852 basePath: this.baseDirectory
124853 });
124854
124855 const flatArray = [];
124856 let hasIgnorePatterns = false;
124857
124858 eslintrcArray.forEach(configData => {
124859 if (configData.type === "config") {
124860 hasIgnorePatterns = hasIgnorePatterns || configData.ignorePattern;
124861 flatArray.push(...translateESLintRC(configData, {
124862 resolveConfigRelativeTo: path__default["default"].join(this.baseDirectory, "__placeholder.js"),
124863 resolvePluginsRelativeTo: path__default["default"].join(this.resolvePluginsRelativeTo, "__placeholder.js"),
124864 pluginEnvironments: eslintrcArray.pluginEnvironments,
124865 pluginProcessors: eslintrcArray.pluginProcessors
124866 }));
124867 }
124868 });
124869
124870 // combine ignorePatterns to emulate ESLintRC behavior better
124871 if (hasIgnorePatterns) {
124872 flatArray.unshift({
124873 ignores: [filePath => {
124874
124875 // Compute the final config for this file.
124876 // This filters config array elements by `files`/`excludedFiles` then merges the elements.
124877 const finalConfig = eslintrcArray.extractConfig(filePath);
124878
124879 // Test the `ignorePattern` properties of the final config.
124880 return Boolean(finalConfig.ignores) && finalConfig.ignores(filePath);
124881 }]
124882 });
124883 }
124884
124885 return flatArray;
124886 }
124887
124888 /**
124889 * Translates the `env` section of an ESLintRC-style config.
124890 * @param {Object} envConfig The `env` section of an ESLintRC config.
124891 * @returns {Object} A flag-config object representing the environments.
124892 */
124893 env(envConfig) {
124894 return this.config({
124895 env: envConfig
124896 });
124897 }
124898
124899 /**
124900 * Translates the `extends` section of an ESLintRC-style config.
124901 * @param {...string} configsToExtend The names of the configs to load.
124902 * @returns {Object} A flag-config object representing the config.
124903 */
124904 extends(...configsToExtend) {
124905 return this.config({
124906 extends: configsToExtend
124907 });
124908 }
124909
124910 /**
124911 * Translates the `plugins` section of an ESLintRC-style config.
124912 * @param {...string} plugins The names of the plugins to load.
124913 * @returns {Object} A flag-config object representing the plugins.
124914 */
124915 plugins(...plugins) {
124916 return this.config({
124917 plugins
124918 });
124919 }
124920 }
124921
124922 /**
124923 * @fileoverview Package exports for @eslint/eslintrc
124924 * @author Nicholas C. Zakas
124925 */
124926
124927 //-----------------------------------------------------------------------------
124928 // Exports
124929 //-----------------------------------------------------------------------------
124930
124931 const Legacy = {
124932 ConfigArray,
124933 createConfigArrayFactoryContext: createContext,
124934 CascadingConfigArrayFactory,
124935 ConfigArrayFactory,
124936 ConfigDependency,
124937 ExtractedConfig,
124938 IgnorePattern,
124939 OverrideTester,
124940 getUsedExtractedConfigs,
124941 environments,
124942
124943 // shared
124944 ConfigOps,
124945 ConfigValidator,
124946 ModuleResolver,
124947 naming
124948 };
124949
124950 exports.FlatCompat = FlatCompat;
124951 exports.Legacy = Legacy;
124952 //# sourceMappingURL=eslintrc.cjs.map
124953
124954
124955 /***/ }),
124956 /* 864 */
124957 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
124958
124959 "use strict";
124960
124961
124962 const path = __webpack_require__(429);
124963
124964 const resolveFrom = __webpack_require__(865);
124965
124966 const parentModule = __webpack_require__(867);
124967
124968 module.exports = moduleId => {
124969 if (typeof moduleId !== 'string') {
124970 throw new TypeError('Expected a string');
124971 }
124972
124973 const parentPath = parentModule(__filename);
124974 const cwd = parentPath ? path.dirname(parentPath) : __dirname;
124975 const filePath = resolveFrom(cwd, moduleId);
124976 const oldModule = __webpack_require__.c[filePath]; // Delete itself from module parent
124977
124978 if (oldModule && oldModule.parent) {
124979 let i = oldModule.parent.children.length;
124980
124981 while (i--) {
124982 if (oldModule.parent.children[i].id === filePath) {
124983 oldModule.parent.children.splice(i, 1);
124984 }
124985 }
124986 }
124987
124988 delete __webpack_require__.c[filePath]; // Delete module from cache
124989
124990 const parent = __webpack_require__.c[parentPath]; // If `filePath` and `parentPath` are the same, cache will already be deleted so we won't get a memory leak in next step
124991
124992 return parent === undefined ? __webpack_require__(869)(filePath) : parent.require(filePath); // In case cache doesn't have parent, fall back to normal require
124993 };
124994
124995 /***/ }),
124996 /* 865 */
124997 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
124998
124999 "use strict";
125000
125001
125002 const path = __webpack_require__(429);
125003
125004 const Module = __webpack_require__(866);
125005
125006 const fs = __webpack_require__(861);
125007
125008 const resolveFrom = (fromDir, moduleId, silent) => {
125009 if (typeof fromDir !== 'string') {
125010 throw new TypeError("Expected `fromDir` to be of type `string`, got `".concat(typeof fromDir, "`"));
125011 }
125012
125013 if (typeof moduleId !== 'string') {
125014 throw new TypeError("Expected `moduleId` to be of type `string`, got `".concat(typeof moduleId, "`"));
125015 }
125016
125017 try {
125018 fromDir = fs.realpathSync(fromDir);
125019 } catch (err) {
125020 if (err.code === 'ENOENT') {
125021 fromDir = path.resolve(fromDir);
125022 } else if (silent) {
125023 return null;
125024 } else {
125025 throw err;
125026 }
125027 }
125028
125029 const fromFile = path.join(fromDir, 'noop.js');
125030
125031 const resolveFileName = () => Module._resolveFilename(moduleId, {
125032 id: fromFile,
125033 filename: fromFile,
125034 paths: Module._nodeModulePaths(fromDir)
125035 });
125036
125037 if (silent) {
125038 try {
125039 return resolveFileName();
125040 } catch (err) {
125041 return null;
125042 }
125043 }
125044
125045 return resolveFileName();
125046 };
125047
125048 module.exports = (fromDir, moduleId) => resolveFrom(fromDir, moduleId);
125049
125050 module.exports.silent = (fromDir, moduleId) => resolveFrom(fromDir, moduleId, true);
125051
125052 /***/ }),
125053 /* 866 */
125054 /***/ ((module) => {
125055
125056 "use strict";
125057 module.exports = require("module");
125058
125059 /***/ }),
125060 /* 867 */
125061 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
125062
125063 "use strict";
125064
125065
125066 const callsites = __webpack_require__(868);
125067
125068 module.exports = filepath => {
125069 const stacks = callsites();
125070
125071 if (!filepath) {
125072 return stacks[2].getFileName();
125073 }
125074
125075 let seenVal = false; // Skip the first stack as it's this function
125076
125077 stacks.shift();
125078
125079 for (const stack of stacks) {
125080 const parentFilepath = stack.getFileName();
125081
125082 if (typeof parentFilepath !== 'string') {
125083 continue;
125084 }
125085
125086 if (parentFilepath === filepath) {
125087 seenVal = true;
125088 continue;
125089 } // Skip native modules
125090
125091
125092 if (parentFilepath === 'module.js') {
125093 continue;
125094 }
125095
125096 if (seenVal && parentFilepath !== filepath) {
125097 return parentFilepath;
125098 }
125099 }
125100 };
125101
125102 /***/ }),
125103 /* 868 */
125104 /***/ ((module) => {
125105
125106 "use strict";
125107
125108
125109 const callsites = () => {
125110 const _prepareStackTrace = Error.prepareStackTrace;
125111
125112 Error.prepareStackTrace = (_, stack) => stack;
125113
125114 const stack = new Error().stack.slice(1);
125115 Error.prepareStackTrace = _prepareStackTrace;
125116 return stack;
125117 };
125118
125119 module.exports = callsites; // TODO: Remove this for the next major release
125120
125121 module.exports["default"] = callsites;
125122
125123 /***/ }),
125124 /* 869 */
125125 /***/ ((module) => {
125126
125127 function webpackEmptyContext(req) {
125128 var e = new Error("Cannot find module '" + req + "'");
125129 e.code = 'MODULE_NOT_FOUND';
125130 throw e;
125131 }
125132 webpackEmptyContext.keys = () => ([]);
125133 webpackEmptyContext.resolve = webpackEmptyContext;
125134 webpackEmptyContext.id = 869;
125135 module.exports = webpackEmptyContext;
125136
125137 /***/ }),
125138 /* 870 */
125139 /***/ ((module) => {
125140
125141 "use strict";
125142
125143
125144 const singleComment = Symbol('singleComment');
125145 const multiComment = Symbol('multiComment');
125146
125147 const stripWithoutWhitespace = () => '';
125148
125149 const stripWithWhitespace = (string, start, end) => string.slice(start, end).replace(/\S/g, ' ');
125150
125151 const isEscaped = (jsonString, quotePosition) => {
125152 let index = quotePosition - 1;
125153 let backslashCount = 0;
125154
125155 while (jsonString[index] === '\\') {
125156 index -= 1;
125157 backslashCount += 1;
125158 }
125159
125160 return Boolean(backslashCount % 2);
125161 };
125162
125163 module.exports = function (jsonString) {
125164 let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
125165
125166 if (typeof jsonString !== 'string') {
125167 throw new TypeError("Expected argument `jsonString` to be a `string`, got `".concat(typeof jsonString, "`"));
125168 }
125169
125170 const strip = options.whitespace === false ? stripWithoutWhitespace : stripWithWhitespace;
125171 let insideString = false;
125172 let insideComment = false;
125173 let offset = 0;
125174 let result = '';
125175
125176 for (let i = 0; i < jsonString.length; i++) {
125177 const currentCharacter = jsonString[i];
125178 const nextCharacter = jsonString[i + 1];
125179
125180 if (!insideComment && currentCharacter === '"') {
125181 const escaped = isEscaped(jsonString, i);
125182
125183 if (!escaped) {
125184 insideString = !insideString;
125185 }
125186 }
125187
125188 if (insideString) {
125189 continue;
125190 }
125191
125192 if (!insideComment && currentCharacter + nextCharacter === '//') {
125193 result += jsonString.slice(offset, i);
125194 offset = i;
125195 insideComment = singleComment;
125196 i++;
125197 } else if (insideComment === singleComment && currentCharacter + nextCharacter === '\r\n') {
125198 i++;
125199 insideComment = false;
125200 result += strip(jsonString, offset, i);
125201 offset = i;
125202 continue;
125203 } else if (insideComment === singleComment && currentCharacter === '\n') {
125204 insideComment = false;
125205 result += strip(jsonString, offset, i);
125206 offset = i;
125207 } else if (!insideComment && currentCharacter + nextCharacter === '/*') {
125208 result += jsonString.slice(offset, i);
125209 offset = i;
125210 insideComment = multiComment;
125211 i++;
125212 continue;
125213 } else if (insideComment === multiComment && currentCharacter + nextCharacter === '*/') {
125214 i++;
125215 insideComment = false;
125216 result += strip(jsonString, offset, i + 1);
125217 offset = i + 1;
125218 continue;
125219 }
125220 }
125221
125222 return result + (insideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
125223 };
125224
125225 /***/ }),
125226 /* 871 */
125227 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
125228
125229 /* provided dependency */ var console = __webpack_require__(438);
125230 module.exports = minimatch;
125231 minimatch.Minimatch = Minimatch;
125232 var path = {
125233 sep: '/'
125234 };
125235
125236 try {
125237 path = __webpack_require__(429);
125238 } catch (er) {}
125239
125240 var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {};
125241
125242 var expand = __webpack_require__(872);
125243
125244 var plTypes = {
125245 '!': {
125246 open: '(?:(?!(?:',
125247 close: '))[^/]*?)'
125248 },
125249 '?': {
125250 open: '(?:',
125251 close: ')?'
125252 },
125253 '+': {
125254 open: '(?:',
125255 close: ')+'
125256 },
125257 '*': {
125258 open: '(?:',
125259 close: ')*'
125260 },
125261 '@': {
125262 open: '(?:',
125263 close: ')'
125264 }
125265 }; // any single thing other than /
125266 // don't need to escape / when using new RegExp()
125267
125268 var qmark = '[^/]'; // * => any number of characters
125269
125270 var star = qmark + '*?'; // ** when dots are allowed. Anything goes, except .. and .
125271 // not (^ or / followed by one or two dots followed by $ or /),
125272 // followed by anything, any number of times.
125273
125274 var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; // not a ^ or / followed by a dot,
125275 // followed by anything, any number of times.
125276
125277 var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; // characters that need to be escaped in RegExp.
125278
125279 var reSpecials = charSet('().*{}+?[]^$\\!'); // "abc" -> { a:true, b:true, c:true }
125280
125281 function charSet(s) {
125282 return s.split('').reduce(function (set, c) {
125283 set[c] = true;
125284 return set;
125285 }, {});
125286 } // normalizes slashes.
125287
125288
125289 var slashSplit = /\/+/;
125290 minimatch.filter = filter;
125291
125292 function filter(pattern, options) {
125293 options = options || {};
125294 return function (p, i, list) {
125295 return minimatch(p, pattern, options);
125296 };
125297 }
125298
125299 function ext(a, b) {
125300 a = a || {};
125301 b = b || {};
125302 var t = {};
125303 Object.keys(b).forEach(function (k) {
125304 t[k] = b[k];
125305 });
125306 Object.keys(a).forEach(function (k) {
125307 t[k] = a[k];
125308 });
125309 return t;
125310 }
125311
125312 minimatch.defaults = function (def) {
125313 if (!def || !Object.keys(def).length) return minimatch;
125314 var orig = minimatch;
125315
125316 var m = function minimatch(p, pattern, options) {
125317 return orig.minimatch(p, pattern, ext(def, options));
125318 };
125319
125320 m.Minimatch = function Minimatch(pattern, options) {
125321 return new orig.Minimatch(pattern, ext(def, options));
125322 };
125323
125324 return m;
125325 };
125326
125327 Minimatch.defaults = function (def) {
125328 if (!def || !Object.keys(def).length) return Minimatch;
125329 return minimatch.defaults(def).Minimatch;
125330 };
125331
125332 function minimatch(p, pattern, options) {
125333 if (typeof pattern !== 'string') {
125334 throw new TypeError('glob pattern string required');
125335 }
125336
125337 if (!options) options = {}; // shortcut: comments match nothing.
125338
125339 if (!options.nocomment && pattern.charAt(0) === '#') {
125340 return false;
125341 } // "" only matches ""
125342
125343
125344 if (pattern.trim() === '') return p === '';
125345 return new Minimatch(pattern, options).match(p);
125346 }
125347
125348 function Minimatch(pattern, options) {
125349 if (!(this instanceof Minimatch)) {
125350 return new Minimatch(pattern, options);
125351 }
125352
125353 if (typeof pattern !== 'string') {
125354 throw new TypeError('glob pattern string required');
125355 }
125356
125357 if (!options) options = {};
125358 pattern = pattern.trim(); // windows support: need to use /, not \
125359
125360 if (path.sep !== '/') {
125361 pattern = pattern.split(path.sep).join('/');
125362 }
125363
125364 this.options = options;
125365 this.set = [];
125366 this.pattern = pattern;
125367 this.regexp = null;
125368 this.negate = false;
125369 this.comment = false;
125370 this.empty = false; // make the set of regexps etc.
125371
125372 this.make();
125373 }
125374
125375 Minimatch.prototype.debug = function () {};
125376
125377 Minimatch.prototype.make = make;
125378
125379 function make() {
125380 // don't do it more than once.
125381 if (this._made) return;
125382 var pattern = this.pattern;
125383 var options = this.options; // empty patterns and comments match nothing.
125384
125385 if (!options.nocomment && pattern.charAt(0) === '#') {
125386 this.comment = true;
125387 return;
125388 }
125389
125390 if (!pattern) {
125391 this.empty = true;
125392 return;
125393 } // step 1: figure out negation, etc.
125394
125395
125396 this.parseNegate(); // step 2: expand braces
125397
125398 var set = this.globSet = this.braceExpand();
125399 if (options.debug) this.debug = console.error;
125400 this.debug(this.pattern, set); // step 3: now we have a set, so turn each one into a series of path-portion
125401 // matching patterns.
125402 // These will be regexps, except in the case of "**", which is
125403 // set to the GLOBSTAR object for globstar behavior,
125404 // and will not contain any / characters
125405
125406 set = this.globParts = set.map(function (s) {
125407 return s.split(slashSplit);
125408 });
125409 this.debug(this.pattern, set); // glob --> regexps
125410
125411 set = set.map(function (s, si, set) {
125412 return s.map(this.parse, this);
125413 }, this);
125414 this.debug(this.pattern, set); // filter out everything that didn't compile properly.
125415
125416 set = set.filter(function (s) {
125417 return s.indexOf(false) === -1;
125418 });
125419 this.debug(this.pattern, set);
125420 this.set = set;
125421 }
125422
125423 Minimatch.prototype.parseNegate = parseNegate;
125424
125425 function parseNegate() {
125426 var pattern = this.pattern;
125427 var negate = false;
125428 var options = this.options;
125429 var negateOffset = 0;
125430 if (options.nonegate) return;
125431
125432 for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) {
125433 negate = !negate;
125434 negateOffset++;
125435 }
125436
125437 if (negateOffset) this.pattern = pattern.substr(negateOffset);
125438 this.negate = negate;
125439 } // Brace expansion:
125440 // a{b,c}d -> abd acd
125441 // a{b,}c -> abc ac
125442 // a{0..3}d -> a0d a1d a2d a3d
125443 // a{b,c{d,e}f}g -> abg acdfg acefg
125444 // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
125445 //
125446 // Invalid sets are not expanded.
125447 // a{2..}b -> a{2..}b
125448 // a{b}c -> a{b}c
125449
125450
125451 minimatch.braceExpand = function (pattern, options) {
125452 return braceExpand(pattern, options);
125453 };
125454
125455 Minimatch.prototype.braceExpand = braceExpand;
125456
125457 function braceExpand(pattern, options) {
125458 if (!options) {
125459 if (this instanceof Minimatch) {
125460 options = this.options;
125461 } else {
125462 options = {};
125463 }
125464 }
125465
125466 pattern = typeof pattern === 'undefined' ? this.pattern : pattern;
125467
125468 if (typeof pattern === 'undefined') {
125469 throw new TypeError('undefined pattern');
125470 }
125471
125472 if (options.nobrace || !pattern.match(/\{.*\}/)) {
125473 // shortcut. no need to expand.
125474 return [pattern];
125475 }
125476
125477 return expand(pattern);
125478 } // parse a component of the expanded set.
125479 // At this point, no pattern may contain "/" in it
125480 // so we're going to return a 2d array, where each entry is the full
125481 // pattern, split on '/', and then turned into a regular expression.
125482 // A regexp is made at the end which joins each array with an
125483 // escaped /, and another full one which joins each regexp with |.
125484 //
125485 // Following the lead of Bash 4.1, note that "**" only has special meaning
125486 // when it is the *only* thing in a path portion. Otherwise, any series
125487 // of * is equivalent to a single *. Globstar behavior is enabled by
125488 // default, and can be disabled by setting options.noglobstar.
125489
125490
125491 Minimatch.prototype.parse = parse;
125492 var SUBPARSE = {};
125493
125494 function parse(pattern, isSub) {
125495 if (pattern.length > 1024 * 64) {
125496 throw new TypeError('pattern is too long');
125497 }
125498
125499 var options = this.options; // shortcuts
125500
125501 if (!options.noglobstar && pattern === '**') return GLOBSTAR;
125502 if (pattern === '') return '';
125503 var re = '';
125504 var hasMagic = !!options.nocase;
125505 var escaping = false; // ? => one single character
125506
125507 var patternListStack = [];
125508 var negativeLists = [];
125509 var stateChar;
125510 var inClass = false;
125511 var reClassStart = -1;
125512 var classStart = -1; // . and .. never match anything that doesn't start with .,
125513 // even when options.dot is set.
125514
125515 var patternStart = pattern.charAt(0) === '.' ? '' // anything
125516 // not (start or / followed by . or .. followed by / or end)
125517 : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)';
125518 var self = this;
125519
125520 function clearStateChar() {
125521 if (stateChar) {
125522 // we had some state-tracking character
125523 // that wasn't consumed by this pass.
125524 switch (stateChar) {
125525 case '*':
125526 re += star;
125527 hasMagic = true;
125528 break;
125529
125530 case '?':
125531 re += qmark;
125532 hasMagic = true;
125533 break;
125534
125535 default:
125536 re += '\\' + stateChar;
125537 break;
125538 }
125539
125540 self.debug('clearStateChar %j %j', stateChar, re);
125541 stateChar = false;
125542 }
125543 }
125544
125545 for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) {
125546 this.debug('%s\t%s %s %j', pattern, i, re, c); // skip over any that are escaped.
125547
125548 if (escaping && reSpecials[c]) {
125549 re += '\\' + c;
125550 escaping = false;
125551 continue;
125552 }
125553
125554 switch (c) {
125555 case '/':
125556 // completely not allowed, even escaped.
125557 // Should already be path-split by now.
125558 return false;
125559
125560 case '\\':
125561 clearStateChar();
125562 escaping = true;
125563 continue;
125564 // the various stateChar values
125565 // for the "extglob" stuff.
125566
125567 case '?':
125568 case '*':
125569 case '+':
125570 case '@':
125571 case '!':
125572 this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); // all of those are literals inside a class, except that
125573 // the glob [!a] means [^a] in regexp
125574
125575 if (inClass) {
125576 this.debug(' in class');
125577 if (c === '!' && i === classStart + 1) c = '^';
125578 re += c;
125579 continue;
125580 } // if we already have a stateChar, then it means
125581 // that there was something like ** or +? in there.
125582 // Handle the stateChar, then proceed with this one.
125583
125584
125585 self.debug('call clearStateChar %j', stateChar);
125586 clearStateChar();
125587 stateChar = c; // if extglob is disabled, then +(asdf|foo) isn't a thing.
125588 // just clear the statechar *now*, rather than even diving into
125589 // the patternList stuff.
125590
125591 if (options.noext) clearStateChar();
125592 continue;
125593
125594 case '(':
125595 if (inClass) {
125596 re += '(';
125597 continue;
125598 }
125599
125600 if (!stateChar) {
125601 re += '\\(';
125602 continue;
125603 }
125604
125605 patternListStack.push({
125606 type: stateChar,
125607 start: i - 1,
125608 reStart: re.length,
125609 open: plTypes[stateChar].open,
125610 close: plTypes[stateChar].close
125611 }); // negation is (?:(?!js)[^/]*)
125612
125613 re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
125614 this.debug('plType %j %j', stateChar, re);
125615 stateChar = false;
125616 continue;
125617
125618 case ')':
125619 if (inClass || !patternListStack.length) {
125620 re += '\\)';
125621 continue;
125622 }
125623
125624 clearStateChar();
125625 hasMagic = true;
125626 var pl = patternListStack.pop(); // negation is (?:(?!js)[^/]*)
125627 // The others are (?:<pattern>)<type>
125628
125629 re += pl.close;
125630
125631 if (pl.type === '!') {
125632 negativeLists.push(pl);
125633 }
125634
125635 pl.reEnd = re.length;
125636 continue;
125637
125638 case '|':
125639 if (inClass || !patternListStack.length || escaping) {
125640 re += '\\|';
125641 escaping = false;
125642 continue;
125643 }
125644
125645 clearStateChar();
125646 re += '|';
125647 continue;
125648 // these are mostly the same in regexp and glob
125649
125650 case '[':
125651 // swallow any state-tracking char before the [
125652 clearStateChar();
125653
125654 if (inClass) {
125655 re += '\\' + c;
125656 continue;
125657 }
125658
125659 inClass = true;
125660 classStart = i;
125661 reClassStart = re.length;
125662 re += c;
125663 continue;
125664
125665 case ']':
125666 // a right bracket shall lose its special
125667 // meaning and represent itself in
125668 // a bracket expression if it occurs
125669 // first in the list. -- POSIX.2 2.8.3.2
125670 if (i === classStart + 1 || !inClass) {
125671 re += '\\' + c;
125672 escaping = false;
125673 continue;
125674 } // handle the case where we left a class open.
125675 // "[z-a]" is valid, equivalent to "\[z-a\]"
125676
125677
125678 if (inClass) {
125679 // split where the last [ was, make sure we don't have
125680 // an invalid re. if so, re-walk the contents of the
125681 // would-be class to re-translate any characters that
125682 // were passed through as-is
125683 // TODO: It would probably be faster to determine this
125684 // without a try/catch and a new RegExp, but it's tricky
125685 // to do safely. For now, this is safe and works.
125686 var cs = pattern.substring(classStart + 1, i);
125687
125688 try {
125689 RegExp('[' + cs + ']');
125690 } catch (er) {
125691 // not a valid class!
125692 var sp = this.parse(cs, SUBPARSE);
125693 re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
125694 hasMagic = hasMagic || sp[1];
125695 inClass = false;
125696 continue;
125697 }
125698 } // finish up the class.
125699
125700
125701 hasMagic = true;
125702 inClass = false;
125703 re += c;
125704 continue;
125705
125706 default:
125707 // swallow any state char that wasn't consumed
125708 clearStateChar();
125709
125710 if (escaping) {
125711 // no need
125712 escaping = false;
125713 } else if (reSpecials[c] && !(c === '^' && inClass)) {
125714 re += '\\';
125715 }
125716
125717 re += c;
125718 } // switch
125719
125720 } // for
125721 // handle the case where we left a class open.
125722 // "[abc" is valid, equivalent to "\[abc"
125723
125724
125725 if (inClass) {
125726 // split where the last [ was, and escape it
125727 // this is a huge pita. We now have to re-walk
125728 // the contents of the would-be class to re-translate
125729 // any characters that were passed through as-is
125730 cs = pattern.substr(classStart + 1);
125731 sp = this.parse(cs, SUBPARSE);
125732 re = re.substr(0, reClassStart) + '\\[' + sp[0];
125733 hasMagic = hasMagic || sp[1];
125734 } // handle the case where we had a +( thing at the *end*
125735 // of the pattern.
125736 // each pattern list stack adds 3 chars, and we need to go through
125737 // and escape any | chars that were passed through as-is for the regexp.
125738 // Go through and escape them, taking care not to double-escape any
125739 // | chars that were already escaped.
125740
125741
125742 for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
125743 var tail = re.slice(pl.reStart + pl.open.length);
125744 this.debug('setting tail', re, pl); // maybe some even number of \, then maybe 1 \, followed by a |
125745
125746 tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
125747 if (!$2) {
125748 // the | isn't already escaped, so escape it.
125749 $2 = '\\';
125750 } // need to escape all those slashes *again*, without escaping the
125751 // one that we need for escaping the | character. As it works out,
125752 // escaping an even number of slashes can be done by simply repeating
125753 // it exactly after itself. That's why this trick works.
125754 //
125755 // I am sorry that you have to see this.
125756
125757
125758 return $1 + $1 + $2 + '|';
125759 });
125760 this.debug('tail=%j\n %s', tail, tail, pl, re);
125761 var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
125762 hasMagic = true;
125763 re = re.slice(0, pl.reStart) + t + '\\(' + tail;
125764 } // handle trailing things that only matter at the very end.
125765
125766
125767 clearStateChar();
125768
125769 if (escaping) {
125770 // trailing \\
125771 re += '\\\\';
125772 } // only need to apply the nodot start if the re starts with
125773 // something that could conceivably capture a dot
125774
125775
125776 var addPatternStart = false;
125777
125778 switch (re.charAt(0)) {
125779 case '.':
125780 case '[':
125781 case '(':
125782 addPatternStart = true;
125783 } // Hack to work around lack of negative lookbehind in JS
125784 // A pattern like: *.!(x).!(y|z) needs to ensure that a name
125785 // like 'a.xyz.yz' doesn't match. So, the first negative
125786 // lookahead, has to look ALL the way ahead, to the end of
125787 // the pattern.
125788
125789
125790 for (var n = negativeLists.length - 1; n > -1; n--) {
125791 var nl = negativeLists[n];
125792 var nlBefore = re.slice(0, nl.reStart);
125793 var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
125794 var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
125795 var nlAfter = re.slice(nl.reEnd);
125796 nlLast += nlAfter; // Handle nested stuff like *(*.js|!(*.json)), where open parens
125797 // mean that we should *not* include the ) in the bit that is considered
125798 // "after" the negated section.
125799
125800 var openParensBefore = nlBefore.split('(').length - 1;
125801 var cleanAfter = nlAfter;
125802
125803 for (i = 0; i < openParensBefore; i++) {
125804 cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
125805 }
125806
125807 nlAfter = cleanAfter;
125808 var dollar = '';
125809
125810 if (nlAfter === '' && isSub !== SUBPARSE) {
125811 dollar = '$';
125812 }
125813
125814 var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
125815 re = newRe;
125816 } // if the re is not "" at this point, then we need to make sure
125817 // it doesn't match against an empty path part.
125818 // Otherwise a/* will match a/, which it should not.
125819
125820
125821 if (re !== '' && hasMagic) {
125822 re = '(?=.)' + re;
125823 }
125824
125825 if (addPatternStart) {
125826 re = patternStart + re;
125827 } // parsing just a piece of a larger pattern.
125828
125829
125830 if (isSub === SUBPARSE) {
125831 return [re, hasMagic];
125832 } // skip the regexp for non-magical patterns
125833 // unescape anything in it, though, so that it'll be
125834 // an exact match against a file etc.
125835
125836
125837 if (!hasMagic) {
125838 return globUnescape(pattern);
125839 }
125840
125841 var flags = options.nocase ? 'i' : '';
125842
125843 try {
125844 var regExp = new RegExp('^' + re + '$', flags);
125845 } catch (er) {
125846 // If it was an invalid regular expression, then it can't match
125847 // anything. This trick looks for a character after the end of
125848 // the string, which is of course impossible, except in multi-line
125849 // mode, but it's not a /m regex.
125850 return new RegExp('$.');
125851 }
125852
125853 regExp._glob = pattern;
125854 regExp._src = re;
125855 return regExp;
125856 }
125857
125858 minimatch.makeRe = function (pattern, options) {
125859 return new Minimatch(pattern, options || {}).makeRe();
125860 };
125861
125862 Minimatch.prototype.makeRe = makeRe;
125863
125864 function makeRe() {
125865 if (this.regexp || this.regexp === false) return this.regexp; // at this point, this.set is a 2d array of partial
125866 // pattern strings, or "**".
125867 //
125868 // It's better to use .match(). This function shouldn't
125869 // be used, really, but it's pretty convenient sometimes,
125870 // when you just want to work with a regex.
125871
125872 var set = this.set;
125873
125874 if (!set.length) {
125875 this.regexp = false;
125876 return this.regexp;
125877 }
125878
125879 var options = this.options;
125880 var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
125881 var flags = options.nocase ? 'i' : '';
125882 var re = set.map(function (pattern) {
125883 return pattern.map(function (p) {
125884 return p === GLOBSTAR ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src;
125885 }).join('\\\/');
125886 }).join('|'); // must match entire pattern
125887 // ending in a * or ** will make it less strict.
125888
125889 re = '^(?:' + re + ')$'; // can match anything, as long as it's not this.
125890
125891 if (this.negate) re = '^(?!' + re + ').*$';
125892
125893 try {
125894 this.regexp = new RegExp(re, flags);
125895 } catch (ex) {
125896 this.regexp = false;
125897 }
125898
125899 return this.regexp;
125900 }
125901
125902 minimatch.match = function (list, pattern, options) {
125903 options = options || {};
125904 var mm = new Minimatch(pattern, options);
125905 list = list.filter(function (f) {
125906 return mm.match(f);
125907 });
125908
125909 if (mm.options.nonull && !list.length) {
125910 list.push(pattern);
125911 }
125912
125913 return list;
125914 };
125915
125916 Minimatch.prototype.match = match;
125917
125918 function match(f, partial) {
125919 this.debug('match', f, this.pattern); // short-circuit in the case of busted things.
125920 // comments, etc.
125921
125922 if (this.comment) return false;
125923 if (this.empty) return f === '';
125924 if (f === '/' && partial) return true;
125925 var options = this.options; // windows: need to use /, not \
125926
125927 if (path.sep !== '/') {
125928 f = f.split(path.sep).join('/');
125929 } // treat the test path as a set of pathparts.
125930
125931
125932 f = f.split(slashSplit);
125933 this.debug(this.pattern, 'split', f); // just ONE of the pattern sets in this.set needs to match
125934 // in order for it to be valid. If negating, then just one
125935 // match means that we have failed.
125936 // Either way, return on the first hit.
125937
125938 var set = this.set;
125939 this.debug(this.pattern, 'set', set); // Find the basename of the path by looking for the last non-empty segment
125940
125941 var filename;
125942 var i;
125943
125944 for (i = f.length - 1; i >= 0; i--) {
125945 filename = f[i];
125946 if (filename) break;
125947 }
125948
125949 for (i = 0; i < set.length; i++) {
125950 var pattern = set[i];
125951 var file = f;
125952
125953 if (options.matchBase && pattern.length === 1) {
125954 file = [filename];
125955 }
125956
125957 var hit = this.matchOne(file, pattern, partial);
125958
125959 if (hit) {
125960 if (options.flipNegate) return true;
125961 return !this.negate;
125962 }
125963 } // didn't get any hits. this is success if it's a negative
125964 // pattern, failure otherwise.
125965
125966
125967 if (options.flipNegate) return false;
125968 return this.negate;
125969 } // set partial to true to test if, for example,
125970 // "/a/b" matches the start of "/*/b/*/d"
125971 // Partial means, if you run out of file before you run
125972 // out of pattern, then that's fine, as long as all
125973 // the parts match.
125974
125975
125976 Minimatch.prototype.matchOne = function (file, pattern, partial) {
125977 var options = this.options;
125978 this.debug('matchOne', {
125979 'this': this,
125980 file: file,
125981 pattern: pattern
125982 });
125983 this.debug('matchOne', file.length, pattern.length);
125984
125985 for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
125986 this.debug('matchOne loop');
125987 var p = pattern[pi];
125988 var f = file[fi];
125989 this.debug(pattern, p, f); // should be impossible.
125990 // some invalid regexp stuff in the set.
125991
125992 if (p === false) return false;
125993
125994 if (p === GLOBSTAR) {
125995 this.debug('GLOBSTAR', [pattern, p, f]); // "**"
125996 // a/**/b/**/c would match the following:
125997 // a/b/x/y/z/c
125998 // a/x/y/z/b/c
125999 // a/b/x/b/x/c
126000 // a/b/c
126001 // To do this, take the rest of the pattern after
126002 // the **, and see if it would match the file remainder.
126003 // If so, return success.
126004 // If not, the ** "swallows" a segment, and try again.
126005 // This is recursively awful.
126006 //
126007 // a/**/b/**/c matching a/b/x/y/z/c
126008 // - a matches a
126009 // - doublestar
126010 // - matchOne(b/x/y/z/c, b/**/c)
126011 // - b matches b
126012 // - doublestar
126013 // - matchOne(x/y/z/c, c) -> no
126014 // - matchOne(y/z/c, c) -> no
126015 // - matchOne(z/c, c) -> no
126016 // - matchOne(c, c) yes, hit
126017
126018 var fr = fi;
126019 var pr = pi + 1;
126020
126021 if (pr === pl) {
126022 this.debug('** at the end'); // a ** at the end will just swallow the rest.
126023 // We have found a match.
126024 // however, it will not swallow /.x, unless
126025 // options.dot is set.
126026 // . and .. are *never* matched by **, for explosively
126027 // exponential reasons.
126028
126029 for (; fi < fl; fi++) {
126030 if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false;
126031 }
126032
126033 return true;
126034 } // ok, let's see if we can swallow whatever we can.
126035
126036
126037 while (fr < fl) {
126038 var swallowee = file[fr];
126039 this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); // XXX remove this slice. Just pass the start index.
126040
126041 if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
126042 this.debug('globstar found match!', fr, fl, swallowee); // found a match.
126043
126044 return true;
126045 } else {
126046 // can't swallow "." or ".." ever.
126047 // can only swallow ".foo" when explicitly asked.
126048 if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') {
126049 this.debug('dot detected!', file, fr, pattern, pr);
126050 break;
126051 } // ** swallows a segment, and continue.
126052
126053
126054 this.debug('globstar swallow a segment, and continue');
126055 fr++;
126056 }
126057 } // no match was found.
126058 // However, in partial mode, we can't say this is necessarily over.
126059 // If there's more *pattern* left, then
126060
126061
126062 if (partial) {
126063 // ran out of file
126064 this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
126065 if (fr === fl) return true;
126066 }
126067
126068 return false;
126069 } // something other than **
126070 // non-magic patterns just have to match exactly
126071 // patterns with magic have been turned into regexps.
126072
126073
126074 var hit;
126075
126076 if (typeof p === 'string') {
126077 if (options.nocase) {
126078 hit = f.toLowerCase() === p.toLowerCase();
126079 } else {
126080 hit = f === p;
126081 }
126082
126083 this.debug('string match', p, f, hit);
126084 } else {
126085 hit = f.match(p);
126086 this.debug('pattern match', p, f, hit);
126087 }
126088
126089 if (!hit) return false;
126090 } // Note: ending in / means that we'll get a final ""
126091 // at the end of the pattern. This can only match a
126092 // corresponding "" at the end of the file.
126093 // If the file ends in /, then it can only match a
126094 // a pattern that ends in /, unless the pattern just
126095 // doesn't have any more for it. But, a/b/ should *not*
126096 // match "a/b/*", even though "" matches against the
126097 // [^/]*? pattern, except in partial mode, where it might
126098 // simply not be reached yet.
126099 // However, a/b/ should still satisfy a/*
126100 // now either we fell off the end of the pattern, or we're done.
126101
126102
126103 if (fi === fl && pi === pl) {
126104 // ran out of pattern and filename at the same time.
126105 // an exact hit!
126106 return true;
126107 } else if (fi === fl) {
126108 // ran out of file, but still had pattern left.
126109 // this is ok if we're doing the match as part of
126110 // a glob fs traversal.
126111 return partial;
126112 } else if (pi === pl) {
126113 // ran out of pattern, still have file left.
126114 // this is only acceptable if we're on the very last
126115 // empty segment of a file with a trailing slash.
126116 // a/* should match a/b/
126117 var emptyFileEnd = fi === fl - 1 && file[fi] === '';
126118 return emptyFileEnd;
126119 } // should be unreachable.
126120
126121
126122 throw new Error('wtf?');
126123 }; // replace stuff like \* with *
126124
126125
126126 function globUnescape(s) {
126127 return s.replace(/\\(.)/g, '$1');
126128 }
126129
126130 function regExpEscape(s) {
126131 return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
126132 }
126133
126134 /***/ }),
126135 /* 872 */
126136 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
126137
126138 var concatMap = __webpack_require__(873);
126139
126140 var balanced = __webpack_require__(874);
126141
126142 module.exports = expandTop;
126143 var escSlash = '\0SLASH' + Math.random() + '\0';
126144 var escOpen = '\0OPEN' + Math.random() + '\0';
126145 var escClose = '\0CLOSE' + Math.random() + '\0';
126146 var escComma = '\0COMMA' + Math.random() + '\0';
126147 var escPeriod = '\0PERIOD' + Math.random() + '\0';
126148
126149 function numeric(str) {
126150 return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
126151 }
126152
126153 function escapeBraces(str) {
126154 return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod);
126155 }
126156
126157 function unescapeBraces(str) {
126158 return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.');
126159 } // Basically just str.split(","), but handling cases
126160 // where we have nested braced sections, which should be
126161 // treated as individual members, like {a,{b,c},d}
126162
126163
126164 function parseCommaParts(str) {
126165 if (!str) return [''];
126166 var parts = [];
126167 var m = balanced('{', '}', str);
126168 if (!m) return str.split(',');
126169 var pre = m.pre;
126170 var body = m.body;
126171 var post = m.post;
126172 var p = pre.split(',');
126173 p[p.length - 1] += '{' + body + '}';
126174 var postParts = parseCommaParts(post);
126175
126176 if (post.length) {
126177 p[p.length - 1] += postParts.shift();
126178 p.push.apply(p, postParts);
126179 }
126180
126181 parts.push.apply(parts, p);
126182 return parts;
126183 }
126184
126185 function expandTop(str) {
126186 if (!str) return []; // I don't know why Bash 4.3 does this, but it does.
126187 // Anything starting with {} will have the first two bytes preserved
126188 // but *only* at the top level, so {},a}b will not expand to anything,
126189 // but a{},b}c will be expanded to [a}c,abc].
126190 // One could argue that this is a bug in Bash, but since the goal of
126191 // this module is to match Bash's rules, we escape a leading {}
126192
126193 if (str.substr(0, 2) === '{}') {
126194 str = '\\{\\}' + str.substr(2);
126195 }
126196
126197 return expand(escapeBraces(str), true).map(unescapeBraces);
126198 }
126199
126200 function identity(e) {
126201 return e;
126202 }
126203
126204 function embrace(str) {
126205 return '{' + str + '}';
126206 }
126207
126208 function isPadded(el) {
126209 return /^-?0\d/.test(el);
126210 }
126211
126212 function lte(i, y) {
126213 return i <= y;
126214 }
126215
126216 function gte(i, y) {
126217 return i >= y;
126218 }
126219
126220 function expand(str, isTop) {
126221 var expansions = [];
126222 var m = balanced('{', '}', str);
126223 if (!m || /\$$/.test(m.pre)) return [str];
126224 var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
126225 var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
126226 var isSequence = isNumericSequence || isAlphaSequence;
126227 var isOptions = m.body.indexOf(',') >= 0;
126228
126229 if (!isSequence && !isOptions) {
126230 // {a},b}
126231 if (m.post.match(/,.*\}/)) {
126232 str = m.pre + '{' + m.body + escClose + m.post;
126233 return expand(str);
126234 }
126235
126236 return [str];
126237 }
126238
126239 var n;
126240
126241 if (isSequence) {
126242 n = m.body.split(/\.\./);
126243 } else {
126244 n = parseCommaParts(m.body);
126245
126246 if (n.length === 1) {
126247 // x{{a,b}}y ==> x{a}y x{b}y
126248 n = expand(n[0], false).map(embrace);
126249
126250 if (n.length === 1) {
126251 var post = m.post.length ? expand(m.post, false) : [''];
126252 return post.map(function (p) {
126253 return m.pre + n[0] + p;
126254 });
126255 }
126256 }
126257 } // at this point, n is the parts, and we know it's not a comma set
126258 // with a single entry.
126259 // no need to expand pre, since it is guaranteed to be free of brace-sets
126260
126261
126262 var pre = m.pre;
126263 var post = m.post.length ? expand(m.post, false) : [''];
126264 var N;
126265
126266 if (isSequence) {
126267 var x = numeric(n[0]);
126268 var y = numeric(n[1]);
126269 var width = Math.max(n[0].length, n[1].length);
126270 var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
126271 var test = lte;
126272 var reverse = y < x;
126273
126274 if (reverse) {
126275 incr *= -1;
126276 test = gte;
126277 }
126278
126279 var pad = n.some(isPadded);
126280 N = [];
126281
126282 for (var i = x; test(i, y); i += incr) {
126283 var c;
126284
126285 if (isAlphaSequence) {
126286 c = String.fromCharCode(i);
126287 if (c === '\\') c = '';
126288 } else {
126289 c = String(i);
126290
126291 if (pad) {
126292 var need = width - c.length;
126293
126294 if (need > 0) {
126295 var z = new Array(need + 1).join('0');
126296 if (i < 0) c = '-' + z + c.slice(1);else c = z + c;
126297 }
126298 }
126299 }
126300
126301 N.push(c);
126302 }
126303 } else {
126304 N = concatMap(n, function (el) {
126305 return expand(el, false);
126306 });
126307 }
126308
126309 for (var j = 0; j < N.length; j++) {
126310 for (var k = 0; k < post.length; k++) {
126311 var expansion = pre + N[j] + post[k];
126312 if (!isTop || isSequence || expansion) expansions.push(expansion);
126313 }
126314 }
126315
126316 return expansions;
126317 }
126318
126319 /***/ }),
126320 /* 873 */
126321 /***/ ((module) => {
126322
126323 module.exports = function (xs, fn) {
126324 var res = [];
126325
126326 for (var i = 0; i < xs.length; i++) {
126327 var x = fn(xs[i], i);
126328 if (isArray(x)) res.push.apply(res, x);else res.push(x);
126329 }
126330
126331 return res;
126332 };
126333
126334 var isArray = Array.isArray || function (xs) {
126335 return Object.prototype.toString.call(xs) === '[object Array]';
126336 };
126337
126338 /***/ }),
126339 /* 874 */
126340 /***/ ((module) => {
126341
126342 "use strict";
126343
126344
126345 module.exports = balanced;
126346
126347 function balanced(a, b, str) {
126348 if (a instanceof RegExp) a = maybeMatch(a, str);
126349 if (b instanceof RegExp) b = maybeMatch(b, str);
126350 var r = range(a, b, str);
126351 return r && {
126352 start: r[0],
126353 end: r[1],
126354 pre: str.slice(0, r[0]),
126355 body: str.slice(r[0] + a.length, r[1]),
126356 post: str.slice(r[1] + b.length)
126357 };
126358 }
126359
126360 function maybeMatch(reg, str) {
126361 var m = str.match(reg);
126362 return m ? m[0] : null;
126363 }
126364
126365 balanced.range = range;
126366
126367 function range(a, b, str) {
126368 var begs, beg, left, right, result;
126369 var ai = str.indexOf(a);
126370 var bi = str.indexOf(b, ai + 1);
126371 var i = ai;
126372
126373 if (ai >= 0 && bi > 0) {
126374 if (a === b) {
126375 return [ai, bi];
126376 }
126377
126378 begs = [];
126379 left = str.length;
126380
126381 while (i >= 0 && !result) {
126382 if (i == ai) {
126383 begs.push(i);
126384 ai = str.indexOf(a, i + 1);
126385 } else if (begs.length == 1) {
126386 result = [begs.pop(), bi];
126387 } else {
126388 beg = begs.pop();
126389
126390 if (beg < left) {
126391 left = beg;
126392 right = bi;
126393 }
126394
126395 bi = str.indexOf(b, i + 1);
126396 }
126397
126398 i = ai < bi && ai >= 0 ? ai : bi;
126399 }
126400
126401 if (begs.length) {
126402 result = [left, right];
126403 }
126404 }
126405
126406 return result;
126407 }
126408
126409 /***/ }),
126410 /* 875 */
126411 /***/ ((module) => {
126412
126413 "use strict";
126414 module.exports = require("os");
126415
126416 /***/ }),
126417 /* 876 */
126418 /***/ ((module) => {
126419
126420 "use strict";
126421 module.exports = require("url");
126422
126423 /***/ }),
126424 /* 877 */
126425 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
126426
126427 "use strict";
126428 /* provided dependency */ var process = __webpack_require__(494);
126429 /**
126430 * @fileoverview `FileEnumerator` class.
126431 *
126432 * `FileEnumerator` class has two responsibilities:
126433 *
126434 * 1. Find target files by processing glob patterns.
126435 * 2. Tie each target file and appropriate configuration.
126436 *
126437 * It provides a method:
126438 *
126439 * - `iterateFiles(patterns)`
126440 * Iterate files which are matched by given patterns together with the
126441 * corresponded configuration. This is for `CLIEngine#executeOnFiles()`.
126442 * While iterating files, it loads the configuration file of each directory
126443 * before iterate files on the directory, so we can use the configuration
126444 * files to determine target files.
126445 *
126446 * @example
126447 * const enumerator = new FileEnumerator();
126448 * const linter = new Linter();
126449 *
126450 * for (const { config, filePath } of enumerator.iterateFiles(["*.js"])) {
126451 * const code = fs.readFileSync(filePath, "utf8");
126452 * const messages = linter.verify(code, config, filePath);
126453 *
126454 * console.log(messages);
126455 * }
126456 *
126457 * @author Toru Nagashima <https://github.com/mysticatea>
126458 */
126459 //------------------------------------------------------------------------------
126460 // Requirements
126461 //------------------------------------------------------------------------------
126462
126463 const fs = __webpack_require__(861);
126464
126465 const path = __webpack_require__(429);
126466
126467 const getGlobParent = __webpack_require__(878);
126468
126469 const isGlob = __webpack_require__(879);
126470
126471 const escapeRegExp = __webpack_require__(525);
126472
126473 const {
126474 Minimatch
126475 } = __webpack_require__(871);
126476
126477 const {
126478 Legacy: {
126479 IgnorePattern,
126480 CascadingConfigArrayFactory
126481 }
126482 } = __webpack_require__(863);
126483
126484 const debug = __webpack_require__(496)("eslint:file-enumerator"); //------------------------------------------------------------------------------
126485 // Helpers
126486 //------------------------------------------------------------------------------
126487
126488
126489 const minimatchOpts = {
126490 dot: true,
126491 matchBase: true
126492 };
126493 const dotfilesPattern = /(?:(?:^\.)|(?:[/\\]\.))[^/\\.].*/u;
126494 const NONE = 0;
126495 const IGNORED_SILENTLY = 1;
126496 const IGNORED = 2; // For VSCode intellisense
126497
126498 /** @typedef {ReturnType<CascadingConfigArrayFactory.getConfigArrayForFile>} ConfigArray */
126499
126500 /**
126501 * @typedef {Object} FileEnumeratorOptions
126502 * @property {CascadingConfigArrayFactory} [configArrayFactory] The factory for config arrays.
126503 * @property {string} [cwd] The base directory to start lookup.
126504 * @property {string[]} [extensions] The extensions to match files for directory patterns.
126505 * @property {boolean} [globInputPaths] Set to false to skip glob resolution of input file paths to lint (default: true). If false, each input file paths is assumed to be a non-glob path to an existing file.
126506 * @property {boolean} [ignore] The flag to check ignored files.
126507 * @property {string[]} [rulePaths] The value of `--rulesdir` option.
126508 */
126509
126510 /**
126511 * @typedef {Object} FileAndConfig
126512 * @property {string} filePath The path to a target file.
126513 * @property {ConfigArray} config The config entries of that file.
126514 * @property {boolean} ignored If `true` then this file should be ignored and warned because it was directly specified.
126515 */
126516
126517 /**
126518 * @typedef {Object} FileEntry
126519 * @property {string} filePath The path to a target file.
126520 * @property {ConfigArray} config The config entries of that file.
126521 * @property {NONE|IGNORED_SILENTLY|IGNORED} flag The flag.
126522 * - `NONE` means the file is a target file.
126523 * - `IGNORED_SILENTLY` means the file should be ignored silently.
126524 * - `IGNORED` means the file should be ignored and warned because it was directly specified.
126525 */
126526
126527 /**
126528 * @typedef {Object} FileEnumeratorInternalSlots
126529 * @property {CascadingConfigArrayFactory} configArrayFactory The factory for config arrays.
126530 * @property {string} cwd The base directory to start lookup.
126531 * @property {RegExp|null} extensionRegExp The RegExp to test if a string ends with specific file extensions.
126532 * @property {boolean} globInputPaths Set to false to skip glob resolution of input file paths to lint (default: true). If false, each input file paths is assumed to be a non-glob path to an existing file.
126533 * @property {boolean} ignoreFlag The flag to check ignored files.
126534 * @property {(filePath:string, dot:boolean) => boolean} defaultIgnores The default predicate function to ignore files.
126535 */
126536
126537 /** @type {WeakMap<FileEnumerator, FileEnumeratorInternalSlots>} */
126538
126539 const internalSlotsMap = new WeakMap();
126540 /**
126541 * Check if a string is a glob pattern or not.
126542 * @param {string} pattern A glob pattern.
126543 * @returns {boolean} `true` if the string is a glob pattern.
126544 */
126545
126546 function isGlobPattern(pattern) {
126547 return isGlob(path.sep === "\\" ? pattern.replace(/\\/gu, "/") : pattern);
126548 }
126549 /**
126550 * Get stats of a given path.
126551 * @param {string} filePath The path to target file.
126552 * @throws {Error} As may be thrown by `fs.statSync`.
126553 * @returns {fs.Stats|null} The stats.
126554 * @private
126555 */
126556
126557
126558 function statSafeSync(filePath) {
126559 try {
126560 return fs.statSync(filePath);
126561 } catch (error) {
126562 /* istanbul ignore next */
126563 if (error.code !== "ENOENT") {
126564 throw error;
126565 }
126566
126567 return null;
126568 }
126569 }
126570 /**
126571 * Get filenames in a given path to a directory.
126572 * @param {string} directoryPath The path to target directory.
126573 * @throws {Error} As may be thrown by `fs.readdirSync`.
126574 * @returns {import("fs").Dirent[]} The filenames.
126575 * @private
126576 */
126577
126578
126579 function readdirSafeSync(directoryPath) {
126580 try {
126581 return fs.readdirSync(directoryPath, {
126582 withFileTypes: true
126583 });
126584 } catch (error) {
126585 /* istanbul ignore next */
126586 if (error.code !== "ENOENT") {
126587 throw error;
126588 }
126589
126590 return [];
126591 }
126592 }
126593 /**
126594 * Create a `RegExp` object to detect extensions.
126595 * @param {string[] | null} extensions The extensions to create.
126596 * @returns {RegExp | null} The created `RegExp` object or null.
126597 */
126598
126599
126600 function createExtensionRegExp(extensions) {
126601 if (extensions) {
126602 const normalizedExts = extensions.map(ext => escapeRegExp(ext.startsWith(".") ? ext.slice(1) : ext));
126603 return new RegExp(".\\.(?:".concat(normalizedExts.join("|"), ")$"), "u");
126604 }
126605
126606 return null;
126607 }
126608 /**
126609 * The error type when no files match a glob.
126610 */
126611
126612
126613 class NoFilesFoundError extends Error {
126614 /**
126615 * @param {string} pattern The glob pattern which was not found.
126616 * @param {boolean} globDisabled If `true` then the pattern was a glob pattern, but glob was disabled.
126617 */
126618 constructor(pattern, globDisabled) {
126619 super("No files matching '".concat(pattern, "' were found").concat(globDisabled ? " (glob was disabled)" : "", "."));
126620 this.messageTemplate = "file-not-found";
126621 this.messageData = {
126622 pattern,
126623 globDisabled
126624 };
126625 }
126626
126627 }
126628 /**
126629 * The error type when there are files matched by a glob, but all of them have been ignored.
126630 */
126631
126632
126633 class AllFilesIgnoredError extends Error {
126634 /**
126635 * @param {string} pattern The glob pattern which was not found.
126636 */
126637 constructor(pattern) {
126638 super("All files matched by '".concat(pattern, "' are ignored."));
126639 this.messageTemplate = "all-files-ignored";
126640 this.messageData = {
126641 pattern
126642 };
126643 }
126644
126645 }
126646 /**
126647 * This class provides the functionality that enumerates every file which is
126648 * matched by given glob patterns and that configuration.
126649 */
126650
126651
126652 class FileEnumerator {
126653 /**
126654 * Initialize this enumerator.
126655 * @param {FileEnumeratorOptions} options The options.
126656 */
126657 constructor() {
126658 let {
126659 cwd = process.cwd(),
126660 configArrayFactory = new CascadingConfigArrayFactory({
126661 cwd,
126662 eslintRecommendedPath: path.resolve(__dirname, "../../conf/eslint-recommended.js"),
126663 eslintAllPath: path.resolve(__dirname, "../../conf/eslint-all.js")
126664 }),
126665 extensions = null,
126666 globInputPaths = true,
126667 errorOnUnmatchedPattern = true,
126668 ignore = true
126669 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
126670 internalSlotsMap.set(this, {
126671 configArrayFactory,
126672 cwd,
126673 defaultIgnores: IgnorePattern.createDefaultIgnore(cwd),
126674 extensionRegExp: createExtensionRegExp(extensions),
126675 globInputPaths,
126676 errorOnUnmatchedPattern,
126677 ignoreFlag: ignore
126678 });
126679 }
126680 /**
126681 * Check if a given file is target or not.
126682 * @param {string} filePath The path to a candidate file.
126683 * @param {ConfigArray} [providedConfig] Optional. The configuration for the file.
126684 * @returns {boolean} `true` if the file is a target.
126685 */
126686
126687
126688 isTargetPath(filePath, providedConfig) {
126689 const {
126690 configArrayFactory,
126691 extensionRegExp
126692 } = internalSlotsMap.get(this); // If `--ext` option is present, use it.
126693
126694 if (extensionRegExp) {
126695 return extensionRegExp.test(filePath);
126696 } // `.js` file is target by default.
126697
126698
126699 if (filePath.endsWith(".js")) {
126700 return true;
126701 } // use `overrides[].files` to check additional targets.
126702
126703
126704 const config = providedConfig || configArrayFactory.getConfigArrayForFile(filePath, {
126705 ignoreNotFoundError: true
126706 });
126707 return config.isAdditionalTargetPath(filePath);
126708 }
126709 /**
126710 * Iterate files which are matched by given glob patterns.
126711 * @param {string|string[]} patternOrPatterns The glob patterns to iterate files.
126712 * @throws {NoFilesFoundError|AllFilesIgnoredError} On an unmatched pattern.
126713 * @returns {IterableIterator<FileAndConfig>} The found files.
126714 */
126715
126716
126717 *iterateFiles(patternOrPatterns) {
126718 const {
126719 globInputPaths,
126720 errorOnUnmatchedPattern
126721 } = internalSlotsMap.get(this);
126722 const patterns = Array.isArray(patternOrPatterns) ? patternOrPatterns : [patternOrPatterns];
126723 debug("Start to iterate files: %o", patterns); // The set of paths to remove duplicate.
126724
126725 const set = new Set();
126726
126727 for (const pattern of patterns) {
126728 let foundRegardlessOfIgnored = false;
126729 let found = false; // Skip empty string.
126730
126731 if (!pattern) {
126732 continue;
126733 } // Iterate files of this pattern.
126734
126735
126736 for (const {
126737 config,
126738 filePath,
126739 flag
126740 } of this._iterateFiles(pattern)) {
126741 foundRegardlessOfIgnored = true;
126742
126743 if (flag === IGNORED_SILENTLY) {
126744 continue;
126745 }
126746
126747 found = true; // Remove duplicate paths while yielding paths.
126748
126749 if (!set.has(filePath)) {
126750 set.add(filePath);
126751 yield {
126752 config,
126753 filePath,
126754 ignored: flag === IGNORED
126755 };
126756 }
126757 } // Raise an error if any files were not found.
126758
126759
126760 if (errorOnUnmatchedPattern) {
126761 if (!foundRegardlessOfIgnored) {
126762 throw new NoFilesFoundError(pattern, !globInputPaths && isGlob(pattern));
126763 }
126764
126765 if (!found) {
126766 throw new AllFilesIgnoredError(pattern);
126767 }
126768 }
126769 }
126770
126771 debug("Complete iterating files: ".concat(JSON.stringify(patterns)));
126772 }
126773 /**
126774 * Iterate files which are matched by a given glob pattern.
126775 * @param {string} pattern The glob pattern to iterate files.
126776 * @returns {IterableIterator<FileEntry>} The found files.
126777 */
126778
126779
126780 _iterateFiles(pattern) {
126781 const {
126782 cwd,
126783 globInputPaths
126784 } = internalSlotsMap.get(this);
126785 const absolutePath = path.resolve(cwd, pattern);
126786 const isDot = dotfilesPattern.test(pattern);
126787 const stat = statSafeSync(absolutePath);
126788
126789 if (stat && stat.isDirectory()) {
126790 return this._iterateFilesWithDirectory(absolutePath, isDot);
126791 }
126792
126793 if (stat && stat.isFile()) {
126794 return this._iterateFilesWithFile(absolutePath);
126795 }
126796
126797 if (globInputPaths && isGlobPattern(pattern)) {
126798 return this._iterateFilesWithGlob(absolutePath, isDot);
126799 }
126800
126801 return [];
126802 }
126803 /**
126804 * Iterate a file which is matched by a given path.
126805 * @param {string} filePath The path to the target file.
126806 * @returns {IterableIterator<FileEntry>} The found files.
126807 * @private
126808 */
126809
126810
126811 _iterateFilesWithFile(filePath) {
126812 debug("File: ".concat(filePath));
126813 const {
126814 configArrayFactory
126815 } = internalSlotsMap.get(this);
126816 const config = configArrayFactory.getConfigArrayForFile(filePath);
126817
126818 const ignored = this._isIgnoredFile(filePath, {
126819 config,
126820 direct: true
126821 });
126822
126823 const flag = ignored ? IGNORED : NONE;
126824 return [{
126825 config,
126826 filePath,
126827 flag
126828 }];
126829 }
126830 /**
126831 * Iterate files in a given path.
126832 * @param {string} directoryPath The path to the target directory.
126833 * @param {boolean} dotfiles If `true` then it doesn't skip dot files by default.
126834 * @returns {IterableIterator<FileEntry>} The found files.
126835 * @private
126836 */
126837
126838
126839 _iterateFilesWithDirectory(directoryPath, dotfiles) {
126840 debug("Directory: ".concat(directoryPath));
126841 return this._iterateFilesRecursive(directoryPath, {
126842 dotfiles,
126843 recursive: true,
126844 selector: null
126845 });
126846 }
126847 /**
126848 * Iterate files which are matched by a given glob pattern.
126849 * @param {string} pattern The glob pattern to iterate files.
126850 * @param {boolean} dotfiles If `true` then it doesn't skip dot files by default.
126851 * @returns {IterableIterator<FileEntry>} The found files.
126852 * @private
126853 */
126854
126855
126856 _iterateFilesWithGlob(pattern, dotfiles) {
126857 debug("Glob: ".concat(pattern));
126858 const directoryPath = path.resolve(getGlobParent(pattern));
126859 const globPart = pattern.slice(directoryPath.length + 1);
126860 /*
126861 * recursive if there are `**` or path separators in the glob part.
126862 * Otherwise, patterns such as `src/*.js`, it doesn't need recursive.
126863 */
126864
126865 const recursive = /\*\*|\/|\\/u.test(globPart);
126866 const selector = new Minimatch(pattern, minimatchOpts);
126867 debug("recursive? ".concat(recursive));
126868 return this._iterateFilesRecursive(directoryPath, {
126869 dotfiles,
126870 recursive,
126871 selector
126872 });
126873 }
126874 /**
126875 * Iterate files in a given path.
126876 * @param {string} directoryPath The path to the target directory.
126877 * @param {Object} options The options to iterate files.
126878 * @param {boolean} [options.dotfiles] If `true` then it doesn't skip dot files by default.
126879 * @param {boolean} [options.recursive] If `true` then it dives into sub directories.
126880 * @param {InstanceType<Minimatch>} [options.selector] The matcher to choose files.
126881 * @returns {IterableIterator<FileEntry>} The found files.
126882 * @private
126883 */
126884
126885
126886 *_iterateFilesRecursive(directoryPath, options) {
126887 debug("Enter the directory: ".concat(directoryPath));
126888 const {
126889 configArrayFactory
126890 } = internalSlotsMap.get(this);
126891 /** @type {ConfigArray|null} */
126892
126893 let config = null; // Enumerate the files of this directory.
126894
126895 for (const entry of readdirSafeSync(directoryPath)) {
126896 const filePath = path.join(directoryPath, entry.name);
126897 const fileInfo = entry.isSymbolicLink() ? statSafeSync(filePath) : entry;
126898
126899 if (!fileInfo) {
126900 continue;
126901 } // Check if the file is matched.
126902
126903
126904 if (fileInfo.isFile()) {
126905 if (!config) {
126906 config = configArrayFactory.getConfigArrayForFile(filePath,
126907 /*
126908 * We must ignore `ConfigurationNotFoundError` at this
126909 * point because we don't know if target files exist in
126910 * this directory.
126911 */
126912 {
126913 ignoreNotFoundError: true
126914 });
126915 }
126916
126917 const matched = options.selector // Started with a glob pattern; choose by the pattern.
126918 ? options.selector.match(filePath) // Started with a directory path; choose by file extensions.
126919 : this.isTargetPath(filePath, config);
126920
126921 if (matched) {
126922 const ignored = this._isIgnoredFile(filePath, { ...options,
126923 config
126924 });
126925
126926 const flag = ignored ? IGNORED_SILENTLY : NONE;
126927 debug("Yield: ".concat(entry.name).concat(ignored ? " but ignored" : ""));
126928 yield {
126929 config: configArrayFactory.getConfigArrayForFile(filePath),
126930 filePath,
126931 flag
126932 };
126933 } else {
126934 debug("Didn't match: ".concat(entry.name));
126935 } // Dive into the sub directory.
126936
126937 } else if (options.recursive && fileInfo.isDirectory()) {
126938 if (!config) {
126939 config = configArrayFactory.getConfigArrayForFile(filePath, {
126940 ignoreNotFoundError: true
126941 });
126942 }
126943
126944 const ignored = this._isIgnoredFile(filePath + path.sep, { ...options,
126945 config
126946 });
126947
126948 if (!ignored) {
126949 yield* this._iterateFilesRecursive(filePath, options);
126950 }
126951 }
126952 }
126953
126954 debug("Leave the directory: ".concat(directoryPath));
126955 }
126956 /**
126957 * Check if a given file should be ignored.
126958 * @param {string} filePath The path to a file to check.
126959 * @param {Object} options Options
126960 * @param {ConfigArray} [options.config] The config for this file.
126961 * @param {boolean} [options.dotfiles] If `true` then this is not ignore dot files by default.
126962 * @param {boolean} [options.direct] If `true` then this is a direct specified file.
126963 * @returns {boolean} `true` if the file should be ignored.
126964 * @private
126965 */
126966
126967
126968 _isIgnoredFile(filePath, _ref) {
126969 let {
126970 config: providedConfig,
126971 dotfiles = false,
126972 direct = false
126973 } = _ref;
126974 const {
126975 configArrayFactory,
126976 defaultIgnores,
126977 ignoreFlag
126978 } = internalSlotsMap.get(this);
126979
126980 if (ignoreFlag) {
126981 const config = providedConfig || configArrayFactory.getConfigArrayForFile(filePath, {
126982 ignoreNotFoundError: true
126983 });
126984 const ignores = config.extractConfig(filePath).ignores || defaultIgnores;
126985 return ignores(filePath, dotfiles);
126986 }
126987
126988 return !direct && defaultIgnores(filePath, dotfiles);
126989 }
126990
126991 } //------------------------------------------------------------------------------
126992 // Public Interface
126993 //------------------------------------------------------------------------------
126994
126995
126996 module.exports = {
126997 FileEnumerator
126998 };
126999
127000 /***/ }),
127001 /* 878 */
127002 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
127003
127004 "use strict";
127005
127006
127007 var isGlob = __webpack_require__(879);
127008
127009 var pathPosixDirname = (__webpack_require__(429).posix.dirname);
127010
127011 var isWin32 = (__webpack_require__(875).platform)() === 'win32';
127012 var slash = '/';
127013 var backslash = /\\/g;
127014 var escaped = /\\([!*?|[\](){}])/g;
127015 /**
127016 * @param {string} str
127017 * @param {Object} opts
127018 * @param {boolean} [opts.flipBackslashes=true]
127019 */
127020
127021 module.exports = function globParent(str, opts) {
127022 var options = Object.assign({
127023 flipBackslashes: true
127024 }, opts); // flip windows path separators
127025
127026 if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) {
127027 str = str.replace(backslash, slash);
127028 } // special case for strings ending in enclosure containing path separator
127029
127030
127031 if (isEnclosure(str)) {
127032 str += slash;
127033 } // preserves full path in case of trailing path separator
127034
127035
127036 str += 'a'; // remove path parts that are globby
127037
127038 do {
127039 str = pathPosixDirname(str);
127040 } while (isGlobby(str)); // remove escape chars and return result
127041
127042
127043 return str.replace(escaped, '$1');
127044 };
127045
127046 function isEnclosure(str) {
127047 var lastChar = str.slice(-1);
127048 var enclosureStart;
127049
127050 switch (lastChar) {
127051 case '}':
127052 enclosureStart = '{';
127053 break;
127054
127055 case ']':
127056 enclosureStart = '[';
127057 break;
127058
127059 default:
127060 return false;
127061 }
127062
127063 var foundIndex = str.indexOf(enclosureStart);
127064
127065 if (foundIndex < 0) {
127066 return false;
127067 }
127068
127069 return str.slice(foundIndex + 1, -1).includes(slash);
127070 }
127071
127072 function isGlobby(str) {
127073 if (/\([^()]+$/.test(str)) {
127074 return true;
127075 }
127076
127077 if (str[0] === '{' || str[0] === '[') {
127078 return true;
127079 }
127080
127081 if (/[^\\][{[]/.test(str)) {
127082 return true;
127083 }
127084
127085 return isGlob(str);
127086 }
127087
127088 /***/ }),
127089 /* 879 */
127090 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
127091
127092 /*!
127093 * is-glob <https://github.com/jonschlinkert/is-glob>
127094 *
127095 * Copyright (c) 2014-2017, Jon Schlinkert.
127096 * Released under the MIT License.
127097 */
127098 var isExtglob = __webpack_require__(880);
127099
127100 var chars = {
127101 '{': '}',
127102 '(': ')',
127103 '[': ']'
127104 };
127105
127106 var strictCheck = function (str) {
127107 if (str[0] === '!') {
127108 return true;
127109 }
127110
127111 var index = 0;
127112 var pipeIndex = -2;
127113 var closeSquareIndex = -2;
127114 var closeCurlyIndex = -2;
127115 var closeParenIndex = -2;
127116 var backSlashIndex = -2;
127117
127118 while (index < str.length) {
127119 if (str[index] === '*') {
127120 return true;
127121 }
127122
127123 if (str[index + 1] === '?' && /[\].+)]/.test(str[index])) {
127124 return true;
127125 }
127126
127127 if (closeSquareIndex !== -1 && str[index] === '[' && str[index + 1] !== ']') {
127128 if (closeSquareIndex < index) {
127129 closeSquareIndex = str.indexOf(']', index);
127130 }
127131
127132 if (closeSquareIndex > index) {
127133 if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) {
127134 return true;
127135 }
127136
127137 backSlashIndex = str.indexOf('\\', index);
127138
127139 if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) {
127140 return true;
127141 }
127142 }
127143 }
127144
127145 if (closeCurlyIndex !== -1 && str[index] === '{' && str[index + 1] !== '}') {
127146 closeCurlyIndex = str.indexOf('}', index);
127147
127148 if (closeCurlyIndex > index) {
127149 backSlashIndex = str.indexOf('\\', index);
127150
127151 if (backSlashIndex === -1 || backSlashIndex > closeCurlyIndex) {
127152 return true;
127153 }
127154 }
127155 }
127156
127157 if (closeParenIndex !== -1 && str[index] === '(' && str[index + 1] === '?' && /[:!=]/.test(str[index + 2]) && str[index + 3] !== ')') {
127158 closeParenIndex = str.indexOf(')', index);
127159
127160 if (closeParenIndex > index) {
127161 backSlashIndex = str.indexOf('\\', index);
127162
127163 if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) {
127164 return true;
127165 }
127166 }
127167 }
127168
127169 if (pipeIndex !== -1 && str[index] === '(' && str[index + 1] !== '|') {
127170 if (pipeIndex < index) {
127171 pipeIndex = str.indexOf('|', index);
127172 }
127173
127174 if (pipeIndex !== -1 && str[pipeIndex + 1] !== ')') {
127175 closeParenIndex = str.indexOf(')', pipeIndex);
127176
127177 if (closeParenIndex > pipeIndex) {
127178 backSlashIndex = str.indexOf('\\', pipeIndex);
127179
127180 if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) {
127181 return true;
127182 }
127183 }
127184 }
127185 }
127186
127187 if (str[index] === '\\') {
127188 var open = str[index + 1];
127189 index += 2;
127190 var close = chars[open];
127191
127192 if (close) {
127193 var n = str.indexOf(close, index);
127194
127195 if (n !== -1) {
127196 index = n + 1;
127197 }
127198 }
127199
127200 if (str[index] === '!') {
127201 return true;
127202 }
127203 } else {
127204 index++;
127205 }
127206 }
127207
127208 return false;
127209 };
127210
127211 var relaxedCheck = function (str) {
127212 if (str[0] === '!') {
127213 return true;
127214 }
127215
127216 var index = 0;
127217
127218 while (index < str.length) {
127219 if (/[*?{}()[\]]/.test(str[index])) {
127220 return true;
127221 }
127222
127223 if (str[index] === '\\') {
127224 var open = str[index + 1];
127225 index += 2;
127226 var close = chars[open];
127227
127228 if (close) {
127229 var n = str.indexOf(close, index);
127230
127231 if (n !== -1) {
127232 index = n + 1;
127233 }
127234 }
127235
127236 if (str[index] === '!') {
127237 return true;
127238 }
127239 } else {
127240 index++;
127241 }
127242 }
127243
127244 return false;
127245 };
127246
127247 module.exports = function isGlob(str, options) {
127248 if (typeof str !== 'string' || str === '') {
127249 return false;
127250 }
127251
127252 if (isExtglob(str)) {
127253 return true;
127254 }
127255
127256 var check = strictCheck; // optionally relax check
127257
127258 if (options && options.strict === false) {
127259 check = relaxedCheck;
127260 }
127261
127262 return check(str);
127263 };
127264
127265 /***/ }),
127266 /* 880 */
127267 /***/ ((module) => {
127268
127269 /*!
127270 * is-extglob <https://github.com/jonschlinkert/is-extglob>
127271 *
127272 * Copyright (c) 2014-2016, Jon Schlinkert.
127273 * Licensed under the MIT License.
127274 */
127275 module.exports = function isExtglob(str) {
127276 if (typeof str !== 'string' || str === '') {
127277 return false;
127278 }
127279
127280 var match;
127281
127282 while (match = /(\\).|([@?!+*]\(.*\))/g.exec(str)) {
127283 if (match[2]) return true;
127284 str = str.slice(match.index + match[0].length);
127285 }
127286
127287 return false;
127288 };
127289
127290 /***/ }),
127291 /* 881 */
127292 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
127293
127294 "use strict";
127295
127296
127297 const {
127298 Linter
127299 } = __webpack_require__(428);
127300
127301 const interpolate = __webpack_require__(543);
127302
127303 const SourceCodeFixer = __webpack_require__(856);
127304
127305 module.exports = {
127306 Linter,
127307 // For testers.
127308 SourceCodeFixer,
127309 interpolate
127310 };
127311
127312 /***/ }),
127313 /* 882 */
127314 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
127315
127316 "use strict";
127317 /**
127318 * @fileoverview Module for loading rules from files and directories.
127319 * @author Michael Ficarra
127320 */
127321 //------------------------------------------------------------------------------
127322 // Requirements
127323 //------------------------------------------------------------------------------
127324
127325 const fs = __webpack_require__(861),
127326 path = __webpack_require__(429);
127327
127328 const rulesDirCache = {}; //------------------------------------------------------------------------------
127329 // Public Interface
127330 //------------------------------------------------------------------------------
127331
127332 /**
127333 * Load all rule modules from specified directory.
127334 * @param {string} relativeRulesDir Path to rules directory, may be relative.
127335 * @param {string} cwd Current working directory
127336 * @returns {Object} Loaded rule modules.
127337 */
127338
127339 module.exports = function (relativeRulesDir, cwd) {
127340 const rulesDir = path.resolve(cwd, relativeRulesDir); // cache will help performance as IO operation are expensive
127341
127342 if (rulesDirCache[rulesDir]) {
127343 return rulesDirCache[rulesDir];
127344 }
127345
127346 const rules = Object.create(null);
127347 fs.readdirSync(rulesDir).forEach(file => {
127348 if (path.extname(file) !== ".js") {
127349 return;
127350 }
127351
127352 rules[file.slice(0, -3)] = __webpack_require__(883)(path.join(rulesDir, file));
127353 });
127354 rulesDirCache[rulesDir] = rules;
127355 return rules;
127356 };
127357
127358 /***/ }),
127359 /* 883 */
127360 /***/ ((module) => {
127361
127362 function webpackEmptyContext(req) {
127363 var e = new Error("Cannot find module '" + req + "'");
127364 e.code = 'MODULE_NOT_FOUND';
127365 throw e;
127366 }
127367 webpackEmptyContext.keys = () => ([]);
127368 webpackEmptyContext.resolve = webpackEmptyContext;
127369 webpackEmptyContext.id = 883;
127370 module.exports = webpackEmptyContext;
127371
127372 /***/ }),
127373 /* 884 */
127374 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
127375
127376 "use strict";
127377 /**
127378 * @fileoverview Defining the hashing function in one place.
127379 * @author Michael Ficarra
127380 */
127381 //------------------------------------------------------------------------------
127382 // Requirements
127383 //------------------------------------------------------------------------------
127384
127385 const murmur = __webpack_require__(885); //------------------------------------------------------------------------------
127386 // Helpers
127387 //------------------------------------------------------------------------------
127388 //------------------------------------------------------------------------------
127389 // Private
127390 //------------------------------------------------------------------------------
127391
127392 /**
127393 * hash the given string
127394 * @param {string} str the string to hash
127395 * @returns {string} the hash
127396 */
127397
127398
127399 function hash(str) {
127400 return murmur(str).result().toString(36);
127401 } //------------------------------------------------------------------------------
127402 // Public Interface
127403 //------------------------------------------------------------------------------
127404
127405
127406 module.exports = hash;
127407
127408 /***/ }),
127409 /* 885 */
127410 /***/ ((module) => {
127411
127412 /**
127413 * @preserve
127414 * JS Implementation of incremental MurmurHash3 (r150) (as of May 10, 2013)
127415 *
127416 * @author <a href="mailto:jensyt@gmail.com">Jens Taylor</a>
127417 * @see http://github.com/homebrewing/brauhaus-diff
127418 * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
127419 * @see http://github.com/garycourt/murmurhash-js
127420 * @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
127421 * @see http://sites.google.com/site/murmurhash/
127422 */
127423 (function () {
127424 var cache; // Call this function without `new` to use the cached object (good for
127425 // single-threaded environments), or with `new` to create a new object.
127426 //
127427 // @param {string} key A UTF-16 or ASCII string
127428 // @param {number} seed An optional positive integer
127429 // @return {object} A MurmurHash3 object for incremental hashing
127430
127431 function MurmurHash3(key, seed) {
127432 var m = this instanceof MurmurHash3 ? this : cache;
127433 m.reset(seed);
127434
127435 if (typeof key === 'string' && key.length > 0) {
127436 m.hash(key);
127437 }
127438
127439 if (m !== this) {
127440 return m;
127441 }
127442 }
127443
127444 ; // Incrementally add a string to this hash
127445 //
127446 // @param {string} key A UTF-16 or ASCII string
127447 // @return {object} this
127448
127449 MurmurHash3.prototype.hash = function (key) {
127450 var h1, k1, i, top, len;
127451 len = key.length;
127452 this.len += len;
127453 k1 = this.k1;
127454 i = 0;
127455
127456 switch (this.rem) {
127457 case 0:
127458 k1 ^= len > i ? key.charCodeAt(i++) & 0xffff : 0;
127459
127460 case 1:
127461 k1 ^= len > i ? (key.charCodeAt(i++) & 0xffff) << 8 : 0;
127462
127463 case 2:
127464 k1 ^= len > i ? (key.charCodeAt(i++) & 0xffff) << 16 : 0;
127465
127466 case 3:
127467 k1 ^= len > i ? (key.charCodeAt(i) & 0xff) << 24 : 0;
127468 k1 ^= len > i ? (key.charCodeAt(i++) & 0xff00) >> 8 : 0;
127469 }
127470
127471 this.rem = len + this.rem & 3; // & 3 is same as % 4
127472
127473 len -= this.rem;
127474
127475 if (len > 0) {
127476 h1 = this.h1;
127477
127478 while (1) {
127479 k1 = k1 * 0x2d51 + (k1 & 0xffff) * 0xcc9e0000 & 0xffffffff;
127480 k1 = k1 << 15 | k1 >>> 17;
127481 k1 = k1 * 0x3593 + (k1 & 0xffff) * 0x1b870000 & 0xffffffff;
127482 h1 ^= k1;
127483 h1 = h1 << 13 | h1 >>> 19;
127484 h1 = h1 * 5 + 0xe6546b64 & 0xffffffff;
127485
127486 if (i >= len) {
127487 break;
127488 }
127489
127490 k1 = key.charCodeAt(i++) & 0xffff ^ (key.charCodeAt(i++) & 0xffff) << 8 ^ (key.charCodeAt(i++) & 0xffff) << 16;
127491 top = key.charCodeAt(i++);
127492 k1 ^= (top & 0xff) << 24 ^ (top & 0xff00) >> 8;
127493 }
127494
127495 k1 = 0;
127496
127497 switch (this.rem) {
127498 case 3:
127499 k1 ^= (key.charCodeAt(i + 2) & 0xffff) << 16;
127500
127501 case 2:
127502 k1 ^= (key.charCodeAt(i + 1) & 0xffff) << 8;
127503
127504 case 1:
127505 k1 ^= key.charCodeAt(i) & 0xffff;
127506 }
127507
127508 this.h1 = h1;
127509 }
127510
127511 this.k1 = k1;
127512 return this;
127513 }; // Get the result of this hash
127514 //
127515 // @return {number} The 32-bit hash
127516
127517
127518 MurmurHash3.prototype.result = function () {
127519 var k1, h1;
127520 k1 = this.k1;
127521 h1 = this.h1;
127522
127523 if (k1 > 0) {
127524 k1 = k1 * 0x2d51 + (k1 & 0xffff) * 0xcc9e0000 & 0xffffffff;
127525 k1 = k1 << 15 | k1 >>> 17;
127526 k1 = k1 * 0x3593 + (k1 & 0xffff) * 0x1b870000 & 0xffffffff;
127527 h1 ^= k1;
127528 }
127529
127530 h1 ^= this.len;
127531 h1 ^= h1 >>> 16;
127532 h1 = h1 * 0xca6b + (h1 & 0xffff) * 0x85eb0000 & 0xffffffff;
127533 h1 ^= h1 >>> 13;
127534 h1 = h1 * 0xae35 + (h1 & 0xffff) * 0xc2b20000 & 0xffffffff;
127535 h1 ^= h1 >>> 16;
127536 return h1 >>> 0;
127537 }; // Reset the hash object for reuse
127538 //
127539 // @param {number} seed An optional positive integer
127540
127541
127542 MurmurHash3.prototype.reset = function (seed) {
127543 this.h1 = typeof seed === 'number' ? seed : 0;
127544 this.rem = this.k1 = this.len = 0;
127545 return this;
127546 }; // A cached object to use. This can be safely used if you're in a single-
127547 // threaded environment, otherwise you need to create new hashes to use.
127548
127549
127550 cache = new MurmurHash3();
127551
127552 if (true) {
127553 module.exports = MurmurHash3;
127554 } else {}
127555 })();
127556
127557 /***/ }),
127558 /* 886 */
127559 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
127560
127561 "use strict";
127562 /* provided dependency */ var process = __webpack_require__(494);
127563 /**
127564 * @fileoverview Utility for caching lint results.
127565 * @author Kevin Partington
127566 */
127567 //-----------------------------------------------------------------------------
127568 // Requirements
127569 //-----------------------------------------------------------------------------
127570
127571 const assert = __webpack_require__(431);
127572
127573 const fs = __webpack_require__(861);
127574
127575 const fileEntryCache = __webpack_require__(887);
127576
127577 const stringify = __webpack_require__(905);
127578
127579 const pkg = __webpack_require__(443);
127580
127581 const hash = __webpack_require__(884);
127582
127583 const debug = __webpack_require__(496)("eslint:lint-result-cache"); //-----------------------------------------------------------------------------
127584 // Helpers
127585 //-----------------------------------------------------------------------------
127586
127587
127588 const configHashCache = new WeakMap();
127589 const nodeVersion = process && process.version;
127590 const validCacheStrategies = ["metadata", "content"];
127591 const invalidCacheStrategyErrorMessage = "Cache strategy must be one of: ".concat(validCacheStrategies.map(strategy => "\"".concat(strategy, "\"")).join(", "));
127592 /**
127593 * Tests whether a provided cacheStrategy is valid
127594 * @param {string} cacheStrategy The cache strategy to use
127595 * @returns {boolean} true if `cacheStrategy` is one of `validCacheStrategies`; false otherwise
127596 */
127597
127598 function isValidCacheStrategy(cacheStrategy) {
127599 return validCacheStrategies.indexOf(cacheStrategy) !== -1;
127600 }
127601 /**
127602 * Calculates the hash of the config
127603 * @param {ConfigArray} config The config.
127604 * @returns {string} The hash of the config
127605 */
127606
127607
127608 function hashOfConfigFor(config) {
127609 if (!configHashCache.has(config)) {
127610 configHashCache.set(config, hash("".concat(pkg.version, "_").concat(nodeVersion, "_").concat(stringify(config))));
127611 }
127612
127613 return configHashCache.get(config);
127614 } //-----------------------------------------------------------------------------
127615 // Public Interface
127616 //-----------------------------------------------------------------------------
127617
127618 /**
127619 * Lint result cache. This wraps around the file-entry-cache module,
127620 * transparently removing properties that are difficult or expensive to
127621 * serialize and adding them back in on retrieval.
127622 */
127623
127624
127625 class LintResultCache {
127626 /**
127627 * Creates a new LintResultCache instance.
127628 * @param {string} cacheFileLocation The cache file location.
127629 * @param {"metadata" | "content"} cacheStrategy The cache strategy to use.
127630 */
127631 constructor(cacheFileLocation, cacheStrategy) {
127632 assert(cacheFileLocation, "Cache file location is required");
127633 assert(cacheStrategy, "Cache strategy is required");
127634 assert(isValidCacheStrategy(cacheStrategy), invalidCacheStrategyErrorMessage);
127635 debug("Caching results to ".concat(cacheFileLocation));
127636 const useChecksum = cacheStrategy === "content";
127637 debug("Using \"".concat(cacheStrategy, "\" strategy to detect changes"));
127638 this.fileEntryCache = fileEntryCache.create(cacheFileLocation, void 0, useChecksum);
127639 this.cacheFileLocation = cacheFileLocation;
127640 }
127641 /**
127642 * Retrieve cached lint results for a given file path, if present in the
127643 * cache. If the file is present and has not been changed, rebuild any
127644 * missing result information.
127645 * @param {string} filePath The file for which to retrieve lint results.
127646 * @param {ConfigArray} config The config of the file.
127647 * @returns {Object|null} The rebuilt lint results, or null if the file is
127648 * changed or not in the filesystem.
127649 */
127650
127651
127652 getCachedLintResults(filePath, config) {
127653 /*
127654 * Cached lint results are valid if and only if:
127655 * 1. The file is present in the filesystem
127656 * 2. The file has not changed since the time it was previously linted
127657 * 3. The ESLint configuration has not changed since the time the file
127658 * was previously linted
127659 * If any of these are not true, we will not reuse the lint results.
127660 */
127661 const fileDescriptor = this.fileEntryCache.getFileDescriptor(filePath);
127662 const hashOfConfig = hashOfConfigFor(config);
127663 const changed = fileDescriptor.changed || fileDescriptor.meta.hashOfConfig !== hashOfConfig;
127664
127665 if (fileDescriptor.notFound) {
127666 debug("File not found on the file system: ".concat(filePath));
127667 return null;
127668 }
127669
127670 if (changed) {
127671 debug("Cache entry not found or no longer valid: ".concat(filePath));
127672 return null;
127673 } // If source is present but null, need to reread the file from the filesystem.
127674
127675
127676 if (fileDescriptor.meta.results && fileDescriptor.meta.results.source === null) {
127677 debug("Rereading cached result source from filesystem: ".concat(filePath));
127678 fileDescriptor.meta.results.source = fs.readFileSync(filePath, "utf-8");
127679 }
127680
127681 return fileDescriptor.meta.results;
127682 }
127683 /**
127684 * Set the cached lint results for a given file path, after removing any
127685 * information that will be both unnecessary and difficult to serialize.
127686 * Avoids caching results with an "output" property (meaning fixes were
127687 * applied), to prevent potentially incorrect results if fixes are not
127688 * written to disk.
127689 * @param {string} filePath The file for which to set lint results.
127690 * @param {ConfigArray} config The config of the file.
127691 * @param {Object} result The lint result to be set for the file.
127692 * @returns {void}
127693 */
127694
127695
127696 setCachedLintResults(filePath, config, result) {
127697 if (result && Object.prototype.hasOwnProperty.call(result, "output")) {
127698 return;
127699 }
127700
127701 const fileDescriptor = this.fileEntryCache.getFileDescriptor(filePath);
127702
127703 if (fileDescriptor && !fileDescriptor.notFound) {
127704 debug("Updating cached result: ".concat(filePath)); // Serialize the result, except that we want to remove the file source if present.
127705
127706 const resultToSerialize = Object.assign({}, result);
127707 /*
127708 * Set result.source to null.
127709 * In `getCachedLintResults`, if source is explicitly null, we will
127710 * read the file from the filesystem to set the value again.
127711 */
127712
127713 if (Object.prototype.hasOwnProperty.call(resultToSerialize, "source")) {
127714 resultToSerialize.source = null;
127715 }
127716
127717 fileDescriptor.meta.results = resultToSerialize;
127718 fileDescriptor.meta.hashOfConfig = hashOfConfigFor(config);
127719 }
127720 }
127721 /**
127722 * Persists the in-memory cache to disk.
127723 * @returns {void}
127724 */
127725
127726
127727 reconcile() {
127728 debug("Persisting cached results: ".concat(this.cacheFileLocation));
127729 this.fileEntryCache.reconcile();
127730 }
127731
127732 }
127733
127734 module.exports = LintResultCache;
127735
127736 /***/ }),
127737 /* 887 */
127738 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
127739
127740 var path = __webpack_require__(429);
127741
127742 var crypto = __webpack_require__(888);
127743
127744 module.exports = {
127745 createFromFile: function (filePath, useChecksum) {
127746 var fname = path.basename(filePath);
127747 var dir = path.dirname(filePath);
127748 return this.create(fname, dir, useChecksum);
127749 },
127750 create: function (cacheId, _path, useChecksum) {
127751 var fs = __webpack_require__(861);
127752
127753 var flatCache = __webpack_require__(889);
127754
127755 var cache = flatCache.load(cacheId, _path);
127756 var normalizedEntries = {};
127757
127758 var removeNotFoundFiles = function removeNotFoundFiles() {
127759 const cachedEntries = cache.keys(); // remove not found entries
127760
127761 cachedEntries.forEach(function remover(fPath) {
127762 try {
127763 fs.statSync(fPath);
127764 } catch (err) {
127765 if (err.code === 'ENOENT') {
127766 cache.removeKey(fPath);
127767 }
127768 }
127769 });
127770 };
127771
127772 removeNotFoundFiles();
127773 return {
127774 /**
127775 * the flat cache storage used to persist the metadata of the `files
127776 * @type {Object}
127777 */
127778 cache: cache,
127779
127780 /**
127781 * Given a buffer, calculate md5 hash of its content.
127782 * @method getHash
127783 * @param {Buffer} buffer buffer to calculate hash on
127784 * @return {String} content hash digest
127785 */
127786 getHash: function (buffer) {
127787 return crypto.createHash('md5').update(buffer).digest('hex');
127788 },
127789
127790 /**
127791 * Return whether or not a file has changed since last time reconcile was called.
127792 * @method hasFileChanged
127793 * @param {String} file the filepath to check
127794 * @return {Boolean} wheter or not the file has changed
127795 */
127796 hasFileChanged: function (file) {
127797 return this.getFileDescriptor(file).changed;
127798 },
127799
127800 /**
127801 * given an array of file paths it return and object with three arrays:
127802 * - changedFiles: Files that changed since previous run
127803 * - notChangedFiles: Files that haven't change
127804 * - notFoundFiles: Files that were not found, probably deleted
127805 *
127806 * @param {Array} files the files to analyze and compare to the previous seen files
127807 * @return {[type]} [description]
127808 */
127809 analyzeFiles: function (files) {
127810 var me = this;
127811 files = files || [];
127812 var res = {
127813 changedFiles: [],
127814 notFoundFiles: [],
127815 notChangedFiles: []
127816 };
127817 me.normalizeEntries(files).forEach(function (entry) {
127818 if (entry.changed) {
127819 res.changedFiles.push(entry.key);
127820 return;
127821 }
127822
127823 if (entry.notFound) {
127824 res.notFoundFiles.push(entry.key);
127825 return;
127826 }
127827
127828 res.notChangedFiles.push(entry.key);
127829 });
127830 return res;
127831 },
127832 getFileDescriptor: function (file) {
127833 var fstat;
127834
127835 try {
127836 fstat = fs.statSync(file);
127837 } catch (ex) {
127838 this.removeEntry(file);
127839 return {
127840 key: file,
127841 notFound: true,
127842 err: ex
127843 };
127844 }
127845
127846 if (useChecksum) {
127847 return this._getFileDescriptorUsingChecksum(file);
127848 }
127849
127850 return this._getFileDescriptorUsingMtimeAndSize(file, fstat);
127851 },
127852 _getFileDescriptorUsingMtimeAndSize: function (file, fstat) {
127853 var meta = cache.getKey(file);
127854 var cacheExists = !!meta;
127855 var cSize = fstat.size;
127856 var cTime = fstat.mtime.getTime();
127857 var isDifferentDate;
127858 var isDifferentSize;
127859
127860 if (!meta) {
127861 meta = {
127862 size: cSize,
127863 mtime: cTime
127864 };
127865 } else {
127866 isDifferentDate = cTime !== meta.mtime;
127867 isDifferentSize = cSize !== meta.size;
127868 }
127869
127870 var nEntry = normalizedEntries[file] = {
127871 key: file,
127872 changed: !cacheExists || isDifferentDate || isDifferentSize,
127873 meta: meta
127874 };
127875 return nEntry;
127876 },
127877 _getFileDescriptorUsingChecksum: function (file) {
127878 var meta = cache.getKey(file);
127879 var cacheExists = !!meta;
127880 var contentBuffer;
127881
127882 try {
127883 contentBuffer = fs.readFileSync(file);
127884 } catch (ex) {
127885 contentBuffer = '';
127886 }
127887
127888 var isDifferent = true;
127889 var hash = this.getHash(contentBuffer);
127890
127891 if (!meta) {
127892 meta = {
127893 hash: hash
127894 };
127895 } else {
127896 isDifferent = hash !== meta.hash;
127897 }
127898
127899 var nEntry = normalizedEntries[file] = {
127900 key: file,
127901 changed: !cacheExists || isDifferent,
127902 meta: meta
127903 };
127904 return nEntry;
127905 },
127906
127907 /**
127908 * Return the list o the files that changed compared
127909 * against the ones stored in the cache
127910 *
127911 * @method getUpdated
127912 * @param files {Array} the array of files to compare against the ones in the cache
127913 * @returns {Array}
127914 */
127915 getUpdatedFiles: function (files) {
127916 var me = this;
127917 files = files || [];
127918 return me.normalizeEntries(files).filter(function (entry) {
127919 return entry.changed;
127920 }).map(function (entry) {
127921 return entry.key;
127922 });
127923 },
127924
127925 /**
127926 * return the list of files
127927 * @method normalizeEntries
127928 * @param files
127929 * @returns {*}
127930 */
127931 normalizeEntries: function (files) {
127932 files = files || [];
127933 var me = this;
127934 var nEntries = files.map(function (file) {
127935 return me.getFileDescriptor(file);
127936 }); //normalizeEntries = nEntries;
127937
127938 return nEntries;
127939 },
127940
127941 /**
127942 * Remove an entry from the file-entry-cache. Useful to force the file to still be considered
127943 * modified the next time the process is run
127944 *
127945 * @method removeEntry
127946 * @param entryName
127947 */
127948 removeEntry: function (entryName) {
127949 delete normalizedEntries[entryName];
127950 cache.removeKey(entryName);
127951 },
127952
127953 /**
127954 * Delete the cache file from the disk
127955 * @method deleteCacheFile
127956 */
127957 deleteCacheFile: function () {
127958 cache.removeCacheFile();
127959 },
127960
127961 /**
127962 * remove the cache from the file and clear the memory cache
127963 */
127964 destroy: function () {
127965 normalizedEntries = {};
127966 cache.destroy();
127967 },
127968 _getMetaForFileUsingCheckSum: function (cacheEntry) {
127969 var contentBuffer = fs.readFileSync(cacheEntry.key);
127970 var hash = this.getHash(contentBuffer);
127971 var meta = Object.assign(cacheEntry.meta, {
127972 hash: hash
127973 });
127974 delete meta.size;
127975 delete meta.mtime;
127976 return meta;
127977 },
127978 _getMetaForFileUsingMtimeAndSize: function (cacheEntry) {
127979 var stat = fs.statSync(cacheEntry.key);
127980 var meta = Object.assign(cacheEntry.meta, {
127981 size: stat.size,
127982 mtime: stat.mtime.getTime()
127983 });
127984 delete meta.hash;
127985 return meta;
127986 },
127987
127988 /**
127989 * Sync the files and persist them to the cache
127990 * @method reconcile
127991 */
127992 reconcile: function (noPrune) {
127993 removeNotFoundFiles();
127994 noPrune = typeof noPrune === 'undefined' ? true : noPrune;
127995 var entries = normalizedEntries;
127996 var keys = Object.keys(entries);
127997
127998 if (keys.length === 0) {
127999 return;
128000 }
128001
128002 var me = this;
128003 keys.forEach(function (entryName) {
128004 var cacheEntry = entries[entryName];
128005
128006 try {
128007 var meta = useChecksum ? me._getMetaForFileUsingCheckSum(cacheEntry) : me._getMetaForFileUsingMtimeAndSize(cacheEntry);
128008 cache.setKey(entryName, meta);
128009 } catch (err) {
128010 // if the file does not exists we don't save it
128011 // other errors are just thrown
128012 if (err.code !== 'ENOENT') {
128013 throw err;
128014 }
128015 }
128016 });
128017 cache.save(noPrune);
128018 }
128019 };
128020 }
128021 };
128022
128023 /***/ }),
128024 /* 888 */
128025 /***/ ((module) => {
128026
128027 "use strict";
128028 module.exports = require("crypto");
128029
128030 /***/ }),
128031 /* 889 */
128032 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
128033
128034 var path = __webpack_require__(429);
128035
128036 var fs = __webpack_require__(861);
128037
128038 var utils = __webpack_require__(890);
128039
128040 var del = __webpack_require__(892);
128041
128042 var writeJSON = utils.writeJSON;
128043 var cache = {
128044 /**
128045 * Load a cache identified by the given Id. If the element does not exists, then initialize an empty
128046 * cache storage. If specified `cacheDir` will be used as the directory to persist the data to. If omitted
128047 * then the cache module directory `./cache` will be used instead
128048 *
128049 * @method load
128050 * @param docId {String} the id of the cache, would also be used as the name of the file cache
128051 * @param [cacheDir] {String} directory for the cache entry
128052 */
128053 load: function (docId, cacheDir) {
128054 var me = this;
128055 me._visited = {};
128056 me._persisted = {};
128057 me._pathToFile = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, '../.cache/', docId);
128058
128059 if (fs.existsSync(me._pathToFile)) {
128060 me._persisted = utils.tryParse(me._pathToFile, {});
128061 }
128062 },
128063
128064 /**
128065 * Load the cache from the provided file
128066 * @method loadFile
128067 * @param {String} pathToFile the path to the file containing the info for the cache
128068 */
128069 loadFile: function (pathToFile) {
128070 var me = this;
128071 var dir = path.dirname(pathToFile);
128072 var fName = path.basename(pathToFile);
128073 me.load(fName, dir);
128074 },
128075
128076 /**
128077 * Returns the entire persisted object
128078 * @method all
128079 * @returns {*}
128080 */
128081 all: function () {
128082 return this._persisted;
128083 },
128084 keys: function () {
128085 return Object.keys(this._persisted);
128086 },
128087
128088 /**
128089 * sets a key to a given value
128090 * @method setKey
128091 * @param key {string} the key to set
128092 * @param value {object} the value of the key. Could be any object that can be serialized with JSON.stringify
128093 */
128094 setKey: function (key, value) {
128095 this._visited[key] = true;
128096 this._persisted[key] = value;
128097 },
128098
128099 /**
128100 * remove a given key from the cache
128101 * @method removeKey
128102 * @param key {String} the key to remove from the object
128103 */
128104 removeKey: function (key) {
128105 delete this._visited[key]; // esfmt-ignore-line
128106
128107 delete this._persisted[key]; // esfmt-ignore-line
128108 },
128109
128110 /**
128111 * Return the value of the provided key
128112 * @method getKey
128113 * @param key {String} the name of the key to retrieve
128114 * @returns {*} the value from the key
128115 */
128116 getKey: function (key) {
128117 this._visited[key] = true;
128118 return this._persisted[key];
128119 },
128120
128121 /**
128122 * Remove keys that were not accessed/set since the
128123 * last time the `prune` method was called.
128124 * @method _prune
128125 * @private
128126 */
128127 _prune: function () {
128128 var me = this;
128129 var obj = {};
128130 var keys = Object.keys(me._visited); // no keys visited for either get or set value
128131
128132 if (keys.length === 0) {
128133 return;
128134 }
128135
128136 keys.forEach(function (key) {
128137 obj[key] = me._persisted[key];
128138 });
128139 me._visited = {};
128140 me._persisted = obj;
128141 },
128142
128143 /**
128144 * Save the state of the cache identified by the docId to disk
128145 * as a JSON structure
128146 * @param [noPrune=false] {Boolean} whether to remove from cache the non visited files
128147 * @method save
128148 */
128149 save: function (noPrune) {
128150 var me = this;
128151 !noPrune && me._prune();
128152 writeJSON(me._pathToFile, me._persisted);
128153 },
128154
128155 /**
128156 * remove the file where the cache is persisted
128157 * @method removeCacheFile
128158 * @return {Boolean} true or false if the file was successfully deleted
128159 */
128160 removeCacheFile: function () {
128161 return del(this._pathToFile);
128162 },
128163
128164 /**
128165 * Destroy the file cache and cache content.
128166 * @method destroy
128167 */
128168 destroy: function () {
128169 var me = this;
128170 me._visited = {};
128171 me._persisted = {};
128172 me.removeCacheFile();
128173 }
128174 };
128175 module.exports = {
128176 /**
128177 * Alias for create. Should be considered depreacted. Will be removed in next releases
128178 *
128179 * @method load
128180 * @param docId {String} the id of the cache, would also be used as the name of the file cache
128181 * @param [cacheDir] {String} directory for the cache entry
128182 * @returns {cache} cache instance
128183 */
128184 load: function (docId, cacheDir) {
128185 return this.create(docId, cacheDir);
128186 },
128187
128188 /**
128189 * Load a cache identified by the given Id. If the element does not exists, then initialize an empty
128190 * cache storage.
128191 *
128192 * @method create
128193 * @param docId {String} the id of the cache, would also be used as the name of the file cache
128194 * @param [cacheDir] {String} directory for the cache entry
128195 * @returns {cache} cache instance
128196 */
128197 create: function (docId, cacheDir) {
128198 var obj = Object.create(cache);
128199 obj.load(docId, cacheDir);
128200 return obj;
128201 },
128202 createFromFile: function (filePath) {
128203 var obj = Object.create(cache);
128204 obj.loadFile(filePath);
128205 return obj;
128206 },
128207
128208 /**
128209 * Clear the cache identified by the given id. Caches stored in a different cache directory can be deleted directly
128210 *
128211 * @method clearCache
128212 * @param docId {String} the id of the cache, would also be used as the name of the file cache
128213 * @param cacheDir {String} the directory where the cache file was written
128214 * @returns {Boolean} true if the cache folder was deleted. False otherwise
128215 */
128216 clearCacheById: function (docId, cacheDir) {
128217 var filePath = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, '../.cache/', docId);
128218 return del(filePath);
128219 },
128220
128221 /**
128222 * Remove all cache stored in the cache directory
128223 * @method clearAll
128224 * @returns {Boolean} true if the cache folder was deleted. False otherwise
128225 */
128226 clearAll: function (cacheDir) {
128227 var filePath = cacheDir ? path.resolve(cacheDir) : path.resolve(__dirname, '../.cache/');
128228 return del(filePath);
128229 }
128230 };
128231
128232 /***/ }),
128233 /* 890 */
128234 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
128235
128236 var fs = __webpack_require__(861);
128237
128238 var path = __webpack_require__(429);
128239
128240 var flatted = __webpack_require__(891);
128241
128242 module.exports = {
128243 tryParse: function (filePath, defaultValue) {
128244 var result;
128245
128246 try {
128247 result = this.readJSON(filePath);
128248 } catch (ex) {
128249 result = defaultValue;
128250 }
128251
128252 return result;
128253 },
128254
128255 /**
128256 * Read json file synchronously using flatted
128257 *
128258 * @method readJSON
128259 * @param {String} filePath Json filepath
128260 * @returns {*} parse result
128261 */
128262 readJSON: function (filePath) {
128263 return flatted.parse(fs.readFileSync(filePath, {
128264 encoding: 'utf8'
128265 }));
128266 },
128267
128268 /**
128269 * Write json file synchronously using circular-json
128270 *
128271 * @method writeJSON
128272 * @param {String} filePath Json filepath
128273 * @param {*} data Object to serialize
128274 */
128275 writeJSON: function (filePath, data) {
128276 fs.mkdirSync(path.dirname(filePath), {
128277 recursive: true
128278 });
128279 fs.writeFileSync(filePath, flatted.stringify(data));
128280 }
128281 };
128282
128283 /***/ }),
128284 /* 891 */
128285 /***/ ((__unused_webpack_module, exports) => {
128286
128287 "use strict";
128288
128289 /*! (c) 2020 Andrea Giammarchi */
128290
128291 const {
128292 parse: $parse,
128293 stringify: $stringify
128294 } = JSON;
128295 const {
128296 keys
128297 } = Object;
128298 const Primitive = String; // it could be Number
128299
128300 const primitive = 'string'; // it could be 'number'
128301
128302 const ignore = {};
128303 const object = 'object';
128304
128305 const noop = (_, value) => value;
128306
128307 const primitives = value => value instanceof Primitive ? Primitive(value) : value;
128308
128309 const Primitives = (_, value) => typeof value === primitive ? new Primitive(value) : value;
128310
128311 const revive = (input, parsed, output, $) => {
128312 const lazy = [];
128313
128314 for (let ke = keys(output), {
128315 length
128316 } = ke, y = 0; y < length; y++) {
128317 const k = ke[y];
128318 const value = output[k];
128319
128320 if (value instanceof Primitive) {
128321 const tmp = input[value];
128322
128323 if (typeof tmp === object && !parsed.has(tmp)) {
128324 parsed.add(tmp);
128325 output[k] = ignore;
128326 lazy.push({
128327 k,
128328 a: [input, parsed, tmp, $]
128329 });
128330 } else output[k] = $.call(output, k, tmp);
128331 } else if (output[k] !== ignore) output[k] = $.call(output, k, value);
128332 }
128333
128334 for (let {
128335 length
128336 } = lazy, i = 0; i < length; i++) {
128337 const {
128338 k,
128339 a
128340 } = lazy[i];
128341 output[k] = $.call(output, k, revive.apply(null, a));
128342 }
128343
128344 return output;
128345 };
128346
128347 const set = (known, input, value) => {
128348 const index = Primitive(input.push(value) - 1);
128349 known.set(value, index);
128350 return index;
128351 };
128352
128353 const parse = (text, reviver) => {
128354 const input = $parse(text, Primitives).map(primitives);
128355 const value = input[0];
128356 const $ = reviver || noop;
128357 const tmp = typeof value === object && value ? revive(input, new Set(), value, $) : value;
128358 return $.call({
128359 '': tmp
128360 }, '', tmp);
128361 };
128362
128363 exports.parse = parse;
128364
128365 const stringify = (value, replacer, space) => {
128366 const $ = replacer && typeof replacer === object ? (k, v) => k === '' || -1 < replacer.indexOf(k) ? v : void 0 : replacer || noop;
128367 const known = new Map();
128368 const input = [];
128369 const output = [];
128370 let i = +set(known, input, $.call({
128371 '': value
128372 }, '', value));
128373 let firstRun = !i;
128374
128375 while (i < input.length) {
128376 firstRun = true;
128377 output[i] = $stringify(input[i++], replace, space);
128378 }
128379
128380 return '[' + output.join(',') + ']';
128381
128382 function replace(key, value) {
128383 if (firstRun) {
128384 firstRun = !firstRun;
128385 return value;
128386 }
128387
128388 const after = $.call(this, key, value);
128389
128390 switch (typeof after) {
128391 case object:
128392 if (after === null) return after;
128393
128394 case primitive:
128395 return known.get(after) || set(known, input, after);
128396 }
128397
128398 return after;
128399 }
128400 };
128401
128402 exports.stringify = stringify;
128403
128404 const toJSON = any => $parse(stringify(any));
128405
128406 exports.toJSON = toJSON;
128407
128408 const fromJSON = any => parse($stringify(any));
128409
128410 exports.fromJSON = fromJSON;
128411
128412 /***/ }),
128413 /* 892 */
128414 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
128415
128416 var rimraf = (__webpack_require__(893).sync);
128417
128418 var fs = __webpack_require__(861);
128419
128420 module.exports = function del(file) {
128421 if (fs.existsSync(file)) {
128422 //if rimraf doesn't throw then the file has been deleted or didn't exist
128423 rimraf(file, {
128424 glob: false
128425 });
128426 return true;
128427 }
128428
128429 return false;
128430 };
128431
128432 /***/ }),
128433 /* 893 */
128434 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
128435
128436 /* provided dependency */ var process = __webpack_require__(494);
128437 const assert = __webpack_require__(431);
128438
128439 const path = __webpack_require__(429);
128440
128441 const fs = __webpack_require__(861);
128442
128443 let glob = undefined;
128444
128445 try {
128446 glob = __webpack_require__(894);
128447 } catch (_err) {// treat glob as optional.
128448 }
128449
128450 const defaultGlobOpts = {
128451 nosort: true,
128452 silent: true
128453 }; // for EMFILE handling
128454
128455 let timeout = 0;
128456 const isWindows = process.platform === "win32";
128457
128458 const defaults = options => {
128459 const methods = ['unlink', 'chmod', 'stat', 'lstat', 'rmdir', 'readdir'];
128460 methods.forEach(m => {
128461 options[m] = options[m] || fs[m];
128462 m = m + 'Sync';
128463 options[m] = options[m] || fs[m];
128464 });
128465 options.maxBusyTries = options.maxBusyTries || 3;
128466 options.emfileWait = options.emfileWait || 1000;
128467
128468 if (options.glob === false) {
128469 options.disableGlob = true;
128470 }
128471
128472 if (options.disableGlob !== true && glob === undefined) {
128473 throw Error('glob dependency not found, set `options.disableGlob = true` if intentional');
128474 }
128475
128476 options.disableGlob = options.disableGlob || false;
128477 options.glob = options.glob || defaultGlobOpts;
128478 };
128479
128480 const rimraf = (p, options, cb) => {
128481 if (typeof options === 'function') {
128482 cb = options;
128483 options = {};
128484 }
128485
128486 assert(p, 'rimraf: missing path');
128487 assert.equal(typeof p, 'string', 'rimraf: path should be a string');
128488 assert.equal(typeof cb, 'function', 'rimraf: callback function required');
128489 assert(options, 'rimraf: invalid options argument provided');
128490 assert.equal(typeof options, 'object', 'rimraf: options should be object');
128491 defaults(options);
128492 let busyTries = 0;
128493 let errState = null;
128494 let n = 0;
128495
128496 const next = er => {
128497 errState = errState || er;
128498 if (--n === 0) cb(errState);
128499 };
128500
128501 const afterGlob = (er, results) => {
128502 if (er) return cb(er);
128503 n = results.length;
128504 if (n === 0) return cb();
128505 results.forEach(p => {
128506 const CB = er => {
128507 if (er) {
128508 if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && busyTries < options.maxBusyTries) {
128509 busyTries++; // try again, with the same exact callback as this one.
128510
128511 return setTimeout(() => rimraf_(p, options, CB), busyTries * 100);
128512 } // this one won't happen if graceful-fs is used.
128513
128514
128515 if (er.code === "EMFILE" && timeout < options.emfileWait) {
128516 return setTimeout(() => rimraf_(p, options, CB), timeout++);
128517 } // already gone
128518
128519
128520 if (er.code === "ENOENT") er = null;
128521 }
128522
128523 timeout = 0;
128524 next(er);
128525 };
128526
128527 rimraf_(p, options, CB);
128528 });
128529 };
128530
128531 if (options.disableGlob || !glob.hasMagic(p)) return afterGlob(null, [p]);
128532 options.lstat(p, (er, stat) => {
128533 if (!er) return afterGlob(null, [p]);
128534 glob(p, options.glob, afterGlob);
128535 });
128536 }; // Two possible strategies.
128537 // 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR
128538 // 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR
128539 //
128540 // Both result in an extra syscall when you guess wrong. However, there
128541 // are likely far more normal files in the world than directories. This
128542 // is based on the assumption that a the average number of files per
128543 // directory is >= 1.
128544 //
128545 // If anyone ever complains about this, then I guess the strategy could
128546 // be made configurable somehow. But until then, YAGNI.
128547
128548
128549 const rimraf_ = (p, options, cb) => {
128550 assert(p);
128551 assert(options);
128552 assert(typeof cb === 'function'); // sunos lets the root user unlink directories, which is... weird.
128553 // so we have to lstat here and make sure it's not a dir.
128554
128555 options.lstat(p, (er, st) => {
128556 if (er && er.code === "ENOENT") return cb(null); // Windows can EPERM on stat. Life is suffering.
128557
128558 if (er && er.code === "EPERM" && isWindows) fixWinEPERM(p, options, er, cb);
128559 if (st && st.isDirectory()) return rmdir(p, options, er, cb);
128560 options.unlink(p, er => {
128561 if (er) {
128562 if (er.code === "ENOENT") return cb(null);
128563 if (er.code === "EPERM") return isWindows ? fixWinEPERM(p, options, er, cb) : rmdir(p, options, er, cb);
128564 if (er.code === "EISDIR") return rmdir(p, options, er, cb);
128565 }
128566
128567 return cb(er);
128568 });
128569 });
128570 };
128571
128572 const fixWinEPERM = (p, options, er, cb) => {
128573 assert(p);
128574 assert(options);
128575 assert(typeof cb === 'function');
128576 options.chmod(p, 0o666, er2 => {
128577 if (er2) cb(er2.code === "ENOENT" ? null : er);else options.stat(p, (er3, stats) => {
128578 if (er3) cb(er3.code === "ENOENT" ? null : er);else if (stats.isDirectory()) rmdir(p, options, er, cb);else options.unlink(p, cb);
128579 });
128580 });
128581 };
128582
128583 const fixWinEPERMSync = (p, options, er) => {
128584 assert(p);
128585 assert(options);
128586
128587 try {
128588 options.chmodSync(p, 0o666);
128589 } catch (er2) {
128590 if (er2.code === "ENOENT") return;else throw er;
128591 }
128592
128593 let stats;
128594
128595 try {
128596 stats = options.statSync(p);
128597 } catch (er3) {
128598 if (er3.code === "ENOENT") return;else throw er;
128599 }
128600
128601 if (stats.isDirectory()) rmdirSync(p, options, er);else options.unlinkSync(p);
128602 };
128603
128604 const rmdir = (p, options, originalEr, cb) => {
128605 assert(p);
128606 assert(options);
128607 assert(typeof cb === 'function'); // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
128608 // if we guessed wrong, and it's not a directory, then
128609 // raise the original error.
128610
128611 options.rmdir(p, er => {
128612 if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) rmkids(p, options, cb);else if (er && er.code === "ENOTDIR") cb(originalEr);else cb(er);
128613 });
128614 };
128615
128616 const rmkids = (p, options, cb) => {
128617 assert(p);
128618 assert(options);
128619 assert(typeof cb === 'function');
128620 options.readdir(p, (er, files) => {
128621 if (er) return cb(er);
128622 let n = files.length;
128623 if (n === 0) return options.rmdir(p, cb);
128624 let errState;
128625 files.forEach(f => {
128626 rimraf(path.join(p, f), options, er => {
128627 if (errState) return;
128628 if (er) return cb(errState = er);
128629 if (--n === 0) options.rmdir(p, cb);
128630 });
128631 });
128632 });
128633 }; // this looks simpler, and is strictly *faster*, but will
128634 // tie up the JavaScript thread and fail on excessively
128635 // deep directory trees.
128636
128637
128638 const rimrafSync = (p, options) => {
128639 options = options || {};
128640 defaults(options);
128641 assert(p, 'rimraf: missing path');
128642 assert.equal(typeof p, 'string', 'rimraf: path should be a string');
128643 assert(options, 'rimraf: missing options');
128644 assert.equal(typeof options, 'object', 'rimraf: options should be object');
128645 let results;
128646
128647 if (options.disableGlob || !glob.hasMagic(p)) {
128648 results = [p];
128649 } else {
128650 try {
128651 options.lstatSync(p);
128652 results = [p];
128653 } catch (er) {
128654 results = glob.sync(p, options.glob);
128655 }
128656 }
128657
128658 if (!results.length) return;
128659
128660 for (let i = 0; i < results.length; i++) {
128661 const p = results[i];
128662 let st;
128663
128664 try {
128665 st = options.lstatSync(p);
128666 } catch (er) {
128667 if (er.code === "ENOENT") return; // Windows can EPERM on stat. Life is suffering.
128668
128669 if (er.code === "EPERM" && isWindows) fixWinEPERMSync(p, options, er);
128670 }
128671
128672 try {
128673 // sunos lets the root user unlink directories, which is... weird.
128674 if (st && st.isDirectory()) rmdirSync(p, options, null);else options.unlinkSync(p);
128675 } catch (er) {
128676 if (er.code === "ENOENT") return;
128677 if (er.code === "EPERM") return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er);
128678 if (er.code !== "EISDIR") throw er;
128679 rmdirSync(p, options, er);
128680 }
128681 }
128682 };
128683
128684 const rmdirSync = (p, options, originalEr) => {
128685 assert(p);
128686 assert(options);
128687
128688 try {
128689 options.rmdirSync(p);
128690 } catch (er) {
128691 if (er.code === "ENOENT") return;
128692 if (er.code === "ENOTDIR") throw originalEr;
128693 if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") rmkidsSync(p, options);
128694 }
128695 };
128696
128697 const rmkidsSync = (p, options) => {
128698 assert(p);
128699 assert(options);
128700 options.readdirSync(p).forEach(f => rimrafSync(path.join(p, f), options)); // We only end up here once we got ENOTEMPTY at least once, and
128701 // at this point, we are guaranteed to have removed all the kids.
128702 // So, we know that it won't be ENOENT or ENOTDIR or anything else.
128703 // try really hard to delete stuff on windows, because it has a
128704 // PROFOUNDLY annoying habit of not closing handles promptly when
128705 // files are deleted, resulting in spurious ENOTEMPTY errors.
128706
128707 const retries = isWindows ? 100 : 1;
128708 let i = 0;
128709
128710 do {
128711 let threw = true;
128712
128713 try {
128714 const ret = options.rmdirSync(p, options);
128715 threw = false;
128716 return ret;
128717 } finally {
128718 if (++i < retries && threw) continue;
128719 }
128720 } while (true);
128721 };
128722
128723 module.exports = rimraf;
128724 rimraf.sync = rimrafSync;
128725
128726 /***/ }),
128727 /* 894 */
128728 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
128729
128730 /* provided dependency */ var process = __webpack_require__(494);
128731 /* provided dependency */ var console = __webpack_require__(438);
128732 // Approach:
128733 //
128734 // 1. Get the minimatch set
128735 // 2. For each pattern in the set, PROCESS(pattern, false)
128736 // 3. Store matches per-set, then uniq them
128737 //
128738 // PROCESS(pattern, inGlobStar)
128739 // Get the first [n] items from pattern that are all strings
128740 // Join these together. This is PREFIX.
128741 // If there is no more remaining, then stat(PREFIX) and
128742 // add to matches if it succeeds. END.
128743 //
128744 // If inGlobStar and PREFIX is symlink and points to dir
128745 // set ENTRIES = []
128746 // else readdir(PREFIX) as ENTRIES
128747 // If fail, END
128748 //
128749 // with ENTRIES
128750 // If pattern[n] is GLOBSTAR
128751 // // handle the case where the globstar match is empty
128752 // // by pruning it out, and testing the resulting pattern
128753 // PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
128754 // // handle other cases.
128755 // for ENTRY in ENTRIES (not dotfiles)
128756 // // attach globstar + tail onto the entry
128757 // // Mark that this entry is a globstar match
128758 // PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
128759 //
128760 // else // not globstar
128761 // for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
128762 // Test ENTRY against pattern[n]
128763 // If fails, continue
128764 // If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
128765 //
128766 // Caveat:
128767 // Cache all stats and readdirs results to minimize syscall. Since all
128768 // we ever care about is existence and directory-ness, we can just keep
128769 // `true` for files, and [children,...] for directories, or `false` for
128770 // things that don't exist.
128771 module.exports = glob;
128772
128773 var rp = __webpack_require__(895);
128774
128775 var minimatch = __webpack_require__(871);
128776
128777 var Minimatch = minimatch.Minimatch;
128778
128779 var inherits = __webpack_require__(897);
128780
128781 var EE = (__webpack_require__(898).EventEmitter);
128782
128783 var path = __webpack_require__(429);
128784
128785 var assert = __webpack_require__(431);
128786
128787 var isAbsolute = __webpack_require__(899);
128788
128789 var globSync = __webpack_require__(900);
128790
128791 var common = __webpack_require__(901);
128792
128793 var setopts = common.setopts;
128794 var ownProp = common.ownProp;
128795
128796 var inflight = __webpack_require__(902);
128797
128798 var util = __webpack_require__(439);
128799
128800 var childrenIgnored = common.childrenIgnored;
128801 var isIgnored = common.isIgnored;
128802
128803 var once = __webpack_require__(904);
128804
128805 function glob(pattern, options, cb) {
128806 if (typeof options === 'function') cb = options, options = {};
128807 if (!options) options = {};
128808
128809 if (options.sync) {
128810 if (cb) throw new TypeError('callback provided to sync glob');
128811 return globSync(pattern, options);
128812 }
128813
128814 return new Glob(pattern, options, cb);
128815 }
128816
128817 glob.sync = globSync;
128818 var GlobSync = glob.GlobSync = globSync.GlobSync; // old api surface
128819
128820 glob.glob = glob;
128821
128822 function extend(origin, add) {
128823 if (add === null || typeof add !== 'object') {
128824 return origin;
128825 }
128826
128827 var keys = Object.keys(add);
128828 var i = keys.length;
128829
128830 while (i--) {
128831 origin[keys[i]] = add[keys[i]];
128832 }
128833
128834 return origin;
128835 }
128836
128837 glob.hasMagic = function (pattern, options_) {
128838 var options = extend({}, options_);
128839 options.noprocess = true;
128840 var g = new Glob(pattern, options);
128841 var set = g.minimatch.set;
128842 if (!pattern) return false;
128843 if (set.length > 1) return true;
128844
128845 for (var j = 0; j < set[0].length; j++) {
128846 if (typeof set[0][j] !== 'string') return true;
128847 }
128848
128849 return false;
128850 };
128851
128852 glob.Glob = Glob;
128853 inherits(Glob, EE);
128854
128855 function Glob(pattern, options, cb) {
128856 if (typeof options === 'function') {
128857 cb = options;
128858 options = null;
128859 }
128860
128861 if (options && options.sync) {
128862 if (cb) throw new TypeError('callback provided to sync glob');
128863 return new GlobSync(pattern, options);
128864 }
128865
128866 if (!(this instanceof Glob)) return new Glob(pattern, options, cb);
128867 setopts(this, pattern, options);
128868 this._didRealPath = false; // process each pattern in the minimatch set
128869
128870 var n = this.minimatch.set.length; // The matches are stored as {<filename>: true,...} so that
128871 // duplicates are automagically pruned.
128872 // Later, we do an Object.keys() on these.
128873 // Keep them as a list so we can fill in when nonull is set.
128874
128875 this.matches = new Array(n);
128876
128877 if (typeof cb === 'function') {
128878 cb = once(cb);
128879 this.on('error', cb);
128880 this.on('end', function (matches) {
128881 cb(null, matches);
128882 });
128883 }
128884
128885 var self = this;
128886 this._processing = 0;
128887 this._emitQueue = [];
128888 this._processQueue = [];
128889 this.paused = false;
128890 if (this.noprocess) return this;
128891 if (n === 0) return done();
128892 var sync = true;
128893
128894 for (var i = 0; i < n; i++) {
128895 this._process(this.minimatch.set[i], i, false, done);
128896 }
128897
128898 sync = false;
128899
128900 function done() {
128901 --self._processing;
128902
128903 if (self._processing <= 0) {
128904 if (sync) {
128905 process.nextTick(function () {
128906 self._finish();
128907 });
128908 } else {
128909 self._finish();
128910 }
128911 }
128912 }
128913 }
128914
128915 Glob.prototype._finish = function () {
128916 assert(this instanceof Glob);
128917 if (this.aborted) return;
128918 if (this.realpath && !this._didRealpath) return this._realpath();
128919 common.finish(this);
128920 this.emit('end', this.found);
128921 };
128922
128923 Glob.prototype._realpath = function () {
128924 if (this._didRealpath) return;
128925 this._didRealpath = true;
128926 var n = this.matches.length;
128927 if (n === 0) return this._finish();
128928 var self = this;
128929
128930 for (var i = 0; i < this.matches.length; i++) this._realpathSet(i, next);
128931
128932 function next() {
128933 if (--n === 0) self._finish();
128934 }
128935 };
128936
128937 Glob.prototype._realpathSet = function (index, cb) {
128938 var matchset = this.matches[index];
128939 if (!matchset) return cb();
128940 var found = Object.keys(matchset);
128941 var self = this;
128942 var n = found.length;
128943 if (n === 0) return cb();
128944 var set = this.matches[index] = Object.create(null);
128945 found.forEach(function (p, i) {
128946 // If there's a problem with the stat, then it means that
128947 // one or more of the links in the realpath couldn't be
128948 // resolved. just return the abs value in that case.
128949 p = self._makeAbs(p);
128950 rp.realpath(p, self.realpathCache, function (er, real) {
128951 if (!er) set[real] = true;else if (er.syscall === 'stat') set[p] = true;else self.emit('error', er); // srsly wtf right here
128952
128953 if (--n === 0) {
128954 self.matches[index] = set;
128955 cb();
128956 }
128957 });
128958 });
128959 };
128960
128961 Glob.prototype._mark = function (p) {
128962 return common.mark(this, p);
128963 };
128964
128965 Glob.prototype._makeAbs = function (f) {
128966 return common.makeAbs(this, f);
128967 };
128968
128969 Glob.prototype.abort = function () {
128970 this.aborted = true;
128971 this.emit('abort');
128972 };
128973
128974 Glob.prototype.pause = function () {
128975 if (!this.paused) {
128976 this.paused = true;
128977 this.emit('pause');
128978 }
128979 };
128980
128981 Glob.prototype.resume = function () {
128982 if (this.paused) {
128983 this.emit('resume');
128984 this.paused = false;
128985
128986 if (this._emitQueue.length) {
128987 var eq = this._emitQueue.slice(0);
128988
128989 this._emitQueue.length = 0;
128990
128991 for (var i = 0; i < eq.length; i++) {
128992 var e = eq[i];
128993
128994 this._emitMatch(e[0], e[1]);
128995 }
128996 }
128997
128998 if (this._processQueue.length) {
128999 var pq = this._processQueue.slice(0);
129000
129001 this._processQueue.length = 0;
129002
129003 for (var i = 0; i < pq.length; i++) {
129004 var p = pq[i];
129005 this._processing--;
129006
129007 this._process(p[0], p[1], p[2], p[3]);
129008 }
129009 }
129010 }
129011 };
129012
129013 Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
129014 assert(this instanceof Glob);
129015 assert(typeof cb === 'function');
129016 if (this.aborted) return;
129017 this._processing++;
129018
129019 if (this.paused) {
129020 this._processQueue.push([pattern, index, inGlobStar, cb]);
129021
129022 return;
129023 } //console.error('PROCESS %d', this._processing, pattern)
129024 // Get the first [n] parts of pattern that are all strings.
129025
129026
129027 var n = 0;
129028
129029 while (typeof pattern[n] === 'string') {
129030 n++;
129031 } // now n is the index of the first one that is *not* a string.
129032 // see if there's anything else
129033
129034
129035 var prefix;
129036
129037 switch (n) {
129038 // if not, then this is rather simple
129039 case pattern.length:
129040 this._processSimple(pattern.join('/'), index, cb);
129041
129042 return;
129043
129044 case 0:
129045 // pattern *starts* with some non-trivial item.
129046 // going to readdir(cwd), but not include the prefix in matches.
129047 prefix = null;
129048 break;
129049
129050 default:
129051 // pattern has some string bits in the front.
129052 // whatever it starts with, whether that's 'absolute' like /foo/bar,
129053 // or 'relative' like '../baz'
129054 prefix = pattern.slice(0, n).join('/');
129055 break;
129056 }
129057
129058 var remain = pattern.slice(n); // get the list of entries.
129059
129060 var read;
129061 if (prefix === null) read = '.';else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
129062 if (!prefix || !isAbsolute(prefix)) prefix = '/' + prefix;
129063 read = prefix;
129064 } else read = prefix;
129065
129066 var abs = this._makeAbs(read); //if ignored, skip _processing
129067
129068
129069 if (childrenIgnored(this, read)) return cb();
129070 var isGlobStar = remain[0] === minimatch.GLOBSTAR;
129071 if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb);
129072 };
129073
129074 Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
129075 var self = this;
129076
129077 this._readdir(abs, inGlobStar, function (er, entries) {
129078 return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
129079 });
129080 };
129081
129082 Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
129083 // if the abs isn't a dir, then nothing can match!
129084 if (!entries) return cb(); // It will only match dot entries if it starts with a dot, or if
129085 // dot is set. Stuff like @(.foo|.bar) isn't allowed.
129086
129087 var pn = remain[0];
129088 var negate = !!this.minimatch.negate;
129089 var rawGlob = pn._glob;
129090 var dotOk = this.dot || rawGlob.charAt(0) === '.';
129091 var matchedEntries = [];
129092
129093 for (var i = 0; i < entries.length; i++) {
129094 var e = entries[i];
129095
129096 if (e.charAt(0) !== '.' || dotOk) {
129097 var m;
129098
129099 if (negate && !prefix) {
129100 m = !e.match(pn);
129101 } else {
129102 m = e.match(pn);
129103 }
129104
129105 if (m) matchedEntries.push(e);
129106 }
129107 } //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
129108
129109
129110 var len = matchedEntries.length; // If there are no matched entries, then nothing matches.
129111
129112 if (len === 0) return cb(); // if this is the last remaining pattern bit, then no need for
129113 // an additional stat *unless* the user has specified mark or
129114 // stat explicitly. We know they exist, since readdir returned
129115 // them.
129116
129117 if (remain.length === 1 && !this.mark && !this.stat) {
129118 if (!this.matches[index]) this.matches[index] = Object.create(null);
129119
129120 for (var i = 0; i < len; i++) {
129121 var e = matchedEntries[i];
129122
129123 if (prefix) {
129124 if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e;
129125 }
129126
129127 if (e.charAt(0) === '/' && !this.nomount) {
129128 e = path.join(this.root, e);
129129 }
129130
129131 this._emitMatch(index, e);
129132 } // This was the last one, and no stats were needed
129133
129134
129135 return cb();
129136 } // now test all matched entries as stand-ins for that part
129137 // of the pattern.
129138
129139
129140 remain.shift();
129141
129142 for (var i = 0; i < len; i++) {
129143 var e = matchedEntries[i];
129144 var newPattern;
129145
129146 if (prefix) {
129147 if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e;
129148 }
129149
129150 this._process([e].concat(remain), index, inGlobStar, cb);
129151 }
129152
129153 cb();
129154 };
129155
129156 Glob.prototype._emitMatch = function (index, e) {
129157 if (this.aborted) return;
129158 if (isIgnored(this, e)) return;
129159
129160 if (this.paused) {
129161 this._emitQueue.push([index, e]);
129162
129163 return;
129164 }
129165
129166 var abs = isAbsolute(e) ? e : this._makeAbs(e);
129167 if (this.mark) e = this._mark(e);
129168 if (this.absolute) e = abs;
129169 if (this.matches[index][e]) return;
129170
129171 if (this.nodir) {
129172 var c = this.cache[abs];
129173 if (c === 'DIR' || Array.isArray(c)) return;
129174 }
129175
129176 this.matches[index][e] = true;
129177 var st = this.statCache[abs];
129178 if (st) this.emit('stat', e, st);
129179 this.emit('match', e);
129180 };
129181
129182 Glob.prototype._readdirInGlobStar = function (abs, cb) {
129183 if (this.aborted) return; // follow all symlinked directories forever
129184 // just proceed as if this is a non-globstar situation
129185
129186 if (this.follow) return this._readdir(abs, false, cb);
129187 var lstatkey = 'lstat\0' + abs;
129188 var self = this;
129189 var lstatcb = inflight(lstatkey, lstatcb_);
129190 if (lstatcb) self.fs.lstat(abs, lstatcb);
129191
129192 function lstatcb_(er, lstat) {
129193 if (er && er.code === 'ENOENT') return cb();
129194 var isSym = lstat && lstat.isSymbolicLink();
129195 self.symlinks[abs] = isSym; // If it's not a symlink or a dir, then it's definitely a regular file.
129196 // don't bother doing a readdir in that case.
129197
129198 if (!isSym && lstat && !lstat.isDirectory()) {
129199 self.cache[abs] = 'FILE';
129200 cb();
129201 } else self._readdir(abs, false, cb);
129202 }
129203 };
129204
129205 Glob.prototype._readdir = function (abs, inGlobStar, cb) {
129206 if (this.aborted) return;
129207 cb = inflight('readdir\0' + abs + '\0' + inGlobStar, cb);
129208 if (!cb) return; //console.error('RD %j %j', +inGlobStar, abs)
129209
129210 if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs, cb);
129211
129212 if (ownProp(this.cache, abs)) {
129213 var c = this.cache[abs];
129214 if (!c || c === 'FILE') return cb();
129215 if (Array.isArray(c)) return cb(null, c);
129216 }
129217
129218 var self = this;
129219 self.fs.readdir(abs, readdirCb(this, abs, cb));
129220 };
129221
129222 function readdirCb(self, abs, cb) {
129223 return function (er, entries) {
129224 if (er) self._readdirError(abs, er, cb);else self._readdirEntries(abs, entries, cb);
129225 };
129226 }
129227
129228 Glob.prototype._readdirEntries = function (abs, entries, cb) {
129229 if (this.aborted) return; // if we haven't asked to stat everything, then just
129230 // assume that everything in there exists, so we can avoid
129231 // having to stat it a second time.
129232
129233 if (!this.mark && !this.stat) {
129234 for (var i = 0; i < entries.length; i++) {
129235 var e = entries[i];
129236 if (abs === '/') e = abs + e;else e = abs + '/' + e;
129237 this.cache[e] = true;
129238 }
129239 }
129240
129241 this.cache[abs] = entries;
129242 return cb(null, entries);
129243 };
129244
129245 Glob.prototype._readdirError = function (f, er, cb) {
129246 if (this.aborted) return; // handle errors, and cache the information
129247
129248 switch (er.code) {
129249 case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
129250
129251 case 'ENOTDIR':
129252 // totally normal. means it *does* exist.
129253 var abs = this._makeAbs(f);
129254
129255 this.cache[abs] = 'FILE';
129256
129257 if (abs === this.cwdAbs) {
129258 var error = new Error(er.code + ' invalid cwd ' + this.cwd);
129259 error.path = this.cwd;
129260 error.code = er.code;
129261 this.emit('error', error);
129262 this.abort();
129263 }
129264
129265 break;
129266
129267 case 'ENOENT': // not terribly unusual
129268
129269 case 'ELOOP':
129270 case 'ENAMETOOLONG':
129271 case 'UNKNOWN':
129272 this.cache[this._makeAbs(f)] = false;
129273 break;
129274
129275 default:
129276 // some unusual error. Treat as failure.
129277 this.cache[this._makeAbs(f)] = false;
129278
129279 if (this.strict) {
129280 this.emit('error', er); // If the error is handled, then we abort
129281 // if not, we threw out of here
129282
129283 this.abort();
129284 }
129285
129286 if (!this.silent) console.error('glob error', er);
129287 break;
129288 }
129289
129290 return cb();
129291 };
129292
129293 Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
129294 var self = this;
129295
129296 this._readdir(abs, inGlobStar, function (er, entries) {
129297 self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
129298 });
129299 };
129300
129301 Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
129302 //console.error('pgs2', prefix, remain[0], entries)
129303 // no entries means not a dir, so it can never have matches
129304 // foo.txt/** doesn't match foo.txt
129305 if (!entries) return cb(); // test without the globstar, and with every child both below
129306 // and replacing the globstar.
129307
129308 var remainWithoutGlobStar = remain.slice(1);
129309 var gspref = prefix ? [prefix] : [];
129310 var noGlobStar = gspref.concat(remainWithoutGlobStar); // the noGlobStar pattern exits the inGlobStar state
129311
129312 this._process(noGlobStar, index, false, cb);
129313
129314 var isSym = this.symlinks[abs];
129315 var len = entries.length; // If it's a symlink, and we're in a globstar, then stop
129316
129317 if (isSym && inGlobStar) return cb();
129318
129319 for (var i = 0; i < len; i++) {
129320 var e = entries[i];
129321 if (e.charAt(0) === '.' && !this.dot) continue; // these two cases enter the inGlobStar state
129322
129323 var instead = gspref.concat(entries[i], remainWithoutGlobStar);
129324
129325 this._process(instead, index, true, cb);
129326
129327 var below = gspref.concat(entries[i], remain);
129328
129329 this._process(below, index, true, cb);
129330 }
129331
129332 cb();
129333 };
129334
129335 Glob.prototype._processSimple = function (prefix, index, cb) {
129336 // XXX review this. Shouldn't it be doing the mounting etc
129337 // before doing stat? kinda weird?
129338 var self = this;
129339
129340 this._stat(prefix, function (er, exists) {
129341 self._processSimple2(prefix, index, er, exists, cb);
129342 });
129343 };
129344
129345 Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
129346 //console.error('ps2', prefix, exists)
129347 if (!this.matches[index]) this.matches[index] = Object.create(null); // If it doesn't exist, then just mark the lack of results
129348
129349 if (!exists) return cb();
129350
129351 if (prefix && isAbsolute(prefix) && !this.nomount) {
129352 var trail = /[\/\\]$/.test(prefix);
129353
129354 if (prefix.charAt(0) === '/') {
129355 prefix = path.join(this.root, prefix);
129356 } else {
129357 prefix = path.resolve(this.root, prefix);
129358 if (trail) prefix += '/';
129359 }
129360 }
129361
129362 if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); // Mark this as a match
129363
129364 this._emitMatch(index, prefix);
129365
129366 cb();
129367 }; // Returns either 'DIR', 'FILE', or false
129368
129369
129370 Glob.prototype._stat = function (f, cb) {
129371 var abs = this._makeAbs(f);
129372
129373 var needDir = f.slice(-1) === '/';
129374 if (f.length > this.maxLength) return cb();
129375
129376 if (!this.stat && ownProp(this.cache, abs)) {
129377 var c = this.cache[abs];
129378 if (Array.isArray(c)) c = 'DIR'; // It exists, but maybe not how we need it
129379
129380 if (!needDir || c === 'DIR') return cb(null, c);
129381 if (needDir && c === 'FILE') return cb(); // otherwise we have to stat, because maybe c=true
129382 // if we know it exists, but not what it is.
129383 }
129384
129385 var exists;
129386 var stat = this.statCache[abs];
129387
129388 if (stat !== undefined) {
129389 if (stat === false) return cb(null, stat);else {
129390 var type = stat.isDirectory() ? 'DIR' : 'FILE';
129391 if (needDir && type === 'FILE') return cb();else return cb(null, type, stat);
129392 }
129393 }
129394
129395 var self = this;
129396 var statcb = inflight('stat\0' + abs, lstatcb_);
129397 if (statcb) self.fs.lstat(abs, statcb);
129398
129399 function lstatcb_(er, lstat) {
129400 if (lstat && lstat.isSymbolicLink()) {
129401 // If it's a symlink, then treat it as the target, unless
129402 // the target does not exist, then treat it as a file.
129403 return self.fs.stat(abs, function (er, stat) {
129404 if (er) self._stat2(f, abs, null, lstat, cb);else self._stat2(f, abs, er, stat, cb);
129405 });
129406 } else {
129407 self._stat2(f, abs, er, lstat, cb);
129408 }
129409 }
129410 };
129411
129412 Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
129413 if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
129414 this.statCache[abs] = false;
129415 return cb();
129416 }
129417
129418 var needDir = f.slice(-1) === '/';
129419 this.statCache[abs] = stat;
129420 if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) return cb(null, false, stat);
129421 var c = true;
129422 if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE';
129423 this.cache[abs] = this.cache[abs] || c;
129424 if (needDir && c === 'FILE') return cb();
129425 return cb(null, c, stat);
129426 };
129427
129428 /***/ }),
129429 /* 895 */
129430 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
129431
129432 /* provided dependency */ var process = __webpack_require__(494);
129433 module.exports = realpath;
129434 realpath.realpath = realpath;
129435 realpath.sync = realpathSync;
129436 realpath.realpathSync = realpathSync;
129437 realpath.monkeypatch = monkeypatch;
129438 realpath.unmonkeypatch = unmonkeypatch;
129439
129440 var fs = __webpack_require__(861);
129441
129442 var origRealpath = fs.realpath;
129443 var origRealpathSync = fs.realpathSync;
129444 var version = process.version;
129445 var ok = /^v[0-5]\./.test(version);
129446
129447 var old = __webpack_require__(896);
129448
129449 function newError(er) {
129450 return er && er.syscall === 'realpath' && (er.code === 'ELOOP' || er.code === 'ENOMEM' || er.code === 'ENAMETOOLONG');
129451 }
129452
129453 function realpath(p, cache, cb) {
129454 if (ok) {
129455 return origRealpath(p, cache, cb);
129456 }
129457
129458 if (typeof cache === 'function') {
129459 cb = cache;
129460 cache = null;
129461 }
129462
129463 origRealpath(p, cache, function (er, result) {
129464 if (newError(er)) {
129465 old.realpath(p, cache, cb);
129466 } else {
129467 cb(er, result);
129468 }
129469 });
129470 }
129471
129472 function realpathSync(p, cache) {
129473 if (ok) {
129474 return origRealpathSync(p, cache);
129475 }
129476
129477 try {
129478 return origRealpathSync(p, cache);
129479 } catch (er) {
129480 if (newError(er)) {
129481 return old.realpathSync(p, cache);
129482 } else {
129483 throw er;
129484 }
129485 }
129486 }
129487
129488 function monkeypatch() {
129489 fs.realpath = realpath;
129490 fs.realpathSync = realpathSync;
129491 }
129492
129493 function unmonkeypatch() {
129494 fs.realpath = origRealpath;
129495 fs.realpathSync = origRealpathSync;
129496 }
129497
129498 /***/ }),
129499 /* 896 */
129500 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
129501
129502 /* provided dependency */ var process = __webpack_require__(494);
129503 /* provided dependency */ var console = __webpack_require__(438);
129504 // Copyright Joyent, Inc. and other Node contributors.
129505 //
129506 // Permission is hereby granted, free of charge, to any person obtaining a
129507 // copy of this software and associated documentation files (the
129508 // "Software"), to deal in the Software without restriction, including
129509 // without limitation the rights to use, copy, modify, merge, publish,
129510 // distribute, sublicense, and/or sell copies of the Software, and to permit
129511 // persons to whom the Software is furnished to do so, subject to the
129512 // following conditions:
129513 //
129514 // The above copyright notice and this permission notice shall be included
129515 // in all copies or substantial portions of the Software.
129516 //
129517 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
129518 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
129519 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
129520 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
129521 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
129522 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
129523 // USE OR OTHER DEALINGS IN THE SOFTWARE.
129524 var pathModule = __webpack_require__(429);
129525
129526 var isWindows = process.platform === 'win32';
129527
129528 var fs = __webpack_require__(861); // JavaScript implementation of realpath, ported from node pre-v6
129529
129530
129531 var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
129532
129533 function rethrow() {
129534 // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
129535 // is fairly slow to generate.
129536 var callback;
129537
129538 if (DEBUG) {
129539 var backtrace = new Error();
129540 callback = debugCallback;
129541 } else callback = missingCallback;
129542
129543 return callback;
129544
129545 function debugCallback(err) {
129546 if (err) {
129547 backtrace.message = err.message;
129548 err = backtrace;
129549 missingCallback(err);
129550 }
129551 }
129552
129553 function missingCallback(err) {
129554 if (err) {
129555 if (process.throwDeprecation) throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
129556 else if (!process.noDeprecation) {
129557 var msg = 'fs: missing callback ' + (err.stack || err.message);
129558 if (process.traceDeprecation) console.trace(msg);else console.error(msg);
129559 }
129560 }
129561 }
129562 }
129563
129564 function maybeCallback(cb) {
129565 return typeof cb === 'function' ? cb : rethrow();
129566 }
129567
129568 var normalize = pathModule.normalize; // Regexp that finds the next partion of a (partial) path
129569 // result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
129570
129571 if (isWindows) {
129572 var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
129573 } else {
129574 var nextPartRe = /(.*?)(?:[\/]+|$)/g;
129575 } // Regex to find the device root, including trailing slash. E.g. 'c:\\'.
129576
129577
129578 if (isWindows) {
129579 var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
129580 } else {
129581 var splitRootRe = /^[\/]*/;
129582 }
129583
129584 exports.realpathSync = function realpathSync(p, cache) {
129585 // make p is absolute
129586 p = pathModule.resolve(p);
129587
129588 if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
129589 return cache[p];
129590 }
129591
129592 var original = p,
129593 seenLinks = {},
129594 knownHard = {}; // current character position in p
129595
129596 var pos; // the partial path so far, including a trailing slash if any
129597
129598 var current; // the partial path without a trailing slash (except when pointing at a root)
129599
129600 var base; // the partial path scanned in the previous round, with slash
129601
129602 var previous;
129603 start();
129604
129605 function start() {
129606 // Skip over roots
129607 var m = splitRootRe.exec(p);
129608 pos = m[0].length;
129609 current = m[0];
129610 base = m[0];
129611 previous = ''; // On windows, check that the root exists. On unix there is no need.
129612
129613 if (isWindows && !knownHard[base]) {
129614 fs.lstatSync(base);
129615 knownHard[base] = true;
129616 }
129617 } // walk down the path, swapping out linked pathparts for their real
129618 // values
129619 // NB: p.length changes.
129620
129621
129622 while (pos < p.length) {
129623 // find the next part
129624 nextPartRe.lastIndex = pos;
129625 var result = nextPartRe.exec(p);
129626 previous = current;
129627 current += result[0];
129628 base = previous + result[1];
129629 pos = nextPartRe.lastIndex; // continue if not a symlink
129630
129631 if (knownHard[base] || cache && cache[base] === base) {
129632 continue;
129633 }
129634
129635 var resolvedLink;
129636
129637 if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
129638 // some known symbolic link. no need to stat again.
129639 resolvedLink = cache[base];
129640 } else {
129641 var stat = fs.lstatSync(base);
129642
129643 if (!stat.isSymbolicLink()) {
129644 knownHard[base] = true;
129645 if (cache) cache[base] = base;
129646 continue;
129647 } // read the link if it wasn't read before
129648 // dev/ino always return 0 on windows, so skip the check.
129649
129650
129651 var linkTarget = null;
129652
129653 if (!isWindows) {
129654 var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
129655
129656 if (seenLinks.hasOwnProperty(id)) {
129657 linkTarget = seenLinks[id];
129658 }
129659 }
129660
129661 if (linkTarget === null) {
129662 fs.statSync(base);
129663 linkTarget = fs.readlinkSync(base);
129664 }
129665
129666 resolvedLink = pathModule.resolve(previous, linkTarget); // track this, if given a cache.
129667
129668 if (cache) cache[base] = resolvedLink;
129669 if (!isWindows) seenLinks[id] = linkTarget;
129670 } // resolve the link, then start over
129671
129672
129673 p = pathModule.resolve(resolvedLink, p.slice(pos));
129674 start();
129675 }
129676
129677 if (cache) cache[original] = p;
129678 return p;
129679 };
129680
129681 exports.realpath = function realpath(p, cache, cb) {
129682 if (typeof cb !== 'function') {
129683 cb = maybeCallback(cache);
129684 cache = null;
129685 } // make p is absolute
129686
129687
129688 p = pathModule.resolve(p);
129689
129690 if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
129691 return process.nextTick(cb.bind(null, null, cache[p]));
129692 }
129693
129694 var original = p,
129695 seenLinks = {},
129696 knownHard = {}; // current character position in p
129697
129698 var pos; // the partial path so far, including a trailing slash if any
129699
129700 var current; // the partial path without a trailing slash (except when pointing at a root)
129701
129702 var base; // the partial path scanned in the previous round, with slash
129703
129704 var previous;
129705 start();
129706
129707 function start() {
129708 // Skip over roots
129709 var m = splitRootRe.exec(p);
129710 pos = m[0].length;
129711 current = m[0];
129712 base = m[0];
129713 previous = ''; // On windows, check that the root exists. On unix there is no need.
129714
129715 if (isWindows && !knownHard[base]) {
129716 fs.lstat(base, function (err) {
129717 if (err) return cb(err);
129718 knownHard[base] = true;
129719 LOOP();
129720 });
129721 } else {
129722 process.nextTick(LOOP);
129723 }
129724 } // walk down the path, swapping out linked pathparts for their real
129725 // values
129726
129727
129728 function LOOP() {
129729 // stop if scanned past end of path
129730 if (pos >= p.length) {
129731 if (cache) cache[original] = p;
129732 return cb(null, p);
129733 } // find the next part
129734
129735
129736 nextPartRe.lastIndex = pos;
129737 var result = nextPartRe.exec(p);
129738 previous = current;
129739 current += result[0];
129740 base = previous + result[1];
129741 pos = nextPartRe.lastIndex; // continue if not a symlink
129742
129743 if (knownHard[base] || cache && cache[base] === base) {
129744 return process.nextTick(LOOP);
129745 }
129746
129747 if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
129748 // known symbolic link. no need to stat again.
129749 return gotResolvedLink(cache[base]);
129750 }
129751
129752 return fs.lstat(base, gotStat);
129753 }
129754
129755 function gotStat(err, stat) {
129756 if (err) return cb(err); // if not a symlink, skip to the next path part
129757
129758 if (!stat.isSymbolicLink()) {
129759 knownHard[base] = true;
129760 if (cache) cache[base] = base;
129761 return process.nextTick(LOOP);
129762 } // stat & read the link if not read before
129763 // call gotTarget as soon as the link target is known
129764 // dev/ino always return 0 on windows, so skip the check.
129765
129766
129767 if (!isWindows) {
129768 var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
129769
129770 if (seenLinks.hasOwnProperty(id)) {
129771 return gotTarget(null, seenLinks[id], base);
129772 }
129773 }
129774
129775 fs.stat(base, function (err) {
129776 if (err) return cb(err);
129777 fs.readlink(base, function (err, target) {
129778 if (!isWindows) seenLinks[id] = target;
129779 gotTarget(err, target);
129780 });
129781 });
129782 }
129783
129784 function gotTarget(err, target, base) {
129785 if (err) return cb(err);
129786 var resolvedLink = pathModule.resolve(previous, target);
129787 if (cache) cache[base] = resolvedLink;
129788 gotResolvedLink(resolvedLink);
129789 }
129790
129791 function gotResolvedLink(resolvedLink) {
129792 // resolve the link, then start over
129793 p = pathModule.resolve(resolvedLink, p.slice(pos));
129794 start();
129795 }
129796 };
129797
129798 /***/ }),
129799 /* 897 */
129800 /***/ ((module) => {
129801
129802 if (typeof Object.create === 'function') {
129803 // implementation from standard node.js 'util' module
129804 module.exports = function inherits(ctor, superCtor) {
129805 if (superCtor) {
129806 ctor.super_ = superCtor;
129807 ctor.prototype = Object.create(superCtor.prototype, {
129808 constructor: {
129809 value: ctor,
129810 enumerable: false,
129811 writable: true,
129812 configurable: true
129813 }
129814 });
129815 }
129816 };
129817 } else {
129818 // old school shim for old browsers
129819 module.exports = function inherits(ctor, superCtor) {
129820 if (superCtor) {
129821 ctor.super_ = superCtor;
129822
129823 var TempCtor = function () {};
129824
129825 TempCtor.prototype = superCtor.prototype;
129826 ctor.prototype = new TempCtor();
129827 ctor.prototype.constructor = ctor;
129828 }
129829 };
129830 }
129831
129832 /***/ }),
129833 /* 898 */
129834 /***/ ((module) => {
129835
129836 "use strict";
129837 module.exports = require("events");
129838
129839 /***/ }),
129840 /* 899 */
129841 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
129842
129843 "use strict";
129844 /* provided dependency */ var process = __webpack_require__(494);
129845
129846
129847 function posix(path) {
129848 return path.charAt(0) === '/';
129849 }
129850
129851 function win32(path) {
129852 // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
129853 var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
129854 var result = splitDeviceRe.exec(path);
129855 var device = result[1] || '';
129856 var isUnc = Boolean(device && device.charAt(1) !== ':'); // UNC paths are always absolute
129857
129858 return Boolean(result[2] || isUnc);
129859 }
129860
129861 module.exports = process.platform === 'win32' ? win32 : posix;
129862 module.exports.posix = posix;
129863 module.exports.win32 = win32;
129864
129865 /***/ }),
129866 /* 900 */
129867 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
129868
129869 /* provided dependency */ var console = __webpack_require__(438);
129870 /* provided dependency */ var process = __webpack_require__(494);
129871 module.exports = globSync;
129872 globSync.GlobSync = GlobSync;
129873
129874 var rp = __webpack_require__(895);
129875
129876 var minimatch = __webpack_require__(871);
129877
129878 var Minimatch = minimatch.Minimatch;
129879
129880 var Glob = (__webpack_require__(894).Glob);
129881
129882 var util = __webpack_require__(439);
129883
129884 var path = __webpack_require__(429);
129885
129886 var assert = __webpack_require__(431);
129887
129888 var isAbsolute = __webpack_require__(899);
129889
129890 var common = __webpack_require__(901);
129891
129892 var setopts = common.setopts;
129893 var ownProp = common.ownProp;
129894 var childrenIgnored = common.childrenIgnored;
129895 var isIgnored = common.isIgnored;
129896
129897 function globSync(pattern, options) {
129898 if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167');
129899 return new GlobSync(pattern, options).found;
129900 }
129901
129902 function GlobSync(pattern, options) {
129903 if (!pattern) throw new Error('must provide pattern');
129904 if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167');
129905 if (!(this instanceof GlobSync)) return new GlobSync(pattern, options);
129906 setopts(this, pattern, options);
129907 if (this.noprocess) return this;
129908 var n = this.minimatch.set.length;
129909 this.matches = new Array(n);
129910
129911 for (var i = 0; i < n; i++) {
129912 this._process(this.minimatch.set[i], i, false);
129913 }
129914
129915 this._finish();
129916 }
129917
129918 GlobSync.prototype._finish = function () {
129919 assert(this instanceof GlobSync);
129920
129921 if (this.realpath) {
129922 var self = this;
129923 this.matches.forEach(function (matchset, index) {
129924 var set = self.matches[index] = Object.create(null);
129925
129926 for (var p in matchset) {
129927 try {
129928 p = self._makeAbs(p);
129929 var real = rp.realpathSync(p, self.realpathCache);
129930 set[real] = true;
129931 } catch (er) {
129932 if (er.syscall === 'stat') set[self._makeAbs(p)] = true;else throw er;
129933 }
129934 }
129935 });
129936 }
129937
129938 common.finish(this);
129939 };
129940
129941 GlobSync.prototype._process = function (pattern, index, inGlobStar) {
129942 assert(this instanceof GlobSync); // Get the first [n] parts of pattern that are all strings.
129943
129944 var n = 0;
129945
129946 while (typeof pattern[n] === 'string') {
129947 n++;
129948 } // now n is the index of the first one that is *not* a string.
129949 // See if there's anything else
129950
129951
129952 var prefix;
129953
129954 switch (n) {
129955 // if not, then this is rather simple
129956 case pattern.length:
129957 this._processSimple(pattern.join('/'), index);
129958
129959 return;
129960
129961 case 0:
129962 // pattern *starts* with some non-trivial item.
129963 // going to readdir(cwd), but not include the prefix in matches.
129964 prefix = null;
129965 break;
129966
129967 default:
129968 // pattern has some string bits in the front.
129969 // whatever it starts with, whether that's 'absolute' like /foo/bar,
129970 // or 'relative' like '../baz'
129971 prefix = pattern.slice(0, n).join('/');
129972 break;
129973 }
129974
129975 var remain = pattern.slice(n); // get the list of entries.
129976
129977 var read;
129978 if (prefix === null) read = '.';else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
129979 if (!prefix || !isAbsolute(prefix)) prefix = '/' + prefix;
129980 read = prefix;
129981 } else read = prefix;
129982
129983 var abs = this._makeAbs(read); //if ignored, skip processing
129984
129985
129986 if (childrenIgnored(this, read)) return;
129987 var isGlobStar = remain[0] === minimatch.GLOBSTAR;
129988 if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar);
129989 };
129990
129991 GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
129992 var entries = this._readdir(abs, inGlobStar); // if the abs isn't a dir, then nothing can match!
129993
129994
129995 if (!entries) return; // It will only match dot entries if it starts with a dot, or if
129996 // dot is set. Stuff like @(.foo|.bar) isn't allowed.
129997
129998 var pn = remain[0];
129999 var negate = !!this.minimatch.negate;
130000 var rawGlob = pn._glob;
130001 var dotOk = this.dot || rawGlob.charAt(0) === '.';
130002 var matchedEntries = [];
130003
130004 for (var i = 0; i < entries.length; i++) {
130005 var e = entries[i];
130006
130007 if (e.charAt(0) !== '.' || dotOk) {
130008 var m;
130009
130010 if (negate && !prefix) {
130011 m = !e.match(pn);
130012 } else {
130013 m = e.match(pn);
130014 }
130015
130016 if (m) matchedEntries.push(e);
130017 }
130018 }
130019
130020 var len = matchedEntries.length; // If there are no matched entries, then nothing matches.
130021
130022 if (len === 0) return; // if this is the last remaining pattern bit, then no need for
130023 // an additional stat *unless* the user has specified mark or
130024 // stat explicitly. We know they exist, since readdir returned
130025 // them.
130026
130027 if (remain.length === 1 && !this.mark && !this.stat) {
130028 if (!this.matches[index]) this.matches[index] = Object.create(null);
130029
130030 for (var i = 0; i < len; i++) {
130031 var e = matchedEntries[i];
130032
130033 if (prefix) {
130034 if (prefix.slice(-1) !== '/') e = prefix + '/' + e;else e = prefix + e;
130035 }
130036
130037 if (e.charAt(0) === '/' && !this.nomount) {
130038 e = path.join(this.root, e);
130039 }
130040
130041 this._emitMatch(index, e);
130042 } // This was the last one, and no stats were needed
130043
130044
130045 return;
130046 } // now test all matched entries as stand-ins for that part
130047 // of the pattern.
130048
130049
130050 remain.shift();
130051
130052 for (var i = 0; i < len; i++) {
130053 var e = matchedEntries[i];
130054 var newPattern;
130055 if (prefix) newPattern = [prefix, e];else newPattern = [e];
130056
130057 this._process(newPattern.concat(remain), index, inGlobStar);
130058 }
130059 };
130060
130061 GlobSync.prototype._emitMatch = function (index, e) {
130062 if (isIgnored(this, e)) return;
130063
130064 var abs = this._makeAbs(e);
130065
130066 if (this.mark) e = this._mark(e);
130067
130068 if (this.absolute) {
130069 e = abs;
130070 }
130071
130072 if (this.matches[index][e]) return;
130073
130074 if (this.nodir) {
130075 var c = this.cache[abs];
130076 if (c === 'DIR' || Array.isArray(c)) return;
130077 }
130078
130079 this.matches[index][e] = true;
130080 if (this.stat) this._stat(e);
130081 };
130082
130083 GlobSync.prototype._readdirInGlobStar = function (abs) {
130084 // follow all symlinked directories forever
130085 // just proceed as if this is a non-globstar situation
130086 if (this.follow) return this._readdir(abs, false);
130087 var entries;
130088 var lstat;
130089 var stat;
130090
130091 try {
130092 lstat = this.fs.lstatSync(abs);
130093 } catch (er) {
130094 if (er.code === 'ENOENT') {
130095 // lstat failed, doesn't exist
130096 return null;
130097 }
130098 }
130099
130100 var isSym = lstat && lstat.isSymbolicLink();
130101 this.symlinks[abs] = isSym; // If it's not a symlink or a dir, then it's definitely a regular file.
130102 // don't bother doing a readdir in that case.
130103
130104 if (!isSym && lstat && !lstat.isDirectory()) this.cache[abs] = 'FILE';else entries = this._readdir(abs, false);
130105 return entries;
130106 };
130107
130108 GlobSync.prototype._readdir = function (abs, inGlobStar) {
130109 var entries;
130110 if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs);
130111
130112 if (ownProp(this.cache, abs)) {
130113 var c = this.cache[abs];
130114 if (!c || c === 'FILE') return null;
130115 if (Array.isArray(c)) return c;
130116 }
130117
130118 try {
130119 return this._readdirEntries(abs, this.fs.readdirSync(abs));
130120 } catch (er) {
130121 this._readdirError(abs, er);
130122
130123 return null;
130124 }
130125 };
130126
130127 GlobSync.prototype._readdirEntries = function (abs, entries) {
130128 // if we haven't asked to stat everything, then just
130129 // assume that everything in there exists, so we can avoid
130130 // having to stat it a second time.
130131 if (!this.mark && !this.stat) {
130132 for (var i = 0; i < entries.length; i++) {
130133 var e = entries[i];
130134 if (abs === '/') e = abs + e;else e = abs + '/' + e;
130135 this.cache[e] = true;
130136 }
130137 }
130138
130139 this.cache[abs] = entries; // mark and cache dir-ness
130140
130141 return entries;
130142 };
130143
130144 GlobSync.prototype._readdirError = function (f, er) {
130145 // handle errors, and cache the information
130146 switch (er.code) {
130147 case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
130148
130149 case 'ENOTDIR':
130150 // totally normal. means it *does* exist.
130151 var abs = this._makeAbs(f);
130152
130153 this.cache[abs] = 'FILE';
130154
130155 if (abs === this.cwdAbs) {
130156 var error = new Error(er.code + ' invalid cwd ' + this.cwd);
130157 error.path = this.cwd;
130158 error.code = er.code;
130159 throw error;
130160 }
130161
130162 break;
130163
130164 case 'ENOENT': // not terribly unusual
130165
130166 case 'ELOOP':
130167 case 'ENAMETOOLONG':
130168 case 'UNKNOWN':
130169 this.cache[this._makeAbs(f)] = false;
130170 break;
130171
130172 default:
130173 // some unusual error. Treat as failure.
130174 this.cache[this._makeAbs(f)] = false;
130175 if (this.strict) throw er;
130176 if (!this.silent) console.error('glob error', er);
130177 break;
130178 }
130179 };
130180
130181 GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
130182 var entries = this._readdir(abs, inGlobStar); // no entries means not a dir, so it can never have matches
130183 // foo.txt/** doesn't match foo.txt
130184
130185
130186 if (!entries) return; // test without the globstar, and with every child both below
130187 // and replacing the globstar.
130188
130189 var remainWithoutGlobStar = remain.slice(1);
130190 var gspref = prefix ? [prefix] : [];
130191 var noGlobStar = gspref.concat(remainWithoutGlobStar); // the noGlobStar pattern exits the inGlobStar state
130192
130193 this._process(noGlobStar, index, false);
130194
130195 var len = entries.length;
130196 var isSym = this.symlinks[abs]; // If it's a symlink, and we're in a globstar, then stop
130197
130198 if (isSym && inGlobStar) return;
130199
130200 for (var i = 0; i < len; i++) {
130201 var e = entries[i];
130202 if (e.charAt(0) === '.' && !this.dot) continue; // these two cases enter the inGlobStar state
130203
130204 var instead = gspref.concat(entries[i], remainWithoutGlobStar);
130205
130206 this._process(instead, index, true);
130207
130208 var below = gspref.concat(entries[i], remain);
130209
130210 this._process(below, index, true);
130211 }
130212 };
130213
130214 GlobSync.prototype._processSimple = function (prefix, index) {
130215 // XXX review this. Shouldn't it be doing the mounting etc
130216 // before doing stat? kinda weird?
130217 var exists = this._stat(prefix);
130218
130219 if (!this.matches[index]) this.matches[index] = Object.create(null); // If it doesn't exist, then just mark the lack of results
130220
130221 if (!exists) return;
130222
130223 if (prefix && isAbsolute(prefix) && !this.nomount) {
130224 var trail = /[\/\\]$/.test(prefix);
130225
130226 if (prefix.charAt(0) === '/') {
130227 prefix = path.join(this.root, prefix);
130228 } else {
130229 prefix = path.resolve(this.root, prefix);
130230 if (trail) prefix += '/';
130231 }
130232 }
130233
130234 if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); // Mark this as a match
130235
130236 this._emitMatch(index, prefix);
130237 }; // Returns either 'DIR', 'FILE', or false
130238
130239
130240 GlobSync.prototype._stat = function (f) {
130241 var abs = this._makeAbs(f);
130242
130243 var needDir = f.slice(-1) === '/';
130244 if (f.length > this.maxLength) return false;
130245
130246 if (!this.stat && ownProp(this.cache, abs)) {
130247 var c = this.cache[abs];
130248 if (Array.isArray(c)) c = 'DIR'; // It exists, but maybe not how we need it
130249
130250 if (!needDir || c === 'DIR') return c;
130251 if (needDir && c === 'FILE') return false; // otherwise we have to stat, because maybe c=true
130252 // if we know it exists, but not what it is.
130253 }
130254
130255 var exists;
130256 var stat = this.statCache[abs];
130257
130258 if (!stat) {
130259 var lstat;
130260
130261 try {
130262 lstat = this.fs.lstatSync(abs);
130263 } catch (er) {
130264 if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
130265 this.statCache[abs] = false;
130266 return false;
130267 }
130268 }
130269
130270 if (lstat && lstat.isSymbolicLink()) {
130271 try {
130272 stat = this.fs.statSync(abs);
130273 } catch (er) {
130274 stat = lstat;
130275 }
130276 } else {
130277 stat = lstat;
130278 }
130279 }
130280
130281 this.statCache[abs] = stat;
130282 var c = true;
130283 if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE';
130284 this.cache[abs] = this.cache[abs] || c;
130285 if (needDir && c === 'FILE') return false;
130286 return c;
130287 };
130288
130289 GlobSync.prototype._mark = function (p) {
130290 return common.mark(this, p);
130291 };
130292
130293 GlobSync.prototype._makeAbs = function (f) {
130294 return common.makeAbs(this, f);
130295 };
130296
130297 /***/ }),
130298 /* 901 */
130299 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
130300
130301 /* provided dependency */ var process = __webpack_require__(494);
130302 exports.setopts = setopts;
130303 exports.ownProp = ownProp;
130304 exports.makeAbs = makeAbs;
130305 exports.finish = finish;
130306 exports.mark = mark;
130307 exports.isIgnored = isIgnored;
130308 exports.childrenIgnored = childrenIgnored;
130309
130310 function ownProp(obj, field) {
130311 return Object.prototype.hasOwnProperty.call(obj, field);
130312 }
130313
130314 var fs = __webpack_require__(861);
130315
130316 var path = __webpack_require__(429);
130317
130318 var minimatch = __webpack_require__(871);
130319
130320 var isAbsolute = __webpack_require__(899);
130321
130322 var Minimatch = minimatch.Minimatch;
130323
130324 function alphasort(a, b) {
130325 return a.localeCompare(b, 'en');
130326 }
130327
130328 function setupIgnores(self, options) {
130329 self.ignore = options.ignore || [];
130330 if (!Array.isArray(self.ignore)) self.ignore = [self.ignore];
130331
130332 if (self.ignore.length) {
130333 self.ignore = self.ignore.map(ignoreMap);
130334 }
130335 } // ignore patterns are always in dot:true mode.
130336
130337
130338 function ignoreMap(pattern) {
130339 var gmatcher = null;
130340
130341 if (pattern.slice(-3) === '/**') {
130342 var gpattern = pattern.replace(/(\/\*\*)+$/, '');
130343 gmatcher = new Minimatch(gpattern, {
130344 dot: true
130345 });
130346 }
130347
130348 return {
130349 matcher: new Minimatch(pattern, {
130350 dot: true
130351 }),
130352 gmatcher: gmatcher
130353 };
130354 }
130355
130356 function setopts(self, pattern, options) {
130357 if (!options) options = {}; // base-matching: just use globstar for that.
130358
130359 if (options.matchBase && -1 === pattern.indexOf("/")) {
130360 if (options.noglobstar) {
130361 throw new Error("base matching requires globstar");
130362 }
130363
130364 pattern = "**/" + pattern;
130365 }
130366
130367 self.silent = !!options.silent;
130368 self.pattern = pattern;
130369 self.strict = options.strict !== false;
130370 self.realpath = !!options.realpath;
130371 self.realpathCache = options.realpathCache || Object.create(null);
130372 self.follow = !!options.follow;
130373 self.dot = !!options.dot;
130374 self.mark = !!options.mark;
130375 self.nodir = !!options.nodir;
130376 if (self.nodir) self.mark = true;
130377 self.sync = !!options.sync;
130378 self.nounique = !!options.nounique;
130379 self.nonull = !!options.nonull;
130380 self.nosort = !!options.nosort;
130381 self.nocase = !!options.nocase;
130382 self.stat = !!options.stat;
130383 self.noprocess = !!options.noprocess;
130384 self.absolute = !!options.absolute;
130385 self.fs = options.fs || fs;
130386 self.maxLength = options.maxLength || Infinity;
130387 self.cache = options.cache || Object.create(null);
130388 self.statCache = options.statCache || Object.create(null);
130389 self.symlinks = options.symlinks || Object.create(null);
130390 setupIgnores(self, options);
130391 self.changedCwd = false;
130392 var cwd = process.cwd();
130393 if (!ownProp(options, "cwd")) self.cwd = cwd;else {
130394 self.cwd = path.resolve(options.cwd);
130395 self.changedCwd = self.cwd !== cwd;
130396 }
130397 self.root = options.root || path.resolve(self.cwd, "/");
130398 self.root = path.resolve(self.root);
130399 if (process.platform === "win32") self.root = self.root.replace(/\\/g, "/"); // TODO: is an absolute `cwd` supposed to be resolved against `root`?
130400 // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
130401
130402 self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
130403 if (process.platform === "win32") self.cwdAbs = self.cwdAbs.replace(/\\/g, "/");
130404 self.nomount = !!options.nomount; // disable comments and negation in Minimatch.
130405 // Note that they are not supported in Glob itself anyway.
130406
130407 options.nonegate = true;
130408 options.nocomment = true;
130409 self.minimatch = new Minimatch(pattern, options);
130410 self.options = self.minimatch.options;
130411 }
130412
130413 function finish(self) {
130414 var nou = self.nounique;
130415 var all = nou ? [] : Object.create(null);
130416
130417 for (var i = 0, l = self.matches.length; i < l; i++) {
130418 var matches = self.matches[i];
130419
130420 if (!matches || Object.keys(matches).length === 0) {
130421 if (self.nonull) {
130422 // do like the shell, and spit out the literal glob
130423 var literal = self.minimatch.globSet[i];
130424 if (nou) all.push(literal);else all[literal] = true;
130425 }
130426 } else {
130427 // had matches
130428 var m = Object.keys(matches);
130429 if (nou) all.push.apply(all, m);else m.forEach(function (m) {
130430 all[m] = true;
130431 });
130432 }
130433 }
130434
130435 if (!nou) all = Object.keys(all);
130436 if (!self.nosort) all = all.sort(alphasort); // at *some* point we statted all of these
130437
130438 if (self.mark) {
130439 for (var i = 0; i < all.length; i++) {
130440 all[i] = self._mark(all[i]);
130441 }
130442
130443 if (self.nodir) {
130444 all = all.filter(function (e) {
130445 var notDir = !/\/$/.test(e);
130446 var c = self.cache[e] || self.cache[makeAbs(self, e)];
130447 if (notDir && c) notDir = c !== 'DIR' && !Array.isArray(c);
130448 return notDir;
130449 });
130450 }
130451 }
130452
130453 if (self.ignore.length) all = all.filter(function (m) {
130454 return !isIgnored(self, m);
130455 });
130456 self.found = all;
130457 }
130458
130459 function mark(self, p) {
130460 var abs = makeAbs(self, p);
130461 var c = self.cache[abs];
130462 var m = p;
130463
130464 if (c) {
130465 var isDir = c === 'DIR' || Array.isArray(c);
130466 var slash = p.slice(-1) === '/';
130467 if (isDir && !slash) m += '/';else if (!isDir && slash) m = m.slice(0, -1);
130468
130469 if (m !== p) {
130470 var mabs = makeAbs(self, m);
130471 self.statCache[mabs] = self.statCache[abs];
130472 self.cache[mabs] = self.cache[abs];
130473 }
130474 }
130475
130476 return m;
130477 } // lotta situps...
130478
130479
130480 function makeAbs(self, f) {
130481 var abs = f;
130482
130483 if (f.charAt(0) === '/') {
130484 abs = path.join(self.root, f);
130485 } else if (isAbsolute(f) || f === '') {
130486 abs = f;
130487 } else if (self.changedCwd) {
130488 abs = path.resolve(self.cwd, f);
130489 } else {
130490 abs = path.resolve(f);
130491 }
130492
130493 if (process.platform === 'win32') abs = abs.replace(/\\/g, '/');
130494 return abs;
130495 } // Return true, if pattern ends with globstar '**', for the accompanying parent directory.
130496 // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
130497
130498
130499 function isIgnored(self, path) {
130500 if (!self.ignore.length) return false;
130501 return self.ignore.some(function (item) {
130502 return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path));
130503 });
130504 }
130505
130506 function childrenIgnored(self, path) {
130507 if (!self.ignore.length) return false;
130508 return self.ignore.some(function (item) {
130509 return !!(item.gmatcher && item.gmatcher.match(path));
130510 });
130511 }
130512
130513 /***/ }),
130514 /* 902 */
130515 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
130516
130517 /* provided dependency */ var process = __webpack_require__(494);
130518 var wrappy = __webpack_require__(903);
130519
130520 var reqs = Object.create(null);
130521
130522 var once = __webpack_require__(904);
130523
130524 module.exports = wrappy(inflight);
130525
130526 function inflight(key, cb) {
130527 if (reqs[key]) {
130528 reqs[key].push(cb);
130529 return null;
130530 } else {
130531 reqs[key] = [cb];
130532 return makeres(key);
130533 }
130534 }
130535
130536 function makeres(key) {
130537 return once(function RES() {
130538 var cbs = reqs[key];
130539 var len = cbs.length;
130540 var args = slice(arguments); // XXX It's somewhat ambiguous whether a new callback added in this
130541 // pass should be queued for later execution if something in the
130542 // list of callbacks throws, or if it should just be discarded.
130543 // However, it's such an edge case that it hardly matters, and either
130544 // choice is likely as surprising as the other.
130545 // As it happens, we do go ahead and schedule it for later execution.
130546
130547 try {
130548 for (var i = 0; i < len; i++) {
130549 cbs[i].apply(null, args);
130550 }
130551 } finally {
130552 if (cbs.length > len) {
130553 // added more in the interim.
130554 // de-zalgo, just in case, but don't call again.
130555 cbs.splice(0, len);
130556 process.nextTick(function () {
130557 RES.apply(null, args);
130558 });
130559 } else {
130560 delete reqs[key];
130561 }
130562 }
130563 });
130564 }
130565
130566 function slice(args) {
130567 var length = args.length;
130568 var array = [];
130569
130570 for (var i = 0; i < length; i++) array[i] = args[i];
130571
130572 return array;
130573 }
130574
130575 /***/ }),
130576 /* 903 */
130577 /***/ ((module) => {
130578
130579 // Returns a wrapper function that returns a wrapped callback
130580 // The wrapper function should do some stuff, and return a
130581 // presumably different callback function.
130582 // This makes sure that own properties are retained, so that
130583 // decorations and such are not lost along the way.
130584 module.exports = wrappy;
130585
130586 function wrappy(fn, cb) {
130587 if (fn && cb) return wrappy(fn)(cb);
130588 if (typeof fn !== 'function') throw new TypeError('need wrapper function');
130589 Object.keys(fn).forEach(function (k) {
130590 wrapper[k] = fn[k];
130591 });
130592 return wrapper;
130593
130594 function wrapper() {
130595 var args = new Array(arguments.length);
130596
130597 for (var i = 0; i < args.length; i++) {
130598 args[i] = arguments[i];
130599 }
130600
130601 var ret = fn.apply(this, args);
130602 var cb = args[args.length - 1];
130603
130604 if (typeof ret === 'function' && ret !== cb) {
130605 Object.keys(cb).forEach(function (k) {
130606 ret[k] = cb[k];
130607 });
130608 }
130609
130610 return ret;
130611 }
130612 }
130613
130614 /***/ }),
130615 /* 904 */
130616 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
130617
130618 var wrappy = __webpack_require__(903);
130619
130620 module.exports = wrappy(once);
130621 module.exports.strict = wrappy(onceStrict);
130622 once.proto = once(function () {
130623 Object.defineProperty(Function.prototype, 'once', {
130624 value: function () {
130625 return once(this);
130626 },
130627 configurable: true
130628 });
130629 Object.defineProperty(Function.prototype, 'onceStrict', {
130630 value: function () {
130631 return onceStrict(this);
130632 },
130633 configurable: true
130634 });
130635 });
130636
130637 function once(fn) {
130638 var f = function () {
130639 if (f.called) return f.value;
130640 f.called = true;
130641 return f.value = fn.apply(this, arguments);
130642 };
130643
130644 f.called = false;
130645 return f;
130646 }
130647
130648 function onceStrict(fn) {
130649 var f = function () {
130650 if (f.called) throw new Error(f.onceError);
130651 f.called = true;
130652 return f.value = fn.apply(this, arguments);
130653 };
130654
130655 var name = fn.name || 'Function wrapped with `once`';
130656 f.onceError = name + " shouldn't be called more than once";
130657 f.called = false;
130658 return f;
130659 }
130660
130661 /***/ }),
130662 /* 905 */
130663 /***/ ((module) => {
130664
130665 module.exports = function (obj, opts) {
130666 if (!opts) opts = {};
130667 if (typeof opts === 'function') opts = {
130668 cmp: opts
130669 };
130670 var space = opts.space || '';
130671 if (typeof space === 'number') space = Array(space + 1).join(' ');
130672 var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false;
130673
130674 var replacer = opts.replacer || function (key, value) {
130675 return value;
130676 };
130677
130678 var cmp = opts.cmp && function (f) {
130679 return function (node) {
130680 return function (a, b) {
130681 var aobj = {
130682 key: a,
130683 value: node[a]
130684 };
130685 var bobj = {
130686 key: b,
130687 value: node[b]
130688 };
130689 return f(aobj, bobj);
130690 };
130691 };
130692 }(opts.cmp);
130693
130694 var seen = [];
130695 return function stringify(parent, key, node, level) {
130696 var indent = space ? '\n' + new Array(level + 1).join(space) : '';
130697 var colonSeparator = space ? ': ' : ':';
130698
130699 if (node && node.toJSON && typeof node.toJSON === 'function') {
130700 node = node.toJSON();
130701 }
130702
130703 node = replacer.call(parent, key, node);
130704
130705 if (node === undefined) {
130706 return;
130707 }
130708
130709 if (typeof node !== 'object' || node === null) {
130710 return JSON.stringify(node);
130711 }
130712
130713 if (isArray(node)) {
130714 var out = [];
130715
130716 for (var i = 0; i < node.length; i++) {
130717 var item = stringify(node, i, node[i], level + 1) || JSON.stringify(null);
130718 out.push(indent + space + item);
130719 }
130720
130721 return '[' + out.join(',') + indent + ']';
130722 } else {
130723 if (seen.indexOf(node) !== -1) {
130724 if (cycles) return JSON.stringify('__cycle__');
130725 throw new TypeError('Converting circular structure to JSON');
130726 } else seen.push(node);
130727
130728 var keys = objectKeys(node).sort(cmp && cmp(node));
130729 var out = [];
130730
130731 for (var i = 0; i < keys.length; i++) {
130732 var key = keys[i];
130733 var value = stringify(node, key, node[key], level + 1);
130734 if (!value) continue;
130735 var keyValue = JSON.stringify(key) + colonSeparator + value;
130736 ;
130737 out.push(indent + space + keyValue);
130738 }
130739
130740 seen.splice(seen.indexOf(node), 1);
130741 return '{' + out.join(',') + indent + '}';
130742 }
130743 }({
130744 '': obj
130745 }, '', obj, 0);
130746 };
130747
130748 var isArray = Array.isArray || function (x) {
130749 return {}.toString.call(x) === '[object Array]';
130750 };
130751
130752 var objectKeys = Object.keys || function (obj) {
130753 var has = Object.prototype.hasOwnProperty || function () {
130754 return true;
130755 };
130756
130757 var keys = [];
130758
130759 for (var key in obj) {
130760 if (has.call(obj, key)) keys.push(key);
130761 }
130762
130763 return keys;
130764 };
130765
130766 /***/ })
130767 /******/ ]);
130768 /************************************************************************/
130769 /******/ // The module cache
130770 /******/ var __webpack_module_cache__ = {};
130771 /******/
130772 /******/ // The require function
130773 /******/ function __webpack_require__(moduleId) {
130774 /******/ // Check if module is in cache
130775 /******/ var cachedModule = __webpack_module_cache__[moduleId];
130776 /******/ if (cachedModule !== undefined) {
130777 /******/ return cachedModule.exports;
130778 /******/ }
130779 /******/ // Create a new module (and put it into the cache)
130780 /******/ var module = __webpack_module_cache__[moduleId] = {
130781 /******/ id: moduleId,
130782 /******/ loaded: false,
130783 /******/ exports: {}
130784 /******/ };
130785 /******/
130786 /******/ // Execute the module function
130787 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
130788 /******/
130789 /******/ // Flag the module as loaded
130790 /******/ module.loaded = true;
130791 /******/
130792 /******/ // Return the exports of the module
130793 /******/ return module.exports;
130794 /******/ }
130795 /******/
130796 /******/ // expose the module cache
130797 /******/ __webpack_require__.c = __webpack_module_cache__;
130798 /******/
130799 /************************************************************************/
130800 /******/ /* webpack/runtime/hasOwnProperty shorthand */
130801 /******/ (() => {
130802 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
130803 /******/ })();
130804 /******/
130805 /******/ /* webpack/runtime/node module decorator */
130806 /******/ (() => {
130807 /******/ __webpack_require__.nmd = (module) => {
130808 /******/ module.paths = [];
130809 /******/ if (!module.children) module.children = [];
130810 /******/ return module;
130811 /******/ };
130812 /******/ })();
130813 /******/
130814 /************************************************************************/
130815 /******/
130816 /******/ // module cache are used so entry inlining is disabled
130817 /******/ // startup
130818 /******/ // Load entry module and return exports
130819 /******/ __webpack_require__(0);
130820 /******/ __webpack_require__(427);
130821 /******/ __webpack_require__(428);
130822 /******/ var __webpack_exports__ = __webpack_require__(859);
130823 /******/
130824 /******/ return __webpack_exports__;
130825 /******/ })()
130826 ;
130827 });